last.fm: initial implementation of filterAlbumName

This commit is contained in:
inalone 2022-02-22 01:22:00 +00:00
parent ddf8d05204
commit 1f7f2e2174
4 changed files with 20 additions and 3 deletions

View file

@ -101,7 +101,7 @@ export default class LastFMPlugin {
self._lastfm.track.scrobble({
'artist': artist,
'track': attributes.name,
'album': attributes.albumName,
'album': this.getAlbumName(attributes),
'albumArtist': artist,
'timestamp': new Date().getTime() / 1000
}, function (err: any, scrobbled: any) {
@ -139,7 +139,7 @@ export default class LastFMPlugin {
this._lastfm.track.updateNowPlaying({
'artist': artist,
'track': attributes.name,
'album': attributes.albumName,
'album': this.getAlbumName(attributes),
'albumArtist': artist
}, function (err: any, nowPlaying: any) {
if (err) {
@ -156,6 +156,14 @@ export default class LastFMPlugin {
}
}
private getAlbumName(attributes: any): string {
if (!this._store.lastfm.filterAlbumName) {
return attributes.albumName;
}
return attributes.albumName.replace(/ - Single| - EP/g, '');
}
private async getPrimaryArtist(attributes: any) {
const songId = attributes.playParams.catalogId || attributes.playParams.id