refactor: Make scrobbled data transform responsibility of concrete scrobbler class

This commit is contained in:
FoxxMD
2023-03-10 11:23:15 -05:00
parent 9ab0468913
commit ca148f490e
3 changed files with 4 additions and 4 deletions
+2 -2
View File
@@ -158,8 +158,8 @@ export default abstract class AbstractScrobbleClient {
return [validTime, log]
}
addScrobbledTrack = (playObj: any, scrobbleResp: any) => {
this.scrobbledPlayObjs.push({play: playObj, scrobble: this.formatPlayObj(scrobbleResp)});
addScrobbledTrack = (playObj: PlayObject, scrobbledPlay: PlayObject) => {
this.scrobbledPlayObjs.push({play: playObj, scrobble: scrobbledPlay});
}
cleanSourceSearchTitle = (playObj: PlayObject) => {
+1 -1
View File
@@ -179,7 +179,7 @@ export default class LastfmScrobbler extends AbstractScrobbleClient {
this.initialized = false;
throw new Error('Service reported daily scrobble limit exceeded! 😬 Disabling client');
}
this.addScrobbledTrack(playObj, {...rest, date: { uts: timestamp}, name: trackName});
this.addScrobbledTrack(playObj, this.formatPlayObj({...rest, date: { uts: timestamp}, name: trackName}));
if (newFromSource) {
this.logger.info(`Scrobbled (New) => (${source}) ${buildTrackString(playObj)}`);
} else {
+1 -1
View File
@@ -436,7 +436,7 @@ export default class MalojaScrobbler extends AbstractScrobbleClient {
} = {}} = response;
scrobbleResponse = {...rest, album: mAlbum, time: mTime, duration: mDuration};
}
this.addScrobbledTrack(playObj, scrobbleResponse);
this.addScrobbledTrack(playObj, this.formatPlayObj(scrobbleResponse));
if (newFromSource) {
this.logger.info(`Scrobbled (New) => (${source}) ${buildTrackString(playObj)}`);
} else {