diff --git a/client/components/modals/item/tabs/Match.vue b/client/components/modals/item/tabs/Match.vue index f76f3bab2..193a7eb21 100644 --- a/client/components/modals/item/tabs/Match.vue +++ b/client/components/modals/item/tabs/Match.vue @@ -475,6 +475,7 @@ export default { explicit: true, asin: true, isbn: true, + rating: true, abridged: true, // Podcast specific itunesPageUrl: true, @@ -585,16 +586,6 @@ export default { var updatePayload = {} updatePayload.metadata = {} - // Always include rating if it exists in the match - if (this.selectedMatch?.rating !== undefined && this.selectedMatch?.rating !== null) { - const ratingValue = Number(this.selectedMatch.rating) - if (!isNaN(ratingValue) && ratingValue > 0) { - updatePayload.metadata.rating = ratingValue - } else if (ratingValue === 0 || isNaN(ratingValue)) { - updatePayload.metadata.rating = undefined - } - } - for (const key in this.selectedMatchUsage) { if (this.selectedMatchUsage[key] && this.selectedMatch[key] !== undefined && this.selectedMatch[key] !== null) { if (key === 'series') { @@ -636,9 +627,11 @@ export default { } else if (key === 'itunesId') { updatePayload.metadata.itunesId = Number(this.selectedMatch[key]) } else if (key === 'rating') { - const ratingValue = typeof this.selectedMatch[key] === 'object' && this.selectedMatch[key].average ? this.selectedMatch[key].average : Number(this.selectedMatch[key]) + const ratingValue = Number(this.selectedMatch[key]) if (!isNaN(ratingValue) && ratingValue > 0) { updatePayload.metadata.rating = ratingValue + } else if (ratingValue === 0 || isNaN(ratingValue)) { + updatePayload.metadata.rating = undefined } } else { updatePayload.metadata[key] = this.selectedMatch[key] diff --git a/server/scanner/Scanner.js b/server/scanner/Scanner.js index a986d2252..bd1d4091a 100644 --- a/server/scanner/Scanner.js +++ b/server/scanner/Scanner.js @@ -231,15 +231,17 @@ class Scanner { updatePayload[key] = tagsArray } } else if (key === 'rating') { - // Normalize rating: convert object with average to number, or number to number + // Normalize rating (handle object format {average: 4.5} from some providers) let ratingValue = matchData[key] if (ratingValue && typeof ratingValue === 'object' && ratingValue.average) { - ratingValue = Number(ratingValue.average) || null + ratingValue = Number(ratingValue.average) } else if (ratingValue !== undefined && ratingValue !== null) { - ratingValue = Number(ratingValue) || null + ratingValue = Number(ratingValue) + } else { + ratingValue = null } - if (ratingValue === 0) ratingValue = null - if ((!libraryItem.media.rating || options.overrideDetails) && ratingValue !== null && !isNaN(ratingValue) && ratingValue > 0) { + // 0 = no rating, only update if valid rating > 0 + if (ratingValue !== null && !isNaN(ratingValue) && ratingValue > 0 && (!libraryItem.media.rating || options.overrideDetails)) { updatePayload[key] = ratingValue } else if (ratingValue === null && libraryItem.media.rating && options.overrideDetails) { updatePayload[key] = null