Merge pull request #504 from inalone/filterAlbumNameFromDev
last.fm: initial implementation of filterAlbumName
This commit is contained in:
commit
9c958d531c
2 changed files with 9 additions and 3 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -889,4 +889,4 @@
|
|||
}
|
||||
}
|
||||
})
|
||||
</script>
|
||||
</script>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue