From 32e50e93d99b1de45d5e30960cd9580b4800ea6b Mon Sep 17 00:00:00 2001 From: markjbear Date: Sat, 21 Sep 2024 16:44:41 +0100 Subject: [PATCH 1/7] Support strm files, which won't have mediastream data until played, so would fail current check for 'other resolution' --- server/api/jellyfin.ts | 1 + server/lib/scanners/jellyfin/index.ts | 67 +++++++++++++-------------- 2 files changed, 33 insertions(+), 35 deletions(-) diff --git a/server/api/jellyfin.ts b/server/api/jellyfin.ts index f65503477..87b71f34d 100644 --- a/server/api/jellyfin.ts +++ b/server/api/jellyfin.ts @@ -76,6 +76,7 @@ export interface JellyfinMediaSource { Path: string; Type: string; VideoType: string; + Container?: string; MediaStreams: JellyfinMediaStream[]; } diff --git a/server/lib/scanners/jellyfin/index.ts b/server/lib/scanners/jellyfin/index.ts index f48de70ef..45172a738 100644 --- a/server/lib/scanners/jellyfin/index.ts +++ b/server/lib/scanners/jellyfin/index.ts @@ -96,7 +96,7 @@ class JellyfinScanner { (MediaStream) => MediaStream.Type === 'Video' ).some((MediaStream) => { return (MediaStream.Width ?? 0) <= 2000; - }); + }) || (MediaSource.Container && MediaSource.Container === "strm"); }); await this.asyncLock.dispatch(newMedia.tmdbId, async () => { @@ -325,18 +325,18 @@ class JellyfinScanner { // and then not modifying the status if there are 0 items existingSeason.status = totalStandard >= season.episode_count || - existingSeason.status === MediaStatus.AVAILABLE + existingSeason.status === MediaStatus.AVAILABLE ? MediaStatus.AVAILABLE : totalStandard > 0 - ? MediaStatus.PARTIALLY_AVAILABLE - : existingSeason.status; + ? MediaStatus.PARTIALLY_AVAILABLE + : existingSeason.status; existingSeason.status4k = (this.enable4kShow && total4k >= season.episode_count) || - existingSeason.status4k === MediaStatus.AVAILABLE + existingSeason.status4k === MediaStatus.AVAILABLE ? MediaStatus.AVAILABLE : this.enable4kShow && total4k > 0 - ? MediaStatus.PARTIALLY_AVAILABLE - : existingSeason.status4k; + ? MediaStatus.PARTIALLY_AVAILABLE + : existingSeason.status4k; } else { newSeasons.push( new Season({ @@ -347,14 +347,14 @@ class JellyfinScanner { totalStandard >= season.episode_count ? MediaStatus.AVAILABLE : totalStandard > 0 - ? MediaStatus.PARTIALLY_AVAILABLE - : MediaStatus.UNKNOWN, + ? MediaStatus.PARTIALLY_AVAILABLE + : MediaStatus.UNKNOWN, status4k: this.enable4kShow && total4k >= season.episode_count ? MediaStatus.AVAILABLE : this.enable4kShow && total4k > 0 - ? MediaStatus.PARTIALLY_AVAILABLE - : MediaStatus.UNKNOWN, + ? MediaStatus.PARTIALLY_AVAILABLE + : MediaStatus.UNKNOWN, }) ); } @@ -370,18 +370,18 @@ class JellyfinScanner { newSeasons.filter( (season) => season.status === MediaStatus.AVAILABLE ).length + - (media?.seasons.filter( - (season) => season.status === MediaStatus.AVAILABLE - ).length ?? 0) >= + (media?.seasons.filter( + (season) => season.status === MediaStatus.AVAILABLE + ).length ?? 0) >= filteredSeasons.length; const isAll4kSeasons = newSeasons.filter( (season) => season.status4k === MediaStatus.AVAILABLE ).length + - (media?.seasons.filter( - (season) => season.status4k === MediaStatus.AVAILABLE - ).length ?? 0) >= + (media?.seasons.filter( + (season) => season.status4k === MediaStatus.AVAILABLE + ).length ?? 0) >= filteredSeasons.length; if (media) { @@ -404,8 +404,7 @@ class JellyfinScanner { // the lastSeasonChange field so we can trigger notifications if (newStandardSeasonAvailable > currentStandardSeasonAvailable) { this.log( - `Detected ${ - newStandardSeasonAvailable - currentStandardSeasonAvailable + `Detected ${newStandardSeasonAvailable - currentStandardSeasonAvailable } new standard season(s) for ${tvShow.name}`, 'debug' ); @@ -415,8 +414,7 @@ class JellyfinScanner { if (new4kSeasonAvailable > current4kSeasonAvailable) { this.log( - `Detected ${ - new4kSeasonAvailable - current4kSeasonAvailable + `Detected ${new4kSeasonAvailable - current4kSeasonAvailable } new 4K season(s) for ${tvShow.name}`, 'debug' ); @@ -444,10 +442,10 @@ class JellyfinScanner { isAllStandardSeasons || shouldStayAvailable ? MediaStatus.AVAILABLE : media.seasons.some( - (season) => season.status !== MediaStatus.UNKNOWN - ) - ? MediaStatus.PARTIALLY_AVAILABLE - : MediaStatus.UNKNOWN; + (season) => season.status !== MediaStatus.UNKNOWN + ) + ? MediaStatus.PARTIALLY_AVAILABLE + : MediaStatus.UNKNOWN; media.status4k = (isAll4kSeasons || shouldStayAvailable4k) && this.enable4kShow ? MediaStatus.AVAILABLE @@ -455,8 +453,8 @@ class JellyfinScanner { media.seasons.some( (season) => season.status4k !== MediaStatus.UNKNOWN ) - ? MediaStatus.PARTIALLY_AVAILABLE - : MediaStatus.UNKNOWN; + ? MediaStatus.PARTIALLY_AVAILABLE + : MediaStatus.UNKNOWN; await mediaRepository.save(media); this.log(`Updating existing title: ${tvShow.name}`); } else { @@ -472,10 +470,10 @@ class JellyfinScanner { status: isAllStandardSeasons ? MediaStatus.AVAILABLE : newSeasons.some( - (season) => season.status !== MediaStatus.UNKNOWN - ) - ? MediaStatus.PARTIALLY_AVAILABLE - : MediaStatus.UNKNOWN, + (season) => season.status !== MediaStatus.UNKNOWN + ) + ? MediaStatus.PARTIALLY_AVAILABLE + : MediaStatus.UNKNOWN, status4k: isAll4kSeasons && this.enable4kShow ? MediaStatus.AVAILABLE @@ -483,8 +481,8 @@ class JellyfinScanner { newSeasons.some( (season) => season.status4k !== MediaStatus.UNKNOWN ) - ? MediaStatus.PARTIALLY_AVAILABLE - : MediaStatus.UNKNOWN, + ? MediaStatus.PARTIALLY_AVAILABLE + : MediaStatus.UNKNOWN, }); await mediaRepository.save(newMedia); this.log(`Saved ${tvShow.name}`); @@ -495,8 +493,7 @@ class JellyfinScanner { } } catch (e) { this.log( - `Failed to process Jellyfin item. Id: ${ - jellyfinitem.SeriesId ?? jellyfinitem.SeasonId ?? jellyfinitem.Id + `Failed to process Jellyfin item. Id: ${jellyfinitem.SeriesId ?? jellyfinitem.SeasonId ?? jellyfinitem.Id }`, 'error', { From 6538c095e8c666f79a6626b26a7aa56f0b01aeeb Mon Sep 17 00:00:00 2001 From: Alan Date: Mon, 28 Oct 2024 17:41:12 +0100 Subject: [PATCH 2/7] Update server/lib/scanners/jellyfin/index.ts Co-authored-by: Gauthier --- server/lib/scanners/jellyfin/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/lib/scanners/jellyfin/index.ts b/server/lib/scanners/jellyfin/index.ts index 45172a738..52a1df6c5 100644 --- a/server/lib/scanners/jellyfin/index.ts +++ b/server/lib/scanners/jellyfin/index.ts @@ -96,7 +96,7 @@ class JellyfinScanner { (MediaStream) => MediaStream.Type === 'Video' ).some((MediaStream) => { return (MediaStream.Width ?? 0) <= 2000; - }) || (MediaSource.Container && MediaSource.Container === "strm"); + }) || MediaSource.Container === 'strm'; }); await this.asyncLock.dispatch(newMedia.tmdbId, async () => { From 9cc83684cc7d04a158fbd0412a967574ab96b9b9 Mon Sep 17 00:00:00 2001 From: Alan Date: Mon, 28 Oct 2024 17:52:28 +0100 Subject: [PATCH 3/7] Create format.yml --- .github/workflows/format.yml | 39 ++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 .github/workflows/format.yml diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml new file mode 100644 index 000000000..133c889e0 --- /dev/null +++ b/.github/workflows/format.yml @@ -0,0 +1,39 @@ +name: Code Formatting + +on: + pull_request: + branches: [main] + push: + branches: [main] + +jobs: + format: + runs-on: ubuntu-latest + + steps: + - name: Check out repository + uses: actions/checkout@v3 + + - name: Set up Node.js + uses: actions/setup-node@v3 + with: + node-version: '16' + + - name: Install dependencies + run: | + npm install -g pnpm + pnpm install + + - name: Run pnpm format + run: pnpm format + + - name: Commit and push changes + if: ${{ steps.format.outcome == 'success' }} + run: | + git config --global user.name "github-actions[bot]" + git config --global user.email "github-actions[bot]@users.noreply.github.com" + git add . + git commit -m "Apply formatting with pnpm format" + git push + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From c493dddd7a67d010148f4cf52195d8bb877c1d81 Mon Sep 17 00:00:00 2001 From: Alan Date: Mon, 28 Oct 2024 17:54:21 +0100 Subject: [PATCH 4/7] Update format.yml --- .github/workflows/format.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index 133c889e0..603ba8922 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -2,9 +2,9 @@ name: Code Formatting on: pull_request: - branches: [main] + branches: [develop] push: - branches: [main] + branches: [develop] jobs: format: From 5e2e0117152f4212c26de20be06074a49eb0c1e3 Mon Sep 17 00:00:00 2001 From: Alan Date: Mon, 28 Oct 2024 18:04:46 +0100 Subject: [PATCH 5/7] Update index.ts --- server/lib/scanners/jellyfin/index.ts | 32 +++++++++++++-------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/server/lib/scanners/jellyfin/index.ts b/server/lib/scanners/jellyfin/index.ts index 52a1df6c5..d0c537ce0 100644 --- a/server/lib/scanners/jellyfin/index.ts +++ b/server/lib/scanners/jellyfin/index.ts @@ -325,18 +325,18 @@ class JellyfinScanner { // and then not modifying the status if there are 0 items existingSeason.status = totalStandard >= season.episode_count || - existingSeason.status === MediaStatus.AVAILABLE + existingSeason.status === MediaStatus.AVAILABLE ? MediaStatus.AVAILABLE : totalStandard > 0 - ? MediaStatus.PARTIALLY_AVAILABLE - : existingSeason.status; + ? MediaStatus.PARTIALLY_AVAILABLE + : existingSeason.status; existingSeason.status4k = (this.enable4kShow && total4k >= season.episode_count) || - existingSeason.status4k === MediaStatus.AVAILABLE + existingSeason.status4k === MediaStatus.AVAILABLE ? MediaStatus.AVAILABLE : this.enable4kShow && total4k > 0 - ? MediaStatus.PARTIALLY_AVAILABLE - : existingSeason.status4k; + ? MediaStatus.PARTIALLY_AVAILABLE + : existingSeason.status4k; } else { newSeasons.push( new Season({ @@ -347,14 +347,14 @@ class JellyfinScanner { totalStandard >= season.episode_count ? MediaStatus.AVAILABLE : totalStandard > 0 - ? MediaStatus.PARTIALLY_AVAILABLE - : MediaStatus.UNKNOWN, + ? MediaStatus.PARTIALLY_AVAILABLE + : MediaStatus.UNKNOWN, status4k: this.enable4kShow && total4k >= season.episode_count ? MediaStatus.AVAILABLE : this.enable4kShow && total4k > 0 - ? MediaStatus.PARTIALLY_AVAILABLE - : MediaStatus.UNKNOWN, + ? MediaStatus.PARTIALLY_AVAILABLE + : MediaStatus.UNKNOWN, }) ); } @@ -444,8 +444,8 @@ class JellyfinScanner { : media.seasons.some( (season) => season.status !== MediaStatus.UNKNOWN ) - ? MediaStatus.PARTIALLY_AVAILABLE - : MediaStatus.UNKNOWN; + ? MediaStatus.PARTIALLY_AVAILABLE + : MediaStatus.UNKNOWN; media.status4k = (isAll4kSeasons || shouldStayAvailable4k) && this.enable4kShow ? MediaStatus.AVAILABLE @@ -472,8 +472,8 @@ class JellyfinScanner { : newSeasons.some( (season) => season.status !== MediaStatus.UNKNOWN ) - ? MediaStatus.PARTIALLY_AVAILABLE - : MediaStatus.UNKNOWN, + ? MediaStatus.PARTIALLY_AVAILABLE + : MediaStatus.UNKNOWN, status4k: isAll4kSeasons && this.enable4kShow ? MediaStatus.AVAILABLE @@ -481,8 +481,8 @@ class JellyfinScanner { newSeasons.some( (season) => season.status4k !== MediaStatus.UNKNOWN ) - ? MediaStatus.PARTIALLY_AVAILABLE - : MediaStatus.UNKNOWN, + ? MediaStatus.PARTIALLY_AVAILABLE + : MediaStatus.UNKNOWN, }); await mediaRepository.save(newMedia); this.log(`Saved ${tvShow.name}`); From a2c70c167ef0addf0eee92fd9a9d049bce3dbb66 Mon Sep 17 00:00:00 2001 From: Alan Date: Mon, 28 Oct 2024 18:14:50 +0100 Subject: [PATCH 6/7] Delete .github/workflows/format.yml --- .github/workflows/format.yml | 39 ------------------------------------ 1 file changed, 39 deletions(-) delete mode 100644 .github/workflows/format.yml diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml deleted file mode 100644 index 603ba8922..000000000 --- a/.github/workflows/format.yml +++ /dev/null @@ -1,39 +0,0 @@ -name: Code Formatting - -on: - pull_request: - branches: [develop] - push: - branches: [develop] - -jobs: - format: - runs-on: ubuntu-latest - - steps: - - name: Check out repository - uses: actions/checkout@v3 - - - name: Set up Node.js - uses: actions/setup-node@v3 - with: - node-version: '16' - - - name: Install dependencies - run: | - npm install -g pnpm - pnpm install - - - name: Run pnpm format - run: pnpm format - - - name: Commit and push changes - if: ${{ steps.format.outcome == 'success' }} - run: | - git config --global user.name "github-actions[bot]" - git config --global user.email "github-actions[bot]@users.noreply.github.com" - git add . - git commit -m "Apply formatting with pnpm format" - git push - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 6fdf5e2693389cca8eb9136f9cb4d0355b196649 Mon Sep 17 00:00:00 2001 From: Alan Date: Mon, 28 Oct 2024 18:31:57 +0100 Subject: [PATCH 7/7] Update index.ts --- server/lib/scanners/jellyfin/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/lib/scanners/jellyfin/index.ts b/server/lib/scanners/jellyfin/index.ts index d0c537ce0..2cf659208 100644 --- a/server/lib/scanners/jellyfin/index.ts +++ b/server/lib/scanners/jellyfin/index.ts @@ -453,8 +453,8 @@ class JellyfinScanner { media.seasons.some( (season) => season.status4k !== MediaStatus.UNKNOWN ) - ? MediaStatus.PARTIALLY_AVAILABLE - : MediaStatus.UNKNOWN; + ? MediaStatus.PARTIALLY_AVAILABLE + : MediaStatus.UNKNOWN; await mediaRepository.save(media); this.log(`Updating existing title: ${tvShow.name}`); } else {