Compare commits
323 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b3a0611302 | |||
| c20cc766e1 | |||
| cac463d4c3 | |||
| 7faa35dab4 | |||
| 24022092ad | |||
| e2e3094d2d | |||
| d669994bf0 | |||
| 45b8f6c4c8 | |||
| 044f651299 | |||
| f865910a90 | |||
| f2360c07a3 | |||
| 4c812c9ba4 | |||
| 26261dbfe7 | |||
| ae90e0e52e | |||
| 72d0895401 | |||
| e16c8a07bd | |||
| a7a138db31 | |||
| 76956c0abc | |||
| d4376e0539 | |||
| b94ba9d409 | |||
| 744ca84a8b | |||
| c55fde25a5 | |||
| 030031dcff | |||
| 341c19bace | |||
| e3a8d209b4 | |||
| e816870f67 | |||
| f28acc7fa1 | |||
| b2ae39e0d9 | |||
| 893662ba50 | |||
| 314004bc19 | |||
| b15d3c9ad3 | |||
| 8293eb26b9 | |||
| d8fc0a9914 | |||
| 1f4f4acb46 | |||
| d64e18b69a | |||
| 7a4271c85f | |||
| afb716566d | |||
| e5c68e1257 | |||
| 4cedbe28e3 | |||
| 9ff92f3f0d | |||
| d92e59aa72 | |||
| d593436281 | |||
| 41b8bd4459 | |||
| 7215950bd4 | |||
| c435f63d09 | |||
| eed664b7d3 | |||
| 5b550517b2 | |||
| e565073fd5 | |||
| 2b93191714 | |||
| 046225654a | |||
| 0db27d7b1b | |||
| f571cd5a6a | |||
| 79a55327dc | |||
| dbc796b0b0 | |||
| 02d8e7d828 | |||
| 1e4d126cb9 | |||
| f3a1d56c56 | |||
| 67b8684f3c | |||
| b04614e18d | |||
| 689a90d275 | |||
| 766be1e8bb | |||
| f2f66606d7 | |||
| 949fa4b513 | |||
| 40fa2fd390 | |||
| 7f26bd1091 | |||
| 86ac1aaa6b | |||
| 3c9727d36c | |||
| 5a2809e337 | |||
| d1d89dfb12 | |||
| 45ec0ed8b5 | |||
| ebb66f6ca3 | |||
| b85c9186ef | |||
| c606102f6d | |||
| 8b70582561 | |||
| b62fef3c1f | |||
| 71ab342838 | |||
| 83c4681e99 | |||
| 42e52f60ad | |||
| 6ac64c5319 | |||
| 83e0cfd7ee | |||
| 700e53a807 | |||
| 4d1f90b2f7 | |||
| d74babd8f3 | |||
| b7b2700425 | |||
| 04e4505402 | |||
| 95330223f4 | |||
| f28fa563c9 | |||
| d6ce6ae8b9 | |||
| 8f57f35372 | |||
| 9aa79682ba | |||
| d4cddb8a5d | |||
| dc300fae53 | |||
| 70980f09de | |||
| ca0cf763ff | |||
| 3d4c52092e | |||
| fc0af10509 | |||
| 88216e0ec4 | |||
| 474ae50c36 | |||
| 929e1936eb | |||
| 6382563440 | |||
| 733b4ba73a | |||
| 5d580abb08 | |||
| fc43f151a2 | |||
| 526f4051e9 | |||
| 635fd0433d | |||
| 370170bab0 | |||
| b317af0d30 | |||
| ca1f7af445 | |||
| 65836cc844 | |||
| b4090bdcb2 | |||
| ed61acc19a | |||
| 9b9b609c83 | |||
| 4cc69f4be0 | |||
| 527ba2e11c | |||
| 25d4e207f7 | |||
| 7a269987d2 | |||
| 081944d358 | |||
| 299810a4a9 | |||
| 53e58d8b1b | |||
| b99703301f | |||
| bdf263d867 | |||
| 9d5aedba5f | |||
| 0f88fe3c7f | |||
| 557b14e33e | |||
| c222d370ce | |||
| 0d629591ed | |||
| 23fa02eb59 | |||
| bea016c962 | |||
| fae1e4c556 | |||
| f2b9c68969 | |||
| e04ac6fd35 | |||
| 25011224cf | |||
| 191be0931e | |||
| 2cd2f36fe4 | |||
| 4f19ed5730 | |||
| 5949be852a | |||
| ffe075650c | |||
| abb35571ef | |||
| 474399683d | |||
| a238d59a07 | |||
| c779488ade | |||
| cc44f333b6 | |||
| 2b6302c06e | |||
| c3901fde56 | |||
| aead9c0e22 | |||
| 2fd747432a | |||
| 236db6d2f6 | |||
| 181c057cb8 | |||
| 7daef156e5 | |||
| f068ca3bd6 | |||
| 6c0eff5b39 | |||
| 5e946a45ee | |||
| 7d83779b6f | |||
| 663a873e07 | |||
| 3321a0cf09 | |||
| 5a9fb80239 | |||
| 8ac2d1f7bc | |||
| 9fa9d26341 | |||
| dd0b273b26 | |||
| cab108a839 | |||
| 3d83e67a52 | |||
| b809d964b3 | |||
| 96727072c8 | |||
| 9ec0d7c63b | |||
| bfe0a47b32 | |||
| 9b5f830462 | |||
| 42f9ed76c0 | |||
| 69faa6c583 | |||
| 0c7428f136 | |||
| 97e666c566 | |||
| 5cd3d7ebb7 | |||
| 62a5ded920 | |||
| 21801e8ba1 | |||
| 1a45fc82b5 | |||
| 4fb779920a | |||
| d7727224c2 | |||
| a96dc8bd9b | |||
| d146c347b4 | |||
| f2dea2a3fd | |||
| 4d1dd42420 | |||
| 8eb0ba60c1 | |||
| 2bf15d95df | |||
| be2db99586 | |||
| 37fe9df27c | |||
| 8759ad4d49 | |||
| 051ff4cf6d | |||
| fa4626c080 | |||
| d36c8ebce8 | |||
| 4cc577a72d | |||
| cdf7ce0fc4 | |||
| d894a98b79 | |||
| 2b57a5725c | |||
| 3f96790904 | |||
| 2bac9a8f0c | |||
| 997093ae3a | |||
| 5cbafa566d | |||
| 0d3cf0169e | |||
| 6e3c187493 | |||
| f8771b52ec | |||
| e3d610c3c5 | |||
| 486ffaa6dd | |||
| d96d1f1119 | |||
| 30f28456de | |||
| f8aad322cc | |||
| c6545a8b68 | |||
| 0fe9c1ce91 | |||
| b6882c86dc | |||
| 4503ad295c | |||
| 1a9bd2417a | |||
| 0d2f1b26b3 | |||
| bc59e56ef5 | |||
| b8bac71270 | |||
| 6238448716 | |||
| 56c970c2db | |||
| fcce108948 | |||
| cfeaef6180 | |||
| ebab369eac | |||
| 2a44c35224 | |||
| 0584a102ee | |||
| 2aae53bc15 | |||
| 911044b415 | |||
| b77def6883 | |||
| 5c48935fa8 | |||
| 9e996d612c | |||
| 5be844e1b7 | |||
| e2d9d592bc | |||
| 6f189bf2b8 | |||
| 47f567b6f1 | |||
| 305160d2e4 | |||
| f3ff7a446b | |||
| a3ec1a3712 | |||
| 6bbd6dcd44 | |||
| ce43df6f43 | |||
| 2250015e78 | |||
| 933f7eea1b | |||
| 631a314d24 | |||
| ed06fd5139 | |||
| 2326ecdedc | |||
| 38813f7d42 | |||
| 853922443f | |||
| 8b826d981b | |||
| 8bf1710e07 | |||
| 5e42941d3b | |||
| a1255bda6a | |||
| 9a2fdb3573 | |||
| 08f6627a24 | |||
| 53aafcd38e | |||
| d73e65172a | |||
| fff710585f | |||
| 1294990f4f | |||
| 974038e9b0 | |||
| ab0d0d1890 | |||
| f3fbe5575a | |||
| 860cb75d58 | |||
| e31f168e9b | |||
| 7f5537ca47 | |||
| a03072b617 | |||
| 31d05dbdd6 | |||
| d4faf7bd72 | |||
| 6e728b009f | |||
| efd3814a7e | |||
| b391cd5e9e | |||
| 8433773fad | |||
| 381bf18161 | |||
| f8ffccae7f | |||
| 2528bc1032 | |||
| 4b5f5d6ca3 | |||
| e2eaacd239 | |||
| 77d4ab9ea9 | |||
| 6883cd0969 | |||
| 43a152359e | |||
| 482cf4b8c3 | |||
| 2b4945217a | |||
| ccc1712d10 | |||
| 8622c3bfb7 | |||
| 820e7b91da | |||
| 08ba3717ea | |||
| 8f3eb3205d | |||
| 379c58a48d | |||
| 28b43838dd | |||
| 38f1d9749e | |||
| 9cc25d133d | |||
| 8e1b69b37f | |||
| a43fd188dc | |||
| f011529388 | |||
| 8ffb54603a | |||
| d3ee1e84b1 | |||
| 1035f6a101 | |||
| 22792b62cb | |||
| ef6f342a54 | |||
| a888257c82 | |||
| d55f808423 | |||
| dc92e3b0e4 | |||
| 95cebffa87 | |||
| 617ebf367f | |||
| 70b4589382 | |||
| 5221584b06 | |||
| c4ace4ac95 | |||
| 2fcf4084f8 | |||
| c632417dda | |||
| d090c59939 | |||
| 94d5326411 | |||
| c49f279a27 | |||
| 0fb042b740 | |||
| a5706c2fa6 | |||
| 4278b34fe6 | |||
| 0aeee8233b | |||
| 95de28cdda | |||
| 0874a26131 | |||
| 1bfbad2420 | |||
| fe1d8d8840 | |||
| a53a533cc4 | |||
| 4725722b1c | |||
| 9ea3f45886 | |||
| e64cc73f88 | |||
| 63990d6a2d | |||
| 09723bd123 | |||
| c242533f4e | |||
| 507998a4e3 | |||
| 7939f3b009 | |||
| e1d63c0ea0 | |||
| e1a16b4ec6 | |||
| 9569b4550d |
@@ -3,7 +3,7 @@
|
|||||||
"isRoot": true,
|
"isRoot": true,
|
||||||
"tools": {
|
"tools": {
|
||||||
"dotnet-ef": {
|
"dotnet-ef": {
|
||||||
"version": "10.0.9",
|
"version": "10.0.10",
|
||||||
"commands": [
|
"commands": [
|
||||||
"dotnet-ef"
|
"dotnet-ef"
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -24,21 +24,21 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
|
|
||||||
- name: Setup .NET
|
- name: Setup .NET
|
||||||
uses: actions/setup-dotnet@26b0ec14cb23fa6904739307f278c14f94c95bf1 # v5.4.0
|
uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # v6.0.0
|
||||||
with:
|
with:
|
||||||
dotnet-version: '10.0.x'
|
dotnet-version: '10.0.x'
|
||||||
|
|
||||||
- name: Initialize CodeQL
|
- name: Initialize CodeQL
|
||||||
uses: github/codeql-action/init@8aad20d150bbac5944a9f9d289da16a4b0d87c1e # v4.36.2
|
uses: github/codeql-action/init@e4fba868fa4b1b91e1fdab776edc8cfbe6e9fb81 # v4.37.3
|
||||||
with:
|
with:
|
||||||
languages: ${{ matrix.language }}
|
languages: ${{ matrix.language }}
|
||||||
queries: +security-extended
|
queries: +security-extended
|
||||||
|
|
||||||
- name: Autobuild
|
- name: Autobuild
|
||||||
uses: github/codeql-action/autobuild@8aad20d150bbac5944a9f9d289da16a4b0d87c1e # v4.36.2
|
uses: github/codeql-action/autobuild@e4fba868fa4b1b91e1fdab776edc8cfbe6e9fb81 # v4.37.3
|
||||||
|
|
||||||
- name: Perform CodeQL Analysis
|
- name: Perform CodeQL Analysis
|
||||||
uses: github/codeql-action/analyze@8aad20d150bbac5944a9f9d289da16a4b0d87c1e # v4.36.2
|
uses: github/codeql-action/analyze@e4fba868fa4b1b91e1fdab776edc8cfbe6e9fb81 # v4.37.3
|
||||||
|
|||||||
@@ -11,13 +11,13 @@ jobs:
|
|||||||
permissions: read-all
|
permissions: read-all
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
with:
|
with:
|
||||||
ref: ${{ github.event.pull_request.head.sha }}
|
ref: ${{ github.event.pull_request.head.sha }}
|
||||||
repository: ${{ github.event.pull_request.head.repo.full_name }}
|
repository: ${{ github.event.pull_request.head.repo.full_name }}
|
||||||
|
|
||||||
- name: Setup .NET
|
- name: Setup .NET
|
||||||
uses: actions/setup-dotnet@26b0ec14cb23fa6904739307f278c14f94c95bf1 # v5.4.0
|
uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # v6.0.0
|
||||||
with:
|
with:
|
||||||
dotnet-version: '10.0.x'
|
dotnet-version: '10.0.x'
|
||||||
|
|
||||||
@@ -40,14 +40,14 @@ jobs:
|
|||||||
permissions: read-all
|
permissions: read-all
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
with:
|
with:
|
||||||
ref: ${{ github.event.pull_request.head.sha }}
|
ref: ${{ github.event.pull_request.head.sha }}
|
||||||
repository: ${{ github.event.pull_request.head.repo.full_name }}
|
repository: ${{ github.event.pull_request.head.repo.full_name }}
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: Setup .NET
|
- name: Setup .NET
|
||||||
uses: actions/setup-dotnet@26b0ec14cb23fa6904739307f278c14f94c95bf1 # v5.4.0
|
uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # v6.0.0
|
||||||
with:
|
with:
|
||||||
dotnet-version: '10.0.x'
|
dotnet-version: '10.0.x'
|
||||||
|
|
||||||
|
|||||||
@@ -15,9 +15,9 @@ jobs:
|
|||||||
format-check:
|
format-check:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
|
|
||||||
- uses: actions/setup-dotnet@26b0ec14cb23fa6904739307f278c14f94c95bf1 # v5.4.0
|
- uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # v6.0.0
|
||||||
with:
|
with:
|
||||||
dotnet-version: ${{ env.SDK_VERSION }}
|
dotnet-version: ${{ env.SDK_VERSION }}
|
||||||
|
|
||||||
|
|||||||
@@ -20,9 +20,9 @@ jobs:
|
|||||||
|
|
||||||
runs-on: "${{ matrix.os }}"
|
runs-on: "${{ matrix.os }}"
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
|
|
||||||
- uses: actions/setup-dotnet@26b0ec14cb23fa6904739307f278c14f94c95bf1 # v5.4.0
|
- uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # v6.0.0
|
||||||
with:
|
with:
|
||||||
dotnet-version: ${{ env.SDK_VERSION }}
|
dotnet-version: ${{ env.SDK_VERSION }}
|
||||||
|
|
||||||
@@ -35,7 +35,7 @@ jobs:
|
|||||||
--verbosity minimal
|
--verbosity minimal
|
||||||
|
|
||||||
- name: Merge code coverage results
|
- name: Merge code coverage results
|
||||||
uses: danielpalme/ReportGenerator-GitHub-Action@049f7ec958c672fd31d5cc1cb01622dc8d2e23ab # v5.5.10
|
uses: danielpalme/ReportGenerator-GitHub-Action@d3ebf1f760f7d8ab92cc44d9bcfee7ad73722a31 # v5.5.11
|
||||||
with:
|
with:
|
||||||
reports: "**/coverage.cobertura.xml"
|
reports: "**/coverage.cobertura.xml"
|
||||||
targetdir: "merged/"
|
targetdir: "merged/"
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ jobs:
|
|||||||
reactions: '+1'
|
reactions: '+1'
|
||||||
|
|
||||||
- name: Checkout the latest code
|
- name: Checkout the latest code
|
||||||
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
with:
|
with:
|
||||||
token: ${{ secrets.JF_BOT_TOKEN }}
|
token: ${{ secrets.JF_BOT_TOKEN }}
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
@@ -40,12 +40,12 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: pull in script
|
- name: pull in script
|
||||||
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
with:
|
with:
|
||||||
repository: jellyfin/jellyfin-triage-script
|
repository: jellyfin/jellyfin-triage-script
|
||||||
|
|
||||||
- name: install python
|
- name: install python
|
||||||
uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0
|
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
|
||||||
with:
|
with:
|
||||||
python-version: '3.14'
|
python-version: '3.14'
|
||||||
cache: 'pip'
|
cache: 'pip'
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
if: ${{ contains(github.repository, 'jellyfin/') }}
|
if: ${{ contains(github.repository, 'jellyfin/') }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/stale@eb5cf3af3ac0a1aa4c9c45633dd1ae542a27a899 # v10.3.0
|
- uses: actions/stale@4391f3da665fdf50b6810c1a66712fb9ba21aa93 # v11.0.0
|
||||||
with:
|
with:
|
||||||
repo-token: ${{ secrets.JF_BOT_TOKEN }}
|
repo-token: ${{ secrets.JF_BOT_TOKEN }}
|
||||||
ascending: true
|
ascending: true
|
||||||
|
|||||||
@@ -10,12 +10,12 @@ jobs:
|
|||||||
issues: write
|
issues: write
|
||||||
steps:
|
steps:
|
||||||
- name: pull in script
|
- name: pull in script
|
||||||
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
with:
|
with:
|
||||||
repository: jellyfin/jellyfin-triage-script
|
repository: jellyfin/jellyfin-triage-script
|
||||||
|
|
||||||
- name: install python
|
- name: install python
|
||||||
uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0
|
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
|
||||||
with:
|
with:
|
||||||
python-version: '3.14'
|
python-version: '3.14'
|
||||||
cache: 'pip'
|
cache: 'pip'
|
||||||
|
|||||||
@@ -22,13 +22,13 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout Repository
|
- name: Checkout Repository
|
||||||
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
with:
|
with:
|
||||||
ref: ${{ inputs.ref }}
|
ref: ${{ inputs.ref }}
|
||||||
repository: ${{ inputs.repository }}
|
repository: ${{ inputs.repository }}
|
||||||
|
|
||||||
- name: Configure .NET
|
- name: Configure .NET
|
||||||
uses: actions/setup-dotnet@26b0ec14cb23fa6904739307f278c14f94c95bf1 # v5.4.0
|
uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # v6.0.0
|
||||||
with:
|
with:
|
||||||
dotnet-version: '10.0.x'
|
dotnet-version: '10.0.x'
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ jobs:
|
|||||||
base_ref: ${{ steps.ancestor.outputs.base_ref }}
|
base_ref: ${{ steps.ancestor.outputs.base_ref }}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout Repository
|
- name: Checkout Repository
|
||||||
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
with:
|
with:
|
||||||
ref: ${{ github.event.pull_request.head.sha }}
|
ref: ${{ github.event.pull_request.head.sha }}
|
||||||
repository: ${{ github.event.pull_request.head.repo.full_name }}
|
repository: ${{ github.event.pull_request.head.repo.full_name }}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
if: ${{ contains(github.repository, 'jellyfin/') }}
|
if: ${{ contains(github.repository, 'jellyfin/') }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/stale@eb5cf3af3ac0a1aa4c9c45633dd1ae542a27a899 # v10.3.0
|
- uses: actions/stale@4391f3da665fdf50b6810c1a66712fb9ba21aa93 # v11.0.0
|
||||||
with:
|
with:
|
||||||
repo-token: ${{ secrets.JF_BOT_TOKEN }}
|
repo-token: ${{ secrets.JF_BOT_TOKEN }}
|
||||||
ascending: true
|
ascending: true
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ jobs:
|
|||||||
yq-version: v4.9.8
|
yq-version: v4.9.8
|
||||||
|
|
||||||
- name: Checkout Repository
|
- name: Checkout Repository
|
||||||
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
with:
|
with:
|
||||||
ref: ${{ env.TAG_BRANCH }}
|
ref: ${{ env.TAG_BRANCH }}
|
||||||
|
|
||||||
@@ -66,7 +66,7 @@ jobs:
|
|||||||
NEXT_VERSION: ${{ github.event.inputs.NEXT_VERSION }}
|
NEXT_VERSION: ${{ github.event.inputs.NEXT_VERSION }}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout Repository
|
- name: Checkout Repository
|
||||||
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
with:
|
with:
|
||||||
ref: ${{ env.TAG_BRANCH }}
|
ref: ${{ env.TAG_BRANCH }}
|
||||||
|
|
||||||
|
|||||||
@@ -172,6 +172,7 @@
|
|||||||
- [whooo](https://github.com/whooo)
|
- [whooo](https://github.com/whooo)
|
||||||
- [WiiPlayer2](https://github.com/WiiPlayer2)
|
- [WiiPlayer2](https://github.com/WiiPlayer2)
|
||||||
- [WillWill56](https://github.com/WillWill56)
|
- [WillWill56](https://github.com/WillWill56)
|
||||||
|
- [WizardOfYendor1](https://github.com/WizardOfYendor1)
|
||||||
- [wtayl0r](https://github.com/wtayl0r)
|
- [wtayl0r](https://github.com/wtayl0r)
|
||||||
- [Wuerfelbecher](https://github.com/Wuerfelbecher)
|
- [Wuerfelbecher](https://github.com/Wuerfelbecher)
|
||||||
- [Wunax](https://github.com/Wunax)
|
- [Wunax](https://github.com/Wunax)
|
||||||
@@ -233,6 +234,8 @@
|
|||||||
- [MSalman5230](https://github.com/MSalman5230)
|
- [MSalman5230](https://github.com/MSalman5230)
|
||||||
- [dwandw](https://github.com/dwandw)
|
- [dwandw](https://github.com/dwandw)
|
||||||
- [Lampan-git](https://github.com/Lampan-git)
|
- [Lampan-git](https://github.com/Lampan-git)
|
||||||
|
- [elio42](https://github.com/elio42)
|
||||||
|
- [rwebster85](https://github.com/rwebster85)
|
||||||
|
|
||||||
# Emby Contributors
|
# Emby Contributors
|
||||||
|
|
||||||
|
|||||||
+26
-25
@@ -17,7 +17,7 @@
|
|||||||
<PackageVersion Include="Diacritics" Version="4.1.8" />
|
<PackageVersion Include="Diacritics" Version="4.1.8" />
|
||||||
<PackageVersion Include="DiscUtils.Udf" Version="0.16.13" />
|
<PackageVersion Include="DiscUtils.Udf" Version="0.16.13" />
|
||||||
<PackageVersion Include="DotNet.Glob" Version="3.1.3" />
|
<PackageVersion Include="DotNet.Glob" Version="3.1.3" />
|
||||||
<PackageVersion Include="FsCheck.Xunit.v3" Version="3.3.3" />
|
<PackageVersion Include="FsCheck.Xunit.v3" Version="3.3.4" />
|
||||||
<PackageVersion Include="HarfBuzzSharp.NativeAssets.Linux" Version="8.3.1.5" />
|
<PackageVersion Include="HarfBuzzSharp.NativeAssets.Linux" Version="8.3.1.5" />
|
||||||
<PackageVersion Include="ICU4N.Transliterator" Version="60.1.0-alpha.356" />
|
<PackageVersion Include="ICU4N.Transliterator" Version="60.1.0-alpha.356" />
|
||||||
<PackageVersion Include="IDisposableAnalyzers" Version="4.0.8" />
|
<PackageVersion Include="IDisposableAnalyzers" Version="4.0.8" />
|
||||||
@@ -26,33 +26,34 @@
|
|||||||
<PackageVersion Include="libse" Version="4.0.12" />
|
<PackageVersion Include="libse" Version="4.0.12" />
|
||||||
<PackageVersion Include="LrcParser" Version="2025.623.0" />
|
<PackageVersion Include="LrcParser" Version="2025.623.0" />
|
||||||
<PackageVersion Include="MetaBrainz.MusicBrainz" Version="8.0.1" />
|
<PackageVersion Include="MetaBrainz.MusicBrainz" Version="8.0.1" />
|
||||||
<PackageVersion Include="Microsoft.AspNetCore.Authorization" Version="10.0.9" />
|
<PackageVersion Include="Microsoft.AspNetCore.Authorization" Version="10.0.10" />
|
||||||
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Testing" Version="10.0.9" />
|
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Testing" Version="10.0.10" />
|
||||||
<PackageVersion Include="Microsoft.CodeAnalysis.BannedApiAnalyzers" Version="4.14.0" />
|
<PackageVersion Include="Microsoft.CodeAnalysis.BannedApiAnalyzers" Version="5.6.0" />
|
||||||
<PackageVersion Include="Microsoft.CodeAnalysis.Common" Version="5.3.0" />
|
<PackageVersion Include="Microsoft.CodeAnalysis.Common" Version="5.6.0" />
|
||||||
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="5.3.0" />
|
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="5.6.0" />
|
||||||
<PackageVersion Include="Microsoft.CodeAnalysis.Analyzers" Version="5.3.0" />
|
<PackageVersion Include="Microsoft.CodeAnalysis.Analyzers" Version="5.6.0" />
|
||||||
<PackageVersion Include="Microsoft.Data.Sqlite" Version="10.0.9" />
|
<PackageVersion Include="Microsoft.Data.Sqlite" Version="10.0.10" />
|
||||||
<PackageVersion Include="Microsoft.EntityFrameworkCore.Design" Version="10.0.9" />
|
<PackageVersion Include="Microsoft.EntityFrameworkCore.Design" Version="10.0.10" />
|
||||||
<PackageVersion Include="Microsoft.EntityFrameworkCore.Relational" Version="10.0.9" />
|
<PackageVersion Include="Microsoft.EntityFrameworkCore.Relational" Version="10.0.10" />
|
||||||
<PackageVersion Include="Microsoft.EntityFrameworkCore.Sqlite" Version="10.0.9" />
|
<PackageVersion Include="Microsoft.EntityFrameworkCore.Sqlite" Version="10.0.10" />
|
||||||
<PackageVersion Include="Microsoft.EntityFrameworkCore.Tools" Version="10.0.9" />
|
<PackageVersion Include="Microsoft.EntityFrameworkCore.Tools" Version="10.0.10" />
|
||||||
<PackageVersion Include="Microsoft.Extensions.Caching.Abstractions" Version="10.0.9" />
|
<PackageVersion Include="Microsoft.Extensions.Caching.Abstractions" Version="10.0.10" />
|
||||||
<PackageVersion Include="Microsoft.Extensions.Caching.Memory" Version="10.0.9" />
|
<PackageVersion Include="Microsoft.Extensions.Caching.Memory" Version="10.0.10" />
|
||||||
<PackageVersion Include="Microsoft.Extensions.Configuration.Abstractions" Version="10.0.9" />
|
<PackageVersion Include="Microsoft.Extensions.Configuration.Abstractions" Version="10.0.10" />
|
||||||
<PackageVersion Include="Microsoft.Extensions.Configuration.Binder" Version="10.0.9" />
|
<PackageVersion Include="Microsoft.Extensions.Configuration.Binder" Version="10.0.10" />
|
||||||
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="10.0.9" />
|
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="10.0.10" />
|
||||||
<PackageVersion Include="Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore" Version="10.0.9" />
|
<PackageVersion Include="Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore" Version="10.0.10" />
|
||||||
<PackageVersion Include="Microsoft.Extensions.Hosting.Abstractions" Version="10.0.9" />
|
<PackageVersion Include="Microsoft.Extensions.Hosting.Abstractions" Version="10.0.10" />
|
||||||
<PackageVersion Include="Microsoft.Extensions.Http" Version="10.0.9" />
|
<PackageVersion Include="Microsoft.Extensions.Http" Version="10.0.10" />
|
||||||
<PackageVersion Include="Microsoft.Extensions.Logging" Version="10.0.9" />
|
<PackageVersion Include="Microsoft.Extensions.Logging" Version="10.0.10" />
|
||||||
<PackageVersion Include="Microsoft.Extensions.Options" Version="10.0.9" />
|
<PackageVersion Include="Microsoft.Extensions.Options" Version="10.0.10" />
|
||||||
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.7.0" />
|
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.8.1" />
|
||||||
<PackageVersion Include="MimeTypes" Version="2.5.2" />
|
<PackageVersion Include="MimeTypes" Version="2.5.2" />
|
||||||
<PackageVersion Include="Morestachio" Version="5.0.1.670" />
|
<PackageVersion Include="Morestachio" Version="5.0.1.670" />
|
||||||
<PackageVersion Include="Moq" Version="4.18.4" />
|
<PackageVersion Include="Moq" Version="4.18.4" />
|
||||||
<PackageVersion Include="NEbml" Version="1.1.0.5" />
|
<PackageVersion Include="NEbml" Version="1.1.0.5" />
|
||||||
<PackageVersion Include="Newtonsoft.Json" Version="13.0.4" />
|
<PackageVersion Include="Newtonsoft.Json" Version="13.0.4" />
|
||||||
|
<PackageVersion Include="PDFtoImage" Version="5.2.1" />
|
||||||
<PackageVersion Include="PlaylistsNET" Version="1.4.1" />
|
<PackageVersion Include="PlaylistsNET" Version="1.4.1" />
|
||||||
<PackageVersion Include="prometheus-net.AspNetCore" Version="8.2.1" />
|
<PackageVersion Include="prometheus-net.AspNetCore" Version="8.2.1" />
|
||||||
<PackageVersion Include="prometheus-net.DotNetRuntime" Version="4.4.1" />
|
<PackageVersion Include="prometheus-net.DotNetRuntime" Version="4.4.1" />
|
||||||
@@ -67,7 +68,7 @@
|
|||||||
<PackageVersion Include="Serilog.Sinks.File" Version="7.0.0" />
|
<PackageVersion Include="Serilog.Sinks.File" Version="7.0.0" />
|
||||||
<PackageVersion Include="Serilog.Sinks.Graylog" Version="3.1.1" />
|
<PackageVersion Include="Serilog.Sinks.Graylog" Version="3.1.1" />
|
||||||
<PackageVersion Include="SerilogAnalyzer" Version="0.15.0" />
|
<PackageVersion Include="SerilogAnalyzer" Version="0.15.0" />
|
||||||
<PackageVersion Include="SharpCompress" Version="0.49.1" />
|
<PackageVersion Include="SharpCompress" Version="0.50.1" />
|
||||||
<PackageVersion Include="SharpFuzz" Version="2.3.0" />
|
<PackageVersion Include="SharpFuzz" Version="2.3.0" />
|
||||||
<PackageVersion Include="SkiaSharp" Version="3.119.4" />
|
<PackageVersion Include="SkiaSharp" Version="3.119.4" />
|
||||||
<PackageVersion Include="SkiaSharp.HarfBuzz" Version="3.119.4" />
|
<PackageVersion Include="SkiaSharp.HarfBuzz" Version="3.119.4" />
|
||||||
@@ -77,7 +78,7 @@
|
|||||||
<PackageVersion Include="Svg.Skia" Version="3.7.0" />
|
<PackageVersion Include="Svg.Skia" Version="3.7.0" />
|
||||||
<PackageVersion Include="Swashbuckle.AspNetCore.ReDoc" Version="10.2.3" />
|
<PackageVersion Include="Swashbuckle.AspNetCore.ReDoc" Version="10.2.3" />
|
||||||
<PackageVersion Include="Swashbuckle.AspNetCore" Version="10.2.3" />
|
<PackageVersion Include="Swashbuckle.AspNetCore" Version="10.2.3" />
|
||||||
<PackageVersion Include="System.Text.Json" Version="10.0.9" />
|
<PackageVersion Include="System.Text.Json" Version="10.0.10" />
|
||||||
<PackageVersion Include="TagLibSharp" Version="2.3.0" />
|
<PackageVersion Include="TagLibSharp" Version="2.3.0" />
|
||||||
<PackageVersion Include="z440.atl.core" Version="7.15.3" />
|
<PackageVersion Include="z440.atl.core" Version="7.15.3" />
|
||||||
<PackageVersion Include="TMDbLib" Version="3.0.0" />
|
<PackageVersion Include="TMDbLib" Version="3.0.0" />
|
||||||
|
|||||||
@@ -57,7 +57,6 @@ namespace Emby.Naming.Common
|
|||||||
".nrg",
|
".nrg",
|
||||||
".nsv",
|
".nsv",
|
||||||
".nuv",
|
".nuv",
|
||||||
".ogg",
|
|
||||||
".ogm",
|
".ogm",
|
||||||
".ogv",
|
".ogv",
|
||||||
".pva",
|
".pva",
|
||||||
@@ -362,7 +361,10 @@ namespace Emby.Naming.Common
|
|||||||
// Not a Kodi rule as well, but the expression below also causes false positives,
|
// Not a Kodi rule as well, but the expression below also causes false positives,
|
||||||
// so we make sure this one gets tested first.
|
// so we make sure this one gets tested first.
|
||||||
// "Foo Bar 889"
|
// "Foo Bar 889"
|
||||||
new EpisodeExpression(@".*[\\\/](?![Ee]pisode)(?<seriesname>[\w\s]+?)\s(?<epnumber>[0-9]{1,4})(-(?<endingepnumber>[0-9]{2,4}))*[^\\\/x]*$")
|
// Names carrying an SxxEyy marker are excluded because the Kodi expression above already covers them.
|
||||||
|
// Without that guard this expression reads digits out of the title instead, turning
|
||||||
|
// "S01E01 1-23-45 [Bluray-1080p]" into episodes 1 through 45.
|
||||||
|
new EpisodeExpression(@".*[\\\/](?![Ee]pisode)(?![^\\\/]*[Ss][0-9]+[][ ._-]*[Ee][0-9]+)(?<seriesname>[\w\s]+?)\s(?<epnumber>[0-9]{1,4})(-(?<endingepnumber>[0-9]{2,4}))*[^\\\/x]*$")
|
||||||
{
|
{
|
||||||
IsNamed = true
|
IsNamed = true
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -125,7 +125,7 @@ namespace Emby.Naming.TV
|
|||||||
result.Success = true;
|
result.Success = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (DateTime.TryParse(match.Groups[0].ValueSpan, out date))
|
else if (DateTime.TryParse(match.Groups[0].ValueSpan, CultureInfo.InvariantCulture, out date))
|
||||||
{
|
{
|
||||||
result.Year = date.Year;
|
result.Year = date.Year;
|
||||||
result.Month = date.Month;
|
result.Month = date.Month;
|
||||||
|
|||||||
@@ -52,13 +52,18 @@ namespace Emby.Naming.Video
|
|||||||
while (path.Length > 0)
|
while (path.Length > 0)
|
||||||
{
|
{
|
||||||
var index = path.IndexOfAny(delimiters);
|
var index = path.IndexOfAny(delimiters);
|
||||||
|
ReadOnlySpan<char> currentSlice;
|
||||||
if (index == -1)
|
if (index == -1)
|
||||||
{
|
{
|
||||||
index = path.Length - 1;
|
// No delimiter left, the last token is the remainder of the path
|
||||||
|
currentSlice = path;
|
||||||
|
path = default;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
currentSlice = path[..index];
|
||||||
|
path = path[(index + 1)..];
|
||||||
}
|
}
|
||||||
|
|
||||||
var currentSlice = path[..index];
|
|
||||||
path = path[(index + 1)..];
|
|
||||||
|
|
||||||
if (!foundPrefix)
|
if (!foundPrefix)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -39,6 +39,8 @@ using Emby.Server.Implementations.SyncPlay;
|
|||||||
using Emby.Server.Implementations.TV;
|
using Emby.Server.Implementations.TV;
|
||||||
using Emby.Server.Implementations.Updates;
|
using Emby.Server.Implementations.Updates;
|
||||||
using Jellyfin.Api.Helpers;
|
using Jellyfin.Api.Helpers;
|
||||||
|
using Jellyfin.Data;
|
||||||
|
using Jellyfin.Database.Implementations.Enums;
|
||||||
using Jellyfin.Drawing;
|
using Jellyfin.Drawing;
|
||||||
using Jellyfin.MediaEncoding.Hls.Playlist;
|
using Jellyfin.MediaEncoding.Hls.Playlist;
|
||||||
using Jellyfin.Networking.Manager;
|
using Jellyfin.Networking.Manager;
|
||||||
@@ -417,6 +419,8 @@ namespace Emby.Server.Implementations
|
|||||||
{
|
{
|
||||||
Logger.LogInformation("Running startup tasks");
|
Logger.LogInformation("Running startup tasks");
|
||||||
|
|
||||||
|
EnsureStartupWizardIntegrity();
|
||||||
|
|
||||||
Resolve<ITaskManager>().AddTasks(GetExports<IScheduledTask>(false));
|
Resolve<ITaskManager>().AddTasks(GetExports<IScheduledTask>(false));
|
||||||
|
|
||||||
ConfigurationManager.ConfigurationUpdated += OnConfigurationUpdated;
|
ConfigurationManager.ConfigurationUpdated += OnConfigurationUpdated;
|
||||||
@@ -436,6 +440,24 @@ namespace Emby.Server.Implementations
|
|||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void EnsureStartupWizardIntegrity()
|
||||||
|
{
|
||||||
|
if (ConfigurationManager.CommonConfiguration.IsStartupWizardCompleted)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var hasConfiguredAdministrator = Resolve<IUserManager>().GetUsers()
|
||||||
|
.Any(user => user.HasPermission(PermissionKind.IsAdministrator) && !string.IsNullOrEmpty(user.Password));
|
||||||
|
|
||||||
|
if (hasConfiguredAdministrator)
|
||||||
|
{
|
||||||
|
Logger.LogWarning("The startup wizard is marked incomplete but a configured administrator already exists. Marking setup as completed to prevent the unauthenticated setup endpoints from being reachable.");
|
||||||
|
ConfigurationManager.Configuration.IsStartupWizardCompleted = true;
|
||||||
|
ConfigurationManager.SaveConfiguration();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public void Init(IServiceCollection serviceCollection)
|
public void Init(IServiceCollection serviceCollection)
|
||||||
{
|
{
|
||||||
@@ -965,8 +987,9 @@ namespace Emby.Server.Implementations
|
|||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public string GetLocalApiUrl(string hostname, string scheme = null, int? port = null)
|
public string GetLocalApiUrl(string hostname, string scheme = null, int? port = null)
|
||||||
{
|
{
|
||||||
// If the smartAPI doesn't start with http then treat it as a host or ip.
|
// If the smartAPI isn't already a complete URL then treat it as a host or ip.
|
||||||
if (hostname.StartsWith("http", StringComparison.OrdinalIgnoreCase))
|
if (hostname.StartsWith("http://", StringComparison.OrdinalIgnoreCase)
|
||||||
|
|| hostname.StartsWith("https://", StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
return hostname.TrimEnd('/');
|
return hostname.TrimEnd('/');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
#pragma warning disable CS1591
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
@@ -10,6 +8,9 @@ using Microsoft.Extensions.Logging;
|
|||||||
|
|
||||||
namespace Emby.Server.Implementations.Devices
|
namespace Emby.Server.Implementations.Devices
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Provides the persistent unique identifier of this server installation.
|
||||||
|
/// </summary>
|
||||||
public class DeviceId
|
public class DeviceId
|
||||||
{
|
{
|
||||||
private readonly IApplicationPaths _appPaths;
|
private readonly IApplicationPaths _appPaths;
|
||||||
@@ -18,12 +19,20 @@ namespace Emby.Server.Implementations.Devices
|
|||||||
|
|
||||||
private string? _id;
|
private string? _id;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="DeviceId"/> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="appPaths">Instance of the <see cref="IApplicationPaths"/> interface.</param>
|
||||||
|
/// <param name="logger">Instance of the <see cref="ILogger{DeviceId}"/> interface.</param>
|
||||||
public DeviceId(IApplicationPaths appPaths, ILogger<DeviceId> logger)
|
public DeviceId(IApplicationPaths appPaths, ILogger<DeviceId> logger)
|
||||||
{
|
{
|
||||||
_appPaths = appPaths;
|
_appPaths = appPaths;
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the device id, loading it from disk or generating and persisting a new one if none exists.
|
||||||
|
/// </summary>
|
||||||
public string Value => _id ??= GetDeviceId();
|
public string Value => _id ??= GetDeviceId();
|
||||||
|
|
||||||
private string CachePath => Path.Combine(_appPaths.DataPath, "device.txt");
|
private string CachePath => Path.Combine(_appPaths.DataPath, "device.txt");
|
||||||
|
|||||||
@@ -71,6 +71,8 @@ namespace Emby.Server.Implementations.Dto
|
|||||||
{
|
{
|
||||||
BaseItemKind.Person, [
|
BaseItemKind.Person, [
|
||||||
BaseItemKind.Audio,
|
BaseItemKind.Audio,
|
||||||
|
BaseItemKind.AudioBook,
|
||||||
|
BaseItemKind.Book,
|
||||||
BaseItemKind.Episode,
|
BaseItemKind.Episode,
|
||||||
BaseItemKind.Movie,
|
BaseItemKind.Movie,
|
||||||
BaseItemKind.LiveTvProgram,
|
BaseItemKind.LiveTvProgram,
|
||||||
@@ -167,9 +169,13 @@ namespace Emby.Server.Implementations.Dto
|
|||||||
|
|
||||||
// Batch-fetch user data for all items
|
// Batch-fetch user data for all items
|
||||||
Dictionary<Guid, UserItemData>? userDataBatch = null;
|
Dictionary<Guid, UserItemData>? userDataBatch = null;
|
||||||
|
IReadOnlyDictionary<Guid, VersionResumeData>? resumeDataBatch = null;
|
||||||
if (user is not null && options.EnableUserData)
|
if (user is not null && options.EnableUserData)
|
||||||
{
|
{
|
||||||
userDataBatch = _userDataRepository.GetUserDataBatch(accessibleItems, user);
|
userDataBatch = _userDataRepository.GetUserDataBatch(accessibleItems, user);
|
||||||
|
|
||||||
|
// For items with alternate versions, the most recently played version drives resume.
|
||||||
|
resumeDataBatch = _userDataRepository.GetResumeUserDataBatch(accessibleItems, user);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pre-compute collection folders once to avoid N+1 queries in CanDelete
|
// Pre-compute collection folders once to avoid N+1 queries in CanDelete
|
||||||
@@ -248,7 +254,8 @@ namespace Emby.Server.Implementations.Dto
|
|||||||
allCollectionFolders,
|
allCollectionFolders,
|
||||||
childCountBatch,
|
childCountBatch,
|
||||||
playedCountBatch,
|
playedCountBatch,
|
||||||
artistsBatch);
|
artistsBatch,
|
||||||
|
resumeDataBatch?.GetValueOrDefault(item.Id));
|
||||||
|
|
||||||
if (item is LiveTvChannel tvChannel)
|
if (item is LiveTvChannel tvChannel)
|
||||||
{
|
{
|
||||||
@@ -309,7 +316,8 @@ namespace Emby.Server.Implementations.Dto
|
|||||||
List<Folder>? allCollectionFolders = null,
|
List<Folder>? allCollectionFolders = null,
|
||||||
Dictionary<Guid, int>? childCountBatch = null,
|
Dictionary<Guid, int>? childCountBatch = null,
|
||||||
Dictionary<Guid, (int Played, int Total)>? playedCountBatch = null,
|
Dictionary<Guid, (int Played, int Total)>? playedCountBatch = null,
|
||||||
IReadOnlyDictionary<string, MusicArtist[]>? artistsBatch = null)
|
IReadOnlyDictionary<string, MusicArtist[]>? artistsBatch = null,
|
||||||
|
VersionResumeData? resumeData = null)
|
||||||
{
|
{
|
||||||
var dto = new BaseItemDto
|
var dto = new BaseItemDto
|
||||||
{
|
{
|
||||||
@@ -353,7 +361,8 @@ namespace Emby.Server.Implementations.Dto
|
|||||||
options,
|
options,
|
||||||
userData,
|
userData,
|
||||||
childCountBatch,
|
childCountBatch,
|
||||||
playedCountBatch);
|
playedCountBatch,
|
||||||
|
resumeData);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item is IHasMediaSources
|
if (item is IHasMediaSources
|
||||||
@@ -369,7 +378,7 @@ namespace Emby.Server.Implementations.Dto
|
|||||||
AttachStudios(dto, item);
|
AttachStudios(dto, item);
|
||||||
}
|
}
|
||||||
|
|
||||||
AttachBasicFields(dto, item, owner, options, artistsBatch);
|
AttachBasicFields(dto, item, owner, options, artistsBatch, user);
|
||||||
|
|
||||||
if (options.ContainsField(ItemFields.CanDelete))
|
if (options.ContainsField(ItemFields.CanDelete))
|
||||||
{
|
{
|
||||||
@@ -538,7 +547,8 @@ namespace Emby.Server.Implementations.Dto
|
|||||||
DtoOptions options,
|
DtoOptions options,
|
||||||
UserItemData? userData = null,
|
UserItemData? userData = null,
|
||||||
Dictionary<Guid, int>? childCountBatch = null,
|
Dictionary<Guid, int>? childCountBatch = null,
|
||||||
Dictionary<Guid, (int Played, int Total)>? playedCountBatch = null)
|
Dictionary<Guid, (int Played, int Total)>? playedCountBatch = null,
|
||||||
|
VersionResumeData? resumeData = null)
|
||||||
{
|
{
|
||||||
if (item.IsFolder)
|
if (item.IsFolder)
|
||||||
{
|
{
|
||||||
@@ -600,6 +610,9 @@ namespace Emby.Server.Implementations.Dto
|
|||||||
// Use pre-fetched user data
|
// Use pre-fetched user data
|
||||||
dto.UserData = GetUserItemDataDto(userData, item.Id);
|
dto.UserData = GetUserItemDataDto(userData, item.Id);
|
||||||
item.FillUserDataDtoValues(dto.UserData, userData, dto, user, options);
|
item.FillUserDataDtoValues(dto.UserData, userData, dto, user, options);
|
||||||
|
|
||||||
|
// For items with alternate versions, the most recently played version drives resume.
|
||||||
|
resumeData?.ApplyTo(dto.UserData);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -943,7 +956,8 @@ namespace Emby.Server.Implementations.Dto
|
|||||||
/// <param name="owner">The owner.</param>
|
/// <param name="owner">The owner.</param>
|
||||||
/// <param name="options">The options.</param>
|
/// <param name="options">The options.</param>
|
||||||
/// <param name="artistsBatch">Optional pre-fetched artist lookup shared across a batch of items.</param>
|
/// <param name="artistsBatch">Optional pre-fetched artist lookup shared across a batch of items.</param>
|
||||||
private void AttachBasicFields(BaseItemDto dto, BaseItem item, BaseItem? owner, DtoOptions options, IReadOnlyDictionary<string, MusicArtist[]>? artistsBatch = null)
|
/// <param name="user">The user, for per-user values such as the accessible media source count.</param>
|
||||||
|
private void AttachBasicFields(BaseItemDto dto, BaseItem item, BaseItem? owner, DtoOptions options, IReadOnlyDictionary<string, MusicArtist[]>? artistsBatch = null, User? user = null)
|
||||||
{
|
{
|
||||||
if (options.ContainsField(ItemFields.DateCreated))
|
if (options.ContainsField(ItemFields.DateCreated))
|
||||||
{
|
{
|
||||||
@@ -1074,7 +1088,7 @@ namespace Emby.Server.Implementations.Dto
|
|||||||
dto.ParentId = item.DisplayParentId;
|
dto.ParentId = item.DisplayParentId;
|
||||||
}
|
}
|
||||||
|
|
||||||
AddInheritedImages(dto, item, options, owner);
|
AddInheritedImages(dto, item, options, owner, artistsBatch);
|
||||||
|
|
||||||
if (options.ContainsField(ItemFields.Path))
|
if (options.ContainsField(ItemFields.Path))
|
||||||
{
|
{
|
||||||
@@ -1257,7 +1271,12 @@ namespace Emby.Server.Implementations.Dto
|
|||||||
|
|
||||||
if (options.ContainsField(ItemFields.MediaSourceCount))
|
if (options.ContainsField(ItemFields.MediaSourceCount))
|
||||||
{
|
{
|
||||||
var mediaSourceCount = video.MediaSourceCount;
|
// Match the per-user filtering of the media sources: versions the user cannot
|
||||||
|
// access are not selectable, so they must not count towards the badge either.
|
||||||
|
var mediaSourceCount = user is null
|
||||||
|
|| (!video.PrimaryVersionId.HasValue && video.LinkedAlternateVersions.Length == 0 && !video.HasLocalAlternateVersions)
|
||||||
|
? video.MediaSourceCount
|
||||||
|
: video.GetAllVersions().Count(v => v.Id.Equals(video.Id) || v.IsVisibleStandalone(user));
|
||||||
if (mediaSourceCount != 1)
|
if (mediaSourceCount != 1)
|
||||||
{
|
{
|
||||||
dto.MediaSourceCount = mediaSourceCount;
|
dto.MediaSourceCount = mediaSourceCount;
|
||||||
@@ -1366,38 +1385,22 @@ namespace Emby.Server.Implementations.Dto
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.PreferEpisodeParentPoster)
|
if (options.GetImageLimit(ImageType.Primary) > 0)
|
||||||
{
|
{
|
||||||
var episodeSeason = episode.Season;
|
var episodeSeason = episode.Season;
|
||||||
var seasonPrimaryTag = episodeSeason is not null
|
var seasonPrimaryTag = episodeSeason is not null
|
||||||
? GetTagAndFillBlurhash(dto, episodeSeason, ImageType.Primary)
|
? GetTagAndFillBlurhash(dto, episodeSeason, ImageType.Primary)
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
BaseItem? posterParent = null;
|
|
||||||
if (seasonPrimaryTag is not null)
|
if (seasonPrimaryTag is not null)
|
||||||
{
|
{
|
||||||
dto.ParentPrimaryImageItemId = episodeSeason!.Id;
|
dto.ParentPrimaryImageItemId = episodeSeason!.Id;
|
||||||
dto.ParentPrimaryImageTag = seasonPrimaryTag;
|
dto.ParentPrimaryImageTag = seasonPrimaryTag;
|
||||||
posterParent = episodeSeason;
|
|
||||||
}
|
}
|
||||||
else if (episodeSeries is not null && dto.SeriesPrimaryImageTag is not null)
|
else if (episodeSeries is not null && dto.SeriesPrimaryImageTag is not null)
|
||||||
{
|
{
|
||||||
dto.ParentPrimaryImageItemId = episodeSeries.Id;
|
dto.ParentPrimaryImageItemId = episodeSeries.Id;
|
||||||
dto.ParentPrimaryImageTag = dto.SeriesPrimaryImageTag;
|
dto.ParentPrimaryImageTag = dto.SeriesPrimaryImageTag;
|
||||||
posterParent = episodeSeries;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (posterParent is not null)
|
|
||||||
{
|
|
||||||
if (dto.ImageTags is not null && dto.ImageTags.Remove(ImageType.Primary, out var ownPrimaryTag))
|
|
||||||
{
|
|
||||||
// Only drop the episode's own primary blurhash; keep the poster parent's.
|
|
||||||
dto.ImageBlurHashes?.GetValueOrDefault(ImageType.Primary)?.Remove(ownPrimaryTag);
|
|
||||||
}
|
|
||||||
|
|
||||||
dto.SeriesPrimaryImageTag = null;
|
|
||||||
dto.PrimaryImageAspectRatio = null;
|
|
||||||
AttachPrimaryImageAspectRatio(dto, posterParent);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1516,11 +1519,11 @@ namespace Emby.Server.Implementations.Dto
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private BaseItem? GetImageDisplayParent(BaseItem currentItem, BaseItem originalItem)
|
private BaseItem? GetImageDisplayParent(BaseItem currentItem, BaseItem originalItem, IReadOnlyDictionary<string, MusicArtist[]>? artistsBatch)
|
||||||
{
|
{
|
||||||
if (currentItem is MusicAlbum musicAlbum)
|
if (currentItem is MusicAlbum musicAlbum)
|
||||||
{
|
{
|
||||||
var artist = musicAlbum.GetMusicArtist(new DtoOptions(false));
|
var artist = GetBatchedAlbumArtist(musicAlbum, artistsBatch) ?? musicAlbum.GetMusicArtist(new DtoOptions(false));
|
||||||
if (artist is not null)
|
if (artist is not null)
|
||||||
{
|
{
|
||||||
return artist;
|
return artist;
|
||||||
@@ -1537,7 +1540,20 @@ namespace Emby.Server.Implementations.Dto
|
|||||||
return parent;
|
return parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AddInheritedImages(BaseItemDto dto, BaseItem item, DtoOptions options, BaseItem? owner)
|
private static MusicArtist? GetBatchedAlbumArtist(MusicAlbum album, IReadOnlyDictionary<string, MusicArtist[]>? artistsBatch)
|
||||||
|
{
|
||||||
|
if (artistsBatch is null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
var name = album.AlbumArtists.Count > 0 ? album.AlbumArtists[0] : null;
|
||||||
|
return !string.IsNullOrEmpty(name) && artistsBatch.TryGetValue(name, out var artists) && artists.Length > 0
|
||||||
|
? artists[0]
|
||||||
|
: null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AddInheritedImages(BaseItemDto dto, BaseItem item, DtoOptions options, BaseItem? owner, IReadOnlyDictionary<string, MusicArtist[]>? artistsBatch)
|
||||||
{
|
{
|
||||||
if (item is UserView { ViewType: CollectionType.playlists } playlistsView
|
if (item is UserView { ViewType: CollectionType.playlists } playlistsView
|
||||||
&& options.GetImageLimit(ImageType.Primary) > 0
|
&& options.GetImageLimit(ImageType.Primary) > 0
|
||||||
@@ -1582,7 +1598,7 @@ namespace Emby.Server.Implementations.Dto
|
|||||||
|| (!(imageTags is not null && imageTags.ContainsKey(ImageType.Thumb)) && thumbLimit > 0)
|
|| (!(imageTags is not null && imageTags.ContainsKey(ImageType.Thumb)) && thumbLimit > 0)
|
||||||
|| parent is Series)
|
|| parent is Series)
|
||||||
{
|
{
|
||||||
parent ??= isFirst ? GetImageDisplayParent(item, item) ?? owner : parent;
|
parent ??= isFirst ? GetImageDisplayParent(item, item, artistsBatch) ?? owner : parent;
|
||||||
if (parent is null)
|
if (parent is null)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
@@ -1641,7 +1657,7 @@ namespace Emby.Server.Implementations.Dto
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
parent = GetImageDisplayParent(parent, item);
|
parent = GetImageDisplayParent(parent, item, artistsBatch);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -127,8 +127,12 @@ namespace Emby.Server.Implementations.HttpServer
|
|||||||
{
|
{
|
||||||
receiveResult = await _socket.ReceiveAsync(memory, cancellationToken).ConfigureAwait(false);
|
receiveResult = await _socket.ReceiveAsync(memory, cancellationToken).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch (WebSocketException ex)
|
catch (Exception ex) when (ex is WebSocketException or ObjectDisposedException or OperationCanceledException)
|
||||||
{
|
{
|
||||||
|
// ObjectDisposedException/OperationCanceledException: the socket was torn
|
||||||
|
// down underneath us (e.g. by the keep-alive watchdog after the connection
|
||||||
|
// was declared lost). Fall through so Closed is still raised and the
|
||||||
|
// session can release this connection.
|
||||||
_logger.LogWarning("WS {IP} error receiving data: {Message}", RemoteEndPoint, ex.Message);
|
_logger.LogWarning("WS {IP} error receiving data: {Message}", RemoteEndPoint, ex.Message);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -691,7 +691,7 @@ namespace Emby.Server.Implementations.IO
|
|||||||
}
|
}
|
||||||
catch (Exception ex) when (ex is UnauthorizedAccessException or DirectoryNotFoundException or SecurityException)
|
catch (Exception ex) when (ex is UnauthorizedAccessException or DirectoryNotFoundException or SecurityException)
|
||||||
{
|
{
|
||||||
_logger.LogError(ex, "Failed to enumerate path {Path}", path);
|
_logger.LogWarning("Failed to enumerate path \"{Path}\": {Message}", path, ex.Message);
|
||||||
return Enumerable.Empty<string>();
|
return Enumerable.Empty<string>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using Jellyfin.Api.Extensions;
|
||||||
using Jellyfin.Data.Enums;
|
using Jellyfin.Data.Enums;
|
||||||
using Jellyfin.Database.Implementations.Enums;
|
using Jellyfin.Database.Implementations.Enums;
|
||||||
using MediaBrowser.Common.Configuration;
|
using MediaBrowser.Common.Configuration;
|
||||||
@@ -14,7 +15,6 @@ using MediaBrowser.Controller.Entities;
|
|||||||
using MediaBrowser.Controller.Providers;
|
using MediaBrowser.Controller.Providers;
|
||||||
using MediaBrowser.Model.Entities;
|
using MediaBrowser.Model.Entities;
|
||||||
using MediaBrowser.Model.IO;
|
using MediaBrowser.Model.IO;
|
||||||
using MediaBrowser.Model.Querying;
|
|
||||||
|
|
||||||
namespace Emby.Server.Implementations.Images
|
namespace Emby.Server.Implementations.Images
|
||||||
{
|
{
|
||||||
@@ -28,51 +28,23 @@ namespace Emby.Server.Implementations.Images
|
|||||||
{
|
{
|
||||||
var view = (CollectionFolder)item;
|
var view = (CollectionFolder)item;
|
||||||
var viewType = view.CollectionType;
|
var viewType = view.CollectionType;
|
||||||
|
var includeItemTypes = DtoExtensions.GetBaseItemKindsForCollectionType(viewType);
|
||||||
BaseItemKind[] includeItemTypes;
|
|
||||||
|
|
||||||
switch (viewType)
|
|
||||||
{
|
|
||||||
case CollectionType.movies:
|
|
||||||
includeItemTypes = new[] { BaseItemKind.Movie };
|
|
||||||
break;
|
|
||||||
case CollectionType.tvshows:
|
|
||||||
includeItemTypes = new[] { BaseItemKind.Series };
|
|
||||||
break;
|
|
||||||
case CollectionType.music:
|
|
||||||
includeItemTypes = new[] { BaseItemKind.MusicArtist }; // Music albums usually don't have dedicated backdrops, so use artist instead
|
|
||||||
break;
|
|
||||||
case CollectionType.musicvideos:
|
|
||||||
includeItemTypes = new[] { BaseItemKind.MusicVideo };
|
|
||||||
break;
|
|
||||||
case CollectionType.books:
|
|
||||||
includeItemTypes = new[] { BaseItemKind.Book, BaseItemKind.AudioBook };
|
|
||||||
break;
|
|
||||||
case CollectionType.boxsets:
|
|
||||||
includeItemTypes = new[] { BaseItemKind.BoxSet };
|
|
||||||
break;
|
|
||||||
case CollectionType.homevideos:
|
|
||||||
case CollectionType.photos:
|
|
||||||
includeItemTypes = new[] { BaseItemKind.Video, BaseItemKind.Photo };
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
includeItemTypes = new[] { BaseItemKind.Video, BaseItemKind.Audio, BaseItemKind.Photo, BaseItemKind.Movie, BaseItemKind.Series };
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
var recursive = viewType != CollectionType.playlists;
|
var recursive = viewType != CollectionType.playlists;
|
||||||
|
|
||||||
|
if (viewType == CollectionType.music)
|
||||||
|
{
|
||||||
|
// Music albums usually don't have dedicated backdrops, so use artist instead
|
||||||
|
includeItemTypes = [BaseItemKind.MusicArtist];
|
||||||
|
}
|
||||||
|
|
||||||
return view.GetItemList(new InternalItemsQuery
|
return view.GetItemList(new InternalItemsQuery
|
||||||
{
|
{
|
||||||
CollapseBoxSetItems = false,
|
CollapseBoxSetItems = false,
|
||||||
Recursive = recursive,
|
Recursive = recursive,
|
||||||
DtoOptions = new DtoOptions(false),
|
DtoOptions = new DtoOptions(false),
|
||||||
ImageTypes = new[] { ImageType.Primary },
|
ImageTypes = [ImageType.Primary],
|
||||||
Limit = 8,
|
Limit = 8,
|
||||||
OrderBy = new[]
|
OrderBy = [(ItemSortBy.Random, SortOrder.Ascending)],
|
||||||
{
|
|
||||||
(ItemSortBy.Random, SortOrder.Ascending)
|
|
||||||
},
|
|
||||||
IncludeItemTypes = includeItemTypes
|
IncludeItemTypes = includeItemTypes
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ using MediaBrowser.Model.Configuration;
|
|||||||
using MediaBrowser.Model.Drawing;
|
using MediaBrowser.Model.Drawing;
|
||||||
using MediaBrowser.Model.Dto;
|
using MediaBrowser.Model.Dto;
|
||||||
using MediaBrowser.Model.Entities;
|
using MediaBrowser.Model.Entities;
|
||||||
|
using MediaBrowser.Model.Globalization;
|
||||||
using MediaBrowser.Model.IO;
|
using MediaBrowser.Model.IO;
|
||||||
using MediaBrowser.Model.Library;
|
using MediaBrowser.Model.Library;
|
||||||
using MediaBrowser.Model.Querying;
|
using MediaBrowser.Model.Querying;
|
||||||
@@ -86,6 +87,7 @@ namespace Emby.Server.Implementations.Library
|
|||||||
private readonly IPeopleRepository _peopleRepository;
|
private readonly IPeopleRepository _peopleRepository;
|
||||||
private readonly ExtraResolver _extraResolver;
|
private readonly ExtraResolver _extraResolver;
|
||||||
private readonly IPathManager _pathManager;
|
private readonly IPathManager _pathManager;
|
||||||
|
private readonly ILocalizationManager _localization;
|
||||||
private readonly FastConcurrentLru<Guid, BaseItem> _cache;
|
private readonly FastConcurrentLru<Guid, BaseItem> _cache;
|
||||||
private readonly DotIgnoreIgnoreRule _dotIgnoreIgnoreRule;
|
private readonly DotIgnoreIgnoreRule _dotIgnoreIgnoreRule;
|
||||||
private readonly IMediaStreamRepository _mediaStreamRepository;
|
private readonly IMediaStreamRepository _mediaStreamRepository;
|
||||||
@@ -132,6 +134,7 @@ namespace Emby.Server.Implementations.Library
|
|||||||
/// <param name="peopleRepository">The people repository.</param>
|
/// <param name="peopleRepository">The people repository.</param>
|
||||||
/// <param name="pathManager">The path manager.</param>
|
/// <param name="pathManager">The path manager.</param>
|
||||||
/// <param name="dotIgnoreIgnoreRule">The .ignore rule handler.</param>
|
/// <param name="dotIgnoreIgnoreRule">The .ignore rule handler.</param>
|
||||||
|
/// <param name="localization">The localization manager.</param>
|
||||||
/// <param name="mediaStreamRepository">The media stream repository.</param>
|
/// <param name="mediaStreamRepository">The media stream repository.</param>
|
||||||
/// <param name="externalDataManagerFactory">The external data manager (lazy, to break the DI cycle through ChapterManager).</param>
|
/// <param name="externalDataManagerFactory">The external data manager (lazy, to break the DI cycle through ChapterManager).</param>
|
||||||
public LibraryManager(
|
public LibraryManager(
|
||||||
@@ -157,6 +160,7 @@ namespace Emby.Server.Implementations.Library
|
|||||||
IPeopleRepository peopleRepository,
|
IPeopleRepository peopleRepository,
|
||||||
IPathManager pathManager,
|
IPathManager pathManager,
|
||||||
DotIgnoreIgnoreRule dotIgnoreIgnoreRule,
|
DotIgnoreIgnoreRule dotIgnoreIgnoreRule,
|
||||||
|
ILocalizationManager localization,
|
||||||
IMediaStreamRepository mediaStreamRepository,
|
IMediaStreamRepository mediaStreamRepository,
|
||||||
Lazy<IExternalDataManager> externalDataManagerFactory)
|
Lazy<IExternalDataManager> externalDataManagerFactory)
|
||||||
{
|
{
|
||||||
@@ -184,6 +188,7 @@ namespace Emby.Server.Implementations.Library
|
|||||||
_peopleRepository = peopleRepository;
|
_peopleRepository = peopleRepository;
|
||||||
_pathManager = pathManager;
|
_pathManager = pathManager;
|
||||||
_dotIgnoreIgnoreRule = dotIgnoreIgnoreRule;
|
_dotIgnoreIgnoreRule = dotIgnoreIgnoreRule;
|
||||||
|
_localization = localization;
|
||||||
_extraResolver = new ExtraResolver(loggerFactory.CreateLogger<ExtraResolver>(), namingOptions, directoryService);
|
_extraResolver = new ExtraResolver(loggerFactory.CreateLogger<ExtraResolver>(), namingOptions, directoryService);
|
||||||
|
|
||||||
_configurationManager.ConfigurationUpdated += ConfigurationUpdated;
|
_configurationManager.ConfigurationUpdated += ConfigurationUpdated;
|
||||||
@@ -2315,9 +2320,13 @@ namespace Emby.Server.Implementations.Library
|
|||||||
{
|
{
|
||||||
var comparer = Comparers.FirstOrDefault(c => name == c.Type);
|
var comparer = Comparers.FirstOrDefault(c => name == c.Type);
|
||||||
|
|
||||||
// If it requires a user, create a new one, and assign the user
|
|
||||||
if (comparer is IUserBaseItemComparer)
|
if (comparer is IUserBaseItemComparer)
|
||||||
{
|
{
|
||||||
|
if (user is null)
|
||||||
|
{
|
||||||
|
throw new ArgumentException($"Sort key '{name}' requires a user, but none was provided.");
|
||||||
|
}
|
||||||
|
|
||||||
var userComparer = (IUserBaseItemComparer)Activator.CreateInstance(comparer.GetType())!; // only null for Nullable<T> instances
|
var userComparer = (IUserBaseItemComparer)Activator.CreateInstance(comparer.GetType())!; // only null for Nullable<T> instances
|
||||||
|
|
||||||
userComparer.User = user;
|
userComparer.User = user;
|
||||||
@@ -3195,11 +3204,11 @@ namespace Emby.Server.Implementations.Library
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!episode.ProductionYear.HasValue)
|
if (episode.ProductionYear is null)
|
||||||
{
|
{
|
||||||
episode.ProductionYear = episodeInfo.Year;
|
episode.ProductionYear = episodeInfo.Year;
|
||||||
|
|
||||||
if (episode.ProductionYear.HasValue)
|
if (episode.ProductionYear is not null)
|
||||||
{
|
{
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
@@ -3276,9 +3285,11 @@ namespace Emby.Server.Implementations.Library
|
|||||||
var ownerVideoInfo = VideoResolver.Resolve(owner.Path, isFolder, _namingOptions, libraryRoot: owner.ContainingFolderPath);
|
var ownerVideoInfo = VideoResolver.Resolve(owner.Path, isFolder, _namingOptions, libraryRoot: owner.ContainingFolderPath);
|
||||||
if (ownerVideoInfo is null)
|
if (ownerVideoInfo is null)
|
||||||
{
|
{
|
||||||
yield break;
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var candidates = new List<ExtraCandidate>();
|
||||||
|
|
||||||
var count = filtered.Count;
|
var count = filtered.Count;
|
||||||
for (var i = 0; i < count; i++)
|
for (var i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
@@ -3292,35 +3303,50 @@ namespace Emby.Server.Implementations.Library
|
|||||||
|
|
||||||
foreach (var file in filesInSubFolderList)
|
foreach (var file in filesInSubFolderList)
|
||||||
{
|
{
|
||||||
if (!_extraResolver.TryGetExtraTypeForOwner(file.FullName, ownerVideoInfo, out var extraType))
|
if (!_extraResolver.TryGetExtraTypeForOwner(file.FullName, ownerVideoInfo, out var extraType, out var extraRule))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
var extra = GetExtra(file, extraType.Value, subFolderIsMixedFolder);
|
AddCandidate(file, extraType.Value, extraRule, subFolderIsMixedFolder);
|
||||||
if (extra is not null)
|
|
||||||
{
|
|
||||||
yield return extra;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (!current.IsDirectory && _extraResolver.TryGetExtraTypeForOwner(current.FullName, ownerVideoInfo, out var extraType))
|
else if (!current.IsDirectory && _extraResolver.TryGetExtraTypeForOwner(current.FullName, ownerVideoInfo, out var extraType, out var extraRule))
|
||||||
{
|
{
|
||||||
var extra = GetExtra(current, extraType.Value, false);
|
AddCandidate(current, extraType.Value, extraRule, false);
|
||||||
if (extra is not null)
|
|
||||||
{
|
|
||||||
yield return extra;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BaseItem? GetExtra(FileSystemMetadata file, ExtraType extraType, bool isInMixedFolder)
|
var extras = new List<BaseItem>();
|
||||||
|
var typeCounters = new Dictionary<ExtraType, int>();
|
||||||
|
|
||||||
|
// Order by path so that the numbering handed out below does not depend on the
|
||||||
|
// order the file system happened to list the folder in
|
||||||
|
foreach (var candidate in candidates.OrderBy(c => c.Extra.Path, StringComparer.Ordinal))
|
||||||
|
{
|
||||||
|
var extra = PrepareExtra(candidate);
|
||||||
|
if (extra is not null)
|
||||||
|
{
|
||||||
|
extras.Add(extra);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return extras;
|
||||||
|
|
||||||
|
void AddCandidate(FileSystemMetadata file, ExtraType extraType, ExtraRule extraRule, bool isInMixedFolder)
|
||||||
{
|
{
|
||||||
var extra = ResolvePath(_fileSystem.GetFileInfo(file.FullName), directoryService, _extraResolver.GetResolversForExtraType(extraType));
|
var extra = ResolvePath(_fileSystem.GetFileInfo(file.FullName), directoryService, _extraResolver.GetResolversForExtraType(extraType));
|
||||||
if (extra is not Video && extra is not Audio)
|
if (extra is Video or Audio)
|
||||||
{
|
{
|
||||||
return null;
|
candidates.Add(new ExtraCandidate(extra, extraType, extraRule, isInMixedFolder));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
BaseItem? PrepareExtra(ExtraCandidate candidate)
|
||||||
|
{
|
||||||
|
var resolved = candidate.Extra;
|
||||||
|
var extra = resolved;
|
||||||
|
var name = GetExtraName(candidate, ownerVideoInfo, typeCounters);
|
||||||
|
|
||||||
// Try to retrieve it from the db. If we don't find it, use the resolved version
|
// Try to retrieve it from the db. If we don't find it, use the resolved version
|
||||||
var itemById = GetItemById(extra.Id);
|
var itemById = GetItemById(extra.Id);
|
||||||
@@ -3329,10 +3355,18 @@ namespace Emby.Server.Implementations.Library
|
|||||||
extra = itemById;
|
extra = itemById;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only update extra type if it is more specific then the currently known extra type
|
// An extra is named after its file, so the file is the source of truth. Items created
|
||||||
if (extra.ExtraType is null or ExtraType.Unknown || extraType != ExtraType.Unknown)
|
// by older versions, or renamed by a metadata provider, are corrected here;
|
||||||
|
// RefreshExtras persists the change.
|
||||||
|
if (!string.IsNullOrEmpty(name) && extra.LockedFields?.Contains(MetadataField.Name) != true)
|
||||||
{
|
{
|
||||||
extra.ExtraType = extraType;
|
extra.Name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Only update extra type if it is more specific then the currently known extra type
|
||||||
|
if (extra.ExtraType is null or ExtraType.Unknown || candidate.ExtraType != ExtraType.Unknown)
|
||||||
|
{
|
||||||
|
extra.ExtraType = candidate.ExtraType;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only return items that are actual extras (have ExtraType set)
|
// Only return items that are actual extras (have ExtraType set)
|
||||||
@@ -3340,7 +3374,7 @@ namespace Emby.Server.Implementations.Library
|
|||||||
// so that RefreshExtras can detect when they need updating and set ForceSave.
|
// so that RefreshExtras can detect when they need updating and set ForceSave.
|
||||||
if (extra.ExtraType is not null)
|
if (extra.ExtraType is not null)
|
||||||
{
|
{
|
||||||
extra.IsInMixedFolder = isInMixedFolder;
|
extra.IsInMixedFolder = candidate.IsInMixedFolder;
|
||||||
return extra;
|
return extra;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3348,6 +3382,57 @@ namespace Emby.Server.Implementations.Library
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the name to give an extra.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="candidate">The resolved extra.</param>
|
||||||
|
/// <param name="ownerVideoInfo">The naming info of the owner.</param>
|
||||||
|
/// <param name="typeCounters">Number of extras named after their type so far, per type.</param>
|
||||||
|
/// <returns>The name.</returns>
|
||||||
|
private string GetExtraName(ExtraCandidate candidate, VideoFileInfo ownerVideoInfo, Dictionary<ExtraType, int> typeCounters)
|
||||||
|
{
|
||||||
|
var isNamedAfterOwner = candidate.ExtraRule.RuleType switch
|
||||||
|
{
|
||||||
|
ExtraRuleType.Filename => true,
|
||||||
|
ExtraRuleType.Suffix => string.Equals(candidate.Extra.Name, ownerVideoInfo.Name, StringComparison.OrdinalIgnoreCase),
|
||||||
|
_ => false
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!isNamedAfterOwner)
|
||||||
|
{
|
||||||
|
return candidate.Extra.Name;
|
||||||
|
}
|
||||||
|
|
||||||
|
typeCounters.TryGetValue(candidate.ExtraType, out var seen);
|
||||||
|
typeCounters[candidate.ExtraType] = seen + 1;
|
||||||
|
|
||||||
|
var typeName = _localization.GetServerLocalizedString(GetExtraTypeNameKey(candidate.ExtraType));
|
||||||
|
|
||||||
|
return seen == 0
|
||||||
|
? typeName
|
||||||
|
: string.Format(
|
||||||
|
CultureInfo.InvariantCulture,
|
||||||
|
_localization.GetServerLocalizedString("NameExtraNumbered"),
|
||||||
|
typeName,
|
||||||
|
seen + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string GetExtraTypeNameKey(ExtraType extraType) => extraType switch
|
||||||
|
{
|
||||||
|
ExtraType.Clip => "NameExtraClip",
|
||||||
|
ExtraType.Trailer => "NameExtraTrailer",
|
||||||
|
ExtraType.BehindTheScenes => "NameExtraBehindTheScenes",
|
||||||
|
ExtraType.DeletedScene => "NameExtraDeletedScene",
|
||||||
|
ExtraType.Interview => "NameExtraInterview",
|
||||||
|
ExtraType.Scene => "NameExtraScene",
|
||||||
|
ExtraType.Sample => "NameExtraSample",
|
||||||
|
ExtraType.ThemeSong => "NameExtraThemeSong",
|
||||||
|
ExtraType.ThemeVideo => "NameExtraThemeVideo",
|
||||||
|
ExtraType.Featurette => "NameExtraFeaturette",
|
||||||
|
ExtraType.Short => "NameExtraShort",
|
||||||
|
_ => "NameExtraUnknown"
|
||||||
|
};
|
||||||
|
|
||||||
public string GetPathAfterNetworkSubstitution(string path, BaseItem? ownerItem)
|
public string GetPathAfterNetworkSubstitution(string path, BaseItem? ownerItem)
|
||||||
{
|
{
|
||||||
foreach (var map in _configurationManager.Configuration.PathSubstitutions)
|
foreach (var map in _configurationManager.Configuration.PathSubstitutions)
|
||||||
@@ -3886,5 +3971,19 @@ namespace Emby.Server.Implementations.Library
|
|||||||
{
|
{
|
||||||
return _mediaStreamRepository.GetMediaStreamLanguages(mediaStreamType);
|
return _mediaStreamRepository.GetMediaStreamLanguages(mediaStreamType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public IReadOnlyList<string> GetMediaStreamLanguages(MediaStreamType mediaStreamType, InternalItemsQuery query)
|
||||||
|
{
|
||||||
|
if (query.User is not null)
|
||||||
|
{
|
||||||
|
AddUserToQuery(query, query.User);
|
||||||
|
}
|
||||||
|
|
||||||
|
SetTopParentOrAncestorIds(query);
|
||||||
|
return _itemRepository.GetMediaStreamLanguages(query, mediaStreamType);
|
||||||
|
}
|
||||||
|
|
||||||
|
private sealed record ExtraCandidate(BaseItem Extra, ExtraType ExtraType, ExtraRule ExtraRule, bool IsInMixedFolder);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -229,7 +229,11 @@ namespace Emby.Server.Implementations.Library
|
|||||||
list.Add(source);
|
list.Add(source);
|
||||||
}
|
}
|
||||||
|
|
||||||
return SortMediaSources(list, item.Id).ToArray();
|
var preferredId = mediaSources.Count > 0 && Guid.TryParse(mediaSources[0].Id, out var topSourceId)
|
||||||
|
? topSourceId
|
||||||
|
: item.Id;
|
||||||
|
|
||||||
|
return SortMediaSources(list, preferredId).ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />>
|
/// <inheritdoc />>
|
||||||
@@ -406,6 +410,59 @@ namespace Emby.Server.Implementations.Library
|
|||||||
source.SupportsDirectStream = user.HasPermission(PermissionKind.EnablePlaybackRemuxing);
|
source.SupportsDirectStream = user.HasPermission(PermissionKind.EnablePlaybackRemuxing);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sources = SetAlternateVersionResumeStates(item, sources, user);
|
||||||
|
}
|
||||||
|
|
||||||
|
return sources;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// When the queried item is a primary, moves the most recently played version to the front so
|
||||||
|
/// that resuming without an explicit source selection plays the version that was last watched.
|
||||||
|
/// A directly queried alternate version keeps its own source first. Per-user playback position
|
||||||
|
/// is not surfaced on the source itself; it is carried by each version's own UserData.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="item">The queried item.</param>
|
||||||
|
/// <param name="sources">The item's media sources.</param>
|
||||||
|
/// <param name="user">The user.</param>
|
||||||
|
/// <returns>The media sources, reordered when a version drives resume.</returns>
|
||||||
|
private IReadOnlyList<MediaSourceInfo> SetAlternateVersionResumeStates(BaseItem item, IReadOnlyList<MediaSourceInfo> sources, User user)
|
||||||
|
{
|
||||||
|
// For a video, multiple sources means alternate versions.
|
||||||
|
if (item is not Video video || sources.Count < 2)
|
||||||
|
{
|
||||||
|
return sources;
|
||||||
|
}
|
||||||
|
|
||||||
|
var versions = video.GetAllVersions();
|
||||||
|
if (versions.Count < 2)
|
||||||
|
{
|
||||||
|
return sources;
|
||||||
|
}
|
||||||
|
|
||||||
|
var userDataByVersion = _userDataManager.GetUserDataBatch(versions, user);
|
||||||
|
var dataBySourceId = new Dictionary<string, UserItemData>(versions.Count, StringComparer.OrdinalIgnoreCase);
|
||||||
|
foreach (var version in versions)
|
||||||
|
{
|
||||||
|
if (userDataByVersion.TryGetValue(version.Id, out var data))
|
||||||
|
{
|
||||||
|
dataBySourceId[version.Id.ToString("N", CultureInfo.InvariantCulture)] = data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reorder only for a resumable (in-progress) version;
|
||||||
|
// a completed version has no position to resume, so it must not be pulled to the front here.
|
||||||
|
var resumeSource = VersionPlaybackSelector.SelectMostRecentlyPlayed(
|
||||||
|
sources,
|
||||||
|
source => source.Id is not null ? dataBySourceId.GetValueOrDefault(source.Id) : null,
|
||||||
|
data => data.PlaybackPositionTicks > 0);
|
||||||
|
|
||||||
|
if (resumeSource is not null && !video.PrimaryVersionId.HasValue && !ReferenceEquals(sources[0], resumeSource))
|
||||||
|
{
|
||||||
|
var reordered = new List<MediaSourceInfo>(sources.Count) { resumeSource };
|
||||||
|
reordered.AddRange(sources.Where(s => !ReferenceEquals(s, resumeSource)));
|
||||||
|
return reordered;
|
||||||
}
|
}
|
||||||
|
|
||||||
return sources;
|
return sources;
|
||||||
|
|||||||
@@ -29,17 +29,41 @@ namespace Emby.Server.Implementations.Library
|
|||||||
throw new ArgumentException("String can't be empty.", nameof(attribute));
|
throw new ArgumentException("String can't be empty.", nameof(attribute));
|
||||||
}
|
}
|
||||||
|
|
||||||
var attributeIndex = str.IndexOf(attribute, StringComparison.OrdinalIgnoreCase);
|
// Allow tmdb as an alias for tmdbid, tvdb for tvdbid, etc.
|
||||||
|
// The code below only supports aliases for attributes in the form of "<alias>id".
|
||||||
// Must be at least 3 characters after the attribute =, ], any character,
|
ReadOnlySpan<char> shortAttr = attribute switch
|
||||||
// then we offset it by 1, because we want the index and not length.
|
|
||||||
var maxIndex = str.Length - attribute.Length - 2;
|
|
||||||
while (attributeIndex > -1 && attributeIndex < maxIndex)
|
|
||||||
{
|
{
|
||||||
var attributeEnd = attributeIndex + attribute.Length;
|
_ when attribute.Equals("tmdbid", StringComparison.OrdinalIgnoreCase) => "tmdb",
|
||||||
|
_ when attribute.Equals("tvdbid", StringComparison.OrdinalIgnoreCase) => "tvdb",
|
||||||
|
_ when attribute.Equals("imdbid", StringComparison.OrdinalIgnoreCase) => "imdb",
|
||||||
|
_ => ReadOnlySpan<char>.Empty
|
||||||
|
};
|
||||||
|
|
||||||
|
for (int strIndex = 0, attributeIndex = 0; attributeIndex > -1;)
|
||||||
|
{
|
||||||
|
// We may want to use imdbid pattern matching later, so we don't want to modify the original 'str'.
|
||||||
|
var subStr = str[strIndex..];
|
||||||
|
int attributeEnd = 0;
|
||||||
|
|
||||||
|
if (shortAttr.Length > 0)
|
||||||
|
{
|
||||||
|
// If we are using an alias it should be shorter (and a prefix), so let's search for that.
|
||||||
|
attributeIndex = subStr.IndexOf(shortAttr, StringComparison.OrdinalIgnoreCase);
|
||||||
|
attributeEnd = attributeIndex + shortAttr.Length;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
attributeIndex = subStr.IndexOf(attribute, StringComparison.OrdinalIgnoreCase);
|
||||||
|
attributeEnd = attributeIndex + attribute.Length;
|
||||||
|
}
|
||||||
|
|
||||||
|
// The next iteration should start at the end of the attribute we just found.
|
||||||
|
// If attributeIndex < 0, the loop will end and strIndex won't be used again.
|
||||||
|
strIndex += attributeEnd;
|
||||||
|
|
||||||
if (attributeIndex > 0)
|
if (attributeIndex > 0)
|
||||||
{
|
{
|
||||||
var attributeOpener = str[attributeIndex - 1];
|
var attributeOpener = subStr[attributeIndex - 1];
|
||||||
var attributeCloser = attributeOpener switch
|
var attributeCloser = attributeOpener switch
|
||||||
{
|
{
|
||||||
'[' => ']',
|
'[' => ']',
|
||||||
@@ -47,20 +71,37 @@ namespace Emby.Server.Implementations.Library
|
|||||||
'{' => '}',
|
'{' => '}',
|
||||||
_ => '\0'
|
_ => '\0'
|
||||||
};
|
};
|
||||||
if (attributeCloser != '\0' && (str[attributeEnd] == '=' || str[attributeEnd] == '-'))
|
|
||||||
{
|
|
||||||
var closingIndex = str[attributeEnd..].IndexOf(attributeCloser);
|
|
||||||
|
|
||||||
// Must be at least 1 character before the closing bracket.
|
if (attributeCloser != '\0')
|
||||||
if (closingIndex > 1)
|
{
|
||||||
|
if (shortAttr.Length > 0
|
||||||
|
&& attributeEnd + 1 < subStr.Length
|
||||||
|
&& (subStr[attributeEnd] is 'i' or 'I')
|
||||||
|
&& (subStr[attributeEnd + 1] is 'd' or 'D'))
|
||||||
{
|
{
|
||||||
return str[(attributeEnd + 1)..(attributeEnd + closingIndex)].Trim().ToString();
|
// We were searching for a shortened attribute, but it's followed by "id" - let's skip it.
|
||||||
|
attributeEnd += 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
// attributeEnd points at '='.
|
||||||
|
// We need at least 1 more character and the closing bracket after that.
|
||||||
|
if (attributeEnd + 2 < subStr.Length && (subStr[attributeEnd] is '=' or '-'))
|
||||||
|
{
|
||||||
|
var closingIndex = subStr[attributeEnd..].IndexOf(attributeCloser);
|
||||||
|
|
||||||
|
// Must be at least 1 character before the closing bracket.
|
||||||
|
if (closingIndex > 1)
|
||||||
|
{
|
||||||
|
var trimmed = subStr[(attributeEnd + 1)..(attributeEnd + closingIndex)].Trim();
|
||||||
|
|
||||||
|
if (trimmed.Length > 0)
|
||||||
|
{
|
||||||
|
return trimmed.ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
str = str[attributeEnd..];
|
|
||||||
attributeIndex = str.IndexOf(attribute, StringComparison.OrdinalIgnoreCase);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// for imdbid we also accept pattern matching
|
// for imdbid we also accept pattern matching
|
||||||
@@ -70,16 +111,6 @@ namespace Emby.Server.Implementations.Library
|
|||||||
return match ? imdbId.ToString() : null;
|
return match ? imdbId.ToString() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allow tmdb as an alias for tmdbid
|
|
||||||
if (attribute.Equals("tmdbid", StringComparison.OrdinalIgnoreCase))
|
|
||||||
{
|
|
||||||
var tmdbValue = str.GetAttributeValue("tmdb");
|
|
||||||
if (tmdbValue is not null)
|
|
||||||
{
|
|
||||||
return tmdbValue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using Jellyfin.Extensions;
|
||||||
using MediaBrowser.Common.Configuration;
|
using MediaBrowser.Common.Configuration;
|
||||||
using MediaBrowser.Controller.Configuration;
|
using MediaBrowser.Controller.Configuration;
|
||||||
using MediaBrowser.Controller.Entities;
|
using MediaBrowser.Controller.Entities;
|
||||||
@@ -43,7 +44,19 @@ public class PathManager : IPathManager
|
|||||||
public string? GetAttachmentPath(string mediaSourceId, string fileName)
|
public string? GetAttachmentPath(string mediaSourceId, string fileName)
|
||||||
{
|
{
|
||||||
var folder = GetAttachmentFolderPath(mediaSourceId);
|
var folder = GetAttachmentFolderPath(mediaSourceId);
|
||||||
return folder is null ? null : Path.Combine(folder, fileName);
|
if (folder is null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
var safeName = PathHelper.GetSafeLeafFileName(fileName);
|
||||||
|
if (safeName is null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Rejecting attachment filename '{FileName}' for MediaSource {MediaSourceId}: not a valid leaf name.", fileName, mediaSourceId);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Path.Combine(folder, safeName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
|
|||||||
@@ -32,8 +32,8 @@ namespace Emby.Server.Implementations.Library.Resolvers
|
|||||||
: base(logger, namingOptions, directoryService)
|
: base(logger, namingOptions, directoryService)
|
||||||
{
|
{
|
||||||
_namingOptions = namingOptions;
|
_namingOptions = namingOptions;
|
||||||
_trailerResolvers = new IItemResolver[] { new GenericVideoResolver<Trailer>(logger, namingOptions, directoryService) };
|
_trailerResolvers = [new GenericVideoResolver<Trailer>(logger, namingOptions, directoryService, parseName: true)];
|
||||||
_videoResolvers = new IItemResolver[] { this };
|
_videoResolvers = [this];
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override Video Resolve(ItemResolveArgs args)
|
protected override Video Resolve(ItemResolveArgs args)
|
||||||
@@ -54,12 +54,13 @@ namespace Emby.Server.Implementations.Library.Resolvers
|
|||||||
_ => _videoResolvers
|
_ => _videoResolvers
|
||||||
};
|
};
|
||||||
|
|
||||||
public bool TryGetExtraTypeForOwner(string path, VideoFileInfo ownerVideoFileInfo, [NotNullWhen(true)] out ExtraType? extraType, string? libraryRoot = "")
|
public bool TryGetExtraTypeForOwner(string path, VideoFileInfo ownerVideoFileInfo, [NotNullWhen(true)] out ExtraType? extraType, [NotNullWhen(true)] out ExtraRule? extraRule, string? libraryRoot = "")
|
||||||
{
|
{
|
||||||
var extraResult = GetExtraInfo(path, _namingOptions, libraryRoot);
|
var extraResult = GetExtraInfo(path, _namingOptions, libraryRoot);
|
||||||
if (extraResult.ExtraType is null)
|
if (extraResult.ExtraType is null || extraResult.Rule is null)
|
||||||
{
|
{
|
||||||
extraType = null;
|
extraType = null;
|
||||||
|
extraRule = null;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,6 +89,7 @@ namespace Emby.Server.Implementations.Library.Resolvers
|
|||||||
}
|
}
|
||||||
|
|
||||||
extraType = extraResult.ExtraType;
|
extraType = extraResult.ExtraType;
|
||||||
|
extraRule = extraResult.Rule;
|
||||||
return isValid;
|
return isValid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
using Emby.Naming.Common;
|
using Emby.Naming.Common;
|
||||||
using MediaBrowser.Controller.Entities;
|
using MediaBrowser.Controller.Entities;
|
||||||
|
using MediaBrowser.Controller.Library;
|
||||||
using MediaBrowser.Controller.Providers;
|
using MediaBrowser.Controller.Providers;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
@@ -14,15 +15,25 @@ namespace Emby.Server.Implementations.Library.Resolvers
|
|||||||
public class GenericVideoResolver<T> : BaseVideoResolver<T>
|
public class GenericVideoResolver<T> : BaseVideoResolver<T>
|
||||||
where T : Video, new()
|
where T : Video, new()
|
||||||
{
|
{
|
||||||
|
private readonly bool _parseName;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="GenericVideoResolver{T}"/> class.
|
/// Initializes a new instance of the <see cref="GenericVideoResolver{T}"/> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="logger">The logger.</param>
|
/// <param name="logger">The logger.</param>
|
||||||
/// <param name="namingOptions">The naming options.</param>
|
/// <param name="namingOptions">The naming options.</param>
|
||||||
/// <param name="directoryService">The directory service.</param>
|
/// <param name="directoryService">The directory service.</param>
|
||||||
public GenericVideoResolver(ILogger logger, NamingOptions namingOptions, IDirectoryService directoryService)
|
/// <param name="parseName">Whether to parse the file name for metadata such as the year.</param>
|
||||||
|
public GenericVideoResolver(ILogger logger, NamingOptions namingOptions, IDirectoryService directoryService, bool parseName = false)
|
||||||
: base(logger, namingOptions, directoryService)
|
: base(logger, namingOptions, directoryService)
|
||||||
{
|
{
|
||||||
|
_parseName = parseName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override T Resolve(ItemResolveArgs args)
|
||||||
|
{
|
||||||
|
return ResolveVideo<T>(args, _parseName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -376,15 +376,24 @@ namespace Emby.Server.Implementations.Library.Resolvers.Movies
|
|||||||
// We need to only look at the name of this actual item (not parents)
|
// We need to only look at the name of this actual item (not parents)
|
||||||
var justName = item.IsInMixedFolder ? Path.GetFileName(item.Path.AsSpan()) : Path.GetFileName(item.ContainingFolderPath.AsSpan());
|
var justName = item.IsInMixedFolder ? Path.GetFileName(item.Path.AsSpan()) : Path.GetFileName(item.ContainingFolderPath.AsSpan());
|
||||||
|
|
||||||
var tmdbid = justName.GetAttributeValue("tmdbid");
|
// The fallback filename is only used when the item isn't in a mixed folder
|
||||||
|
var fileName = item.IsInMixedFolder ? ReadOnlySpan<char>.Empty : Path.GetFileName(item.Path.AsSpan());
|
||||||
|
|
||||||
// If not in a mixed folder and ID not found in folder path, check filename
|
item.TrySetProviderId(MetadataProvider.Tmdb, GetIdFromNameOrPath(justName, fileName, "tmdbid"));
|
||||||
if (string.IsNullOrEmpty(tmdbid) && !item.IsInMixedFolder)
|
item.TrySetProviderId(MetadataProvider.Tvdb, GetIdFromNameOrPath(justName, fileName, "tvdbid"));
|
||||||
|
|
||||||
|
string GetIdFromNameOrPath(ReadOnlySpan<char> name, ReadOnlySpan<char> fallbackName, string attribute)
|
||||||
{
|
{
|
||||||
tmdbid = Path.GetFileName(item.Path.AsSpan()).GetAttributeValue("tmdbid");
|
var id = name.GetAttributeValue(attribute);
|
||||||
}
|
|
||||||
|
|
||||||
item.TrySetProviderId(MetadataProvider.Tmdb, tmdbid);
|
// If not in a mixed folder and ID not found in folder path, check filename
|
||||||
|
if (string.IsNullOrEmpty(id) && !item.IsInMixedFolder)
|
||||||
|
{
|
||||||
|
id = fallbackName.GetAttributeValue(attribute);
|
||||||
|
}
|
||||||
|
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(item.Path))
|
if (!string.IsNullOrEmpty(item.Path))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using Emby.Server.Implementations.Playlists;
|
||||||
using Jellyfin.Data.Enums;
|
using Jellyfin.Data.Enums;
|
||||||
using Jellyfin.Extensions;
|
using Jellyfin.Extensions;
|
||||||
using MediaBrowser.Controller.Library;
|
using MediaBrowser.Controller.Library;
|
||||||
@@ -45,8 +47,30 @@ namespace Emby.Server.Implementations.Library.Resolvers
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Anything directly inside the internal playlists folder is a playlist, even when its
|
||||||
|
// playlist.xml is missing: failing to resolve here makes the library scan treat the
|
||||||
|
// playlist as deleted from disk and remove it, taking its items with it.
|
||||||
|
if (args.Parent is PlaylistsFolder)
|
||||||
|
{
|
||||||
|
return new Playlist
|
||||||
|
{
|
||||||
|
Path = args.Path,
|
||||||
|
Name = filename,
|
||||||
|
OpenAccess = true
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
// It's a directory-based playlist if the directory contains a playlist file
|
// It's a directory-based playlist if the directory contains a playlist file
|
||||||
var filePaths = Directory.EnumerateFiles(args.Path, "*", new EnumerationOptions { IgnoreInaccessible = true });
|
IEnumerable<string> filePaths;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
filePaths = Directory.EnumerateFiles(args.Path, "*", new EnumerationOptions { IgnoreInaccessible = true });
|
||||||
|
}
|
||||||
|
catch (IOException)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
if (filePaths.Any(f => f.EndsWith(PlaylistXmlSaver.DefaultPlaylistFilename, StringComparison.OrdinalIgnoreCase)))
|
if (filePaths.Any(f => f.EndsWith(PlaylistXmlSaver.DefaultPlaylistFilename, StringComparison.OrdinalIgnoreCase)))
|
||||||
{
|
{
|
||||||
return new Playlist
|
return new Playlist
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ public sealed class MovieSimilarItemsProvider : ILocalSimilarItemsProvider<Movie
|
|||||||
private readonly IDbContextFactory<JellyfinDbContext> _dbProvider;
|
private readonly IDbContextFactory<JellyfinDbContext> _dbProvider;
|
||||||
private readonly IItemQueryHelpers _queryHelpers;
|
private readonly IItemQueryHelpers _queryHelpers;
|
||||||
private readonly IServerConfigurationManager _serverConfigurationManager;
|
private readonly IServerConfigurationManager _serverConfigurationManager;
|
||||||
|
private readonly ILibraryManager _libraryManager;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="MovieSimilarItemsProvider"/> class.
|
/// Initializes a new instance of the <see cref="MovieSimilarItemsProvider"/> class.
|
||||||
@@ -60,14 +61,17 @@ public sealed class MovieSimilarItemsProvider : ILocalSimilarItemsProvider<Movie
|
|||||||
/// <param name="dbProvider">The database context factory.</param>
|
/// <param name="dbProvider">The database context factory.</param>
|
||||||
/// <param name="queryHelpers">The shared query helpers.</param>
|
/// <param name="queryHelpers">The shared query helpers.</param>
|
||||||
/// <param name="serverConfigurationManager">The server configuration manager.</param>
|
/// <param name="serverConfigurationManager">The server configuration manager.</param>
|
||||||
|
/// <param name="libraryManager">The library manager.</param>
|
||||||
public MovieSimilarItemsProvider(
|
public MovieSimilarItemsProvider(
|
||||||
IDbContextFactory<JellyfinDbContext> dbProvider,
|
IDbContextFactory<JellyfinDbContext> dbProvider,
|
||||||
IItemQueryHelpers queryHelpers,
|
IItemQueryHelpers queryHelpers,
|
||||||
IServerConfigurationManager serverConfigurationManager)
|
IServerConfigurationManager serverConfigurationManager,
|
||||||
|
ILibraryManager libraryManager)
|
||||||
{
|
{
|
||||||
_dbProvider = dbProvider;
|
_dbProvider = dbProvider;
|
||||||
_queryHelpers = queryHelpers;
|
_queryHelpers = queryHelpers;
|
||||||
_serverConfigurationManager = serverConfigurationManager;
|
_serverConfigurationManager = serverConfigurationManager;
|
||||||
|
_libraryManager = libraryManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
@@ -156,6 +160,11 @@ public sealed class MovieSimilarItemsProvider : ILocalSimilarItemsProvider<Movie
|
|||||||
IsPlayed = false
|
IsPlayed = false
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (query.User is not null)
|
||||||
|
{
|
||||||
|
_libraryManager.ConfigureUserAccess(filter, query.User);
|
||||||
|
}
|
||||||
|
|
||||||
_queryHelpers.PrepareFilterQuery(filter);
|
_queryHelpers.PrepareFilterQuery(filter);
|
||||||
var baseQuery = _queryHelpers.PrepareItemQuery(context, filter);
|
var baseQuery = _queryHelpers.PrepareItemQuery(context, filter);
|
||||||
baseQuery = _queryHelpers.TranslateQuery(baseQuery, context, filter);
|
baseQuery = _queryHelpers.TranslateQuery(baseQuery, context, filter);
|
||||||
|
|||||||
@@ -192,7 +192,8 @@ namespace Emby.Server.Implementations.Library
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var userData = item.UserData?.Where(e => e.UserId.Equals(user.Id)).Select(Map).FirstOrDefault();
|
var userDataRow = ResolveUserDataRow(item, item.UserData?.Where(e => e.UserId.Equals(user.Id)));
|
||||||
|
var userData = userDataRow is not null ? Map(userDataRow) : null;
|
||||||
if (userData is not null)
|
if (userData is not null)
|
||||||
{
|
{
|
||||||
result[item.Id] = userData;
|
result[item.Id] = userData;
|
||||||
@@ -211,36 +212,128 @@ namespace Emby.Server.Implementations.Library
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build a single query for all missing items
|
// Build a single query for all missing items. Fetch rows by item alone so rows kept
|
||||||
|
// under keys from older metadata resolve the same way as the in-memory path.
|
||||||
var allItemIds = itemsNeedingQuery.Select(x => x.Item.Id).ToList();
|
var allItemIds = itemsNeedingQuery.Select(x => x.Item.Id).ToList();
|
||||||
var allKeys = itemsNeedingQuery.SelectMany(x => x.Keys).Distinct().ToList();
|
using var context = _repository.CreateDbContext();
|
||||||
if (allKeys.Count > 0)
|
var userDataArray = context.UserData
|
||||||
|
.AsNoTracking()
|
||||||
|
.Where(e => e.UserId.Equals(user.Id))
|
||||||
|
.WhereOneOrMany(allItemIds, e => e.ItemId)
|
||||||
|
.ToArray();
|
||||||
|
|
||||||
|
var userDataByItem = userDataArray.GroupBy(e => e.ItemId).ToDictionary(g => g.Key, g => g.ToArray());
|
||||||
|
foreach (var (item, keys) in itemsNeedingQuery)
|
||||||
{
|
{
|
||||||
using var context = _repository.CreateDbContext();
|
UserItemData userData;
|
||||||
var userDataArray = context.UserData
|
if (userDataByItem.TryGetValue(item.Id, out var itemUserData) && itemUserData.Length > 0)
|
||||||
.AsNoTracking()
|
|
||||||
.Where(e => e.UserId.Equals(user.Id))
|
|
||||||
.WhereOneOrMany(allItemIds, e => e.ItemId)
|
|
||||||
.WhereOneOrMany(allKeys, e => e.CustomDataKey)
|
|
||||||
.ToArray();
|
|
||||||
|
|
||||||
var userDataByItem = userDataArray.GroupBy(e => e.ItemId).ToDictionary(g => g.Key, g => g.ToArray());
|
|
||||||
foreach (var (item, keys) in itemsNeedingQuery)
|
|
||||||
{
|
{
|
||||||
UserItemData userData;
|
userData = Map(ResolveUserDataRow(item, itemUserData)!);
|
||||||
if (userDataByItem.TryGetValue(item.Id, out var itemUserData) && itemUserData.Length > 0)
|
}
|
||||||
{
|
else
|
||||||
var directDataReference = itemUserData.FirstOrDefault(e => e.CustomDataKey == item.Id.ToString("N"));
|
{
|
||||||
userData = directDataReference is not null ? Map(directDataReference) : Map(itemUserData.First());
|
userData = new UserItemData { Key = keys.Count > 0 ? keys[0] : string.Empty };
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
userData = new UserItemData { Key = keys.Count > 0 ? keys[0] : string.Empty };
|
|
||||||
}
|
|
||||||
|
|
||||||
result[item.Id] = userData;
|
result[item.Id] = userData;
|
||||||
var cacheKey = GetCacheKey(user.InternalId, item.Id);
|
var cacheKey = GetCacheKey(user.InternalId, item.Id);
|
||||||
_cache.AddOrUpdate(cacheKey, userData);
|
_cache.AddOrUpdate(cacheKey, userData);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public VersionResumeData? GetResumeUserData(User user, BaseItem item)
|
||||||
|
{
|
||||||
|
return GetResumeUserDataBatch([item], user).GetValueOrDefault(item.Id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public IReadOnlyDictionary<Guid, VersionResumeData> GetResumeUserDataBatch(IReadOnlyList<BaseItem> items, User user)
|
||||||
|
{
|
||||||
|
ArgumentNullException.ThrowIfNull(user);
|
||||||
|
|
||||||
|
var result = new Dictionary<Guid, VersionResumeData>();
|
||||||
|
|
||||||
|
// Candidate primaries: a directly queried version (PrimaryVersionId set) keeps its own data.
|
||||||
|
// Linked alternates are already known in memory; only the local-alternate existence check
|
||||||
|
// would otherwise hit the database (one query per item via Video.HasLocalAlternateVersions),
|
||||||
|
// so collect those ids and resolve them all in a single query below.
|
||||||
|
List<Video>? candidates = null;
|
||||||
|
List<Guid>? localProbeIds = null;
|
||||||
|
foreach (var item in items)
|
||||||
|
{
|
||||||
|
if (item is not Video video || video.PrimaryVersionId.HasValue)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
(candidates ??= []).Add(video);
|
||||||
|
|
||||||
|
if (video.LinkedAlternateVersions.Length == 0)
|
||||||
|
{
|
||||||
|
(localProbeIds ??= []).Add(video.Id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (candidates is null)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
HashSet<Guid>? withLocalAlternates = null;
|
||||||
|
if (localProbeIds is not null)
|
||||||
|
{
|
||||||
|
using var dbContext = _repository.CreateDbContext();
|
||||||
|
withLocalAlternates = dbContext.LinkedChildren
|
||||||
|
.Where(lc => lc.ChildType == Jellyfin.Database.Implementations.Entities.LinkedChildType.LocalAlternateVersion)
|
||||||
|
.WhereOneOrMany(localProbeIds, lc => lc.ParentId)
|
||||||
|
.Select(lc => lc.ParentId)
|
||||||
|
.Distinct()
|
||||||
|
.ToHashSet();
|
||||||
|
}
|
||||||
|
|
||||||
|
List<(Guid PrimaryId, IReadOnlyList<Video> Versions)>? versionGroups = null;
|
||||||
|
List<BaseItem>? allVersions = null;
|
||||||
|
|
||||||
|
foreach (var video in candidates)
|
||||||
|
{
|
||||||
|
// Only items that actually have alternate versions aggregate over them.
|
||||||
|
if (video.LinkedAlternateVersions.Length == 0
|
||||||
|
&& (withLocalAlternates is null || !withLocalAlternates.Contains(video.Id)))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
var versions = video.GetAllVersions();
|
||||||
|
if (versions.Count < 2)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
(versionGroups ??= []).Add((video.Id, versions));
|
||||||
|
(allVersions ??= []).AddRange(versions);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (versionGroups is null)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
var userDataByVersion = GetUserDataBatch(allVersions!.DistinctBy(i => i.Id).ToList(), user);
|
||||||
|
|
||||||
|
foreach (var (primaryId, versions) in versionGroups)
|
||||||
|
{
|
||||||
|
// Consider both in-progress and completed versions so a finished alternate still marks the primary as played.
|
||||||
|
var resumeVersion = VersionPlaybackSelector.SelectMostRecentlyPlayed(
|
||||||
|
versions,
|
||||||
|
version => userDataByVersion.GetValueOrDefault(version.Id),
|
||||||
|
data => data.PlaybackPositionTicks > 0 || data.Played);
|
||||||
|
|
||||||
|
if (resumeVersion is not null)
|
||||||
|
{
|
||||||
|
result[primaryId] = new VersionResumeData(resumeVersion.Id, userDataByVersion[resumeVersion.Id]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -259,12 +352,41 @@ namespace Emby.Server.Implementations.Library
|
|||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public UserItemData? GetUserData(User user, BaseItem item)
|
public UserItemData? GetUserData(User user, BaseItem item)
|
||||||
{
|
{
|
||||||
return item.UserData?.Where(e => e.UserId.Equals(user.Id)).Select(Map).FirstOrDefault() ?? new UserItemData()
|
ArgumentNullException.ThrowIfNull(user);
|
||||||
|
var row = ResolveUserDataRow(item, item.UserData?.Where(e => e.UserId.Equals(user.Id)));
|
||||||
|
return row is not null ? Map(row) : new UserItemData()
|
||||||
{
|
{
|
||||||
Key = item.GetUserDataKeys()[0],
|
Key = item.GetUserDataKeys()[0],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Picks the row matching the item's current user data keys, in key order, so rows left behind
|
||||||
|
/// under keys from older metadata don't take priority over the rows the write path updates.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="item">The item whose keys to match.</param>
|
||||||
|
/// <param name="rows">The candidate user data rows for a single user.</param>
|
||||||
|
/// <returns>The best matching row, or <c>null</c> when there are none.</returns>
|
||||||
|
private static UserData? ResolveUserDataRow(BaseItem item, IEnumerable<UserData>? rows)
|
||||||
|
{
|
||||||
|
var candidates = rows?.ToList();
|
||||||
|
if (candidates is null || candidates.Count == 0)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var key in item.GetUserDataKeys())
|
||||||
|
{
|
||||||
|
var match = candidates.Find(e => string.Equals(e.CustomDataKey, key, StringComparison.Ordinal));
|
||||||
|
if (match is not null)
|
||||||
|
{
|
||||||
|
return match;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return candidates[0];
|
||||||
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public UserItemDataDto? GetUserDataDto(BaseItem item, User user)
|
public UserItemDataDto? GetUserDataDto(BaseItem item, User user)
|
||||||
=> GetUserDataDto(item, null, user, new DtoOptions());
|
=> GetUserDataDto(item, null, user, new DtoOptions());
|
||||||
@@ -281,6 +403,10 @@ namespace Emby.Server.Implementations.Library
|
|||||||
var dto = GetUserItemDataDto(userData, item.Id);
|
var dto = GetUserItemDataDto(userData, item.Id);
|
||||||
|
|
||||||
item.FillUserDataDtoValues(dto, userData, itemDto, user, options);
|
item.FillUserDataDtoValues(dto, userData, itemDto, user, options);
|
||||||
|
|
||||||
|
// For an item with alternate versions, surface the most recently played version's resume point.
|
||||||
|
GetResumeUserData(user, item)?.ApplyTo(dto);
|
||||||
|
|
||||||
return dto;
|
return dto;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -385,5 +511,41 @@ namespace Emby.Server.Implementations.Library
|
|||||||
|
|
||||||
return playedToCompletion;
|
return playedToCompletion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public void ResetPlaybackStreamSelections(User user, BaseItem item)
|
||||||
|
{
|
||||||
|
ArgumentNullException.ThrowIfNull(user);
|
||||||
|
ArgumentNullException.ThrowIfNull(item);
|
||||||
|
|
||||||
|
using var dbContext = _repository.CreateDbContext();
|
||||||
|
var rows = dbContext.UserData
|
||||||
|
.Where(e => e.ItemId == item.Id && e.UserId == user.Id
|
||||||
|
&& (e.AudioStreamIndex != null || e.SubtitleStreamIndex != null))
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
if (rows.Count == 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var row in rows)
|
||||||
|
{
|
||||||
|
row.AudioStreamIndex = null;
|
||||||
|
row.SubtitleStreamIndex = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
dbContext.SaveChanges();
|
||||||
|
|
||||||
|
var cacheKey = GetCacheKey(user.InternalId, item.Id);
|
||||||
|
if (_cache.TryGet(cacheKey, out var cached))
|
||||||
|
{
|
||||||
|
cached.AudioStreamIndex = null;
|
||||||
|
cached.SubtitleStreamIndex = null;
|
||||||
|
_cache.AddOrUpdate(cacheKey, cached);
|
||||||
|
}
|
||||||
|
|
||||||
|
item.UserData = dbContext.UserData.Where(e => e.ItemId == item.Id).AsNoTracking().ToArray();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,64 @@
|
|||||||
|
using System;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using MediaBrowser.Controller.Entities;
|
||||||
|
using MediaBrowser.Controller.Library;
|
||||||
|
using MediaBrowser.Model.Entities;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
|
namespace Emby.Server.Implementations.Library.Validators;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Ensures top-level library folders have a primary poster after scans.
|
||||||
|
/// Poster extraction is attempted before library scanning. When a library is
|
||||||
|
/// empty at that point, no poster can be extracted. This post-scan task reruns
|
||||||
|
/// metadata extraction for top-level folders that are still missing images.
|
||||||
|
/// </summary>
|
||||||
|
public class CollectionPosterVerifyPostScanTask : ILibraryPostScanTask
|
||||||
|
{
|
||||||
|
private readonly ILibraryManager _libraryManager;
|
||||||
|
private readonly ILogger<CollectionPosterVerifyPostScanTask> _logger;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="CollectionPosterVerifyPostScanTask" /> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="libraryManager">The library manager.</param>
|
||||||
|
/// <param name="logger">The logger.</param>
|
||||||
|
public CollectionPosterVerifyPostScanTask(
|
||||||
|
ILibraryManager libraryManager,
|
||||||
|
ILogger<CollectionPosterVerifyPostScanTask> logger)
|
||||||
|
{
|
||||||
|
_libraryManager = libraryManager;
|
||||||
|
_logger = logger;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Runs the specified progress.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="progress">The progress.</param>
|
||||||
|
/// <param name="cancellationToken">The cancellation token.</param>
|
||||||
|
/// <returns>Task.</returns>
|
||||||
|
public async Task Run(IProgress<double> progress, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
var libraries = _libraryManager.GetUserRootFolder().Children.OfType<CollectionFolder>().ToList();
|
||||||
|
var totalLibraries = libraries.Count;
|
||||||
|
var processedLibraries = 0;
|
||||||
|
|
||||||
|
foreach (var library in libraries)
|
||||||
|
{
|
||||||
|
cancellationToken.ThrowIfCancellationRequested();
|
||||||
|
|
||||||
|
if (!library.HasImage(ImageType.Primary))
|
||||||
|
{
|
||||||
|
_logger.LogDebug("Library {LibraryName} is missing a primary image. Refreshing metadata.", library.Name);
|
||||||
|
await library.RefreshMetadata(cancellationToken).ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
processedLibraries++;
|
||||||
|
progress.Report((double)processedLibraries / totalLibraries * 100);
|
||||||
|
}
|
||||||
|
|
||||||
|
progress.Report(100);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -108,5 +108,18 @@
|
|||||||
"CleanupUserDataTaskDescription": "Neteja totes les dades d'usuari (estat de la visualització, estat dels preferits, etc.) del contingut multimèdia que no ha estat present durant almenys 90 dies.",
|
"CleanupUserDataTaskDescription": "Neteja totes les dades d'usuari (estat de la visualització, estat dels preferits, etc.) del contingut multimèdia que no ha estat present durant almenys 90 dies.",
|
||||||
"CleanupUserDataTask": "Tasca de neteja de dades d'usuari",
|
"CleanupUserDataTask": "Tasca de neteja de dades d'usuari",
|
||||||
"Original": "Original",
|
"Original": "Original",
|
||||||
"LyricDownloadFailureFromForItem": "No s'han pogut descarregar les lletres des de {0} per a {1}"
|
"LyricDownloadFailureFromForItem": "No s'han pogut descarregar les lletres des de {0} per a {1}",
|
||||||
|
"NameExtraBehindTheScenes": "Rere les càmeres",
|
||||||
|
"NameExtraClip": "Tall",
|
||||||
|
"NameExtraDeletedScene": "Escena eliminada",
|
||||||
|
"NameExtraFeaturette": "Migmetratge",
|
||||||
|
"NameExtraInterview": "Entrevista",
|
||||||
|
"NameExtraNumbered": "{0} {1}",
|
||||||
|
"NameExtraSample": "Mostra",
|
||||||
|
"NameExtraScene": "Escena",
|
||||||
|
"NameExtraShort": "Curt",
|
||||||
|
"NameExtraThemeSong": "Tema musical",
|
||||||
|
"NameExtraThemeVideo": "Vídeo temàtic",
|
||||||
|
"NameExtraTrailer": "Tràiler",
|
||||||
|
"NameExtraUnknown": "Extra"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
"Favorites": "Favoritter",
|
"Favorites": "Favoritter",
|
||||||
"Folders": "Mapper",
|
"Folders": "Mapper",
|
||||||
"Genres": "Genrer",
|
"Genres": "Genrer",
|
||||||
"HeaderContinueWatching": "Fortsæt afspilning",
|
"HeaderContinueWatching": "Fortsæt med at se",
|
||||||
"HeaderFavoriteEpisodes": "Yndlingsafsnit",
|
"HeaderFavoriteEpisodes": "Yndlingsafsnit",
|
||||||
"HeaderFavoriteShows": "Yndlingsserier",
|
"HeaderFavoriteShows": "Yndlingsserier",
|
||||||
"HeaderLiveTV": "Live-TV",
|
"HeaderLiveTV": "Live-TV",
|
||||||
@@ -65,7 +65,7 @@
|
|||||||
"TaskDownloadMissingSubtitlesDescription": "Søger på internettet efter manglende undertekster baseret på metadata-konfigurationen.",
|
"TaskDownloadMissingSubtitlesDescription": "Søger på internettet efter manglende undertekster baseret på metadata-konfigurationen.",
|
||||||
"TaskDownloadMissingSubtitles": "Hent manglende undertekster",
|
"TaskDownloadMissingSubtitles": "Hent manglende undertekster",
|
||||||
"TaskUpdatePluginsDescription": "Henter og installerer opdateringer for plugins, som er konfigurerede til at blive opdateret automatisk.",
|
"TaskUpdatePluginsDescription": "Henter og installerer opdateringer for plugins, som er konfigurerede til at blive opdateret automatisk.",
|
||||||
"TaskUpdatePlugins": "Opdater plugins",
|
"TaskUpdatePlugins": "Opdatér plugins",
|
||||||
"TaskCleanLogsDescription": "Sletter log-filer som er mere end {0} dage gamle.",
|
"TaskCleanLogsDescription": "Sletter log-filer som er mere end {0} dage gamle.",
|
||||||
"TaskCleanLogs": "Ryd log-mappe",
|
"TaskCleanLogs": "Ryd log-mappe",
|
||||||
"TaskRefreshLibraryDescription": "Scanner dit mediebibliotek for nye filer og opdateret metadata.",
|
"TaskRefreshLibraryDescription": "Scanner dit mediebibliotek for nye filer og opdateret metadata.",
|
||||||
@@ -79,10 +79,10 @@
|
|||||||
"TaskRefreshChapterImages": "Udtræk kapitelbilleder",
|
"TaskRefreshChapterImages": "Udtræk kapitelbilleder",
|
||||||
"TaskRefreshChapterImagesDescription": "Laver miniaturebilleder for videoer, der har kapitler.",
|
"TaskRefreshChapterImagesDescription": "Laver miniaturebilleder for videoer, der har kapitler.",
|
||||||
"TaskRefreshChannelsDescription": "Opdaterer information for internetkanaler.",
|
"TaskRefreshChannelsDescription": "Opdaterer information for internetkanaler.",
|
||||||
"TaskRefreshChannels": "Opdater kanaler",
|
"TaskRefreshChannels": "Opdatér kanaler",
|
||||||
"TaskCleanTranscodeDescription": "Fjerner omkodningsfiler, som er mere end 1 dag gamle.",
|
"TaskCleanTranscodeDescription": "Fjerner omkodningsfiler, som er mere end 1 dag gamle.",
|
||||||
"TaskCleanTranscode": "Tøm omkodningsmappen",
|
"TaskCleanTranscode": "Tøm omkodningsmappen",
|
||||||
"TaskRefreshPeople": "Opdater personer",
|
"TaskRefreshPeople": "Opdatér personer",
|
||||||
"TaskRefreshPeopleDescription": "Opdaterer metadata for skuespillere og instruktører i dit mediebibliotek.",
|
"TaskRefreshPeopleDescription": "Opdaterer metadata for skuespillere og instruktører i dit mediebibliotek.",
|
||||||
"TaskCleanActivityLogDescription": "Sletter linjer i aktivitetsloggen ældre end den konfigurerede alder.",
|
"TaskCleanActivityLogDescription": "Sletter linjer i aktivitetsloggen ældre end den konfigurerede alder.",
|
||||||
"TaskCleanActivityLog": "Ryd aktivitetslog",
|
"TaskCleanActivityLog": "Ryd aktivitetslog",
|
||||||
@@ -90,7 +90,7 @@
|
|||||||
"Forced": "Tvunget",
|
"Forced": "Tvunget",
|
||||||
"Default": "Standard",
|
"Default": "Standard",
|
||||||
"TaskOptimizeDatabaseDescription": "Komprimerer databasen for at frigøre plads. Denne handling køres efter at have scannet mediebiblioteket, eller efter at have lavet ændringer til databasen.",
|
"TaskOptimizeDatabaseDescription": "Komprimerer databasen for at frigøre plads. Denne handling køres efter at have scannet mediebiblioteket, eller efter at have lavet ændringer til databasen.",
|
||||||
"TaskOptimizeDatabase": "Optimer database",
|
"TaskOptimizeDatabase": "Optimér database",
|
||||||
"TaskKeyframeExtractorDescription": "Udtrækker rammer fra videofiler for at lave mere præcise HLS-playlister. Denne opgave kan tage lang tid.",
|
"TaskKeyframeExtractorDescription": "Udtrækker rammer fra videofiler for at lave mere præcise HLS-playlister. Denne opgave kan tage lang tid.",
|
||||||
"TaskKeyframeExtractor": "Udtræk nøglerammer",
|
"TaskKeyframeExtractor": "Udtræk nøglerammer",
|
||||||
"External": "Ekstern",
|
"External": "Ekstern",
|
||||||
@@ -99,7 +99,7 @@
|
|||||||
"TaskRefreshTrickplayImagesDescription": "Laver trickplay-billeder for videoer i aktiverede biblioteker.",
|
"TaskRefreshTrickplayImagesDescription": "Laver trickplay-billeder for videoer i aktiverede biblioteker.",
|
||||||
"TaskAudioNormalizationDescription": "Skanner filer for data vedrørende lydnormalisering.",
|
"TaskAudioNormalizationDescription": "Skanner filer for data vedrørende lydnormalisering.",
|
||||||
"TaskAudioNormalization": "Lydnormalisering",
|
"TaskAudioNormalization": "Lydnormalisering",
|
||||||
"TaskDownloadMissingLyricsDescription": "Søger på internettet efter manglende sangtekster baseret på metadata-konfigurationen",
|
"TaskDownloadMissingLyricsDescription": "Download sangtekster",
|
||||||
"TaskDownloadMissingLyrics": "Hent manglende sangtekster",
|
"TaskDownloadMissingLyrics": "Hent manglende sangtekster",
|
||||||
"TaskExtractMediaSegments": "Scan for mediesegmenter",
|
"TaskExtractMediaSegments": "Scan for mediesegmenter",
|
||||||
"TaskMoveTrickplayImages": "Migrer billedelokationer for trickplay-billeder",
|
"TaskMoveTrickplayImages": "Migrer billedelokationer for trickplay-billeder",
|
||||||
|
|||||||
@@ -28,6 +28,19 @@
|
|||||||
"Movies": "Movies",
|
"Movies": "Movies",
|
||||||
"Music": "Music",
|
"Music": "Music",
|
||||||
"MusicVideos": "Music Videos",
|
"MusicVideos": "Music Videos",
|
||||||
|
"NameExtraBehindTheScenes": "Behind The Scenes",
|
||||||
|
"NameExtraClip": "Clip",
|
||||||
|
"NameExtraDeletedScene": "Deleted Scene",
|
||||||
|
"NameExtraFeaturette": "Featurette",
|
||||||
|
"NameExtraInterview": "Interview",
|
||||||
|
"NameExtraNumbered": "{0} {1}",
|
||||||
|
"NameExtraSample": "Sample",
|
||||||
|
"NameExtraScene": "Scene",
|
||||||
|
"NameExtraShort": "Short",
|
||||||
|
"NameExtraThemeSong": "Theme Song",
|
||||||
|
"NameExtraThemeVideo": "Theme Video",
|
||||||
|
"NameExtraTrailer": "Trailer",
|
||||||
|
"NameExtraUnknown": "Extra",
|
||||||
"NameInstallFailed": "{0} installation failed",
|
"NameInstallFailed": "{0} installation failed",
|
||||||
"NameSeasonNumber": "Season {0}",
|
"NameSeasonNumber": "Season {0}",
|
||||||
"NameSeasonUnknown": "Season Unknown",
|
"NameSeasonUnknown": "Season Unknown",
|
||||||
|
|||||||
@@ -106,5 +106,7 @@
|
|||||||
"TaskExtractMediaSegments": "Escaneo de segmentos de medios",
|
"TaskExtractMediaSegments": "Escaneo de segmentos de medios",
|
||||||
"TaskMoveTrickplayImages": "Migrar la ubicación de la imagen de Trickplay",
|
"TaskMoveTrickplayImages": "Migrar la ubicación de la imagen de Trickplay",
|
||||||
"CleanupUserDataTask": "Tarea de limpieza de datos de usuario",
|
"CleanupUserDataTask": "Tarea de limpieza de datos de usuario",
|
||||||
"CleanupUserDataTaskDescription": "Limpia todos los datos de usuario (estado de visualización, favoritos, etc.) que no están presentes en la biblioteca por al menos 90 días."
|
"CleanupUserDataTaskDescription": "Limpia todos los datos de usuario (estado de visualización, favoritos, etc.) que no están presentes en la biblioteca por al menos 90 días.",
|
||||||
|
"LyricDownloadFailureFromForItem": "No se pudo descargar las letras de {0} para {1}",
|
||||||
|
"Original": "Original"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"Artists": "Listafólk",
|
"Artists": "Tónlistafólk",
|
||||||
"Collections": "Søvn",
|
"Collections": "Søvn",
|
||||||
"Default": "Sjálvgildi",
|
"Default": "Forsett",
|
||||||
"External": "Ytri",
|
"External": "Ytri",
|
||||||
"Genres": "Greinar",
|
"Genres": "Greinar",
|
||||||
"AppDeviceValues": "App: {0}, Eind: {1}",
|
"AppDeviceValues": "App: {0}, Eind: {1}",
|
||||||
@@ -12,5 +12,94 @@
|
|||||||
"Forced": "Kravt",
|
"Forced": "Kravt",
|
||||||
"FailedLoginAttemptWithUserName": "Miseydnað innritanarroynd frá {0}",
|
"FailedLoginAttemptWithUserName": "Miseydnað innritanarroynd frá {0}",
|
||||||
"HeaderFavoriteEpisodes": "Yndispartar",
|
"HeaderFavoriteEpisodes": "Yndispartar",
|
||||||
"LabelIpAddressValue": "IP atsetur: {0}"
|
"LabelIpAddressValue": "IP-atsetur: {0}",
|
||||||
|
"AuthenticationSucceededWithUserName": "{0} varð samgildur",
|
||||||
|
"HeaderFavoriteShows": "Yndisrøðir",
|
||||||
|
"HeaderLiveTV": "Beinleiðis sjónvarp",
|
||||||
|
"HearingImpaired": "Hoyrnarveik",
|
||||||
|
"Inherit": "Arvar",
|
||||||
|
"LabelRunningTimeValue": "Spælitíð: {0}",
|
||||||
|
"Latest": "Seinastu",
|
||||||
|
"LyricDownloadFailureFromForItem": "Miseydnaðist at niðurtakað sangtekst fyri {1} frá {0}",
|
||||||
|
"NameInstallFailed": "{0} innlegging miseydnaðist",
|
||||||
|
"NewVersionIsAvailable": "Ein nýggj útgáva av Jellyfin ambætaranum er tøk.",
|
||||||
|
"NotificationOptionNewLibraryContent": "Nýtt tilfar innlagt",
|
||||||
|
"NotificationOptionPluginInstalled": "Ískoytisforrit innlagt",
|
||||||
|
"NotificationOptionPluginUninstalled": "Ískoytisforrit strikað",
|
||||||
|
"NotificationOptionPluginUpdateInstalled": "Ískoytisforrit dagført",
|
||||||
|
"NotificationOptionUserLockedOut": "Brúkari útihýstur",
|
||||||
|
"Photos": "Ljósmyndir",
|
||||||
|
"PluginInstalledWithName": "{0} innlagt",
|
||||||
|
"PluginUninstalledWithName": "{0} strikað",
|
||||||
|
"PluginUpdatedWithName": "{0} dagført",
|
||||||
|
"Shows": "Røðir",
|
||||||
|
"SubtitleDownloadFailureFromForItem": "Miseydnaðist at niðurtakað undirtekstir til {1} frá {0}",
|
||||||
|
"TvShows": "Sjónvarpsrøðir",
|
||||||
|
"UserCreatedWithName": "Brúkari {0} er stovnaður",
|
||||||
|
"UserDeletedWithName": "Brúkari {0} er strikaður",
|
||||||
|
"UserDownloadingItemWithValues": "{0} niðurtekur {1}",
|
||||||
|
"UserLockedOutWithName": "Brúkari {0} er útihýstur",
|
||||||
|
"VersionNumber": "Útgáva {0}",
|
||||||
|
"TasksLibraryCategory": "Savn",
|
||||||
|
"TaskRefreshLibrary": "Skanna miðlasavn",
|
||||||
|
"TaskCleanLogsDescription": "Strikar gerðalistafílur eldri enn {0} dagar.",
|
||||||
|
"TaskUpdatePlugins": "Dagfør ískoytisforrit",
|
||||||
|
"TaskRefreshChannels": "Endurinnles rásir",
|
||||||
|
"TaskDownloadMissingLyricsDescription": "Niðurtekur sangtekstir",
|
||||||
|
"Movies": "Filmar",
|
||||||
|
"MixedContent": "Blandað innihald",
|
||||||
|
"Music": "Tónleikur",
|
||||||
|
"UserStartedPlayingItemWithValues": "{0} spælur {1} á {2}",
|
||||||
|
"HeaderContinueWatching": "Hald áfram at hyggja",
|
||||||
|
"MusicVideos": "Sjónbandaløg",
|
||||||
|
"TaskUpdatePluginsDescription": "Niðurtekur og innleggur dagføringar til ískoytisforrit ið eru stillaði til at dagførast sjálvvirkandi.",
|
||||||
|
"TaskCleanTranscodeDescription": "Strikar umkotaðar fílar ið eru eldri enn 1 dag.",
|
||||||
|
"TaskOptimizeDatabase": "Albøt dátugrunn",
|
||||||
|
"NameSeasonNumber": "Sesong {0}",
|
||||||
|
"NameSeasonUnknown": "Ókend sesong",
|
||||||
|
"ScheduledTaskFailedWithName": "{0} miseydnaðist",
|
||||||
|
"Undefined": "Óskilmarkað",
|
||||||
|
"TasksMaintenanceCategory": "Viðlíkahald",
|
||||||
|
"TaskCleanLogs": "Reinsa gerðalistaskjáttu",
|
||||||
|
"UserOnlineFromDevice": "{0} er íbundin frá {1}",
|
||||||
|
"HeaderNextUp": "Næst á skránni",
|
||||||
|
"NotificationOptionPluginError": "Brek í ískoytisforriti",
|
||||||
|
"NotificationOptionInstallationFailed": "Innleggingarbrek",
|
||||||
|
"NotificationOptionServerRestartRequired": "Tørvur er á ambætaraendurbyrjan",
|
||||||
|
"TasksApplicationCategory": "Nýtsluskipan",
|
||||||
|
"NotificationOptionApplicationUpdateAvailable": "Skipanardagføring er tøk",
|
||||||
|
"NotificationOptionApplicationUpdateInstalled": "Skipanardagføring varð innløgd",
|
||||||
|
"UserStoppedPlayingItemWithValues": "{0} er liðugur at spæla {1} á {2}",
|
||||||
|
"HomeVideos": "Heimaupptøkur",
|
||||||
|
"StartupEmbyServerIsLoading": "Jellyfin-ambætarin er undir byrjanarinnlesing. Vinaliga royn aftur um eitt bil.",
|
||||||
|
"UserOfflineFromDevice": "{0} breyt av á {1}",
|
||||||
|
"UserPasswordChangedWithName": "Loyniorðið hjá brúkaranum {0} er broytt",
|
||||||
|
"TasksChannelsCategory": "Alnetsrásir",
|
||||||
|
"TaskCleanActivityLog": "Reinsa virksemisskrá",
|
||||||
|
"TaskCleanActivityLogDescription": "Strikar skrásetingar eldri enn ásetta aldur.",
|
||||||
|
"TaskCleanCache": "Reinsa kovaskjáttu",
|
||||||
|
"TaskCleanCacheDescription": "Strikar kovafílar ið kervið ikki hevur tørv á longur.",
|
||||||
|
"TaskCleanTranscode": "Reinsa umkotuskjáttu",
|
||||||
|
"TaskDownloadMissingLyrics": "Niðurtak vantandi sangtekstir",
|
||||||
|
"TaskDownloadMissingSubtitles": "Niðurtak vantandi undirtekstir",
|
||||||
|
"CleanupUserDataTaskDescription": "Strikar allar brúkaradátur, so sum spælistøðu, yndislistastøðu o.s.fr., fyri miðlar ið ikki hava verið tøkir í í minsta lagi 90 dagar.",
|
||||||
|
"CleanupUserDataTask": "Koyrsla ið reinsar brúkaradátur",
|
||||||
|
"TaskRefreshPeople": "Dagfør persónsupplýsingar",
|
||||||
|
"TaskRefreshPeopleDescription": "Dagførur metadátur um leikarar og leikstjórar í tínum margmiðlasavni.",
|
||||||
|
"TaskRefreshChannelsDescription": "Dagførur upplýsingar um alnetsrásir.",
|
||||||
|
"TaskDownloadMissingSubtitlesDescription": "Leitar á alnótini eftir vantandi undirtekstum grundað á metadátauppsetan.",
|
||||||
|
"NotificationOptionTaskFailed": "Brek undir fyriskipaðari koyrslu",
|
||||||
|
"TaskRefreshLibraryDescription": "Skannar títt miðlasavn fyri nýggjum fílum og dagførur metadátur.",
|
||||||
|
"TaskKeyframeExtractor": "Lyklamyndaúttøka",
|
||||||
|
"TaskKeyframeExtractorDescription": "Úttekur lyklamyndir frá kykmynda-fílum til tess at byggja nágreiniligari HLS-spælilistar. Koyrslan kann taka langa tíð.",
|
||||||
|
"TaskOptimizeDatabaseDescription": "Trýstur dátugrunninin saman og loysur tóma goymslu. Koyrslan kann bøta um avrikið, eftir skanning ella aðrar broytingar í savninum ið elva til dátugrunnsbroytingar.",
|
||||||
|
"TaskRefreshChapterImagesDescription": "Ger smámyndir fyri kykmyndir ið hava kapitlar.",
|
||||||
|
"TaskRefreshChapterImages": "Kapitlamyndaúttøkur",
|
||||||
|
"NotificationOptionVideoPlayback": "Kykmyndaspæl byrjað",
|
||||||
|
"NotificationOptionVideoPlaybackStopped": "Kykmyndaspæl steðgað",
|
||||||
|
"NotificationOptionAudioPlayback": "Ljóðspæl byrjað",
|
||||||
|
"NotificationOptionAudioPlaybackStopped": "Ljóðspæl steðgað",
|
||||||
|
"TaskExtractMediaSegments": "Leita eftir margmiðlabrotum",
|
||||||
|
"TaskExtractMediaSegmentsDescription": "Framleiður upplýsingar um brot í margmiðlum, við hjálp frá MediaSegment-virktum ískoytisforritum.",
|
||||||
|
"NotificationOptionCameraImageUploaded": "Ljósmynd uppsent"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -106,5 +106,7 @@
|
|||||||
"TaskExtractMediaSegmentsDescription": "מחלץ חלקי מדיה מתוספים המאפשרים זאת.",
|
"TaskExtractMediaSegmentsDescription": "מחלץ חלקי מדיה מתוספים המאפשרים זאת.",
|
||||||
"TaskMoveTrickplayImagesDescription": "הזזת קבצי Trickplay קיימים בהתאם להגדרות הספרייה.",
|
"TaskMoveTrickplayImagesDescription": "הזזת קבצי Trickplay קיימים בהתאם להגדרות הספרייה.",
|
||||||
"CleanupUserDataTaskDescription": "ניקוי כל המידע של המשתמש (מצב צפייה, מועדפים וכו) ממדיה שאינה קיימת מעל 90 יום.",
|
"CleanupUserDataTaskDescription": "ניקוי כל המידע של המשתמש (מצב צפייה, מועדפים וכו) ממדיה שאינה קיימת מעל 90 יום.",
|
||||||
"CleanupUserDataTask": "משימת ניקוי מידע משתמש"
|
"CleanupUserDataTask": "משימת ניקוי מידע משתמש",
|
||||||
|
"LyricDownloadFailureFromForItem": "הורדת המילים מ-{0} עבור {1} נכשלה",
|
||||||
|
"Original": "מקור"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -105,5 +105,6 @@
|
|||||||
"TaskExtractMediaSegmentsDescription": "मीडियासेगमेंट सक्षम प्लगइन्स से मीडिया सेगमेंट निकालता है या प्राप्त करता है।",
|
"TaskExtractMediaSegmentsDescription": "मीडियासेगमेंट सक्षम प्लगइन्स से मीडिया सेगमेंट निकालता है या प्राप्त करता है।",
|
||||||
"TaskMoveTrickplayImages": "ट्रिकप्ले छवि स्थान माइग्रेट करें",
|
"TaskMoveTrickplayImages": "ट्रिकप्ले छवि स्थान माइग्रेट करें",
|
||||||
"TaskMoveTrickplayImagesDescription": "लाइब्रेरी सेटिंग्स के अनुसार मौजूदा ट्रिकप्ले फ़ाइलों को स्थानांतरित करता है।",
|
"TaskMoveTrickplayImagesDescription": "लाइब्रेरी सेटिंग्स के अनुसार मौजूदा ट्रिकप्ले फ़ाइलों को स्थानांतरित करता है।",
|
||||||
"CleanupUserDataTask": "यूज़र डेटा सफाई कार्य"
|
"CleanupUserDataTask": "यूज़र डेटा सफाई कार्य",
|
||||||
|
"Original": "असली"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -107,5 +107,6 @@
|
|||||||
"TaskMoveTrickplayImagesDescription": "Premješta postojeće datoteke brzog pregledavanja u postavke biblioteke.",
|
"TaskMoveTrickplayImagesDescription": "Premješta postojeće datoteke brzog pregledavanja u postavke biblioteke.",
|
||||||
"CleanupUserDataTask": "Zadatak čišćenja korisničkih podataka",
|
"CleanupUserDataTask": "Zadatak čišćenja korisničkih podataka",
|
||||||
"CleanupUserDataTaskDescription": "Briše sve korisničke podatke (stanje gledanja, status favorita itd.) s medija koji više nisu prisutni najmanje 90 dana.",
|
"CleanupUserDataTaskDescription": "Briše sve korisničke podatke (stanje gledanja, status favorita itd.) s medija koji više nisu prisutni najmanje 90 dana.",
|
||||||
"Original": "Original"
|
"Original": "Original",
|
||||||
|
"LyricDownloadFailureFromForItem": "Preuzimanje tekstova pjesmi od {0} za {1} nije uspjelo"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,7 +62,7 @@
|
|||||||
"UserDownloadingItemWithValues": "{0} hleður niður {1}",
|
"UserDownloadingItemWithValues": "{0} hleður niður {1}",
|
||||||
"SubtitleDownloadFailureFromForItem": "Tókst ekki að hala niður skjátextum frá {0} til {1}",
|
"SubtitleDownloadFailureFromForItem": "Tókst ekki að hala niður skjátextum frá {0} til {1}",
|
||||||
"Shows": "Þættir",
|
"Shows": "Þættir",
|
||||||
"TaskRefreshChannelsDescription": "Endurhlaða upplýsingum netrása.",
|
"TaskRefreshChannelsDescription": "Endurhleður upplýsingum netrása.",
|
||||||
"TaskRefreshChannels": "Endurhlaða Rásir",
|
"TaskRefreshChannels": "Endurhlaða Rásir",
|
||||||
"TaskCleanTranscodeDescription": "Eyða umkóðuðum skrám sem eru meira en einum degi eldri.",
|
"TaskCleanTranscodeDescription": "Eyða umkóðuðum skrám sem eru meira en einum degi eldri.",
|
||||||
"TaskCleanTranscode": "Hreinsa Umkóðunarmöppu",
|
"TaskCleanTranscode": "Hreinsa Umkóðunarmöppu",
|
||||||
@@ -80,7 +80,7 @@
|
|||||||
"TasksMaintenanceCategory": "Viðhald",
|
"TasksMaintenanceCategory": "Viðhald",
|
||||||
"Default": "Sjálfgefið",
|
"Default": "Sjálfgefið",
|
||||||
"TaskCleanActivityLog": "Hreinsa athafnaskrá",
|
"TaskCleanActivityLog": "Hreinsa athafnaskrá",
|
||||||
"TaskRefreshPeople": "Endurnýja fólk",
|
"TaskRefreshPeople": "Endurnýja upplýsingar um fólk",
|
||||||
"TaskDownloadMissingSubtitles": "Sækja texta sem vantar",
|
"TaskDownloadMissingSubtitles": "Sækja texta sem vantar",
|
||||||
"TaskOptimizeDatabase": "Fínstilla gagnagrunn",
|
"TaskOptimizeDatabase": "Fínstilla gagnagrunn",
|
||||||
"Undefined": "Óskilgreint",
|
"Undefined": "Óskilgreint",
|
||||||
@@ -95,13 +95,18 @@
|
|||||||
"TaskCleanActivityLogDescription": "Eyðir virkniskráningarfærslum sem hafa náð settum hámarksaldri.",
|
"TaskCleanActivityLogDescription": "Eyðir virkniskráningarfærslum sem hafa náð settum hámarksaldri.",
|
||||||
"Forced": "Þvingað",
|
"Forced": "Þvingað",
|
||||||
"External": "Útvær",
|
"External": "Útvær",
|
||||||
"TaskRefreshTrickplayImagesDescription": "Býr til hraðspilunarmyndir fyrir myndbönd í virkum söfnum.",
|
"TaskRefreshTrickplayImagesDescription": "Býr til hraðspilunarmyndir (Trickplay) fyrir myndbönd í virkum söfnum.",
|
||||||
"TaskRefreshTrickplayImages": "Búa til hraðspilunarmyndir",
|
"TaskRefreshTrickplayImages": "Búa til hraðspilunarmyndir (Trickplay)",
|
||||||
"TaskAudioNormalization": "Hljóðstöðlun",
|
"TaskAudioNormalization": "Hljóðstöðlun",
|
||||||
"TaskAudioNormalizationDescription": "Leitar að hljóðstöðlunargögnum í skrám.",
|
"TaskAudioNormalizationDescription": "Leitar að hljóðstöðlunargögnum í skrám.",
|
||||||
"TaskDownloadMissingLyricsDescription": "Sækja söngtexta fyrir lög",
|
"TaskDownloadMissingLyricsDescription": "Sækja söngtexta fyrir lög",
|
||||||
"TaskDownloadMissingLyrics": "Sækja söngtexta sem vantar",
|
"TaskDownloadMissingLyrics": "Sækja söngtexta sem vantar",
|
||||||
"TaskExtractMediaSegments": "Skönnun efnishluta",
|
"TaskExtractMediaSegments": "Skönnun efnishluta",
|
||||||
"CleanupUserDataTask": "Hreinsun notendagagna",
|
"CleanupUserDataTask": "Hreinsun notendagagna",
|
||||||
"CleanupUserDataTaskDescription": "Hreinsar öll notendagögn (spilunarstöðu, uppáhöld o.s.frv.) um gögn sem hafa ekki verið til staðar í að lámarki 90 daga."
|
"CleanupUserDataTaskDescription": "Hreinsar öll notendagögn (spilunarstöðu, uppáhöld o.s.frv.) um gögn sem hafa ekki verið til staðar í að lámarki 90 daga.",
|
||||||
|
"LyricDownloadFailureFromForItem": "Ekki tókst að niðurhala texta frá {0} fyrir {1}",
|
||||||
|
"Original": "Upprunaleg",
|
||||||
|
"TaskExtractMediaSegmentsDescription": "Sækir myndbúta úr viðbótum þar sem MediaSegment er virkt.",
|
||||||
|
"TaskMoveTrickplayImages": "Flytja geymslustað fyrir Trickplay-myndir",
|
||||||
|
"TaskMoveTrickplayImagesDescription": "Flytur fyrirliggjandi Trickplay-skrár í samræmi við stillingar safnsins."
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -106,5 +106,7 @@
|
|||||||
"TaskDownloadMissingLyrics": "失われた歌詞をダウンロード",
|
"TaskDownloadMissingLyrics": "失われた歌詞をダウンロード",
|
||||||
"TaskExtractMediaSegmentsDescription": "MediaSegment 対応プラグインからメディア セグメントを抽出または取得します。",
|
"TaskExtractMediaSegmentsDescription": "MediaSegment 対応プラグインからメディア セグメントを抽出または取得します。",
|
||||||
"CleanupUserDataTask": "ユーザーデータのクリーンアップタスク",
|
"CleanupUserDataTask": "ユーザーデータのクリーンアップタスク",
|
||||||
"CleanupUserDataTaskDescription": "90日以上存在しないメディアに対して、視聴状態やお気に入り状態などのユーザーデータをすべて削除します。"
|
"CleanupUserDataTaskDescription": "90日以上存在しないメディアに対して、視聴状態やお気に入り状態などのユーザーデータをすべて削除します。",
|
||||||
|
"LyricDownloadFailureFromForItem": "歌詞",
|
||||||
|
"Original": "オリジナル"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -104,5 +104,9 @@
|
|||||||
"TaskKeyframeExtractorDescription": "Extrahéiert Schlësselbiller aus Videodateien, fir méi präzis HLS-Playlisten ze erstellen. Dës Aufgab kann eng längere Zäit daueren.",
|
"TaskKeyframeExtractorDescription": "Extrahéiert Schlësselbiller aus Videodateien, fir méi präzis HLS-Playlisten ze erstellen. Dës Aufgab kann eng längere Zäit daueren.",
|
||||||
"TaskRefreshChannelsDescription": "Aktualiséiert Informatiounen iwwer Internetkanäl.",
|
"TaskRefreshChannelsDescription": "Aktualiséiert Informatiounen iwwer Internetkanäl.",
|
||||||
"TaskExtractMediaSegmentsDescription": "Extrahéiert oder kritt Mediesegmenter aus Plugins, déi MediaSegment ënnerstëtzen.",
|
"TaskExtractMediaSegmentsDescription": "Extrahéiert oder kritt Mediesegmenter aus Plugins, déi MediaSegment ënnerstëtzen.",
|
||||||
"TaskOptimizeDatabaseDescription": "Kompriméiert d’Datebank a schneit de fräie Speicherplatz zou. Dës Aufgab no engem Bibliothéik-Scan oder anere Ännerungen, déi Datebankmodifikatioune mat sech bréngen, auszeféieren, kann d’Performance verbesseren."
|
"TaskOptimizeDatabaseDescription": "Kompriméiert d’Datebank a schneit de fräie Speicherplatz zou. Dës Aufgab no engem Bibliothéik-Scan oder anere Ännerungen, déi Datebankmodifikatioune mat sech bréngen, auszeféieren, kann d’Performance verbesseren.",
|
||||||
|
"LyricDownloadFailureFromForItem": "Feeler beim Download vun de Songtexter vun {0} fir {1}",
|
||||||
|
"Original": "Original",
|
||||||
|
"CleanupUserDataTask": "Aufgab fir Berengege vu Benotzerdaten",
|
||||||
|
"CleanupUserDataTaskDescription": "Läscht all Benotzerdaten (Ofspillstatus, Favoritestatus, asw.) vu Medien, déi zënter mindestens 90 Deeg net méi besteeënd sinn."
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -107,5 +107,6 @@
|
|||||||
"TaskDownloadMissingLyricsDescription": "Lejupielādēt vārdus dziesmām",
|
"TaskDownloadMissingLyricsDescription": "Lejupielādēt vārdus dziesmām",
|
||||||
"CleanupUserDataTask": "Lietotāju datu tīrīšanas uzdevums",
|
"CleanupUserDataTask": "Lietotāju datu tīrīšanas uzdevums",
|
||||||
"CleanupUserDataTaskDescription": "Notīra visus lietotāja datus (skatīšanās stāvokļus, favorītu statusi utt.) no medijiem, kas vairs nav pieejami vismaz 90 dienas.",
|
"CleanupUserDataTaskDescription": "Notīra visus lietotāja datus (skatīšanās stāvokļus, favorītu statusi utt.) no medijiem, kas vairs nav pieejami vismaz 90 dienas.",
|
||||||
"Original": "Oriģināls"
|
"Original": "Oriģināls",
|
||||||
|
"LyricDownloadFailureFromForItem": "Dziesmu vārdi nevarēja tikt lejupielādēti no {0} priekš {1}"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -108,5 +108,18 @@
|
|||||||
"CleanupUserDataTask": "Opruimtaak gebruikersdata",
|
"CleanupUserDataTask": "Opruimtaak gebruikersdata",
|
||||||
"Genres": "Genres",
|
"Genres": "Genres",
|
||||||
"Original": "Oorspronkelijk",
|
"Original": "Oorspronkelijk",
|
||||||
"LyricDownloadFailureFromForItem": "Downloaden van liedteksten voor {1} van {0} mislukt"
|
"LyricDownloadFailureFromForItem": "Downloaden van liedteksten voor {1} van {0} mislukt",
|
||||||
|
"NameExtraBehindTheScenes": "Achter de schermen",
|
||||||
|
"NameExtraClip": "Clip",
|
||||||
|
"NameExtraDeletedScene": "Geschrapte scène",
|
||||||
|
"NameExtraFeaturette": "Featurette",
|
||||||
|
"NameExtraInterview": "Vraaggesprek",
|
||||||
|
"NameExtraNumbered": "{0} {1}",
|
||||||
|
"NameExtraSample": "Voorbeeldfragment",
|
||||||
|
"NameExtraScene": "Scène",
|
||||||
|
"NameExtraShort": "Korte film",
|
||||||
|
"NameExtraThemeSong": "Themamuziek",
|
||||||
|
"NameExtraThemeVideo": "Themavideo",
|
||||||
|
"NameExtraTrailer": "Trailer",
|
||||||
|
"NameExtraUnknown": "Extra inhoud"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,27 @@
|
|||||||
{
|
{
|
||||||
"AppDeviceValues": "Aplicacion: {0}, Periferic: {1}"
|
"AppDeviceValues": "Aplicacion: {0}, Periferic: {1}",
|
||||||
|
"Books": "Libres",
|
||||||
|
"Artists": "Artistas",
|
||||||
|
"Collections": "Collecciones",
|
||||||
|
"ChapterNameValue": "Capitol {0}",
|
||||||
|
"External": "Extèrn",
|
||||||
|
"Folders": "Dorsièrs",
|
||||||
|
"Favorites": "Favorits",
|
||||||
|
"HeaderContinueWatching": "Contunhar de regardar",
|
||||||
|
"HeaderFavoriteEpisodes": "Episòdis Favorits",
|
||||||
|
"AuthenticationSucceededWithUserName": "{0} autentificat amb succès",
|
||||||
|
"HeaderFavoriteShows": "Serias Favoritas",
|
||||||
|
"HeaderLiveTV": "TV en dirècte",
|
||||||
|
"HeaderNextUp": "Seguent",
|
||||||
|
"HearingImpaired": "Amb de deficiéncias auditivas",
|
||||||
|
"Movies": "Filmes",
|
||||||
|
"Music": "Musica",
|
||||||
|
"Latest": "Darrièr",
|
||||||
|
"Forced": "Forçat",
|
||||||
|
"Default": "Defaut",
|
||||||
|
"Genres": "Genres",
|
||||||
|
"HomeVideos": "Vidèos d'Acuèlh",
|
||||||
|
"Inherit": "Eiretar",
|
||||||
|
"LabelIpAddressValue": "Adreça IP: {0}",
|
||||||
|
"LabelRunningTimeValue": "Temps d'execucion : {0}"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1 +1,15 @@
|
|||||||
{}
|
{
|
||||||
|
"AppDeviceValues": "ඇප්: {0}, උපාංග: {1}",
|
||||||
|
"Artists": "කලාකරුවන්",
|
||||||
|
"AuthenticationSucceededWithUserName": "{0} සාර්ථකව තහවුරු කරන ලදී",
|
||||||
|
"Books": "පොත්",
|
||||||
|
"ChapterNameValue": "{0} වෙනි පරිච්ඡේදය",
|
||||||
|
"Collections": "සංහිතා",
|
||||||
|
"Default": "පෙරනිමි",
|
||||||
|
"External": "බාහිර",
|
||||||
|
"FailedLoginAttemptWithUserName": "{0} වෙතින් සිදුකළ පිවිසීමේ උත්සාහය අසාර්ථක විය",
|
||||||
|
"Favorites": "ප්රියතමයන්",
|
||||||
|
"Folders": "ෆෝල්ඩර",
|
||||||
|
"Forced": "නියමිත",
|
||||||
|
"Genres": "ප්රභේද"
|
||||||
|
}
|
||||||
|
|||||||
@@ -106,5 +106,7 @@
|
|||||||
"TaskAudioNormalization": "Normalizimi i audios",
|
"TaskAudioNormalization": "Normalizimi i audios",
|
||||||
"TaskAudioNormalizationDescription": "Skannon skedarët për të dhëna të normalizimit të audios.",
|
"TaskAudioNormalizationDescription": "Skannon skedarët për të dhëna të normalizimit të audios.",
|
||||||
"CleanupUserDataTaskDescription": "Pastron të gjitha të dhënat e përdorueseve (gjendja e shikimit, statusi i të preferuarave etj.) nga mediat që nuk janë më të pranishme për të paktën 90 ditë.",
|
"CleanupUserDataTaskDescription": "Pastron të gjitha të dhënat e përdorueseve (gjendja e shikimit, statusi i të preferuarave etj.) nga mediat që nuk janë më të pranishme për të paktën 90 ditë.",
|
||||||
"CleanupUserDataTask": "Veprim për pastrimin të dhënave të përdorueseve"
|
"CleanupUserDataTask": "Veprim për pastrimin të dhënave të përdorueseve",
|
||||||
|
"LyricDownloadFailureFromForItem": "Teksti i këngës nuk arriti të shkarkohej nga {0} për {1}",
|
||||||
|
"Original": "Origjinal"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -106,5 +106,7 @@
|
|||||||
"TaskExtractMediaSegmentsDescription": "แยกหรือดึงส่วนของสื่อจากปลั๊กอินที่เปิดใช้งาน MediaSegment",
|
"TaskExtractMediaSegmentsDescription": "แยกหรือดึงส่วนของสื่อจากปลั๊กอินที่เปิดใช้งาน MediaSegment",
|
||||||
"TaskMoveTrickplayImages": "ย้ายตำแหน่งเก็บภาพตัวอย่าง Trickplay",
|
"TaskMoveTrickplayImages": "ย้ายตำแหน่งเก็บภาพตัวอย่าง Trickplay",
|
||||||
"CleanupUserDataTask": "ส่วนงานล้างข้อมูลผู้ใช้",
|
"CleanupUserDataTask": "ส่วนงานล้างข้อมูลผู้ใช้",
|
||||||
"CleanupUserDataTaskDescription": "ล้างข้อมูลผู้ใช้ทั้งหมด (สถานะการรับชม สถานะรายการโปรด ฯลฯ) จากสื่อที่ไม่ได้ใช้งานแล้วอย่างน้อย 90 วัน"
|
"CleanupUserDataTaskDescription": "ล้างข้อมูลผู้ใช้ทั้งหมด (สถานะการรับชม สถานะรายการโปรด ฯลฯ) จากสื่อที่ไม่ได้ใช้งานแล้วอย่างน้อย 90 วัน",
|
||||||
|
"LyricDownloadFailureFromForItem": "ไม่สามารถดาวน์โหลดเนื้อเพลงจาก {0} สำหรับ {1}",
|
||||||
|
"Original": "ต้นฉบับ"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,8 +77,8 @@
|
|||||||
"TaskCleanLogsDescription": "自動刪走超過 {0} 日嘅紀錄檔。",
|
"TaskCleanLogsDescription": "自動刪走超過 {0} 日嘅紀錄檔。",
|
||||||
"TaskCleanLogs": "清理日誌資料夾",
|
"TaskCleanLogs": "清理日誌資料夾",
|
||||||
"TaskRefreshLibrary": "掃描媒體櫃",
|
"TaskRefreshLibrary": "掃描媒體櫃",
|
||||||
"TaskRefreshChapterImagesDescription": "幫有章節嘅影片整返啲章節縮圖。",
|
"TaskRefreshChapterImagesDescription": "幫有章節嘅影片整返啲章節預覽圖。",
|
||||||
"TaskRefreshChapterImages": "擷取章節圖片",
|
"TaskRefreshChapterImages": "擷取章節圖像",
|
||||||
"TaskCleanCacheDescription": "刪走系統已經唔再需要嘅快取檔案。",
|
"TaskCleanCacheDescription": "刪走系統已經唔再需要嘅快取檔案。",
|
||||||
"TaskCleanCache": "清理快取(Cache)資料夾",
|
"TaskCleanCache": "清理快取(Cache)資料夾",
|
||||||
"TasksChannelsCategory": "網路頻道",
|
"TasksChannelsCategory": "網路頻道",
|
||||||
|
|||||||
@@ -106,5 +106,7 @@
|
|||||||
"TaskMoveTrickplayImages": "遷移快轉縮圖位置",
|
"TaskMoveTrickplayImages": "遷移快轉縮圖位置",
|
||||||
"TaskMoveTrickplayImagesDescription": "根據媒體庫的設定遷移快轉縮圖的檔案。",
|
"TaskMoveTrickplayImagesDescription": "根據媒體庫的設定遷移快轉縮圖的檔案。",
|
||||||
"CleanupUserDataTask": "用戶資料清理工作",
|
"CleanupUserDataTask": "用戶資料清理工作",
|
||||||
"CleanupUserDataTaskDescription": "從用戶資料中清除已被刪除超過 90 天的媒體的相關資料。"
|
"CleanupUserDataTaskDescription": "從用戶資料中清除已被刪除超過 90 天的媒體的相關資料。",
|
||||||
|
"Original": "原作",
|
||||||
|
"LyricDownloadFailureFromForItem": "無法從 {0} 下載 {1} 的歌詞"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -261,6 +261,24 @@ namespace Emby.Server.Implementations.Localization
|
|||||||
_cultures);
|
_cultures);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public string? GetLanguageDisplayName(string language)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(language))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
var displayName = FindLanguageInfo(language)?.DisplayName;
|
||||||
|
if (displayName is null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Truncate at the first delimiter to avoid cluttered display names
|
||||||
|
return displayName.Split([';', ','], StringSplitOptions.None)[0].Trim();
|
||||||
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public IReadOnlyList<CountryInfo> GetCountries()
|
public IReadOnlyList<CountryInfo> GetCountries()
|
||||||
{
|
{
|
||||||
@@ -356,6 +374,27 @@ namespace Emby.Server.Implementations.Localization
|
|||||||
{
|
{
|
||||||
ArgumentException.ThrowIfNullOrEmpty(rating);
|
ArgumentException.ThrowIfNullOrEmpty(rating);
|
||||||
|
|
||||||
|
// Some providers may list multiple ratings separated by '/' (e.g. "SE:15 / SE:15+ / SE:Från 15 år").
|
||||||
|
// Try each one in order and use the first that resolves.
|
||||||
|
var ratingValues = rating.Split('/', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries);
|
||||||
|
|
||||||
|
foreach (var ratingValue in ratingValues)
|
||||||
|
{
|
||||||
|
var score = GetSingleRatingScore(ratingValue, countryCode);
|
||||||
|
if (score is not null)
|
||||||
|
{
|
||||||
|
return score;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Resolves a single rating value to a score.
|
||||||
|
/// </summary>
|
||||||
|
private ParentalRatingScore? GetSingleRatingScore(string rating, string? countryCode)
|
||||||
|
{
|
||||||
// Handle unrated content
|
// Handle unrated content
|
||||||
if (_unratedValues.Contains(rating.AsSpan(), StringComparison.OrdinalIgnoreCase))
|
if (_unratedValues.Contains(rating.AsSpan(), StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
@@ -364,7 +403,7 @@ namespace Emby.Server.Implementations.Localization
|
|||||||
|
|
||||||
// Convert ints directly
|
// Convert ints directly
|
||||||
// This may override some of the locale specific age ratings (but those always map to the same age)
|
// This may override some of the locale specific age ratings (but those always map to the same age)
|
||||||
if (int.TryParse(rating, out var ratingAge))
|
if (TryParseRatingAsScore(rating, out var ratingAge))
|
||||||
{
|
{
|
||||||
return new(ratingAge, null);
|
return new(ratingAge, null);
|
||||||
}
|
}
|
||||||
@@ -466,6 +505,13 @@ namespace Emby.Server.Implementations.Localization
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If it's not a recognized rating string, fall back to using the number as the score
|
||||||
|
if (TryParseRatingAsScore(ratingPart, out var numericScore))
|
||||||
|
{
|
||||||
|
result = new ParentalRatingScore(numericScore, null);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
_logger.LogWarning(
|
_logger.LogWarning(
|
||||||
"Rating '{Rating}' not found in the '{CountryCode}' rating system, treating as unrated",
|
"Rating '{Rating}' not found in the '{CountryCode}' rating system, treating as unrated",
|
||||||
rating,
|
rating,
|
||||||
@@ -480,6 +526,18 @@ namespace Emby.Server.Implementations.Localization
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Tries to parse a rating as a number, allowing an optional trailing '+' (e.g. "16" or "18+").
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="ratingValue">Rating value to parse.</param>
|
||||||
|
/// <param name="score">Parsed score.</param>
|
||||||
|
/// <returns>Returns true if parsing was successful.</returns>
|
||||||
|
private static bool TryParseRatingAsScore(ReadOnlySpan<char> ratingValue, out int score)
|
||||||
|
{
|
||||||
|
var trimmed = ratingValue.TrimEnd('+');
|
||||||
|
return int.TryParse(trimmed, out score);
|
||||||
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public string GetLocalizedString(string phrase)
|
public string GetLocalizedString(string phrase)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -10,21 +10,42 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ratingStrings": ["K12"],
|
"ratingStrings": ["K12", "K-12", "12"],
|
||||||
|
"ratingScore": {
|
||||||
|
"score": 12,
|
||||||
|
"subScore": null
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ratingStrings": ["K13", "K-13", "13"],
|
||||||
"ratingScore": {
|
"ratingScore": {
|
||||||
"score": 13,
|
"score": 13,
|
||||||
"subScore": null
|
"subScore": null
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ratingStrings": ["K15"],
|
"ratingStrings": ["K15", "K-15", "15"],
|
||||||
"ratingScore": {
|
"ratingScore": {
|
||||||
"score": 15,
|
"score": 15,
|
||||||
"subScore": null
|
"subScore": null
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ratingStrings": ["K18"],
|
"ratingStrings": ["K16", "K-16", "16"],
|
||||||
|
"ratingScore": {
|
||||||
|
"score": 16,
|
||||||
|
"subScore": null
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ratingStrings": ["K17", "K-17", "17"],
|
||||||
|
"ratingScore": {
|
||||||
|
"score": 17,
|
||||||
|
"subScore": null
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ratingStrings": ["K18", "K-18", "18", "18+"],
|
||||||
"ratingScore": {
|
"ratingScore": {
|
||||||
"score": 18,
|
"score": 18,
|
||||||
"subScore": null
|
"subScore": null
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ratingStrings": ["7"],
|
"ratingStrings": ["7", "7+", "7 År", "Från 7 år"],
|
||||||
"ratingScore": {
|
"ratingScore": {
|
||||||
"score": 7,
|
"score": 7,
|
||||||
"subScore": null
|
"subScore": null
|
||||||
@@ -31,7 +31,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ratingStrings": ["11"],
|
"ratingStrings": ["11", "11+", "11 År", "Från 11 år"],
|
||||||
"ratingScore": {
|
"ratingScore": {
|
||||||
"score": 11,
|
"score": 11,
|
||||||
"subScore": null
|
"subScore": null
|
||||||
@@ -45,11 +45,18 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ratingStrings": ["15"],
|
"ratingStrings": ["15", "15+", "15 År", "Från 15 år"],
|
||||||
"ratingScore": {
|
"ratingScore": {
|
||||||
"score": 15,
|
"score": 15,
|
||||||
"subScore": null
|
"subScore": null
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ratingStrings": ["18", "18+", "Barnförbjuden", "Bfj"],
|
||||||
|
"ratingScore": {
|
||||||
|
"score": 18,
|
||||||
|
"subScore": null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -219,28 +219,15 @@ namespace Emby.Server.Implementations.Playlists
|
|||||||
var playlist = _libraryManager.GetItemById(playlistId) as Playlist
|
var playlist = _libraryManager.GetItemById(playlistId) as Playlist
|
||||||
?? throw new ArgumentException("No Playlist exists with Id " + playlistId);
|
?? throw new ArgumentException("No Playlist exists with Id " + playlistId);
|
||||||
|
|
||||||
// Retrieve all the items to be added to the playlist
|
// Retrieve all the items to be added to the playlist.
|
||||||
var newItems = GetPlaylistItems(newItemIds, user, options)
|
var newItems = GetPlaylistItems(newItemIds, user, options)
|
||||||
.Where(i => i.SupportsAddingToPlaylist);
|
.Where(i => i.SupportsAddingToPlaylist);
|
||||||
|
|
||||||
// Filter out duplicate items
|
|
||||||
var existingIds = playlist.LinkedChildren.Select(c => c.ItemId).ToHashSet();
|
|
||||||
newItems = newItems
|
|
||||||
.Where(i => !existingIds.Contains(i.Id))
|
|
||||||
.Distinct();
|
|
||||||
|
|
||||||
// Create a list of the new linked children to add to the playlist
|
// Create a list of the new linked children to add to the playlist
|
||||||
var childrenToAdd = newItems
|
var childrenToAdd = newItems
|
||||||
.Select(LinkedChild.Create)
|
.Select(LinkedChild.Create)
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
// Log duplicates that have been ignored, if any
|
|
||||||
int numDuplicates = newItemIds.Count - childrenToAdd.Count;
|
|
||||||
if (numDuplicates > 0)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("Ignored adding {DuplicateCount} duplicate items to playlist {PlaylistName}.", numDuplicates, playlist.Name);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Do nothing else if there are no items to add to the playlist
|
// Do nothing else if there are no items to add to the playlist
|
||||||
if (childrenToAdd.Count == 0)
|
if (childrenToAdd.Count == 0)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ using System.Diagnostics;
|
|||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@@ -234,7 +235,7 @@ public partial class AudioNormalizationTask : IScheduledTask
|
|||||||
{
|
{
|
||||||
FileName = _mediaEncoder.EncoderPath,
|
FileName = _mediaEncoder.EncoderPath,
|
||||||
Arguments = args,
|
Arguments = args,
|
||||||
RedirectStandardOutput = false,
|
StandardErrorEncoding = Encoding.UTF8,
|
||||||
RedirectStandardError = true
|
RedirectStandardError = true
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -4,9 +4,15 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Jellyfin.Data.Enums;
|
||||||
using Jellyfin.Database.Implementations;
|
using Jellyfin.Database.Implementations;
|
||||||
|
using Jellyfin.Database.Implementations.Entities;
|
||||||
|
using MediaBrowser.Controller.Entities;
|
||||||
using MediaBrowser.Controller.Library;
|
using MediaBrowser.Controller.Library;
|
||||||
|
using MediaBrowser.Controller.Persistence;
|
||||||
|
using MediaBrowser.Controller.Providers;
|
||||||
using MediaBrowser.Model.Globalization;
|
using MediaBrowser.Model.Globalization;
|
||||||
|
using MediaBrowser.Model.IO;
|
||||||
using MediaBrowser.Model.Tasks;
|
using MediaBrowser.Model.Tasks;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
@@ -21,7 +27,9 @@ public class PeopleValidationTask : IScheduledTask, IConfigurableScheduledTask
|
|||||||
private readonly ILibraryManager _libraryManager;
|
private readonly ILibraryManager _libraryManager;
|
||||||
private readonly ILocalizationManager _localization;
|
private readonly ILocalizationManager _localization;
|
||||||
private readonly IDbContextFactory<JellyfinDbContext> _dbContextFactory;
|
private readonly IDbContextFactory<JellyfinDbContext> _dbContextFactory;
|
||||||
|
private readonly IFileSystem _fileSystem;
|
||||||
private readonly ILogger<PeopleValidationTask> _logger;
|
private readonly ILogger<PeopleValidationTask> _logger;
|
||||||
|
private readonly IItemTypeLookup _itemTypeLookup;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="PeopleValidationTask" /> class.
|
/// Initializes a new instance of the <see cref="PeopleValidationTask" /> class.
|
||||||
@@ -29,13 +37,23 @@ public class PeopleValidationTask : IScheduledTask, IConfigurableScheduledTask
|
|||||||
/// <param name="libraryManager">Instance of the <see cref="ILibraryManager"/> interface.</param>
|
/// <param name="libraryManager">Instance of the <see cref="ILibraryManager"/> interface.</param>
|
||||||
/// <param name="localization">Instance of the <see cref="ILocalizationManager"/> interface.</param>
|
/// <param name="localization">Instance of the <see cref="ILocalizationManager"/> interface.</param>
|
||||||
/// <param name="dbContextFactory">Instance of the <see cref="IDbContextFactory{TContext}"/> interface.</param>
|
/// <param name="dbContextFactory">Instance of the <see cref="IDbContextFactory{TContext}"/> interface.</param>
|
||||||
|
/// <param name="fileSystem">Instance of the <see cref="IFileSystem"/> interface.</param>
|
||||||
/// <param name="logger">Instance of the <see cref="ILogger{PeopleValidationTask}"/> interface.</param>
|
/// <param name="logger">Instance of the <see cref="ILogger{PeopleValidationTask}"/> interface.</param>
|
||||||
public PeopleValidationTask(ILibraryManager libraryManager, ILocalizationManager localization, IDbContextFactory<JellyfinDbContext> dbContextFactory, ILogger<PeopleValidationTask> logger)
|
/// <param name="itemTypeLookup">Instance of the <see cref="IItemTypeLookup"/> interface.</param>
|
||||||
|
public PeopleValidationTask(
|
||||||
|
ILibraryManager libraryManager,
|
||||||
|
ILocalizationManager localization,
|
||||||
|
IDbContextFactory<JellyfinDbContext> dbContextFactory,
|
||||||
|
IFileSystem fileSystem,
|
||||||
|
ILogger<PeopleValidationTask> logger,
|
||||||
|
IItemTypeLookup itemTypeLookup)
|
||||||
{
|
{
|
||||||
_libraryManager = libraryManager;
|
_libraryManager = libraryManager;
|
||||||
_localization = localization;
|
_localization = localization;
|
||||||
_dbContextFactory = dbContextFactory;
|
_dbContextFactory = dbContextFactory;
|
||||||
|
_fileSystem = fileSystem;
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
|
_itemTypeLookup = itemTypeLookup;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
@@ -83,10 +101,11 @@ public class PeopleValidationTask : IScheduledTask, IConfigurableScheduledTask
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Phase 1: Deduplicate and remove orphaned people (0-33%)
|
||||||
var context = await _dbContextFactory.CreateDbContextAsync(cancellationToken).ConfigureAwait(false);
|
var context = await _dbContextFactory.CreateDbContextAsync(cancellationToken).ConfigureAwait(false);
|
||||||
await using (context.ConfigureAwait(false))
|
await using (context.ConfigureAwait(false))
|
||||||
{
|
{
|
||||||
IProgress<double> subProgress = new Progress<double>((val) => progress.Report(val / 2));
|
IProgress<double> subProgress = new Progress<double>((val) => progress.Report(val / 3));
|
||||||
var dupQuery = context.Peoples
|
var dupQuery = context.Peoples
|
||||||
.GroupBy(e => new { e.Name, e.PersonType })
|
.GroupBy(e => new { e.Name, e.PersonType })
|
||||||
.Where(e => e.Count() > 1)
|
.Where(e => e.Count() > 1)
|
||||||
@@ -141,9 +160,104 @@ public class PeopleValidationTask : IScheduledTask, IConfigurableScheduledTask
|
|||||||
subProgress.Report(100);
|
subProgress.Report(100);
|
||||||
}
|
}
|
||||||
|
|
||||||
IProgress<double> validateProgress = new Progress<double>((val) => progress.Report((val / 2) + 50));
|
// Phase 2: Validate people (33-66%). Runs after orphaned PeopleBaseItemMap entries are
|
||||||
|
// cleaned up above, so dead people are removed in a single pass instead of requiring a second run.
|
||||||
|
IProgress<double> validateProgress = new Progress<double>((val) => progress.Report((val / 3) + 33));
|
||||||
await _libraryManager.ValidatePeopleAsync(validateProgress, cancellationToken).ConfigureAwait(false);
|
await _libraryManager.ValidatePeopleAsync(validateProgress, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
|
// Phase 3: Refresh images for people missing them (66-100%)
|
||||||
|
IProgress<double> refreshProgress = new Progress<double>((val) => progress.Report((val / 3) + 66));
|
||||||
|
await RefreshPeopleImagesAsync(refreshProgress, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
progress.Report(100);
|
progress.Report(100);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task RefreshPeopleImagesAsync(IProgress<double> progress, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
var thirtyDaysAgo = DateTime.UtcNow.AddDays(-30);
|
||||||
|
var personTypeName = _itemTypeLookup.BaseItemKindNames[BaseItemKind.Person];
|
||||||
|
|
||||||
|
var context = await _dbContextFactory.CreateDbContextAsync(cancellationToken).ConfigureAwait(false);
|
||||||
|
await using (context.ConfigureAwait(false))
|
||||||
|
{
|
||||||
|
const int PartitionSize = 100;
|
||||||
|
|
||||||
|
var numPeople = await context.BaseItems
|
||||||
|
.AsNoTracking()
|
||||||
|
.Where(b => b.Type == personTypeName)
|
||||||
|
.Where(b => b.DateLastRefreshed == null || b.DateLastRefreshed < thirtyDaysAgo)
|
||||||
|
.Where(b =>
|
||||||
|
!b.Images!.Any(i => i.ImageType == ImageInfoImageType.Primary) ||
|
||||||
|
string.IsNullOrEmpty(b.Overview))
|
||||||
|
.CountAsync(cancellationToken)
|
||||||
|
.ConfigureAwait(false);
|
||||||
|
|
||||||
|
_logger.LogDebug("Found {Count} people needing image/overview refresh", numPeople);
|
||||||
|
|
||||||
|
if (numPeople == 0)
|
||||||
|
{
|
||||||
|
progress.Report(100);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var numComplete = 0;
|
||||||
|
var numRefreshed = 0;
|
||||||
|
|
||||||
|
await foreach (var entry in context.BaseItems
|
||||||
|
.AsNoTracking()
|
||||||
|
.Where(b => b.Type == personTypeName)
|
||||||
|
.Where(b => b.DateLastRefreshed == null || b.DateLastRefreshed < thirtyDaysAgo)
|
||||||
|
.Where(b =>
|
||||||
|
!b.Images!.Any(i => i.ImageType == ImageInfoImageType.Primary) ||
|
||||||
|
string.IsNullOrEmpty(b.Overview))
|
||||||
|
.OrderBy(b => b.Id)
|
||||||
|
.WithPartitionProgress(partition => _logger.LogDebug("Processing people partition {Partition}", partition))
|
||||||
|
.PartitionEagerAsync(PartitionSize, cancellationToken)
|
||||||
|
.WithCancellation(cancellationToken)
|
||||||
|
.ConfigureAwait(false))
|
||||||
|
{
|
||||||
|
if (await RefreshPersonAsync(entry.Id, cancellationToken).ConfigureAwait(false))
|
||||||
|
{
|
||||||
|
numRefreshed++;
|
||||||
|
}
|
||||||
|
|
||||||
|
numComplete++;
|
||||||
|
progress.Report(100.0 * numComplete / numPeople);
|
||||||
|
}
|
||||||
|
|
||||||
|
_logger.LogInformation("Refreshed metadata for {Count} people missing images or overview", numRefreshed);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task<bool> RefreshPersonAsync(Guid personId, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (_libraryManager.GetItemById(personId) is not Person item)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
var hasImage = item.HasImage(MediaBrowser.Model.Entities.ImageType.Primary);
|
||||||
|
var hasOverview = !string.IsNullOrEmpty(item.Overview);
|
||||||
|
|
||||||
|
var options = new MetadataRefreshOptions(new DirectoryService(_fileSystem))
|
||||||
|
{
|
||||||
|
ImageRefreshMode = hasImage ? MetadataRefreshMode.ValidationOnly : MetadataRefreshMode.Default,
|
||||||
|
MetadataRefreshMode = hasOverview ? MetadataRefreshMode.ValidationOnly : MetadataRefreshMode.Default
|
||||||
|
};
|
||||||
|
|
||||||
|
await item.RefreshMetadata(options, cancellationToken).ConfigureAwait(false);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch (OperationCanceledException)
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Error refreshing images for person {PersonId}", personId);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -641,8 +641,7 @@ namespace Emby.Server.Implementations.Session
|
|||||||
if (playingSessions.Count > 0)
|
if (playingSessions.Count > 0)
|
||||||
{
|
{
|
||||||
var idle = playingSessions
|
var idle = playingSessions
|
||||||
.Where(i => (DateTime.UtcNow - i.LastPlaybackCheckIn).TotalMinutes > 5)
|
.Where(i => (DateTime.UtcNow - i.LastPlaybackCheckIn).TotalMinutes > 5);
|
||||||
.ToList();
|
|
||||||
|
|
||||||
foreach (var session in idle)
|
foreach (var session in idle)
|
||||||
{
|
{
|
||||||
@@ -729,6 +728,31 @@ namespace Emby.Server.Implementations.Session
|
|||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Resolves the item whose user data (playback position, played status) should be updated
|
||||||
|
/// for a playback report. When an alternate version is played the client reports the displayed
|
||||||
|
/// item as <c>ItemId</c> and the played version as <c>MediaSourceId</c>.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="libraryItem">The now playing (displayed) item.</param>
|
||||||
|
/// <param name="mediaSourceId">The reported media source id.</param>
|
||||||
|
/// <returns>The item to track progress against.</returns>
|
||||||
|
private BaseItem GetProgressItem(BaseItem libraryItem, string mediaSourceId)
|
||||||
|
{
|
||||||
|
if (libraryItem is Video libraryVideo
|
||||||
|
&& !string.IsNullOrEmpty(mediaSourceId)
|
||||||
|
&& Guid.TryParse(mediaSourceId, out var mediaSourceItemId)
|
||||||
|
&& !mediaSourceItemId.Equals(libraryVideo.Id))
|
||||||
|
{
|
||||||
|
var versionItem = libraryVideo.GetAlternateVersion(mediaSourceItemId);
|
||||||
|
if (versionItem is not null)
|
||||||
|
{
|
||||||
|
return versionItem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return libraryItem;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Used to report that playback has started for an item.
|
/// Used to report that playback has started for an item.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -760,9 +784,10 @@ namespace Emby.Server.Implementations.Session
|
|||||||
|
|
||||||
if (libraryItem is not null)
|
if (libraryItem is not null)
|
||||||
{
|
{
|
||||||
|
var progressItem = GetProgressItem(libraryItem, info.MediaSourceId);
|
||||||
foreach (var user in users)
|
foreach (var user in users)
|
||||||
{
|
{
|
||||||
OnPlaybackStart(user, libraryItem);
|
OnPlaybackStart(user, progressItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -894,9 +919,10 @@ namespace Emby.Server.Implementations.Session
|
|||||||
// only update saved user data on actual check-ins, not automated ones
|
// only update saved user data on actual check-ins, not automated ones
|
||||||
if (libraryItem is not null && !isAutomated)
|
if (libraryItem is not null && !isAutomated)
|
||||||
{
|
{
|
||||||
|
var progressItem = GetProgressItem(libraryItem, info.MediaSourceId);
|
||||||
foreach (var user in users)
|
foreach (var user in users)
|
||||||
{
|
{
|
||||||
OnPlaybackProgress(user, libraryItem, info);
|
OnPlaybackProgress(user, progressItem, info);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -956,6 +982,20 @@ namespace Emby.Server.Implementations.Session
|
|||||||
if (changed)
|
if (changed)
|
||||||
{
|
{
|
||||||
_userDataManager.SaveUserData(user, item, data, UserDataSaveReason.PlaybackProgress, CancellationToken.None);
|
_userDataManager.SaveUserData(user, item, data, UserDataSaveReason.PlaybackProgress, CancellationToken.None);
|
||||||
|
|
||||||
|
// A completed version marks every alternate version played and clears their resume points, so the
|
||||||
|
// whole movie leaves Continue Watching and reads as watched everywhere. (Per-version resume positions
|
||||||
|
// only persist while nothing has been completed yet.)
|
||||||
|
if (data.Played == true && item is Video playedVideo)
|
||||||
|
{
|
||||||
|
playedVideo.PropagatePlayedState(user, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((!user.RememberAudioSelections && info.AudioStreamIndex.HasValue)
|
||||||
|
|| (!user.RememberSubtitleSelections && info.SubtitleStreamIndex.HasValue))
|
||||||
|
{
|
||||||
|
_userDataManager.ResetPlaybackStreamSelections(user, item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1087,9 +1127,10 @@ namespace Emby.Server.Implementations.Session
|
|||||||
|
|
||||||
if (libraryItem is not null)
|
if (libraryItem is not null)
|
||||||
{
|
{
|
||||||
|
var progressItem = GetProgressItem(libraryItem, info.MediaSourceId);
|
||||||
foreach (var user in users)
|
foreach (var user in users)
|
||||||
{
|
{
|
||||||
playedToCompletion = OnPlaybackStopped(user, libraryItem, info.PositionTicks, info.Failed);
|
playedToCompletion = OnPlaybackStopped(user, progressItem, info.PositionTicks, info.Failed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1142,6 +1183,14 @@ namespace Emby.Server.Implementations.Session
|
|||||||
|
|
||||||
_userDataManager.SaveUserData(user, item, data, UserDataSaveReason.PlaybackFinished, CancellationToken.None);
|
_userDataManager.SaveUserData(user, item, data, UserDataSaveReason.PlaybackFinished, CancellationToken.None);
|
||||||
|
|
||||||
|
// A completed version marks every alternate version played and clears their resume points, so the
|
||||||
|
// whole movie leaves Continue Watching and reads as watched everywhere. (Per-version resume positions
|
||||||
|
// only persist while nothing has been completed yet.)
|
||||||
|
if (data.Played == true && item is Video playedVideo)
|
||||||
|
{
|
||||||
|
playedVideo.PropagatePlayedState(user, true);
|
||||||
|
}
|
||||||
|
|
||||||
return playedToCompletion;
|
return playedToCompletion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -246,8 +246,21 @@ namespace Emby.Server.Implementations.Session
|
|||||||
_logger.LogInformation("Lost {0} WebSockets.", lost.Count);
|
_logger.LogInformation("Lost {0} WebSockets.", lost.Count);
|
||||||
foreach (var webSocket in lost)
|
foreach (var webSocket in lost)
|
||||||
{
|
{
|
||||||
// TODO: handle session relative to the lost webSocket
|
|
||||||
RemoveWebSocket(webSocket);
|
RemoveWebSocket(webSocket);
|
||||||
|
|
||||||
|
// The connection stopped answering keep-alives, so a close frame will
|
||||||
|
// never arrive and the pending receive loop would hang forever, keeping
|
||||||
|
// the session (and e.g. its SyncPlay group membership) alive. Disposing
|
||||||
|
// the connection aborts the receive loop, which raises Closed and lets
|
||||||
|
// the session end normally.
|
||||||
|
try
|
||||||
|
{
|
||||||
|
webSocket.Dispose();
|
||||||
|
}
|
||||||
|
catch (Exception exception)
|
||||||
|
{
|
||||||
|
_logger.LogWarning(exception, "Error disposing lost WebSocket from {RemoteEndPoint}.", webSocket.RemoteEndPoint);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,34 +3,14 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using Jellyfin.Data.Enums;
|
using Jellyfin.Data.Enums;
|
||||||
using Jellyfin.Database.Implementations.Entities;
|
|
||||||
using MediaBrowser.Controller.Entities;
|
using MediaBrowser.Controller.Entities;
|
||||||
using MediaBrowser.Controller.Library;
|
|
||||||
using MediaBrowser.Controller.Sorting;
|
using MediaBrowser.Controller.Sorting;
|
||||||
using MediaBrowser.Model.Querying;
|
using MediaBrowser.Model.Querying;
|
||||||
|
|
||||||
namespace Emby.Server.Implementations.Sorting
|
namespace Emby.Server.Implementations.Sorting
|
||||||
{
|
{
|
||||||
public class DateLastMediaAddedComparer : IUserBaseItemComparer
|
public class DateLastMediaAddedComparer : IBaseItemComparer
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the user.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The user.</value>
|
|
||||||
public User User { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the user manager.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The user manager.</value>
|
|
||||||
public IUserManager UserManager { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the user data manager.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The user data manager.</value>
|
|
||||||
public IUserDataManager UserDataManager { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the name.
|
/// Gets the name.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ namespace Emby.Server.Implementations.Sorting
|
|||||||
return x.PremiereDate.Value;
|
return x.PremiereDate.Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (x.ProductionYear.HasValue)
|
if (x.ProductionYear is not null)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ namespace Emby.Server.Implementations.Sorting
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (x.ProductionYear.HasValue)
|
if (x.ProductionYear is not null)
|
||||||
{
|
{
|
||||||
return x.ProductionYear.Value;
|
return x.ProductionYear.Value;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Globalization;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Jellyfin.Data;
|
using Jellyfin.Data;
|
||||||
using Jellyfin.Data.Enums;
|
using Jellyfin.Data.Enums;
|
||||||
@@ -136,11 +137,15 @@ namespace Emby.Server.Implementations.TV
|
|||||||
|
|
||||||
if (nextEpisode is not null)
|
if (nextEpisode is not null)
|
||||||
{
|
{
|
||||||
|
// The last played date and the version that was actually played live on the version item's user data
|
||||||
|
// The played state propagated to the sibling versions carries no date
|
||||||
|
var (playedVersion, lastPlayedDate) = GetMostRecentlyPlayedVersion(result.LastWatched, user);
|
||||||
|
nextEpisode = GetPreferredVersion(nextEpisode, result.LastWatched, playedVersion);
|
||||||
|
|
||||||
DateTime lastWatchedDate = DateTime.MinValue;
|
DateTime lastWatchedDate = DateTime.MinValue;
|
||||||
if (result.LastWatched is not null)
|
if (result.LastWatched is not null)
|
||||||
{
|
{
|
||||||
var userData = _userDataManager.GetUserData(user, result.LastWatched);
|
lastWatchedDate = lastPlayedDate ?? DateTime.MinValue.AddDays(1);
|
||||||
lastWatchedDate = userData?.LastPlayedDate ?? DateTime.MinValue.AddDays(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nextUpList.Add((lastWatchedDate, nextEpisode));
|
nextUpList.Add((lastWatchedDate, nextEpisode));
|
||||||
@@ -152,11 +157,13 @@ namespace Emby.Server.Implementations.TV
|
|||||||
|
|
||||||
if (nextPlayedEpisode is not null)
|
if (nextPlayedEpisode is not null)
|
||||||
{
|
{
|
||||||
|
var (playedVersion, lastPlayedDate) = GetMostRecentlyPlayedVersion(result.LastWatchedForRewatching, user);
|
||||||
|
nextPlayedEpisode = GetPreferredVersion(nextPlayedEpisode, result.LastWatchedForRewatching, playedVersion);
|
||||||
|
|
||||||
DateTime rewatchLastWatchedDate = DateTime.MinValue;
|
DateTime rewatchLastWatchedDate = DateTime.MinValue;
|
||||||
if (result.LastWatchedForRewatching is not null)
|
if (result.LastWatchedForRewatching is not null)
|
||||||
{
|
{
|
||||||
var userData = _userDataManager.GetUserData(user, result.LastWatchedForRewatching);
|
rewatchLastWatchedDate = lastPlayedDate ?? DateTime.MinValue.AddDays(1);
|
||||||
rewatchLastWatchedDate = userData?.LastPlayedDate ?? DateTime.MinValue.AddDays(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nextUpList.Add((rewatchLastWatchedDate, nextPlayedEpisode));
|
nextUpList.Add((rewatchLastWatchedDate, nextPlayedEpisode));
|
||||||
@@ -219,10 +226,13 @@ namespace Emby.Server.Implementations.TV
|
|||||||
|
|
||||||
if (nextEpisode is not null && !includeResumable)
|
if (nextEpisode is not null && !includeResumable)
|
||||||
{
|
{
|
||||||
var userData = _userDataManager.GetUserData(user, nextEpisode);
|
// The resume progress may live on an alternate version
|
||||||
if (userData?.PlaybackPositionTicks > 0)
|
foreach (var version in nextEpisode.GetAllVersions())
|
||||||
{
|
{
|
||||||
return null;
|
if (_userDataManager.GetUserData(user, version)?.PlaybackPositionTicks > 0)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -237,6 +247,74 @@ namespace Emby.Server.Implementations.TV
|
|||||||
return DetermineNextEpisode(result, user, includeSpecials, includeResumable: false, includePlayed: true);
|
return DetermineNextEpisode(result, user, includeSpecials, includeResumable: false, includePlayed: true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the version of the last watched episode that was actually played, together with its last played date.
|
||||||
|
/// The version that was played carries the most recent LastPlayedDate.
|
||||||
|
/// dates.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="lastWatched">The last watched episode (any version).</param>
|
||||||
|
/// <param name="user">The user.</param>
|
||||||
|
/// <returns>The played version and its last played date.</returns>
|
||||||
|
private (Video? PlayedVersion, DateTime? LastPlayedDate) GetMostRecentlyPlayedVersion(BaseItem? lastWatched, User user)
|
||||||
|
{
|
||||||
|
if (lastWatched is not Video lastWatchedVideo)
|
||||||
|
{
|
||||||
|
return (null, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
var versions = lastWatchedVideo.GetAllVersions();
|
||||||
|
var userDataByVersion = _userDataManager.GetUserDataBatch(versions, user);
|
||||||
|
|
||||||
|
var playedVersion = VersionPlaybackSelector.SelectMostRecentlyPlayed(
|
||||||
|
versions,
|
||||||
|
version => userDataByVersion.GetValueOrDefault(version.Id),
|
||||||
|
data => data.LastPlayedDate.HasValue);
|
||||||
|
|
||||||
|
return (playedVersion, playedVersion is null ? null : userDataByVersion[playedVersion.Id].LastPlayedDate);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// When the last watched episode was played as an alternate version, prefer the next episode's version with the matching name,
|
||||||
|
/// so Next Up continues in the version the user has been watching instead of falling back to the primary.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="nextEpisode">The determined next episode (a primary).</param>
|
||||||
|
/// <param name="lastWatched">The last watched episode.</param>
|
||||||
|
/// <param name="playedVersion">The version of the last watched episode that was played.</param>
|
||||||
|
/// <returns>The matching version of the next episode, or the episode itself.</returns>
|
||||||
|
private Episode GetPreferredVersion(Episode nextEpisode, BaseItem? lastWatched, Video? playedVersion)
|
||||||
|
{
|
||||||
|
// No version preference, or the primary was played
|
||||||
|
if (lastWatched is not Video lastWatchedVideo
|
||||||
|
|| playedVersion is null
|
||||||
|
|| !playedVersion.PrimaryVersionId.HasValue)
|
||||||
|
{
|
||||||
|
return nextEpisode;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Match by version name
|
||||||
|
var playedVersionId = playedVersion.Id.ToString("N", CultureInfo.InvariantCulture);
|
||||||
|
var playedVersionName = lastWatchedVideo.GetMediaSources(false)
|
||||||
|
.FirstOrDefault(source => string.Equals(source.Id, playedVersionId, StringComparison.OrdinalIgnoreCase))?.Name;
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(playedVersionName))
|
||||||
|
{
|
||||||
|
return nextEpisode;
|
||||||
|
}
|
||||||
|
|
||||||
|
var matchingSource = nextEpisode.GetMediaSources(false)
|
||||||
|
.FirstOrDefault(source => string.Equals(source.Name, playedVersionName, StringComparison.OrdinalIgnoreCase));
|
||||||
|
|
||||||
|
if (matchingSource is not null
|
||||||
|
&& Guid.TryParse(matchingSource.Id, out var matchingId)
|
||||||
|
&& !matchingId.Equals(nextEpisode.Id)
|
||||||
|
&& _libraryManager.GetItemById<Episode>(matchingId) is { } matchingVersion)
|
||||||
|
{
|
||||||
|
return matchingVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
return nextEpisode;
|
||||||
|
}
|
||||||
|
|
||||||
private static string GetUniqueSeriesKey(Series series)
|
private static string GetUniqueSeriesKey(Series series)
|
||||||
{
|
{
|
||||||
return series.GetPresentationUniqueKey();
|
return series.GetPresentationUniqueKey();
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Jellyfin.Api.Helpers;
|
||||||
using Jellyfin.Data.Enums;
|
using Jellyfin.Data.Enums;
|
||||||
using Jellyfin.Data.Queries;
|
using Jellyfin.Data.Queries;
|
||||||
using Jellyfin.Database.Implementations.Enums;
|
using Jellyfin.Database.Implementations.Enums;
|
||||||
@@ -84,36 +84,9 @@ public class ActivityLogController : BaseJellyfinApiController
|
|||||||
ItemId = itemId,
|
ItemId = itemId,
|
||||||
Username = username,
|
Username = username,
|
||||||
Severity = severity,
|
Severity = severity,
|
||||||
OrderBy = GetOrderBy(sortBy ?? [], sortOrder ?? []),
|
OrderBy = RequestHelpers.GetOrderBy(sortBy ?? [], sortOrder ?? []),
|
||||||
};
|
};
|
||||||
|
|
||||||
return await _activityManager.GetPagedResultAsync(query).ConfigureAwait(false);
|
return await _activityManager.GetPagedResultAsync(query).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static (ActivityLogSortBy SortBy, SortOrder SortOrder)[] GetOrderBy(
|
|
||||||
IReadOnlyList<ActivityLogSortBy> sortBy,
|
|
||||||
IReadOnlyList<SortOrder> requestedSortOrder)
|
|
||||||
{
|
|
||||||
if (sortBy.Count == 0)
|
|
||||||
{
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
var result = new (ActivityLogSortBy, SortOrder)[sortBy.Count];
|
|
||||||
var i = 0;
|
|
||||||
for (; i < requestedSortOrder.Count; i++)
|
|
||||||
{
|
|
||||||
result[i] = (sortBy[i], requestedSortOrder[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add remaining elements with the first specified SortOrder
|
|
||||||
// or the default one if no SortOrders are specified
|
|
||||||
var order = requestedSortOrder.Count > 0 ? requestedSortOrder[0] : SortOrder.Ascending;
|
|
||||||
for (; i < sortBy.Count; i++)
|
|
||||||
{
|
|
||||||
result[i] = (sortBy[i], order);
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1607,8 +1607,9 @@ public class DynamicHlsController : BaseJellyfinApiController
|
|||||||
|
|
||||||
if (state.VideoStream is not null && state.IsOutputVideo)
|
if (state.VideoStream is not null && state.IsOutputVideo)
|
||||||
{
|
{
|
||||||
// fMP4 needs this flag to write the audio packet DTS/PTS including the initial delay into MOOF::TRAF::TFDT
|
// fMP4 needs frag_discont to write the audio packet DTS/PTS including the initial delay into MOOF::TRAF::TFDT
|
||||||
hlsArguments += $" {(useLegacySegmentOption ? "-hls_ts_options" : "-hls_segment_options")} movflags=+frag_discont";
|
// HLS does not use SIDX, and skipping it avoids FFmpeg rewriting open-GOP boundary packet PTS
|
||||||
|
hlsArguments += $" {(useLegacySegmentOption ? "-hls_ts_options" : "-hls_segment_options")} movflags=+frag_discont+skip_sidx";
|
||||||
}
|
}
|
||||||
|
|
||||||
segmentFormat = "fmp4" + outputFmp4HeaderArg;
|
segmentFormat = "fmp4" + outputFmp4HeaderArg;
|
||||||
|
|||||||
@@ -158,13 +158,43 @@ public class FilterController : BaseJellyfinApiController
|
|||||||
IsSeries = isSeries
|
IsSeries = isSeries
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var streamLanguageQuery = new InternalItemsQuery(user)
|
||||||
|
{
|
||||||
|
// It's possible that different langauges are only available on alternative versions.
|
||||||
|
// To fetch them all, owned items are included.
|
||||||
|
IncludeOwnedItems = true,
|
||||||
|
IncludeItemTypes = includeItemTypes,
|
||||||
|
DtoOptions = new DtoOptions
|
||||||
|
{
|
||||||
|
Fields = Array.Empty<ItemFields>(),
|
||||||
|
EnableImages = false,
|
||||||
|
EnableUserData = false
|
||||||
|
},
|
||||||
|
IsAiring = isAiring,
|
||||||
|
IsMovie = isMovie,
|
||||||
|
IsSports = isSports,
|
||||||
|
IsKids = isKids,
|
||||||
|
IsNews = isNews,
|
||||||
|
IsSeries = isSeries
|
||||||
|
};
|
||||||
|
|
||||||
if ((recursive ?? true) || parentItem is UserView || parentItem is ICollectionFolder)
|
if ((recursive ?? true) || parentItem is UserView || parentItem is ICollectionFolder)
|
||||||
{
|
{
|
||||||
genreQuery.AncestorIds = parentItem is null ? Array.Empty<Guid>() : new[] { parentItem.Id };
|
var ancestorIds = parentItem is null ? Array.Empty<Guid>() : new[] { parentItem.Id };
|
||||||
|
genreQuery.AncestorIds = ancestorIds;
|
||||||
|
streamLanguageQuery.AncestorIds = ancestorIds;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
genreQuery.Parent = parentItem;
|
genreQuery.Parent = parentItem;
|
||||||
|
streamLanguageQuery.Parent = parentItem;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((includeItemTypes.Contains(BaseItemKind.Series) || includeItemTypes.Contains(BaseItemKind.Season))
|
||||||
|
&& !includeItemTypes.Contains(BaseItemKind.Episode))
|
||||||
|
{
|
||||||
|
// streams are joined on epsiodes not shows or seasons
|
||||||
|
streamLanguageQuery.IncludeItemTypes = [.. includeItemTypes, BaseItemKind.Episode];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (includeItemTypes.Length == 1
|
if (includeItemTypes.Length == 1
|
||||||
@@ -188,10 +218,13 @@ public class FilterController : BaseJellyfinApiController
|
|||||||
}).ToArray();
|
}).ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (includeItemTypes.Contains(BaseItemKind.Movie) || includeItemTypes.Contains(BaseItemKind.Series))
|
if (includeItemTypes.Contains(BaseItemKind.Movie)
|
||||||
|
|| includeItemTypes.Contains(BaseItemKind.Series)
|
||||||
|
|| includeItemTypes.Contains(BaseItemKind.Season)
|
||||||
|
|| includeItemTypes.Contains(BaseItemKind.Episode))
|
||||||
{
|
{
|
||||||
filters.AudioLanguages = _libraryManager
|
filters.AudioLanguages = _libraryManager
|
||||||
.GetMediaStreamLanguages(MediaStreamType.Audio)
|
.GetMediaStreamLanguages(MediaStreamType.Audio, streamLanguageQuery)
|
||||||
.Select(language =>
|
.Select(language =>
|
||||||
{
|
{
|
||||||
var culture = _localization.FindLanguageInfo(language);
|
var culture = _localization.FindLanguageInfo(language);
|
||||||
@@ -204,7 +237,7 @@ public class FilterController : BaseJellyfinApiController
|
|||||||
.OrderBy(l => l.Name)
|
.OrderBy(l => l.Name)
|
||||||
.ToArray();
|
.ToArray();
|
||||||
filters.SubtitleLanguages = _libraryManager
|
filters.SubtitleLanguages = _libraryManager
|
||||||
.GetMediaStreamLanguages(MediaStreamType.Subtitle)
|
.GetMediaStreamLanguages(MediaStreamType.Subtitle, streamLanguageQuery)
|
||||||
.Select(language =>
|
.Select(language =>
|
||||||
{
|
{
|
||||||
var culture = _localization.FindLanguageInfo(language);
|
var culture = _localization.FindLanguageInfo(language);
|
||||||
|
|||||||
@@ -60,11 +60,8 @@ public class HlsSegmentController : BaseJellyfinApiController
|
|||||||
public ActionResult GetHlsAudioSegmentLegacy([FromRoute, Required] string itemId, [FromRoute, Required] string segmentId)
|
public ActionResult GetHlsAudioSegmentLegacy([FromRoute, Required] string itemId, [FromRoute, Required] string segmentId)
|
||||||
{
|
{
|
||||||
// TODO: Deprecate with new iOS app
|
// TODO: Deprecate with new iOS app
|
||||||
var file = string.Concat(segmentId, Path.GetExtension(Request.Path.Value.AsSpan()));
|
var file = ValidateTranscodePath(string.Concat(segmentId, Path.GetExtension(Request.Path.Value.AsSpan())));
|
||||||
var transcodePath = _serverConfigurationManager.GetTranscodePath();
|
if (file is null)
|
||||||
file = Path.GetFullPath(Path.Combine(transcodePath, file));
|
|
||||||
var fileDir = Path.GetDirectoryName(file);
|
|
||||||
if (string.IsNullOrEmpty(fileDir) || !fileDir.StartsWith(transcodePath, StringComparison.InvariantCulture))
|
|
||||||
{
|
{
|
||||||
return BadRequest("Invalid segment.");
|
return BadRequest("Invalid segment.");
|
||||||
}
|
}
|
||||||
@@ -86,12 +83,9 @@ public class HlsSegmentController : BaseJellyfinApiController
|
|||||||
[SuppressMessage("Microsoft.Performance", "CA1801:ReviewUnusedParameters", MessageId = "itemId", Justification = "Required for ServiceStack")]
|
[SuppressMessage("Microsoft.Performance", "CA1801:ReviewUnusedParameters", MessageId = "itemId", Justification = "Required for ServiceStack")]
|
||||||
public ActionResult GetHlsPlaylistLegacy([FromRoute, Required] string itemId, [FromRoute, Required] string playlistId)
|
public ActionResult GetHlsPlaylistLegacy([FromRoute, Required] string itemId, [FromRoute, Required] string playlistId)
|
||||||
{
|
{
|
||||||
var file = string.Concat(playlistId, Path.GetExtension(Request.Path.Value.AsSpan()));
|
var file = ValidateTranscodePath(string.Concat(playlistId, Path.GetExtension(Request.Path.Value.AsSpan())));
|
||||||
var transcodePath = _serverConfigurationManager.GetTranscodePath();
|
if (file is null
|
||||||
file = Path.GetFullPath(Path.Combine(transcodePath, file));
|
|| !Path.GetExtension(file.AsSpan()).Equals(".m3u8", StringComparison.OrdinalIgnoreCase))
|
||||||
var fileDir = Path.GetDirectoryName(file);
|
|
||||||
if (string.IsNullOrEmpty(fileDir) || !fileDir.StartsWith(transcodePath, StringComparison.InvariantCulture)
|
|
||||||
|| Path.GetExtension(file.AsSpan()).Equals(".m3u8", StringComparison.OrdinalIgnoreCase))
|
|
||||||
{
|
{
|
||||||
return BadRequest("Invalid segment.");
|
return BadRequest("Invalid segment.");
|
||||||
}
|
}
|
||||||
@@ -140,18 +134,13 @@ public class HlsSegmentController : BaseJellyfinApiController
|
|||||||
[FromRoute, Required] string segmentId,
|
[FromRoute, Required] string segmentId,
|
||||||
[FromRoute, Required] string segmentContainer)
|
[FromRoute, Required] string segmentContainer)
|
||||||
{
|
{
|
||||||
var file = string.Concat(segmentId, Path.GetExtension(Request.Path.Value.AsSpan()));
|
var file = ValidateTranscodePath(string.Concat(segmentId, Path.GetExtension(Request.Path.Value.AsSpan())));
|
||||||
var transcodeFolderPath = _serverConfigurationManager.GetTranscodePath();
|
if (file is null)
|
||||||
|
|
||||||
file = Path.GetFullPath(Path.Combine(transcodeFolderPath, file));
|
|
||||||
var fileDir = Path.GetDirectoryName(file);
|
|
||||||
if (string.IsNullOrEmpty(fileDir) || !fileDir.StartsWith(transcodeFolderPath, StringComparison.InvariantCulture))
|
|
||||||
{
|
{
|
||||||
return BadRequest("Invalid segment.");
|
return BadRequest("Invalid segment.");
|
||||||
}
|
}
|
||||||
|
|
||||||
var normalizedPlaylistId = playlistId;
|
var transcodeFolderPath = _serverConfigurationManager.GetTranscodePath();
|
||||||
|
|
||||||
var filePaths = _fileSystem.GetFilePaths(transcodeFolderPath);
|
var filePaths = _fileSystem.GetFilePaths(transcodeFolderPath);
|
||||||
// Add . to start of segment container for future use.
|
// Add . to start of segment container for future use.
|
||||||
segmentContainer = segmentContainer.Insert(0, ".");
|
segmentContainer = segmentContainer.Insert(0, ".");
|
||||||
@@ -161,7 +150,7 @@ public class HlsSegmentController : BaseJellyfinApiController
|
|||||||
var pathExtension = Path.GetExtension(path);
|
var pathExtension = Path.GetExtension(path);
|
||||||
if ((string.Equals(pathExtension, segmentContainer, StringComparison.OrdinalIgnoreCase)
|
if ((string.Equals(pathExtension, segmentContainer, StringComparison.OrdinalIgnoreCase)
|
||||||
|| string.Equals(pathExtension, ".m3u8", StringComparison.OrdinalIgnoreCase))
|
|| string.Equals(pathExtension, ".m3u8", StringComparison.OrdinalIgnoreCase))
|
||||||
&& path.Contains(normalizedPlaylistId, StringComparison.OrdinalIgnoreCase))
|
&& path.Contains(playlistId, StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
playlistPath = path;
|
playlistPath = path;
|
||||||
break;
|
break;
|
||||||
@@ -173,6 +162,19 @@ public class HlsSegmentController : BaseJellyfinApiController
|
|||||||
: GetFileResult(file, playlistPath);
|
: GetFileResult(file, playlistPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private string? ValidateTranscodePath(string filename)
|
||||||
|
{
|
||||||
|
var transcodePath = Path.TrimEndingDirectorySeparator(Path.GetFullPath(_serverConfigurationManager.GetTranscodePath()));
|
||||||
|
var file = Path.GetFullPath(filename, transcodePath);
|
||||||
|
// Require a separator after the transcode path so a sibling like "<transcodePath>-evil" can't pass.
|
||||||
|
if (!file.StartsWith(transcodePath + Path.DirectorySeparatorChar, StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return file;
|
||||||
|
}
|
||||||
|
|
||||||
private ActionResult GetFileResult(string path, string playlistPath)
|
private ActionResult GetFileResult(string path, string playlistPath)
|
||||||
{
|
{
|
||||||
var transcodingJob = _transcodeManager.OnTranscodeBeginRequest(playlistPath, TranscodingJobType.Hls);
|
var transcodingJob = _transcodeManager.OnTranscodeBeginRequest(playlistPath, TranscodingJobType.Hls);
|
||||||
|
|||||||
@@ -125,7 +125,13 @@ public class ImageController : BaseJellyfinApiController
|
|||||||
{
|
{
|
||||||
// Handle image/png; charset=utf-8
|
// Handle image/png; charset=utf-8
|
||||||
var mimeType = Request.ContentType?.Split(';').FirstOrDefault();
|
var mimeType = Request.ContentType?.Split(';').FirstOrDefault();
|
||||||
var userDataPath = Path.Combine(_serverConfigurationManager.ApplicationPaths.UserConfigurationDirectoryPath, user.Username);
|
var userConfigurationDirectoryPath = _serverConfigurationManager.ApplicationPaths.UserConfigurationDirectoryPath;
|
||||||
|
var userDataPath = Path.Combine(userConfigurationDirectoryPath, user.Username);
|
||||||
|
if (!PathHelper.IsContainedIn(userConfigurationDirectoryPath, userDataPath))
|
||||||
|
{
|
||||||
|
return BadRequest("Invalid user.");
|
||||||
|
}
|
||||||
|
|
||||||
if (user.ProfileImage is not null)
|
if (user.ProfileImage is not null)
|
||||||
{
|
{
|
||||||
await _userManager.ClearProfileImageAsync(user).ConfigureAwait(false);
|
await _userManager.ClearProfileImageAsync(user).ConfigureAwait(false);
|
||||||
@@ -2049,7 +2055,7 @@ public class ImageController : BaseJellyfinApiController
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check If-Modified-Since header for time-based validation
|
// Check If-Modified-Since header for time-based validation
|
||||||
if (DateTime.TryParse(Request.Headers[HeaderNames.IfModifiedSince], out var ifModifiedSinceHeader))
|
if (DateTime.TryParse(Request.Headers[HeaderNames.IfModifiedSince], CultureInfo.InvariantCulture, out var ifModifiedSinceHeader))
|
||||||
{
|
{
|
||||||
// Return 304 if the image has not been modified since the client's cached version
|
// Return 304 if the image has not been modified since the client's cached version
|
||||||
if (dateImageModified <= ifModifiedSinceHeader)
|
if (dateImageModified <= ifModifiedSinceHeader)
|
||||||
|
|||||||
@@ -236,7 +236,7 @@ public class ItemUpdateController : BaseJellyfinApiController
|
|||||||
return NoContent();
|
return NoContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task UpdateItem(BaseItemDto request, BaseItem item)
|
internal async Task UpdateItem(BaseItemDto request, BaseItem item)
|
||||||
{
|
{
|
||||||
item.Name = request.Name;
|
item.Name = request.Name;
|
||||||
item.ForcedSortName = request.ForcedSortName;
|
item.ForcedSortName = request.ForcedSortName;
|
||||||
@@ -250,7 +250,11 @@ public class ItemUpdateController : BaseJellyfinApiController
|
|||||||
item.IndexNumber = request.IndexNumber;
|
item.IndexNumber = request.IndexNumber;
|
||||||
item.ParentIndexNumber = request.ParentIndexNumber;
|
item.ParentIndexNumber = request.ParentIndexNumber;
|
||||||
item.Overview = request.Overview;
|
item.Overview = request.Overview;
|
||||||
item.Genres = request.Genres.Distinct(StringComparer.OrdinalIgnoreCase).ToArray();
|
|
||||||
|
if (request.Genres is not null)
|
||||||
|
{
|
||||||
|
item.Genres = request.Genres.Distinct(StringComparer.OrdinalIgnoreCase).ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
if (item is Episode episode)
|
if (item is Episode episode)
|
||||||
{
|
{
|
||||||
@@ -279,6 +283,11 @@ public class ItemUpdateController : BaseJellyfinApiController
|
|||||||
item.DateCreated = NormalizeDateTime(request.DateCreated.Value);
|
item.DateCreated = NormalizeDateTime(request.DateCreated.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (request.SeriesName is not null && item is IHasSeries hasSeries)
|
||||||
|
{
|
||||||
|
hasSeries.SeriesName = request.SeriesName;
|
||||||
|
}
|
||||||
|
|
||||||
item.EndDate = request.EndDate.HasValue ? NormalizeDateTime(request.EndDate.Value) : null;
|
item.EndDate = request.EndDate.HasValue ? NormalizeDateTime(request.EndDate.Value) : null;
|
||||||
item.PremiereDate = request.PremiereDate.HasValue ? NormalizeDateTime(request.PremiereDate.Value) : null;
|
item.PremiereDate = request.PremiereDate.HasValue ? NormalizeDateTime(request.PremiereDate.Value) : null;
|
||||||
item.ProductionYear = request.ProductionYear;
|
item.ProductionYear = request.ProductionYear;
|
||||||
@@ -288,15 +297,27 @@ public class ItemUpdateController : BaseJellyfinApiController
|
|||||||
item.CustomRating = request.CustomRating;
|
item.CustomRating = request.CustomRating;
|
||||||
|
|
||||||
var currentTags = item.Tags;
|
var currentTags = item.Tags;
|
||||||
var newTags = request.Tags.Select(t => t.Trim()).Distinct(StringComparer.OrdinalIgnoreCase).ToArray();
|
List<string> removedTags;
|
||||||
var removedTags = currentTags.Except(newTags).ToList();
|
List<string> addedTags;
|
||||||
var addedTags = newTags.Except(currentTags).ToList();
|
if (request.Tags is not null)
|
||||||
item.Tags = newTags;
|
{
|
||||||
|
var newTags = request.Tags.Select(t => t.Trim()).Distinct(StringComparer.OrdinalIgnoreCase).ToArray();
|
||||||
|
removedTags = currentTags.Except(newTags).ToList();
|
||||||
|
addedTags = newTags.Except(currentTags).ToList();
|
||||||
|
item.Tags = newTags;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
removedTags = [];
|
||||||
|
addedTags = [];
|
||||||
|
}
|
||||||
|
|
||||||
if (item is Series rseries)
|
if (item is Series rseries)
|
||||||
{
|
{
|
||||||
foreach (var season in rseries.Children.OfType<Season>())
|
foreach (var season in rseries.Children.OfType<Season>())
|
||||||
{
|
{
|
||||||
|
season.SeriesName = rseries.Name;
|
||||||
|
|
||||||
if (!season.LockedFields.Contains(MetadataField.OfficialRating))
|
if (!season.LockedFields.Contains(MetadataField.OfficialRating))
|
||||||
{
|
{
|
||||||
season.OfficialRating = request.OfficialRating;
|
season.OfficialRating = request.OfficialRating;
|
||||||
@@ -314,6 +335,8 @@ public class ItemUpdateController : BaseJellyfinApiController
|
|||||||
|
|
||||||
foreach (var ep in season.Children.OfType<Episode>())
|
foreach (var ep in season.Children.OfType<Episode>())
|
||||||
{
|
{
|
||||||
|
ep.SeriesName = rseries.Name;
|
||||||
|
|
||||||
if (!ep.LockedFields.Contains(MetadataField.OfficialRating))
|
if (!ep.LockedFields.Contains(MetadataField.OfficialRating))
|
||||||
{
|
{
|
||||||
ep.OfficialRating = request.OfficialRating;
|
ep.OfficialRating = request.OfficialRating;
|
||||||
@@ -403,15 +426,18 @@ public class ItemUpdateController : BaseJellyfinApiController
|
|||||||
item.RunTimeTicks = request.RunTimeTicks;
|
item.RunTimeTicks = request.RunTimeTicks;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var pair in request.ProviderIds.ToList())
|
if (request.ProviderIds is not null)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(pair.Value))
|
foreach (var pair in request.ProviderIds.ToList())
|
||||||
{
|
{
|
||||||
request.ProviderIds.Remove(pair.Key);
|
if (string.IsNullOrEmpty(pair.Value))
|
||||||
|
{
|
||||||
|
request.ProviderIds.Remove(pair.Key);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
item.ProviderIds = request.ProviderIds;
|
item.ProviderIds = request.ProviderIds;
|
||||||
|
}
|
||||||
|
|
||||||
if (item is Video video)
|
if (item is Video video)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -287,6 +287,8 @@ public class ItemsController : BaseJellyfinApiController
|
|||||||
QueryResult<BaseItem> result;
|
QueryResult<BaseItem> result;
|
||||||
|
|
||||||
Guid[] linkedChildAncestorIds = [];
|
Guid[] linkedChildAncestorIds = [];
|
||||||
|
|
||||||
|
includeItemTypes ??= [];
|
||||||
if (includeItemTypes.Length == 1
|
if (includeItemTypes.Length == 1
|
||||||
&& (includeItemTypes[0] == BaseItemKind.BoxSet || includeItemTypes[0] == BaseItemKind.Playlist)
|
&& (includeItemTypes[0] == BaseItemKind.BoxSet || includeItemTypes[0] == BaseItemKind.Playlist)
|
||||||
&& item is not BoxSet
|
&& item is not BoxSet
|
||||||
@@ -326,7 +328,6 @@ public class ItemsController : BaseJellyfinApiController
|
|||||||
includeItemTypes = collectionType switch
|
includeItemTypes = collectionType switch
|
||||||
{
|
{
|
||||||
CollectionType.boxsets => [BaseItemKind.BoxSet],
|
CollectionType.boxsets => [BaseItemKind.BoxSet],
|
||||||
null => [BaseItemKind.Movie, BaseItemKind.Series],
|
|
||||||
_ => []
|
_ => []
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -962,9 +963,15 @@ public class ItemsController : BaseJellyfinApiController
|
|||||||
var excludeItemIds = Array.Empty<Guid>();
|
var excludeItemIds = Array.Empty<Guid>();
|
||||||
if (excludeActiveSessions)
|
if (excludeActiveSessions)
|
||||||
{
|
{
|
||||||
|
// NowPlayingItem.Id is the displayed/primary id, but resume queries surface the actually-played
|
||||||
|
// alternate version's own id. Expand each active session to every version id so an in-progress
|
||||||
|
// alternate is excluded too, instead of leaking back into the resume list.
|
||||||
excludeItemIds = _sessionManager.Sessions
|
excludeItemIds = _sessionManager.Sessions
|
||||||
.Where(s => s.UserId.Equals(requestUserId) && s.NowPlayingItem is not null)
|
.Where(s => s.UserId.Equals(requestUserId) && s.NowPlayingItem is not null)
|
||||||
.Select(s => s.NowPlayingItem.Id)
|
.SelectMany(s => _libraryManager.GetItemById(s.NowPlayingItem.Id) is Video video
|
||||||
|
? video.GetAllVersions().Select(v => v.Id)
|
||||||
|
: [s.NowPlayingItem.Id])
|
||||||
|
.Distinct()
|
||||||
.ToArray();
|
.ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ public class MediaInfoController : BaseJellyfinApiController
|
|||||||
return NotFound();
|
return NotFound();
|
||||||
}
|
}
|
||||||
|
|
||||||
return await _mediaInfoHelper.GetPlaybackInfo(item, user).ConfigureAwait(false);
|
return await _mediaInfoHelper.GetPlaybackInfo(item, user, Request).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -177,6 +177,7 @@ public class MediaInfoController : BaseJellyfinApiController
|
|||||||
var info = await _mediaInfoHelper.GetPlaybackInfo(
|
var info = await _mediaInfoHelper.GetPlaybackInfo(
|
||||||
item,
|
item,
|
||||||
user,
|
user,
|
||||||
|
Request,
|
||||||
mediaSourceId,
|
mediaSourceId,
|
||||||
liveStreamId)
|
liveStreamId)
|
||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ using System.Linq;
|
|||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Jellyfin.Api.Attributes;
|
using Jellyfin.Api.Attributes;
|
||||||
|
using Jellyfin.Extensions;
|
||||||
using Jellyfin.Extensions.Json;
|
using Jellyfin.Extensions.Json;
|
||||||
using MediaBrowser.Common.Api;
|
using MediaBrowser.Common.Api;
|
||||||
using MediaBrowser.Common.Plugins;
|
using MediaBrowser.Common.Plugins;
|
||||||
@@ -226,10 +227,13 @@ public class PluginsController : BaseJellyfinApiController
|
|||||||
return NotFound();
|
return NotFound();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(plugin.Manifest.ImagePath))
|
string? imagePath = plugin.Manifest.ImagePath;
|
||||||
|
if (!string.IsNullOrWhiteSpace(imagePath))
|
||||||
{
|
{
|
||||||
var imagePath = Path.Combine(plugin.Path, plugin.Manifest.ImagePath);
|
var pluginPath = Path.TrimEndingDirectorySeparator(Path.GetFullPath(plugin.Path));
|
||||||
if (!System.IO.File.Exists(imagePath))
|
imagePath = Path.GetFullPath(imagePath, pluginPath);
|
||||||
|
// Require a separator after the plugin path so a sibling like "<pluginPath>-evil" can't pass.
|
||||||
|
if (imagePath.StartsWith(pluginPath + Path.DirectorySeparatorChar, StringComparison.OrdinalIgnoreCase) is false || System.IO.File.Exists(imagePath) is false)
|
||||||
{
|
{
|
||||||
return NotFound();
|
return NotFound();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -140,6 +140,11 @@ public class StartupController : BaseJellyfinApiController
|
|||||||
return NotFound();
|
return NotFound();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(user.Password))
|
||||||
|
{
|
||||||
|
return Forbid();
|
||||||
|
}
|
||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(startupUserDto.Password))
|
if (string.IsNullOrWhiteSpace(startupUserDto.Password))
|
||||||
{
|
{
|
||||||
return BadRequest("Password must not be empty");
|
return BadRequest("Password must not be empty");
|
||||||
|
|||||||
@@ -277,8 +277,15 @@ public class TvShowsController : BaseJellyfinApiController
|
|||||||
|
|
||||||
if (startItemId.HasValue)
|
if (startItemId.HasValue)
|
||||||
{
|
{
|
||||||
|
// The start item may be an alternate version, which is not part of the episode listing; start from its primary episode instead.
|
||||||
|
var startId = startItemId.Value;
|
||||||
|
if (_libraryManager.GetItemById<Video>(startId)?.PrimaryVersionId is { } primaryVersionId)
|
||||||
|
{
|
||||||
|
startId = primaryVersionId;
|
||||||
|
}
|
||||||
|
|
||||||
episodes = episodes
|
episodes = episodes
|
||||||
.SkipWhile(i => !startItemId.Value.Equals(i.Id))
|
.SkipWhile(i => !startId.Equals(i.Id))
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -133,6 +133,7 @@ public class UniversalAudioController : BaseJellyfinApiController
|
|||||||
var info = await _mediaInfoHelper.GetPlaybackInfo(
|
var info = await _mediaInfoHelper.GetPlaybackInfo(
|
||||||
item,
|
item,
|
||||||
user,
|
user,
|
||||||
|
Request,
|
||||||
mediaSourceId)
|
mediaSourceId)
|
||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
|
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ public class UserLibraryController : BaseJellyfinApiController
|
|||||||
private readonly IDtoService _dtoService;
|
private readonly IDtoService _dtoService;
|
||||||
private readonly IUserViewManager _userViewManager;
|
private readonly IUserViewManager _userViewManager;
|
||||||
private readonly IFileSystem _fileSystem;
|
private readonly IFileSystem _fileSystem;
|
||||||
|
private readonly IProviderManager _providerManager;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="UserLibraryController"/> class.
|
/// Initializes a new instance of the <see cref="UserLibraryController"/> class.
|
||||||
@@ -50,13 +51,15 @@ public class UserLibraryController : BaseJellyfinApiController
|
|||||||
/// <param name="dtoService">Instance of the <see cref="IDtoService"/> interface.</param>
|
/// <param name="dtoService">Instance of the <see cref="IDtoService"/> interface.</param>
|
||||||
/// <param name="userViewManager">Instance of the <see cref="IUserViewManager"/> interface.</param>
|
/// <param name="userViewManager">Instance of the <see cref="IUserViewManager"/> interface.</param>
|
||||||
/// <param name="fileSystem">Instance of the <see cref="IFileSystem"/> interface.</param>
|
/// <param name="fileSystem">Instance of the <see cref="IFileSystem"/> interface.</param>
|
||||||
|
/// <param name="providerManager">Instance of the <see cref="IProviderManager"/> interface.</param>
|
||||||
public UserLibraryController(
|
public UserLibraryController(
|
||||||
IUserManager userManager,
|
IUserManager userManager,
|
||||||
IUserDataManager userDataRepository,
|
IUserDataManager userDataRepository,
|
||||||
ILibraryManager libraryManager,
|
ILibraryManager libraryManager,
|
||||||
IDtoService dtoService,
|
IDtoService dtoService,
|
||||||
IUserViewManager userViewManager,
|
IUserViewManager userViewManager,
|
||||||
IFileSystem fileSystem)
|
IFileSystem fileSystem,
|
||||||
|
IProviderManager providerManager)
|
||||||
{
|
{
|
||||||
_userManager = userManager;
|
_userManager = userManager;
|
||||||
_userDataRepository = userDataRepository;
|
_userDataRepository = userDataRepository;
|
||||||
@@ -64,6 +67,7 @@ public class UserLibraryController : BaseJellyfinApiController
|
|||||||
_dtoService = dtoService;
|
_dtoService = dtoService;
|
||||||
_userViewManager = userViewManager;
|
_userViewManager = userViewManager;
|
||||||
_fileSystem = fileSystem;
|
_fileSystem = fileSystem;
|
||||||
|
_providerManager = providerManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -75,7 +79,7 @@ public class UserLibraryController : BaseJellyfinApiController
|
|||||||
/// <returns>An <see cref="OkResult"/> containing the item.</returns>
|
/// <returns>An <see cref="OkResult"/> containing the item.</returns>
|
||||||
[HttpGet("Items/{itemId}")]
|
[HttpGet("Items/{itemId}")]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
public async Task<ActionResult<BaseItemDto>> GetItem(
|
public ActionResult<BaseItemDto> GetItem(
|
||||||
[FromQuery] Guid? userId,
|
[FromQuery] Guid? userId,
|
||||||
[FromRoute, Required] Guid itemId)
|
[FromRoute, Required] Guid itemId)
|
||||||
{
|
{
|
||||||
@@ -94,7 +98,7 @@ public class UserLibraryController : BaseJellyfinApiController
|
|||||||
return NotFound();
|
return NotFound();
|
||||||
}
|
}
|
||||||
|
|
||||||
await RefreshItemOnDemandIfNeeded(item).ConfigureAwait(false);
|
QueueRefreshOnDemandIfNeeded(item);
|
||||||
|
|
||||||
var dtoOptions = new DtoOptions();
|
var dtoOptions = new DtoOptions();
|
||||||
|
|
||||||
@@ -112,7 +116,7 @@ public class UserLibraryController : BaseJellyfinApiController
|
|||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[Obsolete("Kept for backwards compatibility")]
|
[Obsolete("Kept for backwards compatibility")]
|
||||||
[ApiExplorerSettings(IgnoreApi = true)]
|
[ApiExplorerSettings(IgnoreApi = true)]
|
||||||
public Task<ActionResult<BaseItemDto>> GetItemLegacy(
|
public ActionResult<BaseItemDto> GetItemLegacy(
|
||||||
[FromRoute, Required] Guid userId,
|
[FromRoute, Required] Guid userId,
|
||||||
[FromRoute, Required] Guid itemId)
|
[FromRoute, Required] Guid itemId)
|
||||||
=> GetItem(userId, itemId);
|
=> GetItem(userId, itemId);
|
||||||
@@ -551,8 +555,6 @@ public class UserLibraryController : BaseJellyfinApiController
|
|||||||
var dtoOptions = new DtoOptions { Fields = fields }
|
var dtoOptions = new DtoOptions { Fields = fields }
|
||||||
.AddAdditionalDtoOptions(enableImages, enableUserData, imageTypeLimit, enableImageTypes);
|
.AddAdditionalDtoOptions(enableImages, enableUserData, imageTypeLimit, enableImageTypes);
|
||||||
|
|
||||||
dtoOptions.PreferEpisodeParentPoster = true;
|
|
||||||
|
|
||||||
var list = _userViewManager.GetLatestItems(
|
var list = _userViewManager.GetLatestItems(
|
||||||
new LatestItemsQuery
|
new LatestItemsQuery
|
||||||
{
|
{
|
||||||
@@ -641,25 +643,28 @@ public class UserLibraryController : BaseJellyfinApiController
|
|||||||
limit,
|
limit,
|
||||||
groupItems);
|
groupItems);
|
||||||
|
|
||||||
private async Task RefreshItemOnDemandIfNeeded(BaseItem item)
|
private void QueueRefreshOnDemandIfNeeded(BaseItem item)
|
||||||
{
|
{
|
||||||
if (item is Person)
|
if (item is not Person)
|
||||||
{
|
{
|
||||||
var hasMetadata = !string.IsNullOrWhiteSpace(item.Overview) && item.HasImage(ImageType.Primary);
|
return;
|
||||||
var performFullRefresh = !hasMetadata && (DateTime.UtcNow - item.DateLastRefreshed).TotalDays >= 3;
|
|
||||||
|
|
||||||
if (performFullRefresh)
|
|
||||||
{
|
|
||||||
var options = new MetadataRefreshOptions(new DirectoryService(_fileSystem))
|
|
||||||
{
|
|
||||||
MetadataRefreshMode = MetadataRefreshMode.FullRefresh,
|
|
||||||
ImageRefreshMode = MetadataRefreshMode.FullRefresh,
|
|
||||||
ForceSave = true
|
|
||||||
};
|
|
||||||
|
|
||||||
await item.RefreshMetadata(options, CancellationToken.None).ConfigureAwait(false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var hasMetadata = !string.IsNullOrWhiteSpace(item.Overview) && item.HasImage(ImageType.Primary);
|
||||||
|
if (hasMetadata || (DateTime.UtcNow - item.DateLastRefreshed).TotalDays < 3)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_providerManager.QueueRefresh(
|
||||||
|
item.Id,
|
||||||
|
new MetadataRefreshOptions(new DirectoryService(_fileSystem))
|
||||||
|
{
|
||||||
|
MetadataRefreshMode = MetadataRefreshMode.FullRefresh,
|
||||||
|
ImageRefreshMode = MetadataRefreshMode.FullRefresh,
|
||||||
|
ForceSave = true
|
||||||
|
},
|
||||||
|
RefreshPriority.High);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using Jellyfin.Data.Enums;
|
||||||
using MediaBrowser.Controller.Dto;
|
using MediaBrowser.Controller.Dto;
|
||||||
using MediaBrowser.Model.Entities;
|
using MediaBrowser.Model.Entities;
|
||||||
|
|
||||||
@@ -9,6 +10,37 @@ namespace Jellyfin.Api.Extensions;
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static class DtoExtensions
|
public static class DtoExtensions
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the BaseItemKind values associated with the specified CollectionType.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="collectionType">The collection type to map to BaseItemKind values.</param>
|
||||||
|
/// <returns>An array of BaseItemKind values that correspond to the collection type.</returns>
|
||||||
|
public static BaseItemKind[] GetBaseItemKindsForCollectionType(CollectionType? collectionType)
|
||||||
|
{
|
||||||
|
switch (collectionType)
|
||||||
|
{
|
||||||
|
case CollectionType.movies:
|
||||||
|
return [BaseItemKind.Movie];
|
||||||
|
case CollectionType.tvshows:
|
||||||
|
return [BaseItemKind.Series];
|
||||||
|
case CollectionType.music:
|
||||||
|
return [BaseItemKind.MusicAlbum];
|
||||||
|
case CollectionType.musicvideos:
|
||||||
|
return [BaseItemKind.MusicVideo];
|
||||||
|
case CollectionType.books:
|
||||||
|
return [BaseItemKind.Book, BaseItemKind.AudioBook];
|
||||||
|
case CollectionType.boxsets:
|
||||||
|
return [BaseItemKind.BoxSet];
|
||||||
|
case CollectionType.homevideos:
|
||||||
|
case CollectionType.photos:
|
||||||
|
return [BaseItemKind.Video, BaseItemKind.Photo];
|
||||||
|
case CollectionType.folders:
|
||||||
|
return [];
|
||||||
|
default:
|
||||||
|
return [BaseItemKind.Video, BaseItemKind.Audio, BaseItemKind.Photo, BaseItemKind.Movie, BaseItemKind.Series];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Add additional DtoOptions.
|
/// Add additional DtoOptions.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ using Jellyfin.Database.Implementations.Enums;
|
|||||||
using Jellyfin.Extensions;
|
using Jellyfin.Extensions;
|
||||||
using MediaBrowser.Common.Extensions;
|
using MediaBrowser.Common.Extensions;
|
||||||
using MediaBrowser.Common.Net;
|
using MediaBrowser.Common.Net;
|
||||||
|
using MediaBrowser.Controller;
|
||||||
using MediaBrowser.Controller.Configuration;
|
using MediaBrowser.Controller.Configuration;
|
||||||
using MediaBrowser.Controller.Devices;
|
using MediaBrowser.Controller.Devices;
|
||||||
using MediaBrowser.Controller.Entities;
|
using MediaBrowser.Controller.Entities;
|
||||||
@@ -44,6 +45,7 @@ public class MediaInfoHelper
|
|||||||
private readonly ILogger<MediaInfoHelper> _logger;
|
private readonly ILogger<MediaInfoHelper> _logger;
|
||||||
private readonly INetworkManager _networkManager;
|
private readonly INetworkManager _networkManager;
|
||||||
private readonly IDeviceManager _deviceManager;
|
private readonly IDeviceManager _deviceManager;
|
||||||
|
private readonly IServerApplicationHost _appHost;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="MediaInfoHelper"/> class.
|
/// Initializes a new instance of the <see cref="MediaInfoHelper"/> class.
|
||||||
@@ -56,6 +58,7 @@ public class MediaInfoHelper
|
|||||||
/// <param name="logger">Instance of the <see cref="ILogger{MediaInfoHelper}"/> interface.</param>
|
/// <param name="logger">Instance of the <see cref="ILogger{MediaInfoHelper}"/> interface.</param>
|
||||||
/// <param name="networkManager">Instance of the <see cref="INetworkManager"/> interface.</param>
|
/// <param name="networkManager">Instance of the <see cref="INetworkManager"/> interface.</param>
|
||||||
/// <param name="deviceManager">Instance of the <see cref="IDeviceManager"/> interface.</param>
|
/// <param name="deviceManager">Instance of the <see cref="IDeviceManager"/> interface.</param>
|
||||||
|
/// <param name="appHost">Instance of the <see cref="IServerApplicationHost"/> interface.</param>
|
||||||
public MediaInfoHelper(
|
public MediaInfoHelper(
|
||||||
IUserManager userManager,
|
IUserManager userManager,
|
||||||
ILibraryManager libraryManager,
|
ILibraryManager libraryManager,
|
||||||
@@ -64,7 +67,8 @@ public class MediaInfoHelper
|
|||||||
IServerConfigurationManager serverConfigurationManager,
|
IServerConfigurationManager serverConfigurationManager,
|
||||||
ILogger<MediaInfoHelper> logger,
|
ILogger<MediaInfoHelper> logger,
|
||||||
INetworkManager networkManager,
|
INetworkManager networkManager,
|
||||||
IDeviceManager deviceManager)
|
IDeviceManager deviceManager,
|
||||||
|
IServerApplicationHost appHost)
|
||||||
{
|
{
|
||||||
_userManager = userManager;
|
_userManager = userManager;
|
||||||
_libraryManager = libraryManager;
|
_libraryManager = libraryManager;
|
||||||
@@ -74,6 +78,7 @@ public class MediaInfoHelper
|
|||||||
_logger = logger;
|
_logger = logger;
|
||||||
_networkManager = networkManager;
|
_networkManager = networkManager;
|
||||||
_deviceManager = deviceManager;
|
_deviceManager = deviceManager;
|
||||||
|
_appHost = appHost;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -81,40 +86,20 @@ public class MediaInfoHelper
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="item">The item.</param>
|
/// <param name="item">The item.</param>
|
||||||
/// <param name="user">The user.</param>
|
/// <param name="user">The user.</param>
|
||||||
|
/// <param name="request">The current <see cref="HttpRequest"/>.</param>
|
||||||
/// <param name="mediaSourceId">Media source id.</param>
|
/// <param name="mediaSourceId">Media source id.</param>
|
||||||
/// <param name="liveStreamId">Live stream id.</param>
|
/// <param name="liveStreamId">Live stream id.</param>
|
||||||
/// <returns>A <see cref="Task"/> containing the <see cref="PlaybackInfoResponse"/>.</returns>
|
/// <returns>A <see cref="Task"/> containing the <see cref="PlaybackInfoResponse"/>.</returns>
|
||||||
public async Task<PlaybackInfoResponse> GetPlaybackInfo(
|
public async Task<PlaybackInfoResponse> GetPlaybackInfo(
|
||||||
BaseItem item,
|
BaseItem item,
|
||||||
User? user,
|
User? user,
|
||||||
|
HttpRequest request,
|
||||||
string? mediaSourceId = null,
|
string? mediaSourceId = null,
|
||||||
string? liveStreamId = null)
|
string? liveStreamId = null)
|
||||||
{
|
{
|
||||||
var result = new PlaybackInfoResponse();
|
var result = new PlaybackInfoResponse();
|
||||||
|
|
||||||
MediaSourceInfo[] mediaSources;
|
var mediaSources = await ResolvePlaybackMediaSources(item, user, mediaSourceId, liveStreamId).ConfigureAwait(false);
|
||||||
if (string.IsNullOrWhiteSpace(liveStreamId))
|
|
||||||
{
|
|
||||||
// TODO (moved from MediaBrowser.Api) handle supportedLiveMediaTypes?
|
|
||||||
var mediaSourcesList = await _mediaSourceManager.GetPlaybackMediaSources(item, user, true, true, CancellationToken.None).ConfigureAwait(false);
|
|
||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(mediaSourceId))
|
|
||||||
{
|
|
||||||
mediaSources = mediaSourcesList.ToArray();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mediaSources = mediaSourcesList
|
|
||||||
.Where(i => string.Equals(i.Id, mediaSourceId, StringComparison.OrdinalIgnoreCase))
|
|
||||||
.ToArray();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var mediaSource = await _mediaSourceManager.GetLiveStream(liveStreamId, CancellationToken.None).ConfigureAwait(false);
|
|
||||||
|
|
||||||
mediaSources = new[] { mediaSource };
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mediaSources.Length == 0)
|
if (mediaSources.Length == 0)
|
||||||
{
|
{
|
||||||
@@ -136,6 +121,11 @@ public class MediaInfoHelper
|
|||||||
mediaSourcesClone[i].DefaultAudioIndexSource = mediaSources[i].DefaultAudioIndexSource;
|
mediaSourcesClone[i].DefaultAudioIndexSource = mediaSources[i].DefaultAudioIndexSource;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach (var mediaSource in mediaSourcesClone)
|
||||||
|
{
|
||||||
|
RewritePublishedLiveStreamPath(mediaSource, request);
|
||||||
|
}
|
||||||
|
|
||||||
result.MediaSources = mediaSourcesClone;
|
result.MediaSources = mediaSourcesClone;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -145,6 +135,28 @@ public class MediaInfoHelper
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task<MediaSourceInfo[]> ResolvePlaybackMediaSources(BaseItem item, User? user, string? mediaSourceId, string? liveStreamId)
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrWhiteSpace(liveStreamId))
|
||||||
|
{
|
||||||
|
var mediaSource = await _mediaSourceManager.GetLiveStream(liveStreamId, CancellationToken.None).ConfigureAwait(false);
|
||||||
|
|
||||||
|
return new[] { mediaSource };
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO (moved from MediaBrowser.Api) handle supportedLiveMediaTypes?
|
||||||
|
var mediaSourcesList = await _mediaSourceManager.GetPlaybackMediaSources(item, user, true, true, CancellationToken.None).ConfigureAwait(false);
|
||||||
|
|
||||||
|
if (string.IsNullOrWhiteSpace(mediaSourceId))
|
||||||
|
{
|
||||||
|
return mediaSourcesList.ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
return mediaSourcesList
|
||||||
|
.Where(i => string.Equals(i.Id, mediaSourceId, StringComparison.OrdinalIgnoreCase))
|
||||||
|
.ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// SetDeviceSpecificData.
|
/// SetDeviceSpecificData.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -415,6 +427,8 @@ public class MediaInfoHelper
|
|||||||
{
|
{
|
||||||
var result = await _mediaSourceManager.OpenLiveStream(request, CancellationToken.None).ConfigureAwait(false);
|
var result = await _mediaSourceManager.OpenLiveStream(request, CancellationToken.None).ConfigureAwait(false);
|
||||||
|
|
||||||
|
RewritePublishedLiveStreamPath(result.MediaSource, httpContext.Request);
|
||||||
|
|
||||||
var profile = request.DeviceProfile;
|
var profile = request.DeviceProfile;
|
||||||
if (profile is null)
|
if (profile is null)
|
||||||
{
|
{
|
||||||
@@ -524,4 +538,90 @@ public class MediaInfoHelper
|
|||||||
|
|
||||||
return maxBitrate;
|
return maxBitrate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Rewrites a Live TV media source's <see cref="MediaSourceInfo.Path"/> to the request-appropriate published
|
||||||
|
/// URL when it points at a Jellyfin-hosted live stream buffer, so response copies never leak server-local
|
||||||
|
/// addresses. Only opened live streams are eligible. The shared instance held by
|
||||||
|
/// <see cref="IMediaSourceManager"/> is never touched by this method.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="mediaSource">The media source clone to rewrite in place.</param>
|
||||||
|
/// <param name="request">The current <see cref="HttpRequest"/>.</param>
|
||||||
|
private void RewritePublishedLiveStreamPath(MediaSourceInfo mediaSource, HttpRequest request)
|
||||||
|
{
|
||||||
|
// Opened live streams always carry a LiveStreamId; this excludes pre-open and plugin/remote sources.
|
||||||
|
if (string.IsNullOrEmpty(mediaSource.LiveStreamId))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var baseUrl = _serverConfigurationManager.GetNetworkConfiguration().BaseUrl;
|
||||||
|
var publishedPath = GetPublishedLiveStreamPath(_appHost.GetSmartApiUrl(request), mediaSource.Path, mediaSource.Protocol, baseUrl);
|
||||||
|
|
||||||
|
if (publishedPath is not null)
|
||||||
|
{
|
||||||
|
mediaSource.Path = publishedPath;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mediaSource.Path is not null && mediaSource.Path.Contains("/LiveTv/LiveStreamFiles/", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
_logger.LogDebug("Not rewriting live stream path for media source {MediaSourceId}: the local path did not resolve under the request's smart API URL/BaseUrl", mediaSource.Id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Resolves a Jellyfin-hosted Live TV buffer path to its request-appropriate published equivalent.
|
||||||
|
/// Returns null when the path isn't a Jellyfin-hosted <c>/LiveTv/LiveStreamFiles/</c> HTTP URL.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="smartApiUrl">The request-appropriate base URL, as returned by <see cref="IServerApplicationHost.GetSmartApiUrl(HttpRequest)"/>.</param>
|
||||||
|
/// <param name="localPath">The media source's local (LAN-access) path, as built from <see cref="IServerApplicationHost.GetApiUrlForLocalAccess"/>.</param>
|
||||||
|
/// <param name="protocol">The media source's protocol.</param>
|
||||||
|
/// <param name="baseUrl">The server's configured BaseUrl, if any.</param>
|
||||||
|
/// <returns>The published path, or null if the local path should be left unchanged.</returns>
|
||||||
|
internal static string? GetPublishedLiveStreamPath(
|
||||||
|
string smartApiUrl,
|
||||||
|
string? localPath,
|
||||||
|
MediaProtocol protocol,
|
||||||
|
string baseUrl)
|
||||||
|
{
|
||||||
|
if (protocol != MediaProtocol.Http
|
||||||
|
|| !Uri.TryCreate(localPath, UriKind.Absolute, out var localUri))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
var relativePath = localUri.PathAndQuery;
|
||||||
|
if (!string.IsNullOrEmpty(baseUrl))
|
||||||
|
{
|
||||||
|
var basePrefix = baseUrl + "/";
|
||||||
|
if (!relativePath.StartsWith(basePrefix, StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
relativePath = relativePath[baseUrl.Length..];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!relativePath.StartsWith("/LiveTv/LiveStreamFiles/", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
var prefix = smartApiUrl.TrimEnd('/');
|
||||||
|
if (!string.IsNullOrEmpty(baseUrl))
|
||||||
|
{
|
||||||
|
var includesBaseUrl = Uri.TryCreate(prefix, UriKind.Absolute, out var publishedUri)
|
||||||
|
&& Uri.UnescapeDataString(publishedUri.AbsolutePath)
|
||||||
|
.TrimEnd('/')
|
||||||
|
.EndsWith(baseUrl, StringComparison.OrdinalIgnoreCase);
|
||||||
|
|
||||||
|
if (!includesBaseUrl)
|
||||||
|
{
|
||||||
|
prefix += baseUrl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return prefix + relativePath;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ using System.Security.Claims;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Jellyfin.Api.Constants;
|
using Jellyfin.Api.Constants;
|
||||||
using Jellyfin.Api.Extensions;
|
using Jellyfin.Api.Extensions;
|
||||||
using Jellyfin.Data.Enums;
|
|
||||||
using Jellyfin.Database.Implementations.Entities;
|
using Jellyfin.Database.Implementations.Entities;
|
||||||
using Jellyfin.Database.Implementations.Enums;
|
using Jellyfin.Database.Implementations.Enums;
|
||||||
using Jellyfin.Extensions;
|
using Jellyfin.Extensions;
|
||||||
@@ -31,15 +30,16 @@ public static class RequestHelpers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="sortBy">Sort By. Comma delimited string.</param>
|
/// <param name="sortBy">Sort By. Comma delimited string.</param>
|
||||||
/// <param name="requestedSortOrder">Sort Order. Comma delimited string.</param>
|
/// <param name="requestedSortOrder">Sort Order. Comma delimited string.</param>
|
||||||
|
/// <typeparam name="TSortBy">The type of the sort by field.</typeparam>
|
||||||
/// <returns>Order By.</returns>
|
/// <returns>Order By.</returns>
|
||||||
public static (ItemSortBy, SortOrder)[] GetOrderBy(IReadOnlyList<ItemSortBy> sortBy, IReadOnlyList<SortOrder> requestedSortOrder)
|
public static (TSortBy, SortOrder)[] GetOrderBy<TSortBy>(IReadOnlyList<TSortBy> sortBy, IReadOnlyList<SortOrder> requestedSortOrder)
|
||||||
{
|
{
|
||||||
if (sortBy.Count == 0)
|
if (sortBy.Count == 0)
|
||||||
{
|
{
|
||||||
return Array.Empty<(ItemSortBy, SortOrder)>();
|
return Array.Empty<(TSortBy, SortOrder)>();
|
||||||
}
|
}
|
||||||
|
|
||||||
var result = new (ItemSortBy, SortOrder)[sortBy.Count];
|
var result = new (TSortBy, SortOrder)[sortBy.Count];
|
||||||
var i = 0;
|
var i = 0;
|
||||||
// Add elements which have a SortOrder specified
|
// Add elements which have a SortOrder specified
|
||||||
for (; i < requestedSortOrder.Count; i++)
|
for (; i < requestedSortOrder.Count; i++)
|
||||||
|
|||||||
@@ -144,6 +144,15 @@ public static class StreamingHelpers
|
|||||||
mediaSource = liveStreamInfo.Item1;
|
mediaSource = liveStreamInfo.Item1;
|
||||||
state.DirectStreamProvider = liveStreamInfo.Item2;
|
state.DirectStreamProvider = liveStreamInfo.Item2;
|
||||||
|
|
||||||
|
// The requested live stream is no longer open. This commonly happens when a client keeps
|
||||||
|
// polling the HLS playlist (e.g. live.m3u8) after the stream was disposed because its
|
||||||
|
// consumer count dropped to zero. GetLiveStreamWithDirectStreamProvider returns a null
|
||||||
|
// MediaSource in that case, so return 404 instead of dereferencing it below.
|
||||||
|
if (mediaSource is null)
|
||||||
|
{
|
||||||
|
throw new ResourceNotFoundException($"The live stream with id {streamingRequest.LiveStreamId} could not be found or is no longer available.");
|
||||||
|
}
|
||||||
|
|
||||||
// Cap the max bitrate when it is too high. This is usually due to ffmpeg is unable to probe the source liveTV streams' bitrate.
|
// Cap the max bitrate when it is too high. This is usually due to ffmpeg is unable to probe the source liveTV streams' bitrate.
|
||||||
if (mediaSource.FallbackMaxStreamingBitrate is not null && streamingRequest.VideoBitRate is not null)
|
if (mediaSource.FallbackMaxStreamingBitrate is not null && streamingRequest.VideoBitRate is not null)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -56,11 +56,11 @@ public class ActivityManager : IActivityManager
|
|||||||
var dbContext = await _provider.CreateDbContextAsync().ConfigureAwait(false);
|
var dbContext = await _provider.CreateDbContextAsync().ConfigureAwait(false);
|
||||||
await using (dbContext.ConfigureAwait(false))
|
await using (dbContext.ConfigureAwait(false))
|
||||||
{
|
{
|
||||||
// TODO switch to LeftJoin in .NET 10.
|
var entries = dbContext.ActivityLogs.LeftJoin(
|
||||||
var entries = from a in dbContext.ActivityLogs
|
dbContext.Users,
|
||||||
join u in dbContext.Users on a.UserId equals u.Id into ugj
|
a => a.UserId,
|
||||||
from u in ugj.DefaultIfEmpty()
|
u => u.Id,
|
||||||
select new ExpandedActivityLog { ActivityLog = a, Username = u.Username };
|
(a, u) => new ExpandedActivityLog { ActivityLog = a, Username = u == null ? null : u.Username });
|
||||||
|
|
||||||
if (query.HasUserId is not null)
|
if (query.HasUserId is not null)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -213,8 +213,10 @@ namespace Jellyfin.Server.Implementations.Devices
|
|||||||
var dbContext = await _dbProvider.CreateDbContextAsync().ConfigureAwait(false);
|
var dbContext = await _dbProvider.CreateDbContextAsync().ConfigureAwait(false);
|
||||||
await using (dbContext.ConfigureAwait(false))
|
await using (dbContext.ConfigureAwait(false))
|
||||||
{
|
{
|
||||||
dbContext.Devices.Remove(device);
|
await dbContext.Devices
|
||||||
await dbContext.SaveChangesAsync().ConfigureAwait(false);
|
.Where(d => d.Id == device.Id)
|
||||||
|
.ExecuteDeleteAsync()
|
||||||
|
.ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -39,6 +39,19 @@ public static class ExpressionExtensions
|
|||||||
return predicates.Aggregate((aggregatePredicate, nextPredicate) => aggregatePredicate.Or(nextPredicate));
|
return predicates.Aggregate((aggregatePredicate, nextPredicate) => aggregatePredicate.Or(nextPredicate));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Negates a predicate.
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T">The predicate parameter type.</typeparam>
|
||||||
|
/// <param name="predicate">The predicate expression to negate.</param>
|
||||||
|
/// <returns>A new expression representing the negation of the input predicate.</returns>
|
||||||
|
public static Expression<Func<T, bool>> Not<T>(this Expression<Func<T, bool>> predicate)
|
||||||
|
{
|
||||||
|
ArgumentNullException.ThrowIfNull(predicate);
|
||||||
|
|
||||||
|
return Expression.Lambda<Func<T, bool>>(Expression.Not(predicate.Body), predicate.Parameters);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Combines two predicates into a single predicate using a logical AND operation.
|
/// Combines two predicates into a single predicate using a logical AND operation.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -359,18 +359,39 @@ public class BackupService : IBackupService
|
|||||||
jsonSerializer.WriteStartArray();
|
jsonSerializer.WriteStartArray();
|
||||||
|
|
||||||
var set = entityType.ValueFactory().ConfigureAwait(false);
|
var set = entityType.ValueFactory().ConfigureAwait(false);
|
||||||
await foreach (var item in set.ConfigureAwait(false))
|
var enumerator = set.GetAsyncEnumerator();
|
||||||
|
await using (enumerator)
|
||||||
{
|
{
|
||||||
entities++;
|
while (true)
|
||||||
try
|
|
||||||
{
|
{
|
||||||
using var document = JsonSerializer.SerializeToDocument(item, _serializerSettings);
|
bool hasNext;
|
||||||
document.WriteTo(jsonSerializer);
|
try
|
||||||
}
|
{
|
||||||
catch (Exception ex)
|
hasNext = await enumerator.MoveNextAsync();
|
||||||
{
|
}
|
||||||
_logger.LogError(ex, "Could not load entity {Entity}", item);
|
catch (Exception ex)
|
||||||
throw;
|
{
|
||||||
|
_logger.LogError(ex, "Could not read next entity of type {Table}, the underlying data appears to be corrupt. Skipping this row and continuing backup; the affected database row should be inspected and fixed manually", entityType.SourceName);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!hasNext)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
var item = enumerator.Current;
|
||||||
|
entities++;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var document = JsonSerializer.SerializeToDocument(item, _serializerSettings);
|
||||||
|
document.WriteTo(jsonSerializer);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Could not load entity {Entity}", item);
|
||||||
|
throw;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -134,6 +134,21 @@ public static class BaseItemMapper
|
|||||||
if (dto is Video video)
|
if (dto is Video video)
|
||||||
{
|
{
|
||||||
video.PrimaryVersionId = entity.PrimaryVersionId;
|
video.PrimaryVersionId = entity.PrimaryVersionId;
|
||||||
|
|
||||||
|
// The LinkedChildren table is the source of truth for version links
|
||||||
|
if (entity.LinkedChildEntities is not null)
|
||||||
|
{
|
||||||
|
video.LinkedAlternateVersions = entity.LinkedChildEntities
|
||||||
|
// LocalAlternateVersion links belong to Video.LocalAlternateVersions, not here
|
||||||
|
.Where(e => e.ChildType == Database.Implementations.Entities.LinkedChildType.LinkedAlternateVersion)
|
||||||
|
.OrderBy(e => e.SortOrder)
|
||||||
|
.Select(e => new LinkedChild
|
||||||
|
{
|
||||||
|
ItemId = e.ChildId,
|
||||||
|
Type = (MediaBrowser.Controller.Entities.LinkedChildType)e.ChildType
|
||||||
|
})
|
||||||
|
.ToArray();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dto is IHasSeries hasSeriesName)
|
if (dto is IHasSeries hasSeriesName)
|
||||||
@@ -183,7 +198,7 @@ public static class BaseItemMapper
|
|||||||
if (dto is Folder folder)
|
if (dto is Folder folder)
|
||||||
{
|
{
|
||||||
folder.DateLastMediaAdded = entity.DateLastMediaAdded ?? DateTime.SpecifyKind(DateTime.MinValue, DateTimeKind.Utc);
|
folder.DateLastMediaAdded = entity.DateLastMediaAdded ?? DateTime.SpecifyKind(DateTime.MinValue, DateTimeKind.Utc);
|
||||||
if (entity.LinkedChildEntities is not null && entity.LinkedChildEntities.Count > 0)
|
if (entity.LinkedChildEntities is not null)
|
||||||
{
|
{
|
||||||
folder.LinkedChildren = entity.LinkedChildEntities
|
folder.LinkedChildren = entity.LinkedChildEntities
|
||||||
.OrderBy(e => e.SortOrder)
|
.OrderBy(e => e.SortOrder)
|
||||||
|
|||||||
@@ -4,9 +4,11 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Jellyfin.Data.Enums;
|
using Jellyfin.Data.Enums;
|
||||||
|
using Jellyfin.Database.Implementations;
|
||||||
using Jellyfin.Database.Implementations.Entities;
|
using Jellyfin.Database.Implementations.Entities;
|
||||||
using MediaBrowser.Controller.Entities;
|
using MediaBrowser.Controller.Entities;
|
||||||
using MediaBrowser.Model.Dto;
|
using MediaBrowser.Model.Dto;
|
||||||
|
using MediaBrowser.Model.Entities;
|
||||||
using MediaBrowser.Model.Querying;
|
using MediaBrowser.Model.Querying;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using BaseItemDto = MediaBrowser.Controller.Entities.BaseItem;
|
using BaseItemDto = MediaBrowser.Controller.Entities.BaseItem;
|
||||||
@@ -81,6 +83,40 @@ public sealed partial class BaseItemRepository
|
|||||||
_itemTypeLookup.MusicGenreTypes);
|
_itemTypeLookup.MusicGenreTypes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public IReadOnlyList<string> GetMediaStreamLanguages(InternalItemsQuery filter, MediaStreamType mediaStreamType)
|
||||||
|
{
|
||||||
|
ArgumentNullException.ThrowIfNull(filter);
|
||||||
|
|
||||||
|
using var context = _dbProvider.CreateDbContext();
|
||||||
|
|
||||||
|
return TranslateQuery(
|
||||||
|
context.BaseItems.Include(e => e.MediaStreams).Where(e => e.Id != EF.Constant(PlaceholderId)),
|
||||||
|
context,
|
||||||
|
new InternalItemsQuery(filter.User)
|
||||||
|
{
|
||||||
|
IncludeOwnedItems = filter.IncludeOwnedItems,
|
||||||
|
ExcludeItemTypes = filter.ExcludeItemTypes,
|
||||||
|
IncludeItemTypes = filter.IncludeItemTypes,
|
||||||
|
MediaTypes = filter.MediaTypes,
|
||||||
|
AncestorIds = filter.AncestorIds,
|
||||||
|
ItemIds = filter.ItemIds,
|
||||||
|
TopParentIds = filter.TopParentIds,
|
||||||
|
ParentId = filter.ParentId,
|
||||||
|
IsAiring = filter.IsAiring,
|
||||||
|
IsMovie = filter.IsMovie,
|
||||||
|
IsSports = filter.IsSports,
|
||||||
|
IsKids = filter.IsKids,
|
||||||
|
IsNews = filter.IsNews,
|
||||||
|
IsSeries = filter.IsSeries
|
||||||
|
})
|
||||||
|
.SelectMany(e => e.MediaStreams!)
|
||||||
|
.Where(e => e.StreamType == (MediaStreamTypeEntity)mediaStreamType)
|
||||||
|
.Select(s => string.IsNullOrEmpty(s.Language) ? "und" : s.Language) // und = undetermined
|
||||||
|
.Distinct()
|
||||||
|
.ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
private string[] GetItemValueNames(IReadOnlyList<ItemValueType> itemValueTypes, IReadOnlyList<string> withItemTypes, IReadOnlyList<string> excludeItemTypes)
|
private string[] GetItemValueNames(IReadOnlyList<ItemValueType> itemValueTypes, IReadOnlyList<string> withItemTypes, IReadOnlyList<string> excludeItemTypes)
|
||||||
{
|
{
|
||||||
using var context = _dbProvider.CreateDbContext();
|
using var context = _dbProvider.CreateDbContext();
|
||||||
@@ -132,21 +168,16 @@ public sealed partial class BaseItemRepository
|
|||||||
IsSeries = filter.IsSeries
|
IsSeries = filter.IsSeries
|
||||||
});
|
});
|
||||||
|
|
||||||
// Keep this as an IQueryable sub-select. Materializing to a list would inline one
|
|
||||||
// bound parameter per CleanValue and hit SQLite's variable cap on libraries with
|
|
||||||
// high-cardinality value types (e.g. tens of thousands of artists).
|
|
||||||
var matchingCleanValues = context.ItemValuesMap
|
|
||||||
.Where(ivm => itemValueTypes.Contains(ivm.ItemValue.Type))
|
|
||||||
.Join(
|
|
||||||
innerQueryFilter,
|
|
||||||
ivm => ivm.ItemId,
|
|
||||||
g => g.Id,
|
|
||||||
(ivm, g) => ivm.ItemValue.CleanValue)
|
|
||||||
.Distinct();
|
|
||||||
|
|
||||||
var innerQuery = PrepareItemQuery(context, filter)
|
var innerQuery = PrepareItemQuery(context, filter)
|
||||||
.Where(e => e.Type == returnType)
|
.Where(e => e.Type == returnType)
|
||||||
.Where(e => matchingCleanValues.Contains(e.CleanName!));
|
.Where(e => context.ItemValuesMap
|
||||||
|
.Where(ivm => itemValueTypes.Contains(ivm.ItemValue.Type) && ivm.ItemValue.CleanValue == e.CleanName)
|
||||||
|
.Join(
|
||||||
|
innerQueryFilter,
|
||||||
|
ivm => ivm.ItemId,
|
||||||
|
g => g.Id,
|
||||||
|
(ivm, g) => ivm.ItemId)
|
||||||
|
.Any());
|
||||||
|
|
||||||
var outerQueryFilter = new InternalItemsQuery(filter.User)
|
var outerQueryFilter = new InternalItemsQuery(filter.User)
|
||||||
{
|
{
|
||||||
@@ -169,32 +200,42 @@ public sealed partial class BaseItemRepository
|
|||||||
ExcludeItemIds = filter.ExcludeItemIds
|
ExcludeItemIds = filter.ExcludeItemIds
|
||||||
};
|
};
|
||||||
|
|
||||||
// Collapse rows that share a PresentationUniqueKey (e.g. alternate versions) by picking
|
// Collapse rows that share a PresentationUniqueKey (e.g. alternate versions) into one
|
||||||
// the lowest Id per group. For MusicArtist, prefer the entity from a library the user
|
// representative id per group, then materialize the representative ids once.
|
||||||
// can actually access,since the same artist can have a folder in multiple libraries.
|
|
||||||
// Keep as an IQueryable sub-select so paging is applied AFTER
|
|
||||||
// ApplyOrder runs the caller's actual sort.
|
|
||||||
var masterQuery = TranslateQuery(innerQuery, context, outerQueryFilter);
|
var masterQuery = TranslateQuery(innerQuery, context, outerQueryFilter);
|
||||||
var isMusicArtist = returnType == _itemTypeLookup.BaseItemKindNames[BaseItemKind.MusicArtist];
|
var isMusicArtist = returnType == _itemTypeLookup.BaseItemKindNames[BaseItemKind.MusicArtist];
|
||||||
var representativeIds = isMusicArtist
|
List<Guid> representativeIds;
|
||||||
? masterQuery
|
if (isMusicArtist)
|
||||||
|
{
|
||||||
|
// For MusicArtist, prefer the entity from a library the user can actually access.
|
||||||
|
// Materialize to prevent correlated per-group first-row queries which hurt performance.
|
||||||
|
var topParentIds = filter.TopParentIds;
|
||||||
|
representativeIds = masterQuery
|
||||||
|
.Select(e => new { e.Id, e.PresentationUniqueKey, e.TopParentId })
|
||||||
|
.AsEnumerable()
|
||||||
.GroupBy(e => e.PresentationUniqueKey)
|
.GroupBy(e => e.PresentationUniqueKey)
|
||||||
.Select(g => g
|
.Select(g => g
|
||||||
.OrderBy(e => filter.TopParentIds.Contains(e.TopParentId ?? Guid.Empty) ? 0 : 1)
|
.OrderBy(e => topParentIds.Contains(e.TopParentId ?? Guid.Empty) ? 0 : 1)
|
||||||
.ThenBy(e => e.Id)
|
.ThenBy(e => e.Id)
|
||||||
.First().Id)
|
.First().Id)
|
||||||
: masterQuery
|
.ToList();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
representativeIds = masterQuery
|
||||||
.GroupBy(e => e.PresentationUniqueKey)
|
.GroupBy(e => e.PresentationUniqueKey)
|
||||||
.Select(g => g.Min(e => e.Id));
|
.Select(g => g.Min(e => e.Id))
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
var result = new QueryResult<(BaseItemDto, ItemCounts?)>();
|
var result = new QueryResult<(BaseItemDto, ItemCounts?)>();
|
||||||
if (filter.EnableTotalRecordCount)
|
if (filter.EnableTotalRecordCount)
|
||||||
{
|
{
|
||||||
result.TotalRecordCount = representativeIds.Count();
|
result.TotalRecordCount = representativeIds.Count;
|
||||||
}
|
}
|
||||||
|
|
||||||
var query = ApplyNavigations(
|
var query = ApplyNavigations(
|
||||||
context.BaseItems.AsNoTracking().AsSingleQuery().Where(e => representativeIds.Contains(e.Id)),
|
context.BaseItems.AsNoTracking().AsSingleQuery().WhereOneOrMany(representativeIds, e => e.Id),
|
||||||
filter);
|
filter);
|
||||||
|
|
||||||
query = ApplyOrder(query, filter, context);
|
query = ApplyOrder(query, filter, context);
|
||||||
@@ -275,8 +316,8 @@ public sealed partial class BaseItemRepository
|
|||||||
var itemIds = itemCountQuery.Select(e => e.Id);
|
var itemIds = itemCountQuery.Select(e => e.Id);
|
||||||
|
|
||||||
// Rewrite query to avoid SelectMany on navigation properties (which requires SQL APPLY, not supported on SQLite)
|
// Rewrite query to avoid SelectMany on navigation properties (which requires SQL APPLY, not supported on SQLite)
|
||||||
// Instead, start from ItemValueMaps and join with BaseItems
|
// Instead, start from ItemValueMaps and join with BaseItems.
|
||||||
return context.ItemValuesMap
|
var rawCounts = context.ItemValuesMap
|
||||||
.Where(ivm => itemValueTypes.Contains(ivm.ItemValue.Type))
|
.Where(ivm => itemValueTypes.Contains(ivm.ItemValue.Type))
|
||||||
.Where(ivm => itemIds.Contains(ivm.ItemId))
|
.Where(ivm => itemIds.Contains(ivm.ItemId))
|
||||||
.Join(
|
.Join(
|
||||||
@@ -286,18 +327,47 @@ public sealed partial class BaseItemRepository
|
|||||||
(ivm, e) => new { CleanName = ivm.ItemValue.CleanValue, e.Type })
|
(ivm, e) => new { CleanName = ivm.ItemValue.CleanValue, e.Type })
|
||||||
.GroupBy(x => new { x.CleanName, x.Type })
|
.GroupBy(x => new { x.CleanName, x.Type })
|
||||||
.Select(g => new { g.Key.CleanName, g.Key.Type, Count = g.Count() })
|
.Select(g => new { g.Key.CleanName, g.Key.Type, Count = g.Count() })
|
||||||
.GroupBy(x => x.CleanName)
|
.AsEnumerable();
|
||||||
.ToDictionary(
|
|
||||||
g => g.Key,
|
var countsByCleanName = new Dictionary<string, ItemCounts>();
|
||||||
g => new ItemCounts
|
foreach (var group in rawCounts.GroupBy(x => x.CleanName))
|
||||||
|
{
|
||||||
|
var counts = new ItemCounts();
|
||||||
|
foreach (var row in group)
|
||||||
|
{
|
||||||
|
if (row.Type == seriesTypeName)
|
||||||
{
|
{
|
||||||
SeriesCount = g.Where(x => x.Type == seriesTypeName).Sum(x => x.Count),
|
counts.SeriesCount += row.Count;
|
||||||
EpisodeCount = g.Where(x => x.Type == episodeTypeName).Sum(x => x.Count),
|
}
|
||||||
MovieCount = g.Where(x => x.Type == movieTypeName).Sum(x => x.Count),
|
else if (row.Type == episodeTypeName)
|
||||||
AlbumCount = g.Where(x => x.Type == musicAlbumTypeName).Sum(x => x.Count),
|
{
|
||||||
ArtistCount = g.Where(x => x.Type == musicArtistTypeName).Sum(x => x.Count),
|
counts.EpisodeCount += row.Count;
|
||||||
SongCount = g.Where(x => x.Type == audioTypeName).Sum(x => x.Count),
|
}
|
||||||
TrailerCount = g.Where(x => x.Type == trailerTypeName).Sum(x => x.Count),
|
else if (row.Type == movieTypeName)
|
||||||
});
|
{
|
||||||
|
counts.MovieCount += row.Count;
|
||||||
|
}
|
||||||
|
else if (row.Type == musicAlbumTypeName)
|
||||||
|
{
|
||||||
|
counts.AlbumCount += row.Count;
|
||||||
|
}
|
||||||
|
else if (row.Type == musicArtistTypeName)
|
||||||
|
{
|
||||||
|
counts.ArtistCount += row.Count;
|
||||||
|
}
|
||||||
|
else if (row.Type == audioTypeName)
|
||||||
|
{
|
||||||
|
counts.SongCount += row.Count;
|
||||||
|
}
|
||||||
|
else if (row.Type == trailerTypeName)
|
||||||
|
{
|
||||||
|
counts.TrailerCount += row.Count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
countsByCleanName[group.Key] = counts;
|
||||||
|
}
|
||||||
|
|
||||||
|
return countsByCleanName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,11 +35,40 @@ public sealed partial class BaseItemRepository
|
|||||||
{
|
{
|
||||||
dbQuery = TranslateQuery(dbQuery, context, filter);
|
dbQuery = TranslateQuery(dbQuery, context, filter);
|
||||||
dbQuery = ApplyGroupingFilter(context, dbQuery, filter);
|
dbQuery = ApplyGroupingFilter(context, dbQuery, filter);
|
||||||
|
dbQuery = ApplyAdjacencyFilter(context, dbQuery, filter);
|
||||||
dbQuery = ApplyQueryPaging(dbQuery, filter);
|
dbQuery = ApplyQueryPaging(dbQuery, filter);
|
||||||
dbQuery = ApplyNavigations(dbQuery, filter);
|
dbQuery = ApplyNavigations(dbQuery, filter);
|
||||||
return dbQuery;
|
return dbQuery;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Trims an ordered query down to the AdjacentTo item and its immediate neighbours.
|
||||||
|
/// </summary>
|
||||||
|
private IQueryable<BaseItemEntity> ApplyAdjacencyFilter(JellyfinDbContext context, IQueryable<BaseItemEntity> dbQuery, InternalItemsQuery filter)
|
||||||
|
{
|
||||||
|
if (filter.AdjacentTo.IsNullOrEmpty())
|
||||||
|
{
|
||||||
|
return dbQuery;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Adjacency is relative to the result set and the order the query asked for, so the ids have
|
||||||
|
// to be read back in that order.
|
||||||
|
var orderedIds = dbQuery.Select(e => e.Id).ToList();
|
||||||
|
var index = orderedIds.IndexOf(filter.AdjacentTo.Value);
|
||||||
|
if (index < 0)
|
||||||
|
{
|
||||||
|
// The item isn't part of this result set, so it has no neighbours in it either.
|
||||||
|
return dbQuery.Take(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
var start = Math.Max(index - 1, 0);
|
||||||
|
var adjacentIds = orderedIds.GetRange(start, Math.Min(index + 2, orderedIds.Count) - start);
|
||||||
|
|
||||||
|
var adjacentQuery = context.BaseItems.AsNoTracking().AsSingleQuery().Where(e => adjacentIds.Contains(e.Id));
|
||||||
|
|
||||||
|
return ApplyOrder(adjacentQuery, filter, context);
|
||||||
|
}
|
||||||
|
|
||||||
private IQueryable<BaseItemEntity> ApplyQueryPaging(IQueryable<BaseItemEntity> dbQuery, InternalItemsQuery filter)
|
private IQueryable<BaseItemEntity> ApplyQueryPaging(IQueryable<BaseItemEntity> dbQuery, InternalItemsQuery filter)
|
||||||
{
|
{
|
||||||
if (filter.Limit.HasValue || filter.StartIndex.HasValue)
|
if (filter.Limit.HasValue || filter.StartIndex.HasValue)
|
||||||
@@ -62,18 +91,21 @@ public sealed partial class BaseItemRepository
|
|||||||
|
|
||||||
private IQueryable<BaseItemEntity> ApplyGroupingFilter(JellyfinDbContext context, IQueryable<BaseItemEntity> dbQuery, InternalItemsQuery filter)
|
private IQueryable<BaseItemEntity> ApplyGroupingFilter(JellyfinDbContext context, IQueryable<BaseItemEntity> dbQuery, InternalItemsQuery filter)
|
||||||
{
|
{
|
||||||
// Collapse duplicates sharing a presentation key (e.g. alternate versions) by picking
|
// Collapse duplicates sharing a presentation key (e.g. alternate versions), preferring the
|
||||||
// the min Id per group. Keep the grouped ids as an IQueryable sub-select; materializing
|
// primary version (PrimaryVersionId is null) so detail pages and actions target it instead
|
||||||
|
// of an arbitrary alternate. Keep the grouped ids as an IQueryable sub-select; materializing
|
||||||
// to a List would inline one bound parameter per id and hit SQLite's variable cap.
|
// to a List would inline one bound parameter per id and hit SQLite's variable cap.
|
||||||
var enableGroupByPresentationUniqueKey = EnableGroupByPresentationUniqueKey(filter);
|
var enableGroupByPresentationUniqueKey = EnableGroupByPresentationUniqueKey(filter);
|
||||||
if (enableGroupByPresentationUniqueKey && filter.GroupBySeriesPresentationUniqueKey)
|
if (enableGroupByPresentationUniqueKey && filter.GroupBySeriesPresentationUniqueKey)
|
||||||
{
|
{
|
||||||
var groupedIds = dbQuery.GroupBy(e => new { e.PresentationUniqueKey, e.SeriesPresentationUniqueKey }).Select(e => e.Min(x => x.Id));
|
var groupedIds = dbQuery.GroupBy(e => new { e.PresentationUniqueKey, e.SeriesPresentationUniqueKey })
|
||||||
|
.Select(g => g.Where(e => e.PrimaryVersionId == null).Min(e => (Guid?)e.Id) ?? g.Min(e => (Guid?)e.Id));
|
||||||
dbQuery = context.BaseItems.AsNoTracking().Where(e => groupedIds.Contains(e.Id));
|
dbQuery = context.BaseItems.AsNoTracking().Where(e => groupedIds.Contains(e.Id));
|
||||||
}
|
}
|
||||||
else if (enableGroupByPresentationUniqueKey)
|
else if (enableGroupByPresentationUniqueKey)
|
||||||
{
|
{
|
||||||
var groupedIds = dbQuery.GroupBy(e => e.PresentationUniqueKey).Select(e => e.Min(x => x.Id));
|
var groupedIds = dbQuery.GroupBy(e => e.PresentationUniqueKey)
|
||||||
|
.Select(g => g.Where(e => e.PrimaryVersionId == null).Min(e => (Guid?)e.Id) ?? g.Min(e => (Guid?)e.Id));
|
||||||
dbQuery = context.BaseItems.AsNoTracking().Where(e => groupedIds.Contains(e.Id));
|
dbQuery = context.BaseItems.AsNoTracking().Where(e => groupedIds.Contains(e.Id));
|
||||||
}
|
}
|
||||||
else if (filter.GroupBySeriesPresentationUniqueKey)
|
else if (filter.GroupBySeriesPresentationUniqueKey)
|
||||||
@@ -241,8 +273,8 @@ public sealed partial class BaseItemRepository
|
|||||||
dbQuery = dbQuery.Include(e => e.Images);
|
dbQuery = dbQuery.Include(e => e.Images);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Include LinkedChildEntities for container types and videos that use them
|
// Include LinkedChildEntities for container types and videos that use them (BoxSet, Playlist,
|
||||||
// (BoxSet, Playlist, CollectionFolder for manual linking; Video, Movie for alternate versions).
|
// CollectionFolder for manual linking; every video type for alternate versions).
|
||||||
// When IncludeItemTypes is empty (any type may be returned), always include them to ensure
|
// When IncludeItemTypes is empty (any type may be returned), always include them to ensure
|
||||||
// LinkedChildren are loaded before items are saved back, preventing accidental deletion.
|
// LinkedChildren are loaded before items are saved back, preventing accidental deletion.
|
||||||
var linkedChildTypes = new[]
|
var linkedChildTypes = new[]
|
||||||
@@ -251,7 +283,10 @@ public sealed partial class BaseItemRepository
|
|||||||
BaseItemKind.Playlist,
|
BaseItemKind.Playlist,
|
||||||
BaseItemKind.CollectionFolder,
|
BaseItemKind.CollectionFolder,
|
||||||
BaseItemKind.Video,
|
BaseItemKind.Video,
|
||||||
BaseItemKind.Movie
|
BaseItemKind.Movie,
|
||||||
|
BaseItemKind.Episode,
|
||||||
|
BaseItemKind.MusicVideo,
|
||||||
|
BaseItemKind.Trailer
|
||||||
};
|
};
|
||||||
if (filter.IncludeItemTypes.Length == 0 || filter.IncludeItemTypes.Any(linkedChildTypes.Contains))
|
if (filter.IncludeItemTypes.Length == 0 || filter.IncludeItemTypes.Any(linkedChildTypes.Contains))
|
||||||
{
|
{
|
||||||
@@ -387,7 +422,8 @@ public sealed partial class BaseItemRepository
|
|||||||
|
|
||||||
var baseQuery = context.BaseItems
|
var baseQuery = context.BaseItems
|
||||||
.AsNoTracking()
|
.AsNoTracking()
|
||||||
.Where(b => allDescendantIds.Contains(b.Id) && !b.IsFolder && !b.IsVirtualItem);
|
.Where(b => allDescendantIds.Contains(b.Id))
|
||||||
|
.Where(DescendantQueryHelper.IsCountableLeaf);
|
||||||
|
|
||||||
return ApplyAccessFiltering(context, baseQuery, filter);
|
return ApplyAccessFiltering(context, baseQuery, filter);
|
||||||
}
|
}
|
||||||
@@ -444,6 +480,7 @@ public sealed partial class BaseItemRepository
|
|||||||
if (filter.IncludeInheritedTags.Length > 0)
|
if (filter.IncludeInheritedTags.Length > 0)
|
||||||
{
|
{
|
||||||
var includeTags = filter.IncludeInheritedTags.Select(e => e.GetCleanValue()).ToArray();
|
var includeTags = filter.IncludeInheritedTags.Select(e => e.GetCleanValue()).ToArray();
|
||||||
|
var personTypeName = _itemTypeLookup.BaseItemKindNames[BaseItemKind.Person];
|
||||||
var allowedTagItemIds = context.ItemValuesMap
|
var allowedTagItemIds = context.ItemValuesMap
|
||||||
.Where(f => f.ItemValue.Type == ItemValueType.Tags && includeTags.Contains(f.ItemValue.CleanValue))
|
.Where(f => f.ItemValue.Type == ItemValueType.Tags && includeTags.Contains(f.ItemValue.CleanValue))
|
||||||
.Select(f => f.ItemId);
|
.Select(f => f.ItemId);
|
||||||
@@ -452,7 +489,10 @@ public sealed partial class BaseItemRepository
|
|||||||
allowedTagItemIds.Contains(e.Id)
|
allowedTagItemIds.Contains(e.Id)
|
||||||
|| (e.SeriesId.HasValue && allowedTagItemIds.Contains(e.SeriesId.Value))
|
|| (e.SeriesId.HasValue && allowedTagItemIds.Contains(e.SeriesId.Value))
|
||||||
|| e.Parents!.Any(p => allowedTagItemIds.Contains(p.ParentItemId))
|
|| e.Parents!.Any(p => allowedTagItemIds.Contains(p.ParentItemId))
|
||||||
|| (e.TopParentId.HasValue && allowedTagItemIds.Contains(e.TopParentId.Value)));
|
|| (e.TopParentId.HasValue && allowedTagItemIds.Contains(e.TopParentId.Value))
|
||||||
|
|
||||||
|
// People don't carry the tags of the media they appear in and would never match
|
||||||
|
|| e.Type == personTypeName);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Exclude alternate versions (have PrimaryVersionId set) and owned non-extra items.
|
// Exclude alternate versions (have PrimaryVersionId set) and owned non-extra items.
|
||||||
@@ -496,62 +536,31 @@ public sealed partial class BaseItemRepository
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public IQueryable<Guid> GetFullyPlayedFolderIdsQuery(JellyfinDbContext context, IQueryable<Guid> folderIds, User user)
|
public IQueryable<BaseItemEntity> GetAccessFilteredLeafItemsQuery(JellyfinDbContext context, User user, bool includeOwnedItems = false)
|
||||||
{
|
{
|
||||||
ArgumentNullException.ThrowIfNull(context);
|
ArgumentNullException.ThrowIfNull(context);
|
||||||
ArgumentNullException.ThrowIfNull(folderIds);
|
|
||||||
ArgumentNullException.ThrowIfNull(user);
|
ArgumentNullException.ThrowIfNull(user);
|
||||||
|
|
||||||
var filter = new InternalItemsQuery(user);
|
|
||||||
var userId = user.Id;
|
|
||||||
|
|
||||||
var leafItems = context.BaseItems
|
var leafItems = context.BaseItems
|
||||||
.AsNoTracking()
|
.AsNoTracking()
|
||||||
.Where(b => !b.IsFolder && !b.IsVirtualItem);
|
.Where(DescendantQueryHelper.IsCountableLeaf);
|
||||||
leafItems = ApplyAccessFiltering(context, leafItems, filter);
|
|
||||||
|
|
||||||
var playedLeafItems = leafItems
|
return ApplyAccessFiltering(context, leafItems, new InternalItemsQuery(user) { IncludeOwnedItems = includeOwnedItems });
|
||||||
.Select(b => new { b.Id, Played = b.UserData!.Any(ud => ud.UserId == userId && ud.Played) });
|
}
|
||||||
|
|
||||||
var ancestorLeaves = context.AncestorIds
|
/// <inheritdoc />
|
||||||
.Where(a => folderIds.Contains(a.ParentItemId))
|
public Expression<Func<BaseItemEntity, bool>> BuildHasDescendantFilter(JellyfinDbContext context, IQueryable<BaseItemEntity> descendants)
|
||||||
.Join(
|
{
|
||||||
playedLeafItems,
|
ArgumentNullException.ThrowIfNull(context);
|
||||||
a => a.ItemId,
|
ArgumentNullException.ThrowIfNull(descendants);
|
||||||
b => b.Id,
|
|
||||||
(a, b) => new { FolderId = a.ParentItemId, b.Id, b.Played });
|
|
||||||
|
|
||||||
var linkedLeaves = context.LinkedChildren
|
// Descendants are reachable through the ancestor chain and - for BoxSets and Playlists - as
|
||||||
.Where(lc => folderIds.Contains(lc.ParentId))
|
// linked children, which can themselves be folders contributing their own descendants.
|
||||||
.Join(
|
// Every step is a correlated index seek, so only the rows the outer query keeps are visited
|
||||||
playedLeafItems,
|
// and a folder is left as soon as its first matching descendant is found.
|
||||||
lc => lc.ChildId,
|
return e => context.AncestorIds.Any(a => a.ParentItemId == e.Id && descendants.Any(d => d.Id == a.ItemId))
|
||||||
b => b.Id,
|
|| context.LinkedChildren.Any(lc => lc.ParentId == e.Id
|
||||||
(lc, b) => new { FolderId = lc.ParentId, b.Id, b.Played });
|
&& (descendants.Any(d => d.Id == lc.ChildId)
|
||||||
|
|| context.AncestorIds.Any(a => a.ParentItemId == lc.ChildId && descendants.Any(d => d.Id == a.ItemId))));
|
||||||
var linkedFolderLeaves = context.LinkedChildren
|
|
||||||
.Where(lc => folderIds.Contains(lc.ParentId))
|
|
||||||
.Join(
|
|
||||||
context.BaseItems.Where(b => b.IsFolder),
|
|
||||||
lc => lc.ChildId,
|
|
||||||
b => b.Id,
|
|
||||||
(lc, b) => new { lc.ParentId, FolderChildId = b.Id })
|
|
||||||
.Join(
|
|
||||||
context.AncestorIds,
|
|
||||||
x => x.FolderChildId,
|
|
||||||
a => a.ParentItemId,
|
|
||||||
(x, a) => new { x.ParentId, DescendantId = a.ItemId })
|
|
||||||
.Join(
|
|
||||||
playedLeafItems,
|
|
||||||
x => x.DescendantId,
|
|
||||||
b => b.Id,
|
|
||||||
(x, b) => new { FolderId = x.ParentId, b.Id, b.Played });
|
|
||||||
|
|
||||||
return ancestorLeaves
|
|
||||||
.Union(linkedLeaves)
|
|
||||||
.Union(linkedFolderLeaves)
|
|
||||||
.GroupBy(x => x.FolderId)
|
|
||||||
.Where(g => g.Select(x => x.Id).Distinct().Count() == g.Where(x => x.Played).Select(x => x.Id).Distinct().Count())
|
|
||||||
.Select(g => g.Key);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ public sealed partial class BaseItemRepository
|
|||||||
|
|
||||||
dbQuery = TranslateQuery(dbQuery, context, filter);
|
dbQuery = TranslateQuery(dbQuery, context, filter);
|
||||||
dbQuery = ApplyGroupingFilter(context, dbQuery, filter);
|
dbQuery = ApplyGroupingFilter(context, dbQuery, filter);
|
||||||
|
dbQuery = ApplyAdjacencyFilter(context, dbQuery, filter);
|
||||||
|
|
||||||
if (filter.EnableTotalRecordCount)
|
if (filter.EnableTotalRecordCount)
|
||||||
{
|
{
|
||||||
@@ -75,6 +76,7 @@ public sealed partial class BaseItemRepository
|
|||||||
dbQuery = TranslateQuery(dbQuery, context, filter);
|
dbQuery = TranslateQuery(dbQuery, context, filter);
|
||||||
|
|
||||||
dbQuery = ApplyGroupingFilter(context, dbQuery, filter);
|
dbQuery = ApplyGroupingFilter(context, dbQuery, filter);
|
||||||
|
dbQuery = ApplyAdjacencyFilter(context, dbQuery, filter);
|
||||||
dbQuery = ApplyQueryPaging(dbQuery, filter);
|
dbQuery = ApplyQueryPaging(dbQuery, filter);
|
||||||
|
|
||||||
var hasRandomSort = filter.OrderBy.Any(e => e.OrderBy == ItemSortBy.Random);
|
var hasRandomSort = filter.OrderBy.Any(e => e.OrderBy == ItemSortBy.Random);
|
||||||
@@ -126,38 +128,54 @@ public sealed partial class BaseItemRepository
|
|||||||
|
|
||||||
if (collectionType is CollectionType.movies)
|
if (collectionType is CollectionType.movies)
|
||||||
{
|
{
|
||||||
// Group by PresentationUniqueKey, pick the newest item per group.
|
// Pick, per PresentationUniqueKey, the newest item; return the newest `limit` of those.
|
||||||
var topGroupItems = baseQuery
|
// Build up until limit by streaming through results and deduplicating on the fly.
|
||||||
|
var orderedIds = baseQuery
|
||||||
.Where(e => e.PresentationUniqueKey != null)
|
.Where(e => e.PresentationUniqueKey != null)
|
||||||
.GroupBy(e => e.PresentationUniqueKey)
|
.OrderByDescending(e => e.DateCreated)
|
||||||
.Select(g => new
|
.ThenByDescending(e => e.Id)
|
||||||
{
|
.Select(e => new { e.Id, e.PresentationUniqueKey });
|
||||||
MaxDate = g.Max(e => e.DateCreated),
|
|
||||||
FirstId = g.OrderByDescending(e => e.DateCreated).ThenByDescending(e => e.Id).Select(e => e.Id).First()
|
|
||||||
})
|
|
||||||
.OrderByDescending(g => g.MaxDate);
|
|
||||||
|
|
||||||
var firstIdsQuery = filter.Limit.HasValue
|
// DistinctBy and Take are lazy, so enumeration stops as soon as limit distinct keys are read.
|
||||||
? topGroupItems.Take(filter.Limit.Value).Select(g => g.FirstId)
|
var firstIds = orderedIds
|
||||||
: topGroupItems.Select(g => g.FirstId);
|
.AsEnumerable()
|
||||||
|
.DistinctBy(row => row.PresentationUniqueKey)
|
||||||
|
.Select(row => row.Id)
|
||||||
|
.Take(limit ?? int.MaxValue)
|
||||||
|
.ToList();
|
||||||
|
|
||||||
return LoadLatestByIds(context, firstIdsQuery, filter);
|
return LoadLatestByIds(context, firstIds, filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Albums whose Id is the parent of any track matching the user's filter.
|
|
||||||
var albumIdsWithMatchingTrack = context.AncestorIds
|
|
||||||
.Join(baseQuery, ai => ai.ItemId, t => t.Id, (ai, _) => ai.ParentItemId);
|
|
||||||
|
|
||||||
var musicAlbumTypeName = _itemTypeLookup.BaseItemKindNames[BaseItemKind.MusicAlbum]!;
|
var musicAlbumTypeName = _itemTypeLookup.BaseItemKindNames[BaseItemKind.MusicAlbum]!;
|
||||||
var topAlbumsQuery = context.BaseItems.AsNoTracking()
|
IQueryable<BaseItemEntity> topAlbumsQuery;
|
||||||
.Where(album => album.Type == musicAlbumTypeName)
|
|
||||||
.Where(album => albumIdsWithMatchingTrack.Contains(album.Id))
|
// When the query is scoped to whole libraries, read the newest albums directly by their own TopParentId.
|
||||||
|
if (filter.TopParentIds.Length > 0)
|
||||||
|
{
|
||||||
|
topAlbumsQuery = context.BaseItems.AsNoTracking()
|
||||||
|
.Where(album => album.Type == musicAlbumTypeName
|
||||||
|
&& !album.IsVirtualItem
|
||||||
|
&& album.TopParentId.HasValue)
|
||||||
|
.WhereOneOrMany(filter.TopParentIds, album => album.TopParentId!.Value);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Fallback (e.g. AncestorIds-scoped callers): albums that are the parent of a matching track.
|
||||||
|
var albumIdsWithMatchingTrack = context.AncestorIds
|
||||||
|
.Join(baseQuery, ai => ai.ItemId, t => t.Id, (ai, _) => ai.ParentItemId);
|
||||||
|
topAlbumsQuery = context.BaseItems.AsNoTracking()
|
||||||
|
.Where(album => album.Type == musicAlbumTypeName)
|
||||||
|
.Where(album => albumIdsWithMatchingTrack.Contains(album.Id));
|
||||||
|
}
|
||||||
|
|
||||||
|
var orderedAlbums = topAlbumsQuery
|
||||||
.OrderByDescending(album => album.DateCreated)
|
.OrderByDescending(album => album.DateCreated)
|
||||||
.ThenByDescending(album => album.Id);
|
.ThenByDescending(album => album.Id);
|
||||||
|
|
||||||
var albumIdsQuery = filter.Limit.HasValue
|
var albumIdsQuery = limit.HasValue
|
||||||
? topAlbumsQuery.Take(filter.Limit.Value).Select(a => a.Id)
|
? orderedAlbums.Take(limit.Value).Select(a => a.Id)
|
||||||
: topAlbumsQuery.Select(a => a.Id);
|
: orderedAlbums.Select(a => a.Id);
|
||||||
|
|
||||||
return LoadLatestByIds(context, albumIdsQuery, filter);
|
return LoadLatestByIds(context, albumIdsQuery, filter);
|
||||||
}
|
}
|
||||||
@@ -181,6 +199,29 @@ public sealed partial class BaseItemRepository
|
|||||||
.ToArray()!;
|
.ToArray()!;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private IReadOnlyList<BaseItemDto> LoadLatestByIds(
|
||||||
|
JellyfinDbContext context,
|
||||||
|
List<Guid> ids,
|
||||||
|
InternalItemsQuery filter)
|
||||||
|
{
|
||||||
|
if (ids.Count == 0)
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
var itemsQuery = ApplyNavigations(
|
||||||
|
context.BaseItems.AsNoTracking().WhereOneOrMany(ids, e => e.Id),
|
||||||
|
filter);
|
||||||
|
|
||||||
|
return itemsQuery
|
||||||
|
.OrderByDescending(e => e.DateCreated)
|
||||||
|
.ThenByDescending(e => e.Id)
|
||||||
|
.AsEnumerable()
|
||||||
|
.Select(w => DeserializeBaseItem(w, filter.SkipDeserialization))
|
||||||
|
.Where(dto => dto != null)
|
||||||
|
.ToArray()!;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the latest TV show items with smart Season/Series container selection.
|
/// Gets the latest TV show items with smart Season/Series container selection.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -31,6 +31,10 @@ public sealed partial class BaseItemRepository
|
|||||||
private static readonly string TmdbProviderName = MetadataProvider.Tmdb.ToString().ToLowerInvariant();
|
private static readonly string TmdbProviderName = MetadataProvider.Tmdb.ToString().ToLowerInvariant();
|
||||||
private static readonly string TvdbProviderName = MetadataProvider.Tvdb.ToString().ToLowerInvariant();
|
private static readonly string TvdbProviderName = MetadataProvider.Tvdb.ToString().ToLowerInvariant();
|
||||||
|
|
||||||
|
// A fresh expression per access: EF rejects a query tree that reuses one lambda parameter
|
||||||
|
// instance across several lambdas, and this filter is combined into a tree more than once.
|
||||||
|
private static Expression<Func<BaseItemEntity, bool>> IsFolderFilter => e => e.IsFolder;
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public IQueryable<BaseItemEntity> TranslateQuery(
|
public IQueryable<BaseItemEntity> TranslateQuery(
|
||||||
IQueryable<BaseItemEntity> baseQuery,
|
IQueryable<BaseItemEntity> baseQuery,
|
||||||
@@ -434,127 +438,113 @@ public sealed partial class BaseItemRepository
|
|||||||
|
|
||||||
if (filter.IsLiked.HasValue)
|
if (filter.IsLiked.HasValue)
|
||||||
{
|
{
|
||||||
var isLiked = filter.IsLiked.Value;
|
var likedIds = context.UserData
|
||||||
baseQuery = baseQuery.Where(e => e.UserData!.Any(ud => ud.UserId == filter.User!.Id && ud.Rating >= UserItemData.MinLikeValue) == isLiked);
|
.Where(ud => ud.UserId == filter.User!.Id && ud.Rating >= UserItemData.MinLikeValue)
|
||||||
|
.Select(ud => ud.ItemId);
|
||||||
|
|
||||||
|
baseQuery = filter.IsLiked.Value
|
||||||
|
? baseQuery.Where(e => likedIds.Contains(e.Id))
|
||||||
|
: baseQuery.Where(e => !likedIds.Contains(e.Id));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (filter.IsFavoriteOrLiked.HasValue)
|
if (filter.IsFavoriteOrLiked.HasValue || filter.IsFavorite.HasValue)
|
||||||
{
|
{
|
||||||
var isFavoriteOrLiked = filter.IsFavoriteOrLiked.Value;
|
var favoriteIds = context.UserData
|
||||||
baseQuery = baseQuery.Where(e => e.UserData!.Any(ud => ud.UserId == filter.User!.Id && ud.IsFavorite) == isFavoriteOrLiked);
|
.Where(ud => ud.UserId == filter.User!.Id && ud.IsFavorite)
|
||||||
}
|
.Select(ud => ud.ItemId);
|
||||||
|
|
||||||
if (filter.IsFavorite.HasValue)
|
if (filter.IsFavoriteOrLiked.HasValue)
|
||||||
{
|
{
|
||||||
var isFavorite = filter.IsFavorite.Value;
|
baseQuery = filter.IsFavoriteOrLiked.Value
|
||||||
baseQuery = baseQuery.Where(e => e.UserData!.Any(ud => ud.UserId == filter.User!.Id && ud.IsFavorite) == isFavorite);
|
? baseQuery.Where(e => favoriteIds.Contains(e.Id))
|
||||||
|
: baseQuery.Where(e => !favoriteIds.Contains(e.Id));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (filter.IsFavorite.HasValue)
|
||||||
|
{
|
||||||
|
baseQuery = filter.IsFavorite.Value
|
||||||
|
? baseQuery.Where(e => favoriteIds.Contains(e.Id))
|
||||||
|
: baseQuery.Where(e => !favoriteIds.Contains(e.Id));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (filter.IsPlayed.HasValue)
|
if (filter.IsPlayed.HasValue)
|
||||||
{
|
{
|
||||||
var hasSeries = filter.IncludeItemTypes.Contains(BaseItemKind.Series);
|
var userId = filter.User!.Id;
|
||||||
var hasBoxSet = filter.IncludeItemTypes.Contains(BaseItemKind.BoxSet);
|
|
||||||
|
|
||||||
if (hasSeries || hasBoxSet)
|
// Leaf items carry their own played state.
|
||||||
{
|
var playedItemIds = context.UserData
|
||||||
var userId = filter.User!.Id;
|
.Where(ud => ud.UserId == userId && ud.Played)
|
||||||
var isPlayed = filter.IsPlayed.Value;
|
.Select(ud => ud.ItemId);
|
||||||
var seriesTypeName = _itemTypeLookup.BaseItemKindNames[BaseItemKind.Series];
|
|
||||||
var boxSetTypeName = _itemTypeLookup.BaseItemKindNames[BaseItemKind.BoxSet];
|
|
||||||
|
|
||||||
// Series: played = at least one episode AND all episodes played; unplayed = otherwise.
|
// Folders (Series, Seasons, BoxSets, albums, ...) have none and count as played once no
|
||||||
IQueryable<Guid> playedSeriesIds = hasSeries
|
// descendant is left unplayed, matching what the DTO reports for them. This has to key off
|
||||||
? context.BaseItems
|
// the item itself rather than off the requested item types: tag and collection listings mix
|
||||||
.AsNoTracking()
|
// folders and leaf items in a single query.
|
||||||
.Where(e => !e.IsFolder && !e.IsVirtualItem && e.SeriesId.HasValue)
|
var unplayedLeafItems = GetAccessFilteredLeafItemsQuery(context, filter.User!)
|
||||||
.GroupBy(e => e.SeriesId!.Value)
|
.Where(e => !e.UserData!.Any(ud => ud.UserId == userId && ud.Played));
|
||||||
.Where(g => !g.Any(e => !e.UserData!.Any(ud => ud.UserId == userId && ud.Played)))
|
|
||||||
.Select(g => g.Key)
|
|
||||||
: Enumerable.Empty<Guid>().AsQueryable();
|
|
||||||
|
|
||||||
// BoxSet: played = all children played.
|
var isPlayedFilter = IsFolderFilter.And(BuildHasDescendantFilter(context, unplayedLeafItems).Not())
|
||||||
IQueryable<Guid> playedBoxSetIds = hasBoxSet
|
.Or(IsFolderFilter.Not().And(e => playedItemIds.Contains(e.Id)));
|
||||||
? GetFullyPlayedFolderIdsQuery(
|
|
||||||
context,
|
|
||||||
baseQuery.Where(e => e.Type == boxSetTypeName).Select(e => e.Id),
|
|
||||||
filter.User!)
|
|
||||||
: Enumerable.Empty<Guid>().AsQueryable();
|
|
||||||
|
|
||||||
// Non-folder items: check UserData directly
|
baseQuery = baseQuery.Where(filter.IsPlayed.Value ? isPlayedFilter : isPlayedFilter.Not());
|
||||||
var playedItemIds = context.UserData
|
|
||||||
.Where(ud => ud.UserId == userId && ud.Played)
|
|
||||||
.Select(ud => ud.ItemId);
|
|
||||||
|
|
||||||
if (isPlayed)
|
|
||||||
{
|
|
||||||
baseQuery = baseQuery.Where(e =>
|
|
||||||
(e.Type == seriesTypeName && playedSeriesIds.Contains(e.Id))
|
|
||||||
|| (e.Type == boxSetTypeName && playedBoxSetIds.Contains(e.Id))
|
|
||||||
|| (e.Type != seriesTypeName && e.Type != boxSetTypeName && playedItemIds.Contains(e.Id)));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
baseQuery = baseQuery.Where(e =>
|
|
||||||
(e.Type == seriesTypeName && !playedSeriesIds.Contains(e.Id))
|
|
||||||
|| (e.Type == boxSetTypeName && !playedBoxSetIds.Contains(e.Id))
|
|
||||||
|| (e.Type != seriesTypeName && e.Type != boxSetTypeName && !playedItemIds.Contains(e.Id)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var playedItemIds = context.UserData
|
|
||||||
.Where(ud => ud.UserId == filter.User!.Id && ud.Played)
|
|
||||||
.Select(ud => ud.ItemId);
|
|
||||||
var isPlayedItem = filter.IsPlayed.Value;
|
|
||||||
baseQuery = baseQuery.Where(e => playedItemIds.Contains(e.Id) == isPlayedItem);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (filter.IsResumable.HasValue)
|
if (filter.IsResumable.HasValue)
|
||||||
{
|
{
|
||||||
var hasSeries = filter.IncludeItemTypes.Contains(BaseItemKind.Series);
|
var userId = filter.User!.Id;
|
||||||
|
var isResumable = filter.IsResumable.Value;
|
||||||
|
|
||||||
if (hasSeries)
|
// In-progress user data rows; alternate versions track their own progress.
|
||||||
|
var inProgress = context.UserData
|
||||||
|
.Where(ud => ud.UserId == userId && ud.PlaybackPositionTicks > 0);
|
||||||
|
|
||||||
|
// Folders are resumable when a descendant is in progress, or when they hold both played and
|
||||||
|
// unplayed descendants (partially watched). Alternate versions keep their own progress, so
|
||||||
|
// they count towards the in-progress check but not towards the played/unplayed one.
|
||||||
|
var leafItems = GetAccessFilteredLeafItemsQuery(context, filter.User!);
|
||||||
|
var inProgressLeafItems = GetAccessFilteredLeafItemsQuery(context, filter.User!, includeOwnedItems: true)
|
||||||
|
.Where(e => e.UserData!.Any(ud => ud.UserId == userId && ud.PlaybackPositionTicks > 0));
|
||||||
|
|
||||||
|
var folderResumableFilter = BuildHasDescendantFilter(context, inProgressLeafItems)
|
||||||
|
.Or(BuildHasDescendantFilter(context, leafItems.Where(e => e.UserData!.Any(ud => ud.UserId == userId && ud.Played)))
|
||||||
|
.And(BuildHasDescendantFilter(context, leafItems.Where(e => !e.UserData!.Any(ud => ud.UserId == userId && ud.Played)))));
|
||||||
|
|
||||||
|
if (isResumable)
|
||||||
{
|
{
|
||||||
var userId = filter.User!.Id;
|
// Resume queries surface the version that was actually played, which may be an alternate.
|
||||||
var seriesTypeName = _itemTypeLookup.BaseItemKindNames[BaseItemKind.Series];
|
// Match each version on its own progress rather than coalescing onto the primary.
|
||||||
var isResumable = filter.IsResumable.Value;
|
var inProgressIds = inProgress.Select(ud => ud.ItemId);
|
||||||
|
|
||||||
// Aggregate per series in a single GROUP BY pass, instead of three full scans.
|
baseQuery = baseQuery.Where(IsFolderFilter.And(folderResumableFilter)
|
||||||
var seriesEpisodeStats = context.BaseItems
|
.Or(IsFolderFilter.Not().And(e => inProgressIds.Contains(e.Id))));
|
||||||
.AsNoTracking()
|
|
||||||
.Where(e => !e.IsFolder && !e.IsVirtualItem && e.SeriesId.HasValue)
|
|
||||||
.GroupBy(e => e.SeriesId!.Value)
|
|
||||||
.Select(g => new
|
|
||||||
{
|
|
||||||
SeriesId = g.Key,
|
|
||||||
HasInProgress = g.Any(e => e.UserData!.Any(ud => ud.UserId == userId && ud.PlaybackPositionTicks > 0)),
|
|
||||||
HasPlayed = g.Any(e => e.UserData!.Any(ud => ud.UserId == userId && ud.Played)),
|
|
||||||
HasUnplayed = g.Any(e => !e.UserData!.Any(ud => ud.UserId == userId && ud.Played))
|
|
||||||
});
|
|
||||||
|
|
||||||
// A series is resumable if it has an in-progress episode,
|
// When several versions of the same item are in progress, keep only the most recently played one, use id as tiebreaker.
|
||||||
// or if it has both played and unplayed episodes (partially watched).
|
// Only in-progress siblings can eliminate a candidate: a version without progress has a NULL max LastPlayedDate,
|
||||||
var resumableSeriesIds = seriesEpisodeStats
|
// which is never greater and never ties. Restricting the sibling scan to the in-progress set keeps this bounded by
|
||||||
.Where(s => s.HasInProgress || (s.HasPlayed && s.HasUnplayed))
|
// the user's Continue Watching count instead of forcing a full BaseItems scan (COALESCE keys are non-indexable) per row.
|
||||||
.Select(s => s.SeriesId);
|
// Items in no version group at all have no sibling that could eliminate them, so short-circuit the scan for those.
|
||||||
|
baseQuery = baseQuery.Where(e => e.IsFolder
|
||||||
// Non-series items: resumable if PlaybackPositionTicks > 0
|
|| (e.PrimaryVersionId == null && !context.BaseItems.Any(a => a.PrimaryVersionId == e.Id))
|
||||||
var resumableItemIds = context.UserData
|
|| !context.BaseItems
|
||||||
.Where(ud => ud.UserId == userId && ud.PlaybackPositionTicks > 0)
|
.Where(s => s.Id != e.Id
|
||||||
.Select(ud => ud.ItemId);
|
&& inProgressIds.Contains(s.Id)
|
||||||
|
&& (s.PrimaryVersionId ?? s.Id) == (e.PrimaryVersionId ?? e.Id))
|
||||||
baseQuery = baseQuery.Where(e =>
|
.Any(s =>
|
||||||
(e.Type == seriesTypeName && resumableSeriesIds.Contains(e.Id) == isResumable)
|
inProgress.Where(su => su.ItemId == s.Id).Max(su => su.LastPlayedDate)
|
||||||
|| (e.Type != seriesTypeName && resumableItemIds.Contains(e.Id) == isResumable));
|
> inProgress.Where(eu => eu.ItemId == e.Id).Max(eu => eu.LastPlayedDate)
|
||||||
|
|| (inProgress.Where(su => su.ItemId == s.Id).Max(su => su.LastPlayedDate)
|
||||||
|
== inProgress.Where(eu => eu.ItemId == e.Id).Max(eu => eu.LastPlayedDate)
|
||||||
|
&& s.Id.CompareTo(e.Id) < 0)));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var resumableItemIds = context.UserData
|
// Not-resumable queries operate on primaries only.
|
||||||
.Where(ud => ud.UserId == filter.User!.Id && ud.PlaybackPositionTicks > 0)
|
var resumableMovieIds = inProgress
|
||||||
.Select(ud => ud.ItemId);
|
.Join(context.BaseItems, ud => ud.ItemId, bi => bi.Id, (ud, bi) => bi.PrimaryVersionId ?? bi.Id);
|
||||||
var isResumable = filter.IsResumable.Value;
|
|
||||||
baseQuery = baseQuery.Where(e => resumableItemIds.Contains(e.Id) == isResumable);
|
baseQuery = baseQuery.Where(IsFolderFilter.And(folderResumableFilter.Not())
|
||||||
|
.Or(IsFolderFilter.Not().And(e => !resumableMovieIds.Contains(e.Id))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -741,10 +731,13 @@ public sealed partial class BaseItemRepository
|
|||||||
}
|
}
|
||||||
else if (filter.OwnerIds.Length == 0 && filter.ExtraTypes.Length == 0 && !filter.IncludeOwnedItems)
|
else if (filter.OwnerIds.Length == 0 && filter.ExtraTypes.Length == 0 && !filter.IncludeOwnedItems)
|
||||||
{
|
{
|
||||||
// Exclude alternate versions and owned non-extra items from general queries.
|
// Exclude owned non-extra items from general queries.
|
||||||
// Alternate versions have PrimaryVersionId set (pointing to their primary).
|
|
||||||
// Extras (trailers, etc.) have OwnerId set but also have ExtraType set - keep those.
|
// Extras (trailers, etc.) have OwnerId set but also have ExtraType set - keep those.
|
||||||
baseQuery = baseQuery.Where(e => e.PrimaryVersionId == null && (e.OwnerId == null || e.ExtraType != null));
|
// Alternate versions (PrimaryVersionId set) are normally excluded too, but resume queries
|
||||||
|
// keep them so the actually-played version can surface instead of collapsing onto the primary.
|
||||||
|
baseQuery = filter.IsResumable == true
|
||||||
|
? baseQuery.Where(e => e.OwnerId == null || e.ExtraType != null)
|
||||||
|
: baseQuery.Where(e => e.PrimaryVersionId == null && (e.OwnerId == null || e.ExtraType != null));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (filter.OwnerIds.Length > 0)
|
if (filter.OwnerIds.Length > 0)
|
||||||
@@ -1059,6 +1052,7 @@ public sealed partial class BaseItemRepository
|
|||||||
{
|
{
|
||||||
var includeTags = filter.IncludeInheritedTags.Select(e => e.GetCleanValue()).ToArray();
|
var includeTags = filter.IncludeInheritedTags.Select(e => e.GetCleanValue()).ToArray();
|
||||||
var isPlaylistOnlyQuery = includeTypes.Length == 1 && includeTypes.FirstOrDefault() == BaseItemKind.Playlist;
|
var isPlaylistOnlyQuery = includeTypes.Length == 1 && includeTypes.FirstOrDefault() == BaseItemKind.Playlist;
|
||||||
|
var personTypeName = _itemTypeLookup.BaseItemKindNames[BaseItemKind.Person];
|
||||||
var allowedTagItemIds = context.ItemValuesMap
|
var allowedTagItemIds = context.ItemValuesMap
|
||||||
.Where(f => f.ItemValue.Type == ItemValueType.Tags && includeTags.Contains(f.ItemValue.CleanValue))
|
.Where(f => f.ItemValue.Type == ItemValueType.Tags && includeTags.Contains(f.ItemValue.CleanValue))
|
||||||
.Select(f => f.ItemId);
|
.Select(f => f.ItemId);
|
||||||
@@ -1069,6 +1063,9 @@ public sealed partial class BaseItemRepository
|
|||||||
|| e.Parents!.Any(p => allowedTagItemIds.Contains(p.ParentItemId))
|
|| e.Parents!.Any(p => allowedTagItemIds.Contains(p.ParentItemId))
|
||||||
|| (e.TopParentId.HasValue && allowedTagItemIds.Contains(e.TopParentId.Value))
|
|| (e.TopParentId.HasValue && allowedTagItemIds.Contains(e.TopParentId.Value))
|
||||||
|
|
||||||
|
// People don't carry the tags of the media they appear in and would never match
|
||||||
|
|| e.Type == personTypeName
|
||||||
|
|
||||||
// A playlist should be accessible to its owner regardless of allowed tags
|
// A playlist should be accessible to its owner regardless of allowed tags
|
||||||
|| (isPlaylistOnlyQuery && e.Data!.Contains($"OwnerUserId\":\"{filter.User!.Id:N}\"")));
|
|| (isPlaylistOnlyQuery && e.Data!.Contains($"OwnerUserId\":\"{filter.User!.Id:N}\"")));
|
||||||
}
|
}
|
||||||
@@ -1116,16 +1113,23 @@ public sealed partial class BaseItemRepository
|
|||||||
: baseQuery.WhereNeitherItemNorDescendantMatches(context, isPlaceHolder);
|
: baseQuery.WhereNeitherItemNorDescendantMatches(context, isPlaceHolder);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// An extra is owned by the single version of an item it is named after, so an extra on any
|
||||||
|
// version counts for the item itself
|
||||||
|
IQueryable<Guid> WithPrimaryVersions(IQueryable<Guid> ownerIds)
|
||||||
|
=> ownerIds.Concat(context.BaseItems
|
||||||
|
.Where(version => version.PrimaryVersionId != null && ownerIds.Contains(version.Id))
|
||||||
|
.Select(version => version.PrimaryVersionId!.Value));
|
||||||
|
|
||||||
if (filter.HasSpecialFeature.HasValue)
|
if (filter.HasSpecialFeature.HasValue)
|
||||||
{
|
{
|
||||||
var itemsWithExtras = context.BaseItems
|
var itemsWithExtras = WithPrimaryVersions(context.BaseItems
|
||||||
.Where(extra => extra.OwnerId != null
|
.Where(extra => extra.OwnerId != null
|
||||||
&& extra.ExtraType != null
|
&& extra.ExtraType != null
|
||||||
&& extra.ExtraType != BaseItemExtraType.Unknown
|
&& extra.ExtraType != BaseItemExtraType.Unknown
|
||||||
&& extra.ExtraType != BaseItemExtraType.Trailer
|
&& extra.ExtraType != BaseItemExtraType.Trailer
|
||||||
&& extra.ExtraType != BaseItemExtraType.ThemeSong
|
&& extra.ExtraType != BaseItemExtraType.ThemeSong
|
||||||
&& extra.ExtraType != BaseItemExtraType.ThemeVideo)
|
&& extra.ExtraType != BaseItemExtraType.ThemeVideo)
|
||||||
.Select(extra => extra.OwnerId!.Value)
|
.Select(extra => extra.OwnerId!.Value))
|
||||||
.Distinct();
|
.Distinct();
|
||||||
|
|
||||||
Expression<Func<BaseItemEntity, bool>> hasExtras = e => itemsWithExtras.Contains(e.Id);
|
Expression<Func<BaseItemEntity, bool>> hasExtras = e => itemsWithExtras.Contains(e.Id);
|
||||||
@@ -1137,9 +1141,9 @@ public sealed partial class BaseItemRepository
|
|||||||
|
|
||||||
if (filter.HasTrailer.HasValue)
|
if (filter.HasTrailer.HasValue)
|
||||||
{
|
{
|
||||||
var trailerOwnerIds = context.BaseItems
|
var trailerOwnerIds = WithPrimaryVersions(context.BaseItems
|
||||||
.Where(extra => extra.ExtraType == BaseItemExtraType.Trailer && extra.OwnerId != null)
|
.Where(extra => extra.ExtraType == BaseItemExtraType.Trailer && extra.OwnerId != null)
|
||||||
.Select(extra => extra.OwnerId!.Value);
|
.Select(extra => extra.OwnerId!.Value));
|
||||||
|
|
||||||
Expression<Func<BaseItemEntity, bool>> hasTrailer = e => trailerOwnerIds.Contains(e.Id);
|
Expression<Func<BaseItemEntity, bool>> hasTrailer = e => trailerOwnerIds.Contains(e.Id);
|
||||||
|
|
||||||
@@ -1150,9 +1154,9 @@ public sealed partial class BaseItemRepository
|
|||||||
|
|
||||||
if (filter.HasThemeSong.HasValue)
|
if (filter.HasThemeSong.HasValue)
|
||||||
{
|
{
|
||||||
var themeSongOwnerIds = context.BaseItems
|
var themeSongOwnerIds = WithPrimaryVersions(context.BaseItems
|
||||||
.Where(extra => extra.ExtraType == BaseItemExtraType.ThemeSong && extra.OwnerId != null)
|
.Where(extra => extra.ExtraType == BaseItemExtraType.ThemeSong && extra.OwnerId != null)
|
||||||
.Select(extra => extra.OwnerId!.Value);
|
.Select(extra => extra.OwnerId!.Value));
|
||||||
|
|
||||||
Expression<Func<BaseItemEntity, bool>> hasThemeSong = e => themeSongOwnerIds.Contains(e.Id);
|
Expression<Func<BaseItemEntity, bool>> hasThemeSong = e => themeSongOwnerIds.Contains(e.Id);
|
||||||
|
|
||||||
@@ -1163,9 +1167,9 @@ public sealed partial class BaseItemRepository
|
|||||||
|
|
||||||
if (filter.HasThemeVideo.HasValue)
|
if (filter.HasThemeVideo.HasValue)
|
||||||
{
|
{
|
||||||
var themeVideoOwnerIds = context.BaseItems
|
var themeVideoOwnerIds = WithPrimaryVersions(context.BaseItems
|
||||||
.Where(extra => extra.ExtraType == BaseItemExtraType.ThemeVideo && extra.OwnerId != null)
|
.Where(extra => extra.ExtraType == BaseItemExtraType.ThemeVideo && extra.OwnerId != null)
|
||||||
.Select(extra => extra.OwnerId!.Value);
|
.Select(extra => extra.OwnerId!.Value));
|
||||||
|
|
||||||
Expression<Func<BaseItemEntity, bool>> hasThemeVideo = e => themeVideoOwnerIds.Contains(e.Id);
|
Expression<Func<BaseItemEntity, bool>> hasThemeVideo = e => themeVideoOwnerIds.Contains(e.Id);
|
||||||
|
|
||||||
@@ -1192,33 +1196,6 @@ public sealed partial class BaseItemRepository
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (filter.AdjacentTo.HasValue && !filter.AdjacentTo.Value.IsEmpty())
|
|
||||||
{
|
|
||||||
var adjacentToId = filter.AdjacentTo.Value;
|
|
||||||
var targetItem = context.BaseItems.Where(e => e.Id == adjacentToId).Select(e => new { e.SortName, e.Id }).FirstOrDefault();
|
|
||||||
if (targetItem is not null)
|
|
||||||
{
|
|
||||||
var targetSortName = targetItem.SortName ?? string.Empty;
|
|
||||||
|
|
||||||
// Fetch both prev and next adjacent items in a single query using Concat (UNION ALL).
|
|
||||||
var adjacentIds = context.BaseItems
|
|
||||||
.Where(e => string.Compare(e.SortName, targetSortName) < 0)
|
|
||||||
.OrderByDescending(e => e.SortName)
|
|
||||||
.Select(e => e.Id)
|
|
||||||
.Take(1)
|
|
||||||
.Concat(
|
|
||||||
context.BaseItems
|
|
||||||
.Where(e => string.Compare(e.SortName, targetSortName) > 0)
|
|
||||||
.OrderBy(e => e.SortName)
|
|
||||||
.Select(e => e.Id)
|
|
||||||
.Take(1))
|
|
||||||
.ToList();
|
|
||||||
|
|
||||||
adjacentIds.Add(adjacentToId);
|
|
||||||
baseQuery = baseQuery.Where(e => adjacentIds.Contains(e.Id));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return baseQuery;
|
return baseQuery;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -167,6 +167,14 @@ public sealed partial class BaseItemRepository
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Resume queries surface the actually-played version (which may be an alternate sharing the
|
||||||
|
// primary's presentation key). The resumable filter already keeps one version per group, so
|
||||||
|
// presentation-key grouping must not collapse the surfaced version back onto the primary.
|
||||||
|
if (query.IsResumable == true)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (query.GroupBySeriesPresentationUniqueKey)
|
if (query.GroupBySeriesPresentationUniqueKey)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -141,32 +141,32 @@ public class ItemCountService : IItemCountService
|
|||||||
switch (kind)
|
switch (kind)
|
||||||
{
|
{
|
||||||
case BaseItemKind.Person:
|
case BaseItemKind.Person:
|
||||||
baseQuery = context.PeopleBaseItemMap
|
baseQuery = ItemsById(context, context.PeopleBaseItemMap
|
||||||
.AsNoTracking()
|
.AsNoTracking()
|
||||||
.Where(m => m.People.Name == item.Name)
|
.Where(m => m.People.Name == item.Name)
|
||||||
.Select(m => m.Item);
|
.Select(m => m.ItemId));
|
||||||
break;
|
break;
|
||||||
case BaseItemKind.MusicArtist:
|
case BaseItemKind.MusicArtist:
|
||||||
baseQuery = context.ItemValuesMap
|
baseQuery = ItemsById(context, context.ItemValuesMap
|
||||||
.AsNoTracking()
|
.AsNoTracking()
|
||||||
.Where(ivm => ivm.ItemValue.CleanValue == item.CleanName
|
.Where(ivm => ivm.ItemValue.CleanValue == item.CleanName
|
||||||
&& (ivm.ItemValue.Type == ItemValueType.Artist || ivm.ItemValue.Type == ItemValueType.AlbumArtist))
|
&& (ivm.ItemValue.Type == ItemValueType.Artist || ivm.ItemValue.Type == ItemValueType.AlbumArtist))
|
||||||
.Select(ivm => ivm.Item);
|
.Select(ivm => ivm.ItemId));
|
||||||
break;
|
break;
|
||||||
case BaseItemKind.Genre:
|
case BaseItemKind.Genre:
|
||||||
case BaseItemKind.MusicGenre:
|
case BaseItemKind.MusicGenre:
|
||||||
baseQuery = context.ItemValuesMap
|
baseQuery = ItemsById(context, context.ItemValuesMap
|
||||||
.AsNoTracking()
|
.AsNoTracking()
|
||||||
.Where(ivm => ivm.ItemValue.CleanValue == item.CleanName
|
.Where(ivm => ivm.ItemValue.CleanValue == item.CleanName
|
||||||
&& ivm.ItemValue.Type == ItemValueType.Genre)
|
&& ivm.ItemValue.Type == ItemValueType.Genre)
|
||||||
.Select(ivm => ivm.Item);
|
.Select(ivm => ivm.ItemId));
|
||||||
break;
|
break;
|
||||||
case BaseItemKind.Studio:
|
case BaseItemKind.Studio:
|
||||||
baseQuery = context.ItemValuesMap
|
baseQuery = ItemsById(context, context.ItemValuesMap
|
||||||
.AsNoTracking()
|
.AsNoTracking()
|
||||||
.Where(ivm => ivm.ItemValue.CleanValue == item.CleanName
|
.Where(ivm => ivm.ItemValue.CleanValue == item.CleanName
|
||||||
&& ivm.ItemValue.Type == ItemValueType.Studios)
|
&& ivm.ItemValue.Type == ItemValueType.Studios)
|
||||||
.Select(ivm => ivm.Item);
|
.Select(ivm => ivm.ItemId));
|
||||||
break;
|
break;
|
||||||
case BaseItemKind.Year:
|
case BaseItemKind.Year:
|
||||||
if (int.TryParse(item.Name, NumberStyles.Integer, CultureInfo.InvariantCulture, out var year))
|
if (int.TryParse(item.Name, NumberStyles.Integer, CultureInfo.InvariantCulture, out var year))
|
||||||
@@ -254,6 +254,9 @@ public class ItemCountService : IItemCountService
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static IQueryable<BaseItemEntity> ItemsById(JellyfinDbContext context, IQueryable<Guid> itemIds)
|
||||||
|
=> context.BaseItems.AsNoTracking().Where(e => itemIds.Contains(e.Id));
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public int GetPlayedCount(InternalItemsQuery filter, Guid ancestorId)
|
public int GetPlayedCount(InternalItemsQuery filter, Guid ancestorId)
|
||||||
{
|
{
|
||||||
@@ -293,7 +296,8 @@ public class ItemCountService : IItemCountService
|
|||||||
|
|
||||||
var allDescendantIds = DescendantQueryHelper.GetAllDescendantIds(dbContext, parentId);
|
var allDescendantIds = DescendantQueryHelper.GetAllDescendantIds(dbContext, parentId);
|
||||||
var baseQuery = dbContext.BaseItems
|
var baseQuery = dbContext.BaseItems
|
||||||
.Where(b => allDescendantIds.Contains(b.Id) && !b.IsFolder && !b.IsVirtualItem);
|
.Where(b => allDescendantIds.Contains(b.Id))
|
||||||
|
.Where(DescendantQueryHelper.IsCountableLeaf);
|
||||||
baseQuery = _queryHelpers.ApplyAccessFiltering(dbContext, baseQuery, filter);
|
baseQuery = _queryHelpers.ApplyAccessFiltering(dbContext, baseQuery, filter);
|
||||||
|
|
||||||
return GetPlayedAndTotalCountFromQuery(baseQuery, filter.User.Id);
|
return GetPlayedAndTotalCountFromQuery(baseQuery, filter.User.Id);
|
||||||
@@ -354,7 +358,7 @@ public class ItemCountService : IItemCountService
|
|||||||
var userId = user.Id;
|
var userId = user.Id;
|
||||||
|
|
||||||
var leafItems = dbContext.BaseItems
|
var leafItems = dbContext.BaseItems
|
||||||
.Where(b => !b.IsFolder && !b.IsVirtualItem);
|
.Where(DescendantQueryHelper.IsCountableLeaf);
|
||||||
leafItems = _queryHelpers.ApplyAccessFiltering(dbContext, leafItems, filter);
|
leafItems = _queryHelpers.ApplyAccessFiltering(dbContext, leafItems, filter);
|
||||||
|
|
||||||
var playedLeafItems = leafItems
|
var playedLeafItems = leafItems
|
||||||
|
|||||||
@@ -428,106 +428,144 @@ public class ItemPersistenceService : IItemPersistenceService
|
|||||||
|
|
||||||
foreach (var item in tuples)
|
foreach (var item in tuples)
|
||||||
{
|
{
|
||||||
if (item.Item is Folder folder)
|
// A container that was never hydrated cannot be used to rewrite its links: its empty
|
||||||
|
// array means "unknown", so clearing the stored rows would silently empty the item.
|
||||||
|
if (item.Item is Folder { LinkedChildrenLoaded: false })
|
||||||
{
|
{
|
||||||
var existingLinkedChildren = allLinkedChildrenByParent.GetValueOrDefault(item.Item.Id)?.ToList() ?? new List<LinkedChildEntity>();
|
continue;
|
||||||
if (folder.LinkedChildren.Length > 0)
|
}
|
||||||
{
|
|
||||||
#pragma warning disable CS0618 // Type or member is obsolete - legacy path resolution for old data
|
if (item.Item is Folder or Video
|
||||||
var pathsToResolve = folder.LinkedChildren
|
&& allLinkedChildrenByParent.TryGetValue(item.Item.Id, out var existingLinks)
|
||||||
.Where(lc => (!lc.ItemId.HasValue || lc.ItemId.Value.IsEmpty()) && !string.IsNullOrEmpty(lc.Path))
|
&& existingLinks.Count > 0)
|
||||||
.Select(lc => lc.Path)
|
{
|
||||||
.Distinct()
|
// A video only owns its alternate version links; any other link on that parent is
|
||||||
|
// written by the folder branch below and must survive.
|
||||||
|
var staleLinks = item.Item is Folder
|
||||||
|
? existingLinks
|
||||||
|
: existingLinks
|
||||||
|
.Where(e => e.ChildType is DbLinkedChildType.LocalAlternateVersion or DbLinkedChildType.LinkedAlternateVersion)
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
var pathToIdMap = pathsToResolve.Count > 0
|
if (staleLinks.Count > 0)
|
||||||
? context.BaseItems
|
{
|
||||||
.Where(e => e.Path != null && pathsToResolve.Contains(e.Path))
|
context.LinkedChildren.RemoveRange(staleLinks);
|
||||||
.Select(e => new { e.Path, e.Id })
|
}
|
||||||
.GroupBy(e => e.Path!)
|
}
|
||||||
.ToDictionary(g => g.Key, g => g.First().Id)
|
}
|
||||||
: [];
|
|
||||||
|
|
||||||
var resolvedChildren = new List<(LinkedChild Child, Guid ChildId)>();
|
context.SaveChanges();
|
||||||
foreach (var linkedChild in folder.LinkedChildren)
|
|
||||||
|
// A LinkedChild's ItemId is only a cache.
|
||||||
|
var cachedChildIds = tuples
|
||||||
|
.Select(t => t.Item)
|
||||||
|
.OfType<Folder>()
|
||||||
|
.Where(f => f.LinkedChildrenLoaded)
|
||||||
|
.SelectMany(f => f.LinkedChildren)
|
||||||
|
.Where(lc => lc.ItemId.HasValue && !lc.ItemId.Value.IsEmpty())
|
||||||
|
.Select(lc => lc.ItemId!.Value)
|
||||||
|
.Distinct()
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
var knownChildIds = cachedChildIds.Count > 0
|
||||||
|
? context.BaseItems
|
||||||
|
.WhereOneOrMany(cachedChildIds, e => e.Id)
|
||||||
|
.Select(e => e.Id)
|
||||||
|
.ToHashSet()
|
||||||
|
: [];
|
||||||
|
|
||||||
|
foreach (var item in tuples)
|
||||||
|
{
|
||||||
|
if (item.Item is Folder { LinkedChildrenLoaded: true } folder && folder.LinkedChildren.Length > 0)
|
||||||
|
{
|
||||||
|
#pragma warning disable CS0618 // Type or member is obsolete - legacy path resolution for old data
|
||||||
|
var pathsToResolve = folder.LinkedChildren
|
||||||
|
.Where(lc => !string.IsNullOrEmpty(lc.Path)
|
||||||
|
&& (!lc.ItemId.HasValue || lc.ItemId.Value.IsEmpty() || !knownChildIds.Contains(lc.ItemId.Value)))
|
||||||
|
.Select(lc => lc.Path)
|
||||||
|
.Distinct()
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
var pathToIdMap = pathsToResolve.Count > 0
|
||||||
|
? context.BaseItems
|
||||||
|
.Where(e => e.Path != null && pathsToResolve.Contains(e.Path))
|
||||||
|
.Select(e => new { e.Path, e.Id })
|
||||||
|
.GroupBy(e => e.Path!)
|
||||||
|
.ToDictionary(g => g.Key, g => g.First().Id)
|
||||||
|
: [];
|
||||||
|
|
||||||
|
var resolvedChildren = new List<(LinkedChild Child, Guid ChildId)>();
|
||||||
|
foreach (var linkedChild in folder.LinkedChildren)
|
||||||
|
{
|
||||||
|
var childItemId = linkedChild.ItemId;
|
||||||
|
if (!childItemId.HasValue || childItemId.Value.IsEmpty() || !knownChildIds.Contains(childItemId.Value))
|
||||||
{
|
{
|
||||||
var childItemId = linkedChild.ItemId;
|
if (!string.IsNullOrEmpty(linkedChild.Path) && pathToIdMap.TryGetValue(linkedChild.Path, out var resolvedId))
|
||||||
if (!childItemId.HasValue || childItemId.Value.IsEmpty())
|
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty(linkedChild.Path) && pathToIdMap.TryGetValue(linkedChild.Path, out var resolvedId))
|
childItemId = resolvedId;
|
||||||
{
|
|
||||||
childItemId = resolvedId;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#pragma warning restore CS0618
|
else if (Guid.TryParse(linkedChild.LibraryItemId, out var libraryItemId) && !libraryItemId.IsEmpty())
|
||||||
|
|
||||||
if (childItemId.HasValue && !childItemId.Value.IsEmpty())
|
|
||||||
{
|
{
|
||||||
resolvedChildren.Add((linkedChild, childItemId.Value));
|
childItemId = libraryItemId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#pragma warning restore CS0618
|
||||||
|
|
||||||
|
if (childItemId.HasValue && !childItemId.Value.IsEmpty())
|
||||||
|
{
|
||||||
|
resolvedChildren.Add((linkedChild, childItemId.Value));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Playlists may legitimately contain the same item multiple times (e.g. a song repeated
|
||||||
|
// in an .m3u file). Every other container type keeps a single entry per child.
|
||||||
|
var isPlaylist = folder is Playlist;
|
||||||
|
if (!isPlaylist)
|
||||||
|
{
|
||||||
resolvedChildren = resolvedChildren
|
resolvedChildren = resolvedChildren
|
||||||
.GroupBy(c => c.ChildId)
|
.GroupBy(c => c.ChildId)
|
||||||
.Select(g => g.Last())
|
.Select(g => g.Last())
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
var childIdsToCheck = resolvedChildren.Select(c => c.ChildId).ToList();
|
|
||||||
var existingChildIds = childIdsToCheck.Count > 0
|
|
||||||
? context.BaseItems
|
|
||||||
.Where(e => childIdsToCheck.Contains(e.Id))
|
|
||||||
.Select(e => e.Id)
|
|
||||||
.ToHashSet()
|
|
||||||
: [];
|
|
||||||
|
|
||||||
var isPlaylist = folder is Playlist;
|
|
||||||
var sortOrder = 0;
|
|
||||||
foreach (var (linkedChild, childId) in resolvedChildren)
|
|
||||||
{
|
|
||||||
if (!existingChildIds.Contains(childId))
|
|
||||||
{
|
|
||||||
_logger.LogWarning(
|
|
||||||
"Skipping LinkedChild for parent {ParentName} ({ParentId}): child item {ChildId} does not exist in database",
|
|
||||||
item.Item.Name,
|
|
||||||
item.Item.Id,
|
|
||||||
childId);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
var existingLink = existingLinkedChildren.FirstOrDefault(e => e.ChildId == childId);
|
|
||||||
if (existingLink is null)
|
|
||||||
{
|
|
||||||
context.LinkedChildren.Add(new LinkedChildEntity()
|
|
||||||
{
|
|
||||||
ParentId = item.Item.Id,
|
|
||||||
ChildId = childId,
|
|
||||||
ChildType = (DbLinkedChildType)linkedChild.Type,
|
|
||||||
SortOrder = isPlaylist ? sortOrder : null
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
existingLink.SortOrder = isPlaylist ? sortOrder : null;
|
|
||||||
existingLink.ChildType = (DbLinkedChildType)linkedChild.Type;
|
|
||||||
existingLinkedChildren.Remove(existingLink);
|
|
||||||
}
|
|
||||||
|
|
||||||
sortOrder++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (existingLinkedChildren.Count > 0)
|
var childIdsToCheck = resolvedChildren.Select(c => c.ChildId).Distinct().ToList();
|
||||||
|
var existingChildIds = childIdsToCheck.Count > 0
|
||||||
|
? context.BaseItems
|
||||||
|
.Where(e => childIdsToCheck.Contains(e.Id))
|
||||||
|
.Select(e => e.Id)
|
||||||
|
.ToHashSet()
|
||||||
|
: [];
|
||||||
|
|
||||||
|
var sortOrder = 0;
|
||||||
|
foreach (var (linkedChild, childId) in resolvedChildren)
|
||||||
{
|
{
|
||||||
context.LinkedChildren.RemoveRange(existingLinkedChildren);
|
if (!existingChildIds.Contains(childId))
|
||||||
|
{
|
||||||
|
#pragma warning disable CS0618 // Type or member is obsolete - legacy path is logged for diagnostics
|
||||||
|
_logger.LogWarning(
|
||||||
|
"Skipping LinkedChild for parent {ParentName} ({ParentId}): child item {ChildId} (path {ChildPath}) does not exist in database",
|
||||||
|
item.Item.Name,
|
||||||
|
item.Item.Id,
|
||||||
|
childId,
|
||||||
|
linkedChild.Path ?? "unknown");
|
||||||
|
#pragma warning restore CS0618
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
context.LinkedChildren.Add(new LinkedChildEntity()
|
||||||
|
{
|
||||||
|
ParentId = item.Item.Id,
|
||||||
|
ChildId = childId,
|
||||||
|
ChildType = (DbLinkedChildType)linkedChild.Type,
|
||||||
|
SortOrder = sortOrder
|
||||||
|
});
|
||||||
|
|
||||||
|
sortOrder++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item.Item is Video video)
|
if (item.Item is Video video)
|
||||||
{
|
{
|
||||||
var existingLinkedChildren = (allLinkedChildrenByParent.GetValueOrDefault(video.Id) ?? new List<LinkedChildEntity>())
|
|
||||||
.Where(e => (int)e.ChildType == 2 || (int)e.ChildType == 3)
|
|
||||||
.ToList();
|
|
||||||
|
|
||||||
var newLinkedChildren = new List<(Guid ChildId, LinkedChildType Type)>();
|
var newLinkedChildren = new List<(Guid ChildId, LinkedChildType Type)>();
|
||||||
|
|
||||||
if (video.LocalAlternateVersions.Length > 0)
|
if (video.LocalAlternateVersions.Length > 0)
|
||||||
@@ -577,7 +615,7 @@ public class ItemPersistenceService : IItemPersistenceService
|
|||||||
.ToHashSet()
|
.ToHashSet()
|
||||||
: [];
|
: [];
|
||||||
|
|
||||||
int sortOrder = 0;
|
var sortOrder = 0;
|
||||||
foreach (var (childId, childType) in newLinkedChildren)
|
foreach (var (childId, childType) in newLinkedChildren)
|
||||||
{
|
{
|
||||||
if (!existingChildIds.Contains(childId))
|
if (!existingChildIds.Contains(childId))
|
||||||
@@ -590,36 +628,27 @@ public class ItemPersistenceService : IItemPersistenceService
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
var existingLink = existingLinkedChildren.FirstOrDefault(e => e.ChildId == childId);
|
context.LinkedChildren.Add(new LinkedChildEntity
|
||||||
if (existingLink is null)
|
|
||||||
{
|
{
|
||||||
context.LinkedChildren.Add(new LinkedChildEntity
|
ParentId = video.Id,
|
||||||
{
|
ChildId = childId,
|
||||||
ParentId = video.Id,
|
ChildType = (DbLinkedChildType)childType,
|
||||||
ChildId = childId,
|
SortOrder = sortOrder
|
||||||
ChildType = (DbLinkedChildType)childType,
|
});
|
||||||
SortOrder = sortOrder
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
existingLink.ChildType = (DbLinkedChildType)childType;
|
|
||||||
existingLink.SortOrder = sortOrder;
|
|
||||||
existingLinkedChildren.Remove(existingLink);
|
|
||||||
}
|
|
||||||
|
|
||||||
sortOrder++;
|
sortOrder++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (existingLinkedChildren.Count > 0)
|
// A previously-linked LocalAlternateVersion that is no longer present becomes orphaned;
|
||||||
|
var previousLinkedChildren = allLinkedChildrenByParent.GetValueOrDefault(video.Id);
|
||||||
|
if (previousLinkedChildren is { Count: > 0 })
|
||||||
{
|
{
|
||||||
var orphanedLocalVersionIds = existingLinkedChildren
|
var newChildIds = newLinkedChildren.Select(c => c.ChildId).ToHashSet();
|
||||||
.Where(e => e.ChildType == DbLinkedChildType.LocalAlternateVersion)
|
var orphanedLocalVersionIds = previousLinkedChildren
|
||||||
|
.Where(e => e.ChildType == DbLinkedChildType.LocalAlternateVersion && !newChildIds.Contains(e.ChildId))
|
||||||
.Select(e => e.ChildId)
|
.Select(e => e.ChildId)
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
context.LinkedChildren.RemoveRange(existingLinkedChildren);
|
|
||||||
|
|
||||||
if (orphanedLocalVersionIds.Count > 0)
|
if (orphanedLocalVersionIds.Count > 0)
|
||||||
{
|
{
|
||||||
var orphanedItems = context.BaseItems
|
var orphanedItems = context.BaseItems
|
||||||
|
|||||||
@@ -159,12 +159,16 @@ public class LinkedChildrenService : ILinkedChildrenService
|
|||||||
|
|
||||||
if (existingLink is null)
|
if (existingLink is null)
|
||||||
{
|
{
|
||||||
|
var nextSortOrder = (context.LinkedChildren
|
||||||
|
.Where(lc => lc.ParentId == parentId)
|
||||||
|
.Max(lc => (int?)lc.SortOrder) ?? -1) + 1;
|
||||||
|
|
||||||
context.LinkedChildren.Add(new Jellyfin.Database.Implementations.Entities.LinkedChildEntity
|
context.LinkedChildren.Add(new Jellyfin.Database.Implementations.Entities.LinkedChildEntity
|
||||||
{
|
{
|
||||||
ParentId = parentId,
|
ParentId = parentId,
|
||||||
ChildId = childId,
|
ChildId = childId,
|
||||||
ChildType = dbChildType,
|
ChildType = dbChildType,
|
||||||
SortOrder = null
|
SortOrder = nextSortOrder
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -172,8 +172,7 @@ public class MediaStreamRepository : IMediaStreamRepository
|
|||||||
|
|
||||||
if (!string.IsNullOrEmpty(dto.Language))
|
if (!string.IsNullOrEmpty(dto.Language))
|
||||||
{
|
{
|
||||||
var culture = _localization.FindLanguageInfo(dto.Language);
|
dto.LocalizedLanguage = _localization.GetLanguageDisplayName(dto.Language);
|
||||||
dto.LocalizedLanguage = culture?.DisplayName;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dto.Type is MediaStreamType.Audio)
|
if (dto.Type is MediaStreamType.Audio)
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ public class NextUpService : INextUpService
|
|||||||
.Where(e => e.UserData!.Any(ud => ud.UserId == userId && ud.Played));
|
.Where(e => e.UserData!.Any(ud => ud.UserId == userId && ud.Played));
|
||||||
lastWatchedBase = _queryHelpers.ApplyAccessFiltering(context, lastWatchedBase, filter);
|
lastWatchedBase = _queryHelpers.ApplyAccessFiltering(context, lastWatchedBase, filter);
|
||||||
|
|
||||||
// Use lightweight projection + client-side grouping to avoid correlated scalar subquery
|
// Use lightweight projection + client-side dedup to avoid the correlated scalar subquery
|
||||||
// per group that EF generates for GroupBy+OrderByDescending+FirstOrDefault.
|
// per group that EF generates for GroupBy+OrderByDescending+FirstOrDefault.
|
||||||
var allPlayedLite = lastWatchedBase
|
var allPlayedLite = lastWatchedBase
|
||||||
.Select(e => new
|
.Select(e => new
|
||||||
@@ -110,15 +110,11 @@ public class NextUpService : INextUpService
|
|||||||
})
|
})
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
var lastWatchedInfo = new Dictionary<string, Guid>();
|
var lastWatchedInfo = allPlayedLite
|
||||||
foreach (var group in allPlayedLite.GroupBy(e => e.SeriesPresentationUniqueKey))
|
.OrderByDescending(e => e.ParentIndexNumber)
|
||||||
{
|
.ThenByDescending(e => e.IndexNumber)
|
||||||
var lastWatched = group
|
.DistinctBy(e => e.SeriesPresentationUniqueKey)
|
||||||
.OrderByDescending(e => e.ParentIndexNumber)
|
.ToDictionary(e => e.SeriesPresentationUniqueKey!, e => e.Id);
|
||||||
.ThenByDescending(e => e.IndexNumber)
|
|
||||||
.First();
|
|
||||||
lastWatchedInfo[group.Key!] = lastWatched.Id;
|
|
||||||
}
|
|
||||||
|
|
||||||
Dictionary<string, Guid> lastWatchedByDateInfo = new();
|
Dictionary<string, Guid> lastWatchedByDateInfo = new();
|
||||||
if (includeWatchedForRewatching)
|
if (includeWatchedForRewatching)
|
||||||
@@ -144,11 +140,10 @@ public class NextUpService : INextUpService
|
|||||||
(e, ud) => new { EpisodeId = e.Id, e.SeriesPresentationUniqueKey, ud.LastPlayedDate })
|
(e, ud) => new { EpisodeId = e.Id, e.SeriesPresentationUniqueKey, ud.LastPlayedDate })
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
foreach (var group in playedWithDates.GroupBy(x => x.SeriesPresentationUniqueKey))
|
lastWatchedByDateInfo = playedWithDates
|
||||||
{
|
.OrderByDescending(x => x.LastPlayedDate)
|
||||||
var mostRecent = group.OrderByDescending(x => x.LastPlayedDate).First();
|
.DistinctBy(x => x.SeriesPresentationUniqueKey)
|
||||||
lastWatchedByDateInfo[group.Key!] = mostRecent.EpisodeId;
|
.ToDictionary(x => x.SeriesPresentationUniqueKey!, x => x.EpisodeId);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var allLastWatchedIds = lastWatchedInfo.Values
|
var allLastWatchedIds = lastWatchedInfo.Values
|
||||||
|
|||||||
@@ -29,12 +29,30 @@ public static class OrderMapper
|
|||||||
/// <returns>Func to be executed later for sorting query.</returns>
|
/// <returns>Func to be executed later for sorting query.</returns>
|
||||||
public static Expression<Func<BaseItemEntity, object?>> MapOrderByField(ItemSortBy sortBy, InternalItemsQuery query, JellyfinDbContext jellyfinDbContext)
|
public static Expression<Func<BaseItemEntity, object?>> MapOrderByField(ItemSortBy sortBy, InternalItemsQuery query, JellyfinDbContext jellyfinDbContext)
|
||||||
{
|
{
|
||||||
|
if (sortBy == ItemSortBy.DatePlayed)
|
||||||
|
{
|
||||||
|
// An item's played date is the newest of its own progress and that of its alternate versions,
|
||||||
|
// which track progress under their own ids. Matching both in one predicate ORs them together,
|
||||||
|
// which no index can serve: the user's whole UserData table gets scanned per sorted row.
|
||||||
|
// Two indexed lookups combined by MAX cost a seek each instead.
|
||||||
|
var userData = query.User is null
|
||||||
|
? jellyfinDbContext.UserData
|
||||||
|
: jellyfinDbContext.UserData.Where(w => w.UserId == query.User.Id);
|
||||||
|
|
||||||
|
return e => userData
|
||||||
|
.Where(w => w.ItemId == e.Id)
|
||||||
|
.Select(w => w.LastPlayedDate)
|
||||||
|
.Concat(userData
|
||||||
|
.Where(w => w.Item!.PrimaryVersionId == e.Id)
|
||||||
|
.Select(w => w.LastPlayedDate))
|
||||||
|
.Max();
|
||||||
|
}
|
||||||
|
|
||||||
return (sortBy, query.User) switch
|
return (sortBy, query.User) switch
|
||||||
{
|
{
|
||||||
(ItemSortBy.AirTime, _) => e => e.SortName,
|
(ItemSortBy.AirTime, _) => e => e.SortName,
|
||||||
(ItemSortBy.Runtime, _) => e => e.RunTimeTicks,
|
(ItemSortBy.Runtime, _) => e => e.RunTimeTicks,
|
||||||
(ItemSortBy.Random, _) => e => EF.Functions.Random(),
|
(ItemSortBy.Random, _) => e => EF.Functions.Random(),
|
||||||
(ItemSortBy.DatePlayed, _) => e => e.UserData!.Where(f => f.UserId.Equals(query.User!.Id)).OrderBy(f => f.CustomDataKey).FirstOrDefault()!.LastPlayedDate,
|
|
||||||
(ItemSortBy.PlayCount, _) => e => e.UserData!.Where(f => f.UserId.Equals(query.User!.Id)).OrderBy(f => f.CustomDataKey).FirstOrDefault()!.PlayCount,
|
(ItemSortBy.PlayCount, _) => e => e.UserData!.Where(f => f.UserId.Equals(query.User!.Id)).OrderBy(f => f.CustomDataKey).FirstOrDefault()!.PlayCount,
|
||||||
(ItemSortBy.IsFavoriteOrLiked, _) => e => e.UserData!.Where(f => f.UserId.Equals(query.User!.Id)).OrderBy(f => f.CustomDataKey).Select(f => (bool?)f.IsFavorite).FirstOrDefault() ?? false,
|
(ItemSortBy.IsFavoriteOrLiked, _) => e => e.UserData!.Where(f => f.UserId.Equals(query.User!.Id)).OrderBy(f => f.CustomDataKey).Select(f => (bool?)f.IsFavorite).FirstOrDefault() ?? false,
|
||||||
(ItemSortBy.IsFolder, _) => e => e.IsFolder,
|
(ItemSortBy.IsFolder, _) => e => e.IsFolder,
|
||||||
@@ -50,7 +68,7 @@ public static class OrderMapper
|
|||||||
(ItemSortBy.DateCreated, _) => e => e.DateCreated,
|
(ItemSortBy.DateCreated, _) => e => e.DateCreated,
|
||||||
(ItemSortBy.PremiereDate, _) => e => e.PremiereDate ?? (e.ProductionYear.HasValue ? DateTime.MinValue.AddYears(e.ProductionYear.Value - 1) : null),
|
(ItemSortBy.PremiereDate, _) => e => e.PremiereDate ?? (e.ProductionYear.HasValue ? DateTime.MinValue.AddYears(e.ProductionYear.Value - 1) : null),
|
||||||
(ItemSortBy.StartDate, _) => e => e.StartDate,
|
(ItemSortBy.StartDate, _) => e => e.StartDate,
|
||||||
(ItemSortBy.Name, _) => e => e.SortName,
|
(ItemSortBy.Name, _) => e => e.CleanName,
|
||||||
(ItemSortBy.CommunityRating, _) => e => e.CommunityRating,
|
(ItemSortBy.CommunityRating, _) => e => e.CommunityRating,
|
||||||
(ItemSortBy.ProductionYear, _) => e => e.ProductionYear,
|
(ItemSortBy.ProductionYear, _) => e => e.ProductionYear,
|
||||||
(ItemSortBy.CriticRating, _) => e => e.CriticRating,
|
(ItemSortBy.CriticRating, _) => e => e.CriticRating,
|
||||||
|
|||||||
@@ -79,7 +79,11 @@ public class PeopleRepository(IDbContextFactory<JellyfinDbContext> dbProvider, I
|
|||||||
public IReadOnlyList<string> GetPeopleNames(InternalPeopleQuery filter)
|
public IReadOnlyList<string> GetPeopleNames(InternalPeopleQuery filter)
|
||||||
{
|
{
|
||||||
using var context = _dbProvider.CreateDbContext();
|
using var context = _dbProvider.CreateDbContext();
|
||||||
var dbQuery = TranslateQuery(context.Peoples.AsNoTracking(), context, filter).Select(e => e.Name).Distinct();
|
|
||||||
|
IQueryable<string> dbQuery = TranslateQuery(context.Peoples.AsNoTracking(), context, filter)
|
||||||
|
.Select(e => e.Name)
|
||||||
|
.Distinct()
|
||||||
|
.OrderBy(e => e);
|
||||||
|
|
||||||
if (filter.StartIndex.HasValue && filter.StartIndex > 0)
|
if (filter.StartIndex.HasValue && filter.StartIndex > 0)
|
||||||
{
|
{
|
||||||
@@ -88,7 +92,7 @@ public class PeopleRepository(IDbContextFactory<JellyfinDbContext> dbProvider, I
|
|||||||
|
|
||||||
if (filter.Limit > 0)
|
if (filter.Limit > 0)
|
||||||
{
|
{
|
||||||
dbQuery = dbQuery.OrderBy(e => e).Take(filter.Limit);
|
dbQuery = dbQuery.Take(filter.Limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
return dbQuery.ToArray();
|
return dbQuery.ToArray();
|
||||||
|
|||||||
@@ -87,8 +87,9 @@ public static class StorageHelper
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private static string ResolvePath(string path)
|
private static string ResolvePath(string path)
|
||||||
{
|
{
|
||||||
var parts = path.Split(Path.DirectorySeparatorChar, StringSplitOptions.RemoveEmptyEntries);
|
var root = Path.GetPathRoot(path) ?? Path.DirectorySeparatorChar.ToString();
|
||||||
var current = Path.DirectorySeparatorChar.ToString();
|
var parts = path.Substring(root.Length).Split(Path.DirectorySeparatorChar, StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
var current = root;
|
||||||
foreach (var part in parts)
|
foreach (var part in parts)
|
||||||
{
|
{
|
||||||
current = Path.Combine(current, part);
|
current = Path.Combine(current, part);
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user