fix(availability-sync): fix 4K media availability detection (#2298)
This commit is contained in:
@@ -816,6 +816,50 @@ class AvailabilitySync {
|
|||||||
this.plexSeasonsCache[ratingKey4k] =
|
this.plexSeasonsCache[ratingKey4k] =
|
||||||
await this.plexClient?.getChildrenMetadata(ratingKey4k);
|
await this.plexClient?.getChildrenMetadata(ratingKey4k);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (plexMedia) {
|
||||||
|
if (ratingKey === ratingKey4k) {
|
||||||
|
plexMedia = undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
plexMedia &&
|
||||||
|
media.mediaType === 'movie' &&
|
||||||
|
!plexMedia.Media?.some(
|
||||||
|
(mediaItem) => (mediaItem.width ?? 0) >= 2000
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
plexMedia = undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plexMedia) {
|
if (plexMedia) {
|
||||||
|
|||||||
Reference in New Issue
Block a user