Skip to content

Commit

Permalink
fix: Handle when no existing scrobble match with score greater than 0 #…
Browse files Browse the repository at this point in the history
  • Loading branch information
FoxxMD committed Feb 8, 2024
1 parent 4e45d35 commit be9675b
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/backend/scrobblers/AbstractScrobbleClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ export default abstract class AbstractScrobbleClient implements Authenticatable
}

let existingScrobble;
let closestMatch: {score: number, breakdowns: string[], confidence: string, scrobble?: PlayObject} = {score: 0, breakdowns: [], confidence: 'None'};
let closestMatch: {score: number, breakdowns: string[], confidence: string, scrobble?: PlayObject} = {score: 0, breakdowns: [], confidence: 'No existing scrobble matched with a score higher than 0'};

// then check if we have already recorded this
const [existingExactSubmitted, existingDataSubmitted = []] = this.findExistingSubmittedPlayObj(playObj);
Expand Down Expand Up @@ -419,9 +419,13 @@ export default abstract class AbstractScrobbleClient implements Authenticatable
}

if ((existingScrobble !== undefined && this.verboseOptions.match.onMatch) || (existingScrobble === undefined && this.verboseOptions.match.onNoMatch)) {
const closestScrobble = `Closest Scrobble: ${buildTrackString(closestMatch.scrobble, scoreTrackOpts)} => ${closestMatch.confidence}`;
this.logger.debug(`${capitalize(playObj.meta.source ?? 'Source')}: ${buildTrackString(playObj, scoreTrackOpts)} => ${closestScrobble}`, {leaf: ['Dupe Check']});
if (this.verboseOptions.match.confidenceBreakdown === true) {
const closestScrobbleParts: string[] = [];
if(closestMatch.scrobble !== undefined) {
closestScrobbleParts.push(`Closest Scrobble: ${buildTrackString(closestMatch.scrobble, scoreTrackOpts)}`);
}
closestScrobbleParts.push(closestMatch.confidence);
this.logger.debug(`${capitalize(playObj.meta.source ?? 'Source')}: ${buildTrackString(playObj, scoreTrackOpts)} => ${closestScrobbleParts.join(' => ')}`, {leaf: ['Dupe Check']});
if (this.verboseOptions.match.confidenceBreakdown === true && closestMatch.breakdowns.length > 0) {
this.logger.debug(`Breakdown:
${closestMatch.breakdowns.join('\n')}`, {leaf: ['Dupe Check']});
}
Expand Down

0 comments on commit be9675b

Please sign in to comment.