Skip to content

Conversation

@0xSysR3ll
Copy link
Contributor

@0xSysR3ll 0xSysR3ll commented Jan 14, 2026

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:

  • ratingKey4k points to a separate item from ratingKey (ensures they're distinct items)
  • For movies: the media has 4K resolution (width >= 2000)
  • For TV shows: at least one season has 4K episodes (width >= 2000)

If the ratingKey remains 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.

  • Fixes #XXXX

How Has This Been Tested?

See this ticket

Screenshots / Logs (if applicable)

Checklist:

  • I have read and followed the contribution guidelines.
  • Disclosed any use of AI (see our policy)
  • I have updated the documentation accordingly.
  • All new and existing tests passed.
  • Successful build pnpm build
  • Translation keys pnpm i18n:extract
  • Database migration (if required)

Signed-off-by: 0xsysr3ll <0xsysr3ll@pm.me>
Copy link
Contributor

Copilot AI left a 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 ratingKey4k differs from ratingKey to 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>
@0xSysR3ll 0xSysR3ll force-pushed the 0xsysr3ll/fix/plex-4k-availability-sync branch from ec14024 to 2dc6a99 Compare January 15, 2026 21:13
@fallenbagel fallenbagel requested a review from Copilot January 16, 2026 03:25
Copy link
Contributor

Copilot AI left a 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.

Comment on lines +889 to +915
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;
}
}
}
Copy link

Copilot AI Jan 16, 2026

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.

Copilot uses AI. Check for mistakes.
@fallenbagel fallenbagel added the bug Something isn't working label Jan 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants