Skip to content

Commit

Permalink
Use splat args for media identification on plex/tautulli debug
Browse files Browse the repository at this point in the history
  • Loading branch information
FoxxMD committed Nov 24, 2020
1 parent f981f9e commit aa95604
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
16 changes: 12 additions & 4 deletions sources/PlexSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,20 +59,28 @@ export default class PlexSource {
}

isValidEvent = (playObj) => {
const {meta: {mediaType, title, event, user}} = playObj;
const {
meta: {
mediaType, event, user
},
data: {
artist,
track,
} = {}
} = playObj;

if (this.users !== undefined && user !== undefined && !this.users.includes(user)) {
this.logger.debug(`Will not scrobble webhook event because author was not an allowed user: ${user}`)
this.logger.debug(`Will not scrobble webhook event because author was not an allowed user: ${user}`, artist, track)
return false;
}

if (event !== 'media.scrobble') {
this.logger.debug(`Will not scrobble webhook event because it is not media.scrobble (${event})`)
this.logger.debug(`Will not scrobble webhook event because it is not media.scrobble (${event})`, artist, track)
return false;
}

if (mediaType !== 'track') {
this.logger.debug(`Will not scrobble webhook event because media type was not a track (${mediaType}). Item: ${title}`);
this.logger.debug(`Will not scrobble webhook event because media type was not a track (${mediaType})`, artist, track);
return false;
}

Expand Down
14 changes: 11 additions & 3 deletions sources/TautulliSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,22 @@ export default class TautulliSource extends PlexSource {
}

isValidEvent = (playObj) => {
const {meta: {mediaType, title, user}} = playObj;
const {
meta: {
mediaType, user
},
data: {
artist,
track,
} = {}
} = playObj;

if (this.users !== undefined && user !== undefined && !this.users.includes(user)) {
this.logger.debug(`Will not scrobble webhook event because author was not an allowed user: ${user}`)
this.logger.debug(`Will not scrobble webhook event because author was not an allowed user: ${user}`, artist, track)
return false;
}
if (mediaType !== 'track') {
this.logger.debug(`Will not scrobble webhook event because media type was not a track (${mediaType}). Item: ${title}`);
this.logger.debug(`Will not scrobble webhook event because media type was not a track (${mediaType})`, artist, track);
return false;
}
return true;
Expand Down

0 comments on commit aa95604

Please sign in to comment.