diff --git a/src/main/plugins/lastfm.ts b/src/main/plugins/lastfm.ts index 019a7b2c..2ac0a000 100644 --- a/src/main/plugins/lastfm.ts +++ b/src/main/plugins/lastfm.ts @@ -93,6 +93,7 @@ export default class LastFMPlugin { } const artist = await this.getPrimaryArtist(attributes) + const album = this.getAlbumName(attributes) if (currentAttributes.status && currentAttributes === attributes) { if (fs.existsSync(this.sessionPath)) { @@ -101,7 +102,7 @@ export default class LastFMPlugin { self._lastfm.track.scrobble({ 'artist': artist, 'track': attributes.name, - 'album': attributes.albumName, + 'album': album, 'albumArtist': artist, 'timestamp': new Date().getTime() / 1000 }, function (err: any, scrobbled: any) { @@ -133,13 +134,14 @@ export default class LastFMPlugin { if (fs.existsSync(this.sessionPath)) { const artist = await this.getPrimaryArtist(attributes) + const album = this.getAlbumName(attributes) // update Now Playing if (attributes.status === true) { this._lastfm.track.updateNowPlaying({ 'artist': artist, 'track': attributes.name, - 'album': attributes.albumName, + 'album': album, 'albumArtist': artist }, function (err: any, nowPlaying: any) { if (err) { @@ -156,6 +158,10 @@ export default class LastFMPlugin { } } + private getAlbumName(attributes: any): string { + return attributes.albumName.replace(/ - Single| - EP/g, ''); + } + private async getPrimaryArtist(attributes: any) { const songId = attributes.playParams.catalogId || attributes.playParams.id diff --git a/src/renderer/views/pages/settings.ejs b/src/renderer/views/pages/settings.ejs index dbc4e240..5b058845 100644 --- a/src/renderer/views/pages/settings.ejs +++ b/src/renderer/views/pages/settings.ejs @@ -889,4 +889,4 @@ } } }) - \ No newline at end of file +