-
-
Notifications
You must be signed in to change notification settings - Fork 557
fix(availability-sync): fix 4K media availability detection #2298
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
Signed-off-by: 0xsysr3ll <0xsysr3ll@pm.me>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR addresses a bug where 4K content was incorrectly shown as available after deletion when 4K and 1080p versions were stored in the same Plex library. The fix ensures that ratingKey4k is distinct from ratingKey and validates that movies have actual 4K resolution (width >= 2000).
Changes:
- Added validation to ensure
ratingKey4kdiffers fromratingKeyto detect separate library items - Added resolution verification for movies to confirm 4K status by checking media width >= 2000 pixels
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…shows Signed-off-by: 0xsysr3ll <0xsysr3ll@pm.me>
ec14024 to
2dc6a99
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if (plexMedia && media.mediaType === 'tv') { | ||
| const cachedSeasons = this.plexSeasonsCache[ratingKey4k]; | ||
| if (cachedSeasons?.length) { | ||
| let has4kInAnySeason = false; | ||
| for (const season of cachedSeasons) { | ||
| try { | ||
| const episodes = await this.plexClient?.getChildrenMetadata( | ||
| season.ratingKey | ||
| ); | ||
| const has4kEpisode = episodes?.some((episode) => | ||
| episode.Media?.some( | ||
| (mediaItem) => (mediaItem.width ?? 0) >= 2000 | ||
| ) | ||
| ); | ||
| if (has4kEpisode) { | ||
| has4kInAnySeason = true; | ||
| break; | ||
| } | ||
| } catch { | ||
| // If we can't fetch episodes for a season, continue checking other seasons | ||
| } | ||
| } | ||
| if (!has4kInAnySeason) { | ||
| plexMedia = undefined; | ||
| } | ||
| } | ||
| } |
Copilot
AI
Jan 16, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The TV show 4K validation makes an API call for every season to fetch episodes until finding one with 4K content. This could result in multiple sequential API calls (N+1 pattern) for shows with many seasons. Consider optimizing by: (1) caching episode metadata when seasons are cached, or (2) implementing parallel fetching with Promise.all() to reduce total wait time.
Description
This PR fixes an issue where 4K content was incorrectly shown as available after deletion when 4K and 1080p versions were stored in the same Plex library.
We now verify that:
ratingKey4kpoints to a separate item from ratingKey (ensures they're distinct items)If the
ratingKeyremains the same after deletion, it now checks the actual resolution before marking content as 4K available, preventing false positives when 4K content is deleted but the 1080p version remains.How Has This Been Tested?
See this ticket
Screenshots / Logs (if applicable)
Checklist:
pnpm buildpnpm i18n:extract