fix(plex): Also read MBIDs from guid field#473
fix(plex): Also read MBIDs from guid field#473owendaprile wants to merge 1 commit intoFoxxMD:masterfrom
guid field#473Conversation
✅ Deploy Preview for multi-scrobbler ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
Hey @owendaprile can you take a look at the review? |
Not sure if I'm going crazy but I don't see one 😕. Or do you just mean to submit mine? |
src/backend/sources/PlexApiSource.ts
Outdated
| // the first MBID to be safe. | ||
| for (const metadata of result.MediaContainer.Metadata ?? []) { | ||
| metadataLoop: for (const metadata of result?.MediaContainer?.Metadata ?? []) { | ||
| this.logger.verbose(`Guid: '${metadata.Guid?.map(g => g.id)?.join(", ")}', guid: '${metadata.guid}'`) |
There was a problem hiding this comment.
This, and the Extracted MBID log statement further down, should use the debug level for logging. Preferably also gated behind isDebugMode(). Most users won't care about this information unless its wrong in which case they can enable it for troubleshooting using DEBUG_MODE=true. Otherwise its just noise in the logs.
There was a problem hiding this comment.
Actually, instead of gating with isDebugMode please use logger.trace()
There was a problem hiding this comment.
I changed them to trace but was not able to get them to log even with DEBUG_MODE=true. Was I missing something or is trace not implemented yet?
|
@owendaprile I never hit submit 😅 oops |
Some items on Plex store the MBID in the `guid` field in the `Metadata` response, not in the `Guid` field. This change checks the `guid` field as a fallback if the `Guid` field is not set.
b93c607 to
ebc0aa8
Compare
Checklist before requesting a review
Type of change
Describe your changes
Some items on Plex store the MBID in the
guidfield in theMetadataresponse, not in theGuidfield. This change checks theguidfield as a fallback if theGuidfield is not set.This seems to be very rare. I've only found it on one release in my library and it fixed itself after clicking "Fix Match..." and matching it again.
Example of an item with the MBID in `guid`
{ "MediaContainer": { "size": 1, "allowSync": true, "identifier": "com.plexapp.plugins.library", "librarySectionID": 1, "librarySectionTitle": "Music", "librarySectionUUID": "2bc6b969-87bf-4edb-a2a1-7020a3c6ef28", "mediaTagPrefix": "/system/bundle/media/flags/", "mediaTagVersion": 1770226015, "Metadata": [ { "ratingKey": "17362", "key": "/library/metadata/17362", "parentRatingKey": "17361", "grandparentRatingKey": "7933", "guid": "mbid://9bdba80b-e67e-4397-ac61-5fd8f4f9ede9", "parentGuid": "mbid://1b008cf8-f669-47d8-95bf-d8218441ca06", "grandparentGuid": "plex://artist/602458a7a49713002de8c87c", "type": "track", "title": "Gravitate", "grandparentKey": "/library/metadata/7933", "parentKey": "/library/metadata/17361", "librarySectionTitle": "Music", "librarySectionID": 1, "librarySectionKey": "/library/sections/1", "grandparentTitle": "wishlane", "parentTitle": "Gravitate / Cleft", "summary": "", "index": 1, "parentIndex": 1, "userRating": 7.0, "viewCount": 1, "lastViewedAt": 1771088420, "lastRatedAt": 1771088452, "parentYear": 2026, "thumb": "/library/metadata/17361/thumb/1771088468", "parentThumb": "/library/metadata/17361/thumb/1771088468", "grandparentThumb": "/library/metadata/7933/thumb/1760065861", "duration": 120000, "addedAt": 1771083563, "updatedAt": 1771088468, "musicAnalysisVersion": "1", "Media": [ { "id": 24285, "duration": 120000, "audioChannels": 2, "audioCodec": "flac", "container": "flac", "hasVoiceActivity": false, "Part": [ { "id": 30624, "key": "/library/parts/30624/1771083193/file.flac", "duration": 120000, "file": "/data/Music/wishlane/Gravitate _ Cleft/01 - wishlane - Gravitate.flac", "size": 16030818, "container": "flac", "hasThumbnail": "1", "Stream": [ { "id": 57928, "streamType": 2, "selected": true, "codec": "flac", "index": 0, "channels": 2, "bitrate": 1069, "albumGain": "-8.63", "albumPeak": "1.000000", "albumRange": "9.570543", "audioChannelLayout": "stereo", "bitDepth": 16, "gain": "-8.63", "loudness": "-9.37", "lra": "2.00", "peak": "1.000000", "samplingRate": 48000, "displayTitle": "FLAC (Stereo)", "extendedDisplayTitle": "FLAC (Stereo)" } ] } ] } ], "Image": [ { "alt": "Gravitate", "type": "coverPoster", "url": "/library/metadata/7933/thumb/1760065861" } ], "Field": [ { "locked": true, "name": "title" }, { "locked": true, "name": "originalTitle" }, { "locked": true, "name": "index" }, { "locked": true, "name": "parentIndex" } ] } ] } }Issue number and link, if applicable
N/A