Align TPDB scene mapping with Plex Metadata Response (adult flag, actor identity, external GUIDs) - #2
Merged
Merged
Conversation
Copilot
AI
changed the title
[WIP] Fix Plex image handling by adding missing images endpoint
Add Jun 4, 2026
/library/metadata/{rating_key}/images endpoint for Plex image lookups
Copilot
AI
changed the title
Add
Add legacy TPDB image-field compatibility for scene art and performer photos
Jun 4, 2026
/library/metadata/{rating_key}/images endpoint for Plex image lookups
Copilot
AI
changed the title
Add legacy TPDB image-field compatibility for scene art and performer photos
Improve TPDB image compatibility and mapper output quality for scenes/actors
Jun 4, 2026
Copilot
AI
changed the title
Improve TPDB image compatibility and mapper output quality for scenes/actors
Align TPDB scene mapping with Plex Metadata Response (adult flag, actor identity, external GUIDs)
Jun 4, 2026
adeze
marked this pull request as ready for review
June 4, 2026 07:48
There was a problem hiding this comment.
Pull request overview
This PR expands the TPDB→Plex mapping layer and provider API surface to better match Plex’s metadata expectations by adding an /images endpoint, enriching performer identity in Role, emitting external GUID mappings, and explicitly flagging adult content.
Changes:
- Added
GET /library/metadata/{rating_key}/imagesplus supportingMetadataService.get_images()and scene→image-entry mapping. - Extended scene mapping to always emit
isAdult = 1, add externalGuidentries (imdb/tmdb/tvdb/tpdb), and add stable performerRole.idvalues. - Updated and added tests covering the new mapping behavior and the
/imagesroute responses.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
provider/mappers/tpdb_to_plex.py |
Adds scene image extraction + /images mapping, GUID emission, adult flag, and richer performer role identity mapping. |
provider/services/metadata_service.py |
Centralizes get_scene() hydration and adds get_images() for the new route. |
provider/services/match_service.py |
Expands “has image” detection to include face fields during hydration decisions. |
provider/routes/metadata.py |
Adds the new GET /library/metadata/{rating_key}/images endpoint. |
provider/routes/manifest.py |
Advertises the images feature in the provider manifest. |
tests/test_tpdb_enrichment.py |
Adds assertions for adult/GUID/role-id behavior and new map_scene_to_images() behavior. |
tests/test_metadata_routes.py |
Introduces route-level tests for the new /images endpoint behavior (200/404/empty). |
README.md |
Documents the new /library/metadata/{id}/images endpoint. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+117
to
+139
| image_entries = [] | ||
| seen_urls: set[str] = set() | ||
| for image_type, image_url in scene_images.items(): | ||
| if image_url in seen_urls: | ||
| logger.debug( | ||
| "Skipping duplicate image url for scene=%s type=%s url=%s", | ||
| slug, | ||
| image_type, | ||
| image_url, | ||
| ) | ||
| continue | ||
| seen_urls.add(image_url) | ||
| image_entries.append( | ||
| { | ||
| "type": image_type, | ||
| "url": image_url, | ||
| "key": f"/library/metadata/{slug}/images/{image_type}", | ||
| "ratingKey": slug, | ||
| "provider": "tv.plex.agents.custom.tpdb", | ||
| } | ||
| ) | ||
|
|
||
| return image_entries |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR closes gaps between TPDB payloads and Plex’s richer metadata contract: explicit adult classification, stronger performer→actor identity mapping, and external ID mappings for faster/more-accurate cross-provider matching.
Adult-content classification
isAdultunconditionally in mapped scene outputs to reflect TPDB-only adult content.External identifier mapping (
Guidarray)Guidentries in Plex format (provider://id) sourced from TPDB scene fields and nested ID containers.imdb,tmdb,tvdb) plus TPDB-native identity (tpdb://...) for stable internal linkage.Performer → Plex
RoleenrichmentRoleentries with stable performer IDs (tpdb://performer/{id-or-slug}), in addition to existing tag/thumb mapping.idandslugare present.Coverage updates for new contract behavior
isAdult,Guidemission, performer ID precedence, and empty-image metadata response behavior.Original prompt
Fix Plex image handling in the repository
adeze/plex-tpdb-scanner.Problem:
GET /library/metadata/{rating_key}/imagesand the provider currently returns 404 because no such route exists.GET /POST /library/metadata/matchesGET /library/metadata/{rating_key}ratingKey/key, which is acceptable in the current design; the immediate bug is the missing/imagesendpoint.Repository context:
provider/main.pyprovider/routes/metadata.pyprovider/services/metadata_service.pyprovider/mappers/tpdb_to_plex.pymetadata_tool/api.pyPlease implement a proper fix with code changes and open a pull request.
Requirements:
GET /library/metadata/{rating_key}/images.rating_key(currently TPDB slug), hydrate as needed, and return Plex-compatible image data for poster/thumb/art/background if available./library/metadata/{rating_key}behavior.Docs to align with:
https://developer.plex.tv/pms/index.html#section/API-Info/Metadata-Providershttps://api.theporndb.net/docsExpected outcome:
mainthat fixes the missing images endpoint so Plex no longer gets 404 for/library/metadata/{rating_key}/imageswhen metadata is present.The following is the prior conversation context from the user's chat exploration (may be truncated):
User: how do i rebuild the container via docker compose?
Assistant: From the repo root, run:
That works because
docker-compose.ymlusesbuild: .for thetpdb-providerservice, so Compose will rebuild the image from the localDockerfileand recreate the container.If you want to force a clean rebuild, use:
Or in one go:
A few repo-specific notes:
docker-compose.ymlis the file to use for local rebuilds.docker-compose.portainer.ymluses a prebuilt image (ghcr.io/mystrock/plex-tpdb-scanner:latest), so that one does not rebuild from your local source.TPDB_API_KEYset in your shell or a.envfile before starting.Typical flow:
To verify it came back up:
If you want, I can also show you the best
docker composeworkflow for Apple Silicon specifically, including when to use--no-cache,down, and volume cleanup.User: do i need to turn off the current running container? how?
Assistant: Yes — usually you should stop and remove the currently running container before bringing up the rebuilt one, though
docker compose up -d --buildwill often recreate it for you automatically.Simplest safe approach from the repo directory:
What these do:
docker compose downstops and removes the existing container, network, and Compose-managed resources.docker compose up -d --buildrebuilds the image and starts a fresh container in the background.If you want minimal steps, this is often enough by itself:
Compose will detect the config/image change and replace the running container.
If you specifically want to stop just the running service first:
Useful checks:
If the old container was started outside Compose, remove it manually:
Recommended for your case: use this sequence:
cd plex-tpdb-scanner docker compose down docker compose up -d --buildIf you want, I can give you the exact command sequence for macOS zsh with your
TPDB_API_KEYincluded.User: i think there's an error since the logs show: