Skip to content

Commit dd7e971

Browse files
committed
Fix how scrobbled tracks are returned to source
Returns tracks array should only show that was a track was scrobbled or not (by existing in the array) -- and only be in the array once.
1 parent 1aee74b commit dd7e971

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

clients/ScrobbleClients.js

+12-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
import dayjs from "dayjs";
2-
import {createLabelledLogger, isValidConfigStructure, readJson, returnDuplicateStrings} from "../utils.js";
2+
import {
3+
createLabelledLogger,
4+
isValidConfigStructure,
5+
playObjDataMatch,
6+
readJson,
7+
returnDuplicateStrings
8+
} from "../utils.js";
39
import MalojaScrobbler from "./MalojaScrobbler.js";
410
import LastfmScrobbler from "./LastfmScrobbler.js";
511

@@ -242,7 +248,11 @@ ${sources.join('\n')}`);
242248
if (client.timeFrameIsValid(playObj, newFromSource) && !client.alreadyScrobbled(playObj, newFromSource)) {
243249
await client.scrobble(playObj)
244250
client.tracksScrobbled++;
245-
tracksScrobbled.push(playObj);
251+
// since this is what we return to the source only add to tracksScrobbled if not already in array
252+
// (source should only know that a track was scrobbled (binary) -- doesn't care if it was scrobbled more than once
253+
if(!tracksScrobbled.some(x => playObjDataMatch(x, playObj) && x.data.playDate === playObj.data.playDate)) {
254+
tracksScrobbled.push(playObj);
255+
}
246256
}
247257
} catch(e) {
248258
this.logger.error(`Encountered error while in scrobble loop for ${client.name}`);

0 commit comments

Comments
 (0)