Skip to content

Commit

Permalink
fix: count combined episodes
Browse files Browse the repository at this point in the history
Jellyfin allows combined episodes, like `S01E01-E02`,
but seasons containing such episodes are only recognized
as `Partially Available`. This commit should fix that.
  • Loading branch information
darmiel committed Dec 3, 2022
1 parent 1ceea3d commit 64339e5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
1 change: 1 addition & 0 deletions server/api/jellyfin.ts
Expand Up @@ -38,6 +38,7 @@ export interface JellyfinLibraryItem {
SeasonId?: string;
SeasonName?: string;
IndexNumber?: number;
IndexNumberEnd?: number;
ParentIndexNumber?: number;
MediaType: string;
}
Expand Down
17 changes: 14 additions & 3 deletions server/job/jellyfinsync/index.ts
Expand Up @@ -257,8 +257,19 @@ class JobJellyfinSync {
//use for loop to make sure this loop _completes_ in full
//before the next section
for (const episode of episodes) {
let episodeCount = 1;

// count number of combined episodes
if (
episode.IndexNumber !== undefined &&
episode.IndexNumberEnd !== undefined
) {
episodeCount =
episode.IndexNumberEnd - episode.IndexNumber + 1;
}

if (!this.enable4kShow) {
totalStandard++;
totalStandard += episodeCount;
} else {
const ExtendedEpisodeData = await this.jfClient.getItemData(
episode.Id
Expand All @@ -268,10 +279,10 @@ class JobJellyfinSync {
return MediaSource.MediaStreams.some((MediaStream) => {
if (MediaStream.Type === 'Video') {
if (MediaStream.Width ?? 0 < 2000) {
totalStandard++;
totalStandard += episodeCount;
}
} else {
total4k++;
total4k += episodeCount;
}
});
});
Expand Down

0 comments on commit 64339e5

Please sign in to comment.