Skip to content

fix(plex): Also read MBIDs from guid field#473

Open
owendaprile wants to merge 1 commit intoFoxxMD:masterfrom
owendaprile:push-ovmumqzwvmqx
Open

fix(plex): Also read MBIDs from guid field#473
owendaprile wants to merge 1 commit intoFoxxMD:masterfrom
owendaprile:push-ovmumqzwvmqx

Conversation

@owendaprile
Copy link
Contributor

Checklist before requesting a review

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Describe your changes

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.

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

@netlify
Copy link

netlify bot commented Feb 15, 2026

Deploy Preview for multi-scrobbler ready!

Name Link
🔨 Latest commit ebc0aa8
🔍 Latest deploy log https://app.netlify.com/projects/multi-scrobbler/deploys/69b0b64f29d4bc0008d07f43
😎 Deploy Preview https://deploy-preview-473--multi-scrobbler.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@FoxxMD
Copy link
Owner

FoxxMD commented Mar 4, 2026

Hey @owendaprile can you take a look at the review?

@owendaprile
Copy link
Contributor Author

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?

// 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}'`)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, instead of gating with isDebugMode please use logger.trace()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

@FoxxMD
Copy link
Owner

FoxxMD commented Mar 5, 2026

@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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants