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 artist = await this.getPrimaryArtist(attributes)
|
||||||
|
const album = this.getAlbumName(attributes)
|
||||||
|
|
||||||
if (currentAttributes.status && currentAttributes === attributes) {
|
if (currentAttributes.status && currentAttributes === attributes) {
|
||||||
if (fs.existsSync(this.sessionPath)) {
|
if (fs.existsSync(this.sessionPath)) {
|
||||||
|
@ -101,7 +102,7 @@ export default class LastFMPlugin {
|
||||||
self._lastfm.track.scrobble({
|
self._lastfm.track.scrobble({
|
||||||
'artist': artist,
|
'artist': artist,
|
||||||
'track': attributes.name,
|
'track': attributes.name,
|
||||||
'album': attributes.albumName,
|
'album': album,
|
||||||
'albumArtist': artist,
|
'albumArtist': artist,
|
||||||
'timestamp': new Date().getTime() / 1000
|
'timestamp': new Date().getTime() / 1000
|
||||||
}, function (err: any, scrobbled: any) {
|
}, function (err: any, scrobbled: any) {
|
||||||
|
@ -133,13 +134,14 @@ export default class LastFMPlugin {
|
||||||
|
|
||||||
if (fs.existsSync(this.sessionPath)) {
|
if (fs.existsSync(this.sessionPath)) {
|
||||||
const artist = await this.getPrimaryArtist(attributes)
|
const artist = await this.getPrimaryArtist(attributes)
|
||||||
|
const album = this.getAlbumName(attributes)
|
||||||
|
|
||||||
// update Now Playing
|
// update Now Playing
|
||||||
if (attributes.status === true) {
|
if (attributes.status === true) {
|
||||||
this._lastfm.track.updateNowPlaying({
|
this._lastfm.track.updateNowPlaying({
|
||||||
'artist': artist,
|
'artist': artist,
|
||||||
'track': attributes.name,
|
'track': attributes.name,
|
||||||
'album': attributes.albumName,
|
'album': album,
|
||||||
'albumArtist': artist
|
'albumArtist': artist
|
||||||
}, function (err: any, nowPlaying: any) {
|
}, function (err: any, nowPlaying: any) {
|
||||||
if (err) {
|
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) {
|
private async getPrimaryArtist(attributes: any) {
|
||||||
const songId = attributes.playParams.catalogId || attributes.playParams.id
|
const songId = attributes.playParams.catalogId || attributes.playParams.id
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue