Merge pull request #504 from inalone/filterAlbumNameFromDev

last.fm: initial implementation of filterAlbumName
This commit is contained in:
vapormusic 2022-02-22 20:01:16 +07:00 committed by GitHub
commit 9c958d531c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 3 deletions

View file

@ -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

View file

@ -889,4 +889,4 @@
}
}
})
</script>
</script>