From 77a36f971444ee5dc0d15b2d34a8daaf4e1f28b5 Mon Sep 17 00:00:00 2001 From: Gauthier Date: Sun, 16 Mar 2025 21:57:14 +0100 Subject: [PATCH] fix(job): resolve edge case issue with season availability updates (#1483) Ensure media availability updates correctly for shows marked as UNKNOWN and yet having AVAILABLE or PARTIALLY_AVAILABLE seasons --- server/lib/availabilitySync.ts | 48 ++++++++++++++++++++++------------ 1 file changed, 32 insertions(+), 16 deletions(-) diff --git a/server/lib/availabilitySync.ts b/server/lib/availabilitySync.ts index b85d29e47..0fdfd6276 100644 --- a/server/lib/availabilitySync.ts +++ b/server/lib/availabilitySync.ts @@ -404,6 +404,34 @@ class AvailabilitySync { }); } + if ( + !showExists && + (media.status === MediaStatus.AVAILABLE || + media.status === MediaStatus.PARTIALLY_AVAILABLE || + media.seasons.some( + (season) => season.status === MediaStatus.AVAILABLE + ) || + media.seasons.some( + (season) => season.status === MediaStatus.PARTIALLY_AVAILABLE + )) + ) { + await this.mediaUpdater(media, false, mediaServerType); + } + + if ( + !showExists4k && + (media.status4k === MediaStatus.AVAILABLE || + media.status4k === MediaStatus.PARTIALLY_AVAILABLE || + media.seasons.some( + (season) => season.status4k === MediaStatus.AVAILABLE + ) || + media.seasons.some( + (season) => season.status4k === MediaStatus.PARTIALLY_AVAILABLE + )) + ) { + await this.mediaUpdater(media, true, mediaServerType); + } + // TODO: Figure out how to run seasonUpdater for each season if ([...finalSeasons.values()].includes(false)) { @@ -423,22 +451,6 @@ class AvailabilitySync { mediaServerType ); } - - if ( - !showExists && - (media.status === MediaStatus.AVAILABLE || - media.status === MediaStatus.PARTIALLY_AVAILABLE) - ) { - await this.mediaUpdater(media, false, mediaServerType); - } - - if ( - !showExists4k && - (media.status4k === MediaStatus.AVAILABLE || - media.status4k === MediaStatus.PARTIALLY_AVAILABLE) - ) { - await this.mediaUpdater(media, true, mediaServerType); - } } } } catch (ex) { @@ -466,6 +478,10 @@ class AvailabilitySync { { status: MediaStatus.PARTIALLY_AVAILABLE }, { status4k: MediaStatus.AVAILABLE }, { status4k: MediaStatus.PARTIALLY_AVAILABLE }, + { seasons: { status: MediaStatus.AVAILABLE } }, + { seasons: { status: MediaStatus.PARTIALLY_AVAILABLE } }, + { seasons: { status4k: MediaStatus.AVAILABLE } }, + { seasons: { status4k: MediaStatus.PARTIALLY_AVAILABLE } }, ]; let mediaPage: Media[];