diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json
index a3847dcdfb..76e6bce7b3 100644
--- a/.config/dotnet-tools.json
+++ b/.config/dotnet-tools.json
@@ -3,7 +3,7 @@
"isRoot": true,
"tools": {
"dotnet-ef": {
- "version": "8.0.8",
+ "version": "9.0.4",
"commands": [
"dotnet-ef"
]
diff --git a/.devcontainer/Dev - Server Ffmpeg/devcontainer.json b/.devcontainer/Dev - Server Ffmpeg/devcontainer.json
deleted file mode 100644
index 0b848d9f3c..0000000000
--- a/.devcontainer/Dev - Server Ffmpeg/devcontainer.json
+++ /dev/null
@@ -1,28 +0,0 @@
-{
- "name": "Development Jellyfin Server - FFmpeg",
- "image":"mcr.microsoft.com/devcontainers/dotnet:8.0-jammy",
- // restores nuget packages, installs the dotnet workloads and installs the dev https certificate
- "postStartCommand": "dotnet restore; dotnet workload update; dotnet dev-certs https --trust; sudo bash \"./.devcontainer/Dev - Server Ffmpeg/install-ffmpeg.sh\"",
- // reads the extensions list and installs them
- "postAttachCommand": "cat .vscode/extensions.json | jq -r .recommendations[] | xargs -n 1 code --install-extension",
- "features": {
- "ghcr.io/devcontainers/features/dotnet:2": {
- "version": "none",
- "dotnetRuntimeVersions": "8.0",
- "aspNetCoreRuntimeVersions": "8.0"
- },
- "ghcr.io/devcontainers-contrib/features/apt-packages:1": {
- "preserve_apt_list": false,
- "packages": ["libfontconfig1"]
- },
- "ghcr.io/devcontainers/features/docker-in-docker:2": {
- "dockerDashComposeVersion": "v2"
- },
- "ghcr.io/devcontainers/features/github-cli:1": {},
- "ghcr.io/eitsupi/devcontainer-features/jq-likes:2": {}
- },
- "hostRequirements": {
- "memory": "8gb",
- "cpus": 4
- }
-}
diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json
index 063901c800..c2127ba5c3 100644
--- a/.devcontainer/devcontainer.json
+++ b/.devcontainer/devcontainer.json
@@ -1,19 +1,23 @@
{
"name": "Development Jellyfin Server",
- "image":"mcr.microsoft.com/devcontainers/dotnet:8.0-jammy",
+ "image": "mcr.microsoft.com/devcontainers/dotnet:9.0-bookworm",
+ "service": "app",
+ "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
// restores nuget packages, installs the dotnet workloads and installs the dev https certificate
- "postStartCommand": "dotnet restore; dotnet workload update; dotnet dev-certs https --trust",
+ "postStartCommand": "sudo dotnet restore; sudo dotnet workload update; sudo dotnet dev-certs https --trust; sudo bash \"./.devcontainer/install-ffmpeg.sh\"",
// reads the extensions list and installs them
"postAttachCommand": "cat .vscode/extensions.json | jq -r .recommendations[] | xargs -n 1 code --install-extension",
"features": {
"ghcr.io/devcontainers/features/dotnet:2": {
"version": "none",
- "dotnetRuntimeVersions": "8.0",
- "aspNetCoreRuntimeVersions": "8.0"
+ "dotnetRuntimeVersions": "9.0",
+ "aspNetCoreRuntimeVersions": "9.0"
},
"ghcr.io/devcontainers-contrib/features/apt-packages:1": {
"preserve_apt_list": false,
- "packages": ["libfontconfig1"]
+ "packages": [
+ "libfontconfig1"
+ ]
},
"ghcr.io/devcontainers/features/docker-in-docker:2": {
"dockerDashComposeVersion": "v2"
diff --git a/.devcontainer/Dev - Server Ffmpeg/install-ffmpeg.sh b/.devcontainer/install-ffmpeg.sh
similarity index 89%
rename from .devcontainer/Dev - Server Ffmpeg/install-ffmpeg.sh
rename to .devcontainer/install-ffmpeg.sh
index c867ef538c..1e58e6ef44 100644
--- a/.devcontainer/Dev - Server Ffmpeg/install-ffmpeg.sh
+++ b/.devcontainer/install-ffmpeg.sh
@@ -1,6 +1,6 @@
#!/bin/bash
-## configure the following for a manuall install of a specific version from the repo
+## configure the following for a manual install of a specific version from the repo
# wget https://repo.jellyfin.org/releases/server/ubuntu/versions/jellyfin-ffmpeg/6.0.1-1/jellyfin-ffmpeg6_6.0.1-1-jammy_amd64.deb -O ffmpeg.deb
@@ -29,4 +29,4 @@ Signed-By: /etc/apt/keyrings/jellyfin.gpg
EOF
sudo apt update -y
-sudo apt install jellyfin-ffmpeg6 -y
+sudo apt install jellyfin-ffmpeg7 -y
diff --git a/.editorconfig b/.editorconfig
index b84e563efa..ab5d3d9dd1 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -192,3 +192,341 @@ csharp_space_between_method_call_empty_parameter_list_parentheses = false
# Wrapping preferences
csharp_preserve_single_line_statements = true
csharp_preserve_single_line_blocks = true
+
+###############################
+# C# Analyzer Rules #
+###############################
+### ERROR #
+###########
+# error on SA1000: The keyword 'new' should be followed by a space
+dotnet_diagnostic.SA1000.severity = error
+
+# error on SA1001: Commas should not be preceded by whitespace
+dotnet_diagnostic.SA1001.severity = error
+
+# error on SA1106: Code should not contain empty statements
+dotnet_diagnostic.SA1106.severity = error
+
+# error on SA1107: Code should not contain multiple statements on one line
+dotnet_diagnostic.SA1107.severity = error
+
+# error on SA1028: Code should not contain trailing whitespace
+dotnet_diagnostic.SA1028.severity = error
+
+# error on SA1117: The parameters should all be placed on the same line or each parameter should be placed on its own line
+dotnet_diagnostic.SA1117.severity = error
+
+# error on SA1137: Elements should have the same indentation
+dotnet_diagnostic.SA1137.severity = error
+
+# error on SA1142: Refer to tuple fields by name
+dotnet_diagnostic.SA1142.severity = error
+
+# error on SA1210: Using directives should be ordered alphabetically by the namespaces
+dotnet_diagnostic.SA1210.severity = error
+
+# error on SA1316: Tuple element names should use correct casing
+dotnet_diagnostic.SA1316.severity = error
+
+# error on SA1414: Tuple types in signatures should have element names
+dotnet_diagnostic.SA1414.severity = error
+
+# disable warning SA1513: Closing brace should be followed by blank line
+dotnet_diagnostic.SA1513.severity = error
+
+# error on SA1518: File is required to end with a single newline character
+dotnet_diagnostic.SA1518.severity = error
+
+# error on SA1629: Documentation text should end with a period
+dotnet_diagnostic.SA1629.severity = error
+
+# error on CA1001: Types that own disposable fields should be disposable
+dotnet_diagnostic.CA1001.severity = error
+
+# error on CA1012: Abstract types should not have public constructors
+dotnet_diagnostic.CA1012.severity = error
+
+# error on CA1063: Implement IDisposable correctly
+dotnet_diagnostic.CA1063.severity = error
+
+# error on CA1305: Specify IFormatProvider
+dotnet_diagnostic.CA1305.severity = error
+
+# error on CA1307: Specify StringComparison for clarity
+dotnet_diagnostic.CA1307.severity = error
+
+# error on CA1309: Use ordinal StringComparison
+dotnet_diagnostic.CA1309.severity = error
+
+# error on CA1310: Specify StringComparison for correctness
+dotnet_diagnostic.CA1310.severity = error
+
+# error on CA1513: Use 'ObjectDisposedException.ThrowIf' instead of explicitly throwing a new exception instance
+dotnet_diagnostic.CA1513.severity = error
+
+# error on CA1725: Parameter names should match base declaration
+dotnet_diagnostic.CA1725.severity = error
+
+# error on CA1725: Call async methods when in an async method
+dotnet_diagnostic.CA1727.severity = error
+
+# error on CA1813: Avoid unsealed attributes
+dotnet_diagnostic.CA1813.severity = error
+
+# error on CA1834: Use 'StringBuilder.Append(char)' instead of 'StringBuilder.Append(string)' when the input is a constant unit string
+dotnet_diagnostic.CA1834.severity = error
+
+# error on CA1843: Do not use 'WaitAll' with a single task
+dotnet_diagnostic.CA1843.severity = error
+
+# error on CA1845: Use span-based 'string.Concat'
+dotnet_diagnostic.CA1845.severity = error
+
+# error on CA1849: Call async methods when in an async method
+dotnet_diagnostic.CA1849.severity = error
+
+# error on CA1851: Possible multiple enumerations of IEnumerable collection
+dotnet_diagnostic.CA1851.severity = error
+
+# error on CA1854: Prefer a 'TryGetValue' call over a Dictionary indexer access guarded by a 'ContainsKey' check to avoid double lookup
+dotnet_diagnostic.CA1854.severity = error
+
+# error on CA1860: Avoid using 'Enumerable.Any()' extension method
+dotnet_diagnostic.CA1860.severity = error
+
+# error on CA1862: Use the 'StringComparison' method overloads to perform case-insensitive string comparisons
+dotnet_diagnostic.CA1862.severity = error
+
+# error on CA1863: Use 'CompositeFormat'
+dotnet_diagnostic.CA1863.severity = error
+
+# error on CA1864: Prefer the 'IDictionary.TryAdd(TKey, TValue)' method
+dotnet_diagnostic.CA1864.severity = error
+
+# error on CA1865-CA1867: Use 'string.Method(char)' instead of 'string.Method(string)' for string with single char
+dotnet_diagnostic.CA1865.severity = error
+dotnet_diagnostic.CA1866.severity = error
+dotnet_diagnostic.CA1867.severity = error
+
+# error on CA1868: Unnecessary call to 'Contains' for sets
+dotnet_diagnostic.CA1868.severity = error
+
+# error on CA1869: Cache and reuse 'JsonSerializerOptions' instances
+dotnet_diagnostic.CA1869.severity = error
+
+# error on CA1870: Use a cached 'SearchValues' instance
+dotnet_diagnostic.CA1870.severity = error
+
+# error on CA1871: Do not pass a nullable struct to 'ArgumentNullException.ThrowIfNull'
+dotnet_diagnostic.CA1871.severity = error
+
+# error on CA1872: Prefer 'Convert.ToHexString' and 'Convert.ToHexStringLower' over call chains based on 'BitConverter.ToString'
+dotnet_diagnostic.CA1872.severity = error
+
+# error on CA2016: Forward the CancellationToken parameter to methods that take one
+# or pass in 'CancellationToken.None' explicitly to indicate intentionally not propagating the token
+dotnet_diagnostic.CA2016.severity = error
+
+# error on CA2201: Exception type System.Exception is not sufficiently specific
+dotnet_diagnostic.CA2201.severity = error
+
+# error on CA2215: Dispose methods should call base class dispose
+dotnet_diagnostic.CA2215.severity = error
+
+# error on CA2249: Use 'string.Contains' instead of 'string.IndexOf' to improve readability
+dotnet_diagnostic.CA2249.severity = error
+
+# error on CA2254: Template should be a static expression
+dotnet_diagnostic.CA2254.severity = error
+
+################
+### SUGGESTION #
+################
+# disable warning CA1014: Mark assemblies with CLSCompliantAttribute
+dotnet_diagnostic.CA1014.severity = suggestion
+
+# disable warning CA1024: Use properties where appropriate
+dotnet_diagnostic.CA1024.severity = suggestion
+
+# disable warning CA1031: Do not catch general exception types
+dotnet_diagnostic.CA1031.severity = suggestion
+
+# disable warning CA1032: Implement standard exception constructors
+dotnet_diagnostic.CA1032.severity = suggestion
+
+# disable warning CA1040: Avoid empty interfaces
+dotnet_diagnostic.CA1040.severity = suggestion
+
+# disable warning CA1062: Validate arguments of public methods
+dotnet_diagnostic.CA1062.severity = suggestion
+
+# TODO: enable when false positives are fixed
+# disable warning CA1508: Avoid dead conditional code
+dotnet_diagnostic.CA1508.severity = suggestion
+
+# disable warning CA1515: Consider making public types internal
+dotnet_diagnostic.CA1515.severity = suggestion
+
+# disable warning CA1716: Identifiers should not match keywords
+dotnet_diagnostic.CA1716.severity = suggestion
+
+# disable warning CA1720: Identifiers should not contain type names
+dotnet_diagnostic.CA1720.severity = suggestion
+
+# disable warning CA1724: Type names should not match namespaces
+dotnet_diagnostic.CA1724.severity = suggestion
+
+# disable warning CA1805: Do not initialize unnecessarily
+dotnet_diagnostic.CA1805.severity = suggestion
+
+# disable warning CA1812: internal class that is apparently never instantiated.
+# If so, remove the code from the assembly.
+# If this class is intended to contain only static members, make it static
+dotnet_diagnostic.CA1812.severity = suggestion
+
+# disable warning CA1822: Member does not access instance data and can be marked as static
+dotnet_diagnostic.CA1822.severity = suggestion
+
+# CA1859: Use concrete types when possible for improved performance
+dotnet_diagnostic.CA1859.severity = suggestion
+
+# TODO: Enable
+# CA1861: Prefer 'static readonly' fields over constant array arguments if the called method is called repeatedly and is not mutating the passed array
+dotnet_diagnostic.CA1861.severity = suggestion
+
+# disable warning CA2000: Dispose objects before losing scope
+dotnet_diagnostic.CA2000.severity = suggestion
+
+# disable warning CA2253: Named placeholders should not be numeric values
+dotnet_diagnostic.CA2253.severity = suggestion
+
+# disable warning CA5394: Do not use insecure randomness
+dotnet_diagnostic.CA5394.severity = suggestion
+
+# error on CA3003: Review code for file path injection vulnerabilities
+dotnet_diagnostic.CA3003.severity = suggestion
+
+# error on CA3006: Review code for process command injection vulnerabilities
+dotnet_diagnostic.CA3006.severity = suggestion
+
+###############
+### DISABLED #
+###############
+# disable warning SA1009: Closing parenthesis should be followed by a space.
+dotnet_diagnostic.SA1009.severity = none
+
+# disable warning SA1011: Closing square bracket should be followed by a space.
+dotnet_diagnostic.SA1011.severity = none
+
+# disable warning SA1101: Prefix local calls with 'this.'
+dotnet_diagnostic.SA1101.severity = none
+
+# disable warning SA1108: Block statements should not contain embedded comments
+dotnet_diagnostic.SA1108.severity = none
+
+# disable warning SA1118: Parameter must not span multiple lines.
+dotnet_diagnostic.SA1118.severity = none
+
+# disable warning SA1128:: Put constructor initializers on their own line
+dotnet_diagnostic.SA1128.severity = none
+
+# disable warning SA1130: Use lambda syntax
+dotnet_diagnostic.SA1130.severity = none
+
+# disable warning SA1200: 'using' directive must appear within a namespace declaration
+dotnet_diagnostic.SA1200.severity = none
+
+# disable warning SA1202: 'public' members must come before 'private' members
+dotnet_diagnostic.SA1202.severity = none
+
+# disable warning SA1204: Static members must appear before non-static members
+dotnet_diagnostic.SA1204.severity = none
+
+# disable warning SA1309: Fields must not begin with an underscore
+dotnet_diagnostic.SA1309.severity = none
+
+# disable warning SA1311: Static readonly fields should begin with upper-case letter
+dotnet_diagnostic.SA1311.severity = none
+
+# disable warning SA1413: Use trailing comma in multi-line initializers
+dotnet_diagnostic.SA1413.severity = none
+
+# disable warning SA1512: Single-line comments must not be followed by blank line
+dotnet_diagnostic.SA1512.severity = none
+
+# disable warning SA1515: Single-line comment should be preceded by blank line
+dotnet_diagnostic.SA1515.severity = none
+
+# disable warning SA1600: Elements should be documented
+dotnet_diagnostic.SA1600.severity = none
+
+# disable warning SA1601: Partial elements should be documented
+dotnet_diagnostic.SA1601.severity = none
+
+# disable warning SA1602: Enumeration items should be documented
+dotnet_diagnostic.SA1602.severity = none
+
+# disable warning SA1633: The file header is missing or not located at the top of the file
+dotnet_diagnostic.SA1633.severity = none
+
+# disable warning CA1054: Change the type of parameter url from string to System.Uri
+dotnet_diagnostic.CA1054.severity = none
+
+# disable warning CA1055: URI return values should not be strings
+dotnet_diagnostic.CA1055.severity = none
+
+# disable warning CA1056: URI properties should not be strings
+dotnet_diagnostic.CA1056.severity = none
+
+# disable warning CA1303: Do not pass literals as localized parameters
+dotnet_diagnostic.CA1303.severity = none
+
+# disable warning CA1308: Normalize strings to uppercase
+dotnet_diagnostic.CA1308.severity = none
+
+# disable warning CA1848: Use the LoggerMessage delegates
+dotnet_diagnostic.CA1848.severity = none
+
+# disable warning CA2101: Specify marshaling for P/Invoke string arguments
+dotnet_diagnostic.CA2101.severity = none
+
+# disable warning CA2234: Pass System.Uri objects instead of strings
+dotnet_diagnostic.CA2234.severity = none
+
+# error on RS0030: Do not used banned APIs
+dotnet_diagnostic.RS0030.severity = error
+
+# disable warning IDISP001: Dispose created
+dotnet_diagnostic.IDISP001.severity = suggestion
+
+# TODO: Enable when false positives are fixed
+# disable warning IDISP003: Dispose previous before re-assigning
+dotnet_diagnostic.IDISP003.severity = suggestion
+
+# disable warning IDISP004: Don't ignore created IDisposable
+dotnet_diagnostic.IDISP004.severity = suggestion
+
+# disable warning IDISP007: Don't dispose injected
+dotnet_diagnostic.IDISP007.severity = suggestion
+
+# disable warning IDISP008: Don't assign member with injected and created disposables
+dotnet_diagnostic.IDISP008.severity = suggestion
+
+[tests/**.{cs,vb}]
+# disable warning SA0001: XML comment analysis is disabled due to project configuration
+dotnet_diagnostic.SA0001.severity = none
+
+# disable warning CA1707: Identifiers should not contain underscores
+dotnet_diagnostic.CA1707.severity = none
+
+# disable warning CA2007: Consider calling ConfigureAwait on the awaited task
+dotnet_diagnostic.CA2007.severity = none
+
+# disable warning CA2234: Pass system uri objects instead of strings
+dotnet_diagnostic.CA2234.severity = suggestion
+
+# disable warning xUnit1028: Test methods must have a supported return type.
+dotnet_diagnostic.xUnit1028.severity = none
+
+# CA1826: Do not use Enumerable methods on indexable collections
+dotnet_diagnostic.CA1826.severity = suggestion
diff --git a/.github/ISSUE_TEMPLATE/issue report.yml b/.github/ISSUE_TEMPLATE/issue report.yml
index b522412088..4f58c5bc50 100644
--- a/.github/ISSUE_TEMPLATE/issue report.yml
+++ b/.github/ISSUE_TEMPLATE/issue report.yml
@@ -14,7 +14,7 @@ body:
label: "This issue respects the following points:"
description: All conditions are **required**. Failure to comply with any of these conditions may cause your issue to be closed without comment.
options:
- - label: This is a **bug**, not a question or a configuration issue; Please visit our forum or chat rooms first to troubleshoot with volunteers, before creating a report. The links can be found [here](https://jellyfin.org/contact/).
+ - label: This is a **bug**, not a question or a configuration issue; Please visit our [forum or chat rooms](https://jellyfin.org/contact/) first to troubleshoot with volunteers, before creating a report.
required: true
- label: This issue is **not** already reported on [GitHub](https://github.com/jellyfin/jellyfin/issues?q=is%3Aopen+is%3Aissue) _(I've searched it)_.
required: true
@@ -86,7 +86,7 @@ body:
label: Jellyfin Server version
description: What version of Jellyfin are you using?
options:
- - 10.9.11+
+ - 10.10.0+
- Master
- Unstable
- Older*
diff --git a/.github/workflows/ci-codeql-analysis.yml b/.github/workflows/ci-codeql-analysis.yml
index 1c55437a45..1eced1913b 100644
--- a/.github/workflows/ci-codeql-analysis.yml
+++ b/.github/workflows/ci-codeql-analysis.yml
@@ -22,16 +22,16 @@ jobs:
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Setup .NET
- uses: actions/setup-dotnet@3e891b0cb619bf60e2c25674b222b8940e2c1c25 # v4.1.0
+ uses: actions/setup-dotnet@67a3573c9a986a3f9c594539f4ab511d57bb3ce9 # v4.3.1
with:
- dotnet-version: '8.0.x'
+ dotnet-version: '9.0.x'
- name: Initialize CodeQL
- uses: github/codeql-action/init@662472033e021d55d94146f66f6058822b0b39fd # v3.27.0
+ uses: github/codeql-action/init@45775bd8235c68ba998cffa5171334d58593da47 # v3.28.15
with:
languages: ${{ matrix.language }}
queries: +security-extended
- name: Autobuild
- uses: github/codeql-action/autobuild@662472033e021d55d94146f66f6058822b0b39fd # v3.27.0
+ uses: github/codeql-action/autobuild@45775bd8235c68ba998cffa5171334d58593da47 # v3.28.15
- name: Perform CodeQL Analysis
- uses: github/codeql-action/analyze@662472033e021d55d94146f66f6058822b0b39fd # v3.27.0
+ uses: github/codeql-action/analyze@45775bd8235c68ba998cffa5171334d58593da47 # v3.28.15
diff --git a/.github/workflows/ci-compat.yml b/.github/workflows/ci-compat.yml
index c9d9f84493..13b029e52c 100644
--- a/.github/workflows/ci-compat.yml
+++ b/.github/workflows/ci-compat.yml
@@ -16,12 +16,17 @@ jobs:
ref: ${{ github.event.pull_request.head.sha }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
+ - name: Setup .NET
+ uses: actions/setup-dotnet@67a3573c9a986a3f9c594539f4ab511d57bb3ce9 # v4.3.1
+ with:
+ dotnet-version: '9.0.x'
+
- name: Build
run: |
dotnet build Jellyfin.Server -o ./out
- name: Upload Head
- uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
+ uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: abi-head
retention-days: 14
@@ -41,6 +46,11 @@ jobs:
repository: ${{ github.event.pull_request.head.repo.full_name }}
fetch-depth: 0
+ - name: Setup .NET
+ uses: actions/setup-dotnet@67a3573c9a986a3f9c594539f4ab511d57bb3ce9 # v4.3.1
+ with:
+ dotnet-version: '9.0.x'
+
- name: Checkout common ancestor
env:
HEAD_REF: ${{ github.head_ref }}
@@ -55,7 +65,7 @@ jobs:
dotnet build Jellyfin.Server -o ./out
- name: Upload Head
- uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
+ uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: abi-base
retention-days: 14
@@ -75,13 +85,13 @@ jobs:
steps:
- name: Download abi-head
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
+ uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e # v4.2.1
with:
name: abi-head
path: abi-head
- name: Download abi-base
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
+ uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e # v4.2.1
with:
name: abi-base
path: abi-base
diff --git a/.github/workflows/ci-openapi.yml b/.github/workflows/ci-openapi.yml
index 4633461ad7..95e090f9b6 100644
--- a/.github/workflows/ci-openapi.yml
+++ b/.github/workflows/ci-openapi.yml
@@ -21,18 +21,18 @@ jobs:
ref: ${{ github.event.pull_request.head.sha }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
- name: Setup .NET
- uses: actions/setup-dotnet@3e891b0cb619bf60e2c25674b222b8940e2c1c25 # v4.1.0
+ uses: actions/setup-dotnet@67a3573c9a986a3f9c594539f4ab511d57bb3ce9 # v4.3.1
with:
- dotnet-version: '8.0.x'
+ dotnet-version: '9.0.x'
- name: Generate openapi.json
run: dotnet test tests/Jellyfin.Server.Integration.Tests/Jellyfin.Server.Integration.Tests.csproj -c Release --filter "Jellyfin.Server.Integration.Tests.OpenApiSpecTests"
- name: Upload openapi.json
- uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
+ uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: openapi-head
retention-days: 14
if-no-files-found: error
- path: tests/Jellyfin.Server.Integration.Tests/bin/Release/net8.0/openapi.json
+ path: tests/Jellyfin.Server.Integration.Tests/bin/Release/net9.0/openapi.json
openapi-base:
name: OpenAPI - BASE
@@ -55,18 +55,18 @@ jobs:
ANCESTOR_REF=$(git merge-base upstream/${{ github.base_ref }} origin/$HEAD_REF)
git checkout --progress --force $ANCESTOR_REF
- name: Setup .NET
- uses: actions/setup-dotnet@3e891b0cb619bf60e2c25674b222b8940e2c1c25 # v4.1.0
+ uses: actions/setup-dotnet@67a3573c9a986a3f9c594539f4ab511d57bb3ce9 # v4.3.1
with:
- dotnet-version: '8.0.x'
+ dotnet-version: '9.0.x'
- name: Generate openapi.json
run: dotnet test tests/Jellyfin.Server.Integration.Tests/Jellyfin.Server.Integration.Tests.csproj -c Release --filter "Jellyfin.Server.Integration.Tests.OpenApiSpecTests"
- name: Upload openapi.json
- uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
+ uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: openapi-base
retention-days: 14
if-no-files-found: error
- path: tests/Jellyfin.Server.Integration.Tests/bin/Release/net8.0/openapi.json
+ path: tests/Jellyfin.Server.Integration.Tests/bin/Release/net9.0/openapi.json
openapi-diff:
permissions:
@@ -80,12 +80,12 @@ jobs:
- openapi-base
steps:
- name: Download openapi-head
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
+ uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e # v4.2.1
with:
name: openapi-head
path: openapi-head
- name: Download openapi-base
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
+ uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e # v4.2.1
with:
name: openapi-base
path: openapi-base
@@ -158,7 +158,7 @@ jobs:
run: |-
echo "JELLYFIN_VERSION=$(date +'%Y%m%d%H%M%S')" >> $GITHUB_ENV
- name: Download openapi-head
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
+ uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e # v4.2.1
with:
name: openapi-head
path: openapi-head
@@ -172,7 +172,7 @@ jobs:
strip_components: 1
target: "/srv/incoming/openapi/unstable/jellyfin-openapi-${{ env.JELLYFIN_VERSION }}"
- name: Move openapi.json (unstable) into place
- uses: appleboy/ssh-action@25ce8cbbcb08177468c7ff7ec5cbfa236f9341e1 # v1.1.0
+ uses: appleboy/ssh-action@2ead5e36573f08b82fbfce1504f1a4b05a647c6f # v1.2.2
with:
host: "${{ secrets.REPO_HOST }}"
username: "${{ secrets.REPO_USER }}"
@@ -220,7 +220,7 @@ jobs:
run: |-
echo "JELLYFIN_VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV
- name: Download openapi-head
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
+ uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e # v4.2.1
with:
name: openapi-head
path: openapi-head
@@ -234,7 +234,7 @@ jobs:
strip_components: 1
target: "/srv/incoming/openapi/stable/jellyfin-openapi-${{ env.JELLYFIN_VERSION }}"
- name: Move openapi.json (stable) into place
- uses: appleboy/ssh-action@25ce8cbbcb08177468c7ff7ec5cbfa236f9341e1 # v1.1.0
+ uses: appleboy/ssh-action@2ead5e36573f08b82fbfce1504f1a4b05a647c6f # v1.2.2
with:
host: "${{ secrets.REPO_HOST }}"
username: "${{ secrets.REPO_USER }}"
diff --git a/.github/workflows/ci-tests.yml b/.github/workflows/ci-tests.yml
index 54fb762e6b..be4192a446 100644
--- a/.github/workflows/ci-tests.yml
+++ b/.github/workflows/ci-tests.yml
@@ -9,19 +9,20 @@ on:
pull_request:
env:
- SDK_VERSION: "8.0.x"
+ SDK_VERSION: "9.0.x"
jobs:
run-tests:
strategy:
matrix:
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
+ fail-fast: false
runs-on: "${{ matrix.os }}"
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- - uses: actions/setup-dotnet@3e891b0cb619bf60e2c25674b222b8940e2c1c25 # v4.1.0
+ - uses: actions/setup-dotnet@67a3573c9a986a3f9c594539f4ab511d57bb3ce9 # v4.3.1
with:
dotnet-version: ${{ env.SDK_VERSION }}
@@ -34,7 +35,7 @@ jobs:
--verbosity minimal
- name: Merge code coverage results
- uses: danielpalme/ReportGenerator-GitHub-Action@62f9e70ab348d56eee76d446b4db903a85ab0ea8 # v5.3.11
+ uses: danielpalme/ReportGenerator-GitHub-Action@25b1e0261a9f68d7874dbbace168300558ef68f7 # v5.4.5
with:
reports: "**/coverage.cobertura.xml"
targetdir: "merged/"
diff --git a/.github/workflows/commands.yml b/.github/workflows/commands.yml
index 26b98f973d..5ec4d164a5 100644
--- a/.github/workflows/commands.yml
+++ b/.github/workflows/commands.yml
@@ -34,94 +34,6 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.JF_BOT_TOKEN }}
- check-backport:
- permissions:
- contents: read
-
- name: Check Backport
- if: ${{ ( github.event.issue.pull_request && contains(github.event.comment.body, '@jellyfin-bot check backport') ) || github.event.label.name == 'stable backport' || contains(github.event.pull_request.labels.*.name, 'stable backport' ) }}
- runs-on: ubuntu-latest
- steps:
- - name: Notify as seen
- uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0
- if: ${{ github.event.comment != null }}
- with:
- token: ${{ secrets.JF_BOT_TOKEN }}
- comment-id: ${{ github.event.comment.id }}
- reactions: eyes
-
- - name: Checkout the latest code
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- with:
- token: ${{ secrets.JF_BOT_TOKEN }}
- fetch-depth: 0
-
- - name: Notify as running
- id: comment_running
- uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0
- if: ${{ github.event.comment != null }}
- with:
- token: ${{ secrets.JF_BOT_TOKEN }}
- issue-number: ${{ github.event.issue.number }}
- body: |
- Running backport tests...
-
- - name: Perform test backport
- id: run_tests
- run: |
- set +o errexit
- git config --global user.name "Jellyfin Bot"
- git config --global user.email "team@jellyfin.org"
- CURRENT_BRANCH="origin/${GITHUB_HEAD_REF}"
- git checkout master
- git merge --no-ff ${CURRENT_BRANCH}
- MERGE_COMMIT_HASH=$( git log -q -1 | head -1 | awk '{ print $2 }' )
- git fetch --all
- CURRENT_STABLE=$( git branch -r | grep 'origin/release' | sort -rV | head -1 | awk -F '/' '{ print $NF }' )
- stable_branch="Current stable release branch: ${CURRENT_STABLE}"
- echo ${stable_branch}
- echo ::set-output name=branch::${stable_branch}
- git checkout -t origin/${CURRENT_STABLE} -b ${CURRENT_STABLE}
- git cherry-pick -sx -m1 ${MERGE_COMMIT_HASH} &>output.txt
- retcode=$?
- cat output.txt | grep -v 'hint:'
- output="$( grep -v 'hint:' output.txt )"
- output="${output//'%'/'%25'}"
- output="${output//$'\n'/'%0A'}"
- output="${output//$'\r'/'%0D'}"
- echo ::set-output name=output::$output
- exit ${retcode}
-
- - name: Notify with result success
- uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0
- if: ${{ github.event.comment != null && success() }}
- with:
- token: ${{ secrets.JF_BOT_TOKEN }}
- comment-id: ${{ steps.comment_running.outputs.comment-id }}
- body: |
- ${{ steps.run_tests.outputs.branch }}
- Output from `git cherry-pick`:
-
- ---
-
- ${{ steps.run_tests.outputs.output }}
- reactions: hooray
-
- - name: Notify with result failure
- uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0
- if: ${{ github.event.comment != null && failure() }}
- with:
- token: ${{ secrets.JF_BOT_TOKEN }}
- comment-id: ${{ steps.comment_running.outputs.comment-id }}
- body: |
- ${{ steps.run_tests.outputs.branch }}
- Output from `git cherry-pick`:
-
- ---
-
- ${{ steps.run_tests.outputs.output }}
- reactions: confused
-
rename:
name: Rename
if: contains(github.event.comment.body, '@jellyfin-bot rename') && github.event.comment.author_association == 'MEMBER'
@@ -132,9 +44,9 @@ jobs:
with:
repository: jellyfin/jellyfin-triage-script
- name: install python
- uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
+ uses: actions/setup-python@8d9ed9ac5c53483de85588cdf95a591a75ab9f55 # v5.5.0
with:
- python-version: '3.12'
+ python-version: '3.13'
cache: 'pip'
- name: install python packages
run: pip install -r rename/requirements.txt
diff --git a/.github/workflows/issue-stale.yml b/.github/workflows/issue-stale.yml
index 5a1ca9f7a2..624ea564fb 100644
--- a/.github/workflows/issue-stale.yml
+++ b/.github/workflows/issue-stale.yml
@@ -16,7 +16,7 @@ jobs:
runs-on: ubuntu-latest
if: ${{ contains(github.repository, 'jellyfin/') }}
steps:
- - uses: actions/stale@28ca1036281a5e5922ead5184a1bbf96e5fc984e # v9.0.0
+ - uses: actions/stale@5bef64f19d7facfb25b37b414482c7164d639639 # v9.1.0
with:
repo-token: ${{ secrets.JF_BOT_TOKEN }}
ascending: true
diff --git a/.github/workflows/issue-template-check.yml b/.github/workflows/issue-template-check.yml
index b72e552af0..8a21ab0151 100644
--- a/.github/workflows/issue-template-check.yml
+++ b/.github/workflows/issue-template-check.yml
@@ -14,9 +14,9 @@ jobs:
with:
repository: jellyfin/jellyfin-triage-script
- name: install python
- uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
+ uses: actions/setup-python@8d9ed9ac5c53483de85588cdf95a591a75ab9f55 # v5.5.0
with:
- python-version: '3.12'
+ python-version: '3.13'
cache: 'pip'
- name: install python packages
run: pip install -r main-repo-triage/requirements.txt
diff --git a/.github/workflows/pull-request-conflict.yml b/.github/workflows/pull-request-conflict.yml
index 5d342b7f84..411ebf8290 100644
--- a/.github/workflows/pull-request-conflict.yml
+++ b/.github/workflows/pull-request-conflict.yml
@@ -15,7 +15,7 @@ jobs:
if: ${{ github.repository == 'jellyfin/jellyfin' }}
steps:
- name: Apply label
- uses: eps1lon/actions-label-merge-conflict@1b1b1fcde06a9b3d089f3464c96417961dde1168 # v3.0.2
+ uses: eps1lon/actions-label-merge-conflict@1df065ebe6e3310545d4f4c4e862e43bdca146f0 # v3.0.3
if: ${{ github.event_name == 'push' || github.event_name == 'pull_request_target'}}
with:
dirtyLabel: 'merge conflict'
diff --git a/.github/workflows/pull-request-stale.yaml b/.github/workflows/pull-request-stale.yaml
index d01b3f4a1f..7ce5b0fa61 100644
--- a/.github/workflows/pull-request-stale.yaml
+++ b/.github/workflows/pull-request-stale.yaml
@@ -15,7 +15,7 @@ jobs:
runs-on: ubuntu-latest
if: ${{ contains(github.repository, 'jellyfin/') }}
steps:
- - uses: actions/stale@28ca1036281a5e5922ead5184a1bbf96e5fc984e # v9.0.0
+ - uses: actions/stale@5bef64f19d7facfb25b37b414482c7164d639639 # v9.1.0
with:
repo-token: ${{ secrets.JF_BOT_TOKEN }}
ascending: true
diff --git a/.vscode/extensions.json b/.vscode/extensions.json
index 3be946e446..e4205ce0b1 100644
--- a/.vscode/extensions.json
+++ b/.vscode/extensions.json
@@ -1,12 +1,13 @@
{
- "recommendations": [
+ "recommendations": [
"ms-dotnettools.csharp",
"editorconfig.editorconfig",
"github.vscode-github-actions",
"ms-dotnettools.vscode-dotnet-runtime",
- "ms-dotnettools.csdevkit"
- ],
- "unwantedRecommendations": [
+ "ms-dotnettools.csdevkit",
+ "alexcvzz.vscode-sqlite"
+ ],
+ "unwantedRecommendations": [
- ]
+ ]
}
diff --git a/.vscode/launch.json b/.vscode/launch.json
index 7e50d4f0a4..d97d8de843 100644
--- a/.vscode/launch.json
+++ b/.vscode/launch.json
@@ -6,7 +6,7 @@
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
- "program": "${workspaceFolder}/Jellyfin.Server/bin/Debug/net8.0/jellyfin.dll",
+ "program": "${workspaceFolder}/Jellyfin.Server/bin/Debug/net9.0/jellyfin.dll",
"args": [],
"cwd": "${workspaceFolder}/Jellyfin.Server",
"console": "internalConsole",
@@ -22,7 +22,7 @@
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
- "program": "${workspaceFolder}/Jellyfin.Server/bin/Debug/net8.0/jellyfin.dll",
+ "program": "${workspaceFolder}/Jellyfin.Server/bin/Debug/net9.0/jellyfin.dll",
"args": ["--nowebclient"],
"cwd": "${workspaceFolder}/Jellyfin.Server",
"console": "internalConsole",
@@ -34,7 +34,7 @@
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
- "program": "${workspaceFolder}/Jellyfin.Server/bin/Debug/net8.0/jellyfin.dll",
+ "program": "${workspaceFolder}/Jellyfin.Server/bin/Debug/net9.0/jellyfin.dll",
"args": ["--nowebclient", "--ffmpeg", "/usr/lib/jellyfin-ffmpeg/ffmpeg"],
"cwd": "${workspaceFolder}/Jellyfin.Server",
"console": "internalConsole",
diff --git a/.vscode/settings.json b/.vscode/settings.json
new file mode 100644
index 0000000000..6733d59aca
--- /dev/null
+++ b/.vscode/settings.json
@@ -0,0 +1,3 @@
+{
+ "dotnet.preferVisualStudioCodeFileSystemWatcher": true
+}
diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md
index a9deb1c4a2..0dcce1ea18 100644
--- a/CONTRIBUTORS.md
+++ b/CONTRIBUTORS.md
@@ -192,6 +192,9 @@
- [jaina heartles](https://github.com/heartles)
- [oxixes](https://github.com/oxixes)
- [elfalem](https://github.com/elfalem)
+ - [Kenneth Cochran](https://github.com/kennethcochran)
+ - [benedikt257](https://github.com/benedikt257)
+ - [revam](https://github.com/revam)
# Emby Contributors
@@ -265,3 +268,5 @@
- [0x25CBFC4F](https://github.com/0x25CBFC4F)
- [Robert Lützner](https://github.com/rluetzner)
- [Nathan McCrina](https://github.com/nfmccrina)
+ - [Martin Reuter](https://github.com/reuterma24)
+ - [Michael McElroy](https://github.com/mcmcelro)
diff --git a/Directory.Build.props b/Directory.Build.props
index 44a60ffb5c..31ae8bfbe4 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -3,11 +3,11 @@
enable
- $(MSBuildThisFileDirectory)/jellyfin.ruleset
true
+ NU1902;NU1903
diff --git a/Directory.Packages.props b/Directory.Packages.props
index 5aadeb2541..cdce608d9c 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -4,88 +4,88 @@
-
+
-
-
+
+
+
-
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
+
-
+
-
-
-
-
+
+
+
+
-
+
-
-
-
+
+
+
-
+
-
-
+
+
\ No newline at end of file
diff --git a/Emby.Naming/Common/NamingOptions.cs b/Emby.Naming/Common/NamingOptions.cs
index 333d237a24..6a662aaf55 100644
--- a/Emby.Naming/Common/NamingOptions.cs
+++ b/Emby.Naming/Common/NamingOptions.cs
@@ -238,6 +238,7 @@ namespace Emby.Naming.Common
".dsp",
".dts",
".dvf",
+ ".eac3",
".far",
".flac",
".gdm",
@@ -467,6 +468,14 @@ namespace Emby.Naming.Common
{
IsNamed = true
},
+
+ // Anime style expression
+ // "[Group][Series Name][21][1080p][FLAC][HASH]"
+ // "[Group] Series Name [04][BDRIP]"
+ new EpisodeExpression(@"(?:\[(?:[^\]]+)\]\s*)?(?\[[^\]]+\]|[^[\]]+)\s*\[(?[0-9]+)\]")
+ {
+ IsNamed = true
+ },
};
VideoExtraRules = new[]
diff --git a/Emby.Naming/Emby.Naming.csproj b/Emby.Naming/Emby.Naming.csproj
index 7eb131575d..20b32f3a62 100644
--- a/Emby.Naming/Emby.Naming.csproj
+++ b/Emby.Naming/Emby.Naming.csproj
@@ -6,7 +6,7 @@
- net8.0
+ net9.0
false
true
true
@@ -36,7 +36,7 @@
Jellyfin Contributors
Jellyfin.Naming
- 10.10.0
+ 10.11.0
https://github.com/jellyfin/jellyfin
GPL-3.0-only
diff --git a/Emby.Naming/TV/SeasonPathParser.cs b/Emby.Naming/TV/SeasonPathParser.cs
index 45b91971bf..98ee1e4b8f 100644
--- a/Emby.Naming/TV/SeasonPathParser.cs
+++ b/Emby.Naming/TV/SeasonPathParser.cs
@@ -1,43 +1,35 @@
using System;
using System.Globalization;
using System.IO;
+using System.Text.RegularExpressions;
namespace Emby.Naming.TV
{
///
/// Class to parse season paths.
///
- public static class SeasonPathParser
+ public static partial class SeasonPathParser
{
- ///
- /// A season folder must contain one of these somewhere in the name.
- ///
- private static readonly string[] _seasonFolderNames =
- {
- "season",
- "sæson",
- "temporada",
- "saison",
- "staffel",
- "series",
- "сезон",
- "stagione"
- };
+ [GeneratedRegex(@"^\s*((?(?>\d+))(?:st|nd|rd|th|\.)*(?!\s*[Ee]\d+))\s*(?:[[시즌]*|[シーズン]*|[sS](?:eason|æson|aison|taffel|eries|tagione|äsong|eizoen|easong|ezon|ezona|ezóna|ezonul)*|[tT](?:emporada)*|[kK](?:ausi)*|[Сс](?:езон)*)\s*(?.*)$")]
+ private static partial Regex ProcessPre();
- private static readonly char[] _splitChars = ['.', '_', ' ', '-'];
+ [GeneratedRegex(@"^\s*(?:[[시즌]*|[シーズン]*|[sS](?:eason|æson|aison|taffel|eries|tagione|äsong|eizoen|easong|ezon|ezona|ezóna|ezonul)*|[tT](?:emporada)*|[kK](?:ausi)*|[Сс](?:езон)*)\s*(?(?>\d+)(?!\s*[Ee]\d+))(?.*)$")]
+ private static partial Regex ProcessPost();
///
/// Attempts to parse season number from path.
///
/// Path to season.
+ /// Folder name of the parent.
/// Support special aliases when parsing.
/// Support numeric season folders when parsing.
/// Returns object.
- public static SeasonPathParserResult Parse(string path, bool supportSpecialAliases, bool supportNumericSeasonFolders)
+ public static SeasonPathParserResult Parse(string path, string? parentPath, bool supportSpecialAliases, bool supportNumericSeasonFolders)
{
var result = new SeasonPathParserResult();
+ var parentFolderName = parentPath is null ? null : new DirectoryInfo(parentPath).Name;
- var (seasonNumber, isSeasonFolder) = GetSeasonNumberFromPath(path, supportSpecialAliases, supportNumericSeasonFolders);
+ var (seasonNumber, isSeasonFolder) = GetSeasonNumberFromPath(path, parentFolderName, supportSpecialAliases, supportNumericSeasonFolders);
result.SeasonNumber = seasonNumber;
@@ -54,15 +46,24 @@ namespace Emby.Naming.TV
/// Gets the season number from path.
///
/// The path.
+ /// The parent folder name.
/// if set to true [support special aliases].
/// if set to true [support numeric season folders].
/// System.Nullable{System.Int32}.
private static (int? SeasonNumber, bool IsSeasonFolder) GetSeasonNumberFromPath(
string path,
+ string? parentFolderName,
bool supportSpecialAliases,
bool supportNumericSeasonFolders)
{
string filename = Path.GetFileName(path);
+ filename = Regex.Replace(filename, "[ ._-]", string.Empty);
+
+ if (parentFolderName is not null)
+ {
+ parentFolderName = Regex.Replace(parentFolderName, "[ ._-]", string.Empty);
+ filename = filename.Replace(parentFolderName, string.Empty, StringComparison.OrdinalIgnoreCase);
+ }
if (supportSpecialAliases)
{
@@ -85,53 +86,38 @@ namespace Emby.Naming.TV
}
}
- if (TryGetSeasonNumberFromPart(filename, out int seasonNumber))
+ if (filename.StartsWith('s'))
{
+ var testFilename = filename.AsSpan()[1..];
+
+ if (int.TryParse(testFilename, NumberStyles.Integer, CultureInfo.InvariantCulture, out var val))
+ {
+ return (val, true);
+ }
+ }
+
+ var preMatch = ProcessPre().Match(filename);
+ if (preMatch.Success)
+ {
+ return CheckMatch(preMatch);
+ }
+ else
+ {
+ var postMatch = ProcessPost().Match(filename);
+ return CheckMatch(postMatch);
+ }
+ }
+
+ private static (int? SeasonNumber, bool IsSeasonFolder) CheckMatch(Match match)
+ {
+ var numberString = match.Groups["seasonnumber"];
+ if (numberString.Success)
+ {
+ var seasonNumber = int.Parse(numberString.Value, CultureInfo.InvariantCulture);
return (seasonNumber, true);
}
- // Look for one of the season folder names
- foreach (var name in _seasonFolderNames)
- {
- if (filename.Contains(name, StringComparison.OrdinalIgnoreCase))
- {
- var result = GetSeasonNumberFromPathSubstring(filename.Replace(name, " ", StringComparison.OrdinalIgnoreCase));
- if (result.SeasonNumber.HasValue)
- {
- return result;
- }
-
- break;
- }
- }
-
- var parts = filename.Split(_splitChars, StringSplitOptions.RemoveEmptyEntries);
- foreach (var part in parts)
- {
- if (TryGetSeasonNumberFromPart(part, out seasonNumber))
- {
- return (seasonNumber, true);
- }
- }
-
- return (null, true);
- }
-
- private static bool TryGetSeasonNumberFromPart(ReadOnlySpan part, out int seasonNumber)
- {
- seasonNumber = 0;
- if (part.Length < 2 || !part.StartsWith("s", StringComparison.OrdinalIgnoreCase))
- {
- return false;
- }
-
- if (int.TryParse(part.Slice(1), NumberStyles.Integer, CultureInfo.InvariantCulture, out var value))
- {
- seasonNumber = value;
- return true;
- }
-
- return false;
+ return (null, false);
}
///
diff --git a/Emby.Naming/TV/SeriesResolver.cs b/Emby.Naming/TV/SeriesResolver.cs
index d8fa417436..c955b8a0db 100644
--- a/Emby.Naming/TV/SeriesResolver.cs
+++ b/Emby.Naming/TV/SeriesResolver.cs
@@ -12,7 +12,7 @@ namespace Emby.Naming.TV
///
/// Regex that matches strings of at least 2 characters separated by a dot or underscore.
/// Used for removing separators between words, i.e turns "The_show" into "The show" while
- /// preserving namings like "S.H.O.W".
+ /// preserving names like "S.H.O.W".
///
[GeneratedRegex(@"((?[^\._]{2,})[\._]*)|([\._](?[^\._]{2,}))")]
private static partial Regex SeriesNameRegex();
diff --git a/Emby.Naming/Video/ExtraRuleResolver.cs b/Emby.Naming/Video/ExtraRuleResolver.cs
index 3219472eff..5289065898 100644
--- a/Emby.Naming/Video/ExtraRuleResolver.cs
+++ b/Emby.Naming/Video/ExtraRuleResolver.cs
@@ -18,8 +18,9 @@ namespace Emby.Naming.Video
///
/// Path to file.
/// The naming options.
+ /// Top-level folder for the containing library.
/// Returns object.
- public static ExtraResult GetExtraInfo(string path, NamingOptions namingOptions)
+ public static ExtraResult GetExtraInfo(string path, NamingOptions namingOptions, string? libraryRoot = "")
{
var result = new ExtraResult();
@@ -69,7 +70,9 @@ namespace Emby.Naming.Video
else if (rule.RuleType == ExtraRuleType.DirectoryName)
{
var directoryName = Path.GetFileName(Path.GetDirectoryName(pathSpan));
- if (directoryName.Equals(rule.Token, StringComparison.OrdinalIgnoreCase))
+ string fullDirectory = Path.GetDirectoryName(pathSpan).ToString();
+ if (directoryName.Equals(rule.Token, StringComparison.OrdinalIgnoreCase)
+ && !string.Equals(fullDirectory, libraryRoot, StringComparison.OrdinalIgnoreCase))
{
result.ExtraType = rule.ExtraType;
result.Rule = rule;
diff --git a/Emby.Naming/Video/VideoListResolver.cs b/Emby.Naming/Video/VideoListResolver.cs
index 12bc22a6ac..a3134f3f68 100644
--- a/Emby.Naming/Video/VideoListResolver.cs
+++ b/Emby.Naming/Video/VideoListResolver.cs
@@ -27,8 +27,9 @@ namespace Emby.Naming.Video
/// The naming options.
/// Indication we should consider multi-versions of content.
/// Whether to parse the name or use the filename.
+ /// Top-level folder for the containing library.
/// Returns enumerable of which groups files together when related.
- public static IReadOnlyList Resolve(IReadOnlyList videoInfos, NamingOptions namingOptions, bool supportMultiVersion = true, bool parseName = true)
+ public static IReadOnlyList Resolve(IReadOnlyList videoInfos, NamingOptions namingOptions, bool supportMultiVersion = true, bool parseName = true, string? libraryRoot = "")
{
// Filter out all extras, otherwise they could cause stacks to not be resolved
// See the unit test TestStackedWithTrailer
@@ -65,7 +66,7 @@ namespace Emby.Naming.Video
{
var info = new VideoInfo(stack.Name)
{
- Files = stack.Files.Select(i => VideoResolver.Resolve(i, stack.IsDirectoryStack, namingOptions, parseName))
+ Files = stack.Files.Select(i => VideoResolver.Resolve(i, stack.IsDirectoryStack, namingOptions, parseName, libraryRoot))
.OfType()
.ToList()
};
diff --git a/Emby.Naming/Video/VideoResolver.cs b/Emby.Naming/Video/VideoResolver.cs
index db5bfdbf94..afbf6f8fae 100644
--- a/Emby.Naming/Video/VideoResolver.cs
+++ b/Emby.Naming/Video/VideoResolver.cs
@@ -17,10 +17,11 @@ namespace Emby.Naming.Video
/// The path.
/// The naming options.
/// Whether to parse the name or use the filename.
+ /// Top-level folder for the containing library.
/// VideoFileInfo.
- public static VideoFileInfo? ResolveDirectory(string? path, NamingOptions namingOptions, bool parseName = true)
+ public static VideoFileInfo? ResolveDirectory(string? path, NamingOptions namingOptions, bool parseName = true, string? libraryRoot = "")
{
- return Resolve(path, true, namingOptions, parseName);
+ return Resolve(path, true, namingOptions, parseName, libraryRoot);
}
///
@@ -28,10 +29,11 @@ namespace Emby.Naming.Video
///
/// The path.
/// The naming options.
+ /// Top-level folder for the containing library.
/// VideoFileInfo.
- public static VideoFileInfo? ResolveFile(string? path, NamingOptions namingOptions)
+ public static VideoFileInfo? ResolveFile(string? path, NamingOptions namingOptions, string? libraryRoot = "")
{
- return Resolve(path, false, namingOptions);
+ return Resolve(path, false, namingOptions, libraryRoot: libraryRoot);
}
///
@@ -41,9 +43,10 @@ namespace Emby.Naming.Video
/// if set to true [is folder].
/// The naming options.
/// Whether or not the name should be parsed for info.
+ /// Top-level folder for the containing library.
/// VideoFileInfo.
/// path is null.
- public static VideoFileInfo? Resolve(string? path, bool isDirectory, NamingOptions namingOptions, bool parseName = true)
+ public static VideoFileInfo? Resolve(string? path, bool isDirectory, NamingOptions namingOptions, bool parseName = true, string? libraryRoot = "")
{
if (string.IsNullOrEmpty(path))
{
@@ -75,7 +78,7 @@ namespace Emby.Naming.Video
var format3DResult = Format3DParser.Parse(path, namingOptions);
- var extraResult = ExtraRuleResolver.GetExtraInfo(path, namingOptions);
+ var extraResult = ExtraRuleResolver.GetExtraInfo(path, namingOptions, libraryRoot);
var name = Path.GetFileNameWithoutExtension(path);
diff --git a/Emby.Photos/Emby.Photos.csproj b/Emby.Photos/Emby.Photos.csproj
index 55dbe393c7..645a74aea4 100644
--- a/Emby.Photos/Emby.Photos.csproj
+++ b/Emby.Photos/Emby.Photos.csproj
@@ -19,7 +19,7 @@
- net8.0
+ net9.0
false
true
diff --git a/Emby.Server.Implementations/AppBase/BaseApplicationPaths.cs b/Emby.Server.Implementations/AppBase/BaseApplicationPaths.cs
index dc845b2d7e..f0cca9efd0 100644
--- a/Emby.Server.Implementations/AppBase/BaseApplicationPaths.cs
+++ b/Emby.Server.Implementations/AppBase/BaseApplicationPaths.cs
@@ -34,76 +34,46 @@ namespace Emby.Server.Implementations.AppBase
DataPath = Directory.CreateDirectory(Path.Combine(ProgramDataPath, "data")).FullName;
}
- ///
- /// Gets the path to the program data folder.
- ///
- /// The program data path.
+ ///
public string ProgramDataPath { get; }
///
public string WebPath { get; }
- ///
- /// Gets the path to the system folder.
- ///
- /// The path to the system folder.
+ ///
public string ProgramSystemPath { get; } = AppContext.BaseDirectory;
- ///
- /// Gets the folder path to the data directory.
- ///
- /// The data directory.
+ ///
public string DataPath { get; }
///
public string VirtualDataPath => "%AppDataPath%";
- ///
- /// Gets the image cache path.
- ///
- /// The image cache path.
+ ///
public string ImageCachePath => Path.Combine(CachePath, "images");
- ///
- /// Gets the path to the plugin directory.
- ///
- /// The plugins path.
+ ///
public string PluginsPath => Path.Combine(ProgramDataPath, "plugins");
- ///
- /// Gets the path to the plugin configurations directory.
- ///
- /// The plugin configurations path.
+ ///
public string PluginConfigurationsPath => Path.Combine(PluginsPath, "configurations");
- ///
- /// Gets the path to the log directory.
- ///
- /// The log directory path.
+ ///
public string LogDirectoryPath { get; }
- ///
- /// Gets the path to the application configuration root directory.
- ///
- /// The configuration directory path.
+ ///
public string ConfigurationDirectoryPath { get; }
- ///
- /// Gets the path to the system configuration file.
- ///
- /// The system configuration file path.
+ ///
public string SystemConfigurationFilePath => Path.Combine(ConfigurationDirectoryPath, "system.xml");
- ///
- /// Gets or sets the folder path to the cache directory.
- ///
- /// The cache directory.
+ ///
public string CachePath { get; set; }
- ///
- /// Gets the folder path to the temp directory within the cache folder.
- ///
- /// The temp directory.
+ ///
public string TempDirectory => Path.Join(Path.GetTempPath(), "jellyfin");
+
+ ///
+ public string TrickplayPath => Path.Combine(DataPath, "trickplay");
}
}
diff --git a/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs b/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs
index 9e98d5ce09..9bc3a0204b 100644
--- a/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs
+++ b/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs
@@ -4,6 +4,7 @@ using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
+using System.Threading;
using MediaBrowser.Common.Configuration;
using MediaBrowser.Common.Events;
using MediaBrowser.Common.Extensions;
@@ -19,7 +20,7 @@ namespace Emby.Server.Implementations.AppBase
public abstract class BaseConfigurationManager : IConfigurationManager
{
private readonly ConcurrentDictionary _configurations = new();
- private readonly object _configurationSyncLock = new();
+ private readonly Lock _configurationSyncLock = new();
private ConfigurationStore[] _configurationStores = Array.Empty();
private IConfigurationFactory[] _configurationFactories = Array.Empty();
diff --git a/Emby.Server.Implementations/ApplicationHost.cs b/Emby.Server.Implementations/ApplicationHost.cs
index 5292003f09..5bb75e2b95 100644
--- a/Emby.Server.Implementations/ApplicationHost.cs
+++ b/Emby.Server.Implementations/ApplicationHost.cs
@@ -35,11 +35,12 @@ using Emby.Server.Implementations.SyncPlay;
using Emby.Server.Implementations.TV;
using Emby.Server.Implementations.Updates;
using Jellyfin.Api.Helpers;
+using Jellyfin.Database.Implementations;
using Jellyfin.Drawing;
using Jellyfin.MediaEncoding.Hls.Playlist;
using Jellyfin.Networking.Manager;
using Jellyfin.Networking.Udp;
-using Jellyfin.Server.Implementations;
+using Jellyfin.Server.Implementations.Item;
using Jellyfin.Server.Implementations.MediaSegments;
using MediaBrowser.Common;
using MediaBrowser.Common.Configuration;
@@ -56,6 +57,7 @@ using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Drawing;
using MediaBrowser.Controller.Dto;
using MediaBrowser.Controller.Entities;
+using MediaBrowser.Controller.IO;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.LiveTv;
using MediaBrowser.Controller.Lyrics;
@@ -83,7 +85,6 @@ using MediaBrowser.Model.Net;
using MediaBrowser.Model.Serialization;
using MediaBrowser.Model.System;
using MediaBrowser.Model.Tasks;
-using MediaBrowser.Providers.Chapters;
using MediaBrowser.Providers.Lyric;
using MediaBrowser.Providers.Manager;
using MediaBrowser.Providers.Plugins.Tmdb;
@@ -268,6 +269,11 @@ namespace Emby.Server.Implementations
public string ExpandVirtualPath(string path)
{
+ if (path is null)
+ {
+ return null;
+ }
+
var appPaths = ApplicationPaths;
return path.Replace(appPaths.VirtualDataPath, appPaths.DataPath, StringComparison.OrdinalIgnoreCase)
@@ -492,13 +498,19 @@ namespace Emby.Server.Implementations
serviceCollection.AddSingleton();
- serviceCollection.AddSingleton();
serviceCollection.AddSingleton();
- serviceCollection.AddSingleton();
+ serviceCollection.AddSingleton();
+ serviceCollection.AddSingleton();
+ serviceCollection.AddSingleton();
+ serviceCollection.AddSingleton();
+ serviceCollection.AddSingleton();
+ serviceCollection.AddSingleton();
+ serviceCollection.AddSingleton();
serviceCollection.AddSingleton();
serviceCollection.AddSingleton();
+ serviceCollection.AddSingleton();
// TODO: Refactor to eliminate the circular dependencies here so that Lazy isn't required
serviceCollection.AddTransient(provider => new Lazy(provider.GetRequiredService));
@@ -540,8 +552,6 @@ namespace Emby.Server.Implementations
serviceCollection.AddSingleton();
- serviceCollection.AddSingleton();
-
serviceCollection.AddSingleton();
serviceCollection.AddSingleton();
@@ -565,10 +575,15 @@ namespace Emby.Server.Implementations
///
/// Create services registered with the service container that need to be initialized at application startup.
///
+ /// The configuration used to initialise the application.
/// A task representing the service initialization operation.
- public async Task InitializeServices()
+ public async Task InitializeServices(IConfiguration startupConfig)
{
- var jellyfinDb = await Resolve>().CreateDbContextAsync().ConfigureAwait(false);
+ var factory = Resolve>();
+ var provider = Resolve();
+ provider.DbContextFactory = factory;
+
+ var jellyfinDb = await factory.CreateDbContextAsync().ConfigureAwait(false);
await using (jellyfinDb.ConfigureAwait(false))
{
if ((await jellyfinDb.Database.GetPendingMigrationsAsync().ConfigureAwait(false)).Any())
@@ -579,9 +594,6 @@ namespace Emby.Server.Implementations
}
}
- ((SqliteItemRepository)Resolve()).Initialize();
- ((SqliteUserDataRepository)Resolve()).Initialize();
-
var localizationManager = (LocalizationManager)Resolve();
await localizationManager.LoadAll().ConfigureAwait(false);
@@ -607,7 +619,7 @@ namespace Emby.Server.Implementations
// Don't use an empty string password
password = string.IsNullOrWhiteSpace(password) ? null : password;
- var localCert = new X509Certificate2(path, password, X509KeyStorageFlags.UserKeySet);
+ var localCert = X509CertificateLoader.LoadPkcs12FromFile(path, password, X509KeyStorageFlags.UserKeySet);
if (!localCert.HasPrivateKey)
{
Logger.LogError("No private key included in SSL cert {CertificateLocation}.", path);
@@ -635,6 +647,7 @@ namespace Emby.Server.Implementations
BaseItem.ProviderManager = Resolve();
BaseItem.LocalizationManager = Resolve();
BaseItem.ItemRepository = Resolve();
+ BaseItem.ChapterRepository = Resolve();
BaseItem.FileSystem = Resolve();
BaseItem.UserDataManager = Resolve();
BaseItem.ChannelManager = Resolve();
diff --git a/Emby.Server.Implementations/Collections/CollectionManager.cs b/Emby.Server.Implementations/Collections/CollectionManager.cs
index e414792ba0..60f515f24d 100644
--- a/Emby.Server.Implementations/Collections/CollectionManager.cs
+++ b/Emby.Server.Implementations/Collections/CollectionManager.cs
@@ -4,7 +4,7 @@ using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
-using Jellyfin.Data.Entities;
+using Jellyfin.Database.Implementations.Entities;
using MediaBrowser.Common.Configuration;
using MediaBrowser.Controller.Collections;
using MediaBrowser.Controller.Entities;
@@ -204,7 +204,7 @@ namespace Emby.Server.Implementations.Collections
{
if (_libraryManager.GetItemById(collectionId) is not BoxSet collection)
{
- throw new ArgumentException("No collection exists with the supplied Id");
+ throw new ArgumentException("No collection exists with the supplied collectionId " + collectionId);
}
List? itemList = null;
@@ -218,7 +218,7 @@ namespace Emby.Server.Implementations.Collections
if (item is null)
{
- throw new ArgumentException("No item exists with the supplied Id");
+ throw new ArgumentException("No item exists with the supplied Id " + id);
}
if (!currentLinkedChildrenIds.Contains(id))
diff --git a/Emby.Server.Implementations/ConfigurationOptions.cs b/Emby.Server.Implementations/ConfigurationOptions.cs
index 91791a1c82..a06f6e7fe9 100644
--- a/Emby.Server.Implementations/ConfigurationOptions.cs
+++ b/Emby.Server.Implementations/ConfigurationOptions.cs
@@ -17,7 +17,6 @@ namespace Emby.Server.Implementations
{ DefaultRedirectKey, "web/" },
{ FfmpegProbeSizeKey, "1G" },
{ FfmpegAnalyzeDurationKey, "200M" },
- { PlaylistsAllowDuplicatesKey, bool.FalseString },
{ BindToUnixSocketKey, bool.FalseString },
{ SqliteCacheSizeKey, "20000" },
{ FfmpegSkipValidationKey, bool.FalseString },
diff --git a/Emby.Server.Implementations/Data/BaseSqliteRepository.cs b/Emby.Server.Implementations/Data/BaseSqliteRepository.cs
deleted file mode 100644
index 8ed72c2082..0000000000
--- a/Emby.Server.Implementations/Data/BaseSqliteRepository.cs
+++ /dev/null
@@ -1,269 +0,0 @@
-#nullable disable
-
-#pragma warning disable CS1591
-
-using System;
-using System.Collections.Generic;
-using System.Threading;
-using Jellyfin.Extensions;
-using Microsoft.Data.Sqlite;
-using Microsoft.Extensions.Logging;
-
-namespace Emby.Server.Implementations.Data
-{
- public abstract class BaseSqliteRepository : IDisposable
- {
- private bool _disposed = false;
- private SemaphoreSlim _writeLock = new SemaphoreSlim(1, 1);
- private SqliteConnection _writeConnection;
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// The logger.
- protected BaseSqliteRepository(ILogger logger)
- {
- Logger = logger;
- }
-
- ///
- /// Gets or sets the path to the DB file.
- ///
- protected string DbFilePath { get; set; }
-
- ///
- /// Gets the logger.
- ///
- /// The logger.
- protected ILogger Logger { get; }
-
- ///
- /// Gets the cache size.
- ///
- /// The cache size or null.
- protected virtual int? CacheSize => null;
-
- ///
- /// Gets the locking mode. .
- ///
- protected virtual string LockingMode => "NORMAL";
-
- ///
- /// Gets the journal mode. .
- ///
- /// The journal mode.
- protected virtual string JournalMode => "WAL";
-
- ///
- /// Gets the journal size limit. .
- /// The default (-1) is overridden to prevent unconstrained WAL size, as reported by users.
- ///
- /// The journal size limit.
- protected virtual int? JournalSizeLimit => 134_217_728; // 128MiB
-
- ///
- /// Gets the page size.
- ///
- /// The page size or null.
- protected virtual int? PageSize => null;
-
- ///
- /// Gets the temp store mode.
- ///
- /// The temp store mode.
- ///
- protected virtual TempStoreMode TempStore => TempStoreMode.Memory;
-
- ///
- /// Gets the synchronous mode.
- ///
- /// The synchronous mode or null.
- ///
- protected virtual SynchronousMode? Synchronous => SynchronousMode.Normal;
-
- public virtual void Initialize()
- {
- // Configuration and pragmas can affect VACUUM so it needs to be last.
- using (var connection = GetConnection())
- {
- connection.Execute("VACUUM");
- }
- }
-
- protected ManagedConnection GetConnection(bool readOnly = false)
- {
- if (!readOnly)
- {
- _writeLock.Wait();
- if (_writeConnection is not null)
- {
- return new ManagedConnection(_writeConnection, _writeLock);
- }
-
- var writeConnection = new SqliteConnection($"Filename={DbFilePath};Pooling=False");
- writeConnection.Open();
-
- if (CacheSize.HasValue)
- {
- writeConnection.Execute("PRAGMA cache_size=" + CacheSize.Value);
- }
-
- if (!string.IsNullOrWhiteSpace(LockingMode))
- {
- writeConnection.Execute("PRAGMA locking_mode=" + LockingMode);
- }
-
- if (!string.IsNullOrWhiteSpace(JournalMode))
- {
- writeConnection.Execute("PRAGMA journal_mode=" + JournalMode);
- }
-
- if (JournalSizeLimit.HasValue)
- {
- writeConnection.Execute("PRAGMA journal_size_limit=" + JournalSizeLimit.Value);
- }
-
- if (Synchronous.HasValue)
- {
- writeConnection.Execute("PRAGMA synchronous=" + (int)Synchronous.Value);
- }
-
- if (PageSize.HasValue)
- {
- writeConnection.Execute("PRAGMA page_size=" + PageSize.Value);
- }
-
- writeConnection.Execute("PRAGMA temp_store=" + (int)TempStore);
-
- return new ManagedConnection(_writeConnection = writeConnection, _writeLock);
- }
-
- var connection = new SqliteConnection($"Filename={DbFilePath};Mode=ReadOnly");
- connection.Open();
-
- if (CacheSize.HasValue)
- {
- connection.Execute("PRAGMA cache_size=" + CacheSize.Value);
- }
-
- if (!string.IsNullOrWhiteSpace(LockingMode))
- {
- connection.Execute("PRAGMA locking_mode=" + LockingMode);
- }
-
- if (!string.IsNullOrWhiteSpace(JournalMode))
- {
- connection.Execute("PRAGMA journal_mode=" + JournalMode);
- }
-
- if (JournalSizeLimit.HasValue)
- {
- connection.Execute("PRAGMA journal_size_limit=" + JournalSizeLimit.Value);
- }
-
- if (Synchronous.HasValue)
- {
- connection.Execute("PRAGMA synchronous=" + (int)Synchronous.Value);
- }
-
- if (PageSize.HasValue)
- {
- connection.Execute("PRAGMA page_size=" + PageSize.Value);
- }
-
- connection.Execute("PRAGMA temp_store=" + (int)TempStore);
-
- return new ManagedConnection(connection, null);
- }
-
- public SqliteCommand PrepareStatement(ManagedConnection connection, string sql)
- {
- var command = connection.CreateCommand();
- command.CommandText = sql;
- return command;
- }
-
- protected bool TableExists(ManagedConnection connection, string name)
- {
- using var statement = PrepareStatement(connection, "select DISTINCT tbl_name from sqlite_master");
- foreach (var row in statement.ExecuteQuery())
- {
- if (string.Equals(name, row.GetString(0), StringComparison.OrdinalIgnoreCase))
- {
- return true;
- }
- }
-
- return false;
- }
-
- protected List GetColumnNames(ManagedConnection connection, string table)
- {
- var columnNames = new List();
-
- foreach (var row in connection.Query("PRAGMA table_info(" + table + ")"))
- {
- if (row.TryGetString(1, out var columnName))
- {
- columnNames.Add(columnName);
- }
- }
-
- return columnNames;
- }
-
- protected void AddColumn(ManagedConnection connection, string table, string columnName, string type, List existingColumnNames)
- {
- if (existingColumnNames.Contains(columnName, StringComparison.OrdinalIgnoreCase))
- {
- return;
- }
-
- connection.Execute("alter table " + table + " add column " + columnName + " " + type + " NULL");
- }
-
- protected void CheckDisposed()
- {
- ObjectDisposedException.ThrowIf(_disposed, this);
- }
-
- ///
- public void Dispose()
- {
- Dispose(true);
- GC.SuppressFinalize(this);
- }
-
- ///
- /// Releases unmanaged and - optionally - managed resources.
- ///
- /// true to release both managed and unmanaged resources; false to release only unmanaged resources.
- protected virtual void Dispose(bool dispose)
- {
- if (_disposed)
- {
- return;
- }
-
- if (dispose)
- {
- _writeLock.Wait();
- try
- {
- _writeConnection.Dispose();
- }
- finally
- {
- _writeLock.Release();
- }
-
- _writeLock.Dispose();
- }
-
- _writeConnection = null;
- _writeLock = null;
-
- _disposed = true;
- }
- }
-}
diff --git a/Emby.Server.Implementations/Data/CleanDatabaseScheduledTask.cs b/Emby.Server.Implementations/Data/CleanDatabaseScheduledTask.cs
index 4516b89dc2..9a80eafe50 100644
--- a/Emby.Server.Implementations/Data/CleanDatabaseScheduledTask.cs
+++ b/Emby.Server.Implementations/Data/CleanDatabaseScheduledTask.cs
@@ -1,66 +1,119 @@
#pragma warning disable CS1591
using System;
+using System.IO;
+using System.Linq;
using System.Threading;
using System.Threading.Tasks;
+using Jellyfin.Database.Implementations;
using MediaBrowser.Controller.Entities;
+using MediaBrowser.Controller.IO;
using MediaBrowser.Controller.Library;
+using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
-namespace Emby.Server.Implementations.Data
+namespace Emby.Server.Implementations.Data;
+
+public class CleanDatabaseScheduledTask : ILibraryPostScanTask
{
- public class CleanDatabaseScheduledTask : ILibraryPostScanTask
+ private readonly ILibraryManager _libraryManager;
+ private readonly ILogger _logger;
+ private readonly IDbContextFactory _dbProvider;
+ private readonly IPathManager _pathManager;
+
+ public CleanDatabaseScheduledTask(
+ ILibraryManager libraryManager,
+ ILogger logger,
+ IDbContextFactory dbProvider,
+ IPathManager pathManager)
{
- private readonly ILibraryManager _libraryManager;
- private readonly ILogger _logger;
+ _libraryManager = libraryManager;
+ _logger = logger;
+ _dbProvider = dbProvider;
+ _pathManager = pathManager;
+ }
- public CleanDatabaseScheduledTask(ILibraryManager libraryManager, ILogger logger)
- {
- _libraryManager = libraryManager;
- _logger = logger;
- }
+ public async Task Run(IProgress progress, CancellationToken cancellationToken)
+ {
+ await CleanDeadItems(cancellationToken, progress).ConfigureAwait(false);
+ }
- public Task Run(IProgress progress, CancellationToken cancellationToken)
+ private async Task CleanDeadItems(CancellationToken cancellationToken, IProgress progress)
+ {
+ var itemIds = _libraryManager.GetItemIds(new InternalItemsQuery
{
- CleanDeadItems(cancellationToken, progress);
- return Task.CompletedTask;
- }
+ HasDeadParentId = true
+ });
- private void CleanDeadItems(CancellationToken cancellationToken, IProgress progress)
+ var numComplete = 0;
+ var numItems = itemIds.Count + 1;
+
+ _logger.LogDebug("Cleaning {Number} items with dead parent links", numItems);
+
+ foreach (var itemId in itemIds)
{
- var itemIds = _libraryManager.GetItemIds(new InternalItemsQuery
+ cancellationToken.ThrowIfCancellationRequested();
+
+ var item = _libraryManager.GetItemById(itemId);
+ if (item is not null)
{
- HasDeadParentId = true
- });
+ _logger.LogInformation("Cleaning item {Item} type: {Type} path: {Path}", item.Name, item.GetType().Name, item.Path ?? string.Empty);
- var numComplete = 0;
- var numItems = itemIds.Count;
-
- _logger.LogDebug("Cleaning {0} items with dead parent links", numItems);
-
- foreach (var itemId in itemIds)
- {
- cancellationToken.ThrowIfCancellationRequested();
-
- var item = _libraryManager.GetItemById(itemId);
-
- if (item is not null)
+ foreach (var mediaSource in item.GetMediaSources(false))
{
- _logger.LogInformation("Cleaning item {0} type: {1} path: {2}", item.Name, item.GetType().Name, item.Path ?? string.Empty);
-
- _libraryManager.DeleteItem(item, new DeleteOptions
+ // Delete extracted subtitles
+ try
{
- DeleteFileLocation = false
- });
+ var subtitleFolder = _pathManager.GetSubtitleFolderPath(mediaSource.Id);
+ if (Directory.Exists(subtitleFolder))
+ {
+ Directory.Delete(subtitleFolder, true);
+ }
+ }
+ catch (Exception e)
+ {
+ _logger.LogWarning("Failed to remove subtitle cache folder for {Item}: {Exception}", item.Id, e.Message);
+ }
+
+ // Delete extracted attachments
+ try
+ {
+ var attachmentFolder = _pathManager.GetAttachmentFolderPath(mediaSource.Id);
+ if (Directory.Exists(attachmentFolder))
+ {
+ Directory.Delete(attachmentFolder, true);
+ }
+ }
+ catch (Exception e)
+ {
+ _logger.LogWarning("Failed to remove attachment cache folder for {Item}: {Exception}", item.Id, e.Message);
+ }
}
- numComplete++;
- double percent = numComplete;
- percent /= numItems;
- progress.Report(percent * 100);
+ // Delete item
+ _libraryManager.DeleteItem(item, new DeleteOptions
+ {
+ DeleteFileLocation = false
+ });
}
- progress.Report(100);
+ numComplete++;
+ double percent = numComplete;
+ percent /= numItems;
+ progress.Report(percent * 100);
}
+
+ var context = await _dbProvider.CreateDbContextAsync(cancellationToken).ConfigureAwait(false);
+ await using (context.ConfigureAwait(false))
+ {
+ var transaction = await context.Database.BeginTransactionAsync(cancellationToken).ConfigureAwait(false);
+ await using (transaction.ConfigureAwait(false))
+ {
+ await context.ItemValues.Where(e => e.BaseItemsMap!.Count == 0).ExecuteDeleteAsync(cancellationToken).ConfigureAwait(false);
+ await transaction.CommitAsync(cancellationToken).ConfigureAwait(false);
+ }
+ }
+
+ progress.Report(100);
}
}
diff --git a/Emby.Server.Implementations/Data/ItemTypeLookup.cs b/Emby.Server.Implementations/Data/ItemTypeLookup.cs
new file mode 100644
index 0000000000..82c0a8b6c5
--- /dev/null
+++ b/Emby.Server.Implementations/Data/ItemTypeLookup.cs
@@ -0,0 +1,64 @@
+using System.Collections.Frozen;
+using System.Collections.Generic;
+using System.Threading.Channels;
+using Emby.Server.Implementations.Playlists;
+using Jellyfin.Data.Enums;
+using MediaBrowser.Controller.Entities;
+using MediaBrowser.Controller.Entities.Audio;
+using MediaBrowser.Controller.Entities.Movies;
+using MediaBrowser.Controller.Entities.TV;
+using MediaBrowser.Controller.LiveTv;
+using MediaBrowser.Controller.Persistence;
+using MediaBrowser.Controller.Playlists;
+
+namespace Emby.Server.Implementations.Data;
+
+///
+public class ItemTypeLookup : IItemTypeLookup
+{
+ ///
+ public IReadOnlyList MusicGenreTypes { get; } = [
+ typeof(Audio).FullName!,
+ typeof(MusicVideo).FullName!,
+ typeof(MusicAlbum).FullName!,
+ typeof(MusicArtist).FullName!,
+ ];
+
+ ///
+ public IReadOnlyDictionary BaseItemKindNames { get; } = new Dictionary()
+ {
+ { BaseItemKind.AggregateFolder, typeof(AggregateFolder).FullName! },
+ { BaseItemKind.Audio, typeof(Audio).FullName! },
+ { BaseItemKind.AudioBook, typeof(AudioBook).FullName! },
+ { BaseItemKind.BasePluginFolder, typeof(BasePluginFolder).FullName! },
+ { BaseItemKind.Book, typeof(Book).FullName! },
+ { BaseItemKind.BoxSet, typeof(BoxSet).FullName! },
+ { BaseItemKind.Channel, typeof(Channel).FullName! },
+ { BaseItemKind.CollectionFolder, typeof(CollectionFolder).FullName! },
+ { BaseItemKind.Episode, typeof(Episode).FullName! },
+ { BaseItemKind.Folder, typeof(Folder).FullName! },
+ { BaseItemKind.Genre, typeof(Genre).FullName! },
+ { BaseItemKind.Movie, typeof(Movie).FullName! },
+ { BaseItemKind.LiveTvChannel, typeof(LiveTvChannel).FullName! },
+ { BaseItemKind.LiveTvProgram, typeof(LiveTvProgram).FullName! },
+ { BaseItemKind.MusicAlbum, typeof(MusicAlbum).FullName! },
+ { BaseItemKind.MusicArtist, typeof(MusicArtist).FullName! },
+ { BaseItemKind.MusicGenre, typeof(MusicGenre).FullName! },
+ { BaseItemKind.MusicVideo, typeof(MusicVideo).FullName! },
+ { BaseItemKind.Person, typeof(Person).FullName! },
+ { BaseItemKind.Photo, typeof(Photo).FullName! },
+ { BaseItemKind.PhotoAlbum, typeof(PhotoAlbum).FullName! },
+ { BaseItemKind.Playlist, typeof(Playlist).FullName! },
+ { BaseItemKind.PlaylistsFolder, typeof(PlaylistsFolder).FullName! },
+ { BaseItemKind.Season, typeof(Season).FullName! },
+ { BaseItemKind.Series, typeof(Series).FullName! },
+ { BaseItemKind.Studio, typeof(Studio).FullName! },
+ { BaseItemKind.Trailer, typeof(Trailer).FullName! },
+ { BaseItemKind.TvChannel, typeof(LiveTvChannel).FullName! },
+ { BaseItemKind.TvProgram, typeof(LiveTvProgram).FullName! },
+ { BaseItemKind.UserRootFolder, typeof(UserRootFolder).FullName! },
+ { BaseItemKind.UserView, typeof(UserView).FullName! },
+ { BaseItemKind.Video, typeof(Video).FullName! },
+ { BaseItemKind.Year, typeof(Year).FullName! }
+ }.ToFrozenDictionary();
+}
diff --git a/Emby.Server.Implementations/Data/ManagedConnection.cs b/Emby.Server.Implementations/Data/ManagedConnection.cs
deleted file mode 100644
index 860950b303..0000000000
--- a/Emby.Server.Implementations/Data/ManagedConnection.cs
+++ /dev/null
@@ -1,62 +0,0 @@
-#pragma warning disable CS1591
-
-using System;
-using System.Collections.Generic;
-using System.Threading;
-using Microsoft.Data.Sqlite;
-
-namespace Emby.Server.Implementations.Data;
-
-public sealed class ManagedConnection : IDisposable
-{
- private readonly SemaphoreSlim? _writeLock;
-
- private SqliteConnection _db;
-
- private bool _disposed = false;
-
- public ManagedConnection(SqliteConnection db, SemaphoreSlim? writeLock)
- {
- _db = db;
- _writeLock = writeLock;
- }
-
- public SqliteTransaction BeginTransaction()
- => _db.BeginTransaction();
-
- public SqliteCommand CreateCommand()
- => _db.CreateCommand();
-
- public void Execute(string commandText)
- => _db.Execute(commandText);
-
- public SqliteCommand PrepareStatement(string sql)
- => _db.PrepareStatement(sql);
-
- public IEnumerable Query(string commandText)
- => _db.Query(commandText);
-
- public void Dispose()
- {
- if (_disposed)
- {
- return;
- }
-
- if (_writeLock is null)
- {
- // Read connections are managed with an internal pool
- _db.Dispose();
- }
- else
- {
- // Write lock is managed by BaseSqliteRepository
- // Don't dispose here
- _writeLock.Release();
- }
-
- _db = null!;
-
- _disposed = true;
- }
-}
diff --git a/Emby.Server.Implementations/Data/SqliteExtensions.cs b/Emby.Server.Implementations/Data/SqliteExtensions.cs
index 25ef57d271..0efef4dedc 100644
--- a/Emby.Server.Implementations/Data/SqliteExtensions.cs
+++ b/Emby.Server.Implementations/Data/SqliteExtensions.cs
@@ -127,8 +127,16 @@ namespace Emby.Server.Implementations.Data
return false;
}
- result = reader.GetGuid(index);
- return true;
+ try
+ {
+ result = reader.GetGuid(index);
+ return true;
+ }
+ catch
+ {
+ result = Guid.Empty;
+ return false;
+ }
}
public static bool TryGetString(this SqliteDataReader reader, int index, out string result)
diff --git a/Emby.Server.Implementations/Data/SqliteItemRepository.cs b/Emby.Server.Implementations/Data/SqliteItemRepository.cs
deleted file mode 100644
index 3477194cf7..0000000000
--- a/Emby.Server.Implementations/Data/SqliteItemRepository.cs
+++ /dev/null
@@ -1,5971 +0,0 @@
-#nullable disable
-
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Globalization;
-using System.IO;
-using System.Linq;
-using System.Runtime.CompilerServices;
-using System.Text;
-using System.Text.Json;
-using System.Threading;
-using Emby.Server.Implementations.Playlists;
-using Jellyfin.Data.Enums;
-using Jellyfin.Extensions;
-using Jellyfin.Extensions.Json;
-using MediaBrowser.Controller;
-using MediaBrowser.Controller.Channels;
-using MediaBrowser.Controller.Configuration;
-using MediaBrowser.Controller.Drawing;
-using MediaBrowser.Controller.Entities;
-using MediaBrowser.Controller.Entities.Audio;
-using MediaBrowser.Controller.Entities.Movies;
-using MediaBrowser.Controller.Entities.TV;
-using MediaBrowser.Controller.Extensions;
-using MediaBrowser.Controller.LiveTv;
-using MediaBrowser.Controller.Persistence;
-using MediaBrowser.Controller.Playlists;
-using MediaBrowser.Model.Dto;
-using MediaBrowser.Model.Entities;
-using MediaBrowser.Model.Globalization;
-using MediaBrowser.Model.LiveTv;
-using MediaBrowser.Model.Querying;
-using Microsoft.Data.Sqlite;
-using Microsoft.Extensions.Configuration;
-using Microsoft.Extensions.Logging;
-
-namespace Emby.Server.Implementations.Data
-{
- ///
- /// Class SQLiteItemRepository.
- ///
- public class SqliteItemRepository : BaseSqliteRepository, IItemRepository
- {
- private const string FromText = " from TypedBaseItems A";
- private const string ChaptersTableName = "Chapters2";
-
- private const string SaveItemCommandText =
- @"replace into TypedBaseItems
- (guid,type,data,Path,StartDate,EndDate,ChannelId,IsMovie,IsSeries,EpisodeTitle,IsRepeat,CommunityRating,CustomRating,IndexNumber,IsLocked,Name,OfficialRating,MediaType,Overview,ParentIndexNumber,PremiereDate,ProductionYear,ParentId,Genres,InheritedParentalRatingValue,SortName,ForcedSortName,RunTimeTicks,Size,DateCreated,DateModified,PreferredMetadataLanguage,PreferredMetadataCountryCode,Width,Height,DateLastRefreshed,DateLastSaved,IsInMixedFolder,LockedFields,Studios,Audio,ExternalServiceId,Tags,IsFolder,UnratedType,TopParentId,TrailerTypes,CriticRating,CleanName,PresentationUniqueKey,OriginalTitle,PrimaryVersionId,DateLastMediaAdded,Album,LUFS,NormalizationGain,IsVirtualItem,SeriesName,UserDataKey,SeasonName,SeasonId,SeriesId,ExternalSeriesId,Tagline,ProviderIds,Images,ProductionLocations,ExtraIds,TotalBitrate,ExtraType,Artists,AlbumArtists,ExternalId,SeriesPresentationUniqueKey,ShowId,OwnerId)
- values (@guid,@type,@data,@Path,@StartDate,@EndDate,@ChannelId,@IsMovie,@IsSeries,@EpisodeTitle,@IsRepeat,@CommunityRating,@CustomRating,@IndexNumber,@IsLocked,@Name,@OfficialRating,@MediaType,@Overview,@ParentIndexNumber,@PremiereDate,@ProductionYear,@ParentId,@Genres,@InheritedParentalRatingValue,@SortName,@ForcedSortName,@RunTimeTicks,@Size,@DateCreated,@DateModified,@PreferredMetadataLanguage,@PreferredMetadataCountryCode,@Width,@Height,@DateLastRefreshed,@DateLastSaved,@IsInMixedFolder,@LockedFields,@Studios,@Audio,@ExternalServiceId,@Tags,@IsFolder,@UnratedType,@TopParentId,@TrailerTypes,@CriticRating,@CleanName,@PresentationUniqueKey,@OriginalTitle,@PrimaryVersionId,@DateLastMediaAdded,@Album,@LUFS,@NormalizationGain,@IsVirtualItem,@SeriesName,@UserDataKey,@SeasonName,@SeasonId,@SeriesId,@ExternalSeriesId,@Tagline,@ProviderIds,@Images,@ProductionLocations,@ExtraIds,@TotalBitrate,@ExtraType,@Artists,@AlbumArtists,@ExternalId,@SeriesPresentationUniqueKey,@ShowId,@OwnerId)";
-
- private readonly IServerConfigurationManager _config;
- private readonly IServerApplicationHost _appHost;
- private readonly ILocalizationManager _localization;
- // TODO: Remove this dependency. GetImageCacheTag() is the only method used and it can be converted to a static helper method
- private readonly IImageProcessor _imageProcessor;
-
- private readonly TypeMapper _typeMapper;
- private readonly JsonSerializerOptions _jsonOptions;
-
- private readonly ItemFields[] _allItemFields = Enum.GetValues();
-
- private static readonly string[] _retrieveItemColumns =
- {
- "type",
- "data",
- "StartDate",
- "EndDate",
- "ChannelId",
- "IsMovie",
- "IsSeries",
- "EpisodeTitle",
- "IsRepeat",
- "CommunityRating",
- "CustomRating",
- "IndexNumber",
- "IsLocked",
- "PreferredMetadataLanguage",
- "PreferredMetadataCountryCode",
- "Width",
- "Height",
- "DateLastRefreshed",
- "Name",
- "Path",
- "PremiereDate",
- "Overview",
- "ParentIndexNumber",
- "ProductionYear",
- "OfficialRating",
- "ForcedSortName",
- "RunTimeTicks",
- "Size",
- "DateCreated",
- "DateModified",
- "guid",
- "Genres",
- "ParentId",
- "Audio",
- "ExternalServiceId",
- "IsInMixedFolder",
- "DateLastSaved",
- "LockedFields",
- "Studios",
- "Tags",
- "TrailerTypes",
- "OriginalTitle",
- "PrimaryVersionId",
- "DateLastMediaAdded",
- "Album",
- "LUFS",
- "NormalizationGain",
- "CriticRating",
- "IsVirtualItem",
- "SeriesName",
- "SeasonName",
- "SeasonId",
- "SeriesId",
- "PresentationUniqueKey",
- "InheritedParentalRatingValue",
- "ExternalSeriesId",
- "Tagline",
- "ProviderIds",
- "Images",
- "ProductionLocations",
- "ExtraIds",
- "TotalBitrate",
- "ExtraType",
- "Artists",
- "AlbumArtists",
- "ExternalId",
- "SeriesPresentationUniqueKey",
- "ShowId",
- "OwnerId"
- };
-
- private static readonly string _retrieveItemColumnsSelectQuery = $"select {string.Join(',', _retrieveItemColumns)} from TypedBaseItems where guid = @guid";
-
- private static readonly string[] _mediaStreamSaveColumns =
- {
- "ItemId",
- "StreamIndex",
- "StreamType",
- "Codec",
- "Language",
- "ChannelLayout",
- "Profile",
- "AspectRatio",
- "Path",
- "IsInterlaced",
- "BitRate",
- "Channels",
- "SampleRate",
- "IsDefault",
- "IsForced",
- "IsExternal",
- "Height",
- "Width",
- "AverageFrameRate",
- "RealFrameRate",
- "Level",
- "PixelFormat",
- "BitDepth",
- "IsAnamorphic",
- "RefFrames",
- "CodecTag",
- "Comment",
- "NalLengthSize",
- "IsAvc",
- "Title",
- "TimeBase",
- "CodecTimeBase",
- "ColorPrimaries",
- "ColorSpace",
- "ColorTransfer",
- "DvVersionMajor",
- "DvVersionMinor",
- "DvProfile",
- "DvLevel",
- "RpuPresentFlag",
- "ElPresentFlag",
- "BlPresentFlag",
- "DvBlSignalCompatibilityId",
- "IsHearingImpaired",
- "Rotation"
- };
-
- private static readonly string _mediaStreamSaveColumnsInsertQuery =
- $"insert into mediastreams ({string.Join(',', _mediaStreamSaveColumns)}) values ";
-
- private static readonly string _mediaStreamSaveColumnsSelectQuery =
- $"select {string.Join(',', _mediaStreamSaveColumns)} from mediastreams where ItemId=@ItemId";
-
- private static readonly string[] _mediaAttachmentSaveColumns =
- {
- "ItemId",
- "AttachmentIndex",
- "Codec",
- "CodecTag",
- "Comment",
- "Filename",
- "MIMEType"
- };
-
- private static readonly string _mediaAttachmentSaveColumnsSelectQuery =
- $"select {string.Join(',', _mediaAttachmentSaveColumns)} from mediaattachments where ItemId=@ItemId";
-
- private static readonly string _mediaAttachmentInsertPrefix = BuildMediaAttachmentInsertPrefix();
-
- private static readonly BaseItemKind[] _programTypes = new[]
- {
- BaseItemKind.Program,
- BaseItemKind.TvChannel,
- BaseItemKind.LiveTvProgram,
- BaseItemKind.LiveTvChannel
- };
-
- private static readonly BaseItemKind[] _programExcludeParentTypes = new[]
- {
- BaseItemKind.Series,
- BaseItemKind.Season,
- BaseItemKind.MusicAlbum,
- BaseItemKind.MusicArtist,
- BaseItemKind.PhotoAlbum
- };
-
- private static readonly BaseItemKind[] _serviceTypes = new[]
- {
- BaseItemKind.TvChannel,
- BaseItemKind.LiveTvChannel
- };
-
- private static readonly BaseItemKind[] _startDateTypes = new[]
- {
- BaseItemKind.Program,
- BaseItemKind.LiveTvProgram
- };
-
- private static readonly BaseItemKind[] _seriesTypes = new[]
- {
- BaseItemKind.Book,
- BaseItemKind.AudioBook,
- BaseItemKind.Episode,
- BaseItemKind.Season
- };
-
- private static readonly BaseItemKind[] _artistExcludeParentTypes = new[]
- {
- BaseItemKind.Series,
- BaseItemKind.Season,
- BaseItemKind.PhotoAlbum
- };
-
- private static readonly BaseItemKind[] _artistsTypes = new[]
- {
- BaseItemKind.Audio,
- BaseItemKind.MusicAlbum,
- BaseItemKind.MusicVideo,
- BaseItemKind.AudioBook
- };
-
- private static readonly Dictionary _baseItemKindNames = new()
- {
- { BaseItemKind.AggregateFolder, typeof(AggregateFolder).FullName },
- { BaseItemKind.Audio, typeof(Audio).FullName },
- { BaseItemKind.AudioBook, typeof(AudioBook).FullName },
- { BaseItemKind.BasePluginFolder, typeof(BasePluginFolder).FullName },
- { BaseItemKind.Book, typeof(Book).FullName },
- { BaseItemKind.BoxSet, typeof(BoxSet).FullName },
- { BaseItemKind.Channel, typeof(Channel).FullName },
- { BaseItemKind.CollectionFolder, typeof(CollectionFolder).FullName },
- { BaseItemKind.Episode, typeof(Episode).FullName },
- { BaseItemKind.Folder, typeof(Folder).FullName },
- { BaseItemKind.Genre, typeof(Genre).FullName },
- { BaseItemKind.Movie, typeof(Movie).FullName },
- { BaseItemKind.LiveTvChannel, typeof(LiveTvChannel).FullName },
- { BaseItemKind.LiveTvProgram, typeof(LiveTvProgram).FullName },
- { BaseItemKind.MusicAlbum, typeof(MusicAlbum).FullName },
- { BaseItemKind.MusicArtist, typeof(MusicArtist).FullName },
- { BaseItemKind.MusicGenre, typeof(MusicGenre).FullName },
- { BaseItemKind.MusicVideo, typeof(MusicVideo).FullName },
- { BaseItemKind.Person, typeof(Person).FullName },
- { BaseItemKind.Photo, typeof(Photo).FullName },
- { BaseItemKind.PhotoAlbum, typeof(PhotoAlbum).FullName },
- { BaseItemKind.Playlist, typeof(Playlist).FullName },
- { BaseItemKind.PlaylistsFolder, typeof(PlaylistsFolder).FullName },
- { BaseItemKind.Season, typeof(Season).FullName },
- { BaseItemKind.Series, typeof(Series).FullName },
- { BaseItemKind.Studio, typeof(Studio).FullName },
- { BaseItemKind.Trailer, typeof(Trailer).FullName },
- { BaseItemKind.TvChannel, typeof(LiveTvChannel).FullName },
- { BaseItemKind.TvProgram, typeof(LiveTvProgram).FullName },
- { BaseItemKind.UserRootFolder, typeof(UserRootFolder).FullName },
- { BaseItemKind.UserView, typeof(UserView).FullName },
- { BaseItemKind.Video, typeof(Video).FullName },
- { BaseItemKind.Year, typeof(Year).FullName }
- };
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// Instance of the interface.
- /// Instance of the interface.
- /// Instance of the interface.
- /// Instance of the interface.
- /// Instance of the interface.
- /// Instance of the interface.
- /// config is null.
- public SqliteItemRepository(
- IServerConfigurationManager config,
- IServerApplicationHost appHost,
- ILogger logger,
- ILocalizationManager localization,
- IImageProcessor imageProcessor,
- IConfiguration configuration)
- : base(logger)
- {
- _config = config;
- _appHost = appHost;
- _localization = localization;
- _imageProcessor = imageProcessor;
-
- _typeMapper = new TypeMapper();
- _jsonOptions = JsonDefaults.Options;
-
- DbFilePath = Path.Combine(_config.ApplicationPaths.DataPath, "library.db");
-
- CacheSize = configuration.GetSqliteCacheSize();
- }
-
- ///
- protected override int? CacheSize { get; }
-
- ///
- protected override TempStoreMode TempStore => TempStoreMode.Memory;
-
- ///
- /// Opens the connection to the database.
- ///
- public override void Initialize()
- {
- base.Initialize();
-
- const string CreateMediaStreamsTableCommand
- = "create table if not exists mediastreams (ItemId GUID, StreamIndex INT, StreamType TEXT, Codec TEXT, Language TEXT, ChannelLayout TEXT, Profile TEXT, AspectRatio TEXT, Path TEXT, IsInterlaced BIT, BitRate INT NULL, Channels INT NULL, SampleRate INT NULL, IsDefault BIT, IsForced BIT, IsExternal BIT, Height INT NULL, Width INT NULL, AverageFrameRate FLOAT NULL, RealFrameRate FLOAT NULL, Level FLOAT NULL, PixelFormat TEXT, BitDepth INT NULL, IsAnamorphic BIT NULL, RefFrames INT NULL, CodecTag TEXT NULL, Comment TEXT NULL, NalLengthSize TEXT NULL, IsAvc BIT NULL, Title TEXT NULL, TimeBase TEXT NULL, CodecTimeBase TEXT NULL, ColorPrimaries TEXT NULL, ColorSpace TEXT NULL, ColorTransfer TEXT NULL, DvVersionMajor INT NULL, DvVersionMinor INT NULL, DvProfile INT NULL, DvLevel INT NULL, RpuPresentFlag INT NULL, ElPresentFlag INT NULL, BlPresentFlag INT NULL, DvBlSignalCompatibilityId INT NULL, IsHearingImpaired BIT NULL, Rotation INT NULL, PRIMARY KEY (ItemId, StreamIndex))";
-
- const string CreateMediaAttachmentsTableCommand
- = "create table if not exists mediaattachments (ItemId GUID, AttachmentIndex INT, Codec TEXT, CodecTag TEXT NULL, Comment TEXT NULL, Filename TEXT NULL, MIMEType TEXT NULL, PRIMARY KEY (ItemId, AttachmentIndex))";
-
- string[] queries =
- {
- "create table if not exists TypedBaseItems (guid GUID primary key NOT NULL, type TEXT NOT NULL, data BLOB NULL, ParentId GUID NULL, Path TEXT NULL)",
-
- "create table if not exists AncestorIds (ItemId GUID NOT NULL, AncestorId GUID NOT NULL, AncestorIdText TEXT NOT NULL, PRIMARY KEY (ItemId, AncestorId))",
- "create index if not exists idx_AncestorIds1 on AncestorIds(AncestorId)",
- "create index if not exists idx_AncestorIds5 on AncestorIds(AncestorIdText,ItemId)",
-
- "create table if not exists ItemValues (ItemId GUID NOT NULL, Type INT NOT NULL, Value TEXT NOT NULL, CleanValue TEXT NOT NULL)",
-
- "create table if not exists People (ItemId GUID, Name TEXT NOT NULL, Role TEXT, PersonType TEXT, SortOrder int, ListOrder int)",
-
- "drop index if exists idxPeopleItemId",
- "create index if not exists idxPeopleItemId1 on People(ItemId,ListOrder)",
- "create index if not exists idxPeopleName on People(Name)",
-
- "create table if not exists " + ChaptersTableName + " (ItemId GUID, ChapterIndex INT NOT NULL, StartPositionTicks BIGINT NOT NULL, Name TEXT, ImagePath TEXT, PRIMARY KEY (ItemId, ChapterIndex))",
-
- CreateMediaStreamsTableCommand,
- CreateMediaAttachmentsTableCommand,
-
- "pragma shrink_memory"
- };
-
- string[] postQueries =
- {
- "create index if not exists idx_PathTypedBaseItems on TypedBaseItems(Path)",
- "create index if not exists idx_ParentIdTypedBaseItems on TypedBaseItems(ParentId)",
-
- "create index if not exists idx_PresentationUniqueKey on TypedBaseItems(PresentationUniqueKey)",
- "create index if not exists idx_GuidTypeIsFolderIsVirtualItem on TypedBaseItems(Guid,Type,IsFolder,IsVirtualItem)",
- "create index if not exists idx_CleanNameType on TypedBaseItems(CleanName,Type)",
-
- // covering index
- "create index if not exists idx_TopParentIdGuid on TypedBaseItems(TopParentId,Guid)",
-
- // series
- "create index if not exists idx_TypeSeriesPresentationUniqueKey1 on TypedBaseItems(Type,SeriesPresentationUniqueKey,PresentationUniqueKey,SortName)",
-
- // series counts
- // seriesdateplayed sort order
- "create index if not exists idx_TypeSeriesPresentationUniqueKey3 on TypedBaseItems(SeriesPresentationUniqueKey,Type,IsFolder,IsVirtualItem)",
-
- // live tv programs
- "create index if not exists idx_TypeTopParentIdStartDate on TypedBaseItems(Type,TopParentId,StartDate)",
-
- // covering index for getitemvalues
- "create index if not exists idx_TypeTopParentIdGuid on TypedBaseItems(Type,TopParentId,Guid)",
-
- // used by movie suggestions
- "create index if not exists idx_TypeTopParentIdGroup on TypedBaseItems(Type,TopParentId,PresentationUniqueKey)",
- "create index if not exists idx_TypeTopParentId5 on TypedBaseItems(TopParentId,IsVirtualItem)",
-
- // latest items
- "create index if not exists idx_TypeTopParentId9 on TypedBaseItems(TopParentId,Type,IsVirtualItem,PresentationUniqueKey,DateCreated)",
- "create index if not exists idx_TypeTopParentId8 on TypedBaseItems(TopParentId,IsFolder,IsVirtualItem,PresentationUniqueKey,DateCreated)",
-
- // resume
- "create index if not exists idx_TypeTopParentId7 on TypedBaseItems(TopParentId,MediaType,IsVirtualItem,PresentationUniqueKey)",
-
- // items by name
- "create index if not exists idx_ItemValues6 on ItemValues(ItemId,Type,CleanValue)",
- "create index if not exists idx_ItemValues7 on ItemValues(Type,CleanValue,ItemId)",
-
- // Used to update inherited tags
- "create index if not exists idx_ItemValues8 on ItemValues(Type, ItemId, Value)",
-
- "CREATE INDEX IF NOT EXISTS idx_TypedBaseItemsUserDataKeyType ON TypedBaseItems(UserDataKey, Type)",
- "CREATE INDEX IF NOT EXISTS idx_PeopleNameListOrder ON People(Name, ListOrder)"
- };
-
- using (var connection = GetConnection())
- using (var transaction = connection.BeginTransaction())
- {
- connection.Execute(string.Join(';', queries));
-
- var existingColumnNames = GetColumnNames(connection, "AncestorIds");
- AddColumn(connection, "AncestorIds", "AncestorIdText", "Text", existingColumnNames);
-
- existingColumnNames = GetColumnNames(connection, "TypedBaseItems");
-
- AddColumn(connection, "TypedBaseItems", "Path", "Text", existingColumnNames);
- AddColumn(connection, "TypedBaseItems", "StartDate", "DATETIME", existingColumnNames);
- AddColumn(connection, "TypedBaseItems", "EndDate", "DATETIME", existingColumnNames);
- AddColumn(connection, "TypedBaseItems", "ChannelId", "Text", existingColumnNames);
- AddColumn(connection, "TypedBaseItems", "IsMovie", "BIT", existingColumnNames);
- AddColumn(connection, "TypedBaseItems", "CommunityRating", "Float", existingColumnNames);
- AddColumn(connection, "TypedBaseItems", "CustomRating", "Text", existingColumnNames);
- AddColumn(connection, "TypedBaseItems", "IndexNumber", "INT", existingColumnNames);
- AddColumn(connection, "TypedBaseItems", "IsLocked", "BIT", existingColumnNames);
- AddColumn(connection, "TypedBaseItems", "Name", "Text", existingColumnNames);
- AddColumn(connection, "TypedBaseItems", "OfficialRating", "Text", existingColumnNames);
- AddColumn(connection, "TypedBaseItems", "MediaType", "Text", existingColumnNames);
- AddColumn(connection, "TypedBaseItems", "Overview", "Text", existingColumnNames);
- AddColumn(connection, "TypedBaseItems", "ParentIndexNumber", "INT", existingColumnNames);
- AddColumn(connection, "TypedBaseItems", "PremiereDate", "DATETIME", existingColumnNames);
- AddColumn(connection, "TypedBaseItems", "ProductionYear", "INT", existingColumnNames);
- AddColumn(connection, "TypedBaseItems", "ParentId", "GUID", existingColumnNames);
- AddColumn(connection, "TypedBaseItems", "Genres", "Text", existingColumnNames);
- AddColumn(connection, "TypedBaseItems", "SortName", "Text", existingColumnNames);
- AddColumn(connection, "TypedBaseItems", "ForcedSortName", "Text", existingColumnNames);
- AddColumn(connection, "TypedBaseItems", "RunTimeTicks", "BIGINT", existingColumnNames);
- AddColumn(connection, "TypedBaseItems", "DateCreated", "DATETIME", existingColumnNames);
- AddColumn(connection, "TypedBaseItems", "DateModified", "DATETIME", existingColumnNames);
- AddColumn(connection, "TypedBaseItems", "IsSeries", "BIT", existingColumnNames);
- AddColumn(connection, "TypedBaseItems", "EpisodeTitle", "Text", existingColumnNames);
- AddColumn(connection, "TypedBaseItems", "IsRepeat", "BIT", existingColumnNames);
- AddColumn(connection, "TypedBaseItems", "PreferredMetadataLanguage", "Text", existingColumnNames);
- AddColumn(connection, "TypedBaseItems", "PreferredMetadataCountryCode", "Text", existingColumnNames);
- AddColumn(connection, "TypedBaseItems", "DateLastRefreshed", "DATETIME", existingColumnNames);
- AddColumn(connection, "TypedBaseItems", "DateLastSaved", "DATETIME", existingColumnNames);
- AddColumn(connection, "TypedBaseItems", "IsInMixedFolder", "BIT", existingColumnNames);
- AddColumn(connection, "TypedBaseItems", "LockedFields", "Text", existingColumnNames);
- AddColumn(connection, "TypedBaseItems", "Studios", "Text", existingColumnNames);
- AddColumn(connection, "TypedBaseItems", "Audio", "Text", existingColumnNames);
- AddColumn(connection, "TypedBaseItems", "ExternalServiceId", "Text", existingColumnNames);
- AddColumn(connection, "TypedBaseItems", "Tags", "Text", existingColumnNames);
- AddColumn(connection, "TypedBaseItems", "IsFolder", "BIT", existingColumnNames);
- AddColumn(connection, "TypedBaseItems", "InheritedParentalRatingValue", "INT", existingColumnNames);
- AddColumn(connection, "TypedBaseItems", "UnratedType", "Text", existingColumnNames);
- AddColumn(connection, "TypedBaseItems", "TopParentId", "Text", existingColumnNames);
- AddColumn(connection, "TypedBaseItems", "TrailerTypes", "Text", existingColumnNames);
- AddColumn(connection, "TypedBaseItems", "CriticRating", "Float", existingColumnNames);
- AddColumn(connection, "TypedBaseItems", "CleanName", "Text", existingColumnNames);
- AddColumn(connection, "TypedBaseItems", "PresentationUniqueKey", "Text", existingColumnNames);
- AddColumn(connection, "TypedBaseItems", "OriginalTitle", "Text", existingColumnNames);
- AddColumn(connection, "TypedBaseItems", "PrimaryVersionId", "Text", existingColumnNames);
- AddColumn(connection, "TypedBaseItems", "DateLastMediaAdded", "DATETIME", existingColumnNames);
- AddColumn(connection, "TypedBaseItems", "Album", "Text", existingColumnNames);
- AddColumn(connection, "TypedBaseItems", "LUFS", "Float", existingColumnNames);
- AddColumn(connection, "TypedBaseItems", "NormalizationGain", "Float", existingColumnNames);
- AddColumn(connection, "TypedBaseItems", "IsVirtualItem", "BIT", existingColumnNames);
- AddColumn(connection, "TypedBaseItems", "SeriesName", "Text", existingColumnNames);
- AddColumn(connection, "TypedBaseItems", "UserDataKey", "Text", existingColumnNames);
- AddColumn(connection, "TypedBaseItems", "SeasonName", "Text", existingColumnNames);
- AddColumn(connection, "TypedBaseItems", "SeasonId", "GUID", existingColumnNames);
- AddColumn(connection, "TypedBaseItems", "SeriesId", "GUID", existingColumnNames);
- AddColumn(connection, "TypedBaseItems", "ExternalSeriesId", "Text", existingColumnNames);
- AddColumn(connection, "TypedBaseItems", "Tagline", "Text", existingColumnNames);
- AddColumn(connection, "TypedBaseItems", "ProviderIds", "Text", existingColumnNames);
- AddColumn(connection, "TypedBaseItems", "Images", "Text", existingColumnNames);
- AddColumn(connection, "TypedBaseItems", "ProductionLocations", "Text", existingColumnNames);
- AddColumn(connection, "TypedBaseItems", "ExtraIds", "Text", existingColumnNames);
- AddColumn(connection, "TypedBaseItems", "TotalBitrate", "INT", existingColumnNames);
- AddColumn(connection, "TypedBaseItems", "ExtraType", "Text", existingColumnNames);
- AddColumn(connection, "TypedBaseItems", "Artists", "Text", existingColumnNames);
- AddColumn(connection, "TypedBaseItems", "AlbumArtists", "Text", existingColumnNames);
- AddColumn(connection, "TypedBaseItems", "ExternalId", "Text", existingColumnNames);
- AddColumn(connection, "TypedBaseItems", "SeriesPresentationUniqueKey", "Text", existingColumnNames);
- AddColumn(connection, "TypedBaseItems", "ShowId", "Text", existingColumnNames);
- AddColumn(connection, "TypedBaseItems", "OwnerId", "Text", existingColumnNames);
- AddColumn(connection, "TypedBaseItems", "Width", "INT", existingColumnNames);
- AddColumn(connection, "TypedBaseItems", "Height", "INT", existingColumnNames);
- AddColumn(connection, "TypedBaseItems", "Size", "BIGINT", existingColumnNames);
-
- existingColumnNames = GetColumnNames(connection, "ItemValues");
- AddColumn(connection, "ItemValues", "CleanValue", "Text", existingColumnNames);
-
- existingColumnNames = GetColumnNames(connection, ChaptersTableName);
- AddColumn(connection, ChaptersTableName, "ImageDateModified", "DATETIME", existingColumnNames);
-
- existingColumnNames = GetColumnNames(connection, "MediaStreams");
- AddColumn(connection, "MediaStreams", "IsAvc", "BIT", existingColumnNames);
- AddColumn(connection, "MediaStreams", "TimeBase", "TEXT", existingColumnNames);
- AddColumn(connection, "MediaStreams", "CodecTimeBase", "TEXT", existingColumnNames);
- AddColumn(connection, "MediaStreams", "Title", "TEXT", existingColumnNames);
- AddColumn(connection, "MediaStreams", "NalLengthSize", "TEXT", existingColumnNames);
- AddColumn(connection, "MediaStreams", "Comment", "TEXT", existingColumnNames);
- AddColumn(connection, "MediaStreams", "CodecTag", "TEXT", existingColumnNames);
- AddColumn(connection, "MediaStreams", "PixelFormat", "TEXT", existingColumnNames);
- AddColumn(connection, "MediaStreams", "BitDepth", "INT", existingColumnNames);
- AddColumn(connection, "MediaStreams", "RefFrames", "INT", existingColumnNames);
- AddColumn(connection, "MediaStreams", "KeyFrames", "TEXT", existingColumnNames);
- AddColumn(connection, "MediaStreams", "IsAnamorphic", "BIT", existingColumnNames);
-
- AddColumn(connection, "MediaStreams", "ColorPrimaries", "TEXT", existingColumnNames);
- AddColumn(connection, "MediaStreams", "ColorSpace", "TEXT", existingColumnNames);
- AddColumn(connection, "MediaStreams", "ColorTransfer", "TEXT", existingColumnNames);
-
- AddColumn(connection, "MediaStreams", "DvVersionMajor", "INT", existingColumnNames);
- AddColumn(connection, "MediaStreams", "DvVersionMinor", "INT", existingColumnNames);
- AddColumn(connection, "MediaStreams", "DvProfile", "INT", existingColumnNames);
- AddColumn(connection, "MediaStreams", "DvLevel", "INT", existingColumnNames);
- AddColumn(connection, "MediaStreams", "RpuPresentFlag", "INT", existingColumnNames);
- AddColumn(connection, "MediaStreams", "ElPresentFlag", "INT", existingColumnNames);
- AddColumn(connection, "MediaStreams", "BlPresentFlag", "INT", existingColumnNames);
- AddColumn(connection, "MediaStreams", "DvBlSignalCompatibilityId", "INT", existingColumnNames);
-
- AddColumn(connection, "MediaStreams", "IsHearingImpaired", "BIT", existingColumnNames);
-
- AddColumn(connection, "MediaStreams", "Rotation", "INT", existingColumnNames);
-
- connection.Execute(string.Join(';', postQueries));
-
- transaction.Commit();
- }
- }
-
- ///
- public void SaveImages(BaseItem item)
- {
- ArgumentNullException.ThrowIfNull(item);
-
- CheckDisposed();
-
- var images = SerializeImages(item.ImageInfos);
- using var connection = GetConnection();
- using var transaction = connection.BeginTransaction();
- using var saveImagesStatement = PrepareStatement(connection, "Update TypedBaseItems set Images=@Images where guid=@Id");
- saveImagesStatement.TryBind("@Id", item.Id);
- saveImagesStatement.TryBind("@Images", images);
-
- saveImagesStatement.ExecuteNonQuery();
- transaction.Commit();
- }
-
- ///
- /// Saves the items.
- ///
- /// The items.
- /// The cancellation token.
- ///
- /// or is null.
- ///
- public void SaveItems(IReadOnlyList items, CancellationToken cancellationToken)
- {
- ArgumentNullException.ThrowIfNull(items);
-
- cancellationToken.ThrowIfCancellationRequested();
-
- CheckDisposed();
-
- var itemsLen = items.Count;
- var tuples = new ValueTuple, BaseItem, string, List>[itemsLen];
- for (int i = 0; i < itemsLen; i++)
- {
- var item = items[i];
- var ancestorIds = item.SupportsAncestors ?
- item.GetAncestorIds().Distinct().ToList() :
- null;
-
- var topParent = item.GetTopParent();
-
- var userdataKey = item.GetUserDataKeys().FirstOrDefault();
- var inheritedTags = item.GetInheritedTags();
-
- tuples[i] = (item, ancestorIds, topParent, userdataKey, inheritedTags);
- }
-
- using var connection = GetConnection();
- using var transaction = connection.BeginTransaction();
- SaveItemsInTransaction(connection, tuples);
- transaction.Commit();
- }
-
- private void SaveItemsInTransaction(ManagedConnection db, IEnumerable<(BaseItem Item, List AncestorIds, BaseItem TopParent, string UserDataKey, List InheritedTags)> tuples)
- {
- using (var saveItemStatement = PrepareStatement(db, SaveItemCommandText))
- using (var deleteAncestorsStatement = PrepareStatement(db, "delete from AncestorIds where ItemId=@ItemId"))
- {
- var requiresReset = false;
- foreach (var tuple in tuples)
- {
- if (requiresReset)
- {
- saveItemStatement.Parameters.Clear();
- deleteAncestorsStatement.Parameters.Clear();
- }
-
- var item = tuple.Item;
- var topParent = tuple.TopParent;
- var userDataKey = tuple.UserDataKey;
-
- SaveItem(item, topParent, userDataKey, saveItemStatement);
-
- var inheritedTags = tuple.InheritedTags;
-
- if (item.SupportsAncestors)
- {
- UpdateAncestors(item.Id, tuple.AncestorIds, db, deleteAncestorsStatement);
- }
-
- UpdateItemValues(item.Id, GetItemValuesToSave(item, inheritedTags), db);
-
- requiresReset = true;
- }
- }
- }
-
- private string GetPathToSave(string path)
- {
- if (path is null)
- {
- return null;
- }
-
- return _appHost.ReverseVirtualPath(path);
- }
-
- private string RestorePath(string path)
- {
- return _appHost.ExpandVirtualPath(path);
- }
-
- private void SaveItem(BaseItem item, BaseItem topParent, string userDataKey, SqliteCommand saveItemStatement)
- {
- Type type = item.GetType();
-
- saveItemStatement.TryBind("@guid", item.Id);
- saveItemStatement.TryBind("@type", type.FullName);
-
- if (TypeRequiresDeserialization(type))
- {
- saveItemStatement.TryBind("@data", JsonSerializer.SerializeToUtf8Bytes(item, type, _jsonOptions), true);
- }
- else
- {
- saveItemStatement.TryBindNull("@data");
- }
-
- saveItemStatement.TryBind("@Path", GetPathToSave(item.Path));
-
- if (item is IHasStartDate hasStartDate)
- {
- saveItemStatement.TryBind("@StartDate", hasStartDate.StartDate);
- }
- else
- {
- saveItemStatement.TryBindNull("@StartDate");
- }
-
- if (item.EndDate.HasValue)
- {
- saveItemStatement.TryBind("@EndDate", item.EndDate.Value);
- }
- else
- {
- saveItemStatement.TryBindNull("@EndDate");
- }
-
- saveItemStatement.TryBind("@ChannelId", item.ChannelId.IsEmpty() ? null : item.ChannelId.ToString("N", CultureInfo.InvariantCulture));
-
- if (item is IHasProgramAttributes hasProgramAttributes)
- {
- saveItemStatement.TryBind("@IsMovie", hasProgramAttributes.IsMovie);
- saveItemStatement.TryBind("@IsSeries", hasProgramAttributes.IsSeries);
- saveItemStatement.TryBind("@EpisodeTitle", hasProgramAttributes.EpisodeTitle);
- saveItemStatement.TryBind("@IsRepeat", hasProgramAttributes.IsRepeat);
- }
- else
- {
- saveItemStatement.TryBindNull("@IsMovie");
- saveItemStatement.TryBindNull("@IsSeries");
- saveItemStatement.TryBindNull("@EpisodeTitle");
- saveItemStatement.TryBindNull("@IsRepeat");
- }
-
- saveItemStatement.TryBind("@CommunityRating", item.CommunityRating);
- saveItemStatement.TryBind("@CustomRating", item.CustomRating);
- saveItemStatement.TryBind("@IndexNumber", item.IndexNumber);
- saveItemStatement.TryBind("@IsLocked", item.IsLocked);
- saveItemStatement.TryBind("@Name", item.Name);
- saveItemStatement.TryBind("@OfficialRating", item.OfficialRating);
- saveItemStatement.TryBind("@MediaType", item.MediaType.ToString());
- saveItemStatement.TryBind("@Overview", item.Overview);
- saveItemStatement.TryBind("@ParentIndexNumber", item.ParentIndexNumber);
- saveItemStatement.TryBind("@PremiereDate", item.PremiereDate);
- saveItemStatement.TryBind("@ProductionYear", item.ProductionYear);
-
- var parentId = item.ParentId;
- if (parentId.IsEmpty())
- {
- saveItemStatement.TryBindNull("@ParentId");
- }
- else
- {
- saveItemStatement.TryBind("@ParentId", parentId);
- }
-
- if (item.Genres.Length > 0)
- {
- saveItemStatement.TryBind("@Genres", string.Join('|', item.Genres));
- }
- else
- {
- saveItemStatement.TryBindNull("@Genres");
- }
-
- saveItemStatement.TryBind("@InheritedParentalRatingValue", item.InheritedParentalRatingValue);
-
- saveItemStatement.TryBind("@SortName", item.SortName);
-
- saveItemStatement.TryBind("@ForcedSortName", item.ForcedSortName);
-
- saveItemStatement.TryBind("@RunTimeTicks", item.RunTimeTicks);
- saveItemStatement.TryBind("@Size", item.Size);
-
- saveItemStatement.TryBind("@DateCreated", item.DateCreated);
- saveItemStatement.TryBind("@DateModified", item.DateModified);
-
- saveItemStatement.TryBind("@PreferredMetadataLanguage", item.PreferredMetadataLanguage);
- saveItemStatement.TryBind("@PreferredMetadataCountryCode", item.PreferredMetadataCountryCode);
-
- if (item.Width > 0)
- {
- saveItemStatement.TryBind("@Width", item.Width);
- }
- else
- {
- saveItemStatement.TryBindNull("@Width");
- }
-
- if (item.Height > 0)
- {
- saveItemStatement.TryBind("@Height", item.Height);
- }
- else
- {
- saveItemStatement.TryBindNull("@Height");
- }
-
- if (item.DateLastRefreshed != default(DateTime))
- {
- saveItemStatement.TryBind("@DateLastRefreshed", item.DateLastRefreshed);
- }
- else
- {
- saveItemStatement.TryBindNull("@DateLastRefreshed");
- }
-
- if (item.DateLastSaved != default(DateTime))
- {
- saveItemStatement.TryBind("@DateLastSaved", item.DateLastSaved);
- }
- else
- {
- saveItemStatement.TryBindNull("@DateLastSaved");
- }
-
- saveItemStatement.TryBind("@IsInMixedFolder", item.IsInMixedFolder);
-
- if (item.LockedFields.Length > 0)
- {
- saveItemStatement.TryBind("@LockedFields", string.Join('|', item.LockedFields));
- }
- else
- {
- saveItemStatement.TryBindNull("@LockedFields");
- }
-
- if (item.Studios.Length > 0)
- {
- saveItemStatement.TryBind("@Studios", string.Join('|', item.Studios));
- }
- else
- {
- saveItemStatement.TryBindNull("@Studios");
- }
-
- if (item.Audio.HasValue)
- {
- saveItemStatement.TryBind("@Audio", item.Audio.Value.ToString());
- }
- else
- {
- saveItemStatement.TryBindNull("@Audio");
- }
-
- if (item is LiveTvChannel liveTvChannel)
- {
- saveItemStatement.TryBind("@ExternalServiceId", liveTvChannel.ServiceName);
- }
- else
- {
- saveItemStatement.TryBindNull("@ExternalServiceId");
- }
-
- if (item.Tags.Length > 0)
- {
- saveItemStatement.TryBind("@Tags", string.Join('|', item.Tags));
- }
- else
- {
- saveItemStatement.TryBindNull("@Tags");
- }
-
- saveItemStatement.TryBind("@IsFolder", item.IsFolder);
-
- saveItemStatement.TryBind("@UnratedType", item.GetBlockUnratedType().ToString());
-
- if (topParent is null)
- {
- saveItemStatement.TryBindNull("@TopParentId");
- }
- else
- {
- saveItemStatement.TryBind("@TopParentId", topParent.Id.ToString("N", CultureInfo.InvariantCulture));
- }
-
- if (item is Trailer trailer && trailer.TrailerTypes.Length > 0)
- {
- saveItemStatement.TryBind("@TrailerTypes", string.Join('|', trailer.TrailerTypes));
- }
- else
- {
- saveItemStatement.TryBindNull("@TrailerTypes");
- }
-
- saveItemStatement.TryBind("@CriticRating", item.CriticRating);
-
- if (string.IsNullOrWhiteSpace(item.Name))
- {
- saveItemStatement.TryBindNull("@CleanName");
- }
- else
- {
- saveItemStatement.TryBind("@CleanName", GetCleanValue(item.Name));
- }
-
- saveItemStatement.TryBind("@PresentationUniqueKey", item.PresentationUniqueKey);
- saveItemStatement.TryBind("@OriginalTitle", item.OriginalTitle);
-
- if (item is Video video)
- {
- saveItemStatement.TryBind("@PrimaryVersionId", video.PrimaryVersionId);
- }
- else
- {
- saveItemStatement.TryBindNull("@PrimaryVersionId");
- }
-
- if (item is Folder folder && folder.DateLastMediaAdded.HasValue)
- {
- saveItemStatement.TryBind("@DateLastMediaAdded", folder.DateLastMediaAdded.Value);
- }
- else
- {
- saveItemStatement.TryBindNull("@DateLastMediaAdded");
- }
-
- saveItemStatement.TryBind("@Album", item.Album);
- saveItemStatement.TryBind("@LUFS", item.LUFS);
- saveItemStatement.TryBind("@NormalizationGain", item.NormalizationGain);
- saveItemStatement.TryBind("@IsVirtualItem", item.IsVirtualItem);
-
- if (item is IHasSeries hasSeriesName)
- {
- saveItemStatement.TryBind("@SeriesName", hasSeriesName.SeriesName);
- }
- else
- {
- saveItemStatement.TryBindNull("@SeriesName");
- }
-
- if (string.IsNullOrWhiteSpace(userDataKey))
- {
- saveItemStatement.TryBindNull("@UserDataKey");
- }
- else
- {
- saveItemStatement.TryBind("@UserDataKey", userDataKey);
- }
-
- if (item is Episode episode)
- {
- saveItemStatement.TryBind("@SeasonName", episode.SeasonName);
-
- var nullableSeasonId = episode.SeasonId.IsEmpty() ? (Guid?)null : episode.SeasonId;
-
- saveItemStatement.TryBind("@SeasonId", nullableSeasonId);
- }
- else
- {
- saveItemStatement.TryBindNull("@SeasonName");
- saveItemStatement.TryBindNull("@SeasonId");
- }
-
- if (item is IHasSeries hasSeries)
- {
- var nullableSeriesId = hasSeries.SeriesId.IsEmpty() ? (Guid?)null : hasSeries.SeriesId;
-
- saveItemStatement.TryBind("@SeriesId", nullableSeriesId);
- saveItemStatement.TryBind("@SeriesPresentationUniqueKey", hasSeries.SeriesPresentationUniqueKey);
- }
- else
- {
- saveItemStatement.TryBindNull("@SeriesId");
- saveItemStatement.TryBindNull("@SeriesPresentationUniqueKey");
- }
-
- saveItemStatement.TryBind("@ExternalSeriesId", item.ExternalSeriesId);
- saveItemStatement.TryBind("@Tagline", item.Tagline);
-
- saveItemStatement.TryBind("@ProviderIds", SerializeProviderIds(item.ProviderIds));
- saveItemStatement.TryBind("@Images", SerializeImages(item.ImageInfos));
-
- if (item.ProductionLocations.Length > 0)
- {
- saveItemStatement.TryBind("@ProductionLocations", string.Join('|', item.ProductionLocations));
- }
- else
- {
- saveItemStatement.TryBindNull("@ProductionLocations");
- }
-
- if (item.ExtraIds.Length > 0)
- {
- saveItemStatement.TryBind("@ExtraIds", string.Join('|', item.ExtraIds));
- }
- else
- {
- saveItemStatement.TryBindNull("@ExtraIds");
- }
-
- saveItemStatement.TryBind("@TotalBitrate", item.TotalBitrate);
- if (item.ExtraType.HasValue)
- {
- saveItemStatement.TryBind("@ExtraType", item.ExtraType.Value.ToString());
- }
- else
- {
- saveItemStatement.TryBindNull("@ExtraType");
- }
-
- string artists = null;
- if (item is IHasArtist hasArtists && hasArtists.Artists.Count > 0)
- {
- artists = string.Join('|', hasArtists.Artists);
- }
-
- saveItemStatement.TryBind("@Artists", artists);
-
- string albumArtists = null;
- if (item is IHasAlbumArtist hasAlbumArtists
- && hasAlbumArtists.AlbumArtists.Count > 0)
- {
- albumArtists = string.Join('|', hasAlbumArtists.AlbumArtists);
- }
-
- saveItemStatement.TryBind("@AlbumArtists", albumArtists);
- saveItemStatement.TryBind("@ExternalId", item.ExternalId);
-
- if (item is LiveTvProgram program)
- {
- saveItemStatement.TryBind("@ShowId", program.ShowId);
- }
- else
- {
- saveItemStatement.TryBindNull("@ShowId");
- }
-
- Guid ownerId = item.OwnerId;
- if (ownerId.IsEmpty())
- {
- saveItemStatement.TryBindNull("@OwnerId");
- }
- else
- {
- saveItemStatement.TryBind("@OwnerId", ownerId);
- }
-
- saveItemStatement.ExecuteNonQuery();
- }
-
- internal static string SerializeProviderIds(Dictionary providerIds)
- {
- StringBuilder str = new StringBuilder();
- foreach (var i in providerIds)
- {
- // Ideally we shouldn't need this IsNullOrWhiteSpace check,
- // but we're seeing some cases of bad data slip through
- if (string.IsNullOrWhiteSpace(i.Value))
- {
- continue;
- }
-
- str.Append(i.Key)
- .Append('=')
- .Append(i.Value)
- .Append('|');
- }
-
- if (str.Length == 0)
- {
- return null;
- }
-
- str.Length -= 1; // Remove last |
- return str.ToString();
- }
-
- internal static void DeserializeProviderIds(string value, IHasProviderIds item)
- {
- if (string.IsNullOrWhiteSpace(value))
- {
- return;
- }
-
- foreach (var part in value.SpanSplit('|'))
- {
- var providerDelimiterIndex = part.IndexOf('=');
- // Don't let empty values through
- if (providerDelimiterIndex != -1 && part.Length != providerDelimiterIndex + 1)
- {
- item.SetProviderId(part[..providerDelimiterIndex].ToString(), part[(providerDelimiterIndex + 1)..].ToString());
- }
- }
- }
-
- internal string SerializeImages(ItemImageInfo[] images)
- {
- if (images.Length == 0)
- {
- return null;
- }
-
- StringBuilder str = new StringBuilder();
- foreach (var i in images)
- {
- if (string.IsNullOrWhiteSpace(i.Path))
- {
- continue;
- }
-
- AppendItemImageInfo(str, i);
- str.Append('|');
- }
-
- str.Length -= 1; // Remove last |
- return str.ToString();
- }
-
- internal ItemImageInfo[] DeserializeImages(string value)
- {
- if (string.IsNullOrWhiteSpace(value))
- {
- return Array.Empty();
- }
-
- // TODO The following is an ugly performance optimization, but it's extremely unlikely that the data in the database would be malformed
- var valueSpan = value.AsSpan();
- var count = valueSpan.Count('|') + 1;
-
- var position = 0;
- var result = new ItemImageInfo[count];
- foreach (var part in valueSpan.Split('|'))
- {
- var image = ItemImageInfoFromValueString(part);
-
- if (image is not null)
- {
- result[position++] = image;
- }
- }
-
- if (position == count)
- {
- return result;
- }
-
- if (position == 0)
- {
- return Array.Empty();
- }
-
- // Extremely unlikely, but somehow one or more of the image strings were malformed. Cut the array.
- return result[..position];
- }
-
- private void AppendItemImageInfo(StringBuilder bldr, ItemImageInfo image)
- {
- const char Delimiter = '*';
-
- var path = image.Path ?? string.Empty;
-
- bldr.Append(GetPathToSave(path))
- .Append(Delimiter)
- .Append(image.DateModified.Ticks)
- .Append(Delimiter)
- .Append(image.Type)
- .Append(Delimiter)
- .Append(image.Width)
- .Append(Delimiter)
- .Append(image.Height);
-
- var hash = image.BlurHash;
- if (!string.IsNullOrEmpty(hash))
- {
- bldr.Append(Delimiter)
- // Replace delimiters with other characters.
- // This can be removed when we migrate to a proper DB.
- .Append(hash.Replace(Delimiter, '/').Replace('|', '\\'));
- }
- }
-
- internal ItemImageInfo ItemImageInfoFromValueString(ReadOnlySpan value)
- {
- const char Delimiter = '*';
-
- var nextSegment = value.IndexOf(Delimiter);
- if (nextSegment == -1)
- {
- return null;
- }
-
- ReadOnlySpan path = value[..nextSegment];
- value = value[(nextSegment + 1)..];
- nextSegment = value.IndexOf(Delimiter);
- if (nextSegment == -1)
- {
- return null;
- }
-
- ReadOnlySpan dateModified = value[..nextSegment];
- value = value[(nextSegment + 1)..];
- nextSegment = value.IndexOf(Delimiter);
- if (nextSegment == -1)
- {
- nextSegment = value.Length;
- }
-
- ReadOnlySpan imageType = value[..nextSegment];
-
- var image = new ItemImageInfo
- {
- Path = RestorePath(path.ToString())
- };
-
- if (long.TryParse(dateModified, CultureInfo.InvariantCulture, out var ticks)
- && ticks >= DateTime.MinValue.Ticks
- && ticks <= DateTime.MaxValue.Ticks)
- {
- image.DateModified = new DateTime(ticks, DateTimeKind.Utc);
- }
- else
- {
- return null;
- }
-
- if (Enum.TryParse(imageType, true, out ImageType type))
- {
- image.Type = type;
- }
- else
- {
- return null;
- }
-
- // Optional parameters: width*height*blurhash
- if (nextSegment + 1 < value.Length - 1)
- {
- value = value[(nextSegment + 1)..];
- nextSegment = value.IndexOf(Delimiter);
- if (nextSegment == -1 || nextSegment == value.Length)
- {
- return image;
- }
-
- ReadOnlySpan widthSpan = value[..nextSegment];
-
- value = value[(nextSegment + 1)..];
- nextSegment = value.IndexOf(Delimiter);
- if (nextSegment == -1)
- {
- nextSegment = value.Length;
- }
-
- ReadOnlySpan heightSpan = value[..nextSegment];
-
- if (int.TryParse(widthSpan, NumberStyles.Integer, CultureInfo.InvariantCulture, out var width)
- && int.TryParse(heightSpan, NumberStyles.Integer, CultureInfo.InvariantCulture, out var height))
- {
- image.Width = width;
- image.Height = height;
- }
-
- if (nextSegment < value.Length - 1)
- {
- value = value[(nextSegment + 1)..];
- var length = value.Length;
-
- Span blurHashSpan = stackalloc char[length];
- for (int i = 0; i < length; i++)
- {
- var c = value[i];
- blurHashSpan[i] = c switch
- {
- '/' => Delimiter,
- '\\' => '|',
- _ => c
- };
- }
-
- image.BlurHash = new string(blurHashSpan);
- }
- }
-
- return image;
- }
-
- ///
- /// Internal retrieve from items or users table.
- ///
- /// The id.
- /// BaseItem.
- /// is null.
- /// is .
- public BaseItem RetrieveItem(Guid id)
- {
- if (id.IsEmpty())
- {
- throw new ArgumentException("Guid can't be empty", nameof(id));
- }
-
- CheckDisposed();
-
- using (var connection = GetConnection(true))
- using (var statement = PrepareStatement(connection, _retrieveItemColumnsSelectQuery))
- {
- statement.TryBind("@guid", id);
-
- foreach (var row in statement.ExecuteQuery())
- {
- return GetItem(row, new InternalItemsQuery());
- }
- }
-
- return null;
- }
-
- private bool TypeRequiresDeserialization(Type type)
- {
- if (_config.Configuration.SkipDeserializationForBasicTypes)
- {
- if (type == typeof(Channel)
- || type == typeof(UserRootFolder))
- {
- return false;
- }
- }
-
- return type != typeof(Season)
- && type != typeof(MusicArtist)
- && type != typeof(Person)
- && type != typeof(MusicGenre)
- && type != typeof(Genre)
- && type != typeof(Studio)
- && type != typeof(PlaylistsFolder)
- && type != typeof(PhotoAlbum)
- && type != typeof(Year)
- && type != typeof(Book)
- && type != typeof(LiveTvProgram)
- && type != typeof(AudioBook)
- && type != typeof(MusicAlbum);
- }
-
- private BaseItem GetItem(SqliteDataReader reader, InternalItemsQuery query)
- {
- return GetItem(reader, query, HasProgramAttributes(query), HasEpisodeAttributes(query), HasServiceName(query), HasStartDate(query), HasTrailerTypes(query), HasArtistFields(query), HasSeriesFields(query), false);
- }
-
- private BaseItem GetItem(SqliteDataReader reader, InternalItemsQuery query, bool enableProgramAttributes, bool hasEpisodeAttributes, bool hasServiceName, bool queryHasStartDate, bool hasTrailerTypes, bool hasArtistFields, bool hasSeriesFields, bool skipDeserialization)
- {
- var typeString = reader.GetString(0);
-
- var type = _typeMapper.GetType(typeString);
-
- if (type is null)
- {
- return null;
- }
-
- BaseItem item = null;
-
- if (TypeRequiresDeserialization(type) && !skipDeserialization)
- {
- try
- {
- item = JsonSerializer.Deserialize(reader.GetStream(1), type, _jsonOptions) as BaseItem;
- }
- catch (JsonException ex)
- {
- Logger.LogError(ex, "Error deserializing item with JSON: {Data}", reader.GetString(1));
- }
- }
-
- if (item is null)
- {
- try
- {
- item = Activator.CreateInstance(type) as BaseItem;
- }
- catch
- {
- }
- }
-
- if (item is null)
- {
- return null;
- }
-
- var index = 2;
-
- if (queryHasStartDate)
- {
- if (item is IHasStartDate hasStartDate && reader.TryReadDateTime(index, out var startDate))
- {
- hasStartDate.StartDate = startDate;
- }
-
- index++;
- }
-
- if (reader.TryReadDateTime(index++, out var endDate))
- {
- item.EndDate = endDate;
- }
-
- if (reader.TryGetGuid(index, out var guid))
- {
- item.ChannelId = guid;
- }
-
- index++;
-
- if (enableProgramAttributes)
- {
- if (item is IHasProgramAttributes hasProgramAttributes)
- {
- if (reader.TryGetBoolean(index++, out var isMovie))
- {
- hasProgramAttributes.IsMovie = isMovie;
- }
-
- if (reader.TryGetBoolean(index++, out var isSeries))
- {
- hasProgramAttributes.IsSeries = isSeries;
- }
-
- if (reader.TryGetString(index++, out var episodeTitle))
- {
- hasProgramAttributes.EpisodeTitle = episodeTitle;
- }
-
- if (reader.TryGetBoolean(index++, out var isRepeat))
- {
- hasProgramAttributes.IsRepeat = isRepeat;
- }
- }
- else
- {
- index += 4;
- }
- }
-
- if (reader.TryGetSingle(index++, out var communityRating))
- {
- item.CommunityRating = communityRating;
- }
-
- if (HasField(query, ItemFields.CustomRating))
- {
- if (reader.TryGetString(index++, out var customRating))
- {
- item.CustomRating = customRating;
- }
- }
-
- if (reader.TryGetInt32(index++, out var indexNumber))
- {
- item.IndexNumber = indexNumber;
- }
-
- if (HasField(query, ItemFields.Settings))
- {
- if (reader.TryGetBoolean(index++, out var isLocked))
- {
- item.IsLocked = isLocked;
- }
-
- if (reader.TryGetString(index++, out var preferredMetadataLanguage))
- {
- item.PreferredMetadataLanguage = preferredMetadataLanguage;
- }
-
- if (reader.TryGetString(index++, out var preferredMetadataCountryCode))
- {
- item.PreferredMetadataCountryCode = preferredMetadataCountryCode;
- }
- }
-
- if (HasField(query, ItemFields.Width))
- {
- if (reader.TryGetInt32(index++, out var width))
- {
- item.Width = width;
- }
- }
-
- if (HasField(query, ItemFields.Height))
- {
- if (reader.TryGetInt32(index++, out var height))
- {
- item.Height = height;
- }
- }
-
- if (HasField(query, ItemFields.DateLastRefreshed))
- {
- if (reader.TryReadDateTime(index++, out var dateLastRefreshed))
- {
- item.DateLastRefreshed = dateLastRefreshed;
- }
- }
-
- if (reader.TryGetString(index++, out var name))
- {
- item.Name = name;
- }
-
- if (reader.TryGetString(index++, out var restorePath))
- {
- item.Path = RestorePath(restorePath);
- }
-
- if (reader.TryReadDateTime(index++, out var premiereDate))
- {
- item.PremiereDate = premiereDate;
- }
-
- if (HasField(query, ItemFields.Overview))
- {
- if (reader.TryGetString(index++, out var overview))
- {
- item.Overview = overview;
- }
- }
-
- if (reader.TryGetInt32(index++, out var parentIndexNumber))
- {
- item.ParentIndexNumber = parentIndexNumber;
- }
-
- if (reader.TryGetInt32(index++, out var productionYear))
- {
- item.ProductionYear = productionYear;
- }
-
- if (reader.TryGetString(index++, out var officialRating))
- {
- item.OfficialRating = officialRating;
- }
-
- if (HasField(query, ItemFields.SortName))
- {
- if (reader.TryGetString(index++, out var forcedSortName))
- {
- item.ForcedSortName = forcedSortName;
- }
- }
-
- if (reader.TryGetInt64(index++, out var runTimeTicks))
- {
- item.RunTimeTicks = runTimeTicks;
- }
-
- if (reader.TryGetInt64(index++, out var size))
- {
- item.Size = size;
- }
-
- if (HasField(query, ItemFields.DateCreated))
- {
- if (reader.TryReadDateTime(index++, out var dateCreated))
- {
- item.DateCreated = dateCreated;
- }
- }
-
- if (reader.TryReadDateTime(index++, out var dateModified))
- {
- item.DateModified = dateModified;
- }
-
- item.Id = reader.GetGuid(index++);
-
- if (HasField(query, ItemFields.Genres))
- {
- if (reader.TryGetString(index++, out var genres))
- {
- item.Genres = genres.Split('|', StringSplitOptions.RemoveEmptyEntries);
- }
- }
-
- if (reader.TryGetGuid(index++, out var parentId))
- {
- item.ParentId = parentId;
- }
-
- if (reader.TryGetString(index++, out var audioString))
- {
- if (Enum.TryParse(audioString, true, out ProgramAudio audio))
- {
- item.Audio = audio;
- }
- }
-
- // TODO: Even if not needed by apps, the server needs it internally
- // But get this excluded from contexts where it is not needed
- if (hasServiceName)
- {
- if (item is LiveTvChannel liveTvChannel)
- {
- if (reader.TryGetString(index, out var serviceName))
- {
- liveTvChannel.ServiceName = serviceName;
- }
- }
-
- index++;
- }
-
- if (reader.TryGetBoolean(index++, out var isInMixedFolder))
- {
- item.IsInMixedFolder = isInMixedFolder;
- }
-
- if (HasField(query, ItemFields.DateLastSaved))
- {
- if (reader.TryReadDateTime(index++, out var dateLastSaved))
- {
- item.DateLastSaved = dateLastSaved;
- }
- }
-
- if (HasField(query, ItemFields.Settings))
- {
- if (reader.TryGetString(index++, out var lockedFields))
- {
- List fields = null;
- foreach (var i in lockedFields.AsSpan().Split('|'))
- {
- if (Enum.TryParse(i, true, out MetadataField parsedValue))
- {
- (fields ??= new List()).Add(parsedValue);
- }
- }
-
- item.LockedFields = fields?.ToArray() ?? Array.Empty();
- }
- }
-
- if (HasField(query, ItemFields.Studios))
- {
- if (reader.TryGetString(index++, out var studios))
- {
- item.Studios = studios.Split('|', StringSplitOptions.RemoveEmptyEntries);
- }
- }
-
- if (HasField(query, ItemFields.Tags))
- {
- if (reader.TryGetString(index++, out var tags))
- {
- item.Tags = tags.Split('|', StringSplitOptions.RemoveEmptyEntries);
- }
- }
-
- if (hasTrailerTypes)
- {
- if (item is Trailer trailer)
- {
- if (reader.TryGetString(index, out var trailerTypes))
- {
- List types = null;
- foreach (var i in trailerTypes.AsSpan().Split('|'))
- {
- if (Enum.TryParse(i, true, out TrailerType parsedValue))
- {
- (types ??= new List()).Add(parsedValue);
- }
- }
-
- trailer.TrailerTypes = types?.ToArray() ?? Array.Empty();
- }
- }
-
- index++;
- }
-
- if (HasField(query, ItemFields.OriginalTitle))
- {
- if (reader.TryGetString(index++, out var originalTitle))
- {
- item.OriginalTitle = originalTitle;
- }
- }
-
- if (item is Video video)
- {
- if (reader.TryGetString(index, out var primaryVersionId))
- {
- video.PrimaryVersionId = primaryVersionId;
- }
- }
-
- index++;
-
- if (HasField(query, ItemFields.DateLastMediaAdded))
- {
- if (item is Folder folder && reader.TryReadDateTime(index, out var dateLastMediaAdded))
- {
- folder.DateLastMediaAdded = dateLastMediaAdded;
- }
-
- index++;
- }
-
- if (reader.TryGetString(index++, out var album))
- {
- item.Album = album;
- }
-
- if (reader.TryGetSingle(index++, out var lUFS))
- {
- item.LUFS = lUFS;
- }
-
- if (reader.TryGetSingle(index++, out var normalizationGain))
- {
- item.NormalizationGain = normalizationGain;
- }
-
- if (reader.TryGetSingle(index++, out var criticRating))
- {
- item.CriticRating = criticRating;
- }
-
- if (reader.TryGetBoolean(index++, out var isVirtualItem))
- {
- item.IsVirtualItem = isVirtualItem;
- }
-
- if (item is IHasSeries hasSeriesName)
- {
- if (reader.TryGetString(index, out var seriesName))
- {
- hasSeriesName.SeriesName = seriesName;
- }
- }
-
- index++;
-
- if (hasEpisodeAttributes)
- {
- if (item is Episode episode)
- {
- if (reader.TryGetString(index, out var seasonName))
- {
- episode.SeasonName = seasonName;
- }
-
- index++;
- if (reader.TryGetGuid(index, out var seasonId))
- {
- episode.SeasonId = seasonId;
- }
- }
- else
- {
- index++;
- }
-
- index++;
- }
-
- var hasSeries = item as IHasSeries;
- if (hasSeriesFields)
- {
- if (hasSeries is not null)
- {
- if (reader.TryGetGuid(index, out var seriesId))
- {
- hasSeries.SeriesId = seriesId;
- }
- }
-
- index++;
- }
-
- if (HasField(query, ItemFields.PresentationUniqueKey))
- {
- if (reader.TryGetString(index++, out var presentationUniqueKey))
- {
- item.PresentationUniqueKey = presentationUniqueKey;
- }
- }
-
- if (HasField(query, ItemFields.InheritedParentalRatingValue))
- {
- if (reader.TryGetInt32(index++, out var parentalRating))
- {
- item.InheritedParentalRatingValue = parentalRating;
- }
- }
-
- if (HasField(query, ItemFields.ExternalSeriesId))
- {
- if (reader.TryGetString(index++, out var externalSeriesId))
- {
- item.ExternalSeriesId = externalSeriesId;
- }
- }
-
- if (HasField(query, ItemFields.Taglines))
- {
- if (reader.TryGetString(index++, out var tagLine))
- {
- item.Tagline = tagLine;
- }
- }
-
- if (item.ProviderIds.Count == 0 && reader.TryGetString(index, out var providerIds))
- {
- DeserializeProviderIds(providerIds, item);
- }
-
- index++;
-
- if (query.DtoOptions.EnableImages)
- {
- if (item.ImageInfos.Length == 0 && reader.TryGetString(index, out var imageInfos))
- {
- item.ImageInfos = DeserializeImages(imageInfos);
- }
-
- index++;
- }
-
- if (HasField(query, ItemFields.ProductionLocations))
- {
- if (reader.TryGetString(index++, out var productionLocations))
- {
- item.ProductionLocations = productionLocations.Split('|', StringSplitOptions.RemoveEmptyEntries);
- }
- }
-
- if (HasField(query, ItemFields.ExtraIds))
- {
- if (reader.TryGetString(index++, out var extraIds))
- {
- item.ExtraIds = SplitToGuids(extraIds);
- }
- }
-
- if (reader.TryGetInt32(index++, out var totalBitrate))
- {
- item.TotalBitrate = totalBitrate;
- }
-
- if (reader.TryGetString(index++, out var extraTypeString))
- {
- if (Enum.TryParse(extraTypeString, true, out ExtraType extraType))
- {
- item.ExtraType = extraType;
- }
- }
-
- if (hasArtistFields)
- {
- if (item is IHasArtist hasArtists && reader.TryGetString(index, out var artists))
- {
- hasArtists.Artists = artists.Split('|', StringSplitOptions.RemoveEmptyEntries);
- }
-
- index++;
-
- if (item is IHasAlbumArtist hasAlbumArtists && reader.TryGetString(index, out var albumArtists))
- {
- hasAlbumArtists.AlbumArtists = albumArtists.Split('|', StringSplitOptions.RemoveEmptyEntries);
- }
-
- index++;
- }
-
- if (reader.TryGetString(index++, out var externalId))
- {
- item.ExternalId = externalId;
- }
-
- if (HasField(query, ItemFields.SeriesPresentationUniqueKey))
- {
- if (hasSeries is not null)
- {
- if (reader.TryGetString(index, out var seriesPresentationUniqueKey))
- {
- hasSeries.SeriesPresentationUniqueKey = seriesPresentationUniqueKey;
- }
- }
-
- index++;
- }
-
- if (enableProgramAttributes)
- {
- if (item is LiveTvProgram program && reader.TryGetString(index, out var showId))
- {
- program.ShowId = showId;
- }
-
- index++;
- }
-
- if (reader.TryGetGuid(index, out var ownerId))
- {
- item.OwnerId = ownerId;
- }
-
- return item;
- }
-
- private static Guid[] SplitToGuids(string value)
- {
- var ids = value.Split('|');
-
- var result = new Guid[ids.Length];
-
- for (var i = 0; i < result.Length; i++)
- {
- result[i] = new Guid(ids[i]);
- }
-
- return result;
- }
-
- ///
- public List GetChapters(BaseItem item)
- {
- CheckDisposed();
-
- var chapters = new List();
- using (var connection = GetConnection(true))
- using (var statement = PrepareStatement(connection, "select StartPositionTicks,Name,ImagePath,ImageDateModified from " + ChaptersTableName + " where ItemId = @ItemId order by ChapterIndex asc"))
- {
- statement.TryBind("@ItemId", item.Id);
-
- foreach (var row in statement.ExecuteQuery())
- {
- chapters.Add(GetChapter(row, item));
- }
- }
-
- return chapters;
- }
-
- ///
- public ChapterInfo GetChapter(BaseItem item, int index)
- {
- CheckDisposed();
-
- using (var connection = GetConnection(true))
- using (var statement = PrepareStatement(connection, "select StartPositionTicks,Name,ImagePath,ImageDateModified from " + ChaptersTableName + " where ItemId = @ItemId and ChapterIndex=@ChapterIndex"))
- {
- statement.TryBind("@ItemId", item.Id);
- statement.TryBind("@ChapterIndex", index);
-
- foreach (var row in statement.ExecuteQuery())
- {
- return GetChapter(row, item);
- }
- }
-
- return null;
- }
-
- ///
- /// Gets the chapter.
- ///
- /// The reader.
- /// The item.
- /// ChapterInfo.
- private ChapterInfo GetChapter(SqliteDataReader reader, BaseItem item)
- {
- var chapter = new ChapterInfo
- {
- StartPositionTicks = reader.GetInt64(0)
- };
-
- if (reader.TryGetString(1, out var chapterName))
- {
- chapter.Name = chapterName;
- }
-
- if (reader.TryGetString(2, out var imagePath))
- {
- chapter.ImagePath = imagePath;
- chapter.ImageTag = _imageProcessor.GetImageCacheTag(item, chapter);
- }
-
- if (reader.TryReadDateTime(3, out var imageDateModified))
- {
- chapter.ImageDateModified = imageDateModified;
- }
-
- return chapter;
- }
-
- ///
- /// Saves the chapters.
- ///
- /// The item id.
- /// The chapters.
- public void SaveChapters(Guid id, IReadOnlyList chapters)
- {
- CheckDisposed();
-
- if (id.IsEmpty())
- {
- throw new ArgumentNullException(nameof(id));
- }
-
- ArgumentNullException.ThrowIfNull(chapters);
-
- using var connection = GetConnection();
- using var transaction = connection.BeginTransaction();
- // First delete chapters
- using var command = connection.PrepareStatement($"delete from {ChaptersTableName} where ItemId=@ItemId");
- command.TryBind("@ItemId", id);
- command.ExecuteNonQuery();
-
- InsertChapters(id, chapters, connection);
- transaction.Commit();
- }
-
- private void InsertChapters(Guid idBlob, IReadOnlyList chapters, ManagedConnection db)
- {
- var startIndex = 0;
- var limit = 100;
- var chapterIndex = 0;
-
- const string StartInsertText = "insert into " + ChaptersTableName + " (ItemId, ChapterIndex, StartPositionTicks, Name, ImagePath, ImageDateModified) values ";
- var insertText = new StringBuilder(StartInsertText, 256);
-
- while (startIndex < chapters.Count)
- {
- var endIndex = Math.Min(chapters.Count, startIndex + limit);
-
- for (var i = startIndex; i < endIndex; i++)
- {
- insertText.AppendFormat(CultureInfo.InvariantCulture, "(@ItemId, @ChapterIndex{0}, @StartPositionTicks{0}, @Name{0}, @ImagePath{0}, @ImageDateModified{0}),", i.ToString(CultureInfo.InvariantCulture));
- }
-
- insertText.Length -= 1; // Remove trailing comma
-
- using (var statement = PrepareStatement(db, insertText.ToString()))
- {
- statement.TryBind("@ItemId", idBlob);
-
- for (var i = startIndex; i < endIndex; i++)
- {
- var index = i.ToString(CultureInfo.InvariantCulture);
-
- var chapter = chapters[i];
-
- statement.TryBind("@ChapterIndex" + index, chapterIndex);
- statement.TryBind("@StartPositionTicks" + index, chapter.StartPositionTicks);
- statement.TryBind("@Name" + index, chapter.Name);
- statement.TryBind("@ImagePath" + index, chapter.ImagePath);
- statement.TryBind("@ImageDateModified" + index, chapter.ImageDateModified);
-
- chapterIndex++;
- }
-
- statement.ExecuteNonQuery();
- }
-
- startIndex += limit;
- insertText.Length = StartInsertText.Length;
- }
- }
-
- private static bool EnableJoinUserData(InternalItemsQuery query)
- {
- if (query.User is null)
- {
- return false;
- }
-
- var sortingFields = new HashSet(query.OrderBy.Select(i => i.OrderBy));
-
- return sortingFields.Contains(ItemSortBy.IsFavoriteOrLiked)
- || sortingFields.Contains(ItemSortBy.IsPlayed)
- || sortingFields.Contains(ItemSortBy.IsUnplayed)
- || sortingFields.Contains(ItemSortBy.PlayCount)
- || sortingFields.Contains(ItemSortBy.DatePlayed)
- || sortingFields.Contains(ItemSortBy.SeriesDatePlayed)
- || query.IsFavoriteOrLiked.HasValue
- || query.IsFavorite.HasValue
- || query.IsResumable.HasValue
- || query.IsPlayed.HasValue
- || query.IsLiked.HasValue;
- }
-
- private bool HasField(InternalItemsQuery query, ItemFields name)
- {
- switch (name)
- {
- case ItemFields.Tags:
- return query.DtoOptions.ContainsField(name) || HasProgramAttributes(query);
- case ItemFields.CustomRating:
- case ItemFields.ProductionLocations:
- case ItemFields.Settings:
- case ItemFields.OriginalTitle:
- case ItemFields.Taglines:
- case ItemFields.SortName:
- case ItemFields.Studios:
- case ItemFields.ExtraIds:
- case ItemFields.DateCreated:
- case ItemFields.Overview:
- case ItemFields.Genres:
- case ItemFields.DateLastMediaAdded:
- case ItemFields.PresentationUniqueKey:
- case ItemFields.InheritedParentalRatingValue:
- case ItemFields.ExternalSeriesId:
- case ItemFields.SeriesPresentationUniqueKey:
- case ItemFields.DateLastRefreshed:
- case ItemFields.DateLastSaved:
- return query.DtoOptions.ContainsField(name);
- case ItemFields.ServiceName:
- return HasServiceName(query);
- default:
- return true;
- }
- }
-
- private bool HasProgramAttributes(InternalItemsQuery query)
- {
- if (query.ParentType is not null && _programExcludeParentTypes.Contains(query.ParentType.Value))
- {
- return false;
- }
-
- if (query.IncludeItemTypes.Length == 0)
- {
- return true;
- }
-
- return query.IncludeItemTypes.Any(x => _programTypes.Contains(x));
- }
-
- private bool HasServiceName(InternalItemsQuery query)
- {
- if (query.ParentType is not null && _programExcludeParentTypes.Contains(query.ParentType.Value))
- {
- return false;
- }
-
- if (query.IncludeItemTypes.Length == 0)
- {
- return true;
- }
-
- return query.IncludeItemTypes.Any(x => _serviceTypes.Contains(x));
- }
-
- private bool HasStartDate(InternalItemsQuery query)
- {
- if (query.ParentType is not null && _programExcludeParentTypes.Contains(query.ParentType.Value))
- {
- return false;
- }
-
- if (query.IncludeItemTypes.Length == 0)
- {
- return true;
- }
-
- return query.IncludeItemTypes.Any(x => _startDateTypes.Contains(x));
- }
-
- private bool HasEpisodeAttributes(InternalItemsQuery query)
- {
- if (query.IncludeItemTypes.Length == 0)
- {
- return true;
- }
-
- return query.IncludeItemTypes.Contains(BaseItemKind.Episode);
- }
-
- private bool HasTrailerTypes(InternalItemsQuery query)
- {
- if (query.IncludeItemTypes.Length == 0)
- {
- return true;
- }
-
- return query.IncludeItemTypes.Contains(BaseItemKind.Trailer);
- }
-
- private bool HasArtistFields(InternalItemsQuery query)
- {
- if (query.ParentType is not null && _artistExcludeParentTypes.Contains(query.ParentType.Value))
- {
- return false;
- }
-
- if (query.IncludeItemTypes.Length == 0)
- {
- return true;
- }
-
- return query.IncludeItemTypes.Any(x => _artistsTypes.Contains(x));
- }
-
- private bool HasSeriesFields(InternalItemsQuery query)
- {
- if (query.ParentType == BaseItemKind.PhotoAlbum)
- {
- return false;
- }
-
- if (query.IncludeItemTypes.Length == 0)
- {
- return true;
- }
-
- return query.IncludeItemTypes.Any(x => _seriesTypes.Contains(x));
- }
-
- private void SetFinalColumnsToSelect(InternalItemsQuery query, List columns)
- {
- foreach (var field in _allItemFields)
- {
- if (!HasField(query, field))
- {
- switch (field)
- {
- case ItemFields.Settings:
- columns.Remove("IsLocked");
- columns.Remove("PreferredMetadataCountryCode");
- columns.Remove("PreferredMetadataLanguage");
- columns.Remove("LockedFields");
- break;
- case ItemFields.ServiceName:
- columns.Remove("ExternalServiceId");
- break;
- case ItemFields.SortName:
- columns.Remove("ForcedSortName");
- break;
- case ItemFields.Taglines:
- columns.Remove("Tagline");
- break;
- case ItemFields.Tags:
- columns.Remove("Tags");
- break;
- case ItemFields.IsHD:
- // do nothing
- break;
- default:
- columns.Remove(field.ToString());
- break;
- }
- }
- }
-
- if (!HasProgramAttributes(query))
- {
- columns.Remove("IsMovie");
- columns.Remove("IsSeries");
- columns.Remove("EpisodeTitle");
- columns.Remove("IsRepeat");
- columns.Remove("ShowId");
- }
-
- if (!HasEpisodeAttributes(query))
- {
- columns.Remove("SeasonName");
- columns.Remove("SeasonId");
- }
-
- if (!HasStartDate(query))
- {
- columns.Remove("StartDate");
- }
-
- if (!HasTrailerTypes(query))
- {
- columns.Remove("TrailerTypes");
- }
-
- if (!HasArtistFields(query))
- {
- columns.Remove("AlbumArtists");
- columns.Remove("Artists");
- }
-
- if (!HasSeriesFields(query))
- {
- columns.Remove("SeriesId");
- }
-
- if (!HasEpisodeAttributes(query))
- {
- columns.Remove("SeasonName");
- columns.Remove("SeasonId");
- }
-
- if (!query.DtoOptions.EnableImages)
- {
- columns.Remove("Images");
- }
-
- if (EnableJoinUserData(query))
- {
- columns.Add("UserDatas.UserId");
- columns.Add("UserDatas.lastPlayedDate");
- columns.Add("UserDatas.playbackPositionTicks");
- columns.Add("UserDatas.playcount");
- columns.Add("UserDatas.isFavorite");
- columns.Add("UserDatas.played");
- columns.Add("UserDatas.rating");
- }
-
- if (query.SimilarTo is not null)
- {
- var item = query.SimilarTo;
-
- var builder = new StringBuilder();
- builder.Append('(');
-
- if (item.InheritedParentalRatingValue == 0)
- {
- builder.Append("((InheritedParentalRatingValue=0) * 10)");
- }
- else
- {
- builder.Append(
- @"(SELECT CASE WHEN COALESCE(InheritedParentalRatingValue, 0)=0
- THEN 0
- ELSE 10.0 / (1.0 + ABS(InheritedParentalRatingValue - @InheritedParentalRatingValue))
- END)");
- }
-
- if (item.ProductionYear.HasValue)
- {
- builder.Append("+(Select Case When Abs(COALESCE(ProductionYear, 0) - @ItemProductionYear) < 10 Then 10 Else 0 End )");
- builder.Append("+(Select Case When Abs(COALESCE(ProductionYear, 0) - @ItemProductionYear) < 5 Then 5 Else 0 End )");
- }
-
- // genres, tags, studios, person, year?
- builder.Append("+ (Select count(1) * 10 from ItemValues where ItemId=Guid and CleanValue in (select CleanValue from ItemValues where ItemId=@SimilarItemId))");
- builder.Append("+ (Select count(1) * 10 from People where ItemId=Guid and Name in (select Name from People where ItemId=@SimilarItemId))");
-
- if (item is MusicArtist)
- {
- // Match albums where the artist is AlbumArtist against other albums.
- // It is assumed that similar albums => similar artists.
- builder.Append(
- @"+ (WITH artistValues AS (
- SELECT DISTINCT albumValues.CleanValue
- FROM ItemValues albumValues
- INNER JOIN ItemValues artistAlbums ON albumValues.ItemId = artistAlbums.ItemId
- INNER JOIN TypedBaseItems artistItem ON artistAlbums.CleanValue = artistItem.CleanName AND artistAlbums.TYPE = 1 AND artistItem.Guid = @SimilarItemId
- ), similarArtist AS (
- SELECT albumValues.ItemId
- FROM ItemValues albumValues
- INNER JOIN ItemValues artistAlbums ON albumValues.ItemId = artistAlbums.ItemId
- INNER JOIN TypedBaseItems artistItem ON artistAlbums.CleanValue = artistItem.CleanName AND artistAlbums.TYPE = 1 AND artistItem.Guid = A.Guid
- ) SELECT COUNT(DISTINCT(CleanValue)) * 10 FROM ItemValues WHERE ItemId IN (SELECT ItemId FROM similarArtist) AND CleanValue IN (SELECT CleanValue FROM artistValues))");
- }
-
- builder.Append(") as SimilarityScore");
-
- columns.Add(builder.ToString());
-
- query.ExcludeItemIds = [.. query.ExcludeItemIds, item.Id, .. item.ExtraIds];
- query.ExcludeProviderIds = item.ProviderIds;
- }
-
- if (!string.IsNullOrEmpty(query.SearchTerm))
- {
- var builder = new StringBuilder();
- builder.Append('(');
-
- builder.Append("((CleanName like @SearchTermStartsWith or (OriginalTitle not null and OriginalTitle like @SearchTermStartsWith)) * 10)");
- builder.Append("+ ((CleanName = @SearchTermStartsWith COLLATE NOCASE or (OriginalTitle not null and OriginalTitle = @SearchTermStartsWith COLLATE NOCASE)) * 10)");
-
- if (query.SearchTerm.Length > 1)
- {
- builder.Append("+ ((CleanName like @SearchTermContains or (OriginalTitle not null and OriginalTitle like @SearchTermContains)) * 10)");
- }
-
- builder.Append(") as SearchScore");
-
- columns.Add(builder.ToString());
- }
- }
-
- private void BindSearchParams(InternalItemsQuery query, SqliteCommand statement)
- {
- var searchTerm = query.SearchTerm;
-
- if (string.IsNullOrEmpty(searchTerm))
- {
- return;
- }
-
- searchTerm = FixUnicodeChars(searchTerm);
- searchTerm = GetCleanValue(searchTerm);
-
- var commandText = statement.CommandText;
- if (commandText.Contains("@SearchTermStartsWith", StringComparison.OrdinalIgnoreCase))
- {
- statement.TryBind("@SearchTermStartsWith", searchTerm + "%");
- }
-
- if (commandText.Contains("@SearchTermContains", StringComparison.OrdinalIgnoreCase))
- {
- statement.TryBind("@SearchTermContains", "%" + searchTerm + "%");
- }
- }
-
- private void BindSimilarParams(InternalItemsQuery query, SqliteCommand statement)
- {
- var item = query.SimilarTo;
-
- if (item is null)
- {
- return;
- }
-
- var commandText = statement.CommandText;
-
- if (commandText.Contains("@ItemOfficialRating", StringComparison.OrdinalIgnoreCase))
- {
- statement.TryBind("@ItemOfficialRating", item.OfficialRating);
- }
-
- if (commandText.Contains("@ItemProductionYear", StringComparison.OrdinalIgnoreCase))
- {
- statement.TryBind("@ItemProductionYear", item.ProductionYear ?? 0);
- }
-
- if (commandText.Contains("@SimilarItemId", StringComparison.OrdinalIgnoreCase))
- {
- statement.TryBind("@SimilarItemId", item.Id);
- }
-
- if (commandText.Contains("@InheritedParentalRatingValue", StringComparison.OrdinalIgnoreCase))
- {
- statement.TryBind("@InheritedParentalRatingValue", item.InheritedParentalRatingValue);
- }
- }
-
- private string GetJoinUserDataText(InternalItemsQuery query)
- {
- if (!EnableJoinUserData(query))
- {
- return string.Empty;
- }
-
- return " left join UserDatas on UserDataKey=UserDatas.Key And (UserId=@UserId)";
- }
-
- private string GetGroupBy(InternalItemsQuery query)
- {
- var enableGroupByPresentationUniqueKey = EnableGroupByPresentationUniqueKey(query);
- if (enableGroupByPresentationUniqueKey && query.GroupBySeriesPresentationUniqueKey)
- {
- return " Group by PresentationUniqueKey, SeriesPresentationUniqueKey";
- }
-
- if (enableGroupByPresentationUniqueKey)
- {
- return " Group by PresentationUniqueKey";
- }
-
- if (query.GroupBySeriesPresentationUniqueKey)
- {
- return " Group by SeriesPresentationUniqueKey";
- }
-
- return string.Empty;
- }
-
- ///
- public int GetCount(InternalItemsQuery query)
- {
- ArgumentNullException.ThrowIfNull(query);
-
- CheckDisposed();
-
- // Hack for right now since we currently don't support filtering out these duplicates within a query
- if (query.Limit.HasValue && query.EnableGroupByMetadataKey)
- {
- query.Limit = query.Limit.Value + 4;
- }
-
- var columns = new List { "count(distinct PresentationUniqueKey)" };
- SetFinalColumnsToSelect(query, columns);
- var commandTextBuilder = new StringBuilder("select ", 256)
- .AppendJoin(',', columns)
- .Append(FromText)
- .Append(GetJoinUserDataText(query));
-
- var whereClauses = GetWhereClauses(query, null);
- if (whereClauses.Count != 0)
- {
- commandTextBuilder.Append(" where ")
- .AppendJoin(" AND ", whereClauses);
- }
-
- var commandText = commandTextBuilder.ToString();
-
- using (new QueryTimeLogger(Logger, commandText))
- using (var connection = GetConnection(true))
- using (var statement = PrepareStatement(connection, commandText))
- {
- if (EnableJoinUserData(query))
- {
- statement.TryBind("@UserId", query.User.InternalId);
- }
-
- BindSimilarParams(query, statement);
- BindSearchParams(query, statement);
-
- // Running this again will bind the params
- GetWhereClauses(query, statement);
-
- return statement.SelectScalarInt();
- }
- }
-
- ///
- public List GetItemList(InternalItemsQuery query)
- {
- ArgumentNullException.ThrowIfNull(query);
-
- CheckDisposed();
-
- // Hack for right now since we currently don't support filtering out these duplicates within a query
- if (query.Limit.HasValue && query.EnableGroupByMetadataKey)
- {
- query.Limit = query.Limit.Value + 4;
- }
-
- var columns = _retrieveItemColumns.ToList();
- SetFinalColumnsToSelect(query, columns);
- var commandTextBuilder = new StringBuilder("select ", 1024)
- .AppendJoin(',', columns)
- .Append(FromText)
- .Append(GetJoinUserDataText(query));
-
- var whereClauses = GetWhereClauses(query, null);
-
- if (whereClauses.Count != 0)
- {
- commandTextBuilder.Append(" where ")
- .AppendJoin(" AND ", whereClauses);
- }
-
- commandTextBuilder.Append(GetGroupBy(query))
- .Append(GetOrderByText(query));
-
- if (query.Limit.HasValue || query.StartIndex.HasValue)
- {
- var offset = query.StartIndex ?? 0;
-
- if (query.Limit.HasValue || offset > 0)
- {
- commandTextBuilder.Append(" LIMIT ")
- .Append(query.Limit ?? int.MaxValue);
- }
-
- if (offset > 0)
- {
- commandTextBuilder.Append(" OFFSET ")
- .Append(offset);
- }
- }
-
- var commandText = commandTextBuilder.ToString();
- var items = new List();
- using (new QueryTimeLogger(Logger, commandText))
- using (var connection = GetConnection(true))
- using (var statement = PrepareStatement(connection, commandText))
- {
- if (EnableJoinUserData(query))
- {
- statement.TryBind("@UserId", query.User.InternalId);
- }
-
- BindSimilarParams(query, statement);
- BindSearchParams(query, statement);
-
- // Running this again will bind the params
- GetWhereClauses(query, statement);
-
- var hasEpisodeAttributes = HasEpisodeAttributes(query);
- var hasServiceName = HasServiceName(query);
- var hasProgramAttributes = HasProgramAttributes(query);
- var hasStartDate = HasStartDate(query);
- var hasTrailerTypes = HasTrailerTypes(query);
- var hasArtistFields = HasArtistFields(query);
- var hasSeriesFields = HasSeriesFields(query);
-
- foreach (var row in statement.ExecuteQuery())
- {
- var item = GetItem(row, query, hasProgramAttributes, hasEpisodeAttributes, hasServiceName, hasStartDate, hasTrailerTypes, hasArtistFields, hasSeriesFields, query.SkipDeserialization);
- if (item is not null)
- {
- items.Add(item);
- }
- }
- }
-
- // Hack for right now since we currently don't support filtering out these duplicates within a query
- if (query.EnableGroupByMetadataKey)
- {
- var limit = query.Limit ?? int.MaxValue;
- limit -= 4;
- var newList = new List();
-
- foreach (var item in items)
- {
- AddItem(newList, item);
-
- if (newList.Count >= limit)
- {
- break;
- }
- }
-
- items = newList;
- }
-
- return items;
- }
-
- private string FixUnicodeChars(string buffer)
- {
- buffer = buffer.Replace('\u2013', '-'); // en dash
- buffer = buffer.Replace('\u2014', '-'); // em dash
- buffer = buffer.Replace('\u2015', '-'); // horizontal bar
- buffer = buffer.Replace('\u2017', '_'); // double low line
- buffer = buffer.Replace('\u2018', '\''); // left single quotation mark
- buffer = buffer.Replace('\u2019', '\''); // right single quotation mark
- buffer = buffer.Replace('\u201a', ','); // single low-9 quotation mark
- buffer = buffer.Replace('\u201b', '\''); // single high-reversed-9 quotation mark
- buffer = buffer.Replace('\u201c', '\"'); // left double quotation mark
- buffer = buffer.Replace('\u201d', '\"'); // right double quotation mark
- buffer = buffer.Replace('\u201e', '\"'); // double low-9 quotation mark
- buffer = buffer.Replace("\u2026", "...", StringComparison.Ordinal); // horizontal ellipsis
- buffer = buffer.Replace('\u2032', '\''); // prime
- buffer = buffer.Replace('\u2033', '\"'); // double prime
- buffer = buffer.Replace('\u0060', '\''); // grave accent
- return buffer.Replace('\u00B4', '\''); // acute accent
- }
-
- private void AddItem(List items, BaseItem newItem)
- {
- for (var i = 0; i < items.Count; i++)
- {
- var item = items[i];
-
- foreach (var providerId in newItem.ProviderIds)
- {
- if (string.Equals(providerId.Key, nameof(MetadataProvider.TmdbCollection), StringComparison.Ordinal))
- {
- continue;
- }
-
- if (string.Equals(item.GetProviderId(providerId.Key), providerId.Value, StringComparison.Ordinal))
- {
- if (newItem.SourceType == SourceType.Library)
- {
- items[i] = newItem;
- }
-
- return;
- }
- }
- }
-
- items.Add(newItem);
- }
-
- ///
- public QueryResult GetItems(InternalItemsQuery query)
- {
- ArgumentNullException.ThrowIfNull(query);
-
- CheckDisposed();
-
- if (!query.EnableTotalRecordCount || (!query.Limit.HasValue && (query.StartIndex ?? 0) == 0))
- {
- var returnList = GetItemList(query);
- return new QueryResult(
- query.StartIndex,
- returnList.Count,
- returnList);
- }
-
- // Hack for right now since we currently don't support filtering out these duplicates within a query
- if (query.Limit.HasValue && query.EnableGroupByMetadataKey)
- {
- query.Limit = query.Limit.Value + 4;
- }
-
- var columns = _retrieveItemColumns.ToList();
- SetFinalColumnsToSelect(query, columns);
- var commandTextBuilder = new StringBuilder("select ", 512)
- .AppendJoin(',', columns)
- .Append(FromText)
- .Append(GetJoinUserDataText(query));
-
- var whereClauses = GetWhereClauses(query, null);
-
- var whereText = whereClauses.Count == 0 ?
- string.Empty :
- string.Join(" AND ", whereClauses);
-
- if (!string.IsNullOrEmpty(whereText))
- {
- commandTextBuilder.Append(" where ")
- .Append(whereText);
- }
-
- commandTextBuilder.Append(GetGroupBy(query))
- .Append(GetOrderByText(query));
-
- if (query.Limit.HasValue || query.StartIndex.HasValue)
- {
- var offset = query.StartIndex ?? 0;
-
- if (query.Limit.HasValue || offset > 0)
- {
- commandTextBuilder.Append(" LIMIT ")
- .Append(query.Limit ?? int.MaxValue);
- }
-
- if (offset > 0)
- {
- commandTextBuilder.Append(" OFFSET ")
- .Append(offset);
- }
- }
-
- var isReturningZeroItems = query.Limit.HasValue && query.Limit <= 0;
-
- var itemQuery = string.Empty;
- var totalRecordCountQuery = string.Empty;
- if (!isReturningZeroItems)
- {
- itemQuery = commandTextBuilder.ToString();
- }
-
- if (query.EnableTotalRecordCount)
- {
- commandTextBuilder.Clear();
-
- commandTextBuilder.Append(" select ");
-
- List columnsToSelect;
- if (EnableGroupByPresentationUniqueKey(query))
- {
- columnsToSelect = new List { "count (distinct PresentationUniqueKey)" };
- }
- else if (query.GroupBySeriesPresentationUniqueKey)
- {
- columnsToSelect = new List { "count (distinct SeriesPresentationUniqueKey)" };
- }
- else
- {
- columnsToSelect = new List { "count (guid)" };
- }
-
- SetFinalColumnsToSelect(query, columnsToSelect);
-
- commandTextBuilder.AppendJoin(',', columnsToSelect)
- .Append(FromText)
- .Append(GetJoinUserDataText(query));
- if (!string.IsNullOrEmpty(whereText))
- {
- commandTextBuilder.Append(" where ")
- .Append(whereText);
- }
-
- totalRecordCountQuery = commandTextBuilder.ToString();
- }
-
- var list = new List();
- var result = new QueryResult();
- using var connection = GetConnection(true);
- using var transaction = connection.BeginTransaction();
- if (!isReturningZeroItems)
- {
- using (new QueryTimeLogger(Logger, itemQuery, "GetItems.ItemQuery"))
- using (var statement = PrepareStatement(connection, itemQuery))
- {
- if (EnableJoinUserData(query))
- {
- statement.TryBind("@UserId", query.User.InternalId);
- }
-
- BindSimilarParams(query, statement);
- BindSearchParams(query, statement);
-
- // Running this again will bind the params
- GetWhereClauses(query, statement);
-
- var hasEpisodeAttributes = HasEpisodeAttributes(query);
- var hasServiceName = HasServiceName(query);
- var hasProgramAttributes = HasProgramAttributes(query);
- var hasStartDate = HasStartDate(query);
- var hasTrailerTypes = HasTrailerTypes(query);
- var hasArtistFields = HasArtistFields(query);
- var hasSeriesFields = HasSeriesFields(query);
-
- foreach (var row in statement.ExecuteQuery())
- {
- var item = GetItem(row, query, hasProgramAttributes, hasEpisodeAttributes, hasServiceName, hasStartDate, hasTrailerTypes, hasArtistFields, hasSeriesFields, false);
- if (item is not null)
- {
- list.Add(item);
- }
- }
- }
- }
-
- if (query.EnableTotalRecordCount)
- {
- using (new QueryTimeLogger(Logger, totalRecordCountQuery, "GetItems.TotalRecordCount"))
- using (var statement = PrepareStatement(connection, totalRecordCountQuery))
- {
- if (EnableJoinUserData(query))
- {
- statement.TryBind("@UserId", query.User.InternalId);
- }
-
- BindSimilarParams(query, statement);
- BindSearchParams(query, statement);
-
- // Running this again will bind the params
- GetWhereClauses(query, statement);
-
- result.TotalRecordCount = statement.SelectScalarInt();
- }
- }
-
- transaction.Commit();
-
- result.StartIndex = query.StartIndex ?? 0;
- result.Items = list;
- return result;
- }
-
- private string GetOrderByText(InternalItemsQuery query)
- {
- var orderBy = query.OrderBy;
- bool hasSimilar = query.SimilarTo is not null;
- bool hasSearch = !string.IsNullOrEmpty(query.SearchTerm);
-
- if (hasSimilar || hasSearch)
- {
- List<(ItemSortBy, SortOrder)> prepend = new List<(ItemSortBy, SortOrder)>(4);
- if (hasSearch)
- {
- prepend.Add((ItemSortBy.SearchScore, SortOrder.Descending));
- prepend.Add((ItemSortBy.SortName, SortOrder.Ascending));
- }
-
- if (hasSimilar)
- {
- prepend.Add((ItemSortBy.SimilarityScore, SortOrder.Descending));
- prepend.Add((ItemSortBy.Random, SortOrder.Ascending));
- }
-
- orderBy = query.OrderBy = [.. prepend, .. orderBy];
- }
- else if (orderBy.Count == 0)
- {
- return string.Empty;
- }
-
- return " ORDER BY " + string.Join(',', orderBy.Select(i =>
- {
- var sortBy = MapOrderByField(i.OrderBy, query);
- var sortOrder = i.SortOrder == SortOrder.Ascending ? "ASC" : "DESC";
- return sortBy + " " + sortOrder;
- }));
- }
-
- private string MapOrderByField(ItemSortBy sortBy, InternalItemsQuery query)
- {
- return sortBy switch
- {
- ItemSortBy.AirTime => "SortName", // TODO
- ItemSortBy.Runtime => "RuntimeTicks",
- ItemSortBy.Random => "RANDOM()",
- ItemSortBy.DatePlayed when query.GroupBySeriesPresentationUniqueKey => "MAX(LastPlayedDate)",
- ItemSortBy.DatePlayed => "LastPlayedDate",
- ItemSortBy.PlayCount => "PlayCount",
- ItemSortBy.IsFavoriteOrLiked => "(Select Case When IsFavorite is null Then 0 Else IsFavorite End )",
- ItemSortBy.IsFolder => "IsFolder",
- ItemSortBy.IsPlayed => "played",
- ItemSortBy.IsUnplayed => "played",
- ItemSortBy.DateLastContentAdded => "DateLastMediaAdded",
- ItemSortBy.Artist => "(select CleanValue from ItemValues where ItemId=Guid and Type=0 LIMIT 1)",
- ItemSortBy.AlbumArtist => "(select CleanValue from ItemValues where ItemId=Guid and Type=1 LIMIT 1)",
- ItemSortBy.OfficialRating => "InheritedParentalRatingValue",
- ItemSortBy.Studio => "(select CleanValue from ItemValues where ItemId=Guid and Type=3 LIMIT 1)",
- ItemSortBy.SeriesDatePlayed => "(Select MAX(LastPlayedDate) from TypedBaseItems B" + GetJoinUserDataText(query) + " where Played=1 and B.SeriesPresentationUniqueKey=A.PresentationUniqueKey)",
- ItemSortBy.SeriesSortName => "SeriesName",
- ItemSortBy.AiredEpisodeOrder => "AiredEpisodeOrder",
- ItemSortBy.Album => "Album",
- ItemSortBy.DateCreated => "DateCreated",
- ItemSortBy.PremiereDate => "PremiereDate",
- ItemSortBy.StartDate => "StartDate",
- ItemSortBy.Name => "Name",
- ItemSortBy.CommunityRating => "CommunityRating",
- ItemSortBy.ProductionYear => "ProductionYear",
- ItemSortBy.CriticRating => "CriticRating",
- ItemSortBy.VideoBitRate => "VideoBitRate",
- ItemSortBy.ParentIndexNumber => "ParentIndexNumber",
- ItemSortBy.IndexNumber => "IndexNumber",
- ItemSortBy.SimilarityScore => "SimilarityScore",
- ItemSortBy.SearchScore => "SearchScore",
- _ => "SortName"
- };
- }
-
- ///
- public List GetItemIdsList(InternalItemsQuery query)
- {
- ArgumentNullException.ThrowIfNull(query);
-
- CheckDisposed();
-
- var columns = new List { "guid" };
- SetFinalColumnsToSelect(query, columns);
- var commandTextBuilder = new StringBuilder("select ", 256)
- .AppendJoin(',', columns)
- .Append(FromText)
- .Append(GetJoinUserDataText(query));
-
- var whereClauses = GetWhereClauses(query, null);
- if (whereClauses.Count != 0)
- {
- commandTextBuilder.Append(" where ")
- .AppendJoin(" AND ", whereClauses);
- }
-
- commandTextBuilder.Append(GetGroupBy(query))
- .Append(GetOrderByText(query));
-
- if (query.Limit.HasValue || query.StartIndex.HasValue)
- {
- var offset = query.StartIndex ?? 0;
-
- if (query.Limit.HasValue || offset > 0)
- {
- commandTextBuilder.Append(" LIMIT ")
- .Append(query.Limit ?? int.MaxValue);
- }
-
- if (offset > 0)
- {
- commandTextBuilder.Append(" OFFSET ")
- .Append(offset);
- }
- }
-
- var commandText = commandTextBuilder.ToString();
- var list = new List();
- using (new QueryTimeLogger(Logger, commandText))
- using (var connection = GetConnection(true))
- using (var statement = PrepareStatement(connection, commandText))
- {
- if (EnableJoinUserData(query))
- {
- statement.TryBind("@UserId", query.User.InternalId);
- }
-
- BindSimilarParams(query, statement);
- BindSearchParams(query, statement);
-
- // Running this again will bind the params
- GetWhereClauses(query, statement);
-
- foreach (var row in statement.ExecuteQuery())
- {
- list.Add(row.GetGuid(0));
- }
- }
-
- return list;
- }
-
- private bool IsAlphaNumeric(string str)
- {
- if (string.IsNullOrWhiteSpace(str))
- {
- return false;
- }
-
- for (int i = 0; i < str.Length; i++)
- {
- if (!char.IsLetter(str[i]) && !char.IsNumber(str[i]))
- {
- return false;
- }
- }
-
- return true;
- }
-
- private bool IsValidPersonType(string value)
- {
- return IsAlphaNumeric(value);
- }
-
-#nullable enable
- private List GetWhereClauses(InternalItemsQuery query, SqliteCommand? statement)
- {
- if (query.IsResumable ?? false)
- {
- query.IsVirtualItem = false;
- }
-
- var minWidth = query.MinWidth;
- var maxWidth = query.MaxWidth;
-
- if (query.IsHD.HasValue)
- {
- const int Threshold = 1200;
- if (query.IsHD.Value)
- {
- minWidth = Threshold;
- }
- else
- {
- maxWidth = Threshold - 1;
- }
- }
-
- if (query.Is4K.HasValue)
- {
- const int Threshold = 3800;
- if (query.Is4K.Value)
- {
- minWidth = Threshold;
- }
- else
- {
- maxWidth = Threshold - 1;
- }
- }
-
- var whereClauses = new List();
-
- if (minWidth.HasValue)
- {
- whereClauses.Add("Width>=@MinWidth");
- statement?.TryBind("@MinWidth", minWidth);
- }
-
- if (query.MinHeight.HasValue)
- {
- whereClauses.Add("Height>=@MinHeight");
- statement?.TryBind("@MinHeight", query.MinHeight);
- }
-
- if (maxWidth.HasValue)
- {
- whereClauses.Add("Width<=@MaxWidth");
- statement?.TryBind("@MaxWidth", maxWidth);
- }
-
- if (query.MaxHeight.HasValue)
- {
- whereClauses.Add("Height<=@MaxHeight");
- statement?.TryBind("@MaxHeight", query.MaxHeight);
- }
-
- if (query.IsLocked.HasValue)
- {
- whereClauses.Add("IsLocked=@IsLocked");
- statement?.TryBind("@IsLocked", query.IsLocked);
- }
-
- var tags = query.Tags.ToList();
- var excludeTags = query.ExcludeTags.ToList();
-
- if (query.IsMovie == true)
- {
- if (query.IncludeItemTypes.Length == 0
- || query.IncludeItemTypes.Contains(BaseItemKind.Movie)
- || query.IncludeItemTypes.Contains(BaseItemKind.Trailer))
- {
- whereClauses.Add("(IsMovie is null OR IsMovie=@IsMovie)");
- }
- else
- {
- whereClauses.Add("IsMovie=@IsMovie");
- }
-
- statement?.TryBind("@IsMovie", true);
- }
- else if (query.IsMovie.HasValue)
- {
- whereClauses.Add("IsMovie=@IsMovie");
- statement?.TryBind("@IsMovie", query.IsMovie);
- }
-
- if (query.IsSeries.HasValue)
- {
- whereClauses.Add("IsSeries=@IsSeries");
- statement?.TryBind("@IsSeries", query.IsSeries);
- }
-
- if (query.IsSports.HasValue)
- {
- if (query.IsSports.Value)
- {
- tags.Add("Sports");
- }
- else
- {
- excludeTags.Add("Sports");
- }
- }
-
- if (query.IsNews.HasValue)
- {
- if (query.IsNews.Value)
- {
- tags.Add("News");
- }
- else
- {
- excludeTags.Add("News");
- }
- }
-
- if (query.IsKids.HasValue)
- {
- if (query.IsKids.Value)
- {
- tags.Add("Kids");
- }
- else
- {
- excludeTags.Add("Kids");
- }
- }
-
- if (query.SimilarTo is not null && query.MinSimilarityScore > 0)
- {
- whereClauses.Add("SimilarityScore > " + (query.MinSimilarityScore - 1).ToString(CultureInfo.InvariantCulture));
- }
-
- if (!string.IsNullOrEmpty(query.SearchTerm))
- {
- whereClauses.Add("SearchScore > 0");
- }
-
- if (query.IsFolder.HasValue)
- {
- whereClauses.Add("IsFolder=@IsFolder");
- statement?.TryBind("@IsFolder", query.IsFolder);
- }
-
- var includeTypes = query.IncludeItemTypes;
- // Only specify excluded types if no included types are specified
- if (query.IncludeItemTypes.Length == 0)
- {
- var excludeTypes = query.ExcludeItemTypes;
- if (excludeTypes.Length == 1)
- {
- if (_baseItemKindNames.TryGetValue(excludeTypes[0], out var excludeTypeName))
- {
- whereClauses.Add("type<>@type");
- statement?.TryBind("@type", excludeTypeName);
- }
- else
- {
- Logger.LogWarning("Undefined BaseItemKind to Type mapping: {BaseItemKind}", excludeTypes[0]);
- }
- }
- else if (excludeTypes.Length > 1)
- {
- var whereBuilder = new StringBuilder("type not in (");
- foreach (var excludeType in excludeTypes)
- {
- if (_baseItemKindNames.TryGetValue(excludeType, out var baseItemKindName))
- {
- whereBuilder
- .Append('\'')
- .Append(baseItemKindName)
- .Append("',");
- }
- else
- {
- Logger.LogWarning("Undefined BaseItemKind to Type mapping: {BaseItemKind}", excludeType);
- }
- }
-
- // Remove trailing comma.
- whereBuilder.Length--;
- whereBuilder.Append(')');
- whereClauses.Add(whereBuilder.ToString());
- }
- }
- else if (includeTypes.Length == 1)
- {
- if (_baseItemKindNames.TryGetValue(includeTypes[0], out var includeTypeName))
- {
- whereClauses.Add("type=@type");
- statement?.TryBind("@type", includeTypeName);
- }
- else
- {
- Logger.LogWarning("Undefined BaseItemKind to Type mapping: {BaseItemKind}", includeTypes[0]);
- }
- }
- else if (includeTypes.Length > 1)
- {
- var whereBuilder = new StringBuilder("type in (");
- foreach (var includeType in includeTypes)
- {
- if (_baseItemKindNames.TryGetValue(includeType, out var baseItemKindName))
- {
- whereBuilder
- .Append('\'')
- .Append(baseItemKindName)
- .Append("',");
- }
- else
- {
- Logger.LogWarning("Undefined BaseItemKind to Type mapping: {BaseItemKind}", includeType);
- }
- }
-
- // Remove trailing comma.
- whereBuilder.Length--;
- whereBuilder.Append(')');
- whereClauses.Add(whereBuilder.ToString());
- }
-
- if (query.ChannelIds.Count == 1)
- {
- whereClauses.Add("ChannelId=@ChannelId");
- statement?.TryBind("@ChannelId", query.ChannelIds[0].ToString("N", CultureInfo.InvariantCulture));
- }
- else if (query.ChannelIds.Count > 1)
- {
- var inClause = string.Join(',', query.ChannelIds.Select(i => "'" + i.ToString("N", CultureInfo.InvariantCulture) + "'"));
- whereClauses.Add($"ChannelId in ({inClause})");
- }
-
- if (!query.ParentId.IsEmpty())
- {
- whereClauses.Add("ParentId=@ParentId");
- statement?.TryBind("@ParentId", query.ParentId);
- }
-
- if (!string.IsNullOrWhiteSpace(query.Path))
- {
- whereClauses.Add("Path=@Path");
- statement?.TryBind("@Path", GetPathToSave(query.Path));
- }
-
- if (!string.IsNullOrWhiteSpace(query.PresentationUniqueKey))
- {
- whereClauses.Add("PresentationUniqueKey=@PresentationUniqueKey");
- statement?.TryBind("@PresentationUniqueKey", query.PresentationUniqueKey);
- }
-
- if (query.MinCommunityRating.HasValue)
- {
- whereClauses.Add("CommunityRating>=@MinCommunityRating");
- statement?.TryBind("@MinCommunityRating", query.MinCommunityRating.Value);
- }
-
- if (query.MinIndexNumber.HasValue)
- {
- whereClauses.Add("IndexNumber>=@MinIndexNumber");
- statement?.TryBind("@MinIndexNumber", query.MinIndexNumber.Value);
- }
-
- if (query.MinParentAndIndexNumber.HasValue)
- {
- whereClauses.Add("((ParentIndexNumber=@MinParentAndIndexNumberParent and IndexNumber>=@MinParentAndIndexNumberIndex) or ParentIndexNumber>@MinParentAndIndexNumberParent)");
- statement?.TryBind("@MinParentAndIndexNumberParent", query.MinParentAndIndexNumber.Value.ParentIndexNumber);
- statement?.TryBind("@MinParentAndIndexNumberIndex", query.MinParentAndIndexNumber.Value.IndexNumber);
- }
-
- if (query.MinDateCreated.HasValue)
- {
- whereClauses.Add("DateCreated>=@MinDateCreated");
- statement?.TryBind("@MinDateCreated", query.MinDateCreated.Value);
- }
-
- if (query.MinDateLastSaved.HasValue)
- {
- whereClauses.Add("(DateLastSaved not null and DateLastSaved>=@MinDateLastSavedForUser)");
- statement?.TryBind("@MinDateLastSaved", query.MinDateLastSaved.Value);
- }
-
- if (query.MinDateLastSavedForUser.HasValue)
- {
- whereClauses.Add("(DateLastSaved not null and DateLastSaved>=@MinDateLastSavedForUser)");
- statement?.TryBind("@MinDateLastSavedForUser", query.MinDateLastSavedForUser.Value);
- }
-
- if (query.IndexNumber.HasValue)
- {
- whereClauses.Add("IndexNumber=@IndexNumber");
- statement?.TryBind("@IndexNumber", query.IndexNumber.Value);
- }
-
- if (query.ParentIndexNumber.HasValue)
- {
- whereClauses.Add("ParentIndexNumber=@ParentIndexNumber");
- statement?.TryBind("@ParentIndexNumber", query.ParentIndexNumber.Value);
- }
-
- if (query.ParentIndexNumberNotEquals.HasValue)
- {
- whereClauses.Add("(ParentIndexNumber<>@ParentIndexNumberNotEquals or ParentIndexNumber is null)");
- statement?.TryBind("@ParentIndexNumberNotEquals", query.ParentIndexNumberNotEquals.Value);
- }
-
- var minEndDate = query.MinEndDate;
- var maxEndDate = query.MaxEndDate;
-
- if (query.HasAired.HasValue)
- {
- if (query.HasAired.Value)
- {
- maxEndDate = DateTime.UtcNow;
- }
- else
- {
- minEndDate = DateTime.UtcNow;
- }
- }
-
- if (minEndDate.HasValue)
- {
- whereClauses.Add("EndDate>=@MinEndDate");
- statement?.TryBind("@MinEndDate", minEndDate.Value);
- }
-
- if (maxEndDate.HasValue)
- {
- whereClauses.Add("EndDate<=@MaxEndDate");
- statement?.TryBind("@MaxEndDate", maxEndDate.Value);
- }
-
- if (query.MinStartDate.HasValue)
- {
- whereClauses.Add("StartDate>=@MinStartDate");
- statement?.TryBind("@MinStartDate", query.MinStartDate.Value);
- }
-
- if (query.MaxStartDate.HasValue)
- {
- whereClauses.Add("StartDate<=@MaxStartDate");
- statement?.TryBind("@MaxStartDate", query.MaxStartDate.Value);
- }
-
- if (query.MinPremiereDate.HasValue)
- {
- whereClauses.Add("PremiereDate>=@MinPremiereDate");
- statement?.TryBind("@MinPremiereDate", query.MinPremiereDate.Value);
- }
-
- if (query.MaxPremiereDate.HasValue)
- {
- whereClauses.Add("PremiereDate<=@MaxPremiereDate");
- statement?.TryBind("@MaxPremiereDate", query.MaxPremiereDate.Value);
- }
-
- StringBuilder clauseBuilder = new StringBuilder();
- const string Or = " OR ";
-
- var trailerTypes = query.TrailerTypes;
- int trailerTypesLen = trailerTypes.Length;
- if (trailerTypesLen > 0)
- {
- clauseBuilder.Append('(');
-
- for (int i = 0; i < trailerTypesLen; i++)
- {
- var paramName = "@TrailerTypes" + i;
- clauseBuilder.Append("TrailerTypes like ")
- .Append(paramName)
- .Append(Or);
- statement?.TryBind(paramName, "%" + trailerTypes[i] + "%");
- }
-
- clauseBuilder.Length -= Or.Length;
- clauseBuilder.Append(')');
-
- whereClauses.Add(clauseBuilder.ToString());
-
- clauseBuilder.Length = 0;
- }
-
- if (query.IsAiring.HasValue)
- {
- if (query.IsAiring.Value)
- {
- whereClauses.Add("StartDate<=@MaxStartDate");
- statement?.TryBind("@MaxStartDate", DateTime.UtcNow);
-
- whereClauses.Add("EndDate>=@MinEndDate");
- statement?.TryBind("@MinEndDate", DateTime.UtcNow);
- }
- else
- {
- whereClauses.Add("(StartDate>@IsAiringDate OR EndDate < @IsAiringDate)");
- statement?.TryBind("@IsAiringDate", DateTime.UtcNow);
- }
- }
-
- int personIdsLen = query.PersonIds.Length;
- if (personIdsLen > 0)
- {
- // TODO: Should this query with CleanName ?
-
- clauseBuilder.Append('(');
-
- Span idBytes = stackalloc byte[16];
- for (int i = 0; i < personIdsLen; i++)
- {
- string paramName = "@PersonId" + i;
- clauseBuilder.Append("(guid in (select itemid from People where Name = (select Name from TypedBaseItems where guid=")
- .Append(paramName)
- .Append("))) OR ");
-
- statement?.TryBind(paramName, query.PersonIds[i]);
- }
-
- clauseBuilder.Length -= Or.Length;
- clauseBuilder.Append(')');
-
- whereClauses.Add(clauseBuilder.ToString());
-
- clauseBuilder.Length = 0;
- }
-
- if (!string.IsNullOrWhiteSpace(query.Person))
- {
- whereClauses.Add("Guid in (select ItemId from People where Name=@PersonName)");
- statement?.TryBind("@PersonName", query.Person);
- }
-
- if (!string.IsNullOrWhiteSpace(query.MinSortName))
- {
- whereClauses.Add("SortName>=@MinSortName");
- statement?.TryBind("@MinSortName", query.MinSortName);
- }
-
- if (!string.IsNullOrWhiteSpace(query.ExternalSeriesId))
- {
- whereClauses.Add("ExternalSeriesId=@ExternalSeriesId");
- statement?.TryBind("@ExternalSeriesId", query.ExternalSeriesId);
- }
-
- if (!string.IsNullOrWhiteSpace(query.ExternalId))
- {
- whereClauses.Add("ExternalId=@ExternalId");
- statement?.TryBind("@ExternalId", query.ExternalId);
- }
-
- if (!string.IsNullOrWhiteSpace(query.Name))
- {
- whereClauses.Add("CleanName=@Name");
- statement?.TryBind("@Name", GetCleanValue(query.Name));
- }
-
- // These are the same, for now
- var nameContains = query.NameContains;
- if (!string.IsNullOrWhiteSpace(nameContains))
- {
- whereClauses.Add("(CleanName like @NameContains or OriginalTitle like @NameContains)");
- if (statement is not null)
- {
- nameContains = FixUnicodeChars(nameContains);
- statement.TryBind("@NameContains", "%" + GetCleanValue(nameContains) + "%");
- }
- }
-
- if (!string.IsNullOrWhiteSpace(query.NameStartsWith))
- {
- whereClauses.Add("SortName like @NameStartsWith");
- statement?.TryBind("@NameStartsWith", query.NameStartsWith + "%");
- }
-
- if (!string.IsNullOrWhiteSpace(query.NameStartsWithOrGreater))
- {
- whereClauses.Add("SortName >= @NameStartsWithOrGreater");
- // lowercase this because SortName is stored as lowercase
- statement?.TryBind("@NameStartsWithOrGreater", query.NameStartsWithOrGreater.ToLowerInvariant());
- }
-
- if (!string.IsNullOrWhiteSpace(query.NameLessThan))
- {
- whereClauses.Add("SortName < @NameLessThan");
- // lowercase this because SortName is stored as lowercase
- statement?.TryBind("@NameLessThan", query.NameLessThan.ToLowerInvariant());
- }
-
- if (query.ImageTypes.Length > 0)
- {
- foreach (var requiredImage in query.ImageTypes)
- {
- whereClauses.Add("Images like '%" + requiredImage + "%'");
- }
- }
-
- if (query.IsLiked.HasValue)
- {
- if (query.IsLiked.Value)
- {
- whereClauses.Add("rating>=@UserRating");
- statement?.TryBind("@UserRating", UserItemData.MinLikeValue);
- }
- else
- {
- whereClauses.Add("(rating is null or rating<@UserRating)");
- statement?.TryBind("@UserRating", UserItemData.MinLikeValue);
- }
- }
-
- if (query.IsFavoriteOrLiked.HasValue)
- {
- if (query.IsFavoriteOrLiked.Value)
- {
- whereClauses.Add("IsFavorite=@IsFavoriteOrLiked");
- }
- else
- {
- whereClauses.Add("(IsFavorite is null or IsFavorite=@IsFavoriteOrLiked)");
- }
-
- statement?.TryBind("@IsFavoriteOrLiked", query.IsFavoriteOrLiked.Value);
- }
-
- if (query.IsFavorite.HasValue)
- {
- if (query.IsFavorite.Value)
- {
- whereClauses.Add("IsFavorite=@IsFavorite");
- }
- else
- {
- whereClauses.Add("(IsFavorite is null or IsFavorite=@IsFavorite)");
- }
-
- statement?.TryBind("@IsFavorite", query.IsFavorite.Value);
- }
-
- if (EnableJoinUserData(query))
- {
- if (query.IsPlayed.HasValue)
- {
- // We should probably figure this out for all folders, but for right now, this is the only place where we need it
- if (query.IncludeItemTypes.Length == 1 && query.IncludeItemTypes[0] == BaseItemKind.Series)
- {
- if (query.IsPlayed.Value)
- {
- whereClauses.Add("PresentationUniqueKey not in (select S.SeriesPresentationUniqueKey from TypedBaseitems S left join UserDatas UD on S.UserDataKey=UD.Key And UD.UserId=@UserId where Coalesce(UD.Played, 0)=0 and S.IsFolder=0 and S.IsVirtualItem=0 and S.SeriesPresentationUniqueKey not null)");
- }
- else
- {
- whereClauses.Add("PresentationUniqueKey in (select S.SeriesPresentationUniqueKey from TypedBaseitems S left join UserDatas UD on S.UserDataKey=UD.Key And UD.UserId=@UserId where Coalesce(UD.Played, 0)=0 and S.IsFolder=0 and S.IsVirtualItem=0 and S.SeriesPresentationUniqueKey not null)");
- }
- }
- else
- {
- if (query.IsPlayed.Value)
- {
- whereClauses.Add("(played=@IsPlayed)");
- }
- else
- {
- whereClauses.Add("(played is null or played=@IsPlayed)");
- }
-
- statement?.TryBind("@IsPlayed", query.IsPlayed.Value);
- }
- }
- }
-
- if (query.IsResumable.HasValue)
- {
- if (query.IsResumable.Value)
- {
- whereClauses.Add("playbackPositionTicks > 0");
- }
- else
- {
- whereClauses.Add("(playbackPositionTicks is null or playbackPositionTicks = 0)");
- }
- }
-
- if (query.ArtistIds.Length > 0)
- {
- clauseBuilder.Append('(');
- for (var i = 0; i < query.ArtistIds.Length; i++)
- {
- clauseBuilder.Append("(guid in (select itemid from ItemValues where CleanValue = (select CleanName from TypedBaseItems where guid=@ArtistIds")
- .Append(i)
- .Append(") and Type<=1)) OR ");
- statement?.TryBind("@ArtistIds" + i, query.ArtistIds[i]);
- }
-
- clauseBuilder.Length -= Or.Length;
- whereClauses.Add(clauseBuilder.Append(')').ToString());
- clauseBuilder.Length = 0;
- }
-
- if (query.AlbumArtistIds.Length > 0)
- {
- clauseBuilder.Append('(');
- for (var i = 0; i < query.AlbumArtistIds.Length; i++)
- {
- clauseBuilder.Append("(guid in (select itemid from ItemValues where CleanValue = (select CleanName from TypedBaseItems where guid=@ArtistIds")
- .Append(i)
- .Append(") and Type=1)) OR ");
- statement?.TryBind("@ArtistIds" + i, query.AlbumArtistIds[i]);
- }
-
- clauseBuilder.Length -= Or.Length;
- whereClauses.Add(clauseBuilder.Append(')').ToString());
- clauseBuilder.Length = 0;
- }
-
- if (query.ContributingArtistIds.Length > 0)
- {
- clauseBuilder.Append('(');
- for (var i = 0; i < query.ContributingArtistIds.Length; i++)
- {
- clauseBuilder.Append("((select CleanName from TypedBaseItems where guid=@ArtistIds")
- .Append(i)
- .Append(") in (select CleanValue from ItemValues where ItemId=Guid and Type=0) AND (select CleanName from TypedBaseItems where guid=@ArtistIds")
- .Append(i)
- .Append(") not in (select CleanValue from ItemValues where ItemId=Guid and Type=1)) OR ");
- statement?.TryBind("@ArtistIds" + i, query.ContributingArtistIds[i]);
- }
-
- clauseBuilder.Length -= Or.Length;
- whereClauses.Add(clauseBuilder.Append(')').ToString());
- clauseBuilder.Length = 0;
- }
-
- if (query.AlbumIds.Length > 0)
- {
- clauseBuilder.Append('(');
- for (var i = 0; i < query.AlbumIds.Length; i++)
- {
- clauseBuilder.Append("Album in (select Name from typedbaseitems where guid=@AlbumIds")
- .Append(i)
- .Append(") OR ");
- statement?.TryBind("@AlbumIds" + i, query.AlbumIds[i]);
- }
-
- clauseBuilder.Length -= Or.Length;
- whereClauses.Add(clauseBuilder.Append(')').ToString());
- clauseBuilder.Length = 0;
- }
-
- if (query.ExcludeArtistIds.Length > 0)
- {
- clauseBuilder.Append('(');
- for (var i = 0; i < query.ExcludeArtistIds.Length; i++)
- {
- clauseBuilder.Append("(guid not in (select itemid from ItemValues where CleanValue = (select CleanName from TypedBaseItems where guid=@ExcludeArtistId")
- .Append(i)
- .Append(") and Type<=1)) OR ");
- statement?.TryBind("@ExcludeArtistId" + i, query.ExcludeArtistIds[i]);
- }
-
- clauseBuilder.Length -= Or.Length;
- whereClauses.Add(clauseBuilder.Append(')').ToString());
- clauseBuilder.Length = 0;
- }
-
- if (query.GenreIds.Count > 0)
- {
- clauseBuilder.Append('(');
- for (var i = 0; i < query.GenreIds.Count; i++)
- {
- clauseBuilder.Append("(guid in (select itemid from ItemValues where CleanValue = (select CleanName from TypedBaseItems where guid=@GenreId")
- .Append(i)
- .Append(") and Type=2)) OR ");
- statement?.TryBind("@GenreId" + i, query.GenreIds[i]);
- }
-
- clauseBuilder.Length -= Or.Length;
- whereClauses.Add(clauseBuilder.Append(')').ToString());
- clauseBuilder.Length = 0;
- }
-
- if (query.Genres.Count > 0)
- {
- clauseBuilder.Append('(');
- for (var i = 0; i < query.Genres.Count; i++)
- {
- clauseBuilder.Append("@Genre")
- .Append(i)
- .Append(" in (select CleanValue from ItemValues where ItemId=Guid and Type=2) OR ");
- statement?.TryBind("@Genre" + i, GetCleanValue(query.Genres[i]));
- }
-
- clauseBuilder.Length -= Or.Length;
- whereClauses.Add(clauseBuilder.Append(')').ToString());
- clauseBuilder.Length = 0;
- }
-
- if (tags.Count > 0)
- {
- clauseBuilder.Append('(');
- for (var i = 0; i < tags.Count; i++)
- {
- clauseBuilder.Append("@Tag")
- .Append(i)
- .Append(" in (select CleanValue from ItemValues where ItemId=Guid and Type=4) OR ");
- statement?.TryBind("@Tag" + i, GetCleanValue(tags[i]));
- }
-
- clauseBuilder.Length -= Or.Length;
- whereClauses.Add(clauseBuilder.Append(')').ToString());
- clauseBuilder.Length = 0;
- }
-
- if (excludeTags.Count > 0)
- {
- clauseBuilder.Append('(');
- for (var i = 0; i < excludeTags.Count; i++)
- {
- clauseBuilder.Append("@ExcludeTag")
- .Append(i)
- .Append(" not in (select CleanValue from ItemValues where ItemId=Guid and Type=4) OR ");
- statement?.TryBind("@ExcludeTag" + i, GetCleanValue(excludeTags[i]));
- }
-
- clauseBuilder.Length -= Or.Length;
- whereClauses.Add(clauseBuilder.Append(')').ToString());
- clauseBuilder.Length = 0;
- }
-
- if (query.StudioIds.Length > 0)
- {
- clauseBuilder.Append('(');
- for (var i = 0; i < query.StudioIds.Length; i++)
- {
- clauseBuilder.Append("(guid in (select itemid from ItemValues where CleanValue = (select CleanName from TypedBaseItems where guid=@StudioId")
- .Append(i)
- .Append(") and Type=3)) OR ");
- statement?.TryBind("@StudioId" + i, query.StudioIds[i]);
- }
-
- clauseBuilder.Length -= Or.Length;
- whereClauses.Add(clauseBuilder.Append(')').ToString());
- clauseBuilder.Length = 0;
- }
-
- if (query.OfficialRatings.Length > 0)
- {
- clauseBuilder.Append('(');
- for (var i = 0; i < query.OfficialRatings.Length; i++)
- {
- clauseBuilder.Append("OfficialRating=@OfficialRating").Append(i).Append(Or);
- statement?.TryBind("@OfficialRating" + i, query.OfficialRatings[i]);
- }
-
- clauseBuilder.Length -= Or.Length;
- whereClauses.Add(clauseBuilder.Append(')').ToString());
- clauseBuilder.Length = 0;
- }
-
- clauseBuilder.Append('(');
- if (query.HasParentalRating ?? false)
- {
- clauseBuilder.Append("InheritedParentalRatingValue not null");
- if (query.MinParentalRating.HasValue)
- {
- clauseBuilder.Append(" AND InheritedParentalRatingValue >= @MinParentalRating");
- statement?.TryBind("@MinParentalRating", query.MinParentalRating.Value);
- }
-
- if (query.MaxParentalRating.HasValue)
- {
- clauseBuilder.Append(" AND InheritedParentalRatingValue <= @MaxParentalRating");
- statement?.TryBind("@MaxParentalRating", query.MaxParentalRating.Value);
- }
- }
- else if (query.BlockUnratedItems.Length > 0)
- {
- const string ParamName = "@UnratedType";
- clauseBuilder.Append("(InheritedParentalRatingValue is null AND UnratedType not in (");
-
- for (int i = 0; i < query.BlockUnratedItems.Length; i++)
- {
- clauseBuilder.Append(ParamName).Append(i).Append(',');
- statement?.TryBind(ParamName + i, query.BlockUnratedItems[i].ToString());
- }
-
- // Remove trailing comma
- clauseBuilder.Length--;
- clauseBuilder.Append("))");
-
- if (query.MinParentalRating.HasValue || query.MaxParentalRating.HasValue)
- {
- clauseBuilder.Append(" OR (");
- }
-
- if (query.MinParentalRating.HasValue)
- {
- clauseBuilder.Append("InheritedParentalRatingValue >= @MinParentalRating");
- statement?.TryBind("@MinParentalRating", query.MinParentalRating.Value);
- }
-
- if (query.MaxParentalRating.HasValue)
- {
- if (query.MinParentalRating.HasValue)
- {
- clauseBuilder.Append(" AND ");
- }
-
- clauseBuilder.Append("InheritedParentalRatingValue <= @MaxParentalRating");
- statement?.TryBind("@MaxParentalRating", query.MaxParentalRating.Value);
- }
-
- if (query.MinParentalRating.HasValue || query.MaxParentalRating.HasValue)
- {
- clauseBuilder.Append(')');
- }
-
- if (!(query.MinParentalRating.HasValue || query.MaxParentalRating.HasValue))
- {
- clauseBuilder.Append(" OR InheritedParentalRatingValue not null");
- }
- }
- else if (query.MinParentalRating.HasValue)
- {
- clauseBuilder.Append("InheritedParentalRatingValue is null OR (InheritedParentalRatingValue >= @MinParentalRating");
- statement?.TryBind("@MinParentalRating", query.MinParentalRating.Value);
-
- if (query.MaxParentalRating.HasValue)
- {
- clauseBuilder.Append(" AND InheritedParentalRatingValue <= @MaxParentalRating");
- statement?.TryBind("@MaxParentalRating", query.MaxParentalRating.Value);
- }
-
- clauseBuilder.Append(')');
- }
- else if (query.MaxParentalRating.HasValue)
- {
- clauseBuilder.Append("InheritedParentalRatingValue is null OR InheritedParentalRatingValue <= @MaxParentalRating");
- statement?.TryBind("@MaxParentalRating", query.MaxParentalRating.Value);
- }
- else if (!query.HasParentalRating ?? false)
- {
- clauseBuilder.Append("InheritedParentalRatingValue is null");
- }
-
- if (clauseBuilder.Length > 1)
- {
- whereClauses.Add(clauseBuilder.Append(')').ToString());
- clauseBuilder.Length = 0;
- }
-
- if (query.HasOfficialRating.HasValue)
- {
- if (query.HasOfficialRating.Value)
- {
- whereClauses.Add("(OfficialRating not null AND OfficialRating<>'')");
- }
- else
- {
- whereClauses.Add("(OfficialRating is null OR OfficialRating='')");
- }
- }
-
- if (query.HasOverview.HasValue)
- {
- if (query.HasOverview.Value)
- {
- whereClauses.Add("(Overview not null AND Overview<>'')");
- }
- else
- {
- whereClauses.Add("(Overview is null OR Overview='')");
- }
- }
-
- if (query.HasOwnerId.HasValue)
- {
- if (query.HasOwnerId.Value)
- {
- whereClauses.Add("OwnerId not null");
- }
- else
- {
- whereClauses.Add("OwnerId is null");
- }
- }
-
- if (!string.IsNullOrWhiteSpace(query.HasNoAudioTrackWithLanguage))
- {
- whereClauses.Add("((select language from MediaStreams where MediaStreams.ItemId=A.Guid and MediaStreams.StreamType='Audio' and MediaStreams.Language=@HasNoAudioTrackWithLanguage limit 1) is null)");
- statement?.TryBind("@HasNoAudioTrackWithLanguage", query.HasNoAudioTrackWithLanguage);
- }
-
- if (!string.IsNullOrWhiteSpace(query.HasNoInternalSubtitleTrackWithLanguage))
- {
- whereClauses.Add("((select language from MediaStreams where MediaStreams.ItemId=A.Guid and MediaStreams.StreamType='Subtitle' and MediaStreams.IsExternal=0 and MediaStreams.Language=@HasNoInternalSubtitleTrackWithLanguage limit 1) is null)");
- statement?.TryBind("@HasNoInternalSubtitleTrackWithLanguage", query.HasNoInternalSubtitleTrackWithLanguage);
- }
-
- if (!string.IsNullOrWhiteSpace(query.HasNoExternalSubtitleTrackWithLanguage))
- {
- whereClauses.Add("((select language from MediaStreams where MediaStreams.ItemId=A.Guid and MediaStreams.StreamType='Subtitle' and MediaStreams.IsExternal=1 and MediaStreams.Language=@HasNoExternalSubtitleTrackWithLanguage limit 1) is null)");
- statement?.TryBind("@HasNoExternalSubtitleTrackWithLanguage", query.HasNoExternalSubtitleTrackWithLanguage);
- }
-
- if (!string.IsNullOrWhiteSpace(query.HasNoSubtitleTrackWithLanguage))
- {
- whereClauses.Add("((select language from MediaStreams where MediaStreams.ItemId=A.Guid and MediaStreams.StreamType='Subtitle' and MediaStreams.Language=@HasNoSubtitleTrackWithLanguage limit 1) is null)");
- statement?.TryBind("@HasNoSubtitleTrackWithLanguage", query.HasNoSubtitleTrackWithLanguage);
- }
-
- if (query.HasSubtitles.HasValue)
- {
- if (query.HasSubtitles.Value)
- {
- whereClauses.Add("((select type from MediaStreams where MediaStreams.ItemId=A.Guid and MediaStreams.StreamType='Subtitle' limit 1) not null)");
- }
- else
- {
- whereClauses.Add("((select type from MediaStreams where MediaStreams.ItemId=A.Guid and MediaStreams.StreamType='Subtitle' limit 1) is null)");
- }
- }
-
- if (query.HasChapterImages.HasValue)
- {
- if (query.HasChapterImages.Value)
- {
- whereClauses.Add("((select imagepath from Chapters2 where Chapters2.ItemId=A.Guid and imagepath not null limit 1) not null)");
- }
- else
- {
- whereClauses.Add("((select imagepath from Chapters2 where Chapters2.ItemId=A.Guid and imagepath not null limit 1) is null)");
- }
- }
-
- if (query.HasDeadParentId.HasValue && query.HasDeadParentId.Value)
- {
- whereClauses.Add("ParentId NOT NULL AND ParentId NOT IN (select guid from TypedBaseItems)");
- }
-
- if (query.IsDeadArtist.HasValue && query.IsDeadArtist.Value)
- {
- whereClauses.Add("CleanName not in (Select CleanValue From ItemValues where Type in (0,1))");
- }
-
- if (query.IsDeadStudio.HasValue && query.IsDeadStudio.Value)
- {
- whereClauses.Add("CleanName not in (Select CleanValue From ItemValues where Type = 3)");
- }
-
- if (query.IsDeadPerson.HasValue && query.IsDeadPerson.Value)
- {
- whereClauses.Add("Name not in (Select Name From People)");
- }
-
- if (query.Years.Length == 1)
- {
- whereClauses.Add("ProductionYear=@Years");
- statement?.TryBind("@Years", query.Years[0].ToString(CultureInfo.InvariantCulture));
- }
- else if (query.Years.Length > 1)
- {
- var val = string.Join(',', query.Years);
- whereClauses.Add("ProductionYear in (" + val + ")");
- }
-
- var isVirtualItem = query.IsVirtualItem ?? query.IsMissing;
- if (isVirtualItem.HasValue)
- {
- whereClauses.Add("IsVirtualItem=@IsVirtualItem");
- statement?.TryBind("@IsVirtualItem", isVirtualItem.Value);
- }
-
- if (query.IsSpecialSeason.HasValue)
- {
- if (query.IsSpecialSeason.Value)
- {
- whereClauses.Add("IndexNumber = 0");
- }
- else
- {
- whereClauses.Add("IndexNumber <> 0");
- }
- }
-
- if (query.IsUnaired.HasValue)
- {
- if (query.IsUnaired.Value)
- {
- whereClauses.Add("PremiereDate >= DATETIME('now')");
- }
- else
- {
- whereClauses.Add("PremiereDate < DATETIME('now')");
- }
- }
-
- if (query.MediaTypes.Length == 1)
- {
- whereClauses.Add("MediaType=@MediaTypes");
- statement?.TryBind("@MediaTypes", query.MediaTypes[0].ToString());
- }
- else if (query.MediaTypes.Length > 1)
- {
- var val = string.Join(',', query.MediaTypes.Select(i => $"'{i}'"));
- whereClauses.Add("MediaType in (" + val + ")");
- }
-
- if (query.ItemIds.Length > 0)
- {
- var includeIds = new List();
- var index = 0;
- foreach (var id in query.ItemIds)
- {
- includeIds.Add("Guid = @IncludeId" + index);
- statement?.TryBind("@IncludeId" + index, id);
- index++;
- }
-
- whereClauses.Add("(" + string.Join(" OR ", includeIds) + ")");
- }
-
- if (query.ExcludeItemIds.Length > 0)
- {
- var excludeIds = new List();
- var index = 0;
- foreach (var id in query.ExcludeItemIds)
- {
- excludeIds.Add("Guid <> @ExcludeId" + index);
- statement?.TryBind("@ExcludeId" + index, id);
- index++;
- }
-
- whereClauses.Add(string.Join(" AND ", excludeIds));
- }
-
- if (query.ExcludeProviderIds is not null && query.ExcludeProviderIds.Count > 0)
- {
- var excludeIds = new List();
-
- var index = 0;
- foreach (var pair in query.ExcludeProviderIds)
- {
- if (string.Equals(pair.Key, nameof(MetadataProvider.TmdbCollection), StringComparison.OrdinalIgnoreCase))
- {
- continue;
- }
-
- var paramName = "@ExcludeProviderId" + index;
- excludeIds.Add("(ProviderIds is null or ProviderIds not like " + paramName + ")");
- statement?.TryBind(paramName, "%" + pair.Key + "=" + pair.Value + "%");
- index++;
-
- break;
- }
-
- if (excludeIds.Count > 0)
- {
- whereClauses.Add(string.Join(" AND ", excludeIds));
- }
- }
-
- if (query.HasAnyProviderId is not null && query.HasAnyProviderId.Count > 0)
- {
- var hasProviderIds = new List();
-
- var index = 0;
- foreach (var pair in query.HasAnyProviderId)
- {
- if (string.Equals(pair.Key, nameof(MetadataProvider.TmdbCollection), StringComparison.OrdinalIgnoreCase))
- {
- continue;
- }
-
- // TODO this seems to be an idea for a better schema where ProviderIds are their own table
- // but this is not implemented
- // hasProviderIds.Add("(COALESCE((select value from ProviderIds where ItemId=Guid and Name = '" + pair.Key + "'), '') <> " + paramName + ")");
-
- // TODO this is a really BAD way to do it since the pair:
- // Tmdb, 1234 matches Tmdb=1234 but also Tmdb=1234567
- // and maybe even NotTmdb=1234.
-
- // this is a placeholder for this specific pair to correlate it in the bigger query
- var paramName = "@HasAnyProviderId" + index;
-
- // this is a search for the placeholder
- hasProviderIds.Add("ProviderIds like " + paramName);
-
- // this replaces the placeholder with a value, here: %key=val%
- statement?.TryBind(paramName, "%" + pair.Key + "=" + pair.Value + "%");
- index++;
-
- break;
- }
-
- if (hasProviderIds.Count > 0)
- {
- whereClauses.Add("(" + string.Join(" OR ", hasProviderIds) + ")");
- }
- }
-
- if (query.HasImdbId.HasValue)
- {
- whereClauses.Add(GetProviderIdClause(query.HasImdbId.Value, "imdb"));
- }
-
- if (query.HasTmdbId.HasValue)
- {
- whereClauses.Add(GetProviderIdClause(query.HasTmdbId.Value, "tmdb"));
- }
-
- if (query.HasTvdbId.HasValue)
- {
- whereClauses.Add(GetProviderIdClause(query.HasTvdbId.Value, "tvdb"));
- }
-
- var queryTopParentIds = query.TopParentIds;
-
- if (queryTopParentIds.Length > 0)
- {
- var includedItemByNameTypes = GetItemByNameTypesInQuery(query);
- var enableItemsByName = (query.IncludeItemsByName ?? false) && includedItemByNameTypes.Count > 0;
-
- if (queryTopParentIds.Length == 1)
- {
- if (enableItemsByName && includedItemByNameTypes.Count == 1)
- {
- whereClauses.Add("(TopParentId=@TopParentId or Type=@IncludedItemByNameType)");
- statement?.TryBind("@IncludedItemByNameType", includedItemByNameTypes[0]);
- }
- else if (enableItemsByName && includedItemByNameTypes.Count > 1)
- {
- var itemByNameTypeVal = string.Join(',', includedItemByNameTypes.Select(i => "'" + i + "'"));
- whereClauses.Add("(TopParentId=@TopParentId or Type in (" + itemByNameTypeVal + "))");
- }
- else
- {
- whereClauses.Add("(TopParentId=@TopParentId)");
- }
-
- statement?.TryBind("@TopParentId", queryTopParentIds[0].ToString("N", CultureInfo.InvariantCulture));
- }
- else if (queryTopParentIds.Length > 1)
- {
- var val = string.Join(',', queryTopParentIds.Select(i => "'" + i.ToString("N", CultureInfo.InvariantCulture) + "'"));
-
- if (enableItemsByName && includedItemByNameTypes.Count == 1)
- {
- whereClauses.Add("(Type=@IncludedItemByNameType or TopParentId in (" + val + "))");
- statement?.TryBind("@IncludedItemByNameType", includedItemByNameTypes[0]);
- }
- else if (enableItemsByName && includedItemByNameTypes.Count > 1)
- {
- var itemByNameTypeVal = string.Join(',', includedItemByNameTypes.Select(i => "'" + i + "'"));
- whereClauses.Add("(Type in (" + itemByNameTypeVal + ") or TopParentId in (" + val + "))");
- }
- else
- {
- whereClauses.Add("TopParentId in (" + val + ")");
- }
- }
- }
-
- if (query.AncestorIds.Length == 1)
- {
- whereClauses.Add("Guid in (select itemId from AncestorIds where AncestorId=@AncestorId)");
- statement?.TryBind("@AncestorId", query.AncestorIds[0]);
- }
-
- if (query.AncestorIds.Length > 1)
- {
- var inClause = string.Join(',', query.AncestorIds.Select(i => "'" + i.ToString("N", CultureInfo.InvariantCulture) + "'"));
- whereClauses.Add(string.Format(CultureInfo.InvariantCulture, "Guid in (select itemId from AncestorIds where AncestorIdText in ({0}))", inClause));
- }
-
- if (!string.IsNullOrWhiteSpace(query.AncestorWithPresentationUniqueKey))
- {
- var inClause = "select guid from TypedBaseItems where PresentationUniqueKey=@AncestorWithPresentationUniqueKey";
- whereClauses.Add(string.Format(CultureInfo.InvariantCulture, "Guid in (select itemId from AncestorIds where AncestorId in ({0}))", inClause));
- statement?.TryBind("@AncestorWithPresentationUniqueKey", query.AncestorWithPresentationUniqueKey);
- }
-
- if (!string.IsNullOrWhiteSpace(query.SeriesPresentationUniqueKey))
- {
- whereClauses.Add("SeriesPresentationUniqueKey=@SeriesPresentationUniqueKey");
- statement?.TryBind("@SeriesPresentationUniqueKey", query.SeriesPresentationUniqueKey);
- }
-
- if (query.ExcludeInheritedTags.Length > 0)
- {
- var paramName = "@ExcludeInheritedTags";
- if (statement is null)
- {
- int index = 0;
- string excludedTags = string.Join(',', query.ExcludeInheritedTags.Select(_ => paramName + index++));
- whereClauses.Add("((select CleanValue from ItemValues where ItemId=Guid and Type=6 and cleanvalue in (" + excludedTags + ")) is null)");
- }
- else
- {
- for (int index = 0; index < query.ExcludeInheritedTags.Length; index++)
- {
- statement.TryBind(paramName + index, GetCleanValue(query.ExcludeInheritedTags[index]));
- }
- }
- }
-
- if (query.IncludeInheritedTags.Length > 0)
- {
- var paramName = "@IncludeInheritedTags";
- if (statement is null)
- {
- int index = 0;
- string includedTags = string.Join(',', query.IncludeInheritedTags.Select(_ => paramName + index++));
- // Episodes do not store inherit tags from their parents in the database, and the tag may be still required by the client.
- // In addtion to the tags for the episodes themselves, we need to manually query its parent (the season)'s tags as well.
- if (includeTypes.Length == 1 && includeTypes.FirstOrDefault() is BaseItemKind.Episode)
- {
- whereClauses.Add($"""
- ((select CleanValue from ItemValues where ItemId=Guid and Type=6 and CleanValue in ({includedTags})) is not null
- OR (select CleanValue from ItemValues where ItemId=ParentId and Type=6 and CleanValue in ({includedTags})) is not null)
- """);
- }
-
- // A playlist should be accessible to its owner regardless of allowed tags.
- else if (includeTypes.Length == 1 && includeTypes.FirstOrDefault() is BaseItemKind.Playlist)
- {
- whereClauses.Add($"""
- ((select CleanValue from ItemValues where ItemId=Guid and Type=6 and CleanValue in ({includedTags})) is not null
- OR data like @PlaylistOwnerUserId)
- """);
- }
- else
- {
- whereClauses.Add("((select CleanValue from ItemValues where ItemId=Guid and Type=6 and cleanvalue in (" + includedTags + ")) is not null)");
- }
- }
- else
- {
- for (int index = 0; index < query.IncludeInheritedTags.Length; index++)
- {
- statement.TryBind(paramName + index, GetCleanValue(query.IncludeInheritedTags[index]));
- }
-
- if (query.User is not null)
- {
- statement.TryBind("@PlaylistOwnerUserId", $"""%"OwnerUserId":"{query.User.Id.ToString("N")}"%""");
- }
- }
- }
-
- if (query.SeriesStatuses.Length > 0)
- {
- var statuses = new List();
-
- foreach (var seriesStatus in query.SeriesStatuses)
- {
- statuses.Add("data like '%" + seriesStatus + "%'");
- }
-
- whereClauses.Add("(" + string.Join(" OR ", statuses) + ")");
- }
-
- if (query.BoxSetLibraryFolders.Length > 0)
- {
- var folderIdQueries = new List();
-
- foreach (var folderId in query.BoxSetLibraryFolders)
- {
- folderIdQueries.Add("data like '%" + folderId.ToString("N", CultureInfo.InvariantCulture) + "%'");
- }
-
- whereClauses.Add("(" + string.Join(" OR ", folderIdQueries) + ")");
- }
-
- if (query.VideoTypes.Length > 0)
- {
- var videoTypes = new List();
-
- foreach (var videoType in query.VideoTypes)
- {
- videoTypes.Add("data like '%\"VideoType\":\"" + videoType + "\"%'");
- }
-
- whereClauses.Add("(" + string.Join(" OR ", videoTypes) + ")");
- }
-
- if (query.Is3D.HasValue)
- {
- if (query.Is3D.Value)
- {
- whereClauses.Add("data like '%Video3DFormat%'");
- }
- else
- {
- whereClauses.Add("data not like '%Video3DFormat%'");
- }
- }
-
- if (query.IsPlaceHolder.HasValue)
- {
- if (query.IsPlaceHolder.Value)
- {
- whereClauses.Add("data like '%\"IsPlaceHolder\":true%'");
- }
- else
- {
- whereClauses.Add("(data is null or data not like '%\"IsPlaceHolder\":true%')");
- }
- }
-
- if (query.HasSpecialFeature.HasValue)
- {
- if (query.HasSpecialFeature.Value)
- {
- whereClauses.Add("ExtraIds not null");
- }
- else
- {
- whereClauses.Add("ExtraIds is null");
- }
- }
-
- if (query.HasTrailer.HasValue)
- {
- if (query.HasTrailer.Value)
- {
- whereClauses.Add("ExtraIds not null");
- }
- else
- {
- whereClauses.Add("ExtraIds is null");
- }
- }
-
- if (query.HasThemeSong.HasValue)
- {
- if (query.HasThemeSong.Value)
- {
- whereClauses.Add("ExtraIds not null");
- }
- else
- {
- whereClauses.Add("ExtraIds is null");
- }
- }
-
- if (query.HasThemeVideo.HasValue)
- {
- if (query.HasThemeVideo.Value)
- {
- whereClauses.Add("ExtraIds not null");
- }
- else
- {
- whereClauses.Add("ExtraIds is null");
- }
- }
-
- return whereClauses;
- }
-
- ///
- /// Formats a where clause for the specified provider.
- ///
- /// Whether or not to include items with this provider's ids.
- /// Provider name.
- /// Formatted SQL clause.
- private string GetProviderIdClause(bool includeResults, string provider)
- {
- return string.Format(
- CultureInfo.InvariantCulture,
- "ProviderIds {0} like '%{1}=%'",
- includeResults ? string.Empty : "not",
- provider);
- }
-
-#nullable disable
- private List GetItemByNameTypesInQuery(InternalItemsQuery query)
- {
- var list = new List();
-
- if (IsTypeInQuery(BaseItemKind.Person, query))
- {
- list.Add(typeof(Person).FullName);
- }
-
- if (IsTypeInQuery(BaseItemKind.Genre, query))
- {
- list.Add(typeof(Genre).FullName);
- }
-
- if (IsTypeInQuery(BaseItemKind.MusicGenre, query))
- {
- list.Add(typeof(MusicGenre).FullName);
- }
-
- if (IsTypeInQuery(BaseItemKind.MusicArtist, query))
- {
- list.Add(typeof(MusicArtist).FullName);
- }
-
- if (IsTypeInQuery(BaseItemKind.Studio, query))
- {
- list.Add(typeof(Studio).FullName);
- }
-
- return list;
- }
-
- private bool IsTypeInQuery(BaseItemKind type, InternalItemsQuery query)
- {
- if (query.ExcludeItemTypes.Contains(type))
- {
- return false;
- }
-
- return query.IncludeItemTypes.Length == 0 || query.IncludeItemTypes.Contains(type);
- }
-
- private string GetCleanValue(string value)
- {
- if (string.IsNullOrWhiteSpace(value))
- {
- return value;
- }
-
- return value.RemoveDiacritics().ToLowerInvariant();
- }
-
- private bool EnableGroupByPresentationUniqueKey(InternalItemsQuery query)
- {
- if (!query.GroupByPresentationUniqueKey)
- {
- return false;
- }
-
- if (query.GroupBySeriesPresentationUniqueKey)
- {
- return false;
- }
-
- if (!string.IsNullOrWhiteSpace(query.PresentationUniqueKey))
- {
- return false;
- }
-
- if (query.User is null)
- {
- return false;
- }
-
- if (query.IncludeItemTypes.Length == 0)
- {
- return true;
- }
-
- return query.IncludeItemTypes.Contains(BaseItemKind.Episode)
- || query.IncludeItemTypes.Contains(BaseItemKind.Video)
- || query.IncludeItemTypes.Contains(BaseItemKind.Movie)
- || query.IncludeItemTypes.Contains(BaseItemKind.MusicVideo)
- || query.IncludeItemTypes.Contains(BaseItemKind.Series)
- || query.IncludeItemTypes.Contains(BaseItemKind.Season);
- }
-
- ///
- public void UpdateInheritedValues()
- {
- const string Statements = """
-delete from ItemValues where type = 6;
-insert into ItemValues (ItemId, Type, Value, CleanValue) select ItemId, 6, Value, CleanValue from ItemValues where Type=4;
-insert into ItemValues (ItemId, Type, Value, CleanValue) select AncestorIds.itemid, 6, ItemValues.Value, ItemValues.CleanValue
-FROM AncestorIds
-LEFT JOIN ItemValues ON (AncestorIds.AncestorId = ItemValues.ItemId)
-where AncestorIdText not null and ItemValues.Value not null and ItemValues.Type = 4;
-""";
- using var connection = GetConnection();
- using var transaction = connection.BeginTransaction();
- connection.Execute(Statements);
- transaction.Commit();
- }
-
- ///
- public void DeleteItem(Guid id)
- {
- if (id.IsEmpty())
- {
- throw new ArgumentNullException(nameof(id));
- }
-
- CheckDisposed();
-
- using var connection = GetConnection();
- using var transaction = connection.BeginTransaction();
- // Delete people
- ExecuteWithSingleParam(connection, "delete from People where ItemId=@Id", id);
-
- // Delete chapters
- ExecuteWithSingleParam(connection, "delete from " + ChaptersTableName + " where ItemId=@Id", id);
-
- // Delete media streams
- ExecuteWithSingleParam(connection, "delete from mediastreams where ItemId=@Id", id);
-
- // Delete ancestors
- ExecuteWithSingleParam(connection, "delete from AncestorIds where ItemId=@Id", id);
-
- // Delete item values
- ExecuteWithSingleParam(connection, "delete from ItemValues where ItemId=@Id", id);
-
- // Delete the item
- ExecuteWithSingleParam(connection, "delete from TypedBaseItems where guid=@Id", id);
-
- transaction.Commit();
- }
-
- private void ExecuteWithSingleParam(ManagedConnection db, string query, Guid value)
- {
- using (var statement = PrepareStatement(db, query))
- {
- statement.TryBind("@Id", value);
-
- statement.ExecuteNonQuery();
- }
- }
-
- ///
- public List GetPeopleNames(InternalPeopleQuery query)
- {
- ArgumentNullException.ThrowIfNull(query);
-
- CheckDisposed();
-
- var commandText = new StringBuilder("select Distinct p.Name from People p");
-
- var whereClauses = GetPeopleWhereClauses(query, null);
-
- if (whereClauses.Count != 0)
- {
- commandText.Append(" where ").AppendJoin(" AND ", whereClauses);
- }
-
- commandText.Append(" order by ListOrder");
-
- if (query.Limit > 0)
- {
- commandText.Append(" LIMIT ").Append(query.Limit);
- }
-
- var list = new List();
- using (var connection = GetConnection(true))
- using (var statement = PrepareStatement(connection, commandText.ToString()))
- {
- // Run this again to bind the params
- GetPeopleWhereClauses(query, statement);
-
- foreach (var row in statement.ExecuteQuery())
- {
- list.Add(row.GetString(0));
- }
- }
-
- return list;
- }
-
- ///
- public List GetPeople(InternalPeopleQuery query)
- {
- ArgumentNullException.ThrowIfNull(query);
-
- CheckDisposed();
-
- StringBuilder commandText = new StringBuilder("select ItemId, Name, Role, PersonType, SortOrder from People p");
-
- var whereClauses = GetPeopleWhereClauses(query, null);
-
- if (whereClauses.Count != 0)
- {
- commandText.Append(" where ").AppendJoin(" AND ", whereClauses);
- }
-
- commandText.Append(" order by ListOrder");
-
- if (query.Limit > 0)
- {
- commandText.Append(" LIMIT ").Append(query.Limit);
- }
-
- var list = new List();
- using (var connection = GetConnection(true))
- using (var statement = PrepareStatement(connection, commandText.ToString()))
- {
- // Run this again to bind the params
- GetPeopleWhereClauses(query, statement);
-
- foreach (var row in statement.ExecuteQuery())
- {
- list.Add(GetPerson(row));
- }
- }
-
- return list;
- }
-
- private List GetPeopleWhereClauses(InternalPeopleQuery query, SqliteCommand statement)
- {
- var whereClauses = new List();
-
- if (query.User is not null && query.IsFavorite.HasValue)
- {
- whereClauses.Add(@"p.Name IN (
-SELECT Name FROM TypedBaseItems WHERE UserDataKey IN (
-SELECT key FROM UserDatas WHERE isFavorite=@IsFavorite AND userId=@UserId)
-AND Type = @InternalPersonType)");
- statement?.TryBind("@IsFavorite", query.IsFavorite.Value);
- statement?.TryBind("@InternalPersonType", typeof(Person).FullName);
- statement?.TryBind("@UserId", query.User.InternalId);
- }
-
- if (!query.ItemId.IsEmpty())
- {
- whereClauses.Add("ItemId=@ItemId");
- statement?.TryBind("@ItemId", query.ItemId);
- }
-
- if (!query.AppearsInItemId.IsEmpty())
- {
- whereClauses.Add("p.Name in (Select Name from People where ItemId=@AppearsInItemId)");
- statement?.TryBind("@AppearsInItemId", query.AppearsInItemId);
- }
-
- var queryPersonTypes = query.PersonTypes.Where(IsValidPersonType).ToList();
-
- if (queryPersonTypes.Count == 1)
- {
- whereClauses.Add("PersonType=@PersonType");
- statement?.TryBind("@PersonType", queryPersonTypes[0]);
- }
- else if (queryPersonTypes.Count > 1)
- {
- var val = string.Join(',', queryPersonTypes.Select(i => "'" + i + "'"));
-
- whereClauses.Add("PersonType in (" + val + ")");
- }
-
- var queryExcludePersonTypes = query.ExcludePersonTypes.Where(IsValidPersonType).ToList();
-
- if (queryExcludePersonTypes.Count == 1)
- {
- whereClauses.Add("PersonType<>@PersonType");
- statement?.TryBind("@PersonType", queryExcludePersonTypes[0]);
- }
- else if (queryExcludePersonTypes.Count > 1)
- {
- var val = string.Join(',', queryExcludePersonTypes.Select(i => "'" + i + "'"));
-
- whereClauses.Add("PersonType not in (" + val + ")");
- }
-
- if (query.MaxListOrder.HasValue)
- {
- whereClauses.Add("ListOrder<=@MaxListOrder");
- statement?.TryBind("@MaxListOrder", query.MaxListOrder.Value);
- }
-
- if (!string.IsNullOrWhiteSpace(query.NameContains))
- {
- whereClauses.Add("p.Name like @NameContains");
- statement?.TryBind("@NameContains", "%" + query.NameContains + "%");
- }
-
- return whereClauses;
- }
-
- private void UpdateAncestors(Guid itemId, List ancestorIds, ManagedConnection db, SqliteCommand deleteAncestorsStatement)
- {
- if (itemId.IsEmpty())
- {
- throw new ArgumentNullException(nameof(itemId));
- }
-
- ArgumentNullException.ThrowIfNull(ancestorIds);
-
- CheckDisposed();
-
- // First delete
- deleteAncestorsStatement.TryBind("@ItemId", itemId);
- deleteAncestorsStatement.ExecuteNonQuery();
-
- if (ancestorIds.Count == 0)
- {
- return;
- }
-
- var insertText = new StringBuilder("insert into AncestorIds (ItemId, AncestorId, AncestorIdText) values ");
-
- for (var i = 0; i < ancestorIds.Count; i++)
- {
- insertText.AppendFormat(
- CultureInfo.InvariantCulture,
- "(@ItemId, @AncestorId{0}, @AncestorIdText{0}),",
- i.ToString(CultureInfo.InvariantCulture));
- }
-
- // Remove trailing comma
- insertText.Length--;
-
- using (var statement = PrepareStatement(db, insertText.ToString()))
- {
- statement.TryBind("@ItemId", itemId);
-
- for (var i = 0; i < ancestorIds.Count; i++)
- {
- var index = i.ToString(CultureInfo.InvariantCulture);
-
- var ancestorId = ancestorIds[i];
-
- statement.TryBind("@AncestorId" + index, ancestorId);
- statement.TryBind("@AncestorIdText" + index, ancestorId.ToString("N", CultureInfo.InvariantCulture));
- }
-
- statement.ExecuteNonQuery();
- }
- }
-
- ///
- public QueryResult<(BaseItem Item, ItemCounts ItemCounts)> GetAllArtists(InternalItemsQuery query)
- {
- return GetItemValues(query, new[] { 0, 1 }, typeof(MusicArtist).FullName);
- }
-
- ///
- public QueryResult<(BaseItem Item, ItemCounts ItemCounts)> GetArtists(InternalItemsQuery query)
- {
- return GetItemValues(query, new[] { 0 }, typeof(MusicArtist).FullName);
- }
-
- ///
- public QueryResult<(BaseItem Item, ItemCounts ItemCounts)> GetAlbumArtists(InternalItemsQuery query)
- {
- return GetItemValues(query, new[] { 1 }, typeof(MusicArtist).FullName);
- }
-
- ///
- public QueryResult<(BaseItem Item, ItemCounts ItemCounts)> GetStudios(InternalItemsQuery query)
- {
- return GetItemValues(query, new[] { 3 }, typeof(Studio).FullName);
- }
-
- ///
- public QueryResult<(BaseItem Item, ItemCounts ItemCounts)> GetGenres(InternalItemsQuery query)
- {
- return GetItemValues(query, new[] { 2 }, typeof(Genre).FullName);
- }
-
- ///
- public QueryResult<(BaseItem Item, ItemCounts ItemCounts)> GetMusicGenres(InternalItemsQuery query)
- {
- return GetItemValues(query, new[] { 2 }, typeof(MusicGenre).FullName);
- }
-
- ///
- public List GetStudioNames()
- {
- return GetItemValueNames(new[] { 3 }, Array.Empty(), Array.Empty());
- }
-
- ///
- public List GetAllArtistNames()
- {
- return GetItemValueNames(new[] { 0, 1 }, Array.Empty(), Array.Empty());
- }
-
- ///
- public List GetMusicGenreNames()
- {
- return GetItemValueNames(
- new[] { 2 },
- new string[]
- {
- typeof(Audio).FullName,
- typeof(MusicVideo).FullName,
- typeof(MusicAlbum).FullName,
- typeof(MusicArtist).FullName
- },
- Array.Empty());
- }
-
- ///
- public List GetGenreNames()
- {
- return GetItemValueNames(
- new[] { 2 },
- Array.Empty(),
- new string[]
- {
- typeof(Audio).FullName,
- typeof(MusicVideo).FullName,
- typeof(MusicAlbum).FullName,
- typeof(MusicArtist).FullName
- });
- }
-
- private List GetItemValueNames(int[] itemValueTypes, IReadOnlyList withItemTypes, IReadOnlyList excludeItemTypes)
- {
- CheckDisposed();
-
- var stringBuilder = new StringBuilder("Select Value From ItemValues where Type", 128);
- if (itemValueTypes.Length == 1)
- {
- stringBuilder.Append('=')
- .Append(itemValueTypes[0]);
- }
- else
- {
- stringBuilder.Append(" in (")
- .AppendJoin(',', itemValueTypes)
- .Append(')');
- }
-
- if (withItemTypes.Count > 0)
- {
- stringBuilder.Append(" AND ItemId In (select guid from typedbaseitems where type in (")
- .AppendJoinInSingleQuotes(',', withItemTypes)
- .Append("))");
- }
-
- if (excludeItemTypes.Count > 0)
- {
- stringBuilder.Append(" AND ItemId not In (select guid from typedbaseitems where type in (")
- .AppendJoinInSingleQuotes(',', excludeItemTypes)
- .Append("))");
- }
-
- stringBuilder.Append(" Group By CleanValue");
- var commandText = stringBuilder.ToString();
-
- var list = new List();
- using (new QueryTimeLogger(Logger, commandText))
- using (var connection = GetConnection(true))
- using (var statement = PrepareStatement(connection, commandText))
- {
- foreach (var row in statement.ExecuteQuery())
- {
- if (row.TryGetString(0, out var result))
- {
- list.Add(result);
- }
- }
- }
-
- return list;
- }
-
- private QueryResult<(BaseItem Item, ItemCounts ItemCounts)> GetItemValues(InternalItemsQuery query, int[] itemValueTypes, string returnType)
- {
- ArgumentNullException.ThrowIfNull(query);
-
- if (!query.Limit.HasValue)
- {
- query.EnableTotalRecordCount = false;
- }
-
- CheckDisposed();
-
- var typeClause = itemValueTypes.Length == 1 ?
- ("Type=" + itemValueTypes[0]) :
- ("Type in (" + string.Join(',', itemValueTypes) + ")");
-
- InternalItemsQuery typeSubQuery = null;
-
- string itemCountColumns = null;
-
- var stringBuilder = new StringBuilder(1024);
- var typesToCount = query.IncludeItemTypes;
-
- if (typesToCount.Length > 0)
- {
- stringBuilder.Append("(select group_concat(type, '|') from TypedBaseItems B");
-
- typeSubQuery = new InternalItemsQuery(query.User)
- {
- ExcludeItemTypes = query.ExcludeItemTypes,
- IncludeItemTypes = query.IncludeItemTypes,
- MediaTypes = query.MediaTypes,
- AncestorIds = query.AncestorIds,
- ExcludeItemIds = query.ExcludeItemIds,
- ItemIds = query.ItemIds,
- TopParentIds = query.TopParentIds,
- ParentId = query.ParentId,
- IsPlayed = query.IsPlayed
- };
- var whereClauses = GetWhereClauses(typeSubQuery, null);
-
- stringBuilder.Append(" where ")
- .AppendJoin(" AND ", whereClauses)
- .Append(" AND ")
- .Append("guid in (select ItemId from ItemValues where ItemValues.CleanValue=A.CleanName AND ")
- .Append(typeClause)
- .Append(")) as itemTypes");
-
- itemCountColumns = stringBuilder.ToString();
- stringBuilder.Clear();
- }
-
- List columns = _retrieveItemColumns.ToList();
- // Unfortunately we need to add it to columns to ensure the order of the columns in the select
- if (!string.IsNullOrEmpty(itemCountColumns))
- {
- columns.Add(itemCountColumns);
- }
-
- // do this first before calling GetFinalColumnsToSelect, otherwise ExcludeItemIds will be set by SimilarTo
- var innerQuery = new InternalItemsQuery(query.User)
- {
- ExcludeItemTypes = query.ExcludeItemTypes,
- IncludeItemTypes = query.IncludeItemTypes,
- MediaTypes = query.MediaTypes,
- AncestorIds = query.AncestorIds,
- ItemIds = query.ItemIds,
- TopParentIds = query.TopParentIds,
- ParentId = query.ParentId,
- IsAiring = query.IsAiring,
- IsMovie = query.IsMovie,
- IsSports = query.IsSports,
- IsKids = query.IsKids,
- IsNews = query.IsNews,
- IsSeries = query.IsSeries
- };
-
- SetFinalColumnsToSelect(query, columns);
-
- var innerWhereClauses = GetWhereClauses(innerQuery, null);
-
- stringBuilder.Append(" where Type=@SelectType And CleanName In (Select CleanValue from ItemValues where ")
- .Append(typeClause)
- .Append(" AND ItemId in (select guid from TypedBaseItems");
- if (innerWhereClauses.Count > 0)
- {
- stringBuilder.Append(" where ")
- .AppendJoin(" AND ", innerWhereClauses);
- }
-
- stringBuilder.Append("))");
-
- var outerQuery = new InternalItemsQuery(query.User)
- {
- IsPlayed = query.IsPlayed,
- IsFavorite = query.IsFavorite,
- IsFavoriteOrLiked = query.IsFavoriteOrLiked,
- IsLiked = query.IsLiked,
- IsLocked = query.IsLocked,
- NameLessThan = query.NameLessThan,
- NameStartsWith = query.NameStartsWith,
- NameStartsWithOrGreater = query.NameStartsWithOrGreater,
- Tags = query.Tags,
- OfficialRatings = query.OfficialRatings,
- StudioIds = query.StudioIds,
- GenreIds = query.GenreIds,
- Genres = query.Genres,
- Years = query.Years,
- NameContains = query.NameContains,
- SearchTerm = query.SearchTerm,
- SimilarTo = query.SimilarTo,
- ExcludeItemIds = query.ExcludeItemIds
- };
-
- var outerWhereClauses = GetWhereClauses(outerQuery, null);
- if (outerWhereClauses.Count != 0)
- {
- stringBuilder.Append(" AND ")
- .AppendJoin(" AND ", outerWhereClauses);
- }
-
- var whereText = stringBuilder.ToString();
- stringBuilder.Clear();
-
- stringBuilder.Append("select ")
- .AppendJoin(',', columns)
- .Append(FromText)
- .Append(GetJoinUserDataText(query))
- .Append(whereText)
- .Append(" group by PresentationUniqueKey");
-
- if (query.OrderBy.Count != 0
- || query.SimilarTo is not null
- || !string.IsNullOrEmpty(query.SearchTerm))
- {
- stringBuilder.Append(GetOrderByText(query));
- }
- else
- {
- stringBuilder.Append(" order by SortName");
- }
-
- if (query.Limit.HasValue || query.StartIndex.HasValue)
- {
- var offset = query.StartIndex ?? 0;
-
- if (query.Limit.HasValue || offset > 0)
- {
- stringBuilder.Append(" LIMIT ")
- .Append(query.Limit ?? int.MaxValue);
- }
-
- if (offset > 0)
- {
- stringBuilder.Append(" OFFSET ")
- .Append(offset);
- }
- }
-
- var isReturningZeroItems = query.Limit.HasValue && query.Limit <= 0;
-
- string commandText = string.Empty;
-
- if (!isReturningZeroItems)
- {
- commandText = stringBuilder.ToString();
- }
-
- string countText = string.Empty;
- if (query.EnableTotalRecordCount)
- {
- stringBuilder.Clear();
- var columnsToSelect = new List { "count (distinct PresentationUniqueKey)" };
- SetFinalColumnsToSelect(query, columnsToSelect);
- stringBuilder.Append("select ")
- .AppendJoin(',', columnsToSelect)
- .Append(FromText)
- .Append(GetJoinUserDataText(query))
- .Append(whereText);
-
- countText = stringBuilder.ToString();
- }
-
- var list = new List<(BaseItem, ItemCounts)>();
- var result = new QueryResult<(BaseItem, ItemCounts)>();
- using (new QueryTimeLogger(Logger, commandText))
- using (var connection = GetConnection(true))
- using (var transaction = connection.BeginTransaction())
- {
- if (!isReturningZeroItems)
- {
- using (var statement = PrepareStatement(connection, commandText))
- {
- statement.TryBind("@SelectType", returnType);
- if (EnableJoinUserData(query))
- {
- statement.TryBind("@UserId", query.User.InternalId);
- }
-
- if (typeSubQuery is not null)
- {
- GetWhereClauses(typeSubQuery, null);
- }
-
- BindSimilarParams(query, statement);
- BindSearchParams(query, statement);
- GetWhereClauses(innerQuery, statement);
- GetWhereClauses(outerQuery, statement);
-
- var hasEpisodeAttributes = HasEpisodeAttributes(query);
- var hasProgramAttributes = HasProgramAttributes(query);
- var hasServiceName = HasServiceName(query);
- var hasStartDate = HasStartDate(query);
- var hasTrailerTypes = HasTrailerTypes(query);
- var hasArtistFields = HasArtistFields(query);
- var hasSeriesFields = HasSeriesFields(query);
-
- foreach (var row in statement.ExecuteQuery())
- {
- var item = GetItem(row, query, hasProgramAttributes, hasEpisodeAttributes, hasServiceName, hasStartDate, hasTrailerTypes, hasArtistFields, hasSeriesFields, false);
- if (item is not null)
- {
- var countStartColumn = columns.Count - 1;
-
- list.Add((item, GetItemCounts(row, countStartColumn, typesToCount)));
- }
- }
- }
- }
-
- if (query.EnableTotalRecordCount)
- {
- using (var statement = PrepareStatement(connection, countText))
- {
- statement.TryBind("@SelectType", returnType);
- if (EnableJoinUserData(query))
- {
- statement.TryBind("@UserId", query.User.InternalId);
- }
-
- if (typeSubQuery is not null)
- {
- GetWhereClauses(typeSubQuery, null);
- }
-
- BindSimilarParams(query, statement);
- BindSearchParams(query, statement);
- GetWhereClauses(innerQuery, statement);
- GetWhereClauses(outerQuery, statement);
-
- result.TotalRecordCount = statement.SelectScalarInt();
- }
- }
-
- transaction.Commit();
- }
-
- if (result.TotalRecordCount == 0)
- {
- result.TotalRecordCount = list.Count;
- }
-
- result.StartIndex = query.StartIndex ?? 0;
- result.Items = list;
-
- return result;
- }
-
- private static ItemCounts GetItemCounts(SqliteDataReader reader, int countStartColumn, BaseItemKind[] typesToCount)
- {
- var counts = new ItemCounts();
-
- if (typesToCount.Length == 0)
- {
- return counts;
- }
-
- if (!reader.TryGetString(countStartColumn, out var typeString))
- {
- return counts;
- }
-
- foreach (var typeName in typeString.AsSpan().Split('|'))
- {
- if (typeName.Equals(typeof(Series).FullName, StringComparison.OrdinalIgnoreCase))
- {
- counts.SeriesCount++;
- }
- else if (typeName.Equals(typeof(Episode).FullName, StringComparison.OrdinalIgnoreCase))
- {
- counts.EpisodeCount++;
- }
- else if (typeName.Equals(typeof(Movie).FullName, StringComparison.OrdinalIgnoreCase))
- {
- counts.MovieCount++;
- }
- else if (typeName.Equals(typeof(MusicAlbum).FullName, StringComparison.OrdinalIgnoreCase))
- {
- counts.AlbumCount++;
- }
- else if (typeName.Equals(typeof(MusicArtist).FullName, StringComparison.OrdinalIgnoreCase))
- {
- counts.ArtistCount++;
- }
- else if (typeName.Equals(typeof(Audio).FullName, StringComparison.OrdinalIgnoreCase))
- {
- counts.SongCount++;
- }
- else if (typeName.Equals(typeof(Trailer).FullName, StringComparison.OrdinalIgnoreCase))
- {
- counts.TrailerCount++;
- }
-
- counts.ItemCount++;
- }
-
- return counts;
- }
-
- private List<(int MagicNumber, string Value)> GetItemValuesToSave(BaseItem item, List inheritedTags)
- {
- var list = new List<(int, string)>();
-
- if (item is IHasArtist hasArtist)
- {
- list.AddRange(hasArtist.Artists.Select(i => (0, i)));
- }
-
- if (item is IHasAlbumArtist hasAlbumArtist)
- {
- list.AddRange(hasAlbumArtist.AlbumArtists.Select(i => (1, i)));
- }
-
- list.AddRange(item.Genres.Select(i => (2, i)));
- list.AddRange(item.Studios.Select(i => (3, i)));
- list.AddRange(item.Tags.Select(i => (4, i)));
-
- // keywords was 5
-
- list.AddRange(inheritedTags.Select(i => (6, i)));
-
- // Remove all invalid values.
- list.RemoveAll(i => string.IsNullOrWhiteSpace(i.Item2));
-
- return list;
- }
-
- private void UpdateItemValues(Guid itemId, List<(int MagicNumber, string Value)> values, ManagedConnection db)
- {
- if (itemId.IsEmpty())
- {
- throw new ArgumentNullException(nameof(itemId));
- }
-
- ArgumentNullException.ThrowIfNull(values);
-
- CheckDisposed();
-
- // First delete
- using var command = db.PrepareStatement("delete from ItemValues where ItemId=@Id");
- command.TryBind("@Id", itemId);
- command.ExecuteNonQuery();
-
- InsertItemValues(itemId, values, db);
- }
-
- private void InsertItemValues(Guid id, List<(int MagicNumber, string Value)> values, ManagedConnection db)
- {
- const int Limit = 100;
- var startIndex = 0;
-
- const string StartInsertText = "insert into ItemValues (ItemId, Type, Value, CleanValue) values ";
- var insertText = new StringBuilder(StartInsertText);
- while (startIndex < values.Count)
- {
- var endIndex = Math.Min(values.Count, startIndex + Limit);
-
- for (var i = startIndex; i < endIndex; i++)
- {
- insertText.AppendFormat(
- CultureInfo.InvariantCulture,
- "(@ItemId, @Type{0}, @Value{0}, @CleanValue{0}),",
- i);
- }
-
- // Remove trailing comma
- insertText.Length--;
-
- using (var statement = PrepareStatement(db, insertText.ToString()))
- {
- statement.TryBind("@ItemId", id);
-
- for (var i = startIndex; i < endIndex; i++)
- {
- var index = i.ToString(CultureInfo.InvariantCulture);
-
- var currentValueInfo = values[i];
-
- var itemValue = currentValueInfo.Value;
-
- statement.TryBind("@Type" + index, currentValueInfo.MagicNumber);
- statement.TryBind("@Value" + index, itemValue);
- statement.TryBind("@CleanValue" + index, GetCleanValue(itemValue));
- }
-
- statement.ExecuteNonQuery();
- }
-
- startIndex += Limit;
- insertText.Length = StartInsertText.Length;
- }
- }
-
- ///
- public void UpdatePeople(Guid itemId, List people)
- {
- if (itemId.IsEmpty())
- {
- throw new ArgumentNullException(nameof(itemId));
- }
-
- CheckDisposed();
-
- using var connection = GetConnection();
- using var transaction = connection.BeginTransaction();
- // Delete all existing people first
- using var command = connection.CreateCommand();
- command.CommandText = "delete from People where ItemId=@ItemId";
- command.TryBind("@ItemId", itemId);
- command.ExecuteNonQuery();
-
- if (people is not null)
- {
- InsertPeople(itemId, people, connection);
- }
-
- transaction.Commit();
- }
-
- private void InsertPeople(Guid id, List people, ManagedConnection db)
- {
- const int Limit = 100;
- var startIndex = 0;
- var listIndex = 0;
-
- const string StartInsertText = "insert into People (ItemId, Name, Role, PersonType, SortOrder, ListOrder) values ";
- var insertText = new StringBuilder(StartInsertText);
- while (startIndex < people.Count)
- {
- var endIndex = Math.Min(people.Count, startIndex + Limit);
- for (var i = startIndex; i < endIndex; i++)
- {
- insertText.AppendFormat(
- CultureInfo.InvariantCulture,
- "(@ItemId, @Name{0}, @Role{0}, @PersonType{0}, @SortOrder{0}, @ListOrder{0}),",
- i.ToString(CultureInfo.InvariantCulture));
- }
-
- // Remove trailing comma
- insertText.Length--;
-
- using (var statement = PrepareStatement(db, insertText.ToString()))
- {
- statement.TryBind("@ItemId", id);
-
- for (var i = startIndex; i < endIndex; i++)
- {
- var index = i.ToString(CultureInfo.InvariantCulture);
-
- var person = people[i];
-
- statement.TryBind("@Name" + index, person.Name);
- statement.TryBind("@Role" + index, person.Role);
- statement.TryBind("@PersonType" + index, person.Type.ToString());
- statement.TryBind("@SortOrder" + index, person.SortOrder);
- statement.TryBind("@ListOrder" + index, listIndex);
-
- listIndex++;
- }
-
- statement.ExecuteNonQuery();
- }
-
- startIndex += Limit;
- insertText.Length = StartInsertText.Length;
- }
- }
-
- private PersonInfo GetPerson(SqliteDataReader reader)
- {
- var item = new PersonInfo
- {
- ItemId = reader.GetGuid(0),
- Name = reader.GetString(1)
- };
-
- if (reader.TryGetString(2, out var role))
- {
- item.Role = role;
- }
-
- if (reader.TryGetString(3, out var type)
- && Enum.TryParse(type, true, out PersonKind personKind))
- {
- item.Type = personKind;
- }
-
- if (reader.TryGetInt32(4, out var sortOrder))
- {
- item.SortOrder = sortOrder;
- }
-
- return item;
- }
-
- ///
- public List GetMediaStreams(MediaStreamQuery query)
- {
- CheckDisposed();
-
- ArgumentNullException.ThrowIfNull(query);
-
- var cmdText = _mediaStreamSaveColumnsSelectQuery;
-
- if (query.Type.HasValue)
- {
- cmdText += " AND StreamType=@StreamType";
- }
-
- if (query.Index.HasValue)
- {
- cmdText += " AND StreamIndex=@StreamIndex";
- }
-
- cmdText += " order by StreamIndex ASC";
-
- using (var connection = GetConnection(true))
- {
- var list = new List();
-
- using (var statement = PrepareStatement(connection, cmdText))
- {
- statement.TryBind("@ItemId", query.ItemId);
-
- if (query.Type.HasValue)
- {
- statement.TryBind("@StreamType", query.Type.Value.ToString());
- }
-
- if (query.Index.HasValue)
- {
- statement.TryBind("@StreamIndex", query.Index.Value);
- }
-
- foreach (var row in statement.ExecuteQuery())
- {
- list.Add(GetMediaStream(row));
- }
- }
-
- return list;
- }
- }
-
- ///
- public void SaveMediaStreams(Guid id, IReadOnlyList streams, CancellationToken cancellationToken)
- {
- CheckDisposed();
-
- if (id.IsEmpty())
- {
- throw new ArgumentNullException(nameof(id));
- }
-
- ArgumentNullException.ThrowIfNull(streams);
-
- cancellationToken.ThrowIfCancellationRequested();
-
- using var connection = GetConnection();
- using var transaction = connection.BeginTransaction();
- // Delete existing mediastreams
- using var command = connection.PrepareStatement("delete from mediastreams where ItemId=@ItemId");
- command.TryBind("@ItemId", id);
- command.ExecuteNonQuery();
-
- InsertMediaStreams(id, streams, connection);
-
- transaction.Commit();
- }
-
- private void InsertMediaStreams(Guid id, IReadOnlyList streams, ManagedConnection db)
- {
- const int Limit = 10;
- var startIndex = 0;
-
- var insertText = new StringBuilder(_mediaStreamSaveColumnsInsertQuery);
- while (startIndex < streams.Count)
- {
- var endIndex = Math.Min(streams.Count, startIndex + Limit);
-
- for (var i = startIndex; i < endIndex; i++)
- {
- if (i != startIndex)
- {
- insertText.Append(',');
- }
-
- var index = i.ToString(CultureInfo.InvariantCulture);
- insertText.Append("(@ItemId, ");
-
- foreach (var column in _mediaStreamSaveColumns.Skip(1))
- {
- insertText.Append('@').Append(column).Append(index).Append(',');
- }
-
- insertText.Length -= 1; // Remove the last comma
-
- insertText.Append(')');
- }
-
- using (var statement = PrepareStatement(db, insertText.ToString()))
- {
- statement.TryBind("@ItemId", id);
-
- for (var i = startIndex; i < endIndex; i++)
- {
- var index = i.ToString(CultureInfo.InvariantCulture);
-
- var stream = streams[i];
-
- statement.TryBind("@StreamIndex" + index, stream.Index);
- statement.TryBind("@StreamType" + index, stream.Type.ToString());
- statement.TryBind("@Codec" + index, stream.Codec);
- statement.TryBind("@Language" + index, stream.Language);
- statement.TryBind("@ChannelLayout" + index, stream.ChannelLayout);
- statement.TryBind("@Profile" + index, stream.Profile);
- statement.TryBind("@AspectRatio" + index, stream.AspectRatio);
- statement.TryBind("@Path" + index, GetPathToSave(stream.Path));
-
- statement.TryBind("@IsInterlaced" + index, stream.IsInterlaced);
- statement.TryBind("@BitRate" + index, stream.BitRate);
- statement.TryBind("@Channels" + index, stream.Channels);
- statement.TryBind("@SampleRate" + index, stream.SampleRate);
-
- statement.TryBind("@IsDefault" + index, stream.IsDefault);
- statement.TryBind("@IsForced" + index, stream.IsForced);
- statement.TryBind("@IsExternal" + index, stream.IsExternal);
-
- // Yes these are backwards due to a mistake
- statement.TryBind("@Width" + index, stream.Height);
- statement.TryBind("@Height" + index, stream.Width);
-
- statement.TryBind("@AverageFrameRate" + index, stream.AverageFrameRate);
- statement.TryBind("@RealFrameRate" + index, stream.RealFrameRate);
- statement.TryBind("@Level" + index, stream.Level);
-
- statement.TryBind("@PixelFormat" + index, stream.PixelFormat);
- statement.TryBind("@BitDepth" + index, stream.BitDepth);
- statement.TryBind("@IsAnamorphic" + index, stream.IsAnamorphic);
- statement.TryBind("@IsExternal" + index, stream.IsExternal);
- statement.TryBind("@RefFrames" + index, stream.RefFrames);
-
- statement.TryBind("@CodecTag" + index, stream.CodecTag);
- statement.TryBind("@Comment" + index, stream.Comment);
- statement.TryBind("@NalLengthSize" + index, stream.NalLengthSize);
- statement.TryBind("@IsAvc" + index, stream.IsAVC);
- statement.TryBind("@Title" + index, stream.Title);
-
- statement.TryBind("@TimeBase" + index, stream.TimeBase);
- statement.TryBind("@CodecTimeBase" + index, stream.CodecTimeBase);
-
- statement.TryBind("@ColorPrimaries" + index, stream.ColorPrimaries);
- statement.TryBind("@ColorSpace" + index, stream.ColorSpace);
- statement.TryBind("@ColorTransfer" + index, stream.ColorTransfer);
-
- statement.TryBind("@DvVersionMajor" + index, stream.DvVersionMajor);
- statement.TryBind("@DvVersionMinor" + index, stream.DvVersionMinor);
- statement.TryBind("@DvProfile" + index, stream.DvProfile);
- statement.TryBind("@DvLevel" + index, stream.DvLevel);
- statement.TryBind("@RpuPresentFlag" + index, stream.RpuPresentFlag);
- statement.TryBind("@ElPresentFlag" + index, stream.ElPresentFlag);
- statement.TryBind("@BlPresentFlag" + index, stream.BlPresentFlag);
- statement.TryBind("@DvBlSignalCompatibilityId" + index, stream.DvBlSignalCompatibilityId);
-
- statement.TryBind("@IsHearingImpaired" + index, stream.IsHearingImpaired);
-
- statement.TryBind("@Rotation" + index, stream.Rotation);
- }
-
- statement.ExecuteNonQuery();
- }
-
- startIndex += Limit;
- insertText.Length = _mediaStreamSaveColumnsInsertQuery.Length;
- }
- }
-
- ///
- /// Gets the media stream.
- ///
- /// The reader.
- /// MediaStream.
- private MediaStream GetMediaStream(SqliteDataReader reader)
- {
- var item = new MediaStream
- {
- Index = reader.GetInt32(1),
- Type = Enum.Parse(reader.GetString(2), true)
- };
-
- if (reader.TryGetString(3, out var codec))
- {
- item.Codec = codec;
- }
-
- if (reader.TryGetString(4, out var language))
- {
- item.Language = language;
- }
-
- if (reader.TryGetString(5, out var channelLayout))
- {
- item.ChannelLayout = channelLayout;
- }
-
- if (reader.TryGetString(6, out var profile))
- {
- item.Profile = profile;
- }
-
- if (reader.TryGetString(7, out var aspectRatio))
- {
- item.AspectRatio = aspectRatio;
- }
-
- if (reader.TryGetString(8, out var path))
- {
- item.Path = RestorePath(path);
- }
-
- item.IsInterlaced = reader.GetBoolean(9);
-
- if (reader.TryGetInt32(10, out var bitrate))
- {
- item.BitRate = bitrate;
- }
-
- if (reader.TryGetInt32(11, out var channels))
- {
- item.Channels = channels;
- }
-
- if (reader.TryGetInt32(12, out var sampleRate))
- {
- item.SampleRate = sampleRate;
- }
-
- item.IsDefault = reader.GetBoolean(13);
- item.IsForced = reader.GetBoolean(14);
- item.IsExternal = reader.GetBoolean(15);
-
- if (reader.TryGetInt32(16, out var width))
- {
- item.Width = width;
- }
-
- if (reader.TryGetInt32(17, out var height))
- {
- item.Height = height;
- }
-
- if (reader.TryGetSingle(18, out var averageFrameRate))
- {
- item.AverageFrameRate = averageFrameRate;
- }
-
- if (reader.TryGetSingle(19, out var realFrameRate))
- {
- item.RealFrameRate = realFrameRate;
- }
-
- if (reader.TryGetSingle(20, out var level))
- {
- item.Level = level;
- }
-
- if (reader.TryGetString(21, out var pixelFormat))
- {
- item.PixelFormat = pixelFormat;
- }
-
- if (reader.TryGetInt32(22, out var bitDepth))
- {
- item.BitDepth = bitDepth;
- }
-
- if (reader.TryGetBoolean(23, out var isAnamorphic))
- {
- item.IsAnamorphic = isAnamorphic;
- }
-
- if (reader.TryGetInt32(24, out var refFrames))
- {
- item.RefFrames = refFrames;
- }
-
- if (reader.TryGetString(25, out var codecTag))
- {
- item.CodecTag = codecTag;
- }
-
- if (reader.TryGetString(26, out var comment))
- {
- item.Comment = comment;
- }
-
- if (reader.TryGetString(27, out var nalLengthSize))
- {
- item.NalLengthSize = nalLengthSize;
- }
-
- if (reader.TryGetBoolean(28, out var isAVC))
- {
- item.IsAVC = isAVC;
- }
-
- if (reader.TryGetString(29, out var title))
- {
- item.Title = title;
- }
-
- if (reader.TryGetString(30, out var timeBase))
- {
- item.TimeBase = timeBase;
- }
-
- if (reader.TryGetString(31, out var codecTimeBase))
- {
- item.CodecTimeBase = codecTimeBase;
- }
-
- if (reader.TryGetString(32, out var colorPrimaries))
- {
- item.ColorPrimaries = colorPrimaries;
- }
-
- if (reader.TryGetString(33, out var colorSpace))
- {
- item.ColorSpace = colorSpace;
- }
-
- if (reader.TryGetString(34, out var colorTransfer))
- {
- item.ColorTransfer = colorTransfer;
- }
-
- if (reader.TryGetInt32(35, out var dvVersionMajor))
- {
- item.DvVersionMajor = dvVersionMajor;
- }
-
- if (reader.TryGetInt32(36, out var dvVersionMinor))
- {
- item.DvVersionMinor = dvVersionMinor;
- }
-
- if (reader.TryGetInt32(37, out var dvProfile))
- {
- item.DvProfile = dvProfile;
- }
-
- if (reader.TryGetInt32(38, out var dvLevel))
- {
- item.DvLevel = dvLevel;
- }
-
- if (reader.TryGetInt32(39, out var rpuPresentFlag))
- {
- item.RpuPresentFlag = rpuPresentFlag;
- }
-
- if (reader.TryGetInt32(40, out var elPresentFlag))
- {
- item.ElPresentFlag = elPresentFlag;
- }
-
- if (reader.TryGetInt32(41, out var blPresentFlag))
- {
- item.BlPresentFlag = blPresentFlag;
- }
-
- if (reader.TryGetInt32(42, out var dvBlSignalCompatibilityId))
- {
- item.DvBlSignalCompatibilityId = dvBlSignalCompatibilityId;
- }
-
- item.IsHearingImpaired = reader.TryGetBoolean(43, out var result) && result;
-
- if (reader.TryGetInt32(44, out var rotation))
- {
- item.Rotation = rotation;
- }
-
- if (item.Type is MediaStreamType.Audio or MediaStreamType.Subtitle)
- {
- item.LocalizedDefault = _localization.GetLocalizedString("Default");
- item.LocalizedExternal = _localization.GetLocalizedString("External");
-
- if (item.Type is MediaStreamType.Subtitle)
- {
- item.LocalizedUndefined = _localization.GetLocalizedString("Undefined");
- item.LocalizedForced = _localization.GetLocalizedString("Forced");
- item.LocalizedHearingImpaired = _localization.GetLocalizedString("HearingImpaired");
- }
- }
-
- return item;
- }
-
- ///
- public List GetMediaAttachments(MediaAttachmentQuery query)
- {
- CheckDisposed();
-
- ArgumentNullException.ThrowIfNull(query);
-
- var cmdText = _mediaAttachmentSaveColumnsSelectQuery;
-
- if (query.Index.HasValue)
- {
- cmdText += " AND AttachmentIndex=@AttachmentIndex";
- }
-
- cmdText += " order by AttachmentIndex ASC";
-
- var list = new List();
- using (var connection = GetConnection(true))
- using (var statement = PrepareStatement(connection, cmdText))
- {
- statement.TryBind("@ItemId", query.ItemId);
-
- if (query.Index.HasValue)
- {
- statement.TryBind("@AttachmentIndex", query.Index.Value);
- }
-
- foreach (var row in statement.ExecuteQuery())
- {
- list.Add(GetMediaAttachment(row));
- }
- }
-
- return list;
- }
-
- ///
- public void SaveMediaAttachments(
- Guid id,
- IReadOnlyList attachments,
- CancellationToken cancellationToken)
- {
- CheckDisposed();
- if (id.IsEmpty())
- {
- throw new ArgumentException("Guid can't be empty.", nameof(id));
- }
-
- ArgumentNullException.ThrowIfNull(attachments);
-
- cancellationToken.ThrowIfCancellationRequested();
-
- using (var connection = GetConnection())
- using (var transaction = connection.BeginTransaction())
- using (var command = connection.PrepareStatement("delete from mediaattachments where ItemId=@ItemId"))
- {
- command.TryBind("@ItemId", id);
- command.ExecuteNonQuery();
-
- InsertMediaAttachments(id, attachments, connection, cancellationToken);
-
- transaction.Commit();
- }
- }
-
- private void InsertMediaAttachments(
- Guid id,
- IReadOnlyList attachments,
- ManagedConnection db,
- CancellationToken cancellationToken)
- {
- const int InsertAtOnce = 10;
-
- var insertText = new StringBuilder(_mediaAttachmentInsertPrefix);
- for (var startIndex = 0; startIndex < attachments.Count; startIndex += InsertAtOnce)
- {
- var endIndex = Math.Min(attachments.Count, startIndex + InsertAtOnce);
-
- for (var i = startIndex; i < endIndex; i++)
- {
- insertText.Append("(@ItemId, ");
-
- foreach (var column in _mediaAttachmentSaveColumns.Skip(1))
- {
- insertText.Append('@')
- .Append(column)
- .Append(i)
- .Append(',');
- }
-
- insertText.Length -= 1;
-
- insertText.Append("),");
- }
-
- insertText.Length--;
-
- cancellationToken.ThrowIfCancellationRequested();
-
- using (var statement = PrepareStatement(db, insertText.ToString()))
- {
- statement.TryBind("@ItemId", id);
-
- for (var i = startIndex; i < endIndex; i++)
- {
- var index = i.ToString(CultureInfo.InvariantCulture);
-
- var attachment = attachments[i];
-
- statement.TryBind("@AttachmentIndex" + index, attachment.Index);
- statement.TryBind("@Codec" + index, attachment.Codec);
- statement.TryBind("@CodecTag" + index, attachment.CodecTag);
- statement.TryBind("@Comment" + index, attachment.Comment);
- statement.TryBind("@Filename" + index, attachment.FileName);
- statement.TryBind("@MIMEType" + index, attachment.MimeType);
- }
-
- statement.ExecuteNonQuery();
- }
-
- insertText.Length = _mediaAttachmentInsertPrefix.Length;
- }
- }
-
- ///
- /// Gets the attachment.
- ///
- /// The reader.
- /// MediaAttachment.
- private MediaAttachment GetMediaAttachment(SqliteDataReader reader)
- {
- var item = new MediaAttachment
- {
- Index = reader.GetInt32(1)
- };
-
- if (reader.TryGetString(2, out var codec))
- {
- item.Codec = codec;
- }
-
- if (reader.TryGetString(3, out var codecTag))
- {
- item.CodecTag = codecTag;
- }
-
- if (reader.TryGetString(4, out var comment))
- {
- item.Comment = comment;
- }
-
- if (reader.TryGetString(5, out var fileName))
- {
- item.FileName = fileName;
- }
-
- if (reader.TryGetString(6, out var mimeType))
- {
- item.MimeType = mimeType;
- }
-
- return item;
- }
-
- private static string BuildMediaAttachmentInsertPrefix()
- {
- var queryPrefixText = new StringBuilder();
- queryPrefixText.Append("insert into mediaattachments (");
- foreach (var column in _mediaAttachmentSaveColumns)
- {
- queryPrefixText.Append(column)
- .Append(',');
- }
-
- queryPrefixText.Length -= 1;
- queryPrefixText.Append(") values ");
- return queryPrefixText.ToString();
- }
-
-#nullable enable
-
- private readonly struct QueryTimeLogger : IDisposable
- {
- private readonly ILogger _logger;
- private readonly string _commandText;
- private readonly string _methodName;
- private readonly long _startTimestamp;
-
- public QueryTimeLogger(ILogger logger, string commandText, [CallerMemberName] string methodName = "")
- {
- _logger = logger;
- _commandText = commandText;
- _methodName = methodName;
- _startTimestamp = logger.IsEnabled(LogLevel.Debug) ? Stopwatch.GetTimestamp() : -1;
- }
-
- public void Dispose()
- {
- if (_startTimestamp == -1)
- {
- return;
- }
-
- var elapsedMs = Stopwatch.GetElapsedTime(_startTimestamp).TotalMilliseconds;
-
-#if DEBUG
- const int SlowThreshold = 100;
-#else
- const int SlowThreshold = 10;
-#endif
-
- if (elapsedMs >= SlowThreshold)
- {
- _logger.LogDebug(
- "{Method} query time (slow): {ElapsedMs}ms. Query: {Query}",
- _methodName,
- elapsedMs,
- _commandText);
- }
- }
- }
- }
-}
diff --git a/Emby.Server.Implementations/Data/SqliteUserDataRepository.cs b/Emby.Server.Implementations/Data/SqliteUserDataRepository.cs
deleted file mode 100644
index bfdcc08f42..0000000000
--- a/Emby.Server.Implementations/Data/SqliteUserDataRepository.cs
+++ /dev/null
@@ -1,369 +0,0 @@
-#nullable disable
-
-#pragma warning disable CS1591
-
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Threading;
-using Jellyfin.Data.Entities;
-using MediaBrowser.Controller.Configuration;
-using MediaBrowser.Controller.Entities;
-using MediaBrowser.Controller.Library;
-using MediaBrowser.Controller.Persistence;
-using Microsoft.Data.Sqlite;
-using Microsoft.Extensions.Logging;
-
-namespace Emby.Server.Implementations.Data
-{
- public class SqliteUserDataRepository : BaseSqliteRepository, IUserDataRepository
- {
- private readonly IUserManager _userManager;
-
- public SqliteUserDataRepository(
- ILogger logger,
- IServerConfigurationManager config,
- IUserManager userManager)
- : base(logger)
- {
- _userManager = userManager;
-
- DbFilePath = Path.Combine(config.ApplicationPaths.DataPath, "library.db");
- }
-
- ///
- /// Opens the connection to the database.
- ///
- public override void Initialize()
- {
- base.Initialize();
-
- using (var connection = GetConnection())
- {
- var userDatasTableExists = TableExists(connection, "UserDatas");
- var userDataTableExists = TableExists(connection, "userdata");
-
- var users = userDatasTableExists ? null : _userManager.Users;
- using var transaction = connection.BeginTransaction();
- connection.Execute(string.Join(
- ';',
- "create table if not exists UserDatas (key nvarchar not null, userId INT not null, rating float null, played bit not null, playCount int not null, isFavorite bit not null, playbackPositionTicks bigint not null, lastPlayedDate datetime null, AudioStreamIndex INT, SubtitleStreamIndex INT)",
- "drop index if exists idx_userdata",
- "drop index if exists idx_userdata1",
- "drop index if exists idx_userdata2",
- "drop index if exists userdataindex1",
- "drop index if exists userdataindex",
- "drop index if exists userdataindex3",
- "drop index if exists userdataindex4",
- "create unique index if not exists UserDatasIndex1 on UserDatas (key, userId)",
- "create index if not exists UserDatasIndex2 on UserDatas (key, userId, played)",
- "create index if not exists UserDatasIndex3 on UserDatas (key, userId, playbackPositionTicks)",
- "create index if not exists UserDatasIndex4 on UserDatas (key, userId, isFavorite)",
- "create index if not exists UserDatasIndex5 on UserDatas (key, userId, lastPlayedDate)"));
-
- if (!userDataTableExists)
- {
- transaction.Commit();
- return;
- }
-
- var existingColumnNames = GetColumnNames(connection, "userdata");
-
- AddColumn(connection, "userdata", "InternalUserId", "int", existingColumnNames);
- AddColumn(connection, "userdata", "AudioStreamIndex", "int", existingColumnNames);
- AddColumn(connection, "userdata", "SubtitleStreamIndex", "int", existingColumnNames);
-
- if (userDatasTableExists)
- {
- return;
- }
-
- ImportUserIds(connection, users);
-
- connection.Execute("INSERT INTO UserDatas (key, userId, rating, played, playCount, isFavorite, playbackPositionTicks, lastPlayedDate, AudioStreamIndex, SubtitleStreamIndex) SELECT key, InternalUserId, rating, played, playCount, isFavorite, playbackPositionTicks, lastPlayedDate, AudioStreamIndex, SubtitleStreamIndex from userdata where InternalUserId not null");
-
- transaction.Commit();
- }
- }
-
- private void ImportUserIds(ManagedConnection db, IEnumerable users)
- {
- var userIdsWithUserData = GetAllUserIdsWithUserData(db);
-
- using (var statement = db.PrepareStatement("update userdata set InternalUserId=@InternalUserId where UserId=@UserId"))
- {
- foreach (var user in users)
- {
- if (!userIdsWithUserData.Contains(user.Id))
- {
- continue;
- }
-
- statement.TryBind("@UserId", user.Id);
- statement.TryBind("@InternalUserId", user.InternalId);
-
- statement.ExecuteNonQuery();
- }
- }
- }
-
- private List GetAllUserIdsWithUserData(ManagedConnection db)
- {
- var list = new List();
-
- using (var statement = PrepareStatement(db, "select DISTINCT UserId from UserData where UserId not null"))
- {
- foreach (var row in statement.ExecuteQuery())
- {
- try
- {
- list.Add(row.GetGuid(0));
- }
- catch (Exception ex)
- {
- Logger.LogError(ex, "Error while getting user");
- }
- }
- }
-
- return list;
- }
-
- ///
- public void SaveUserData(long userId, string key, UserItemData userData, CancellationToken cancellationToken)
- {
- ArgumentNullException.ThrowIfNull(userData);
-
- if (userId <= 0)
- {
- throw new ArgumentNullException(nameof(userId));
- }
-
- ArgumentException.ThrowIfNullOrEmpty(key);
-
- PersistUserData(userId, key, userData, cancellationToken);
- }
-
- ///
- public void SaveAllUserData(long userId, UserItemData[] userData, CancellationToken cancellationToken)
- {
- ArgumentNullException.ThrowIfNull(userData);
-
- if (userId <= 0)
- {
- throw new ArgumentNullException(nameof(userId));
- }
-
- PersistAllUserData(userId, userData, cancellationToken);
- }
-
- ///
- /// Persists the user data.
- ///
- /// The user id.
- /// The key.
- /// The user data.
- /// The cancellation token.
- public void PersistUserData(long internalUserId, string key, UserItemData userData, CancellationToken cancellationToken)
- {
- cancellationToken.ThrowIfCancellationRequested();
-
- using (var connection = GetConnection())
- using (var transaction = connection.BeginTransaction())
- {
- SaveUserData(connection, internalUserId, key, userData);
- transaction.Commit();
- }
- }
-
- private static void SaveUserData(ManagedConnection db, long internalUserId, string key, UserItemData userData)
- {
- using (var statement = db.PrepareStatement("replace into UserDatas (key, userId, rating,played,playCount,isFavorite,playbackPositionTicks,lastPlayedDate,AudioStreamIndex,SubtitleStreamIndex) values (@key, @userId, @rating,@played,@playCount,@isFavorite,@playbackPositionTicks,@lastPlayedDate,@AudioStreamIndex,@SubtitleStreamIndex)"))
- {
- statement.TryBind("@userId", internalUserId);
- statement.TryBind("@key", key);
-
- if (userData.Rating.HasValue)
- {
- statement.TryBind("@rating", userData.Rating.Value);
- }
- else
- {
- statement.TryBindNull("@rating");
- }
-
- statement.TryBind("@played", userData.Played);
- statement.TryBind("@playCount", userData.PlayCount);
- statement.TryBind("@isFavorite", userData.IsFavorite);
- statement.TryBind("@playbackPositionTicks", userData.PlaybackPositionTicks);
-
- if (userData.LastPlayedDate.HasValue)
- {
- statement.TryBind("@lastPlayedDate", userData.LastPlayedDate.Value.ToDateTimeParamValue());
- }
- else
- {
- statement.TryBindNull("@lastPlayedDate");
- }
-
- if (userData.AudioStreamIndex.HasValue)
- {
- statement.TryBind("@AudioStreamIndex", userData.AudioStreamIndex.Value);
- }
- else
- {
- statement.TryBindNull("@AudioStreamIndex");
- }
-
- if (userData.SubtitleStreamIndex.HasValue)
- {
- statement.TryBind("@SubtitleStreamIndex", userData.SubtitleStreamIndex.Value);
- }
- else
- {
- statement.TryBindNull("@SubtitleStreamIndex");
- }
-
- statement.ExecuteNonQuery();
- }
- }
-
- ///
- /// Persist all user data for the specified user.
- ///
- private void PersistAllUserData(long internalUserId, UserItemData[] userDataList, CancellationToken cancellationToken)
- {
- cancellationToken.ThrowIfCancellationRequested();
-
- using (var connection = GetConnection())
- using (var transaction = connection.BeginTransaction())
- {
- foreach (var userItemData in userDataList)
- {
- SaveUserData(connection, internalUserId, userItemData.Key, userItemData);
- }
-
- transaction.Commit();
- }
- }
-
- ///
- /// Gets the user data.
- ///
- /// The user id.
- /// The key.
- /// Task{UserItemData}.
- ///
- /// userId
- /// or
- /// key.
- ///
- public UserItemData GetUserData(long userId, string key)
- {
- if (userId <= 0)
- {
- throw new ArgumentNullException(nameof(userId));
- }
-
- ArgumentException.ThrowIfNullOrEmpty(key);
-
- using (var connection = GetConnection(true))
- {
- using (var statement = connection.PrepareStatement("select key,userid,rating,played,playCount,isFavorite,playbackPositionTicks,lastPlayedDate,AudioStreamIndex,SubtitleStreamIndex from UserDatas where key =@Key and userId=@UserId"))
- {
- statement.TryBind("@UserId", userId);
- statement.TryBind("@Key", key);
-
- foreach (var row in statement.ExecuteQuery())
- {
- return ReadRow(row);
- }
- }
-
- return null;
- }
- }
-
- public UserItemData GetUserData(long userId, List keys)
- {
- ArgumentNullException.ThrowIfNull(keys);
-
- if (keys.Count == 0)
- {
- return null;
- }
-
- return GetUserData(userId, keys[0]);
- }
-
- ///
- /// Return all user-data associated with the given user.
- ///
- /// The internal user id.
- /// The list of user item data.
- public List GetAllUserData(long userId)
- {
- if (userId <= 0)
- {
- throw new ArgumentNullException(nameof(userId));
- }
-
- var list = new List();
-
- using (var connection = GetConnection())
- {
- using (var statement = connection.PrepareStatement("select key,userid,rating,played,playCount,isFavorite,playbackPositionTicks,lastPlayedDate,AudioStreamIndex,SubtitleStreamIndex from UserDatas where userId=@UserId"))
- {
- statement.TryBind("@UserId", userId);
-
- foreach (var row in statement.ExecuteQuery())
- {
- list.Add(ReadRow(row));
- }
- }
- }
-
- return list;
- }
-
- ///
- /// Read a row from the specified reader into the provided userData object.
- ///
- /// The list of result set values.
- /// The user item data.
- private UserItemData ReadRow(SqliteDataReader reader)
- {
- var userData = new UserItemData
- {
- Key = reader.GetString(0)
- };
-
- if (reader.TryGetDouble(2, out var rating))
- {
- userData.Rating = rating;
- }
-
- userData.Played = reader.GetBoolean(3);
- userData.PlayCount = reader.GetInt32(4);
- userData.IsFavorite = reader.GetBoolean(5);
- userData.PlaybackPositionTicks = reader.GetInt64(6);
-
- if (reader.TryReadDateTime(7, out var lastPlayedDate))
- {
- userData.LastPlayedDate = lastPlayedDate;
- }
-
- if (reader.TryGetInt32(8, out var audioStreamIndex))
- {
- userData.AudioStreamIndex = audioStreamIndex;
- }
-
- if (reader.TryGetInt32(9, out var subtitleStreamIndex))
- {
- userData.SubtitleStreamIndex = subtitleStreamIndex;
- }
-
- return userData;
- }
- }
-}
diff --git a/Emby.Server.Implementations/Data/SynchronousMode.cs b/Emby.Server.Implementations/Data/SynchronousMode.cs
deleted file mode 100644
index cde524e2e0..0000000000
--- a/Emby.Server.Implementations/Data/SynchronousMode.cs
+++ /dev/null
@@ -1,30 +0,0 @@
-namespace Emby.Server.Implementations.Data;
-
-///
-/// The disk synchronization mode, controls how aggressively SQLite will write data
-/// all the way out to physical storage.
-///
-public enum SynchronousMode
-{
- ///
- /// SQLite continues without syncing as soon as it has handed data off to the operating system.
- ///
- Off = 0,
-
- ///
- /// SQLite database engine will still sync at the most critical moments.
- ///
- Normal = 1,
-
- ///
- /// SQLite database engine will use the xSync method of the VFS
- /// to ensure that all content is safely written to the disk surface prior to continuing.
- ///
- Full = 2,
-
- ///
- /// EXTRA synchronous is like FULL with the addition that the directory containing a rollback journal
- /// is synced after that journal is unlinked to commit a transaction in DELETE mode.
- ///
- Extra = 3
-}
diff --git a/Emby.Server.Implementations/Data/TempStoreMode.cs b/Emby.Server.Implementations/Data/TempStoreMode.cs
deleted file mode 100644
index d2427ce478..0000000000
--- a/Emby.Server.Implementations/Data/TempStoreMode.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-namespace Emby.Server.Implementations.Data;
-
-///
-/// Storage mode used by temporary database files.
-///
-public enum TempStoreMode
-{
- ///
- /// The compile-time C preprocessor macro SQLITE_TEMP_STORE
- /// is used to determine where temporary tables and indices are stored.
- ///
- Default = 0,
-
- ///
- /// Temporary tables and indices are stored in a file.
- ///
- File = 1,
-
- ///
- /// Temporary tables and indices are kept in as if they were pure in-memory databases memory.
- ///
- Memory = 2
-}
diff --git a/Emby.Server.Implementations/Devices/DeviceId.cs b/Emby.Server.Implementations/Devices/DeviceId.cs
index 2459178d81..0b3c3bbd4f 100644
--- a/Emby.Server.Implementations/Devices/DeviceId.cs
+++ b/Emby.Server.Implementations/Devices/DeviceId.cs
@@ -4,6 +4,7 @@ using System;
using System.Globalization;
using System.IO;
using System.Text;
+using System.Threading;
using MediaBrowser.Common.Configuration;
using Microsoft.Extensions.Logging;
@@ -13,7 +14,7 @@ namespace Emby.Server.Implementations.Devices
{
private readonly IApplicationPaths _appPaths;
private readonly ILogger _logger;
- private readonly object _syncLock = new object();
+ private readonly Lock _syncLock = new();
private string? _id;
diff --git a/Emby.Server.Implementations/Dto/DtoService.cs b/Emby.Server.Implementations/Dto/DtoService.cs
index 0c0ba74533..5b0fc9ef3b 100644
--- a/Emby.Server.Implementations/Dto/DtoService.cs
+++ b/Emby.Server.Implementations/Dto/DtoService.cs
@@ -5,11 +5,12 @@ using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
-using Jellyfin.Data.Entities;
using Jellyfin.Data.Enums;
+using Jellyfin.Database.Implementations.Entities;
using Jellyfin.Extensions;
using MediaBrowser.Common;
using MediaBrowser.Controller.Channels;
+using MediaBrowser.Controller.Chapters;
using MediaBrowser.Controller.Drawing;
using MediaBrowser.Controller.Dto;
using MediaBrowser.Controller.Entities;
@@ -40,7 +41,6 @@ namespace Emby.Server.Implementations.Dto
private readonly ILogger _logger;
private readonly ILibraryManager _libraryManager;
private readonly IUserDataManager _userDataRepository;
- private readonly IItemRepository _itemRepo;
private readonly IImageProcessor _imageProcessor;
private readonly IProviderManager _providerManager;
@@ -51,24 +51,24 @@ namespace Emby.Server.Implementations.Dto
private readonly Lazy _livetvManagerFactory;
private readonly ITrickplayManager _trickplayManager;
+ private readonly IChapterRepository _chapterRepository;
public DtoService(
ILogger logger,
ILibraryManager libraryManager,
IUserDataManager userDataRepository,
- IItemRepository itemRepo,
IImageProcessor imageProcessor,
IProviderManager providerManager,
IRecordingsManager recordingsManager,
IApplicationHost appHost,
IMediaSourceManager mediaSourceManager,
Lazy livetvManagerFactory,
- ITrickplayManager trickplayManager)
+ ITrickplayManager trickplayManager,
+ IChapterRepository chapterRepository)
{
_logger = logger;
_libraryManager = libraryManager;
_userDataRepository = userDataRepository;
- _itemRepo = itemRepo;
_imageProcessor = imageProcessor;
_providerManager = providerManager;
_recordingsManager = recordingsManager;
@@ -76,6 +76,7 @@ namespace Emby.Server.Implementations.Dto
_mediaSourceManager = mediaSourceManager;
_livetvManagerFactory = livetvManagerFactory;
_trickplayManager = trickplayManager;
+ _chapterRepository = chapterRepository;
}
private ILiveTvManager LivetvManager => _livetvManagerFactory.Value;
@@ -95,11 +96,11 @@ namespace Emby.Server.Implementations.Dto
if (item is LiveTvChannel tvChannel)
{
- (channelTuples ??= new()).Add((dto, tvChannel));
+ (channelTuples ??= []).Add((dto, tvChannel));
}
else if (item is LiveTvProgram)
{
- (programTuples ??= new()).Add((item, dto));
+ (programTuples ??= []).Add((item, dto));
}
if (item is IItemByName byName)
@@ -165,7 +166,7 @@ namespace Emby.Server.Implementations.Dto
return dto;
}
- private static IList GetTaggedItems(IItemByName byName, User? user, DtoOptions options)
+ private static IReadOnlyList GetTaggedItems(IItemByName byName, User? user, DtoOptions options)
{
return byName.GetTaggedItems(
new InternalItemsQuery(user)
@@ -327,7 +328,7 @@ namespace Emby.Server.Implementations.Dto
return dto;
}
- private static void SetItemByNameInfo(BaseItem item, BaseItemDto dto, IList taggedItems)
+ private static void SetItemByNameInfo(BaseItem item, BaseItemDto dto, IReadOnlyList taggedItems)
{
if (item is MusicArtist)
{
@@ -586,12 +587,12 @@ namespace Emby.Server.Implementations.Dto
if (dto.ImageBlurHashes is not null)
{
// Only add BlurHash for the person's image.
- baseItemPerson.ImageBlurHashes = new Dictionary>();
+ baseItemPerson.ImageBlurHashes = [];
foreach (var (imageType, blurHash) in dto.ImageBlurHashes)
{
if (blurHash is not null)
{
- baseItemPerson.ImageBlurHashes[imageType] = new Dictionary();
+ baseItemPerson.ImageBlurHashes[imageType] = [];
foreach (var (imageId, blurHashValue) in blurHash)
{
if (string.Equals(baseItemPerson.PrimaryImageTag, imageId, StringComparison.OrdinalIgnoreCase))
@@ -670,11 +671,11 @@ namespace Emby.Server.Implementations.Dto
if (!string.IsNullOrEmpty(image.BlurHash))
{
- dto.ImageBlurHashes ??= new Dictionary>();
+ dto.ImageBlurHashes ??= [];
if (!dto.ImageBlurHashes.TryGetValue(image.Type, out var value))
{
- value = new Dictionary();
+ value = [];
dto.ImageBlurHashes[image.Type] = value;
}
@@ -705,7 +706,7 @@ namespace Emby.Server.Implementations.Dto
if (hashes.Count > 0)
{
- dto.ImageBlurHashes ??= new Dictionary>();
+ dto.ImageBlurHashes ??= [];
dto.ImageBlurHashes[imageType] = hashes;
}
@@ -752,7 +753,7 @@ namespace Emby.Server.Implementations.Dto
dto.AspectRatio = hasAspectRatio.AspectRatio;
}
- dto.ImageBlurHashes = new Dictionary>();
+ dto.ImageBlurHashes = [];
var backdropLimit = options.GetImageLimit(ImageType.Backdrop);
if (backdropLimit > 0)
@@ -768,7 +769,7 @@ namespace Emby.Server.Implementations.Dto
if (options.EnableImages)
{
- dto.ImageTags = new Dictionary();
+ dto.ImageTags = [];
// Prevent implicitly captured closure
var currentItem = item;
@@ -1060,7 +1061,7 @@ namespace Emby.Server.Implementations.Dto
if (options.ContainsField(ItemFields.Chapters))
{
- dto.Chapters = _itemRepo.GetChapters(item);
+ dto.Chapters = _chapterRepository.GetChapters(item.Id).ToList();
}
if (options.ContainsField(ItemFields.Trickplay))
diff --git a/Emby.Server.Implementations/Emby.Server.Implementations.csproj b/Emby.Server.Implementations/Emby.Server.Implementations.csproj
index 34276355a7..d99923b4fc 100644
--- a/Emby.Server.Implementations/Emby.Server.Implementations.csproj
+++ b/Emby.Server.Implementations/Emby.Server.Implementations.csproj
@@ -18,9 +18,11 @@
+
+
@@ -37,7 +39,7 @@
- net8.0
+ net9.0
false
true
@@ -66,6 +68,6 @@
-
+
diff --git a/Emby.Server.Implementations/EntryPoints/LibraryChangedNotifier.cs b/Emby.Server.Implementations/EntryPoints/LibraryChangedNotifier.cs
index 4c668379c8..933cfc8cbe 100644
--- a/Emby.Server.Implementations/EntryPoints/LibraryChangedNotifier.cs
+++ b/Emby.Server.Implementations/EntryPoints/LibraryChangedNotifier.cs
@@ -5,8 +5,8 @@ using System.Globalization;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
-using Jellyfin.Data.Entities;
using Jellyfin.Data.Events;
+using Jellyfin.Database.Implementations.Entities;
using Jellyfin.Extensions;
using MediaBrowser.Controller.Channels;
using MediaBrowser.Controller.Configuration;
@@ -34,7 +34,7 @@ public sealed class LibraryChangedNotifier : IHostedService, IDisposable
private readonly IUserManager _userManager;
private readonly ILogger _logger;
- private readonly object _libraryChangedSyncLock = new();
+ private readonly Lock _libraryChangedSyncLock = new();
private readonly List _foldersAddedTo = new();
private readonly List _foldersRemovedFrom = new();
private readonly List _itemsAdded = new();
diff --git a/Emby.Server.Implementations/EntryPoints/UserDataChangeNotifier.cs b/Emby.Server.Implementations/EntryPoints/UserDataChangeNotifier.cs
index aef02ce6bf..fc174b7c14 100644
--- a/Emby.Server.Implementations/EntryPoints/UserDataChangeNotifier.cs
+++ b/Emby.Server.Implementations/EntryPoints/UserDataChangeNotifier.cs
@@ -24,7 +24,7 @@ namespace Emby.Server.Implementations.EntryPoints
private readonly IUserManager _userManager;
private readonly Dictionary> _changedItems = new();
- private readonly object _syncLock = new();
+ private readonly Lock _syncLock = new();
private Timer? _updateTimer;
@@ -144,9 +144,15 @@ namespace Emby.Server.Implementations.EntryPoints
.Select(i =>
{
var dto = _userDataManager.GetUserDataDto(i, user);
+ if (dto is null)
+ {
+ return null!;
+ }
+
dto.ItemId = i.Id;
return dto;
})
+ .Where(e => e is not null)
.ToArray()
};
}
diff --git a/Emby.Server.Implementations/HttpServer/Security/AuthService.cs b/Emby.Server.Implementations/HttpServer/Security/AuthService.cs
index 1d04f3da37..8a79cdebc1 100644
--- a/Emby.Server.Implementations/HttpServer/Security/AuthService.cs
+++ b/Emby.Server.Implementations/HttpServer/Security/AuthService.cs
@@ -1,7 +1,8 @@
#pragma warning disable CS1591
using System.Threading.Tasks;
-using Jellyfin.Data.Enums;
+using Jellyfin.Data;
+using Jellyfin.Database.Implementations.Enums;
using MediaBrowser.Controller.Net;
using Microsoft.AspNetCore.Http;
diff --git a/Emby.Server.Implementations/HttpServer/WebSocketConnection.cs b/Emby.Server.Implementations/HttpServer/WebSocketConnection.cs
index cb6f7e1d35..a720c86fb2 100644
--- a/Emby.Server.Implementations/HttpServer/WebSocketConnection.cs
+++ b/Emby.Server.Implementations/HttpServer/WebSocketConnection.cs
@@ -82,17 +82,17 @@ namespace Emby.Server.Implementations.HttpServer
public WebSocketState State => _socket.State;
///
- public Task SendAsync(OutboundWebSocketMessage message, CancellationToken cancellationToken)
+ public async Task SendAsync(OutboundWebSocketMessage message, CancellationToken cancellationToken)
{
var json = JsonSerializer.SerializeToUtf8Bytes(message, _jsonOptions);
- return _socket.SendAsync(json, WebSocketMessageType.Text, true, cancellationToken);
+ await _socket.SendAsync(json, WebSocketMessageType.Text, true, cancellationToken).ConfigureAwait(false);
}
///
- public Task SendAsync(OutboundWebSocketMessage message, CancellationToken cancellationToken)
+ public async Task SendAsync(OutboundWebSocketMessage message, CancellationToken cancellationToken)
{
var json = JsonSerializer.SerializeToUtf8Bytes(message, _jsonOptions);
- return _socket.SendAsync(json, WebSocketMessageType.Text, true, cancellationToken);
+ await _socket.SendAsync(json, WebSocketMessageType.Text, true, cancellationToken).ConfigureAwait(false);
}
///
@@ -224,12 +224,12 @@ namespace Emby.Server.Implementations.HttpServer
return ret;
}
- private Task SendKeepAliveResponse()
+ private async Task SendKeepAliveResponse()
{
LastKeepAliveDate = DateTime.UtcNow;
- return SendAsync(
+ await SendAsync(
new OutboundKeepAliveMessage(),
- CancellationToken.None);
+ CancellationToken.None).ConfigureAwait(false);
}
///
diff --git a/Emby.Server.Implementations/HttpServer/WebSocketManager.cs b/Emby.Server.Implementations/HttpServer/WebSocketManager.cs
index 774d3563cb..cb5b3993b8 100644
--- a/Emby.Server.Implementations/HttpServer/WebSocketManager.cs
+++ b/Emby.Server.Implementations/HttpServer/WebSocketManager.cs
@@ -84,7 +84,7 @@ namespace Emby.Server.Implementations.HttpServer
/// Processes the web socket message received.
///
/// The result.
- private Task ProcessWebSocketMessageReceived(WebSocketMessageInfo result)
+ private async Task ProcessWebSocketMessageReceived(WebSocketMessageInfo result)
{
var tasks = new Task[_webSocketListeners.Length];
for (var i = 0; i < _webSocketListeners.Length; ++i)
@@ -92,7 +92,7 @@ namespace Emby.Server.Implementations.HttpServer
tasks[i] = _webSocketListeners[i].ProcessMessageAsync(result);
}
- return Task.WhenAll(tasks);
+ await Task.WhenAll(tasks).ConfigureAwait(false);
}
}
}
diff --git a/Emby.Server.Implementations/IO/FileRefresher.cs b/Emby.Server.Implementations/IO/FileRefresher.cs
index e75cab64c9..7378cf8851 100644
--- a/Emby.Server.Implementations/IO/FileRefresher.cs
+++ b/Emby.Server.Implementations/IO/FileRefresher.cs
@@ -18,8 +18,8 @@ namespace Emby.Server.Implementations.IO
private readonly ILibraryManager _libraryManager;
private readonly IServerConfigurationManager _configurationManager;
- private readonly List _affectedPaths = new List();
- private readonly object _timerLock = new object();
+ private readonly List _affectedPaths = new();
+ private readonly Lock _timerLock = new();
private Timer? _timer;
private bool _disposed;
diff --git a/Emby.Server.Implementations/IO/ManagedFileSystem.cs b/Emby.Server.Implementations/IO/ManagedFileSystem.cs
index 4b68f21d55..ac5933a694 100644
--- a/Emby.Server.Implementations/IO/ManagedFileSystem.cs
+++ b/Emby.Server.Implementations/IO/ManagedFileSystem.cs
@@ -276,6 +276,13 @@ namespace Emby.Server.Implementations.IO
{
_logger.LogError(ex, "Reading the file at {Path} failed due to a permissions exception.", fileInfo.FullName);
}
+ catch (IOException ex)
+ {
+ // IOException generally means the file is not accessible due to filesystem issues
+ // Catch this exception and mark the file as not exist to ignore it
+ _logger.LogError(ex, "Reading the file at {Path} failed due to an IO Exception. Marking the file as not existing", fileInfo.FullName);
+ result.Exists = false;
+ }
}
}
@@ -534,8 +541,8 @@ namespace Emby.Server.Implementations.IO
return DriveInfo.GetDrives()
.Where(
d => (d.DriveType == DriveType.Fixed || d.DriveType == DriveType.Network || d.DriveType == DriveType.Removable)
- && d.IsReady
- && d.TotalSize != 0)
+ && d.IsReady
+ && d.TotalSize != 0)
.Select(d => new FileSystemMetadata
{
Name = d.Name,
@@ -553,22 +560,36 @@ namespace Emby.Server.Implementations.IO
///
public virtual IEnumerable GetFiles(string path, bool recursive = false)
{
- return GetFiles(path, null, false, recursive);
+ return GetFiles(path, "*", recursive);
}
///
- public virtual IEnumerable GetFiles(string path, IReadOnlyList? extensions, bool enableCaseSensitiveExtensions, bool recursive = false)
+ public virtual IEnumerable GetFiles(string path, string searchPattern, bool recursive = false)
+ {
+ return GetFiles(path, searchPattern, null, false, recursive);
+ }
+
+ ///
+ public virtual IEnumerable GetFiles(string path, IReadOnlyList? extensions, bool enableCaseSensitiveExtensions, bool recursive)
+ {
+ return GetFiles(path, "*", extensions, enableCaseSensitiveExtensions, recursive);
+ }
+
+ ///
+ public virtual IEnumerable GetFiles(string path, string searchPattern, IReadOnlyList? extensions, bool enableCaseSensitiveExtensions, bool recursive = false)
{
var enumerationOptions = GetEnumerationOptions(recursive);
- // On linux and osx the search pattern is case sensitive
+ // On linux and macOS the search pattern is case-sensitive
// If we're OK with case-sensitivity, and we're only filtering for one extension, then use the native method
if ((enableCaseSensitiveExtensions || _isEnvironmentCaseInsensitive) && extensions is not null && extensions.Count == 1)
{
- return ToMetadata(new DirectoryInfo(path).EnumerateFiles("*" + extensions[0], enumerationOptions));
+ searchPattern = searchPattern.EndsWith(extensions[0], StringComparison.Ordinal) ? searchPattern : searchPattern + extensions[0];
+
+ return ToMetadata(new DirectoryInfo(path).EnumerateFiles(searchPattern, enumerationOptions));
}
- var files = new DirectoryInfo(path).EnumerateFiles("*", enumerationOptions);
+ var files = new DirectoryInfo(path).EnumerateFiles(searchPattern, enumerationOptions);
if (extensions is not null && extensions.Count > 0)
{
@@ -590,6 +611,9 @@ namespace Emby.Server.Implementations.IO
///
public virtual IEnumerable GetFileSystemEntries(string path, bool recursive = false)
{
+ // Note: any of unhandled exceptions thrown by this method may cause the caller to believe the whole path is not accessible.
+ // But what causing the exception may be a single file under that path. This could lead to unexpected behavior.
+ // For example, the scanner will remove everything in that path due to unhandled errors.
var directoryInfo = new DirectoryInfo(path);
var enumerationOptions = GetEnumerationOptions(recursive);
@@ -618,7 +642,7 @@ namespace Emby.Server.Implementations.IO
{
var enumerationOptions = GetEnumerationOptions(recursive);
- // On linux and osx the search pattern is case sensitive
+ // On linux and macOS the search pattern is case-sensitive
// If we're OK with case-sensitivity, and we're only filtering for one extension, then use the native method
if ((enableCaseSensitiveExtensions || _isEnvironmentCaseInsensitive) && extensions is not null && extensions.Length == 1)
{
diff --git a/Emby.Server.Implementations/Images/BaseDynamicImageProvider.cs b/Emby.Server.Implementations/Images/BaseDynamicImageProvider.cs
index 82db7c46b3..8b28691498 100644
--- a/Emby.Server.Implementations/Images/BaseDynamicImageProvider.cs
+++ b/Emby.Server.Implementations/Images/BaseDynamicImageProvider.cs
@@ -7,6 +7,7 @@ using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
+using System.Net.Mime;
using System.Threading;
using System.Threading.Tasks;
using MediaBrowser.Common.Configuration;
@@ -116,13 +117,12 @@ namespace Emby.Server.Implementations.Images
var mimeType = MimeTypes.GetMimeType(outputPath);
- if (string.Equals(mimeType, "application/octet-stream", StringComparison.OrdinalIgnoreCase))
+ if (string.Equals(mimeType, MediaTypeNames.Application.Octet, StringComparison.OrdinalIgnoreCase))
{
- mimeType = "image/png";
+ mimeType = MediaTypeNames.Image.Png;
}
await ProviderManager.SaveImage(item, outputPath, mimeType, imageType, null, false, cancellationToken).ConfigureAwait(false);
- File.Delete(outputPath);
return ItemUpdateType.ImageUpdate;
}
diff --git a/Emby.Server.Implementations/Images/BaseFolderImageProvider.cs b/Emby.Server.Implementations/Images/BaseFolderImageProvider.cs
index f9c10ba098..0d63b3af7d 100644
--- a/Emby.Server.Implementations/Images/BaseFolderImageProvider.cs
+++ b/Emby.Server.Implementations/Images/BaseFolderImageProvider.cs
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using Jellyfin.Data.Enums;
+using Jellyfin.Database.Implementations.Enums;
using MediaBrowser.Common.Configuration;
using MediaBrowser.Controller.Drawing;
using MediaBrowser.Controller.Dto;
diff --git a/Emby.Server.Implementations/Images/CollectionFolderImageProvider.cs b/Emby.Server.Implementations/Images/CollectionFolderImageProvider.cs
index 34c722e41d..273d356a39 100644
--- a/Emby.Server.Implementations/Images/CollectionFolderImageProvider.cs
+++ b/Emby.Server.Implementations/Images/CollectionFolderImageProvider.cs
@@ -6,6 +6,7 @@ using System;
using System.Collections.Generic;
using System.IO;
using Jellyfin.Data.Enums;
+using Jellyfin.Database.Implementations.Enums;
using MediaBrowser.Common.Configuration;
using MediaBrowser.Controller.Drawing;
using MediaBrowser.Controller.Dto;
diff --git a/Emby.Server.Implementations/Images/GenreImageProvider.cs b/Emby.Server.Implementations/Images/GenreImageProvider.cs
index c9b41f8193..706de60a90 100644
--- a/Emby.Server.Implementations/Images/GenreImageProvider.cs
+++ b/Emby.Server.Implementations/Images/GenreImageProvider.cs
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using Jellyfin.Data.Enums;
+using Jellyfin.Database.Implementations.Enums;
using MediaBrowser.Common.Configuration;
using MediaBrowser.Controller.Drawing;
using MediaBrowser.Controller.Dto;
diff --git a/Emby.Server.Implementations/Images/MusicGenreImageProvider.cs b/Emby.Server.Implementations/Images/MusicGenreImageProvider.cs
index 31f053f065..c472623e67 100644
--- a/Emby.Server.Implementations/Images/MusicGenreImageProvider.cs
+++ b/Emby.Server.Implementations/Images/MusicGenreImageProvider.cs
@@ -4,6 +4,7 @@
using System.Collections.Generic;
using Jellyfin.Data.Enums;
+using Jellyfin.Database.Implementations.Enums;
using MediaBrowser.Common.Configuration;
using MediaBrowser.Controller.Drawing;
using MediaBrowser.Controller.Dto;
diff --git a/Emby.Server.Implementations/Library/LibraryManager.cs b/Emby.Server.Implementations/Library/LibraryManager.cs
index 28f7ed6598..1303bb3cb2 100644
--- a/Emby.Server.Implementations/Library/LibraryManager.cs
+++ b/Emby.Server.Implementations/Library/LibraryManager.cs
@@ -2,7 +2,6 @@
#pragma warning disable CA5394
using System;
-using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
@@ -11,6 +10,7 @@ using System.Net;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
+using BitFaster.Caching.Lru;
using Emby.Naming.Common;
using Emby.Naming.TV;
using Emby.Server.Implementations.Library.Resolvers;
@@ -18,8 +18,10 @@ using Emby.Server.Implementations.Library.Validators;
using Emby.Server.Implementations.Playlists;
using Emby.Server.Implementations.ScheduledTasks.Tasks;
using Emby.Server.Implementations.Sorting;
-using Jellyfin.Data.Entities;
+using Jellyfin.Data;
using Jellyfin.Data.Enums;
+using Jellyfin.Database.Implementations.Entities;
+using Jellyfin.Database.Implementations.Enums;
using Jellyfin.Extensions;
using MediaBrowser.Common.Extensions;
using MediaBrowser.Controller;
@@ -62,7 +64,6 @@ namespace Emby.Server.Implementations.Library
private const string ShortcutFileExtension = ".mblink";
private readonly ILogger _logger;
- private readonly ConcurrentDictionary _cache;
private readonly ITaskManager _taskManager;
private readonly IUserManager _userManager;
private readonly IUserDataManager _userDataRepository;
@@ -76,13 +77,16 @@ namespace Emby.Server.Implementations.Library
private readonly IItemRepository _itemRepository;
private readonly IImageProcessor _imageProcessor;
private readonly NamingOptions _namingOptions;
+ private readonly IPeopleRepository _peopleRepository;
private readonly ExtraResolver _extraResolver;
+ private readonly IPathManager _pathManager;
+ private readonly FastConcurrentLru _cache;
///
/// The _root folder sync lock.
///
- private readonly object _rootFolderSyncLock = new object();
- private readonly object _userRootFolderSyncLock = new object();
+ private readonly Lock _rootFolderSyncLock = new();
+ private readonly Lock _userRootFolderSyncLock = new();
private readonly TimeSpan _viewRefreshInterval = TimeSpan.FromHours(24);
@@ -112,6 +116,8 @@ namespace Emby.Server.Implementations.Library
/// The image processor.
/// The naming options.
/// The directory service.
+ /// The people repository.
+ /// The path manager.
public LibraryManager(
IServerApplicationHost appHost,
ILoggerFactory loggerFactory,
@@ -127,7 +133,9 @@ namespace Emby.Server.Implementations.Library
IItemRepository itemRepository,
IImageProcessor imageProcessor,
NamingOptions namingOptions,
- IDirectoryService directoryService)
+ IDirectoryService directoryService,
+ IPeopleRepository peopleRepository,
+ IPathManager pathManager)
{
_appHost = appHost;
_logger = loggerFactory.CreateLogger();
@@ -142,14 +150,17 @@ namespace Emby.Server.Implementations.Library
_mediaEncoder = mediaEncoder;
_itemRepository = itemRepository;
_imageProcessor = imageProcessor;
- _cache = new ConcurrentDictionary();
- _namingOptions = namingOptions;
+ _cache = new FastConcurrentLru(_configurationManager.Configuration.CacheSize);
+
+ _namingOptions = namingOptions;
+ _peopleRepository = peopleRepository;
+ _pathManager = pathManager;
_extraResolver = new ExtraResolver(loggerFactory.CreateLogger(), namingOptions, directoryService);
_configurationManager.ConfigurationUpdated += ConfigurationUpdated;
- RecordConfigurationValues(configurationManager.Configuration);
+ RecordConfigurationValues(_configurationManager.Configuration);
}
///
@@ -197,33 +208,33 @@ namespace Emby.Server.Implementations.Library
/// Gets or sets the postscan tasks.
///
/// The postscan tasks.
- private ILibraryPostScanTask[] PostscanTasks { get; set; } = Array.Empty();
+ private ILibraryPostScanTask[] PostscanTasks { get; set; } = [];
///
/// Gets or sets the intro providers.
///
/// The intro providers.
- private IIntroProvider[] IntroProviders { get; set; } = Array.Empty();
+ private IIntroProvider[] IntroProviders { get; set; } = [];
///
/// Gets or sets the list of entity resolution ignore rules.
///
/// The entity resolution ignore rules.
- private IResolverIgnoreRule[] EntityResolutionIgnoreRules { get; set; } = Array.Empty();
+ private IResolverIgnoreRule[] EntityResolutionIgnoreRules { get; set; } = [];
///
/// Gets or sets the list of currently registered entity resolvers.
///
/// The entity resolvers enumerable.
- private IItemResolver[] EntityResolvers { get; set; } = Array.Empty();
+ private IItemResolver[] EntityResolvers { get; set; } = [];
- private IMultiItemResolver[] MultiItemResolvers { get; set; } = Array.Empty();
+ private IMultiItemResolver[] MultiItemResolvers { get; set; } = [];
///
/// Gets or sets the comparers.
///
/// The comparers.
- private IBaseItemComparer[] Comparers { get; set; } = Array.Empty();
+ private IBaseItemComparer[] Comparers { get; set; } = [];
public bool IsScanRunning { get; private set; }
@@ -297,7 +308,7 @@ namespace Emby.Server.Implementations.Library
}
}
- _cache[item.Id] = item;
+ _cache.AddOrUpdate(item.Id, item);
}
public void DeleteItem(BaseItem item, DeleteOptions options)
@@ -356,7 +367,7 @@ namespace Emby.Server.Implementations.Library
var children = item.IsFolder
? ((Folder)item).GetRecursiveChildren(false)
- : Array.Empty();
+ : [];
foreach (var metadataPath in GetMetadataPaths(item, children))
{
@@ -451,24 +462,55 @@ namespace Emby.Server.Implementations.Library
item.SetParent(null);
_itemRepository.DeleteItem(item.Id);
+ _cache.TryRemove(item.Id, out _);
foreach (var child in children)
{
_itemRepository.DeleteItem(child.Id);
+ _cache.TryRemove(child.Id, out _);
}
- _cache.TryRemove(item.Id, out _);
-
ReportItemRemoved(item, parent);
}
- private static List GetMetadataPaths(BaseItem item, IEnumerable children)
+ private List GetMetadataPaths(BaseItem item, IEnumerable children)
+ {
+ var list = GetInternalMetadataPaths(item);
+ foreach (var child in children)
+ {
+ list.AddRange(GetInternalMetadataPaths(child));
+ }
+
+ return list;
+ }
+
+ private List GetInternalMetadataPaths(BaseItem item)
{
var list = new List
{
item.GetInternalMetadataPath()
};
- list.AddRange(children.Select(i => i.GetInternalMetadataPath()));
+ if (item is Video video)
+ {
+ // Trickplay
+ list.Add(_pathManager.GetTrickplayDirectory(video));
+
+ // Subtitles and attachments
+ foreach (var mediaSource in item.GetMediaSources(false))
+ {
+ var subtitleFolder = _pathManager.GetSubtitleFolderPath(mediaSource.Id);
+ if (subtitleFolder is not null)
+ {
+ list.Add(subtitleFolder);
+ }
+
+ var attachmentFolder = _pathManager.GetAttachmentFolderPath(mediaSource.Id);
+ if (attachmentFolder is not null)
+ {
+ list.Add(attachmentFolder);
+ }
+ }
+ }
return list;
}
@@ -589,7 +631,7 @@ namespace Emby.Server.Implementations.Library
{
_logger.LogError(ex, "Error in GetFilteredFileSystemEntries isPhysicalRoot: {0} IsVf: {1}", isPhysicalRoot, isVf);
- files = Array.Empty();
+ files = [];
}
else
{
@@ -751,14 +793,7 @@ namespace Emby.Server.Implementations.Library
if (folder.Id.IsEmpty())
{
- if (string.IsNullOrEmpty(folder.Path))
- {
- folder.Id = GetNewItemId(folder.GetType().Name, folder.GetType());
- }
- else
- {
- folder.Id = GetNewItemId(folder.Path, folder.GetType());
- }
+ folder.Id = GetNewItemId(folder.Path, folder.GetType());
}
var dbItem = GetItemById(folder.Id) as BasePluginFolder;
@@ -1053,9 +1088,17 @@ namespace Emby.Server.Implementations.Library
cancellationToken: cancellationToken).ConfigureAwait(false);
// Quickly scan CollectionFolders for changes
- foreach (var folder in GetUserRootFolder().Children.OfType())
+ foreach (var child in GetUserRootFolder().Children.OfType())
{
- await folder.RefreshMetadata(cancellationToken).ConfigureAwait(false);
+ // If the user has somehow deleted the collection directory, remove the metadata from the database.
+ if (child is CollectionFolder collectionFolder && !Directory.Exists(collectionFolder.Path))
+ {
+ _itemRepository.DeleteItem(collectionFolder.Id);
+ }
+ else
+ {
+ await child.RefreshMetadata(cancellationToken).ConfigureAwait(false);
+ }
}
}
@@ -1230,7 +1273,7 @@ namespace Emby.Server.Implementations.Library
throw new ArgumentException("Guid can't be empty", nameof(id));
}
- if (_cache.TryGetValue(id, out BaseItem? item))
+ if (_cache.TryGet(id, out var item))
{
return item;
}
@@ -1247,7 +1290,7 @@ namespace Emby.Server.Implementations.Library
///
public T? GetItemById(Guid id)
- where T : BaseItem
+ where T : BaseItem
{
var item = GetItemById(id);
if (item is T typedItem)
@@ -1274,7 +1317,7 @@ namespace Emby.Server.Implementations.Library
return ItemIsVisible(item, user) ? item : null;
}
- public List GetItemList(InternalItemsQuery query, bool allowExternalContent)
+ public IReadOnlyList GetItemList(InternalItemsQuery query, bool allowExternalContent)
{
if (query.Recursive && !query.ParentId.IsEmpty())
{
@@ -1300,7 +1343,7 @@ namespace Emby.Server.Implementations.Library
return itemList;
}
- public List GetItemList(InternalItemsQuery query)
+ public IReadOnlyList GetItemList(InternalItemsQuery query)
{
return GetItemList(query, true);
}
@@ -1324,7 +1367,7 @@ namespace Emby.Server.Implementations.Library
return _itemRepository.GetCount(query);
}
- public List GetItemList(InternalItemsQuery query, List parents)
+ public IReadOnlyList GetItemList(InternalItemsQuery query, List parents)
{
SetTopParentIdsOrAncestors(query, parents);
@@ -1339,6 +1382,36 @@ namespace Emby.Server.Implementations.Library
return _itemRepository.GetItemList(query);
}
+ public IReadOnlyList GetLatestItemList(InternalItemsQuery query, IReadOnlyList parents, CollectionType collectionType)
+ {
+ SetTopParentIdsOrAncestors(query, parents);
+
+ if (query.AncestorIds.Length == 0 && query.TopParentIds.Length == 0)
+ {
+ if (query.User is not null)
+ {
+ AddUserToQuery(query, query.User);
+ }
+ }
+
+ return _itemRepository.GetLatestItemList(query, collectionType);
+ }
+
+ public IReadOnlyList GetNextUpSeriesKeys(InternalItemsQuery query, IReadOnlyCollection parents, DateTime dateCutoff)
+ {
+ SetTopParentIdsOrAncestors(query, parents);
+
+ if (query.AncestorIds.Length == 0 && query.TopParentIds.Length == 0)
+ {
+ if (query.User is not null)
+ {
+ AddUserToQuery(query, query.User);
+ }
+ }
+
+ return _itemRepository.GetNextUpSeriesKeys(query, dateCutoff);
+ }
+
public QueryResult QueryItems(InternalItemsQuery query)
{
if (query.User is not null)
@@ -1357,7 +1430,7 @@ namespace Emby.Server.Implementations.Library
_itemRepository.GetItemList(query));
}
- public List GetItemIds(InternalItemsQuery query)
+ public IReadOnlyList GetItemIds(InternalItemsQuery query)
{
if (query.User is not null)
{
@@ -1443,7 +1516,7 @@ namespace Emby.Server.Implementations.Library
// Optimize by querying against top level views
query.TopParentIds = parents.SelectMany(i => GetTopParentIdsForQuery(i, query.User)).ToArray();
- query.AncestorIds = Array.Empty();
+ query.AncestorIds = [];
// Prevent searching in all libraries due to empty filter
if (query.TopParentIds.Length == 0)
@@ -1563,7 +1636,7 @@ namespace Emby.Server.Implementations.Library
return GetTopParentIdsForQuery(displayParent, user);
}
- return Array.Empty();
+ return [];
}
if (!view.ParentId.IsEmpty())
@@ -1574,7 +1647,7 @@ namespace Emby.Server.Implementations.Library
return GetTopParentIdsForQuery(displayParent, user);
}
- return Array.Empty();
+ return [];
}
// Handle grouping
@@ -1589,7 +1662,7 @@ namespace Emby.Server.Implementations.Library
.SelectMany(i => GetTopParentIdsForQuery(i, user));
}
- return Array.Empty();
+ return [];
}
if (item is CollectionFolder collectionFolder)
@@ -1603,7 +1676,7 @@ namespace Emby.Server.Implementations.Library
return new[] { topParent.Id };
}
- return Array.Empty();
+ return [];
}
///
@@ -1647,7 +1720,7 @@ namespace Emby.Server.Implementations.Library
{
_logger.LogError(ex, "Error getting intros");
- return Enumerable.Empty();
+ return [];
}
}
@@ -1955,13 +2028,13 @@ namespace Emby.Server.Implementations.Library
///
public async Task UpdateItemsAsync(IReadOnlyList items, BaseItem parent, ItemUpdateType updateReason, CancellationToken cancellationToken)
{
+ _itemRepository.SaveItems(items, cancellationToken);
+
foreach (var item in items)
{
await RunMetadataSavers(item, updateReason).ConfigureAwait(false);
}
- _itemRepository.SaveItems(items, cancellationToken);
-
if (ItemUpdated is not null)
{
foreach (var item in items)
@@ -2474,8 +2547,11 @@ namespace Emby.Server.Implementations.Library
}
///
- public int? GetSeasonNumberFromPath(string path)
- => SeasonPathParser.Parse(path, true, true).SeasonNumber;
+ public int? GetSeasonNumberFromPath(string path, Guid? parentId)
+ {
+ var parentPath = parentId.HasValue ? GetItemById(parentId.Value)?.ContainingFolderPath : null;
+ return SeasonPathParser.Parse(path, parentPath, true, true).SeasonNumber;
+ }
///
public bool FillMissingEpisodeNumbersFromPath(Episode episode, bool forceRefresh)
@@ -2626,15 +2702,6 @@ namespace Emby.Server.Implementations.Library
{
episode.ParentIndexNumber = season.IndexNumber;
}
- else
- {
- /*
- Anime series don't generally have a season in their file name, however,
- TVDb needs a season to correctly get the metadata.
- Hence, a null season needs to be filled with something. */
- // FIXME perhaps this would be better for TVDb parser to ask for season 1 if no season is specified
- episode.ParentIndexNumber = 1;
- }
if (episode.ParentIndexNumber.HasValue)
{
@@ -2659,7 +2726,7 @@ namespace Emby.Server.Implementations.Library
public IEnumerable FindExtras(BaseItem owner, IReadOnlyList fileSystemChildren, IDirectoryService directoryService)
{
- var ownerVideoInfo = VideoResolver.Resolve(owner.Path, owner.IsFolder, _namingOptions);
+ var ownerVideoInfo = VideoResolver.Resolve(owner.Path, owner.IsFolder, _namingOptions, libraryRoot: owner.ContainingFolderPath);
if (ownerVideoInfo is null)
{
yield break;
@@ -2736,12 +2803,12 @@ namespace Emby.Server.Implementations.Library
return path;
}
- public List GetPeople(InternalPeopleQuery query)
+ public IReadOnlyList GetPeople(InternalPeopleQuery query)
{
- return _itemRepository.GetPeople(query);
+ return _peopleRepository.GetPeople(query);
}
- public List GetPeople(BaseItem item)
+ public IReadOnlyList GetPeople(BaseItem item)
{
if (item.SupportsPeople)
{
@@ -2756,12 +2823,12 @@ namespace Emby.Server.Implementations.Library
}
}
- return new List();
+ return [];
}
- public List GetPeopleItems(InternalPeopleQuery query)
+ public IReadOnlyList GetPeopleItems(InternalPeopleQuery query)
{
- return _itemRepository.GetPeopleNames(query)
+ return _peopleRepository.GetPeopleNames(query)
.Select(i =>
{
try
@@ -2779,9 +2846,9 @@ namespace Emby.Server.Implementations.Library
.ToList()!; // null values are filtered out
}
- public List GetPeopleNames(InternalPeopleQuery query)
+ public IReadOnlyList GetPeopleNames(InternalPeopleQuery query)
{
- return _itemRepository.GetPeopleNames(query);
+ return _peopleRepository.GetPeopleNames(query);
}
public void UpdatePeople(BaseItem item, List people)
@@ -2790,16 +2857,17 @@ namespace Emby.Server.Implementations.Library
}
///
- public async Task UpdatePeopleAsync(BaseItem item, List people, CancellationToken cancellationToken)
+ public async Task UpdatePeopleAsync(BaseItem item, IReadOnlyList people, CancellationToken cancellationToken)
{
if (!item.SupportsPeople)
{
return;
}
- _itemRepository.UpdatePeople(item.Id, people);
if (people is not null)
{
+ people = people.Where(e => e is not null).ToArray();
+ _peopleRepository.UpdatePeople(item.Id, people);
await SavePeopleMetadataAsync(people, cancellationToken).ConfigureAwait(false);
}
}
@@ -2848,7 +2916,7 @@ namespace Emby.Server.Implementations.Library
throw new ArgumentNullException(nameof(name));
}
- name = _fileSystem.GetValidFilename(name);
+ name = _fileSystem.GetValidFilename(name.Trim());
var rootFolderPath = _configurationManager.ApplicationPaths.DefaultUserViewsPath;
@@ -2882,7 +2950,7 @@ namespace Emby.Server.Implementations.Library
{
var path = Path.Combine(virtualFolderPath, collectionType.ToString()!.ToLowerInvariant() + ".collection"); // Can't be null with legal values?
- await File.WriteAllBytesAsync(path, Array.Empty()).ConfigureAwait(false);
+ await File.WriteAllBytesAsync(path, []).ConfigureAwait(false);
}
CollectionFolder.SaveLibraryOptions(virtualFolderPath, options);
@@ -2914,14 +2982,13 @@ namespace Emby.Server.Implementations.Library
private async Task SavePeopleMetadataAsync(IEnumerable people, CancellationToken cancellationToken)
{
- List? personsToSave = null;
-
foreach (var person in people)
{
cancellationToken.ThrowIfCancellationRequested();
var itemUpdateType = ItemUpdateType.MetadataDownload;
var saveEntity = false;
+ var createEntity = false;
var personEntity = GetPerson(person.Name);
if (personEntity is null)
@@ -2938,6 +3005,7 @@ namespace Emby.Server.Implementations.Library
personEntity.PresentationUniqueKey = personEntity.CreatePresentationUniqueKey();
saveEntity = true;
+ createEntity = true;
}
foreach (var id in person.ProviderIds)
@@ -2965,14 +3033,14 @@ namespace Emby.Server.Implementations.Library
if (saveEntity)
{
- (personsToSave ??= new()).Add(personEntity);
- await RunMetadataSavers(personEntity, itemUpdateType).ConfigureAwait(false);
- }
- }
+ if (createEntity)
+ {
+ CreateItems([personEntity], null, CancellationToken.None);
+ }
- if (personsToSave is not null)
- {
- CreateItems(personsToSave, null, CancellationToken.None);
+ await RunMetadataSavers(personEntity, itemUpdateType).ConfigureAwait(false);
+ CreateItems([personEntity], null, CancellationToken.None);
+ }
}
}
@@ -3027,7 +3095,7 @@ namespace Emby.Server.Implementations.Library
{
var libraryOptions = CollectionFolder.GetLibraryOptions(virtualFolderPath);
- libraryOptions.PathInfos = [..libraryOptions.PathInfos, pathInfo];
+ libraryOptions.PathInfos = [.. libraryOptions.PathInfos, pathInfo];
SyncLibraryOptionsToLocations(virtualFolderPath, libraryOptions);
diff --git a/Emby.Server.Implementations/Library/MediaSourceManager.cs b/Emby.Server.Implementations/Library/MediaSourceManager.cs
index 90a01c052c..c6cfd5391a 100644
--- a/Emby.Server.Implementations/Library/MediaSourceManager.cs
+++ b/Emby.Server.Implementations/Library/MediaSourceManager.cs
@@ -5,6 +5,7 @@
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
+using System.Collections.Immutable;
using System.Globalization;
using System.IO;
using System.Linq;
@@ -12,8 +13,10 @@ using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
using AsyncKeyedLock;
-using Jellyfin.Data.Entities;
+using Jellyfin.Data;
using Jellyfin.Data.Enums;
+using Jellyfin.Database.Implementations.Entities;
+using Jellyfin.Database.Implementations.Enums;
using Jellyfin.Extensions;
using Jellyfin.Extensions.Json;
using MediaBrowser.Common.Configuration;
@@ -38,7 +41,7 @@ namespace Emby.Server.Implementations.Library
public class MediaSourceManager : IMediaSourceManager, IDisposable
{
// Do not use a pipe here because Roku http requests to the server will fail, without any explicit error message.
- private const char LiveStreamIdDelimeter = '_';
+ private const char LiveStreamIdDelimiter = '_';
private readonly IServerApplicationHost _appHost;
private readonly IItemRepository _itemRepo;
@@ -51,7 +54,8 @@ namespace Emby.Server.Implementations.Library
private readonly ILocalizationManager _localizationManager;
private readonly IApplicationPaths _appPaths;
private readonly IDirectoryService _directoryService;
-
+ private readonly IMediaStreamRepository _mediaStreamRepository;
+ private readonly IMediaAttachmentRepository _mediaAttachmentRepository;
private readonly ConcurrentDictionary _openStreams = new ConcurrentDictionary(StringComparer.OrdinalIgnoreCase);
private readonly AsyncNonKeyedLocker _liveStreamLocker = new(1);
private readonly JsonSerializerOptions _jsonOptions = JsonDefaults.Options;
@@ -69,7 +73,9 @@ namespace Emby.Server.Implementations.Library
IFileSystem fileSystem,
IUserDataManager userDataManager,
IMediaEncoder mediaEncoder,
- IDirectoryService directoryService)
+ IDirectoryService directoryService,
+ IMediaStreamRepository mediaStreamRepository,
+ IMediaAttachmentRepository mediaAttachmentRepository)
{
_appHost = appHost;
_itemRepo = itemRepo;
@@ -82,6 +88,8 @@ namespace Emby.Server.Implementations.Library
_localizationManager = localizationManager;
_appPaths = applicationPaths;
_directoryService = directoryService;
+ _mediaStreamRepository = mediaStreamRepository;
+ _mediaAttachmentRepository = mediaAttachmentRepository;
}
public void AddParts(IEnumerable providers)
@@ -89,9 +97,9 @@ namespace Emby.Server.Implementations.Library
_providers = providers.ToArray();
}
- public List GetMediaStreams(MediaStreamQuery query)
+ public IReadOnlyList GetMediaStreams(MediaStreamQuery query)
{
- var list = _itemRepo.GetMediaStreams(query);
+ var list = _mediaStreamRepository.GetMediaStreams(query);
foreach (var stream in list)
{
@@ -121,7 +129,7 @@ namespace Emby.Server.Implementations.Library
return false;
}
- public List GetMediaStreams(Guid itemId)
+ public IReadOnlyList GetMediaStreams(Guid itemId)
{
var list = GetMediaStreams(new MediaStreamQuery
{
@@ -131,7 +139,7 @@ namespace Emby.Server.Implementations.Library
return GetMediaStreamsForItem(list);
}
- private List GetMediaStreamsForItem(List streams)
+ private IReadOnlyList GetMediaStreamsForItem(IReadOnlyList streams)
{
foreach (var stream in streams)
{
@@ -145,13 +153,13 @@ namespace Emby.Server.Implementations.Library
}
///
- public List GetMediaAttachments(MediaAttachmentQuery query)
+ public IReadOnlyList GetMediaAttachments(MediaAttachmentQuery query)
{
- return _itemRepo.GetMediaAttachments(query);
+ return _mediaAttachmentRepository.GetMediaAttachments(query);
}
///
- public List GetMediaAttachments(Guid itemId)
+ public IReadOnlyList GetMediaAttachments(Guid itemId)
{
return GetMediaAttachments(new MediaAttachmentQuery
{
@@ -159,7 +167,7 @@ namespace Emby.Server.Implementations.Library
});
}
- public async Task> GetPlaybackMediaSources(BaseItem item, User user, bool allowMediaProbe, bool enablePathSubstitution, CancellationToken cancellationToken)
+ public async Task> GetPlaybackMediaSources(BaseItem item, User user, bool allowMediaProbe, bool enablePathSubstitution, CancellationToken cancellationToken)
{
var mediaSources = GetStaticMediaSources(item, enablePathSubstitution, user);
@@ -212,7 +220,7 @@ namespace Emby.Server.Implementations.Library
list.Add(source);
}
- return SortMediaSources(list);
+ return SortMediaSources(list).ToArray();
}
/// >
@@ -307,7 +315,7 @@ namespace Emby.Server.Implementations.Library
private static void SetKeyProperties(IMediaSourceProvider provider, MediaSourceInfo mediaSource)
{
- var prefix = provider.GetType().FullName.GetMD5().ToString("N", CultureInfo.InvariantCulture) + LiveStreamIdDelimeter;
+ var prefix = provider.GetType().FullName.GetMD5().ToString("N", CultureInfo.InvariantCulture) + LiveStreamIdDelimiter;
if (!string.IsNullOrEmpty(mediaSource.OpenToken) && !mediaSource.OpenToken.StartsWith(prefix, StringComparison.OrdinalIgnoreCase))
{
@@ -332,7 +340,7 @@ namespace Emby.Server.Implementations.Library
return sources.FirstOrDefault(i => string.Equals(i.Id, mediaSourceId, StringComparison.OrdinalIgnoreCase));
}
- public List GetStaticMediaSources(BaseItem item, bool enablePathSubstitution, User user = null)
+ public IReadOnlyList GetStaticMediaSources(BaseItem item, bool enablePathSubstitution, User user = null)
{
ArgumentNullException.ThrowIfNull(item);
@@ -419,6 +427,7 @@ namespace Emby.Server.Implementations.Library
if (source.MediaStreams.Any(i => i.Type == MediaStreamType.Audio && i.Index == index))
{
source.DefaultAudioStreamIndex = index;
+ source.DefaultAudioIndexSource = AudioIndexSource.User;
return;
}
}
@@ -426,6 +435,15 @@ namespace Emby.Server.Implementations.Library
var preferredAudio = NormalizeLanguage(user.AudioLanguagePreference);
source.DefaultAudioStreamIndex = MediaStreamSelector.GetDefaultAudioStreamIndex(source.MediaStreams, preferredAudio, user.PlayDefaultAudioTrack);
+ if (user.PlayDefaultAudioTrack)
+ {
+ source.DefaultAudioIndexSource |= AudioIndexSource.Default;
+ }
+
+ if (preferredAudio.Count > 0)
+ {
+ source.DefaultAudioIndexSource |= AudioIndexSource.Language;
+ }
}
public void SetDefaultAudioAndSubtitleStreamIndices(BaseItem item, MediaSourceInfo source, User user)
@@ -453,7 +471,7 @@ namespace Emby.Server.Implementations.Library
}
}
- private static List SortMediaSources(IEnumerable sources)
+ private static IEnumerable SortMediaSources(IEnumerable sources)
{
return sources.OrderBy(i =>
{
@@ -470,8 +488,7 @@ namespace Emby.Server.Implementations.Library
return stream?.Width ?? 0;
})
- .Where(i => i.Type != MediaSourceType.Placeholder)
- .ToList();
+ .Where(i => i.Type != MediaSourceType.Placeholder);
}
public async Task> OpenLiveStreamInternal(LiveStreamRequest request, CancellationToken cancellationToken)
@@ -777,9 +794,13 @@ namespace Emby.Server.Implementations.Library
{
ArgumentException.ThrowIfNullOrEmpty(id);
- // TODO probably shouldn't throw here but it is kept for "backwards compatibility"
- var info = GetLiveStreamInfo(id) ?? throw new ResourceNotFoundException();
- return Task.FromResult(new Tuple(info.MediaSource, info as IDirectStreamProvider));
+ var info = GetLiveStreamInfo(id);
+ if (info is null)
+ {
+ return Task.FromResult>(new Tuple(null, null));
+ }
+
+ return Task.FromResult>(new Tuple(info.MediaSource, info as IDirectStreamProvider));
}
public ILiveStream GetLiveStreamInfo(string id)
@@ -806,7 +827,7 @@ namespace Emby.Server.Implementations.Library
return result.Item1;
}
- public async Task> GetRecordingStreamMediaSources(ActiveRecordingInfo info, CancellationToken cancellationToken)
+ public async Task> GetRecordingStreamMediaSources(ActiveRecordingInfo info, CancellationToken cancellationToken)
{
var stream = new MediaSourceInfo
{
@@ -829,10 +850,7 @@ namespace Emby.Server.Implementations.Library
await new LiveStreamHelper(_mediaEncoder, _logger, _appPaths)
.AddMediaInfoWithProbe(stream, false, false, cancellationToken).ConfigureAwait(false);
- return new List
- {
- stream
- };
+ return [stream];
}
public async Task CloseLiveStream(string id)
@@ -864,11 +882,11 @@ namespace Emby.Server.Implementations.Library
{
ArgumentException.ThrowIfNullOrEmpty(key);
- var keys = key.Split(LiveStreamIdDelimeter, 2);
+ var keys = key.Split(LiveStreamIdDelimiter, 2);
var provider = _providers.FirstOrDefault(i => string.Equals(i.GetType().FullName.GetMD5().ToString("N", CultureInfo.InvariantCulture), keys[0], StringComparison.OrdinalIgnoreCase));
- var splitIndex = key.IndexOf(LiveStreamIdDelimeter, StringComparison.Ordinal);
+ var splitIndex = key.IndexOf(LiveStreamIdDelimiter, StringComparison.Ordinal);
var keyId = key.Substring(splitIndex + 1);
return (provider, keyId);
diff --git a/Emby.Server.Implementations/Library/MediaStreamSelector.cs b/Emby.Server.Implementations/Library/MediaStreamSelector.cs
index ea223e3ece..631179ffcf 100644
--- a/Emby.Server.Implementations/Library/MediaStreamSelector.cs
+++ b/Emby.Server.Implementations/Library/MediaStreamSelector.cs
@@ -3,7 +3,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
-using Jellyfin.Data.Enums;
+using Jellyfin.Database.Implementations.Enums;
using Jellyfin.Extensions;
using MediaBrowser.Model.Entities;
@@ -39,46 +39,48 @@ namespace Emby.Server.Implementations.Library
return null;
}
+ // Sort in the following order: Default > No tag > Forced
var sortedStreams = streams
.Where(i => i.Type == MediaStreamType.Subtitle)
.OrderByDescending(x => x.IsExternal)
- .ThenByDescending(x => x.IsForced && string.Equals(x.Language, audioTrackLanguage, StringComparison.OrdinalIgnoreCase))
- .ThenByDescending(x => x.IsForced)
.ThenByDescending(x => x.IsDefault)
- .ThenByDescending(x => preferredLanguages.Contains(x.Language, StringComparison.OrdinalIgnoreCase))
+ .ThenByDescending(x => !x.IsForced && MatchesPreferredLanguage(x.Language, preferredLanguages))
+ .ThenByDescending(x => x.IsForced && MatchesPreferredLanguage(x.Language, preferredLanguages))
+ .ThenByDescending(x => x.IsForced && IsLanguageUndefined(x.Language))
+ .ThenByDescending(x => x.IsForced)
.ToList();
MediaStream? stream = null;
+
if (mode == SubtitlePlaybackMode.Default)
{
- // Load subtitles according to external, forced and default flags.
- stream = sortedStreams.FirstOrDefault(x => x.IsExternal || x.IsForced || x.IsDefault);
+ // Load subtitles according to external, default and forced flags.
+ stream = sortedStreams.FirstOrDefault(x => x.IsExternal || x.IsDefault || x.IsForced);
}
else if (mode == SubtitlePlaybackMode.Smart)
{
// Only attempt to load subtitles if the audio language is not one of the user's preferred subtitle languages.
- // If no subtitles of preferred language available, use default behaviour.
+ // If no subtitles of preferred language available, use none.
+ // If the audio language is one of the user's preferred subtitle languages behave like OnlyForced.
if (!preferredLanguages.Contains(audioTrackLanguage, StringComparison.OrdinalIgnoreCase))
{
- stream = sortedStreams.FirstOrDefault(x => preferredLanguages.Contains(x.Language, StringComparison.OrdinalIgnoreCase)) ??
- sortedStreams.FirstOrDefault(x => x.IsExternal || x.IsForced || x.IsDefault);
+ stream = sortedStreams.FirstOrDefault(x => MatchesPreferredLanguage(x.Language, preferredLanguages));
}
else
{
- // Respect forced flag.
- stream = sortedStreams.FirstOrDefault(x => x.IsForced);
+ stream = BehaviorOnlyForced(sortedStreams, preferredLanguages).FirstOrDefault();
}
}
else if (mode == SubtitlePlaybackMode.Always)
{
- // Always load (full/non-forced) subtitles of the user's preferred subtitle language if possible, otherwise default behaviour.
- stream = sortedStreams.FirstOrDefault(x => !x.IsForced && preferredLanguages.Contains(x.Language, StringComparison.OrdinalIgnoreCase)) ??
- sortedStreams.FirstOrDefault(x => x.IsExternal || x.IsForced || x.IsDefault);
+ // Always load (full/non-forced) subtitles of the user's preferred subtitle language if possible, otherwise OnlyForced behaviour.
+ stream = sortedStreams.FirstOrDefault(x => !x.IsForced && MatchesPreferredLanguage(x.Language, preferredLanguages)) ??
+ BehaviorOnlyForced(sortedStreams, preferredLanguages).FirstOrDefault();
}
else if (mode == SubtitlePlaybackMode.OnlyForced)
{
- // Only load subtitles that are flagged forced.
- stream = sortedStreams.FirstOrDefault(x => x.IsForced);
+ // Load subtitles that are flagged forced of the user's preferred subtitle language or with an undefined language
+ stream = BehaviorOnlyForced(sortedStreams, preferredLanguages).FirstOrDefault();
}
return stream?.Index;
@@ -110,40 +112,72 @@ namespace Emby.Server.Implementations.Library
if (mode == SubtitlePlaybackMode.Default)
{
// Prefer embedded metadata over smart logic
- filteredStreams = sortedStreams.Where(s => s.IsForced || s.IsDefault)
+ // Load subtitles according to external, default, and forced flags.
+ filteredStreams = sortedStreams.Where(s => s.IsExternal || s.IsDefault || s.IsForced)
.ToList();
}
else if (mode == SubtitlePlaybackMode.Smart)
{
// Prefer smart logic over embedded metadata
+ // Only attempt to load subtitles if the audio language is not one of the user's preferred subtitle languages, otherwise OnlyForced behavior.
if (!preferredLanguages.Contains(audioTrackLanguage, StringComparison.OrdinalIgnoreCase))
{
- filteredStreams = sortedStreams.Where(s => !s.IsForced && preferredLanguages.Contains(s.Language, StringComparison.OrdinalIgnoreCase))
+ filteredStreams = sortedStreams.Where(s => MatchesPreferredLanguage(s.Language, preferredLanguages))
.ToList();
}
+ else
+ {
+ filteredStreams = BehaviorOnlyForced(sortedStreams, preferredLanguages);
+ }
}
else if (mode == SubtitlePlaybackMode.Always)
{
- // Always load the most suitable full subtitles
- filteredStreams = sortedStreams.Where(s => !s.IsForced).ToList();
+ // Always load (full/non-forced) subtitles of the user's preferred subtitle language if possible, otherwise OnlyForced behavior.
+ filteredStreams = sortedStreams.Where(s => !s.IsForced && MatchesPreferredLanguage(s.Language, preferredLanguages))
+ .ToList() ?? BehaviorOnlyForced(sortedStreams, preferredLanguages);
}
else if (mode == SubtitlePlaybackMode.OnlyForced)
{
- // Always load the most suitable full subtitles
- filteredStreams = sortedStreams.Where(s => s.IsForced).ToList();
+ // Load subtitles that are flagged forced of the user's preferred subtitle language or with an undefined language
+ filteredStreams = BehaviorOnlyForced(sortedStreams, preferredLanguages);
}
- // Load forced subs if we have found no suitable full subtitles
- var iterStreams = filteredStreams is null || filteredStreams.Count == 0
- ? sortedStreams.Where(s => s.IsForced && string.Equals(s.Language, audioTrackLanguage, StringComparison.OrdinalIgnoreCase))
- : filteredStreams;
+ // If filteredStreams is null, initialize it as an empty list to avoid null reference errors
+ filteredStreams ??= new List();
- foreach (var stream in iterStreams)
+ foreach (var stream in filteredStreams)
{
stream.Score = GetStreamScore(stream, preferredLanguages);
}
}
+ private static bool MatchesPreferredLanguage(string language, IReadOnlyList preferredLanguages)
+ {
+ // If preferredLanguages is empty, treat it as "any language" (wildcard)
+ return preferredLanguages.Count == 0 ||
+ preferredLanguages.Contains(language, StringComparison.OrdinalIgnoreCase);
+ }
+
+ private static bool IsLanguageUndefined(string language)
+ {
+ // Check for null, empty, or known placeholders
+ return string.IsNullOrEmpty(language) ||
+ language.Equals("und", StringComparison.OrdinalIgnoreCase) ||
+ language.Equals("unknown", StringComparison.OrdinalIgnoreCase) ||
+ language.Equals("undetermined", StringComparison.OrdinalIgnoreCase) ||
+ language.Equals("mul", StringComparison.OrdinalIgnoreCase) ||
+ language.Equals("zxx", StringComparison.OrdinalIgnoreCase);
+ }
+
+ private static List BehaviorOnlyForced(IEnumerable sortedStreams, IReadOnlyList preferredLanguages)
+ {
+ return sortedStreams
+ .Where(s => s.IsForced && (MatchesPreferredLanguage(s.Language, preferredLanguages) || IsLanguageUndefined(s.Language)))
+ .OrderByDescending(s => MatchesPreferredLanguage(s.Language, preferredLanguages))
+ .ThenByDescending(s => IsLanguageUndefined(s.Language))
+ .ToList();
+ }
+
internal static int GetStreamScore(MediaStream stream, IReadOnlyList languagePreferences)
{
var index = languagePreferences.FindIndex(x => string.Equals(x, stream.Language, StringComparison.OrdinalIgnoreCase));
diff --git a/Emby.Server.Implementations/Library/MusicManager.cs b/Emby.Server.Implementations/Library/MusicManager.cs
index a69a0f33f3..28cf695007 100644
--- a/Emby.Server.Implementations/Library/MusicManager.cs
+++ b/Emby.Server.Implementations/Library/MusicManager.cs
@@ -2,9 +2,11 @@
using System;
using System.Collections.Generic;
+using System.Collections.Immutable;
using System.Linq;
-using Jellyfin.Data.Entities;
using Jellyfin.Data.Enums;
+using Jellyfin.Database.Implementations.Entities;
+using Jellyfin.Database.Implementations.Enums;
using Jellyfin.Extensions;
using MediaBrowser.Controller.Dto;
using MediaBrowser.Controller.Entities;
@@ -24,30 +26,23 @@ namespace Emby.Server.Implementations.Library
_libraryManager = libraryManager;
}
- public List GetInstantMixFromSong(Audio item, User? user, DtoOptions dtoOptions)
- {
- var list = new List
- {
- item
- };
-
- list.AddRange(GetInstantMixFromGenres(item.Genres, user, dtoOptions));
-
- return list;
- }
-
- ///
- public List GetInstantMixFromArtist(MusicArtist artist, User? user, DtoOptions dtoOptions)
- {
- return GetInstantMixFromGenres(artist.Genres, user, dtoOptions);
- }
-
- public List GetInstantMixFromAlbum(MusicAlbum item, User? user, DtoOptions dtoOptions)
+ public IReadOnlyList GetInstantMixFromSong(Audio item, User? user, DtoOptions dtoOptions)
{
return GetInstantMixFromGenres(item.Genres, user, dtoOptions);
}
- public List GetInstantMixFromFolder(Folder item, User? user, DtoOptions dtoOptions)
+ ///
+ public IReadOnlyList GetInstantMixFromArtist(MusicArtist artist, User? user, DtoOptions dtoOptions)
+ {
+ return GetInstantMixFromGenres(artist.Genres, user, dtoOptions);
+ }
+
+ public IReadOnlyList GetInstantMixFromAlbum(MusicAlbum item, User? user, DtoOptions dtoOptions)
+ {
+ return GetInstantMixFromGenres(item.Genres, user, dtoOptions);
+ }
+
+ public IReadOnlyList GetInstantMixFromFolder(Folder item, User? user, DtoOptions dtoOptions)
{
var genres = item
.GetRecursiveChildren(user, new InternalItemsQuery(user)
@@ -63,12 +58,12 @@ namespace Emby.Server.Implementations.Library
return GetInstantMixFromGenres(genres, user, dtoOptions);
}
- public List GetInstantMixFromPlaylist(Playlist item, User? user, DtoOptions dtoOptions)
+ public IReadOnlyList GetInstantMixFromPlaylist(Playlist item, User? user, DtoOptions dtoOptions)
{
return GetInstantMixFromGenres(item.Genres, user, dtoOptions);
}
- public List GetInstantMixFromGenres(IEnumerable genres, User? user, DtoOptions dtoOptions)
+ public IReadOnlyList GetInstantMixFromGenres(IEnumerable genres, User? user, DtoOptions dtoOptions)
{
var genreIds = genres.DistinctNames().Select(i =>
{
@@ -85,7 +80,7 @@ namespace Emby.Server.Implementations.Library
return GetInstantMixFromGenreIds(genreIds, user, dtoOptions);
}
- public List GetInstantMixFromGenreIds(Guid[] genreIds, User? user, DtoOptions dtoOptions)
+ public IReadOnlyList GetInstantMixFromGenreIds(Guid[] genreIds, User? user, DtoOptions dtoOptions)
{
return _libraryManager.GetItemList(new InternalItemsQuery(user)
{
@@ -97,7 +92,7 @@ namespace Emby.Server.Implementations.Library
});
}
- public List GetInstantMixFromItem(BaseItem item, User? user, DtoOptions dtoOptions)
+ public IReadOnlyList GetInstantMixFromItem(BaseItem item, User? user, DtoOptions dtoOptions)
{
if (item is MusicGenre)
{
diff --git a/Emby.Server.Implementations/Library/PathManager.cs b/Emby.Server.Implementations/Library/PathManager.cs
new file mode 100644
index 0000000000..83a6df9644
--- /dev/null
+++ b/Emby.Server.Implementations/Library/PathManager.cs
@@ -0,0 +1,73 @@
+using System;
+using System.Globalization;
+using System.IO;
+using MediaBrowser.Common.Configuration;
+using MediaBrowser.Controller.Configuration;
+using MediaBrowser.Controller.Entities;
+using MediaBrowser.Controller.IO;
+
+namespace Emby.Server.Implementations.Library;
+
+///
+/// IPathManager implementation.
+///
+public class PathManager : IPathManager
+{
+ private readonly IServerConfigurationManager _config;
+ private readonly IApplicationPaths _appPaths;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The server configuration manager.
+ /// The application paths.
+ public PathManager(
+ IServerConfigurationManager config,
+ IApplicationPaths appPaths)
+ {
+ _config = config;
+ _appPaths = appPaths;
+ }
+
+ private string SubtitleCachePath => Path.Combine(_appPaths.DataPath, "subtitles");
+
+ private string AttachmentCachePath => Path.Combine(_appPaths.DataPath, "attachments");
+
+ ///
+ public string GetAttachmentPath(string mediaSourceId, string fileName)
+ {
+ return Path.Join(GetAttachmentFolderPath(mediaSourceId), fileName);
+ }
+
+ ///
+ public string GetAttachmentFolderPath(string mediaSourceId)
+ {
+ var id = Guid.Parse(mediaSourceId).ToString("D", CultureInfo.InvariantCulture).AsSpan();
+
+ return Path.Join(AttachmentCachePath, id[..2], id);
+ }
+
+ ///
+ public string GetSubtitleFolderPath(string mediaSourceId)
+ {
+ var id = Guid.Parse(mediaSourceId).ToString("D", CultureInfo.InvariantCulture).AsSpan();
+
+ return Path.Join(SubtitleCachePath, id[..2], id);
+ }
+
+ ///
+ public string GetSubtitlePath(string mediaSourceId, int streamIndex, string extension)
+ {
+ return Path.Join(GetSubtitleFolderPath(mediaSourceId), streamIndex.ToString(CultureInfo.InvariantCulture) + extension);
+ }
+
+ ///
+ public string GetTrickplayDirectory(BaseItem item, bool saveWithMedia = false)
+ {
+ var id = item.Id.ToString("D", CultureInfo.InvariantCulture).AsSpan();
+
+ return saveWithMedia
+ ? Path.Combine(item.ContainingFolderPath, Path.ChangeExtension(item.Path, ".trickplay"))
+ : Path.Join(_config.ApplicationPaths.TrickplayPath, id[..2], id);
+ }
+}
diff --git a/Emby.Server.Implementations/Library/Resolvers/ExtraResolver.cs b/Emby.Server.Implementations/Library/Resolvers/ExtraResolver.cs
index b4791b9456..b9f9f29723 100644
--- a/Emby.Server.Implementations/Library/Resolvers/ExtraResolver.cs
+++ b/Emby.Server.Implementations/Library/Resolvers/ExtraResolver.cs
@@ -54,9 +54,9 @@ namespace Emby.Server.Implementations.Library.Resolvers
_ => _videoResolvers
};
- public bool TryGetExtraTypeForOwner(string path, VideoFileInfo ownerVideoFileInfo, [NotNullWhen(true)] out ExtraType? extraType)
+ public bool TryGetExtraTypeForOwner(string path, VideoFileInfo ownerVideoFileInfo, [NotNullWhen(true)] out ExtraType? extraType, string? libraryRoot = "")
{
- var extraResult = GetExtraInfo(path, _namingOptions);
+ var extraResult = GetExtraInfo(path, _namingOptions, libraryRoot);
if (extraResult.ExtraType is null)
{
extraType = null;
diff --git a/Emby.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs b/Emby.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs
index 4debe722b9..f1aeb1340a 100644
--- a/Emby.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs
+++ b/Emby.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs
@@ -270,11 +270,11 @@ namespace Emby.Server.Implementations.Library.Resolvers.Movies
}
var videoInfos = files
- .Select(i => VideoResolver.Resolve(i.FullName, i.IsDirectory, NamingOptions, parseName))
+ .Select(i => VideoResolver.Resolve(i.FullName, i.IsDirectory, NamingOptions, parseName, parent.ContainingFolderPath))
.Where(f => f is not null)
.ToList();
- var resolverResult = VideoListResolver.Resolve(videoInfos, NamingOptions, supportMultiEditions, parseName);
+ var resolverResult = VideoListResolver.Resolve(videoInfos, NamingOptions, supportMultiEditions, parseName, parent.ContainingFolderPath);
var result = new MultiItemResolverResult
{
diff --git a/Emby.Server.Implementations/Library/Resolvers/PlaylistResolver.cs b/Emby.Server.Implementations/Library/Resolvers/PlaylistResolver.cs
index a03c1214d6..14798dda65 100644
--- a/Emby.Server.Implementations/Library/Resolvers/PlaylistResolver.cs
+++ b/Emby.Server.Implementations/Library/Resolvers/PlaylistResolver.cs
@@ -28,7 +28,7 @@ namespace Emby.Server.Implementations.Library.Resolvers
{
if (args.IsDirectory)
{
- // It's a boxset if the path is a directory with [playlist] in its name
+ // It's a playlist if the path is a directory with [playlist] in its name
var filename = Path.GetFileName(Path.TrimEndingDirectorySeparator(args.Path));
if (string.IsNullOrEmpty(filename))
{
diff --git a/Emby.Server.Implementations/Library/Resolvers/TV/SeasonResolver.cs b/Emby.Server.Implementations/Library/Resolvers/TV/SeasonResolver.cs
index abf2d01159..6cb63a28a2 100644
--- a/Emby.Server.Implementations/Library/Resolvers/TV/SeasonResolver.cs
+++ b/Emby.Server.Implementations/Library/Resolvers/TV/SeasonResolver.cs
@@ -48,7 +48,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.TV
var path = args.Path;
- var seasonParserResult = SeasonPathParser.Parse(path, true, true);
+ var seasonParserResult = SeasonPathParser.Parse(path, series.ContainingFolderPath, true, true);
var season = new Season
{
diff --git a/Emby.Server.Implementations/Library/Resolvers/TV/SeriesResolver.cs b/Emby.Server.Implementations/Library/Resolvers/TV/SeriesResolver.cs
index fb48d7bf17..c81a0adb89 100644
--- a/Emby.Server.Implementations/Library/Resolvers/TV/SeriesResolver.cs
+++ b/Emby.Server.Implementations/Library/Resolvers/TV/SeriesResolver.cs
@@ -118,7 +118,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.TV
{
if (child.IsDirectory)
{
- if (IsSeasonFolder(child.FullName, isTvContentType))
+ if (IsSeasonFolder(child.FullName, path, isTvContentType))
{
_logger.LogDebug("{Path} is a series because of season folder {Dir}.", path, child.FullName);
return true;
@@ -155,11 +155,12 @@ namespace Emby.Server.Implementations.Library.Resolvers.TV
/// Determines whether [is season folder] [the specified path].
///
/// The path.
+ /// The parentpath.
/// if set to true [is tv content type].
/// true if [is season folder] [the specified path]; otherwise, false.
- private static bool IsSeasonFolder(string path, bool isTvContentType)
+ private static bool IsSeasonFolder(string path, string parentPath, bool isTvContentType)
{
- var seasonNumber = SeasonPathParser.Parse(path, isTvContentType, isTvContentType).SeasonNumber;
+ var seasonNumber = SeasonPathParser.Parse(path, parentPath, isTvContentType, isTvContentType).SeasonNumber;
return seasonNumber.HasValue;
}
diff --git a/Emby.Server.Implementations/Library/SearchEngine.cs b/Emby.Server.Implementations/Library/SearchEngine.cs
index 7f3f8615e2..9d81b835ce 100644
--- a/Emby.Server.Implementations/Library/SearchEngine.cs
+++ b/Emby.Server.Implementations/Library/SearchEngine.cs
@@ -3,8 +3,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
-using Jellyfin.Data.Entities;
using Jellyfin.Data.Enums;
+using Jellyfin.Database.Implementations.Entities;
+using Jellyfin.Database.Implementations.Enums;
using Jellyfin.Extensions;
using MediaBrowser.Controller.Dto;
using MediaBrowser.Controller.Entities;
@@ -171,7 +172,7 @@ namespace Emby.Server.Implementations.Library
}
};
- List mediaItems;
+ IReadOnlyList mediaItems;
if (searchQuery.IncludeItemTypes.Length == 1 && searchQuery.IncludeItemTypes[0] == BaseItemKind.MusicArtist)
{
diff --git a/Emby.Server.Implementations/Library/SplashscreenPostScanTask.cs b/Emby.Server.Implementations/Library/SplashscreenPostScanTask.cs
index 320685b1f1..71ce3b6012 100644
--- a/Emby.Server.Implementations/Library/SplashscreenPostScanTask.cs
+++ b/Emby.Server.Implementations/Library/SplashscreenPostScanTask.cs
@@ -4,13 +4,13 @@ using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Jellyfin.Data.Enums;
+using Jellyfin.Database.Implementations.Enums;
using MediaBrowser.Controller.Drawing;
using MediaBrowser.Controller.Dto;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Persistence;
using MediaBrowser.Model.Entities;
-using MediaBrowser.Model.Querying;
using Microsoft.Extensions.Logging;
namespace Emby.Server.Implementations.Library;
@@ -43,14 +43,26 @@ public class SplashscreenPostScanTask : ILibraryPostScanTask
///
public Task Run(IProgress progress, CancellationToken cancellationToken)
{
- var posters = GetItemsWithImageType(ImageType.Primary).Select(x => x.GetImages(ImageType.Primary).First().Path).ToList();
- var backdrops = GetItemsWithImageType(ImageType.Thumb).Select(x => x.GetImages(ImageType.Thumb).First().Path).ToList();
+ var posters = GetItemsWithImageType(ImageType.Primary)
+ .Select(x => x.GetImages(ImageType.Primary).FirstOrDefault()?.Path)
+ .Where(path => !string.IsNullOrEmpty(path))
+ .Select(path => path!)
+ .ToList();
+ var backdrops = GetItemsWithImageType(ImageType.Thumb)
+ .Select(x => x.GetImages(ImageType.Thumb).FirstOrDefault()?.Path)
+ .Where(path => !string.IsNullOrEmpty(path))
+ .Select(path => path!)
+ .ToList();
if (backdrops.Count == 0)
{
// Thumb images fit better because they include the title in the image but are not provided with TMDb.
// Using backdrops as a fallback to generate an image at all
_logger.LogDebug("No thumb images found. Using backdrops to generate splashscreen");
- backdrops = GetItemsWithImageType(ImageType.Backdrop).Select(x => x.GetImages(ImageType.Backdrop).First().Path).ToList();
+ backdrops = GetItemsWithImageType(ImageType.Backdrop)
+ .Select(x => x.GetImages(ImageType.Backdrop).FirstOrDefault()?.Path)
+ .Where(path => !string.IsNullOrEmpty(path))
+ .Select(path => path!)
+ .ToList();
}
_imageEncoder.CreateSplashscreen(posters, backdrops);
@@ -65,15 +77,15 @@ public class SplashscreenPostScanTask : ILibraryPostScanTask
CollapseBoxSetItems = false,
Recursive = true,
DtoOptions = new DtoOptions(false),
- ImageTypes = new[] { imageType },
+ ImageTypes = [imageType],
Limit = 30,
// TODO max parental rating configurable
- MaxParentalRating = 10,
- OrderBy = new[]
- {
+ MaxParentalRating = new(10, null),
+ OrderBy =
+ [
(ItemSortBy.Random, SortOrder.Ascending)
- },
- IncludeItemTypes = new[] { BaseItemKind.Movie, BaseItemKind.Series }
+ ],
+ IncludeItemTypes = [BaseItemKind.Movie, BaseItemKind.Series]
});
}
}
diff --git a/Emby.Server.Implementations/Library/UserDataManager.cs b/Emby.Server.Implementations/Library/UserDataManager.cs
index 62d22b23ff..be1d96bf0b 100644
--- a/Emby.Server.Implementations/Library/UserDataManager.cs
+++ b/Emby.Server.Implementations/Library/UserDataManager.cs
@@ -1,17 +1,20 @@
+#pragma warning disable RS0030 // Do not use banned APIs
+
using System;
-using System.Collections.Concurrent;
using System.Collections.Generic;
-using System.Diagnostics;
using System.Globalization;
+using System.Linq;
using System.Threading;
-using Jellyfin.Data.Entities;
+using BitFaster.Caching.Lru;
+using Jellyfin.Database.Implementations;
+using Jellyfin.Database.Implementations.Entities;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Dto;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library;
-using MediaBrowser.Controller.Persistence;
using MediaBrowser.Model.Dto;
using MediaBrowser.Model.Entities;
+using Microsoft.EntityFrameworkCore;
using AudioBook = MediaBrowser.Controller.Entities.AudioBook;
using Book = MediaBrowser.Controller.Entities.Book;
@@ -22,27 +25,22 @@ namespace Emby.Server.Implementations.Library
///
public class UserDataManager : IUserDataManager
{
- private readonly ConcurrentDictionary _userData =
- new ConcurrentDictionary(StringComparer.OrdinalIgnoreCase);
-
private readonly IServerConfigurationManager _config;
- private readonly IUserManager _userManager;
- private readonly IUserDataRepository _repository;
+ private readonly IDbContextFactory _repository;
+ private readonly FastConcurrentLru _cache;
///
/// Initializes a new instance of the class.
///
/// Instance of the interface.
- /// Instance of the interface.
- /// Instance of the interface.
+ /// Instance of the interface.
public UserDataManager(
IServerConfigurationManager config,
- IUserManager userManager,
- IUserDataRepository repository)
+ IDbContextFactory repository)
{
_config = config;
- _userManager = userManager;
_repository = repository;
+ _cache = new FastConcurrentLru(Environment.ProcessorCount, _config.Configuration.CacheSize, StringComparer.OrdinalIgnoreCase);
}
///
@@ -59,15 +57,29 @@ namespace Emby.Server.Implementations.Library
var keys = item.GetUserDataKeys();
- var userId = user.InternalId;
+ using var dbContext = _repository.CreateDbContext();
+ using var transaction = dbContext.Database.BeginTransaction();
foreach (var key in keys)
{
- _repository.SaveUserData(userId, key, userData, cancellationToken);
+ userData.Key = key;
+ var userDataEntry = Map(userData, user.Id, item.Id);
+ if (dbContext.UserData.Any(f => f.ItemId == userDataEntry.ItemId && f.UserId == userDataEntry.UserId && f.CustomDataKey == userDataEntry.CustomDataKey))
+ {
+ dbContext.UserData.Attach(userDataEntry).State = EntityState.Modified;
+ }
+ else
+ {
+ dbContext.UserData.Add(userDataEntry);
+ }
}
+ dbContext.SaveChanges();
+ transaction.Commit();
+
+ var userId = user.InternalId;
var cacheKey = GetCacheKey(userId, item.Id);
- _userData.AddOrUpdate(cacheKey, userData, (_, _) => userData);
+ _cache.AddOrUpdate(cacheKey, userData);
UserDataSaved?.Invoke(this, new UserDataSaveEventArgs
{
@@ -84,10 +96,9 @@ namespace Emby.Server.Implementations.Library
{
ArgumentNullException.ThrowIfNull(user);
ArgumentNullException.ThrowIfNull(item);
- ArgumentNullException.ThrowIfNull(reason);
ArgumentNullException.ThrowIfNull(userDataDto);
- var userData = GetUserData(user, item);
+ var userData = GetUserData(user, item) ?? throw new InvalidOperationException("UserData should not be null.");
if (userDataDto.PlaybackPositionTicks.HasValue)
{
@@ -127,33 +138,91 @@ namespace Emby.Server.Implementations.Library
SaveUserData(user, item, userData, reason, CancellationToken.None);
}
- private UserItemData GetUserData(User user, Guid itemId, List keys)
+ private UserData Map(UserItemData dto, Guid userId, Guid itemId)
{
- var userId = user.InternalId;
-
- var cacheKey = GetCacheKey(userId, itemId);
-
- return _userData.GetOrAdd(cacheKey, _ => GetUserDataInternal(userId, keys));
+ return new UserData()
+ {
+ ItemId = itemId,
+ CustomDataKey = dto.Key,
+ Item = null,
+ User = null,
+ AudioStreamIndex = dto.AudioStreamIndex,
+ IsFavorite = dto.IsFavorite,
+ LastPlayedDate = dto.LastPlayedDate,
+ Likes = dto.Likes,
+ PlaybackPositionTicks = dto.PlaybackPositionTicks,
+ PlayCount = dto.PlayCount,
+ Played = dto.Played,
+ Rating = dto.Rating,
+ UserId = userId,
+ SubtitleStreamIndex = dto.SubtitleStreamIndex,
+ };
}
- private UserItemData GetUserDataInternal(long internalUserId, List keys)
+ private UserItemData Map(UserData dto)
{
- var userData = _repository.GetUserData(internalUserId, keys);
-
- if (userData is not null)
+ return new UserItemData()
{
- return userData;
+ Key = dto.CustomDataKey!,
+ AudioStreamIndex = dto.AudioStreamIndex,
+ IsFavorite = dto.IsFavorite,
+ LastPlayedDate = dto.LastPlayedDate,
+ Likes = dto.Likes,
+ PlaybackPositionTicks = dto.PlaybackPositionTicks,
+ PlayCount = dto.PlayCount,
+ Played = dto.Played,
+ Rating = dto.Rating,
+ SubtitleStreamIndex = dto.SubtitleStreamIndex,
+ };
+ }
+
+ private UserItemData? GetUserData(User user, Guid itemId, List keys)
+ {
+ var cacheKey = GetCacheKey(user.InternalId, itemId);
+
+ if (_cache.TryGet(cacheKey, out var data))
+ {
+ return data;
}
- if (keys.Count > 0)
+ data = GetUserDataInternal(user.Id, itemId, keys);
+
+ if (data is null)
{
- return new UserItemData
+ return new UserItemData()
{
- Key = keys[0]
+ Key = keys[0],
};
}
- throw new UnreachableException();
+ return _cache.GetOrAdd(cacheKey, _ => data);
+ }
+
+ private UserItemData? GetUserDataInternal(Guid userId, Guid itemId, List keys)
+ {
+ if (keys.Count == 0)
+ {
+ return null;
+ }
+
+ using var context = _repository.CreateDbContext();
+ var userData = context.UserData.AsNoTracking().Where(e => e.ItemId == itemId && keys.Contains(e.CustomDataKey) && e.UserId.Equals(userId)).ToArray();
+
+ if (userData.Length > 0)
+ {
+ var directDataReference = userData.FirstOrDefault(e => e.CustomDataKey == itemId.ToString("N"));
+ if (directDataReference is not null)
+ {
+ return Map(directDataReference);
+ }
+
+ return Map(userData.First());
+ }
+
+ return new UserItemData
+ {
+ Key = keys.Last()!
+ };
}
///
@@ -166,20 +235,25 @@ namespace Emby.Server.Implementations.Library
}
///
- public UserItemData GetUserData(User user, BaseItem item)
+ public UserItemData? GetUserData(User user, BaseItem item)
{
return GetUserData(user, item.Id, item.GetUserDataKeys());
}
///
- public UserItemDataDto GetUserDataDto(BaseItem item, User user)
+ public UserItemDataDto? GetUserDataDto(BaseItem item, User user)
=> GetUserDataDto(item, null, user, new DtoOptions());
///
- public UserItemDataDto GetUserDataDto(BaseItem item, BaseItemDto? itemDto, User user, DtoOptions options)
+ public UserItemDataDto? GetUserDataDto(BaseItem item, BaseItemDto? itemDto, User user, DtoOptions options)
{
var userData = GetUserData(user, item);
- var dto = GetUserItemDataDto(userData);
+ if (userData is null)
+ {
+ return null;
+ }
+
+ var dto = GetUserItemDataDto(userData, item.Id);
item.FillUserDataDtoValues(dto, userData, itemDto, user, options);
return dto;
@@ -189,9 +263,10 @@ namespace Emby.Server.Implementations.Library
/// Converts a UserItemData to a DTOUserItemData.
///
/// The data.
+ /// The reference key to an Item.
/// DtoUserItemData.
/// is null.
- private UserItemDataDto GetUserItemDataDto(UserItemData data)
+ private UserItemDataDto GetUserItemDataDto(UserItemData data, Guid itemId)
{
ArgumentNullException.ThrowIfNull(data);
@@ -204,6 +279,7 @@ namespace Emby.Server.Implementations.Library
Rating = data.Rating,
Played = data.Played,
LastPlayedDate = data.LastPlayedDate,
+ ItemId = itemId,
Key = data.Key
};
}
diff --git a/Emby.Server.Implementations/Library/UserViewManager.cs b/Emby.Server.Implementations/Library/UserViewManager.cs
index e9cf47d462..87214c273b 100644
--- a/Emby.Server.Implementations/Library/UserViewManager.cs
+++ b/Emby.Server.Implementations/Library/UserViewManager.cs
@@ -6,8 +6,10 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
-using Jellyfin.Data.Entities;
+using Jellyfin.Data;
using Jellyfin.Data.Enums;
+using Jellyfin.Database.Implementations.Entities;
+using Jellyfin.Database.Implementations.Enums;
using Jellyfin.Extensions;
using MediaBrowser.Controller.Channels;
using MediaBrowser.Controller.Configuration;
@@ -308,39 +310,40 @@ namespace Emby.Server.Implementations.Library
}
}
- var mediaTypes = new List();
+ MediaType[] mediaTypes = [];
if (includeItemTypes.Length == 0)
{
+ HashSet tmpMediaTypes = [];
foreach (var parent in parents.OfType())
{
switch (parent.CollectionType)
{
case CollectionType.books:
- mediaTypes.Add(MediaType.Book);
- mediaTypes.Add(MediaType.Audio);
+ tmpMediaTypes.Add(MediaType.Book);
+ tmpMediaTypes.Add(MediaType.Audio);
break;
case CollectionType.music:
- mediaTypes.Add(MediaType.Audio);
+ tmpMediaTypes.Add(MediaType.Audio);
break;
case CollectionType.photos:
- mediaTypes.Add(MediaType.Photo);
- mediaTypes.Add(MediaType.Video);
+ tmpMediaTypes.Add(MediaType.Photo);
+ tmpMediaTypes.Add(MediaType.Video);
break;
case CollectionType.homevideos:
- mediaTypes.Add(MediaType.Photo);
- mediaTypes.Add(MediaType.Video);
+ tmpMediaTypes.Add(MediaType.Photo);
+ tmpMediaTypes.Add(MediaType.Video);
break;
default:
- mediaTypes.Add(MediaType.Video);
+ tmpMediaTypes.Add(MediaType.Video);
break;
}
}
- mediaTypes = mediaTypes.Distinct().ToList();
+ mediaTypes = tmpMediaTypes.ToArray();
}
- var excludeItemTypes = includeItemTypes.Length == 0 && mediaTypes.Count == 0
+ var excludeItemTypes = includeItemTypes.Length == 0 && mediaTypes.Length == 0
? new[]
{
BaseItemKind.Person,
@@ -366,12 +369,22 @@ namespace Emby.Server.Implementations.Library
Limit = limit * 5,
IsPlayed = isPlayed,
DtoOptions = options,
- MediaTypes = mediaTypes.ToArray()
+ MediaTypes = mediaTypes
};
- if (parents.Count == 0)
+ if (request.GroupItems)
{
- return _libraryManager.GetItemList(query, false);
+ if (parents.OfType().All(i => i.CollectionType == CollectionType.tvshows))
+ {
+ query.Limit = limit;
+ return _libraryManager.GetLatestItemList(query, parents, CollectionType.tvshows);
+ }
+
+ if (parents.OfType().All(i => i.CollectionType == CollectionType.music))
+ {
+ query.Limit = limit;
+ return _libraryManager.GetLatestItemList(query, parents, CollectionType.music);
+ }
}
return _libraryManager.GetItemList(query, parents);
diff --git a/Emby.Server.Implementations/Library/Validators/CollectionPostScanTask.cs b/Emby.Server.Implementations/Library/Validators/CollectionPostScanTask.cs
index 89f64ee4f0..337b1afdd4 100644
--- a/Emby.Server.Implementations/Library/Validators/CollectionPostScanTask.cs
+++ b/Emby.Server.Implementations/Library/Validators/CollectionPostScanTask.cs
@@ -4,6 +4,7 @@ using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Jellyfin.Data.Enums;
+using Jellyfin.Database.Implementations.Enums;
using MediaBrowser.Controller.Collections;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Movies;
diff --git a/Emby.Server.Implementations/Library/Validators/GenresValidator.cs b/Emby.Server.Implementations/Library/Validators/GenresValidator.cs
index e59c62e239..364770fcdc 100644
--- a/Emby.Server.Implementations/Library/Validators/GenresValidator.cs
+++ b/Emby.Server.Implementations/Library/Validators/GenresValidator.cs
@@ -1,6 +1,9 @@
using System;
+using System.Globalization;
using System.Threading;
using System.Threading.Tasks;
+using Jellyfin.Data.Enums;
+using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Persistence;
using Microsoft.Extensions.Logging;
@@ -75,6 +78,26 @@ namespace Emby.Server.Implementations.Library.Validators
progress.Report(percent);
}
+ var deadEntities = _libraryManager.GetItemList(new InternalItemsQuery
+ {
+ IncludeItemTypes = [BaseItemKind.Genre, BaseItemKind.MusicGenre],
+ IsDeadGenre = true,
+ IsLocked = false
+ });
+
+ foreach (var item in deadEntities)
+ {
+ _logger.LogInformation("Deleting dead {ItemType} {ItemId} {ItemName}", item.GetType().Name, item.Id.ToString("N", CultureInfo.InvariantCulture), item.Name);
+
+ _libraryManager.DeleteItem(
+ item,
+ new DeleteOptions
+ {
+ DeleteFileLocation = false
+ },
+ false);
+ }
+
progress.Report(100);
}
}
diff --git a/Emby.Server.Implementations/Localization/Core/af.json b/Emby.Server.Implementations/Localization/Core/af.json
index e89ede10b4..1dce589234 100644
--- a/Emby.Server.Implementations/Localization/Core/af.json
+++ b/Emby.Server.Implementations/Localization/Core/af.json
@@ -129,5 +129,11 @@
"TaskAudioNormalizationDescription": "Skandeer lêers vir oudio-normaliseringsdata.",
"TaskAudioNormalization": "Odio Normalisering",
"TaskCleanCollectionsAndPlaylists": "Maak versamelings en snitlyste skoon",
- "TaskCleanCollectionsAndPlaylistsDescription": "Verwyder items uit versamelings en snitlyste wat nie meer bestaan nie."
+ "TaskCleanCollectionsAndPlaylistsDescription": "Verwyder items uit versamelings en snitlyste wat nie meer bestaan nie.",
+ "TaskDownloadMissingLyrics": "Laai tekorte lirieke af",
+ "TaskDownloadMissingLyricsDescription": "Laai lirieke af vir liedjies",
+ "TaskExtractMediaSegments": "Media Segment Skandeer",
+ "TaskExtractMediaSegmentsDescription": "Onttrek of verkry mediasegmente van MediaSegment-geaktiveerde inproppe.",
+ "TaskMoveTrickplayImages": "Migreer Trickplay Beeldligging",
+ "TaskMoveTrickplayImagesDescription": "Skuif ontstaande trickplay lêers volgens die biblioteekinstellings."
}
diff --git a/Emby.Server.Implementations/Localization/Core/ar.json b/Emby.Server.Implementations/Localization/Core/ar.json
index bd45b0b968..2d29eb5bf7 100644
--- a/Emby.Server.Implementations/Localization/Core/ar.json
+++ b/Emby.Server.Implementations/Localization/Core/ar.json
@@ -16,7 +16,7 @@
"Folders": "المجلدات",
"Genres": "التصنيفات",
"HeaderAlbumArtists": "فناني الألبوم",
- "HeaderContinueWatching": "استئناف المشاهدة",
+ "HeaderContinueWatching": "إستئناف المشاهدة",
"HeaderFavoriteAlbums": "الألبومات المفضلة",
"HeaderFavoriteArtists": "الفنانون المفضلون",
"HeaderFavoriteEpisodes": "الحلقات المفضلة",
@@ -31,7 +31,7 @@
"ItemRemovedWithName": "أُزيل {0} من المكتبة",
"LabelIpAddressValue": "عنوان الآي بي: {0}",
"LabelRunningTimeValue": "مدة التشغيل: {0}",
- "Latest": "أحدث",
+ "Latest": "الأحدث",
"MessageApplicationUpdated": "حُدث خادم Jellyfin",
"MessageApplicationUpdatedTo": "حُدث خادم Jellyfin إلى {0}",
"MessageNamedServerConfigurationUpdatedWithValue": "حُدثت إعدادات الخادم في قسم {0}",
@@ -52,7 +52,7 @@
"NotificationOptionInstallationFailed": "فشل في التثبيت",
"NotificationOptionNewLibraryContent": "أُضيف محتوى جديدا",
"NotificationOptionPluginError": "فشل في الملحق",
- "NotificationOptionPluginInstalled": "ثُبتت المكونات الإضافية",
+ "NotificationOptionPluginInstalled": "ثُبتت الملحق",
"NotificationOptionPluginUninstalled": "تمت إزالة الملحق",
"NotificationOptionPluginUpdateInstalled": "تم تثبيت تحديثات الملحق",
"NotificationOptionServerRestartRequired": "يجب إعادة تشغيل الخادم",
@@ -90,10 +90,10 @@
"UserStartedPlayingItemWithValues": "قام {0} ببدء تشغيل {1} على {2}",
"UserStoppedPlayingItemWithValues": "قام {0} بإيقاف تشغيل {1} على {2}",
"ValueHasBeenAddedToLibrary": "تمت اضافت {0} إلى مكتبة الوسائط",
- "ValueSpecialEpisodeName": "حلقه خاصه - {0}",
+ "ValueSpecialEpisodeName": "حلقة خاصه - {0}",
"VersionNumber": "الإصدار {0}",
"TaskCleanCacheDescription": "يحذف الملفات المؤقتة التي لم يعد النظام بحاجة إليها.",
- "TaskCleanCache": "احذف ما بمجلد الملفات المؤقتة",
+ "TaskCleanCache": "حذف الملفات المؤقتة",
"TasksChannelsCategory": "قنوات الإنترنت",
"TasksLibraryCategory": "مكتبة",
"TasksMaintenanceCategory": "صيانة",
@@ -129,7 +129,12 @@
"TaskRefreshTrickplayImagesDescription": "يُنشئ معاينات Trickplay لمقاطع الفيديو في المكتبات المُمكّنة.",
"TaskCleanCollectionsAndPlaylists": "حذف المجموعات وقوائم التشغيل",
"TaskCleanCollectionsAndPlaylistsDescription": "حذف عناصر من المجموعات وقوائم التشغيل التي لم تعد موجودة.",
- "TaskAudioNormalization": "تطبيع الصوت",
+ "TaskAudioNormalization": "تسوية الصوت",
"TaskAudioNormalizationDescription": "مسح الملفات لتطبيع بيانات الصوت.",
- "TaskDownloadMissingLyrics": "تنزيل عبارات القصيدة"
+ "TaskDownloadMissingLyrics": "تنزيل عبارات القصيدة",
+ "TaskDownloadMissingLyricsDescription": "كلمات",
+ "TaskExtractMediaSegments": "فحص مقاطع الوسائط",
+ "TaskExtractMediaSegmentsDescription": "يستخرج مقاطع وسائط من إضافات MediaSegment المُفعّلة.",
+ "TaskMoveTrickplayImages": "تغيير مكان صور المعاينة السريعة",
+ "TaskMoveTrickplayImagesDescription": "تُنقل ملفات التشغيل السريع الحالية بناءً على إعدادات المكتبة."
}
diff --git a/Emby.Server.Implementations/Localization/Core/be.json b/Emby.Server.Implementations/Localization/Core/be.json
index 97aa0ca58c..d5da04fb9f 100644
--- a/Emby.Server.Implementations/Localization/Core/be.json
+++ b/Emby.Server.Implementations/Localization/Core/be.json
@@ -1,6 +1,6 @@
{
"Sync": "Сінхранізаваць",
- "Playlists": "Плэйлісты",
+ "Playlists": "Спісы прайгравання",
"Latest": "Апошні",
"LabelIpAddressValue": "IP-адрас: {0}",
"ItemAddedWithName": "{0} быў дададзены ў бібліятэку",
@@ -16,7 +16,7 @@
"Collections": "Калекцыі",
"Default": "Па змаўчанні",
"FailedLoginAttemptWithUserName": "Няўдалая спроба ўваходу з {0}",
- "Folders": "Папкі",
+ "Folders": "Тэчкі",
"Favorites": "Абранае",
"External": "Знешні",
"Genres": "Жанры",
diff --git a/Emby.Server.Implementations/Localization/Core/bg-BG.json b/Emby.Server.Implementations/Localization/Core/bg-BG.json
index 4f95b48803..72f5757531 100644
--- a/Emby.Server.Implementations/Localization/Core/bg-BG.json
+++ b/Emby.Server.Implementations/Localization/Core/bg-BG.json
@@ -121,7 +121,7 @@
"TaskCleanActivityLog": "Изчисти дневника с активност",
"TaskOptimizeDatabaseDescription": "Прави базата данни по-компактна и освобождава място. Пускането на тази задача след сканиране на библиотеката или правене на други промени, свързани с модификации на базата данни, може да подобри производителността.",
"TaskOptimizeDatabase": "Оптимизирай базата данни",
- "TaskKeyframeExtractorDescription": "Извличат се ключови кадри от видеофайловете ,за да се създаде по точен ХЛС списък . Задачата може да отнеме много време.",
+ "TaskKeyframeExtractorDescription": "Извличат се ключови кадри от видеофайловете ,за да се създаде по точен HLS списък . Задачата може да отнеме много време.",
"TaskKeyframeExtractor": "Извличане на ключови кадри",
"External": "Външен",
"HearingImpaired": "Увреден слух",
@@ -129,8 +129,12 @@
"TaskRefreshTrickplayImagesDescription": "Създава прегледи на Trickplay за видеа в активирани библиотеки.",
"TaskDownloadMissingLyrics": "Свали липсващи текстове",
"TaskDownloadMissingLyricsDescription": "Свали текстове за песни",
- "TaskCleanCollectionsAndPlaylists": "Изчисти колекциите и плейлистовете",
+ "TaskCleanCollectionsAndPlaylists": "Изчисти колекциите и плейлистите",
"TaskCleanCollectionsAndPlaylistsDescription": "Премахни несъществуващи файлове в колекциите и плейлистите.",
"TaskAudioNormalization": "Нормализиране на звука",
- "TaskAudioNormalizationDescription": "Сканирай файловете за нормализация на звука."
+ "TaskAudioNormalizationDescription": "Сканирай файловете за нормализация на звука.",
+ "TaskExtractMediaSegmentsDescription": "Изважда медиини сегменти от MediaSegment плъгини.",
+ "TaskMoveTrickplayImages": "Мигриране на Локацията за Trickplay изображения",
+ "TaskMoveTrickplayImagesDescription": "Премества съществуващите trickplay изображения спрямо настройките на библиотеката.",
+ "TaskExtractMediaSegments": "Сканиране за сегменти"
}
diff --git a/Emby.Server.Implementations/Localization/Core/bn.json b/Emby.Server.Implementations/Localization/Core/bn.json
index 4724bba3b1..268a141ff1 100644
--- a/Emby.Server.Implementations/Localization/Core/bn.json
+++ b/Emby.Server.Implementations/Localization/Core/bn.json
@@ -125,5 +125,11 @@
"TaskKeyframeExtractor": "কি-ফ্রেম নিষ্কাশক",
"TaskKeyframeExtractorDescription": "ভিডিয়ো থেকে কি-ফ্রেম নিষ্কাশনের মাধ্যমে অধিকতর সঠিক HLS প্লে লিস্ট তৈরী করে। এই প্রক্রিয়া দীর্ঘ সময় ধরে চলতে পারে।",
"TaskRefreshTrickplayImages": "ট্রিকপ্লে ইমেজ তৈরি করুন",
- "TaskRefreshTrickplayImagesDescription": "সক্ষম লাইব্রেরিতে ভিডিওর জন্য ট্রিকপ্লে প্রিভিউ তৈরি করে।"
+ "TaskRefreshTrickplayImagesDescription": "সক্ষম লাইব্রেরিতে ভিডিওর জন্য ট্রিকপ্লে প্রিভিউ তৈরি করে।",
+ "TaskDownloadMissingLyricsDescription": "গানের লিরিক্স ডাউনলোড করে",
+ "TaskCleanCollectionsAndPlaylists": "সংগ্রহ এবং প্লেলিস্ট পরিষ্কার করুন",
+ "TaskCleanCollectionsAndPlaylistsDescription": "সংগ্রহ এবং প্লেলিস্ট থেকে আইটেমগুলি সরিয়ে দেয় যা আর বিদ্যমান নেই।",
+ "TaskExtractMediaSegments": "মিডিয়া সেগমেন্ট স্ক্যান",
+ "TaskExtractMediaSegmentsDescription": "MediaSegment সক্ষম প্লাগইনগুলি থেকে মিডিয়া সেগমেন্টগুলি বের করে বা প্রাপ্ত করে।",
+ "TaskDownloadMissingLyrics": "অনুপস্থিত গান ডাউনলোড করুন"
}
diff --git a/Emby.Server.Implementations/Localization/Core/ca.json b/Emby.Server.Implementations/Localization/Core/ca.json
index 6b3b78fa12..6cce0e0198 100644
--- a/Emby.Server.Implementations/Localization/Core/ca.json
+++ b/Emby.Server.Implementations/Localization/Core/ca.json
@@ -16,7 +16,7 @@
"Folders": "Carpetes",
"Genres": "Gèneres",
"HeaderAlbumArtists": "Artistes de l'àlbum",
- "HeaderContinueWatching": "Continuar veient",
+ "HeaderContinueWatching": "Continua veient",
"HeaderFavoriteAlbums": "Àlbums preferits",
"HeaderFavoriteArtists": "Artistes preferits",
"HeaderFavoriteEpisodes": "Episodis preferits",
@@ -24,13 +24,13 @@
"HeaderFavoriteSongs": "Cançons preferides",
"HeaderLiveTV": "TV en directe",
"HeaderNextUp": "A continuació",
- "HeaderRecordingGroups": "Grups d'enregistrament",
+ "HeaderRecordingGroups": "Grups Musicals",
"HomeVideos": "Vídeos domèstics",
- "Inherit": "Hereta",
- "ItemAddedWithName": "{0} ha sigut afegit a la biblioteca",
- "ItemRemovedWithName": "{0} ha sigut eliminat de la biblioteca",
+ "Inherit": "Heretat",
+ "ItemAddedWithName": "{0} s'ha afegit a la biblioteca",
+ "ItemRemovedWithName": "{0} s'ha eliminat de la biblioteca",
"LabelIpAddressValue": "Adreça IP: {0}",
- "LabelRunningTimeValue": "Temps en funcionament: {0}",
+ "LabelRunningTimeValue": "Temps en marxa: {0}",
"Latest": "Darrers",
"MessageApplicationUpdated": "El servidor de Jellyfin ha estat actualitzat",
"MessageApplicationUpdatedTo": "El servidor de Jellyfin ha estat actualitzat a {0}",
@@ -44,8 +44,8 @@
"NameSeasonNumber": "Temporada {0}",
"NameSeasonUnknown": "Temporada desconeguda",
"NewVersionIsAvailable": "Una nova versió del servidor de Jellyfin està disponible per a descarregar.",
- "NotificationOptionApplicationUpdateAvailable": "Actualització de l'aplicació disponible",
- "NotificationOptionApplicationUpdateInstalled": "Actualització de l'aplicació instal·lada",
+ "NotificationOptionApplicationUpdateAvailable": "Actualització de l'aplicatiu disponible",
+ "NotificationOptionApplicationUpdateInstalled": "Actualització de l'aplicatiu instal·lada",
"NotificationOptionAudioPlayback": "Reproducció d'àudio iniciada",
"NotificationOptionAudioPlaybackStopped": "Reproducció d'àudio aturada",
"NotificationOptionCameraImageUploaded": "Imatge de càmera pujada",
@@ -54,8 +54,8 @@
"NotificationOptionPluginError": "Un complement ha fallat",
"NotificationOptionPluginInstalled": "Complement instal·lat",
"NotificationOptionPluginUninstalled": "Complement desinstal·lat",
- "NotificationOptionPluginUpdateInstalled": "Actualització de complement instal·lada",
- "NotificationOptionServerRestartRequired": "Reinici del servidor requerit",
+ "NotificationOptionPluginUpdateInstalled": "Actualització del complement instal·lada",
+ "NotificationOptionServerRestartRequired": "El servidor s'ha de reiniciar",
"NotificationOptionTaskFailed": "Tasca programada fallida",
"NotificationOptionUserLockedOut": "Usuari expulsat",
"NotificationOptionVideoPlayback": "Reproducció de vídeo iniciada",
@@ -64,15 +64,15 @@
"Playlists": "Llistes de reproducció",
"Plugin": "Complement",
"PluginInstalledWithName": "{0} ha estat instal·lat",
- "PluginUninstalledWithName": "{0} ha estat desinstal·lat",
- "PluginUpdatedWithName": "{0} ha estat actualitzat",
+ "PluginUninstalledWithName": "S'ha instalat {0}",
+ "PluginUpdatedWithName": "S'ha actualitzat {0}",
"ProviderValue": "Proveïdor: {0}",
"ScheduledTaskFailedWithName": "{0} ha fallat",
- "ScheduledTaskStartedWithName": "{0} s'ha iniciat",
- "ServerNameNeedsToBeRestarted": "{0} necessita ser reiniciat",
+ "ScheduledTaskStartedWithName": "S'ha iniciat {0}",
+ "ServerNameNeedsToBeRestarted": "S'ha de reiniciar {0}",
"Shows": "Sèries",
"Songs": "Cançons",
- "StartupEmbyServerIsLoading": "El servidor de Jellyfin s'està carregant. Proveu-ho altre cop aviat.",
+ "StartupEmbyServerIsLoading": "El servidor de Jellyfin s'està carregant. Proveu de nou en una estona.",
"SubtitleDownloadFailureForItem": "Subtitles failed to download for {0}",
"SubtitleDownloadFailureFromForItem": "Els subtítols per a {1} no s'han pogut baixar de {0}",
"Sync": "Sincronitzar",
@@ -80,41 +80,41 @@
"TvShows": "Sèries de TV",
"User": "Usuari",
"UserCreatedWithName": "S'ha creat l'usuari {0}",
- "UserDeletedWithName": "L'usuari {0} ha estat eliminat",
+ "UserDeletedWithName": "S'ha eliminat l'usuari {0}",
"UserDownloadingItemWithValues": "{0} està descarregant {1}",
- "UserLockedOutWithName": "L'usuari {0} ha sigut expulsat",
+ "UserLockedOutWithName": "S'ha expulsat a l'usuari {0}",
"UserOfflineFromDevice": "{0} s'ha desconnectat de {1}",
"UserOnlineFromDevice": "{0} està connectat des de {1}",
- "UserPasswordChangedWithName": "La contrasenya ha estat canviada per a l'usuari {0}",
+ "UserPasswordChangedWithName": "S'ha canviat la contrasenya per a l'usuari {0}",
"UserPolicyUpdatedWithName": "La política d'usuari s'ha actualitzat per a {0}",
- "UserStartedPlayingItemWithValues": "{0} ha començat a reproduir {1}",
- "UserStoppedPlayingItemWithValues": "{0} ha parat de reproduir {1}",
- "ValueHasBeenAddedToLibrary": "{0} ha sigut afegit a la teva biblioteca",
+ "UserStartedPlayingItemWithValues": "{0} ha començat a reproduir {1} a {2}",
+ "UserStoppedPlayingItemWithValues": "{0} ha parat de reproduir {1} a {2}",
+ "ValueHasBeenAddedToLibrary": "S'ha afegit {0} a la teva biblioteca",
"ValueSpecialEpisodeName": "Especial - {0}",
"VersionNumber": "Versió {0}",
"TaskDownloadMissingSubtitlesDescription": "Cerca a internet els subtítols que faltin a partir de la configuració de metadades.",
"TaskDownloadMissingSubtitles": "Descarrega els subtítols que faltin",
- "TaskRefreshChannelsDescription": "Actualitza la informació dels canals d'internet.",
+ "TaskRefreshChannelsDescription": "Actualitza la informació dels canals per internet.",
"TaskRefreshChannels": "Actualitza els canals",
"TaskCleanTranscodeDescription": "Elimina els arxius de transcodificacions que tinguin més d'un dia.",
"TaskCleanTranscode": "Neteja les transcodificacions",
- "TaskUpdatePluginsDescription": "Actualitza els connectors que estan configurats per a actualitzar-se automàticament.",
- "TaskUpdatePlugins": "Actualitza els connectors",
- "TaskRefreshPeopleDescription": "Actualitza les metadades dels actors i directors de la teva mediateca.",
+ "TaskUpdatePluginsDescription": "Actualitza els complements que estan configurats per a actualitzar-se automàticament.",
+ "TaskUpdatePlugins": "Actualitza els complements",
+ "TaskRefreshPeopleDescription": "Actualitza les metadades dels actors i directors de la teva biblioteca de mitjans.",
"TaskRefreshPeople": "Actualitza les persones",
"TaskCleanLogsDescription": "Esborra els logs que tinguin més de {0} dies.",
"TaskCleanLogs": "Neteja els registres",
- "TaskRefreshLibraryDescription": "Escaneja la mediateca buscant fitxers nous i refresca les metadades.",
+ "TaskRefreshLibraryDescription": "Escaneja la biblioteca de mitjans buscant fitxers nous i refresca les metadades.",
"TaskRefreshLibrary": "Escaneja la biblioteca de mitjans",
"TaskRefreshChapterImagesDescription": "Crea les miniatures dels vídeos que tinguin capítols.",
"TaskRefreshChapterImages": "Extreure les imatges dels capítols",
- "TaskCleanCacheDescription": "Elimina els arxius temporals que ja no són necessaris per al servidor.",
- "TaskCleanCache": "Elimina arxius temporals",
- "TasksChannelsCategory": "Canals d'internet",
- "TasksApplicationCategory": "Aplicació",
+ "TaskCleanCacheDescription": "Elimina la memòria cau no necessària per al servidor.",
+ "TaskCleanCache": "Elimina la memòria cau",
+ "TasksChannelsCategory": "Canals per internet",
+ "TasksApplicationCategory": "Aplicatiu",
"TasksLibraryCategory": "Biblioteca",
"TasksMaintenanceCategory": "Manteniment",
- "TaskCleanActivityLogDescription": "Eliminat entrades del registre d'activitats mes antigues que l'antiguitat configurada.",
+ "TaskCleanActivityLogDescription": "Eliminades les entrades del registre d'activitats més antigues que l'antiguitat configurada.",
"TaskCleanActivityLog": "Buidar el registre d'activitat",
"Undefined": "Indefinit",
"Forced": "Forçat",
@@ -128,9 +128,13 @@
"TaskRefreshTrickplayImages": "Generar miniatures de línia de temps",
"TaskRefreshTrickplayImagesDescription": "Crear miniatures de línia de temps per vídeos en les biblioteques habilitades.",
"TaskCleanCollectionsAndPlaylistsDescription": "Esborra elements de col·leccions i llistes de reproducció que ja no existeixen.",
- "TaskCleanCollectionsAndPlaylists": "Neteja col·leccions i llistes de reproducció",
- "TaskAudioNormalization": "Normalització d'Àudio",
- "TaskAudioNormalizationDescription": "Escaneja arxius per dades de normalització d'àudio.",
- "TaskDownloadMissingLyricsDescription": "Baixar lletres de les cançons",
- "TaskDownloadMissingLyrics": "Baixar lletres que falten"
+ "TaskCleanCollectionsAndPlaylists": "Neteja les col·leccions i llistes de reproducció",
+ "TaskAudioNormalization": "Estabilització d'Àudio",
+ "TaskAudioNormalizationDescription": "Escaneja arxius per dades d'estabilització d'àudio.",
+ "TaskDownloadMissingLyricsDescription": "Baixar les lletres de les cançons",
+ "TaskDownloadMissingLyrics": "Baixar les lletres que falten",
+ "TaskExtractMediaSegments": "Escaneig de segments multimèdia",
+ "TaskExtractMediaSegmentsDescription": "Extreu o obté segments multimèdia usant els connectors MediaSegment activats.",
+ "TaskMoveTrickplayImages": "Migra la ubicació de la imatge de Trickplay",
+ "TaskMoveTrickplayImagesDescription": "Mou els fitxers trickplay existents segons la configuració de la biblioteca."
}
diff --git a/Emby.Server.Implementations/Localization/Core/da.json b/Emby.Server.Implementations/Localization/Core/da.json
index 121a0eba8f..d43d4097f9 100644
--- a/Emby.Server.Implementations/Localization/Core/da.json
+++ b/Emby.Server.Implementations/Localization/Core/da.json
@@ -1,5 +1,5 @@
{
- "Albums": "Album",
+ "Albums": "Albummer",
"AppDeviceValues": "App: {0}, Enhed: {1}",
"Application": "Applikation",
"Artists": "Kunstnere",
@@ -72,7 +72,7 @@
"ServerNameNeedsToBeRestarted": "{0} skal genstartes",
"Shows": "Serier",
"Songs": "Sange",
- "StartupEmbyServerIsLoading": "Jellyfin Server er i gang med at starte. Forsøg igen om et øjeblik.",
+ "StartupEmbyServerIsLoading": "Jellyfin er i gang med at starte. Prøv igen om et øjeblik.",
"SubtitleDownloadFailureForItem": "Fejlet i download af undertekster for {0}",
"SubtitleDownloadFailureFromForItem": "Undertekster kunne ikke hentes fra {0} til {1}",
"Sync": "Synkroniser",
@@ -93,13 +93,13 @@
"ValueSpecialEpisodeName": "Special - {0}",
"VersionNumber": "Version {0}",
"TaskDownloadMissingSubtitlesDescription": "Søger på internettet efter manglende undertekster baseret på metadata-konfigurationen.",
- "TaskDownloadMissingSubtitles": "Hentede medie mangler undertekster",
+ "TaskDownloadMissingSubtitles": "Hent manglende undertekster",
"TaskUpdatePluginsDescription": "Henter og installerer opdateringer for plugins, som er konfigurerede til at blive opdateret automatisk.",
- "TaskUpdatePlugins": "Opdater Plugins",
+ "TaskUpdatePlugins": "Opdater plugins",
"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.",
- "TaskRefreshLibrary": "Scan Mediebibliotek",
+ "TaskRefreshLibrary": "Scan mediebibliotek",
"TaskCleanCacheDescription": "Sletter cache-filer som systemet ikke længere bruger.",
"TaskCleanCache": "Ryd cache-mappe",
"TasksChannelsCategory": "Internetkanaler",
@@ -108,33 +108,33 @@
"TasksMaintenanceCategory": "Vedligeholdelse",
"TaskRefreshChapterImages": "Udtræk kapitelbilleder",
"TaskRefreshChapterImagesDescription": "Laver miniaturebilleder for videoer, der har kapitler.",
- "TaskRefreshChannelsDescription": "Opdaterer information for internetkanal.",
- "TaskRefreshChannels": "Opdater Kanaler",
- "TaskCleanTranscodeDescription": "Fjerner transcode-filer, som er mere end 1 dag gammel.",
- "TaskCleanTranscode": "Tøm Transcode-mappen",
- "TaskRefreshPeople": "Opdater Personer",
+ "TaskRefreshChannelsDescription": "Opdaterer information for internetkanaler.",
+ "TaskRefreshChannels": "Opdater kanaler",
+ "TaskCleanTranscodeDescription": "Fjerner omkodningsfiler, som er mere end 1 dag gamle.",
+ "TaskCleanTranscode": "Tøm omkodningsmappen",
+ "TaskRefreshPeople": "Opdater personer",
"TaskRefreshPeopleDescription": "Opdaterer metadata for skuespillere og instruktører i dit mediebibliotek.",
"TaskCleanActivityLogDescription": "Sletter linjer i aktivitetsloggen ældre end den konfigurerede alder.",
- "TaskCleanActivityLog": "Ryd Aktivitetslog",
+ "TaskCleanActivityLog": "Ryd aktivitetslog",
"Undefined": "Udefineret",
"Forced": "Tvunget",
"Default": "Standard",
- "TaskOptimizeDatabaseDescription": "Komprimerer databasen og frigør plads. Denne handling køres efter at have scannet mediebiblioteket, eller efter at have lavet ændringer til databasen, for at højne ydeevnen.",
- "TaskOptimizeDatabase": "Optimér database",
- "TaskKeyframeExtractorDescription": "Udtrækker billeder fra videofiler for at lave mere præcise HLS-playlister. Denne opgave kan tage lang tid.",
- "TaskKeyframeExtractor": "Udtræk af nøglebillede",
+ "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",
+ "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",
"External": "Ekstern",
"HearingImpaired": "Hørehæmmet",
- "TaskRefreshTrickplayImages": "Generér Trickplay Billeder",
- "TaskRefreshTrickplayImagesDescription": "Laver trickplay forhåndsvisninger for videoer i aktiverede biblioteker.",
+ "TaskRefreshTrickplayImages": "Generer trickplay-billeder",
+ "TaskRefreshTrickplayImagesDescription": "Laver trickplay-billeder for videoer i aktiverede biblioteker.",
"TaskCleanCollectionsAndPlaylists": "Ryd op i samlinger og afspilningslister",
"TaskCleanCollectionsAndPlaylistsDescription": "Fjerner elementer fra samlinger og afspilningslister der ikke eksisterer længere.",
- "TaskAudioNormalizationDescription": "Skanner filer for data vedrørende audio-normalisering.",
- "TaskAudioNormalization": "Audio-normalisering",
- "TaskDownloadMissingLyricsDescription": "Hentede sange mangler sangtekster",
- "TaskDownloadMissingLyrics": "Hentede medie mangler sangtekster",
- "TaskExtractMediaSegments": "Scan mediesegment",
- "TaskMoveTrickplayImages": "Migrer billedelokation for Trickplay",
- "TaskMoveTrickplayImagesDescription": "Flyt eksisterende trickplay-filer jævnfør biblioteksindstillilnger.",
- "TaskExtractMediaSegmentsDescription": "Ekstraherer eller henter mediesegmenter fra plugins som understøtter MediaSegment."
+ "TaskAudioNormalizationDescription": "Skanner filer for data vedrørende lydnormalisering.",
+ "TaskAudioNormalization": "Lydnormalisering",
+ "TaskDownloadMissingLyricsDescription": "Søger på internettet efter manglende sangtekster baseret på metadata-konfigurationen",
+ "TaskDownloadMissingLyrics": "Hent manglende sangtekster",
+ "TaskExtractMediaSegments": "Scan for mediesegmenter",
+ "TaskMoveTrickplayImages": "Migrer billedelokationer for trickplay-billeder",
+ "TaskMoveTrickplayImagesDescription": "Flyt eksisterende trickplay-billeder jævnfør biblioteksindstillinger.",
+ "TaskExtractMediaSegmentsDescription": "Udtrækker eller henter mediesegmenter fra plugins som understøtter MediaSegment."
}
diff --git a/Emby.Server.Implementations/Localization/Core/de.json b/Emby.Server.Implementations/Localization/Core/de.json
index 51c9e87d5a..f5ae43bb5b 100644
--- a/Emby.Server.Implementations/Localization/Core/de.json
+++ b/Emby.Server.Implementations/Localization/Core/de.json
@@ -5,7 +5,7 @@
"Artists": "Interpreten",
"AuthenticationSucceededWithUserName": "{0} erfolgreich authentifiziert",
"Books": "Bücher",
- "CameraImageUploadedFrom": "Ein neues Kamerafoto wurde von {0} hochgeladen",
+ "CameraImageUploadedFrom": "Ein neues Kamerabild wurde von {0} hochgeladen",
"Channels": "Kanäle",
"ChapterNameValue": "Kapitel {0}",
"Collections": "Sammlungen",
@@ -18,7 +18,7 @@
"HeaderAlbumArtists": "Album-Interpreten",
"HeaderContinueWatching": "Weiterschauen",
"HeaderFavoriteAlbums": "Lieblingsalben",
- "HeaderFavoriteArtists": "Lieblings-Interpreten",
+ "HeaderFavoriteArtists": "Lieblingsinterpreten",
"HeaderFavoriteEpisodes": "Lieblingsepisoden",
"HeaderFavoriteShows": "Lieblingsserien",
"HeaderFavoriteSongs": "Lieblingslieder",
@@ -43,7 +43,7 @@
"NameInstallFailed": "Installation von {0} fehlgeschlagen",
"NameSeasonNumber": "Staffel {0}",
"NameSeasonUnknown": "Staffel unbekannt",
- "NewVersionIsAvailable": "Eine neue Version von Jellyfin-Server steht zum Download bereit.",
+ "NewVersionIsAvailable": "Eine neue Jellyfin-Serverversion steht zum Download bereit.",
"NotificationOptionApplicationUpdateAvailable": "Anwendungsaktualisierung verfügbar",
"NotificationOptionApplicationUpdateInstalled": "Anwendungsaktualisierung installiert",
"NotificationOptionAudioPlayback": "Audiowiedergabe gestartet",
@@ -72,12 +72,12 @@
"ServerNameNeedsToBeRestarted": "{0} muss neu gestartet werden",
"Shows": "Serien",
"Songs": "Lieder",
- "StartupEmbyServerIsLoading": "Jellyfin-Server startet, bitte versuche es gleich noch einmal.",
+ "StartupEmbyServerIsLoading": "Jellyfin-Server lädt. Bitte versuche es gleich noch einmal.",
"SubtitleDownloadFailureForItem": "Download der Untertitel fehlgeschlagen für {0}",
"SubtitleDownloadFailureFromForItem": "Untertitel von {0} für {1} konnten nicht heruntergeladen werden",
"Sync": "Synchronisation",
"System": "System",
- "TvShows": "TV-Sendungen",
+ "TvShows": "TV-Serien",
"User": "Benutzer",
"UserCreatedWithName": "Benutzer {0} wurde erstellt",
"UserDeletedWithName": "Benutzer {0} wurde gelöscht",
@@ -92,30 +92,30 @@
"ValueHasBeenAddedToLibrary": "{0} wurde deiner Bibliothek hinzugefügt",
"ValueSpecialEpisodeName": "Extra - {0}",
"VersionNumber": "Version {0}",
- "TaskDownloadMissingSubtitlesDescription": "Suche im Internet basierend auf den Metadaten-Einstellungen nach fehlenden Untertiteln.",
- "TaskDownloadMissingSubtitles": "Lade fehlende Untertitel herunter",
- "TaskRefreshChannelsDescription": "Aktualisiere Internet-Kanal-Informationen.",
- "TaskRefreshChannels": "Aktualisiere Kanäle",
- "TaskCleanTranscodeDescription": "Löscht Transkodierdateien, die älter als einen Tag sind.",
- "TaskCleanTranscode": "Räume Transkodierungs-Verzeichnis auf",
+ "TaskDownloadMissingSubtitlesDescription": "Sucht im Internet basierend auf den Metadaten-Einstellungen nach fehlenden Untertiteln.",
+ "TaskDownloadMissingSubtitles": "Fehlende Untertitel herunterladen",
+ "TaskRefreshChannelsDescription": "Aktualisiert Internet-Kanal-Informationen.",
+ "TaskRefreshChannels": "Kanäle aktualisieren",
+ "TaskCleanTranscodeDescription": "Löscht Transkodierungsdateien, die älter als einen Tag sind.",
+ "TaskCleanTranscode": "Transkodierungs-Verzeichnis aufräumen",
"TaskUpdatePluginsDescription": "Lädt Updates für Plugins herunter, welche für automatische Updates konfiguriert sind und installiert diese.",
- "TaskUpdatePlugins": "Aktualisiere Plugins",
+ "TaskUpdatePlugins": "Plugins aktualisieren",
"TaskRefreshPeopleDescription": "Aktualisiert Metadaten für Schauspieler und Regisseure in deinen Bibliotheken.",
- "TaskRefreshPeople": "Aktualisiere Personen",
+ "TaskRefreshPeople": "Personen aktualisieren",
"TaskCleanLogsDescription": "Lösche Log-Dateien, die älter als {0} Tage sind.",
- "TaskCleanLogs": "Räumt Log-Verzeichnis auf",
- "TaskRefreshLibraryDescription": "Scannt alle Bibliotheken nach neu hinzugefügten Dateien und aktualisiere Metadaten.",
- "TaskRefreshLibrary": "Scanne Medien-Bibliothek",
+ "TaskCleanLogs": "Log-Verzeichnis aufräumen",
+ "TaskRefreshLibraryDescription": "Durchsucht alle Bibliotheken nach neu hinzugefügten Dateien und aktualisiert Metadaten.",
+ "TaskRefreshLibrary": "Medien-Bibliothek scannen",
"TaskRefreshChapterImagesDescription": "Erstellt Vorschaubilder für Videos, die Kapitel besitzen.",
- "TaskRefreshChapterImages": "Extrahiere Kapitel-Bilder",
- "TaskCleanCacheDescription": "Löscht nicht mehr benötigte Zwischenspeicherdateien.",
- "TaskCleanCache": "Leere Zwischenspeicher",
+ "TaskRefreshChapterImages": "Kapitel-Bilder extrahieren",
+ "TaskCleanCacheDescription": "Löscht vom System nicht mehr benötigte Zwischenspeicherdateien.",
+ "TaskCleanCache": "Zwischenspeicher-Verzeichnis aufräumen",
"TasksChannelsCategory": "Internet-Kanäle",
"TasksApplicationCategory": "Anwendung",
"TasksLibraryCategory": "Bibliothek",
"TasksMaintenanceCategory": "Wartung",
"TaskCleanActivityLogDescription": "Löscht Aktivitätsprotokolleinträge, die älter als das konfigurierte Alter sind.",
- "TaskCleanActivityLog": "Aktivitätsprotokoll aufräumen",
+ "TaskCleanActivityLog": "Aktivitätsprotokolle aufräumen",
"Undefined": "Undefiniert",
"Forced": "Erzwungen",
"Default": "Standard",
@@ -128,12 +128,12 @@
"TaskRefreshTrickplayImages": "Trickplay-Bilder generieren",
"TaskRefreshTrickplayImagesDescription": "Erstellt ein Trickplay-Vorschauen für Videos in aktivierten Bibliotheken.",
"TaskCleanCollectionsAndPlaylists": "Sammlungen und Playlisten aufräumen",
- "TaskCleanCollectionsAndPlaylistsDescription": "Lösche nicht mehr vorhandene Einträge aus den Sammlungen und Playlisten.",
+ "TaskCleanCollectionsAndPlaylistsDescription": "Löscht nicht mehr vorhandene Einträge aus den Sammlungen und Playlisten.",
"TaskAudioNormalization": "Audio Normalisierung",
"TaskAudioNormalizationDescription": "Durchsucht Dateien nach Audionormalisierungsdaten.",
"TaskDownloadMissingLyricsDescription": "Lädt Songtexte herunter",
"TaskDownloadMissingLyrics": "Fehlende Songtexte herunterladen",
- "TaskExtractMediaSegments": "Scanne Mediensegmente",
+ "TaskExtractMediaSegments": "Mediensegmente scannen",
"TaskExtractMediaSegmentsDescription": "Extrahiert oder empfängt Mediensegmente von Plugins die Mediensegmente nutzen.",
"TaskMoveTrickplayImages": "Verzeichnis für Trickplay-Bilder migrieren",
"TaskMoveTrickplayImagesDescription": "Trickplay-Bilder werden entsprechend der Bibliothekseinstellungen verschoben."
diff --git a/Emby.Server.Implementations/Localization/Core/el.json b/Emby.Server.Implementations/Localization/Core/el.json
index 056a2e4755..f3195f0ea0 100644
--- a/Emby.Server.Implementations/Localization/Core/el.json
+++ b/Emby.Server.Implementations/Localization/Core/el.json
@@ -11,7 +11,7 @@
"Collections": "Συλλογές",
"DeviceOfflineWithName": "Ο/Η {0} αποσυνδέθηκε",
"DeviceOnlineWithName": "Ο/Η {0} συνδέθηκε",
- "FailedLoginAttemptWithUserName": "Αποτυχημένη προσπάθεια σύνδεσης από {0}",
+ "FailedLoginAttemptWithUserName": "Αποτυχία προσπάθειας σύνδεσης από {0}",
"Favorites": "Αγαπημένα",
"Folders": "Φάκελοι",
"Genres": "Είδη",
@@ -27,8 +27,8 @@
"HeaderRecordingGroups": "Ομάδες Ηχογράφησης",
"HomeVideos": "Προσωπικά Βίντεο",
"Inherit": "Κληρονόμηση",
- "ItemAddedWithName": "{0} προστέθηκε στη βιβλιοθήκη",
- "ItemRemovedWithName": "{0} διαγράφηκε από τη βιβλιοθήκη",
+ "ItemAddedWithName": "Το {0} προστέθηκε στη βιβλιοθήκη",
+ "ItemRemovedWithName": "Το {0} διαγράφτηκε από τη βιβλιοθήκη",
"LabelIpAddressValue": "Διεύθυνση IP: {0}",
"LabelRunningTimeValue": "Διάρκεια: {0}",
"Latest": "Πρόσφατα",
@@ -40,7 +40,7 @@
"Movies": "Ταινίες",
"Music": "Μουσική",
"MusicVideos": "Μουσικά Βίντεο",
- "NameInstallFailed": "{0} η εγκατάσταση απέτυχε",
+ "NameInstallFailed": "H εγκατάσταση του {0} απέτυχε",
"NameSeasonNumber": "Κύκλος {0}",
"NameSeasonUnknown": "Άγνωστος Κύκλος",
"NewVersionIsAvailable": "Μια νέα έκδοση του διακομιστή Jellyfin είναι διαθέσιμη για λήψη.",
@@ -54,7 +54,7 @@
"NotificationOptionPluginError": "Αποτυχία του πρόσθετου",
"NotificationOptionPluginInstalled": "Το πρόσθετο εγκαταστάθηκε",
"NotificationOptionPluginUninstalled": "Το πρόσθετο απεγκαταστάθηκε",
- "NotificationOptionPluginUpdateInstalled": "Η αναβάθμιση του πρόσθετου εγκαταστάθηκε",
+ "NotificationOptionPluginUpdateInstalled": "Η ενημέρωση του πρόσθετου εγκαταστάθηκε",
"NotificationOptionServerRestartRequired": "Ο διακομιστής χρειάζεται επανεκκίνηση",
"NotificationOptionTaskFailed": "Αποτυχία προγραμματισμένης εργασίας",
"NotificationOptionUserLockedOut": "Ο χρήστης αποκλείστηκε",
@@ -63,9 +63,9 @@
"Photos": "Φωτογραφίες",
"Playlists": "Λίστες αναπαραγωγής",
"Plugin": "Πρόσθετο",
- "PluginInstalledWithName": "{0} εγκαταστήθηκε",
- "PluginUninstalledWithName": "{0} έχει απεγκατασταθεί",
- "PluginUpdatedWithName": "{0} έχει αναβαθμιστεί",
+ "PluginInstalledWithName": "Το {0} εγκαταστάθηκε",
+ "PluginUninstalledWithName": "Το {0} έχει απεγκατασταθεί",
+ "PluginUpdatedWithName": "Το {0} ενημερώθηκε",
"ProviderValue": "Πάροχος: {0}",
"ScheduledTaskFailedWithName": "{0} αποτυχία",
"ScheduledTaskStartedWithName": "{0} ξεκίνησε",
@@ -96,7 +96,7 @@
"TaskCleanLogsDescription": "Διαγράφει αρχεία καταγραφής που είναι πάνω από {0} ημέρες.",
"TaskCleanLogs": "Εκκαθάριση Καταλόγου Καταγραφής",
"TaskRefreshLibraryDescription": "Σαρώνει την βιβλιοθήκη πολυμέσων σας για νέα αρχεία και ανανεώνει τα μεταδεδομένα.",
- "TaskRefreshLibrary": "Βιβλιοθήκη Σάρωσης Πολυμέσων",
+ "TaskRefreshLibrary": "Σάρωση Βιβλιοθήκης Πολυμέσων",
"TaskRefreshChapterImagesDescription": "Δημιουργεί μικρογραφίες για βίντεο που έχουν κεφάλαια.",
"TaskRefreshChapterImages": "Εξαγωγή Εικόνων Κεφαλαίου",
"TaskCleanCacheDescription": "Διαγράφει αρχεία προσωρινής μνήμης που δεν χρειάζονται πλέον το σύστημα.",
@@ -125,10 +125,16 @@
"TaskKeyframeExtractor": "Εξαγωγέας βασικών καρέ βίντεο",
"External": "Εξωτερικό",
"HearingImpaired": "Με προβλήματα ακοής",
- "TaskRefreshTrickplayImages": "Δημιουργήστε εικόνες Trickplay",
+ "TaskRefreshTrickplayImages": "Δημιουργία εικόνων Trickplay",
"TaskRefreshTrickplayImagesDescription": "Δημιουργεί προεπισκοπήσεις trickplay για βίντεο σε ενεργοποιημένες βιβλιοθήκες.",
"TaskAudioNormalization": "Ομοιομορφία ήχου",
"TaskAudioNormalizationDescription": "Ανίχνευση αρχείων για δεδομένα ομοιομορφίας ήχου.",
"TaskCleanCollectionsAndPlaylists": "Καθαρισμός συλλογών και λιστών αναπαραγωγής",
- "TaskCleanCollectionsAndPlaylistsDescription": "Αφαιρούνται στοιχεία από τις συλλογές και τις λίστες αναπαραγωγής που δεν υπάρχουν πλέον."
+ "TaskCleanCollectionsAndPlaylistsDescription": "Αφαιρούνται στοιχεία από τις συλλογές και τις λίστες αναπαραγωγής που δεν υπάρχουν πλέον.",
+ "TaskMoveTrickplayImages": "Αλλαγή τοποθεσίας εικόνων Trickplay",
+ "TaskDownloadMissingLyrics": "Λήψη στίχων που λείπουν",
+ "TaskMoveTrickplayImagesDescription": "Μετακινεί τα υπάρχοντα αρχεία trickplay σύμφωνα με τις ρυθμίσεις της βιβλιοθήκης.",
+ "TaskDownloadMissingLyricsDescription": "Κατεβάζει στίχους για τραγούδια",
+ "TaskExtractMediaSegments": "Σάρωση τμημάτων πολυμέσων",
+ "TaskExtractMediaSegmentsDescription": "Εξάγει ή βρίσκει τμήματα πολυμέσων από επεκτάσεις που χρησιμοποιούν το MediaSegment."
}
diff --git a/Emby.Server.Implementations/Localization/Core/eo.json b/Emby.Server.Implementations/Localization/Core/eo.json
index 0b595c2caf..42cce1096f 100644
--- a/Emby.Server.Implementations/Localization/Core/eo.json
+++ b/Emby.Server.Implementations/Localization/Core/eo.json
@@ -122,5 +122,9 @@
"AuthenticationSucceededWithUserName": "{0} sukcese aŭtentikigis",
"TaskKeyframeExtractorDescription": "Eltiras ĉefkadrojn el videodosieroj por krei pli precizajn HLS-ludlistojn. Ĉi tiu tasko povas funkcii dum longa tempo.",
"TaskKeyframeExtractor": "Eltiri Ĉefkadrojn",
- "External": "Ekstera"
+ "External": "Ekstera",
+ "TaskAudioNormalizationDescription": "Skanas dosierojn por sonnivelaj normaligaj datumoj.",
+ "TaskRefreshTrickplayImages": "Generi la bildojn por TrickPlay (Antaŭrigardo rapida antaŭen)",
+ "TaskAudioNormalization": "Normaligo Sonnivela",
+ "HearingImpaired": "Surda"
}
diff --git a/Emby.Server.Implementations/Localization/Core/es-AR.json b/Emby.Server.Implementations/Localization/Core/es-AR.json
index f2f657b049..cf31960f9f 100644
--- a/Emby.Server.Implementations/Localization/Core/es-AR.json
+++ b/Emby.Server.Implementations/Localization/Core/es-AR.json
@@ -15,7 +15,7 @@
"Favorites": "Favoritos",
"Folders": "Carpetas",
"Genres": "Géneros",
- "HeaderAlbumArtists": "Artistas de álbum",
+ "HeaderAlbumArtists": "Artistas del álbum",
"HeaderContinueWatching": "Seguir viendo",
"HeaderFavoriteAlbums": "Álbumes favoritos",
"HeaderFavoriteArtists": "Artistas favoritos",
diff --git a/Emby.Server.Implementations/Localization/Core/es_419.json b/Emby.Server.Implementations/Localization/Core/es_419.json
index b458ed4230..2534f37c16 100644
--- a/Emby.Server.Implementations/Localization/Core/es_419.json
+++ b/Emby.Server.Implementations/Localization/Core/es_419.json
@@ -131,5 +131,9 @@
"TaskAudioNormalizationDescription": "Analiza los archivos para normalizar el audio.",
"TaskCleanCollectionsAndPlaylists": "Limpieza de colecciones y listas de reproducción",
"TaskDownloadMissingLyrics": "Descargar letra faltante",
- "TaskDownloadMissingLyricsDescription": "Descarga letras de canciones"
+ "TaskDownloadMissingLyricsDescription": "Descarga letras de canciones",
+ "TaskExtractMediaSegmentsDescription": "Extrae u obtiene segmentos de medios de complementos habilitados para MediaSegment.",
+ "TaskMoveTrickplayImagesDescription": "Mueve archivos de trickplay existentes según la configuración de la biblioteca.",
+ "TaskExtractMediaSegments": "Escaneo de segmentos de medios",
+ "TaskMoveTrickplayImages": "Migrar la ubicación de la imagen de Trickplay"
}
diff --git a/Emby.Server.Implementations/Localization/Core/eu.json b/Emby.Server.Implementations/Localization/Core/eu.json
index 114c76c54c..4df4b90d3a 100644
--- a/Emby.Server.Implementations/Localization/Core/eu.json
+++ b/Emby.Server.Implementations/Localization/Core/eu.json
@@ -19,25 +19,25 @@
"Artists": "Artistak",
"Albums": "Albumak",
"TaskOptimizeDatabase": "Datu basea optimizatu",
- "TaskDownloadMissingSubtitlesDescription": "Metadataren konfigurazioan oinarrituta falta diren azpitituluak bilatzen ditu interneten.",
+ "TaskDownloadMissingSubtitlesDescription": "Falta diren azpitituluak bilatzen ditu interneten metadatuen konfigurazioaren arabera.",
"TaskDownloadMissingSubtitles": "Falta diren azpitituluak deskargatu",
"TaskRefreshChannelsDescription": "Internet kanalen informazioa eguneratu.",
"TaskRefreshChannels": "Kanalak eguneratu",
- "TaskCleanTranscodeDescription": "Egun bat baino zaharragoak diren transcode fitxategiak ezabatzen ditu.",
- "TaskCleanTranscode": "Transcode direktorioa garbitu",
- "TaskUpdatePluginsDescription": "Automatikoki eguneratzeko konfiguratutako pluginen eguneraketak deskargatu eta instalatzen ditu.",
+ "TaskCleanTranscodeDescription": "Egun bat baino zaharragoak diren transkodifikazio fitxategiak ezabatzen ditu.",
+ "TaskCleanTranscode": "Transkodifikazio direktorioa garbitu",
+ "TaskUpdatePluginsDescription": "Automatikoki deskargatu eta instalatu eguneraketak konfiguratutako pluginetarako.",
"TaskUpdatePlugins": "Pluginak eguneratu",
- "TaskRefreshPeopleDescription": "Zure liburutegiko aktore eta zuzendarien metadata eguneratzen du.",
+ "TaskRefreshPeopleDescription": "Zure liburutegiko aktore eta zuzendarien metadatuak eguneratzen ditu.",
"TaskRefreshPeople": "Jendea eguneratu",
"TaskCleanLogsDescription": "{0} egun baino zaharragoak diren log fitxategiak ezabatzen ditu.",
"TaskCleanLogs": "Log direktorioa garbitu",
- "TaskRefreshLibraryDescription": "Zure multimedia liburutegia eskaneatzen du fitxategi berriak eta metadatak eguneratzeko.",
- "TaskRefreshLibrary": "Multimedia Liburutegia eskaneatu",
+ "TaskRefreshLibraryDescription": "Zure multimedia liburutegia eskaneatzen du fitxategi berriak eta metadatuak eguneratzeko.",
+ "TaskRefreshLibrary": "Multimedia liburutegia eskaneatu",
"TaskRefreshChapterImagesDescription": "Kapituluak dituzten bideoen miniaturak sortzen ditu.",
"TaskRefreshChapterImages": "Kapituluen irudiak erauzi",
"TaskCleanCacheDescription": "Sistemak behar ez dituen cache fitxategiak ezabatzen ditu.",
- "TaskCleanCache": "Cache Directorioa garbitu",
- "TaskCleanActivityLogDescription": "Konfiguratuta data baino zaharragoak diren log-ak ezabatu.",
+ "TaskCleanCache": "Cache direktorioa garbitu",
+ "TaskCleanActivityLogDescription": "Konfiguratutako baino zaharragoak diren jarduera-log sarrerak ezabatzen ditu.",
"TaskCleanActivityLog": "Erabilera Log-a garbitu",
"TasksChannelsCategory": "Internet Kanalak",
"TasksApplicationCategory": "Aplikazioa",
@@ -45,22 +45,22 @@
"TasksMaintenanceCategory": "Mantenua",
"VersionNumber": "Bertsioa {0}",
"ValueHasBeenAddedToLibrary": "{0} zure multimedia liburutegian gehitu da",
- "UserStoppedPlayingItemWithValues": "{0}-ek {1} ikusteaz bukatu du {2}-(a)n",
- "UserStartedPlayingItemWithValues": "{0} {1} ikusten ari da {2}-(a)n",
- "UserPolicyUpdatedWithName": "{0} Erabiltzailearen politikak aldatu dira",
- "UserPasswordChangedWithName": "{0} Erabiltzailearen pasahitza aldatu da",
- "UserOnlineFromDevice": "{0} online dago {1}-tik",
- "UserOfflineFromDevice": "{0} {1}-tik deskonektatu da",
- "UserLockedOutWithName": "{0} Erabiltzailea blokeatu da",
- "UserDownloadingItemWithValues": "{1} {0}-tik deskargatzen",
+ "UserStoppedPlayingItemWithValues": "{0} {1} ikusten bukatu du {2}-(e)n",
+ "UserStartedPlayingItemWithValues": "{0} {1} ikusten ari da {2}-(e)n",
+ "UserPolicyUpdatedWithName": "{0} erabiltzailearen politikak aldatu dira",
+ "UserPasswordChangedWithName": "{0} erabiltzailearen pasahitza aldatu da",
+ "UserOnlineFromDevice": "{0} online dago {1}-(e)tik",
+ "UserOfflineFromDevice": "{0} {1}-(e)tik deskonektatu da",
+ "UserLockedOutWithName": "{0} erabiltzailea blokeatu da",
+ "UserDownloadingItemWithValues": "{0} {1} deskargatzen ari da",
"UserDeletedWithName": "{0} Erabiltzailea ezabatu da",
"UserCreatedWithName": "{0} Erabiltzailea sortu da",
"User": "Erabiltzailea",
"Undefined": "Ezezaguna",
- "TvShows": "TB showak",
+ "TvShows": "TB serieak",
"System": "Sistema",
- "SubtitleDownloadFailureFromForItem": "{1}-en azpitutuluak {0} deskargatzean huts egin du",
- "StartupEmbyServerIsLoading": "Jellyfin zerbitzaria kargatzen. Saiatu berriro beranduxeago.",
+ "SubtitleDownloadFailureFromForItem": "{1}-en azpitutuluak {0}-tik deskargatzeak huts egin du",
+ "StartupEmbyServerIsLoading": "Jellyfin zerbitzaria kargatzen. Saiatu berriro beranduago.",
"ServerNameNeedsToBeRestarted": "{0} berrabiarazi behar da",
"ScheduledTaskStartedWithName": "{0} hasi da",
"ScheduledTaskFailedWithName": "{0} huts egin du",
@@ -89,26 +89,26 @@
"NameSeasonNumber": "{0} Denboraldia",
"NameInstallFailed": "{0} instalazioak huts egin du",
"Music": "Musika",
- "MixedContent": "Denetariko edukia",
+ "MixedContent": "Eduki mistoa",
"MessageServerConfigurationUpdated": "Zerbitzariaren konfigurazioa eguneratu da",
- "MessageNamedServerConfigurationUpdatedWithValue": "Zerbitzariaren konfigurazio {0} atala eguneratu da",
+ "MessageNamedServerConfigurationUpdatedWithValue": "Zerbitzariaren {0} konfigurazio atala eguneratu da",
"MessageApplicationUpdatedTo": "Jellyfin zerbitzaria {0}-ra eguneratu da",
"MessageApplicationUpdated": "Jellyfin zerbitzaria eguneratu da",
"Latest": "Azkena",
- "LabelRunningTimeValue": "Denbora martxan: {0}",
+ "LabelRunningTimeValue": "Iraupena: {0}",
"LabelIpAddressValue": "IP helbidea: {0}",
- "ItemRemovedWithName": "{0} liburutegitik ezabatu da",
+ "ItemRemovedWithName": "{0} liburutegitik kendu da",
"ItemAddedWithName": "{0} liburutegira gehitu da",
"HomeVideos": "Etxeko bideoak",
- "HeaderNextUp": "Nobedadeak",
+ "HeaderNextUp": "Hurrengoa",
"HeaderLiveTV": "Zuzeneko TB",
"HeaderFavoriteSongs": "Gogoko abestiak",
- "HeaderFavoriteShows": "Gogoko showak",
+ "HeaderFavoriteShows": "Gogoko serieak",
"HeaderFavoriteEpisodes": "Gogoko atalak",
"HeaderFavoriteArtists": "Gogoko artistak",
"HeaderFavoriteAlbums": "Gogoko albumak",
"Forced": "Behartuta",
- "FailedLoginAttemptWithUserName": "Login egiten akatsa, saiatu hemen {0}",
+ "FailedLoginAttemptWithUserName": "{0}-tik saioa hasteak huts egin du",
"External": "Kanpokoa",
"DeviceOnlineWithName": "{0} konektatu da",
"DeviceOfflineWithName": "{0} deskonektatu da",
@@ -117,13 +117,23 @@
"AuthenticationSucceededWithUserName": "{0} ongi autentifikatu da",
"Application": "Aplikazioa",
"AppDeviceValues": "App: {0}, Gailua: {1}",
- "HearingImpaired": "Entzunaldia aldatua",
+ "HearingImpaired": "Entzumen urritasuna",
"ProviderValue": "Hornitzailea: {0}",
"TaskKeyframeExtractorDescription": "Bideo fitxategietako fotograma gakoak ateratzen ditu HLS erreprodukzio-zerrenda zehatzagoak sortzeko. Zeregin honek denbora asko iraun dezake.",
"HeaderRecordingGroups": "Grabaketa taldeak",
"Inherit": "Oinordetu",
"TaskOptimizeDatabaseDescription": "Datu-basea trinkotu eta bertatik espazioa askatzen du. Liburutegia eskaneatu ondoren edo datu-basean aldaketak egin ondoren ataza hau exekutatzeak errendimendua hobetu lezake.",
"TaskKeyframeExtractor": "Fotograma gakoen erauzgailua",
- "TaskRefreshTrickplayImages": "\"Trickplay Irudiak Sortu",
- "TaskRefreshTrickplayImagesDescription": "Bideoentzako trickplay aurrebistak sortzen ditu gaitutako liburutegietan."
+ "TaskRefreshTrickplayImages": "Trickplay irudiak sortu",
+ "TaskRefreshTrickplayImagesDescription": "Bideoentzako trickplay aurrebistak sortzen ditu gaitutako liburutegietan.",
+ "TaskAudioNormalization": "Audio normalizazioa",
+ "TaskDownloadMissingLyrics": "Deskargatu falta diren letrak",
+ "TaskDownloadMissingLyricsDescription": "Deskargatu abestientzako letrak",
+ "TaskExtractMediaSegments": "Multimedia segmentuen eskaneoa",
+ "TaskCleanCollectionsAndPlaylistsDescription": "Jada existitzen ez diren bildumak eta erreprodukzio-zerrendak kentzen ditu.",
+ "TaskCleanCollectionsAndPlaylists": "Garbitu bildumak eta erreprodukzio-zerrendak",
+ "TaskExtractMediaSegmentsDescription": "Media segmentuak atera edo lortzen ditu MediaSegment gaituta duten pluginetik.",
+ "TaskMoveTrickplayImages": "Aldatu Trickplay irudien kokalekua",
+ "TaskMoveTrickplayImagesDescription": "Lehendik dauden trickplay fitxategiak liburutegiaren ezarpenen arabera mugitzen dira.",
+ "TaskAudioNormalizationDescription": "Audio normalizazio datuak lortzeko fitxategiak eskaneatzen ditu."
}
diff --git a/Emby.Server.Implementations/Localization/Core/fi.json b/Emby.Server.Implementations/Localization/Core/fi.json
index 8a88cf28e9..c9f580cd5f 100644
--- a/Emby.Server.Implementations/Localization/Core/fi.json
+++ b/Emby.Server.Implementations/Localization/Core/fi.json
@@ -130,5 +130,10 @@
"TaskCleanCollectionsAndPlaylists": "Puhdista kokoelmat ja soittolistat",
"TaskAudioNormalization": "Äänenvoimakkuuden normalisointi",
"TaskAudioNormalizationDescription": "Etsii tiedostoista äänenvoimakkuuden normalisointitietoja.",
- "TaskDownloadMissingLyrics": "Lataa puuttuva lyriikka"
+ "TaskDownloadMissingLyrics": "Lataa puuttuva lyriikka",
+ "TaskExtractMediaSegments": "Mediasegmentin skannaus",
+ "TaskDownloadMissingLyricsDescription": "Ladataan sanoituksia",
+ "TaskExtractMediaSegmentsDescription": "Poimii tai hankkii mediasegmenttejä MediaSegment-yhteensopivista laajennuksista.",
+ "TaskMoveTrickplayImages": "Siirrä Trickplay-kuvien sijainti",
+ "TaskMoveTrickplayImagesDescription": "Siirtää olemassa olevia trickplay-tiedostoja kirjaston asetusten mukaan."
}
diff --git a/Emby.Server.Implementations/Localization/Core/fr-CA.json b/Emby.Server.Implementations/Localization/Core/fr-CA.json
index 68ab4b617e..a10912f011 100644
--- a/Emby.Server.Implementations/Localization/Core/fr-CA.json
+++ b/Emby.Server.Implementations/Localization/Core/fr-CA.json
@@ -135,5 +135,6 @@
"TaskDownloadMissingLyricsDescription": "Téléchargement des paroles des chansons",
"TaskMoveTrickplayImagesDescription": "Déplace les fichiers trickplay existants en fonction des paramètres de la bibliothèque.",
"TaskDownloadMissingLyrics": "Télécharger les paroles des chansons manquantes",
- "TaskMoveTrickplayImages": "Changer l'emplacement des images Trickplay"
+ "TaskMoveTrickplayImages": "Changer l'emplacement des images Trickplay",
+ "TaskExtractMediaSegmentsDescription": "Extrait ou obtient des segments de média à partir des plugins compatibles avec MediaSegment."
}
diff --git a/Emby.Server.Implementations/Localization/Core/ga.json b/Emby.Server.Implementations/Localization/Core/ga.json
index b511ed6ba9..b8e787c20a 100644
--- a/Emby.Server.Implementations/Localization/Core/ga.json
+++ b/Emby.Server.Implementations/Localization/Core/ga.json
@@ -1,16 +1,139 @@
{
"Albums": "Albaim",
- "Artists": "Ealaíontóir",
- "AuthenticationSucceededWithUserName": "{0} fíordheimhnithe",
- "Books": "leabhair",
- "CameraImageUploadedFrom": "Tá íomhá ceamara nua uaslódáilte ó {0}",
+ "Artists": "Ealaíontóirí",
+ "AuthenticationSucceededWithUserName": "D'éirigh le fíordheimhniú {0}",
+ "Books": "Leabhair",
+ "CameraImageUploadedFrom": "Uaslódáladh íomhá ceamara nua ó {0}",
"Channels": "Cainéil",
"ChapterNameValue": "Caibidil {0}",
"Collections": "Bailiúcháin",
- "Default": "Mainneachtain",
- "DeviceOfflineWithName": "scoireadh {0}",
- "DeviceOnlineWithName": "{0} ceangailte",
- "External": "Forimeallach",
- "FailedLoginAttemptWithUserName": "Iarracht ar theip ar fhíordheimhniú ó {0}",
- "Favorites": "Ceanáin"
+ "Default": "Réamhshocrú",
+ "DeviceOfflineWithName": "Tá {0} dícheangailte",
+ "DeviceOnlineWithName": "Tá {0} nasctha",
+ "External": "Seachtrach",
+ "FailedLoginAttemptWithUserName": "Theip ar iarracht logáil isteach ó {0}",
+ "Favorites": "Ceanáin",
+ "TaskExtractMediaSegments": "Scanadh Deighleog na Meán",
+ "TaskMoveTrickplayImages": "Imirce Suíomh Íomhá Trickplay",
+ "TaskDownloadMissingLyrics": "Íosluchtaigh liricí ar iarraidh",
+ "TaskKeyframeExtractor": "Keyframe Eastarraingteoir",
+ "TaskAudioNormalization": "Normalú Fuaime",
+ "TaskAudioNormalizationDescription": "Scanann comhaid le haghaidh sonraí normalaithe fuaime.",
+ "TaskRefreshLibraryDescription": "Déanann sé do leabharlann meán a scanadh le haghaidh comhaid nua agus athnuachana meiteashonraí.",
+ "TaskCleanLogs": "Eolaire Logchomhad Glan",
+ "TaskCleanLogsDescription": "Scriostar comhaid loga atá níos mó ná {0} lá d'aois.",
+ "TaskRefreshPeopleDescription": "Nuashonraítear meiteashonraí d’aisteoirí agus stiúrthóirí i do leabharlann meán.",
+ "TaskRefreshTrickplayImages": "Gin Íomhánna Trickplay",
+ "TaskRefreshTrickplayImagesDescription": "Cruthaíonn sé réamhamhairc trickplay le haghaidh físeáin i leabharlanna cumasaithe.",
+ "TaskRefreshChannels": "Cainéil Athnuaigh",
+ "TaskRefreshChannelsDescription": "Athnuachan eolas faoi chainéil idirlín.",
+ "TaskOptimizeDatabase": "Bunachar sonraí a bharrfheabhsú",
+ "TaskKeyframeExtractorDescription": "Baintear eochairfhrámaí as comhaid físe chun seinmliostaí HLS níos cruinne a chruthú. Féadfaidh an tasc seo a bheith ar siúl ar feadh i bhfad.",
+ "TaskCleanCollectionsAndPlaylistsDescription": "Baintear míreanna as bailiúcháin agus seinmliostaí nach ann dóibh a thuilleadh.",
+ "TaskDownloadMissingLyricsDescription": "Íosluchtaigh liricí do na hamhráin",
+ "TaskUpdatePluginsDescription": "Íoslódálann agus suiteálann nuashonruithe do bhreiseáin atá cumraithe le nuashonrú go huathoibríoch.",
+ "TaskDownloadMissingSubtitlesDescription": "Déanann sé cuardach ar an idirlíon le haghaidh fotheidil atá ar iarraidh bunaithe ar chumraíocht meiteashonraí.",
+ "TaskExtractMediaSegmentsDescription": "Sliocht nó faigheann codanna meán ó bhreiseáin chumasaithe MediaSegment.",
+ "TaskCleanCollectionsAndPlaylists": "Glan suas bailiúcháin agus seinmliostaí",
+ "TaskOptimizeDatabaseDescription": "Comhdhlúthaíonn bunachar sonraí agus gearrtar spás saor in aisce. Má ritheann tú an tasc seo tar éis scanadh a dhéanamh ar an leabharlann nó athruithe eile a dhéanamh a thugann le tuiscint gur cheart go bhfeabhsófaí an fheidhmíocht.",
+ "TaskMoveTrickplayImagesDescription": "Bogtar comhaid trickplay atá ann cheana de réir socruithe na leabharlainne.",
+ "AppDeviceValues": "Aip: {0}, Gléas: {1}",
+ "Application": "Feidhmchlár",
+ "Folders": "Fillteáin",
+ "Forced": "Éigean",
+ "Genres": "Seánraí",
+ "HeaderAlbumArtists": "Ealaíontóirí albam",
+ "HeaderContinueWatching": "Leanúint ar aghaidh ag Breathnú",
+ "HeaderFavoriteAlbums": "Albam is fearr leat",
+ "HeaderFavoriteArtists": "Ealaíontóirí is Fearr",
+ "HeaderFavoriteEpisodes": "Eipeasóid is fearr leat",
+ "HeaderFavoriteShows": "Seónna is Fearr",
+ "HeaderFavoriteSongs": "Amhráin is fearr leat",
+ "HeaderLiveTV": "Teilifís beo",
+ "HeaderNextUp": "Ar Aghaidh Suas",
+ "HeaderRecordingGroups": "Grúpaí Taifeadta",
+ "HearingImpaired": "Lag éisteachta",
+ "HomeVideos": "Físeáin Baile",
+ "Inherit": "Oidhreacht",
+ "ItemAddedWithName": "Cuireadh {0} leis an leabharlann",
+ "ItemRemovedWithName": "Baineadh {0} den leabharlann",
+ "LabelIpAddressValue": "Seoladh IP: {0}",
+ "LabelRunningTimeValue": "Am rite: {0}",
+ "Latest": "Is déanaí",
+ "MessageApplicationUpdated": "Tá Freastalaí Jellyfin nuashonraithe",
+ "MessageApplicationUpdatedTo": "Nuashonraíodh Freastalaí Jellyfin go {0}",
+ "MessageNamedServerConfigurationUpdatedWithValue": "Nuashonraíodh an chuid cumraíochta freastalaí {0}",
+ "MessageServerConfigurationUpdated": "Nuashonraíodh cumraíocht an fhreastalaí",
+ "MixedContent": "Ábhar measctha",
+ "Movies": "Scannáin",
+ "Music": "Ceol",
+ "MusicVideos": "Físeáin Ceoil",
+ "NameInstallFailed": "Theip ar shuiteáil {0}",
+ "NameSeasonNumber": "Séasúr {0}",
+ "NameSeasonUnknown": "Séasúr Anaithnid",
+ "NewVersionIsAvailable": "Tá leagan nua de Jellyfin Server ar fáil le híoslódáil.",
+ "NotificationOptionApplicationUpdateAvailable": "Nuashonrú feidhmchláir ar fáil",
+ "NotificationOptionApplicationUpdateInstalled": "Nuashonrú feidhmchláir suiteáilte",
+ "NotificationOptionAudioPlayback": "Cuireadh tús le hathsheinm fuaime",
+ "NotificationOptionAudioPlaybackStopped": "Cuireadh deireadh le hathsheinm fuaime",
+ "NotificationOptionCameraImageUploaded": "Íosluchtaigh grianghraf ceamara",
+ "NotificationOptionInstallationFailed": "Teip suiteála",
+ "NotificationOptionNewLibraryContent": "Ábhar nua curtha leis",
+ "NotificationOptionPluginError": "Teip breiseán",
+ "NotificationOptionPluginInstalled": "Breiseán suiteáilte",
+ "NotificationOptionPluginUninstalled": "Breiseán díshuiteáilte",
+ "NotificationOptionPluginUpdateInstalled": "Nuashonrú breiseán suiteáilte",
+ "NotificationOptionServerRestartRequired": "Teastaíonn atosú an fhreastalaí",
+ "NotificationOptionTaskFailed": "Teip tasc sceidealta",
+ "NotificationOptionUserLockedOut": "Úsáideoir glasáilte amach",
+ "NotificationOptionVideoPlayback": "Cuireadh tús le hathsheinm físe",
+ "NotificationOptionVideoPlaybackStopped": "Cuireadh deireadh le hathsheinm físe",
+ "Photos": "Grianghraif",
+ "Playlists": "Seinmliostaí",
+ "Plugin": "Breiseán",
+ "PluginInstalledWithName": "Suiteáladh {0}",
+ "PluginUninstalledWithName": "Díshuiteáladh {0}",
+ "PluginUpdatedWithName": "Nuashonraíodh {0}",
+ "ProviderValue": "Soláthraí: {0}",
+ "ScheduledTaskFailedWithName": "Theip ar {0}",
+ "ScheduledTaskStartedWithName": "Thosaigh {0}",
+ "ServerNameNeedsToBeRestarted": "Ní mór {0} a atosú",
+ "Shows": "Seónna",
+ "Songs": "Amhráin",
+ "StartupEmbyServerIsLoading": "Tá freastalaí Jellyfin á luchtú. Bain triail eile as gan mhoill.",
+ "SubtitleDownloadFailureFromForItem": "Theip ar fhotheidil a íoslódáil ó {0} le haghaidh {1}",
+ "Sync": "Sioncrónaigh",
+ "System": "Córas",
+ "TvShows": "Seónna Teilifíse",
+ "Undefined": "Neamhshainithe",
+ "User": "Úsáideoir",
+ "UserCreatedWithName": "Cruthaíodh úsáideoir {0}",
+ "UserDeletedWithName": "Scriosadh úsáideoir {0}",
+ "UserDownloadingItemWithValues": "Tá {0} á íoslódáil {1}",
+ "UserLockedOutWithName": "Tá úsáideoir {0} glasáilte amach",
+ "UserOfflineFromDevice": "Tá {0} dícheangailte ó {1}",
+ "UserOnlineFromDevice": "Tá {0} ar líne ó {1}",
+ "UserPasswordChangedWithName": "Athraíodh pasfhocal don úsáideoir {0}",
+ "UserPolicyUpdatedWithName": "Nuashonraíodh polasaí úsáideora le haghaidh {0}",
+ "UserStartedPlayingItemWithValues": "Tá {0} ag seinnt {1} ar {2}",
+ "UserStoppedPlayingItemWithValues": "Chríochnaigh {0} ag imirt {1} ar {2}",
+ "ValueHasBeenAddedToLibrary": "Cuireadh {0} le do leabharlann meán",
+ "ValueSpecialEpisodeName": "Speisialta - {0}",
+ "VersionNumber": "Leagan {0}",
+ "TasksMaintenanceCategory": "Cothabháil",
+ "TasksLibraryCategory": "Leabharlann",
+ "TasksApplicationCategory": "Feidhmchlár",
+ "TasksChannelsCategory": "Cainéil Idirlín",
+ "TaskCleanActivityLog": "Loga Gníomhaíochta Glan",
+ "TaskCleanActivityLogDescription": "Scrios iontrálacha loga gníomhaíochta atá níos sine ná an aois chumraithe.",
+ "TaskCleanCache": "Eolaire Taisce Glan",
+ "TaskCleanCacheDescription": "Scriostar comhaid taisce nach bhfuil ag teastáil ón gcóras a thuilleadh.",
+ "TaskRefreshChapterImages": "Sliocht Íomhánna Caibidil",
+ "TaskRefreshChapterImagesDescription": "Cruthaíonn mionsamhlacha le haghaidh físeáin a bhfuil caibidlí acu.",
+ "TaskRefreshLibrary": "Scan Leabharlann na Meán",
+ "TaskRefreshPeople": "Daoine Athnuaigh",
+ "TaskUpdatePlugins": "Nuashonraigh Breiseáin",
+ "TaskCleanTranscodeDescription": "Scriostar comhaid traschódaithe níos mó ná lá amháin d'aois.",
+ "TaskCleanTranscode": "Eolaire Transcode Glan",
+ "TaskDownloadMissingSubtitles": "Íosluchtaigh fotheidil ar iarraidh"
}
diff --git a/Emby.Server.Implementations/Localization/Core/he.json b/Emby.Server.Implementations/Localization/Core/he.json
index af57b1693e..34d5cf0509 100644
--- a/Emby.Server.Implementations/Localization/Core/he.json
+++ b/Emby.Server.Implementations/Localization/Core/he.json
@@ -16,7 +16,7 @@
"Folders": "תיקיות",
"Genres": "ז׳אנרים",
"HeaderAlbumArtists": "אמני האלבום",
- "HeaderContinueWatching": "להמשיך לצפות",
+ "HeaderContinueWatching": "המשך צפייה",
"HeaderFavoriteAlbums": "אלבומים מועדפים",
"HeaderFavoriteArtists": "אמנים מועדפים",
"HeaderFavoriteEpisodes": "פרקים מועדפים",
@@ -32,8 +32,8 @@
"LabelIpAddressValue": "Ip כתובת: {0}",
"LabelRunningTimeValue": "משך צפייה: {0}",
"Latest": "אחרון",
- "MessageApplicationUpdated": "שרת הJellyfin עודכן",
- "MessageApplicationUpdatedTo": "שרת ה־Jellyfin עודכן לגרסה {0}",
+ "MessageApplicationUpdated": "שרת ג'ליפין עודכן",
+ "MessageApplicationUpdatedTo": "שרת ג'ליפין עודכן לגרסה {0}",
"MessageNamedServerConfigurationUpdatedWithValue": "סעיף הגדרת השרת {0} עודכן",
"MessageServerConfigurationUpdated": "תצורת השרת עודכנה",
"MixedContent": "תוכן מעורב",
@@ -43,7 +43,7 @@
"NameInstallFailed": "התקנת {0} נכשלה",
"NameSeasonNumber": "עונה {0}",
"NameSeasonUnknown": "עונה לא ידועה",
- "NewVersionIsAvailable": "גרסה חדשה של שרת Jellyfin זמינה להורדה.",
+ "NewVersionIsAvailable": "גרסה חדשה של שרת ג'ליפין זמינה להורדה.",
"NotificationOptionApplicationUpdateAvailable": "קיים עדכון זמין ליישום",
"NotificationOptionApplicationUpdateInstalled": "עדכון ליישום הותקן",
"NotificationOptionAudioPlayback": "ניגון שמע החל",
@@ -72,7 +72,7 @@
"ServerNameNeedsToBeRestarted": "{0} דורש הפעלה מחדש",
"Shows": "סדרות",
"Songs": "שירים",
- "StartupEmbyServerIsLoading": "שרת Jellyfin בהליכי טעינה. נא לנסות שנית בהקדם.",
+ "StartupEmbyServerIsLoading": "שרת ג'ליפין טוען. נא לנסות שוב בקרוב.",
"SubtitleDownloadFailureForItem": "Subtitles failed to download for {0}",
"SubtitleDownloadFailureFromForItem": "הורדת כתוביות מ־{0} עבור {1} נכשלה",
"Sync": "סנכרון",
@@ -133,8 +133,8 @@
"TaskCleanCollectionsAndPlaylists": "מנקה אוספים ורשימות השמעה",
"TaskDownloadMissingLyrics": "הורדת מילים חסרות",
"TaskDownloadMissingLyricsDescription": "הורדת מילים לשירים",
- "TaskMoveTrickplayImages": "מעביר את מיקום תמונות Trickplay",
+ "TaskMoveTrickplayImages": "העברת מיקום התמונות",
"TaskExtractMediaSegments": "סריקת מדיה",
"TaskExtractMediaSegmentsDescription": "מחלץ חלקי מדיה מתוספים המאפשרים זאת.",
- "TaskMoveTrickplayImagesDescription": "מזיז קבצי trickplay קיימים בהתאם להגדרות הספרייה."
+ "TaskMoveTrickplayImagesDescription": "הזזת קבצי טריקפליי קיימים בהתאם להגדרות הספרייה."
}
diff --git a/Emby.Server.Implementations/Localization/Core/hi.json b/Emby.Server.Implementations/Localization/Core/hi.json
index 380c08e0d2..813b18ad4b 100644
--- a/Emby.Server.Implementations/Localization/Core/hi.json
+++ b/Emby.Server.Implementations/Localization/Core/hi.json
@@ -99,7 +99,7 @@
"ValueHasBeenAddedToLibrary": "{0} आपके माध्यम ग्रन्थालय में उपजात हो गया हैं",
"TasksLibraryCategory": "संग्रहालय",
"TaskOptimizeDatabase": "जानकारी प्रवृद्धि",
- "TaskDownloadMissingSubtitles": "असमेत अनुलेख को अवाहरति करें",
+ "TaskDownloadMissingSubtitles": "लापता अनुलेख डाउनलोड करें",
"TaskRefreshLibrary": "माध्यम संग्राहत को छाने",
"TaskCleanActivityLog": "क्रियाकलाप लॉग साफ करें",
"TasksChannelsCategory": "इंटरनेट प्रणाली",
@@ -127,5 +127,7 @@
"TaskRefreshTrickplayImages": "ट्रिकप्लै चित्रों को सृजन करे",
"TaskRefreshTrickplayImagesDescription": "नियत संग्रहों में चलचित्रों का ट्रीकप्लै दर्शनों को सृजन करे.",
"TaskAudioNormalization": "श्रव्य सामान्यीकरण",
- "TaskAudioNormalizationDescription": "श्रव्य सामान्यीकरण के लिए फाइलें अन्वेषण करें"
+ "TaskAudioNormalizationDescription": "श्रव्य सामान्यीकरण के लिए फाइलें अन्वेषण करें",
+ "TaskDownloadMissingLyrics": "लापता गानों के बोल डाउनलोड करेँ",
+ "TaskDownloadMissingLyricsDescription": "गानों के बोल डाउनलोड करता है"
}
diff --git a/Emby.Server.Implementations/Localization/Core/ht.json b/Emby.Server.Implementations/Localization/Core/ht.json
new file mode 100644
index 0000000000..4fcba99e90
--- /dev/null
+++ b/Emby.Server.Implementations/Localization/Core/ht.json
@@ -0,0 +1,3 @@
+{
+ "Books": "liv"
+}
diff --git a/Emby.Server.Implementations/Localization/Core/hu.json b/Emby.Server.Implementations/Localization/Core/hu.json
index f205e8b64c..1a9c3ee8be 100644
--- a/Emby.Server.Implementations/Localization/Core/hu.json
+++ b/Emby.Server.Implementations/Localization/Core/hu.json
@@ -13,7 +13,7 @@
"DeviceOnlineWithName": "{0} belépett",
"FailedLoginAttemptWithUserName": "Sikertelen bejelentkezési kísérlet innen: {0}",
"Favorites": "Kedvencek",
- "Folders": "Könyvtárak",
+ "Folders": "Mappák",
"Genres": "Műfajok",
"HeaderAlbumArtists": "Albumelőadók",
"HeaderContinueWatching": "Megtekintés folytatása",
diff --git a/Emby.Server.Implementations/Localization/Core/it.json b/Emby.Server.Implementations/Localization/Core/it.json
index 6b0cfb3594..e05afbabeb 100644
--- a/Emby.Server.Implementations/Localization/Core/it.json
+++ b/Emby.Server.Implementations/Localization/Core/it.json
@@ -58,8 +58,8 @@
"NotificationOptionServerRestartRequired": "Riavvio del server necessario",
"NotificationOptionTaskFailed": "Operazione pianificata fallita",
"NotificationOptionUserLockedOut": "Utente bloccato",
- "NotificationOptionVideoPlayback": "La riproduzione video è iniziata",
- "NotificationOptionVideoPlaybackStopped": "La riproduzione video è stata interrotta",
+ "NotificationOptionVideoPlayback": "Riproduzione video iniziata",
+ "NotificationOptionVideoPlaybackStopped": "Riproduzione video interrotta",
"Photos": "Foto",
"Playlists": "Playlist",
"Plugin": "Plugin",
@@ -134,5 +134,7 @@
"TaskDownloadMissingLyricsDescription": "Scarica testi per le canzoni",
"TaskDownloadMissingLyrics": "Scarica testi mancanti",
"TaskMoveTrickplayImages": "Sposta le immagini Trickplay",
- "TaskMoveTrickplayImagesDescription": "Sposta le immagini Trickplay esistenti secondo la configurazione della libreria."
+ "TaskMoveTrickplayImagesDescription": "Sposta le immagini Trickplay esistenti secondo la configurazione della libreria.",
+ "TaskExtractMediaSegmentsDescription": "Estrae o ottiene segmenti multimediali dai plugin abilitati MediaSegment.",
+ "TaskExtractMediaSegments": "Scansiona Segmento Media"
}
diff --git a/Emby.Server.Implementations/Localization/Core/ja.json b/Emby.Server.Implementations/Localization/Core/ja.json
index 10f4aee251..14a5765921 100644
--- a/Emby.Server.Implementations/Localization/Core/ja.json
+++ b/Emby.Server.Implementations/Localization/Core/ja.json
@@ -134,5 +134,6 @@
"TaskExtractMediaSegments": "メディアセグメントを読み取る",
"TaskMoveTrickplayImages": "Trickplayの画像を移動",
"TaskMoveTrickplayImagesDescription": "ライブラリ設定によりTrickplayのファイルを移動。",
- "TaskDownloadMissingLyrics": "記録されていない歌詞をダウンロード"
+ "TaskDownloadMissingLyrics": "失われた歌詞をダウンロード",
+ "TaskExtractMediaSegmentsDescription": "MediaSegment 対応プラグインからメディア セグメントを抽出または取得します。"
}
diff --git a/Emby.Server.Implementations/Localization/Core/ko.json b/Emby.Server.Implementations/Localization/Core/ko.json
index a739cba358..efc9f61ddf 100644
--- a/Emby.Server.Implementations/Localization/Core/ko.json
+++ b/Emby.Server.Implementations/Localization/Core/ko.json
@@ -3,7 +3,7 @@
"AppDeviceValues": "앱: {0}, 장치: {1}",
"Application": "애플리케이션",
"Artists": "아티스트",
- "AuthenticationSucceededWithUserName": "{0}이(가) 성공적으로 인증됨",
+ "AuthenticationSucceededWithUserName": "{0} 사용자가 성공적으로 인증됨",
"Books": "도서",
"CameraImageUploadedFrom": "{0}에서 새로운 카메라 이미지가 업로드됨",
"Channels": "채널",
@@ -70,7 +70,7 @@
"ScheduledTaskFailedWithName": "{0} 실패",
"ScheduledTaskStartedWithName": "{0} 시작",
"ServerNameNeedsToBeRestarted": "{0}를 재시작해야합니다",
- "Shows": "쇼",
+ "Shows": "시리즈",
"Songs": "노래",
"StartupEmbyServerIsLoading": "Jellyfin 서버를 불러오고 있습니다. 잠시 후에 다시 시도하십시오.",
"SubtitleDownloadFailureForItem": "Subtitles failed to download for {0}",
@@ -81,14 +81,14 @@
"User": "사용자",
"UserCreatedWithName": "사용자 {0} 생성됨",
"UserDeletedWithName": "사용자 {0} 삭제됨",
- "UserDownloadingItemWithValues": "{0}이(가) {1}을 다운로드 중입니다",
- "UserLockedOutWithName": "유저 {0} 은(는) 잠금처리 되었습니다",
- "UserOfflineFromDevice": "{1}에서 {0}의 연결이 끊킴",
- "UserOnlineFromDevice": "{0}이 {1}으로 접속",
- "UserPasswordChangedWithName": "사용자 {0}의 비밀번호가 변경되었습니다",
- "UserPolicyUpdatedWithName": "{0}의 사용자 정책이 업데이트되었습니다",
- "UserStartedPlayingItemWithValues": "{2}에서 {0}이 {1} 재생 중",
- "UserStoppedPlayingItemWithValues": "{2}에서 {0}이 {1} 재생을 마침",
+ "UserDownloadingItemWithValues": "{0} 사용자가 {1} 다운로드 중",
+ "UserLockedOutWithName": "{0} 사용자 잠김",
+ "UserOfflineFromDevice": "{0} 사용자의 {1}에서 연결이 끊김",
+ "UserOnlineFromDevice": "{0} 사용자가 {1}에서 접속함",
+ "UserPasswordChangedWithName": "{0} 사용자 비밀번호 변경됨",
+ "UserPolicyUpdatedWithName": "{0} 사용자 정책 업데이트됨",
+ "UserStartedPlayingItemWithValues": "{0} 사용자의 {2}에서 {1} 재생 중",
+ "UserStoppedPlayingItemWithValues": "{0} 사용자의 {2}에서 {1} 재생을 마침",
"ValueHasBeenAddedToLibrary": "{0}가 미디어 라이브러리에 추가되었습니다",
"ValueSpecialEpisodeName": "스페셜 - {0}",
"VersionNumber": "버전 {0}",
@@ -130,5 +130,11 @@
"TaskAudioNormalizationDescription": "오디오의 볼륨 수준을 일정하게 조정하기 위해 파일을 스캔합니다.",
"TaskRefreshTrickplayImages": "비디오 탐색용 미리보기 썸네일 생성",
"TaskRefreshTrickplayImagesDescription": "활성화된 라이브러리에서 비디오의 트릭플레이 미리보기를 생성합니다.",
- "TaskCleanCollectionsAndPlaylistsDescription": "더 이상 존재하지 않는 컬렉션 및 재생 목록에서 항목을 제거합니다."
+ "TaskCleanCollectionsAndPlaylistsDescription": "더 이상 존재하지 않는 컬렉션 및 재생 목록에서 항목을 제거합니다.",
+ "TaskExtractMediaSegments": "미디어 세그먼트 스캔",
+ "TaskExtractMediaSegmentsDescription": "MediaSegment를 지원하는 플러그인에서 미디어 세그먼트를 추출하거나 가져옵니다.",
+ "TaskMoveTrickplayImages": "트릭플레이 이미지 위치 마이그레이션",
+ "TaskMoveTrickplayImagesDescription": "추출된 트릭플레이 이미지를 라이브러리 설정에 따라 이동합니다.",
+ "TaskDownloadMissingLyrics": "누락된 가사 다운로드",
+ "TaskDownloadMissingLyricsDescription": "가사 다운로드"
}
diff --git a/Emby.Server.Implementations/Localization/Core/lb.json b/Emby.Server.Implementations/Localization/Core/lb.json
new file mode 100644
index 0000000000..176f2ba2b7
--- /dev/null
+++ b/Emby.Server.Implementations/Localization/Core/lb.json
@@ -0,0 +1,139 @@
+{
+ "Albums": "Alben",
+ "Application": "Applikatioun",
+ "Artists": "Kënschtler",
+ "Books": "Bicher",
+ "Channels": "Kanäl",
+ "Collections": "Kollektiounen",
+ "Default": "Standard",
+ "ChapterNameValue": "Kapitel {0}",
+ "DeviceOnlineWithName": "{0} ass Online",
+ "DeviceOfflineWithName": "{0} ass Offline",
+ "External": "Extern",
+ "Favorites": "Favoritten",
+ "Folders": "Dossieren",
+ "Forced": "Forcéiert",
+ "HeaderAlbumArtists": "Album Kënschtler",
+ "HeaderFavoriteAlbums": "Léifsten Alben",
+ "HeaderFavoriteArtists": "Léifsten Kënschtler",
+ "HeaderFavoriteEpisodes": "Léifsten Episoden",
+ "HeaderFavoriteShows": "Léifsten Shows",
+ "HeaderFavoriteSongs": "Léifsten Lidder",
+ "Genres": "Generen",
+ "HeaderContinueWatching": "Weider kucken",
+ "Inherit": "Iwwerhuelen",
+ "HeaderNextUp": "Als Nächst",
+ "HeaderRecordingGroups": "Opname Gruppen",
+ "HearingImpaired": "Daaf",
+ "HomeVideos": "Amateur Videoen",
+ "ItemRemovedWithName": "Element ewech geholl: {0}",
+ "LabelIpAddressValue": "IP Adress: {0}",
+ "LabelRunningTimeValue": "Lafzäit: {0}",
+ "Latest": "Dat Aktuellst",
+ "MessageApplicationUpdatedTo": "Jellyfin Server aktualiséiert op {0}",
+ "MessageNamedServerConfigurationUpdatedWithValue": "Server Konfiguratiounssektioun {0} aktualiséiert",
+ "MessageServerConfigurationUpdated": "Server Konfiguratioun aktualiséiert",
+ "Movies": "Filmer",
+ "Music": "Musek",
+ "NameInstallFailed": "{0} Installatioun net gelongen",
+ "NameSeasonNumber": "Staffel {0}",
+ "NameSeasonUnknown": "Staffel Onbekannt",
+ "MusicVideos": "Museksvideoen",
+ "NotificationOptionApplicationUpdateAvailable": "Applikatiouns Update verfügbar",
+ "NotificationOptionApplicationUpdateInstalled": "Applikatiouns Update nët Installéiert",
+ "NotificationOptionAudioPlayback": "Audio ofspillen gestart",
+ "NotificationOptionAudioPlaybackStopped": "Audio ofspillen gestoppt",
+ "NotificationOptionCameraImageUploaded": "Kamera Bild eropgelueden",
+ "NotificationOptionInstallationFailed": "Installatioun net gelongen",
+ "NotificationOptionNewLibraryContent": "Neien Bibliothéik Inhalt",
+ "NotificationOptionPluginError": "Plugin Feeler",
+ "NotificationOptionPluginInstalled": "Plugin installéiert",
+ "NotificationOptionPluginUninstalled": "Plugin desinstalléiert",
+ "NotificationOptionPluginUpdateInstalled": "Plugin Update installéiert",
+ "Photos": "Fotoen",
+ "NotificationOptionTaskFailed": "Aufgab net gelongen",
+ "NotificationOptionUserLockedOut": "Benotzer Gesperrt",
+ "NotificationOptionVideoPlaybackStopped": "Video ofspillen gestoppt",
+ "NotificationOptionVideoPlayback": "Video ofspillen gestartet",
+ "Plugin": "Plugin",
+ "PluginUninstalledWithName": "{0} desinstalléiert",
+ "PluginUpdatedWithName": "{0} aktualiséiert",
+ "ProviderValue": "Provider: {0}",
+ "ScheduledTaskFailedWithName": "Aufgab: {0} net gelongen",
+ "Playlists": "Playlëschten",
+ "Shows": "Shows",
+ "Songs": "Lidder",
+ "ServerNameNeedsToBeRestarted": "{0} muss nei gestart ginn",
+ "StartupEmbyServerIsLoading": "Jellyfin Server luedt. Probéier méi spéit nach eng Kéier.",
+ "Sync": "Synchroniséieren",
+ "System": "System",
+ "User": "Benotzer",
+ "TvShows": "TV Shows",
+ "Undefined": "Net definéiert",
+ "UserCreatedWithName": "Benotzer {0} erstellt",
+ "UserDownloadingItemWithValues": "{0} luet {1} erof",
+ "UserOfflineFromDevice": "{0} Benotzer Offline um Gerät {1}",
+ "UserLockedOutWithName": "Benotzer {0} gesperrt",
+ "UserOnlineFromDevice": "{0} Benotzer Online um Gerät {1}",
+ "UserPasswordChangedWithName": "Benotzer Passwuert geännert fir {0}",
+ "UserPolicyUpdatedWithName": "Benotzer Politik aktualiséiert fir: {0}",
+ "UserStartedPlayingItemWithValues": "{0} spillt {1} op {2} oof",
+ "ValueHasBeenAddedToLibrary": "{0} der Bibliothéik bäigefüügt",
+ "VersionNumber": "Versioun {0}",
+ "TasksMaintenanceCategory": "Ënnerhalt",
+ "TasksLibraryCategory": "Bibliothéik",
+ "ValueSpecialEpisodeName": "Spezial-Episodenumm",
+ "TasksChannelsCategory": "Internet Kanäl",
+ "TaskCleanActivityLog": "Aktivitéits Log botzen",
+ "TaskCleanActivityLogDescription": "Läscht Aktivitéitslogs méi al wéi konfiguréiert.",
+ "TaskCleanCache": "Aufgab Cache Botzen",
+ "TaskRefreshChapterImages": "Kapitel Biller erstellen",
+ "TaskRefreshChapterImagesDescription": "Erstellt Miniaturbiller fir Videoen, déi Kapitelen hunn.",
+ "TaskAudioNormalization": "Audio Normaliséierung",
+ "TaskRefreshLibrary": "Bibliothéik aktualiséieren",
+ "TaskRefreshLibraryDescription": "Scannt deng Mediebibliothéik no neien Dateien a frëscht d’Metadata op.",
+ "TaskCleanLogs": "Log Dateien botzen",
+ "TaskRefreshPeople": "Persounen aktualiséieren",
+ "TaskRefreshPeopleDescription": "Aktualiséiert Metadata fir Schauspiller a Regisseuren an denger Mediebibliothéik.",
+ "TaskRefreshTrickplayImagesDescription": "Erstellt Trickplay-Viraussiichten fir Videoen an aktivéierte Bibliothéiken.",
+ "TaskCleanTranscode": "Transkodéieren botzen",
+ "TaskCleanTranscodeDescription": "Läscht Transkodéierungsdateien, déi méi al wéi een Dag sinn.",
+ "TaskRefreshChannels": "Kanäl aktualiséieren",
+ "TaskDownloadMissingLyrics": "Fehlend Liddertexter eroflueden",
+ "TaskDownloadMissingLyricsDescription": "Lued Liddertexter fir Lidder erof",
+ "TaskDownloadMissingSubtitles": "Fehlend Ënnertitelen eroflueden",
+ "TaskOptimizeDatabase": "Datebank optiméieren",
+ "TaskKeyframeExtractor": "Schlësselbild Extrakter",
+ "TaskCleanCollectionsAndPlaylists": "Sammlungen a Playlisten botzen",
+ "TaskCleanCollectionsAndPlaylistsDescription": "Ewechhuele vun Elementer aus Sammlungen a Playlisten, déi net méi existéieren.",
+ "TaskExtractMediaSegments": "Mediesegment-Scan",
+ "NewVersionIsAvailable": "Nei Versioun fir Jellyfin Server ass verfügbar.",
+ "CameraImageUploadedFrom": "En neit Kamera Bild gouf vu {0} eropgelueden",
+ "PluginInstalledWithName": "{0} installéiert",
+ "TaskMoveTrickplayImagesDescription": "Verschëfft existent Trickplay-Dateien no de Bibliothéik-Astellungen.",
+ "AppDeviceValues": "App: {0}, Geräter: {1}",
+ "FailedLoginAttemptWithUserName": "Net Gelongen Umeldung {0}",
+ "HeaderLiveTV": "LiveTV",
+ "ItemAddedWithName": "Element derbäi gesat: {0}",
+ "NotificationOptionServerRestartRequired": "Server Restart Erfuerderlech",
+ "ScheduledTaskStartedWithName": "Aufgab: {0} gestart",
+ "AuthenticationSucceededWithUserName": "{0} Authentifikatioun gelongen",
+ "MixedContent": "Gemëschten Inhalt",
+ "MessageApplicationUpdated": "Jellyfin Server Aktualiséiert",
+ "SubtitleDownloadFailureFromForItem": "Ënnertitel Download Feeler vun {0} fir {1}",
+ "TaskCleanLogsDescription": "Läscht Log-Dateien, déi méi al wéi {0} Deeg sinn.",
+ "TaskUpdatePlugins": "Plugins aktualiséieren",
+ "UserDeletedWithName": "Benotzer {0} geläscht",
+ "TasksApplicationCategory": "Applikatioun",
+ "TaskCleanCacheDescription": "Läscht Cache-Dateien, déi net méi vum System gebraucht ginn.",
+ "UserStoppedPlayingItemWithValues": "{0} ass mat {1} op {2} fäerdeg",
+ "TaskAudioNormalizationDescription": "Scannt Dateien no Donnéeën fir d’Audio-Normaliséierung.",
+ "TaskRefreshTrickplayImages": "Trickplay-Biller generéieren",
+ "TaskDownloadMissingSubtitlesDescription": "Sicht am Internet no fehlenden Ënnertitelen op Basis vun der Metadata-Konfiguratioun.",
+ "TaskMoveTrickplayImages": "Trickplay-Biller-Plaz migréieren",
+ "TaskUpdatePluginsDescription": "Lued Aktualiséierungen erof a installéiert se fir Plugins, déi fir automatesch Updates konfiguréiert sinn.",
+ "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.",
+ "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."
+}
diff --git a/Emby.Server.Implementations/Localization/Core/lt-LT.json b/Emby.Server.Implementations/Localization/Core/lt-LT.json
index 95f738bd55..46fc49f5e4 100644
--- a/Emby.Server.Implementations/Localization/Core/lt-LT.json
+++ b/Emby.Server.Implementations/Localization/Core/lt-LT.json
@@ -94,14 +94,14 @@
"VersionNumber": "Version {0}",
"TaskUpdatePluginsDescription": "Atsisiųsti ir įdiegti atnaujinimus priedams kuriem yra nustatytas automatiškas atnaujinimas.",
"TaskUpdatePlugins": "Atnaujinti Priedus",
- "TaskDownloadMissingSubtitlesDescription": "Ieško internete trūkstamų subtitrų remiantis metaduomenų konfigūracija.",
+ "TaskDownloadMissingSubtitlesDescription": "Ieško trūkstamų subtitrų internete remiantis metaduomenų konfigūracija.",
"TaskCleanTranscodeDescription": "Ištrina dienos senumo perkodavimo failus.",
"TaskCleanTranscode": "Išvalyti Perkodavimo Direktorija",
"TaskRefreshLibraryDescription": "Ieškoti naujų failų jūsų mediatekoje ir atnaujina metaduomenis.",
"TaskRefreshLibrary": "Skenuoti Mediateka",
"TaskDownloadMissingSubtitles": "Atsisiųsti trūkstamus subtitrus",
- "TaskRefreshChannelsDescription": "Atnaujina internetinių kanalų informacija.",
- "TaskRefreshChannels": "Atnaujinti Kanalus",
+ "TaskRefreshChannelsDescription": "Atnaujina internetinių kanalų informaciją.",
+ "TaskRefreshChannels": "Atnaujinti kanalus",
"TaskRefreshPeopleDescription": "Atnaujina metaduomenis apie aktorius ir režisierius jūsų mediatekoje.",
"TaskRefreshPeople": "Atnaujinti Žmones",
"TaskCleanLogsDescription": "Ištrina žurnalo failus kurie yra senesni nei {0} dienos.",
@@ -119,22 +119,22 @@
"Forced": "Priverstas",
"Default": "Numatytas",
"TaskCleanActivityLogDescription": "Ištrina veiklos žuranlo įrašus, kurie yra senesni nei nustatytas amžius.",
- "TaskOptimizeDatabase": "Optimizuoti duomenų bazės",
+ "TaskOptimizeDatabase": "Optimizuoti duomenų bazę",
"TaskKeyframeExtractorDescription": "Iš vaizdo įrašo paruošia reikšminius kadrus, kad būtų sukuriamas tikslenis HLS grojaraštis. Šios užduoties vykdymas gali ilgai užtrukti.",
- "TaskKeyframeExtractor": "Pagrindinių kadrų ištraukėjas",
- "TaskOptimizeDatabaseDescription": "Suspaudžia duomenų bazę ir atlaisvina vietą. Paleidžiant šią užduotį, po bibliotekos skenavimo arba kitų veiksmų kurie galimai modifikuoja duomenų bazė, gali pagerinti greitaveiką.",
+ "TaskKeyframeExtractor": "Pagrindinių kadrų išgavėjas",
+ "TaskOptimizeDatabaseDescription": "Suspaudžia duomenų bazę ir atlaisvina vietą. Paleidžiant šią užduotį, po bibliotekos skenavimo arba kitų veiksmų kurie galimai modifikuoja duomenų bazę, gali pagerinti greitaveiką.",
"External": "Išorinis",
"HearingImpaired": "Su klausos sutrikimais",
"TaskRefreshTrickplayImages": "Generuoti Trickplay atvaizdus",
"TaskRefreshTrickplayImagesDescription": "Sukuria trickplay peržiūras vaizdo įrašams įgalintose bibliotekose.",
- "TaskCleanCollectionsAndPlaylists": "Sutvarko duomenis jūsų kolekcijose ir grojaraščiuose",
- "TaskCleanCollectionsAndPlaylistsDescription": "Pašalina nebeegzistuojančius elementus iš kolekcijų ir grojaraščių.",
+ "TaskCleanCollectionsAndPlaylists": "Išvalo duomenis kolekcijose ir grojaraščiuose",
+ "TaskCleanCollectionsAndPlaylistsDescription": "Pašalina neegzistuojančius elementus iš kolekcijų ir grojaraščių.",
"TaskAudioNormalization": "Garso Normalizavimas",
"TaskAudioNormalizationDescription": "Skenuoti garso normalizavimo informacijos failuose.",
- "TaskExtractMediaSegments": "Medijos Segmentų Nuskaitymas",
+ "TaskExtractMediaSegments": "Medijos segmentų nuskaitymas",
"TaskDownloadMissingLyrics": "Parsisiųsti trūkstamus dainų tekstus",
"TaskExtractMediaSegmentsDescription": "Ištraukia arba gauna medijos segmentus iš MediaSegment ijungtų papildinių.",
- "TaskMoveTrickplayImages": "Migruoti Trickplay Vaizdų Vietą",
- "TaskMoveTrickplayImagesDescription": "Perkelia egzisuojančius trickplay failus pagal bibliotekos nustatymus.",
+ "TaskMoveTrickplayImages": "Pakeisti Trickplay vaizdų vietą",
+ "TaskMoveTrickplayImagesDescription": "Perkelia egzistuojančius trickplay failus pagal bibliotekos nustatymus.",
"TaskDownloadMissingLyricsDescription": "Parsisiųsti dainų žodžius"
}
diff --git a/Emby.Server.Implementations/Localization/Core/lv.json b/Emby.Server.Implementations/Localization/Core/lv.json
index 62277fd94a..77340a57ad 100644
--- a/Emby.Server.Implementations/Localization/Core/lv.json
+++ b/Emby.Server.Implementations/Localization/Core/lv.json
@@ -123,11 +123,17 @@
"External": "Ārējais",
"HearingImpaired": "Ar dzirdes traucējumiem",
"TaskKeyframeExtractor": "Atslēgkadru ekstraktors",
- "TaskKeyframeExtractorDescription": "Ekstraktē atslēgkadrus no video failiem lai izveidotu precīzākus HLS atskaņošanas sarakstus. Šis process var būt ilgs.",
+ "TaskKeyframeExtractorDescription": "Izvelk atslēgkadrus no video failiem lai izveidotu precīzākus HLS atskaņošanas sarakstus. Šis process var būt ilgs.",
"TaskRefreshTrickplayImages": "Ģenerēt partīšanas attēlus",
"TaskRefreshTrickplayImagesDescription": "Izveido priekšskatījumus videoklipu pārtīšanai iespējotajās bibliotēkās.",
"TaskAudioNormalization": "Audio normalizācija",
"TaskCleanCollectionsAndPlaylistsDescription": "Noņem vairs neeksistējošus vienumus no kolekcijām un atskaņošanas sarakstiem.",
"TaskAudioNormalizationDescription": "Skanē failus priekš audio normālizācijas informācijas.",
- "TaskCleanCollectionsAndPlaylists": "Notīrīt kolekcijas un atskaņošanas sarakstus"
+ "TaskCleanCollectionsAndPlaylists": "Notīrīt kolekcijas un atskaņošanas sarakstus",
+ "TaskExtractMediaSegments": "Multivides segmenta skenēšana",
+ "TaskExtractMediaSegmentsDescription": "Izvelk vai iegūst multivides segmentus no MediaSegment iespējotiem spraudņiem.",
+ "TaskMoveTrickplayImages": "Trickplay attēlu pārvietošana",
+ "TaskMoveTrickplayImagesDescription": "Pārvieto esošos trickplay failus atbilstoši bibliotēkas iestatījumiem.",
+ "TaskDownloadMissingLyrics": "Lejupielādēt trūkstošos vārdus",
+ "TaskDownloadMissingLyricsDescription": "Lejupielādēt vārdus dziesmām"
}
diff --git a/Emby.Server.Implementations/Localization/Core/mk.json b/Emby.Server.Implementations/Localization/Core/mk.json
index e149f8adfd..6da31227d7 100644
--- a/Emby.Server.Implementations/Localization/Core/mk.json
+++ b/Emby.Server.Implementations/Localization/Core/mk.json
@@ -131,5 +131,6 @@
"TaskRefreshTrickplayImages": "Генерирај слики за прегледување (Trickplay)",
"TaskAudioNormalization": "Нормализација на звукот",
"TaskRefreshTrickplayImagesDescription": "Креира трикплеј прегледи за видеа во овозможените библиотеки.",
- "TaskCleanCollectionsAndPlaylistsDescription": "Отстранува ставки од колекциите и плејлистите што веќе не постојат."
+ "TaskCleanCollectionsAndPlaylistsDescription": "Отстранува ставки од колекциите и плејлистите што веќе не постојат.",
+ "TaskExtractMediaSegments": "Скенирање на сегменти на содржина"
}
diff --git a/Emby.Server.Implementations/Localization/Core/ms.json b/Emby.Server.Implementations/Localization/Core/ms.json
index ebd3f7560b..a3fc7881e3 100644
--- a/Emby.Server.Implementations/Localization/Core/ms.json
+++ b/Emby.Server.Implementations/Localization/Core/ms.json
@@ -9,14 +9,14 @@
"Channels": "Saluran",
"ChapterNameValue": "Bab {0}",
"Collections": "Koleksi",
- "DeviceOfflineWithName": "{0} telah diputuskan sambungan",
+ "DeviceOfflineWithName": "{0} telah dinyahsambung",
"DeviceOnlineWithName": "{0} telah disambung",
- "FailedLoginAttemptWithUserName": "Cubaan log masuk gagal dari {0}",
+ "FailedLoginAttemptWithUserName": "Percubaan gagal log masuk daripada {0}",
"Favorites": "Kegemaran",
- "Folders": "Fail-fail",
+ "Folders": "Folder-folder",
"Genres": "Genre-genre",
- "HeaderAlbumArtists": "Album Artis-artis",
- "HeaderContinueWatching": "Terus Menonton",
+ "HeaderAlbumArtists": "Album artis-artis",
+ "HeaderContinueWatching": "Teruskan Menonton",
"HeaderFavoriteAlbums": "Album-album Kegemaran",
"HeaderFavoriteArtists": "Artis-artis Kegemaran",
"HeaderFavoriteEpisodes": "Episod-episod Kegemaran",
@@ -25,26 +25,26 @@
"HeaderLiveTV": "TV Siaran Langsung",
"HeaderNextUp": "Seterusnya",
"HeaderRecordingGroups": "Kumpulan-kumpulan Rakaman",
- "HomeVideos": "Video Personal",
- "Inherit": "Mewarisi",
- "ItemAddedWithName": "{0} telah ditambahkan ke dalam pustaka",
+ "HomeVideos": "Video Peribadi",
+ "Inherit": "Warisi",
+ "ItemAddedWithName": "{0} telah ditambah ke dalam pustaka",
"ItemRemovedWithName": "{0} telah dibuang daripada pustaka",
"LabelIpAddressValue": "Alamat IP: {0}",
"LabelRunningTimeValue": "Masa berjalan: {0}",
- "Latest": "Terbaru",
- "MessageApplicationUpdated": "Jellyfin Server telah dikemas kini",
- "MessageApplicationUpdatedTo": "Jellyfin Server telah dikemas kini ke {0}",
- "MessageNamedServerConfigurationUpdatedWithValue": "Konfigurasi pelayan di bahagian {0} telah dikemas kini",
+ "Latest": "Terbaharu",
+ "MessageApplicationUpdated": "Pelayan Jellyfin telah dikemas kini",
+ "MessageApplicationUpdatedTo": "Pelayan Jellyfin telah dikemas kini ke {0}",
+ "MessageNamedServerConfigurationUpdatedWithValue": "Konfigurasi pelayan bahagian {0} telah dikemas kini",
"MessageServerConfigurationUpdated": "Konfigurasi pelayan telah dikemas kini",
"MixedContent": "Kandungan campuran",
"Movies": "Filem-filem",
"Music": "Muzik",
"MusicVideos": "Video Muzik",
"NameInstallFailed": "{0} pemasangan gagal",
- "NameSeasonNumber": "Musim {0}",
+ "NameSeasonNumber": "Musim ke-{0}",
"NameSeasonUnknown": "Musim Tidak Diketahui",
- "NewVersionIsAvailable": "Versi terbaru Jellyfin Server bersedia untuk dimuat turunkan.",
- "NotificationOptionApplicationUpdateAvailable": "Kemas kini aplikasi telah sedia",
+ "NewVersionIsAvailable": "Versi terbaharu Pelayan Jellyfin telah tersedia untuk dimuat turun.",
+ "NotificationOptionApplicationUpdateAvailable": "Kemas kini aplikasi telah tersedia",
"NotificationOptionApplicationUpdateInstalled": "Kemas kini aplikasi telah dipasang",
"NotificationOptionAudioPlayback": "Ulangmain audio bermula",
"NotificationOptionAudioPlaybackStopped": "Ulangmain audio dihentikan",
@@ -98,8 +98,8 @@
"TasksLibraryCategory": "Perpustakaan",
"TasksMaintenanceCategory": "Penyelenggaraan",
"Undefined": "Tidak ditentukan",
- "Forced": "Paksa",
- "Default": "Asal",
+ "Forced": "Dipaksa",
+ "Default": "Lalai",
"TaskCleanCache": "Bersihkan Direktori Cache",
"TaskCleanActivityLogDescription": "Padamkan entri log aktiviti yang lebih tua daripada usia yang dikonfigurasi.",
"TaskRefreshPeople": "Segarkan Orang",
@@ -126,5 +126,15 @@
"TaskKeyframeExtractor": "Ekstrak bingkai kunci",
"TaskKeyframeExtractorDescription": "Ekstrak bingkai kunci dari fail video untuk membina HLS playlist yang lebih tepat. Tugas ini mungkin perlukan masa yang panjang.",
"TaskRefreshTrickplayImagesDescription": "Jana gambar prebiu Trickplay untuk video dalam perpustakaan.",
- "TaskRefreshTrickplayImages": "Jana gambar Trickplay"
+ "TaskRefreshTrickplayImages": "Jana gambar Trickplay",
+ "TaskExtractMediaSegments": "Imbasan Segmen Media",
+ "TaskExtractMediaSegmentsDescription": "Mengekstrak atau mendapatkan segmen media daripada pemalam yang didayakan MediaSegment.",
+ "TaskMoveTrickplayImagesDescription": "Mengalihkan fail trickplay sedia ada mengikut tetapan pustakan digital.",
+ "TaskDownloadMissingLyrics": "Muat turun lirik yang hilang",
+ "TaskDownloadMissingLyricsDescription": "Memuat turun lirik-lirik untuk lagu-lagu",
+ "TaskMoveTrickplayImages": "Alih Lokasi Imej Trickplay",
+ "TaskCleanCollectionsAndPlaylists": "Bersihkan koleksi dan senarai audio video",
+ "TaskAudioNormalization": "Normalisasi Audio",
+ "TaskAudioNormalizationDescription": "Mengimbas fail-fail untuk data normalisasi audio.",
+ "TaskCleanCollectionsAndPlaylistsDescription": "Mengalih keluar item daripada koleksi dan senarai audio video yang tidak wujud lagi."
}
diff --git a/Emby.Server.Implementations/Localization/Core/mt.json b/Emby.Server.Implementations/Localization/Core/mt.json
index c9e11165de..f7501ab404 100644
--- a/Emby.Server.Implementations/Localization/Core/mt.json
+++ b/Emby.Server.Implementations/Localization/Core/mt.json
@@ -1,86 +1,86 @@
{
"Albums": "Albums",
- "AppDeviceValues": "App: {0}, Apparat: {1}",
+ "AppDeviceValues": "Applikazzjoni: {0}, Device: {1}",
"Application": "Applikazzjoni",
"Artists": "Artisti",
"AuthenticationSucceededWithUserName": "{1} awtentikat b'suċċess",
"Books": "Kotba",
- "CameraImageUploadedFrom": "Ttellgħet immaġni ġdida tal-kamera minn {1}",
- "Channels": "Kanali",
+ "CameraImageUploadedFrom": "Ttella' ritratt ġdid tal-kamera minn {1}",
+ "Channels": "Stazzjonijiet",
"ChapterNameValue": "Kapitlu {0}",
"Collections": "Kollezzjonijiet",
- "DeviceOfflineWithName": "{0} inqatgħa",
- "DeviceOnlineWithName": "{0} qabad",
+ "DeviceOfflineWithName": "{0} tneħħa",
+ "DeviceOnlineWithName": "{0} tqabbad",
"External": "Estern",
- "FailedLoginAttemptWithUserName": "Tentattiv t'aċċess fallut minn {0}",
+ "FailedLoginAttemptWithUserName": "Attentat fallut ta' login minn {0}",
"Favorites": "Favoriti",
"Forced": "Sfurzat",
"Genres": "Ġeneri",
"HeaderAlbumArtists": "Artisti tal-album",
- "HeaderContinueWatching": "Kompli Segwi",
+ "HeaderContinueWatching": "Kompli Ara",
"HeaderFavoriteAlbums": "Albums Favoriti",
"HeaderFavoriteArtists": "Artisti Favoriti",
"HeaderFavoriteEpisodes": "Episodji Favoriti",
"HeaderFavoriteShows": "Programmi Favoriti",
"HeaderFavoriteSongs": "Kanzunetti Favoriti",
"HeaderNextUp": "Li Jmiss",
- "SubtitleDownloadFailureFromForItem": "Is-sottotitli naqsu milli jitniżżlu minn {0} għal {1}",
- "UserPasswordChangedWithName": "Il-password inbidel għall-utent {0}",
+ "SubtitleDownloadFailureFromForItem": "Is-sottotitli ma setgħux jitniżżlu minn {0} għal {1}",
+ "UserPasswordChangedWithName": "Il-password għall-utent {0} inbidlet",
"TaskUpdatePluginsDescription": "Iniżżel u jinstalla aġġornamenti għal plugins li huma kkonfigurati biex jaġġornaw awtomatikament.",
- "TaskDownloadMissingSubtitlesDescription": "Ifittex fuq l-internet għal sottotitli neqsin abbażi tal-konfigurazzjoni tal-metadata.",
- "TaskOptimizeDatabaseDescription": "Jikkompatti d-database u jaqta' l-ispazju ħieles. It-tħaddim ta' dan il-kompitu wara li tiskennja l-librerija jew tagħmel bidliet oħra li jimplikaw modifiki fid-database jistgħu jtejbu l-prestazzjoni.",
+ "TaskDownloadMissingSubtitlesDescription": "Ifittex fuq l-internet għal sottotitli neqsin skont il-konfigurazzjoni tal-metadata.",
+ "TaskOptimizeDatabaseDescription": "Jikkompatta d-database u jaqta' l-ispazju ħieles. It-tħaddim ta' dan it-task wara li tiskennja l-librerija jew tagħmel bidliet oħra li jimplikaw modifiki fid-database jistgħu jtejbu l-mod kif jaħdem.",
"Default": "Standard",
"Folders": "Folders",
"HeaderLiveTV": "TV Dirett",
- "HeaderRecordingGroups": "Gruppi ta' Reġistrazzjoni",
+ "HeaderRecordingGroups": "Gruppi ta' Rikordjar",
"HearingImpaired": "Nuqqas ta' Smigħ",
- "HomeVideos": "Vidjows Personali",
+ "HomeVideos": "Filmati Personali",
"Inherit": "Jiret",
- "ItemAddedWithName": "{0} ġie miżjud mal-librerija",
+ "ItemAddedWithName": "{0} żdied fil-librerija",
"ItemRemovedWithName": "{0} tneħħa mil-librerija",
- "LabelIpAddressValue": "Indirizz IP: {0}",
+ "LabelIpAddressValue": "Indirizz tal-IP: {0}",
"Latest": "Tal-Aħħar",
- "MessageApplicationUpdated": "Jellyfin Server ġie aġġornat",
- "MessageApplicationUpdatedTo": "JellyFin Server ġie aġġornat għal {0}",
+ "MessageApplicationUpdated": "Il-Jellyfin Server ġie aġġornat",
+ "MessageApplicationUpdatedTo": "Il-JellyFin Server ġie aġġornat għal {0}",
"MessageNamedServerConfigurationUpdatedWithValue": "Is-sezzjoni {0} tal-konfigurazzjoni tas-server ġiet aġġornata",
"MessageServerConfigurationUpdated": "Il-konfigurazzjoni tas-server ġiet aġġornata",
"MixedContent": "Kontenut imħallat",
"Movies": "Films",
"Music": "Mużika",
- "MusicVideos": "Vidjows tal-Mużika",
+ "MusicVideos": "Music Videos",
"NameInstallFailed": "L-installazzjoni ta' {0} falliet",
"NameSeasonNumber": "Staġun {0}",
"NameSeasonUnknown": "Staġun Mhux Magħruf",
- "NewVersionIsAvailable": "Verżjoni ġdida ta' Jellyfin Server hija disponibbli biex titniżżel.",
- "NotificationOptionApplicationUpdateAvailable": "Aġġornament tal-applikazzjoni disponibbli",
- "NotificationOptionCameraImageUploaded": "Immaġini tal-kamera mtella'",
+ "NewVersionIsAvailable": "Verżjoni ġdida tal-Jellyfin Server hija disponibbli biex titniżżel.",
+ "NotificationOptionApplicationUpdateAvailable": "Hemm aġġornament tal-applikazzjoni",
+ "NotificationOptionCameraImageUploaded": "Ritratt tal-kamera mtella'",
"LabelRunningTimeValue": "Tul: {0}",
"NotificationOptionApplicationUpdateInstalled": "Aġġornament tal-applikazzjoni ġie installat",
- "NotificationOptionAudioPlayback": "Il-playback tal-awdjo beda",
+ "NotificationOptionAudioPlayback": "Beda l-playback tal-awdjo",
"NotificationOptionAudioPlaybackStopped": "Il-playback tal-awdjo twaqqaf",
- "NotificationOptionInstallationFailed": "Installazzjoni falliet",
- "NotificationOptionNewLibraryContent": "Kontenut ġdid miżjud",
- "NotificationOptionPluginError": "Ħsara fil-plugin",
+ "NotificationOptionInstallationFailed": "L-Installazzjoni falliet",
+ "NotificationOptionNewLibraryContent": "Kontenut ġdid żdied",
+ "NotificationOptionPluginError": "Falliment fil-plugin",
"NotificationOptionPluginInstalled": "Plugin installat",
"NotificationOptionPluginUninstalled": "Plugin tneħħa",
- "NotificationOptionServerRestartRequired": "Meħtieġ l-istartjar mill-ġdid tas-server",
- "NotificationOptionTaskFailed": "Falliment tal-kompitu skedat",
+ "NotificationOptionServerRestartRequired": "Hemm bżonn li tagħmel restart tas-server",
+ "NotificationOptionTaskFailed": "Falliment tat-task skedat",
"NotificationOptionUserLockedOut": "Utent imsakkar",
"Photos": "Ritratti",
"Playlists": "Playlists",
"Plugin": "Plugin",
"PluginInstalledWithName": "{0} ġie installat",
- "PluginUninstalledWithName": "{0} ġie mneħħi",
+ "PluginUninstalledWithName": "{0} tneħħa",
"PluginUpdatedWithName": "{0} ġie aġġornat",
"ProviderValue": "Fornitur: {0}",
"ScheduledTaskFailedWithName": "{0} falla",
"ScheduledTaskStartedWithName": "{0} beda",
- "ServerNameNeedsToBeRestarted": "{0} jeħtieġ li jerġa' jinbeda",
+ "ServerNameNeedsToBeRestarted": "{0} jeħtieġ restart",
"Songs": "Kanzunetti",
- "StartupEmbyServerIsLoading": "Jellyfin Server qed jixgħel. Jekk jogħġbok erġa' pprova dalwaqt.",
+ "StartupEmbyServerIsLoading": "Jellyfin Server qed jillowdja. Jekk jogħġbok erġa' pprova ftit tal-ħin oħra.",
"Sync": "Sinkronizza",
"System": "Sistema",
- "Undefined": "Mhux Definit",
+ "Undefined": "Bla Definizzjoni",
"User": "Utent",
"UserCreatedWithName": "L-utent {0} inħoloq",
"UserDeletedWithName": "L-utent {0} tħassar",
@@ -89,45 +89,51 @@
"UserOfflineFromDevice": "{0} skonnettja minn {1}",
"UserOnlineFromDevice": "{0} huwa online minn {1}",
"NotificationOptionPluginUpdateInstalled": "Aġġornament ta' plugin ġie installat",
- "NotificationOptionVideoPlayback": "Il-playback tal-vidjow beda",
- "NotificationOptionVideoPlaybackStopped": "Il-playback tal-vidjow waqaf",
- "Shows": "Programmi",
- "TvShows": "Programmi tat-TV",
- "UserPolicyUpdatedWithName": "Il-policy tal-utent ġiet aġġornata għal {0}",
- "UserStartedPlayingItemWithValues": "{0} qed iħaddem {1} fuq {2}",
- "UserStoppedPlayingItemWithValues": "{0} waqaf iħaddem {1} fuq {2}",
+ "NotificationOptionVideoPlayback": "Il-playback tal-filmat beda",
+ "NotificationOptionVideoPlaybackStopped": "Il-playback tal-filmat twaqqaf",
+ "Shows": "Serje",
+ "TvShows": "Serje Televiżivi",
+ "UserPolicyUpdatedWithName": "Il-politka tal-utent ġiet aġġornata għal {0}",
+ "UserStartedPlayingItemWithValues": "{0} qed jara {1} fuq {2}",
+ "UserStoppedPlayingItemWithValues": "{0} waqaf jara {1} fuq {2}",
"ValueHasBeenAddedToLibrary": "{0} ġie miżjud mal-librerija tal-midja tiegħek",
"ValueSpecialEpisodeName": "Speċjali - {0}",
"VersionNumber": "Verżjoni {0}",
"TasksMaintenanceCategory": "Manutenzjoni",
"TasksLibraryCategory": "Librerija",
"TasksApplicationCategory": "Applikazzjoni",
- "TasksChannelsCategory": "Kanali tal-Internet",
+ "TasksChannelsCategory": "Stazzjonijiet tal-Internet",
"TaskCleanActivityLog": "Naddaf il-Logg tal-Attività",
- "TaskCleanActivityLogDescription": "Iħassar l-entrati tar-reġistru tal-attività eqdem mill-età kkonfigurata.",
+ "TaskCleanActivityLogDescription": "Iħassar id-daħliet tar-reġistru tal-attività eqdem mill-età li kienet kkonfigurata.",
"TaskCleanCache": "Naddaf id-Direttorju tal-Cache",
"TaskCleanCacheDescription": "Iħassar il-fajls tal-cache li m'għadhomx meħtieġa mis-sistema.",
- "TaskRefreshChapterImages": "Oħroġ l-Immaġini tal-Kapitolu",
+ "TaskRefreshChapterImages": "Oħroġ ir-Ritratti tal-Kapitlu",
"TaskRefreshChapterImagesDescription": "Joħloq thumbnails għal vidjows li għandhom kapitli.",
- "TaskAudioNormalization": "Normalizzazzjoni Awdjo",
- "TaskAudioNormalizationDescription": "Skennja fajls għal data ta' normalizzazzjoni awdjo.",
+ "TaskAudioNormalization": "Normalizzazzjoni tal-Awdjo",
+ "TaskAudioNormalizationDescription": "Skennja fajls għal data fuq in-normalizzazzjoni tal-awdjo.",
"TaskRefreshLibrary": "Skennja l-Librerija tal-Midja",
"TaskRefreshLibraryDescription": "Jiskennja l-librerija tal-midja tiegħek għal fajls ġodda u jġedded il-metadejta.",
"TaskCleanLogs": "Naddaf id-Direttorju tal-Logg",
"TaskCleanLogsDescription": "Iħassar fajls tal-logg eqdem minn {0} ijiem.",
- "TaskRefreshPeople": "Aġġorna Persuni",
- "TaskRefreshPeopleDescription": "Jaġġorna l-metadejta għall-atturi u d-diretturi fil-librerija tal-midja tiegħek.",
+ "TaskRefreshPeople": "Aġġorna l-Persuni",
+ "TaskRefreshPeopleDescription": "Jaġġorna l-metadata għall-atturi u d-diretturi fil-librerija tal-midja tiegħek.",
"TaskRefreshTrickplayImages": "Iġġenera Stampi Trickplay",
- "TaskRefreshTrickplayImagesDescription": "Joħloq previews trickplay għal vidjows fil-libreriji attivati.",
- "TaskUpdatePlugins": "Aġġorna il-Plugins",
- "TaskCleanTranscode": "Naddaf id-Direttorju tat-Transcode",
- "TaskCleanTranscodeDescription": "Iħassar fajls transcode eqdem minn ġurnata.",
- "TaskRefreshChannels": "Aġġorna l-Kanali",
- "TaskRefreshChannelsDescription": "Aġġorna l-informazzjoni tal-kanali tal-internet.",
+ "TaskRefreshTrickplayImagesDescription": "Joħloq previews trickplay għal videos fil-libreriji li għalihom hi attivata.",
+ "TaskUpdatePlugins": "Aġġorna l-Plugins",
+ "TaskCleanTranscode": "Naddaf id-Direttorju tat-Transcoding",
+ "TaskCleanTranscodeDescription": "Iħassar fajls tat-transcoding li huma eqdem minn ġurnata.",
+ "TaskRefreshChannels": "Aġġorna l-Istazzjonijiet",
+ "TaskRefreshChannelsDescription": "Aġġorna l-informazzjoni tal-istazzjonijiet tal-internet.",
"TaskDownloadMissingSubtitles": "Niżżel is-sottotitli nieqsa",
- "TaskOptimizeDatabase": "Ottimizza d-database",
+ "TaskOptimizeDatabase": "Ottimiżża d-database",
"TaskKeyframeExtractor": "Estrattur ta' Keyframes",
- "TaskKeyframeExtractorDescription": "Jiġbed il-keyframes mill-fajls tal-vidjow biex joħloq playlists HLS aktar preċiżi. Dan il-kompitu jista' jdum għal żmien twil.",
+ "TaskKeyframeExtractorDescription": "Jiġbed il-keyframes mill-fajls tal-videos biex jagħmel playlists HLS aktar preċiżi. Dan it-task jista' jdum żmien twil biex ilesti.",
"TaskCleanCollectionsAndPlaylists": "Naddaf il-kollezzjonijiet u l-playlists",
- "TaskCleanCollectionsAndPlaylistsDescription": "Ineħħi oġġetti minn kollezzjonijiet u playlists li m'għadhomx jeżistu."
+ "TaskCleanCollectionsAndPlaylistsDescription": "Ineħħi oġġetti minn kollezzjonijiet u playlists li m'għadhomx jeżistu.",
+ "TaskDownloadMissingLyrics": "Niżżel il-lirika nieqsa",
+ "TaskDownloadMissingLyricsDescription": "Iniżżel il-lirika għal-kanzunetti",
+ "TaskExtractMediaSegments": "Scan tas-Sezzjoni tal-Midja",
+ "TaskExtractMediaSegmentsDescription": "Jestratta jew iġib sezzjonijiet tal-midja minn plugins attivati tal-MediaSegment.",
+ "TaskMoveTrickplayImages": "Mexxi l-post tat-Trickplay Image",
+ "TaskMoveTrickplayImagesDescription": "Tmexxi l-files tat-trickplay li jeżistu skont kif inhi kkonfigurata l-librerija."
}
diff --git a/Emby.Server.Implementations/Localization/Core/nl.json b/Emby.Server.Implementations/Localization/Core/nl.json
index 2327a73a99..8828eadcb5 100644
--- a/Emby.Server.Implementations/Localization/Core/nl.json
+++ b/Emby.Server.Implementations/Localization/Core/nl.json
@@ -11,7 +11,7 @@
"Collections": "Collecties",
"DeviceOfflineWithName": "Verbinding met {0} is verbroken",
"DeviceOnlineWithName": "{0} is verbonden",
- "FailedLoginAttemptWithUserName": "Mislukte aanmeldpoging vanaf {0}",
+ "FailedLoginAttemptWithUserName": "Mislukte aanmeldpoging van {0}",
"Favorites": "Favorieten",
"Folders": "Mappen",
"Genres": "Genres",
@@ -117,7 +117,7 @@
"TaskCleanActivityLogDescription": "Verwijdert activiteitenlogs ouder dan de ingestelde leeftijd.",
"TaskCleanActivityLog": "Activiteitenlogboek legen",
"Undefined": "Niet gedefinieerd",
- "Forced": "Geforceerd",
+ "Forced": "Gedwongen",
"Default": "Standaard",
"TaskOptimizeDatabaseDescription": "Comprimeert de database en trimt vrije ruimte. Het uitvoeren van deze taak kan de prestaties verbeteren, na het scannen van de bibliotheek of andere aanpassingen die invloed hebben op de database.",
"TaskOptimizeDatabase": "Database optimaliseren",
diff --git a/Emby.Server.Implementations/Localization/Core/pa.json b/Emby.Server.Implementations/Localization/Core/pa.json
index a25099ee0b..6062d97003 100644
--- a/Emby.Server.Implementations/Localization/Core/pa.json
+++ b/Emby.Server.Implementations/Localization/Core/pa.json
@@ -120,5 +120,20 @@
"Albums": "ਐਲਬਮਾਂ",
"TaskOptimizeDatabase": "ਡਾਟਾਬੇਸ ਅਨੁਕੂਲ ਬਣਾਓ",
"External": "ਬਾਹਰੀ",
- "HearingImpaired": "ਸੁਨਣ ਵਿਚ ਕਮਜ਼ੋਰ"
+ "HearingImpaired": "ਸੁਨਣ ਵਿਚ ਕਮਜ਼ੋਰ",
+ "TaskAudioNormalizationDescription": "ਆਵਾਜ਼ ਸਧਾਰਣੀਕਰਨ ਡਾਟਾ ਲਈ ਫਾਇਲਾਂ ਖੋਜੋ।",
+ "TaskRefreshTrickplayImages": "ਟ੍ਰਿਕਪਲੇ ਤਸਵੀਰਾਂ ਤਿਆਰ ਕਰੋ",
+ "TaskExtractMediaSegments": "ਮੀਡੀਆ ਸੈਗਮੈਂਟ ਸਕੈਨ",
+ "TaskMoveTrickplayImagesDescription": "ਟ੍ਰਿਕਪਲੇ ਤਸਵੀਰਾਂ ਦੀ ਜਗਾ ਨੂੰ ਲਾਇਬ੍ਰੇਰੀ ਸੈਟਿੰਗਜ਼ ਅਨੁਸਾਰ ਬਦਲੋ।",
+ "TaskOptimizeDatabaseDescription": "ਡੇਟਾਬੇਸ ਨੂੰ ਸੰਗ੍ਰਹਿਤ ਕਰਦਾ ਹੈ ਅਤੇ ਖਾਲੀ ਜਗ੍ਹਾ ਘਟਾਉਂਦਾ ਹੈ। ਲਾਇਬ੍ਰੇਰੀ ਸਕੈਨ ਕਰਨ ਜਾਂ ਡੇਟਾਬੇਸ ਵਿੱਚ ਸੋਧਾਂ ਕਰਨ ਤੋਂ ਬਾਅਦ ਇਸ ਕੰਮ ਨੂੰ ਚਲਾਉਣਾ ਪ੍ਰਦਰਸ਼ਨ ਵਿੱਚ ਸੁਧਾਰ ਕਰ ਸਕਦਾ ਹੈ।",
+ "TaskExtractMediaSegmentsDescription": "ਮੀਡੀਆ ਸੈਗਮੈਂਟ ਨੂੰ ਮੀਡੀਆਸੈਗਮੈਂਟ ਯੋਗ ਪਲੱਗਇਨਾਂ ਤੋਂ ਨਿਕਾਲਦਾ ਜਾਂ ਪ੍ਰਾਪਤ ਕਰਦਾ ਹੈ।",
+ "TaskMoveTrickplayImages": "ਟ੍ਰਿਕਪਲੇ ਤਸਵੀਰਾਂ ਦੀ ਜਗਾ ਬਦਲੋ",
+ "TaskDownloadMissingLyrics": "ਅਧੂਰੇ ਬੋਲ ਡਾਊਨਲੋਡ ਕਰੋ",
+ "TaskDownloadMissingLyricsDescription": "ਗੀਤਾਂ ਲਈ ਡਾਊਨਲੋਡ ਕਿਤੇ ਬੋਲ",
+ "TaskKeyframeExtractor": "ਕੀ-ਫ੍ਰੇਮ ਐਕਸਟ੍ਰੈਕਟਰ",
+ "TaskCleanCollectionsAndPlaylistsDescription": "ਕਲੈਕਸ਼ਨਾਂ ਅਤੇ ਪਲੇਲਿਸਟਾਂ ਵਿੱਚੋਂ ਉਹ ਆਈਟਮ ਹਟਾਉਂਦਾ ਹੈ ਜੋ ਹੁਣ ਮੌਜੂਦ ਨਹੀਂ ਹਨ।",
+ "TaskCleanCollectionsAndPlaylists": "ਕਲੈਕਸ਼ਨਾਂ ਅਤੇ ਪਲੇਲਿਸਟਾਂ ਨੂੰ ਸਾਫ ਕਰੋ",
+ "TaskAudioNormalization": "ਆਵਾਜ਼ ਸਧਾਰਣੀਕਰਨ",
+ "TaskRefreshTrickplayImagesDescription": "ਚਲ ਰਹੀ ਲਾਇਬ੍ਰੇਰੀਆਂ ਵਿੱਚ ਵੀਡੀਓਜ਼ ਲਈ ਟ੍ਰਿਕਪਲੇ ਪ੍ਰੀਵਿਊ ਬਣਾਉਂਦਾ ਹੈ।",
+ "TaskKeyframeExtractorDescription": "ਕੀ-ਫ੍ਰੇਮਜ਼ ਨੂੰ ਵੀਡੀਓ ਫਾਈਲਾਂ ਵਿੱਚੋਂ ਨਿਕਾਲਦਾ ਹੈ ਤਾਂ ਜੋ ਹੋਰ ਜ਼ਿਆਦਾ ਸਟਿਕ ਹੋਣ ਵਾਲੀਆਂ HLS ਪਲੇਲਿਸਟਾਂ ਬਣਾਈਆਂ ਜਾ ਸਕਣ। ਇਹ ਕੰਮ ਲੰਬੇ ਸਮੇਂ ਤੱਕ ਚੱਲ ਸਕਦਾ ਹੈ।"
}
diff --git a/Emby.Server.Implementations/Localization/Core/pt-PT.json b/Emby.Server.Implementations/Localization/Core/pt-PT.json
index 879bf64b0c..42ea5e0a46 100644
--- a/Emby.Server.Implementations/Localization/Core/pt-PT.json
+++ b/Emby.Server.Implementations/Localization/Core/pt-PT.json
@@ -1,6 +1,6 @@
{
"Albums": "Álbuns",
- "AppDeviceValues": "Aplicação {0}, Dispositivo: {1}",
+ "AppDeviceValues": "Aplicação: {0}, Dispositivo: {1}",
"Application": "Aplicação",
"Artists": "Artistas",
"AuthenticationSucceededWithUserName": "{0} autenticado com sucesso",
diff --git a/Emby.Server.Implementations/Localization/Core/pt.json b/Emby.Server.Implementations/Localization/Core/pt.json
index 2812832cae..0bf0491bec 100644
--- a/Emby.Server.Implementations/Localization/Core/pt.json
+++ b/Emby.Server.Implementations/Localization/Core/pt.json
@@ -13,7 +13,7 @@
"HeaderContinueWatching": "Continuar a ver",
"HeaderAlbumArtists": "Artistas do Álbum",
"Genres": "Géneros",
- "Folders": "Diretórios",
+ "Folders": "Pastas",
"Favorites": "Favoritos",
"Channels": "Canais",
"UserDownloadingItemWithValues": "{0} está sendo baixado {1}",
diff --git a/Emby.Server.Implementations/Localization/Core/ro.json b/Emby.Server.Implementations/Localization/Core/ro.json
index bf59e15837..a873c157e6 100644
--- a/Emby.Server.Implementations/Localization/Core/ro.json
+++ b/Emby.Server.Implementations/Localization/Core/ro.json
@@ -77,7 +77,7 @@
"HeaderAlbumArtists": "Artiști album",
"Genres": "Genuri",
"Folders": "Dosare",
- "Favorites": "Favorite",
+ "Favorites": "Preferate",
"FailedLoginAttemptWithUserName": "Încercare de conectare eșuată pentru {0}",
"DeviceOnlineWithName": "{0} este conectat",
"DeviceOfflineWithName": "{0} s-a deconectat",
diff --git a/Emby.Server.Implementations/Localization/Core/sl-SI.json b/Emby.Server.Implementations/Localization/Core/sl-SI.json
index 19be1a23e0..b17e7ae559 100644
--- a/Emby.Server.Implementations/Localization/Core/sl-SI.json
+++ b/Emby.Server.Implementations/Localization/Core/sl-SI.json
@@ -126,5 +126,15 @@
"TaskKeyframeExtractorDescription": "Iz video datoteke Izvleče ključne sličice, da ustvari bolj natančne sezname predvajanja HLS. Proces lahko traja dolgo časa.",
"HearingImpaired": "Oslabljen sluh",
"TaskRefreshTrickplayImages": "Ustvari Trickplay slike",
- "TaskRefreshTrickplayImagesDescription": "Ustvari trickplay predoglede za posnetke v omogočenih knjižnicah."
+ "TaskRefreshTrickplayImagesDescription": "Ustvari trickplay predoglede za posnetke v omogočenih knjižnicah.",
+ "TaskExtractMediaSegmentsDescription": "Ekstrahira ali pridobi medijske segmente iz vtičnikov, ki podpirajo MediaSegment.",
+ "TaskMoveTrickplayImagesDescription": "Premakne obstoječe datoteke trickplay v skladu z nastavitvami knjižnice.",
+ "TaskExtractMediaSegments": "Skeniranje segmentov v medijih",
+ "TaskMoveTrickplayImages": "Preseli lokacijo Trickplay slik",
+ "TaskDownloadMissingLyrics": "Prenesi manjkajoča besedila pesmi",
+ "TaskDownloadMissingLyricsDescription": "Prenesi besedila za pesmi",
+ "TaskCleanCollectionsAndPlaylists": "Počisti zbirke in sezname predvajanja",
+ "TaskAudioNormalization": "Normalizacija zvoka",
+ "TaskAudioNormalizationDescription": "Pregled datotek za podatke o normalizaciji zvoka.",
+ "TaskCleanCollectionsAndPlaylistsDescription": "Odstrani elemente iz zbirk in seznamov predvajanja, ki ne obstajajo več."
}
diff --git a/Emby.Server.Implementations/Localization/Core/sr.json b/Emby.Server.Implementations/Localization/Core/sr.json
index 9739358df0..af40b5e5a9 100644
--- a/Emby.Server.Implementations/Localization/Core/sr.json
+++ b/Emby.Server.Implementations/Localization/Core/sr.json
@@ -78,7 +78,7 @@
"Genres": "Жанрови",
"Folders": "Фасцикле",
"Favorites": "Омиљено",
- "FailedLoginAttemptWithUserName": "Неуспела пријава са {0}",
+ "FailedLoginAttemptWithUserName": "Неуспели покушај пријавe са {0}",
"DeviceOnlineWithName": "{0} је повезан",
"DeviceOfflineWithName": "{0} је прекинуо везу",
"Collections": "Колекције",
@@ -121,7 +121,10 @@
"TaskOptimizeDatabase": "Оптимизуј банку података",
"TaskOptimizeDatabaseDescription": "Сажима базу података и скраћује слободан простор. Покретање овог задатка након скенирања библиотеке или других промена које подразумевају измене базе података које могу побољшати перформансе.",
"External": "Спољно",
- "TaskKeyframeExtractorDescription": "Екстрактује кљулне сличице из видео датотека да би креирао више преицзну HLS плеј-листу. Овај задатак може да потраје дуже време.",
+ "TaskKeyframeExtractorDescription": "Екстрактује кључне сличице из видео датотека да би креирао више прецизнију HLS плејлисту. Овај задатак може да потраје дуже време.",
"TaskKeyframeExtractor": "Екстрактор кључних сличица",
- "HearingImpaired": "ослабљен слух"
+ "HearingImpaired": "ослабљен слух",
+ "TaskAudioNormalization": "Нормализација звука",
+ "TaskCleanCollectionsAndPlaylists": "Очистите колекције и плејлисте",
+ "TaskAudioNormalizationDescription": "Скенира датотеке за податке о нормализацији звука."
}
diff --git a/Emby.Server.Implementations/Localization/Core/sv.json b/Emby.Server.Implementations/Localization/Core/sv.json
index 5cf54522bf..60810b45d0 100644
--- a/Emby.Server.Implementations/Localization/Core/sv.json
+++ b/Emby.Server.Implementations/Localization/Core/sv.json
@@ -82,13 +82,13 @@
"UserCreatedWithName": "Användaren {0} har skapats",
"UserDeletedWithName": "Användaren {0} har tagits bort",
"UserDownloadingItemWithValues": "{0} laddar ner {1}",
- "UserLockedOutWithName": "Användare {0} har låsts ute",
- "UserOfflineFromDevice": "{0} har avbrutit anslutningen från {1}",
+ "UserLockedOutWithName": "Användare {0} har utelåsts",
+ "UserOfflineFromDevice": "{0} har kopplat ned från {1}",
"UserOnlineFromDevice": "{0} är uppkopplad från {1}",
"UserPasswordChangedWithName": "Lösenordet för {0} har ändrats",
"UserPolicyUpdatedWithName": "Användarpolicyn har uppdaterats för {0}",
- "UserStartedPlayingItemWithValues": "{0} spelar upp {1} på {2}",
- "UserStoppedPlayingItemWithValues": "{0} har avslutat uppspelningen av {1} på {2}",
+ "UserStartedPlayingItemWithValues": "{0} spelar {1} på {2}",
+ "UserStoppedPlayingItemWithValues": "{0} har stoppat uppspelningen av {1} på {2}",
"ValueHasBeenAddedToLibrary": "{0} har lagts till i ditt mediebibliotek",
"ValueSpecialEpisodeName": "Specialavsnitt - {0}",
"VersionNumber": "Version {0}",
@@ -98,8 +98,8 @@
"TaskRefreshChannels": "Uppdatera kanaler",
"TaskCleanTranscodeDescription": "Raderar omkodningsfiler äldre än en dag.",
"TaskCleanTranscode": "Rensa omkodningskatalog",
- "TaskUpdatePluginsDescription": "Laddar ned och installerar uppdateringar till tilläggsprogram som är konfigurerade att uppdateras automatiskt.",
- "TaskUpdatePlugins": "Uppdatera tilläggsprogram",
+ "TaskUpdatePluginsDescription": "Laddar ned och installerar uppdateringar till tillägg som är konfigurerade att uppdateras automatiskt.",
+ "TaskUpdatePlugins": "Uppdatera tillägg",
"TaskRefreshPeopleDescription": "Uppdaterar metadata för skådespelare och regissörer i ditt mediabibliotek.",
"TaskCleanLogsDescription": "Raderar loggfiler som är mer än {0} dagar gamla.",
"TaskCleanLogs": "Rensa loggkatalog",
diff --git a/Emby.Server.Implementations/Localization/Core/uz.json b/Emby.Server.Implementations/Localization/Core/uz.json
index a1b3035f37..150fb71263 100644
--- a/Emby.Server.Implementations/Localization/Core/uz.json
+++ b/Emby.Server.Implementations/Localization/Core/uz.json
@@ -23,5 +23,92 @@
"HeaderLiveTV": "Jonli TV",
"HeaderNextUp": "Keyingisi",
"ItemAddedWithName": "{0} kutbxonaga qo'shildi",
- "LabelIpAddressValue": "IP manzil: {0}"
+ "LabelIpAddressValue": "IP manzil: {0}",
+ "SubtitleDownloadFailureFromForItem": "{0} dan {1} uchun taglavhalarni yuklab boʻlmadi",
+ "UserPasswordChangedWithName": "Foydalanuvchi {0} paroli oʻzgartirildi",
+ "ValueHasBeenAddedToLibrary": "{0} kutubxonaga qoʻshildi",
+ "TaskCleanActivityLogDescription": "Belgilangan yoshdan kattaroq faoliyat jurnali yozuvlarini oʻchiradi.",
+ "TaskAudioNormalization": "Ovozni normallashtirish",
+ "TaskRefreshLibraryDescription": "Media kutubxonasi yangi fayllar uchun skanerlanmoqda va metama'lumotlar yangilanmoqda.",
+ "Default": "Joriy",
+ "HeaderFavoriteAlbums": "Tanlangan albomlar",
+ "HeaderFavoriteArtists": "Tanlangan artistlar",
+ "HeaderFavoriteEpisodes": "Tanlangan epizodlar",
+ "HeaderFavoriteShows": "Tanlangan shoular",
+ "HeaderFavoriteSongs": "Tanlangan qo'shiqlar",
+ "HeaderRecordingGroups": "Yozuvlar guruhi",
+ "HomeVideos": "Uy videolari",
+ "NotificationOptionVideoPlaybackStopped": "Video ijrosi toʻxtatildi",
+ "TvShows": "TV seriallar",
+ "Undefined": "Belgilanmagan",
+ "User": "Foydalanuvchi",
+ "UserCreatedWithName": "{0} foydalanuvchi yaratildi",
+ "TaskCleanCacheDescription": "Tizimga kerak bo'lmagan kesh fayllari o'chiriladi.",
+ "TaskAudioNormalizationDescription": "Ovozni normallashtirish ma'lumotlari uchun fayllarni skanerlaydi.",
+ "PluginInstalledWithName": "{0} - o'rnatildi",
+ "PluginUninstalledWithName": "{0} - o'chirildi",
+ "HearingImpaired": "Yaxshi eshitmaydiganlar uchun",
+ "Inherit": "Meroslangan",
+ "NotificationOptionApplicationUpdateAvailable": "Ilova yangilanishi mavjud",
+ "NotificationOptionApplicationUpdateInstalled": "Ilova yangilanishi oʻrnatildi",
+ "LabelRunningTimeValue": "Davomiyligi",
+ "NotificationOptionAudioPlayback": "Audio tinglash boshlandi",
+ "NotificationOptionAudioPlaybackStopped": "Audio tinglash to'xtatildi",
+ "NotificationOptionCameraImageUploaded": "Kamera tasvirlari yuklandi",
+ "NotificationOptionInstallationFailed": "O'rnatishda hatolik",
+ "NotificationOptionNewLibraryContent": "Yangi tarkib qo'shildi",
+ "NotificationOptionPluginError": "Plagin ishdan chiqdi",
+ "NotificationOptionPluginInstalled": "Plagin o'rnatildi",
+ "NotificationOptionPluginUninstalled": "Plagin o'chirildi",
+ "NotificationOptionPluginUpdateInstalled": "Plagin uchun yangilanish o'rnatildi",
+ "NotificationOptionServerRestartRequired": "Server-ni qayta yuklash lozim",
+ "NotificationOptionTaskFailed": "Rejalashtirilgan vazifa bajarilmadi",
+ "NotificationOptionUserLockedOut": "Foydalanuvchi bloklangan",
+ "NotificationOptionVideoPlayback": "Video ijrosi boshlandi",
+ "Photos": "Surat",
+ "Latest": "So'ngi",
+ "MessageApplicationUpdated": "Jellyfin Server yangilandi",
+ "MessageApplicationUpdatedTo": "Jellyfin Server {0} gacha yangilandi",
+ "MessageNamedServerConfigurationUpdatedWithValue": "Server konfiguratsiyasi ({0}-boʻlim) yangilandi",
+ "MessageServerConfigurationUpdated": "Server konfiguratsiyasi yangilandi",
+ "MixedContent": "Aralashgan tarkib",
+ "Movies": "Kinolar",
+ "Music": "Qo'shiqlar",
+ "MusicVideos": "Musiqali videolar",
+ "NameInstallFailed": "Omadsiz ornatish {0}",
+ "NameSeasonNumber": "{0} Fasl",
+ "NameSeasonUnknown": "Fasl aniqlanmagan",
+ "Playlists": "Pleylistlar",
+ "NewVersionIsAvailable": "Yuklab olish uchun Jellyfin Server ning yangi versiyasi mavjud",
+ "Plugin": "Plagin",
+ "TaskCleanLogs": "Jurnallar katalogini tozalash",
+ "PluginUpdatedWithName": "{0} - yangilandi",
+ "ProviderValue": "Yetkazib beruvchi: {0}",
+ "ScheduledTaskFailedWithName": "{0} - omadsiz",
+ "ScheduledTaskStartedWithName": "{0} - ishga tushirildi",
+ "ServerNameNeedsToBeRestarted": "Qayta yuklash kerak {0}",
+ "Shows": "Teleko'rsatuv",
+ "Songs": "Kompozitsiyalar",
+ "StartupEmbyServerIsLoading": "Jellyfin Server yuklanmoqda. Tez orada qayta urinib koʻring.",
+ "Sync": "Sinxronizatsiya",
+ "System": "Tizim",
+ "UserDeletedWithName": "{0} foydalanuvchisi oʻchirib tashlandi",
+ "UserDownloadingItemWithValues": "{0} yuklanmoqda {1}",
+ "UserLockedOutWithName": "{0} foydalanuvchisi bloklandi",
+ "UserOfflineFromDevice": "{0} {1}dan uzildi",
+ "UserOnlineFromDevice": "{0} {1} dan ulandi",
+ "UserPolicyUpdatedWithName": "{0} foydalanuvchisining siyosatlari yangilandi",
+ "UserStartedPlayingItemWithValues": "{0} - {2} da \"{1}\" ijrosi",
+ "UserStoppedPlayingItemWithValues": "{0} - ijro etish to‘xtatildi {1} {2}",
+ "ValueSpecialEpisodeName": "Maxsus qism – {0}",
+ "VersionNumber": "Versiya {0}",
+ "TasksMaintenanceCategory": "Xizmat ko'rsatish",
+ "TasksLibraryCategory": "Media kutubxona",
+ "TasksApplicationCategory": "Ilova",
+ "TasksChannelsCategory": "Internet kanallari",
+ "TaskCleanActivityLog": "Faoliyat jurnalini tozalash",
+ "TaskCleanCache": "Kesh katalogini tozalash",
+ "TaskRefreshChapterImages": "Sahnadan tasvirini chiqarish",
+ "TaskRefreshChapterImagesDescription": "Sahnalarni o'z ichiga olgan videolar uchun eskizlarni yaratadi.",
+ "TaskRefreshLibrary": "Media kutubxonangizni skanerlash"
}
diff --git a/Emby.Server.Implementations/Localization/Core/zh-HK.json b/Emby.Server.Implementations/Localization/Core/zh-HK.json
index 3ab9774c27..286efb7e92 100644
--- a/Emby.Server.Implementations/Localization/Core/zh-HK.json
+++ b/Emby.Server.Implementations/Localization/Core/zh-HK.json
@@ -126,5 +126,15 @@
"External": "外部",
"HearingImpaired": "聽力障礙",
"TaskRefreshTrickplayImages": "建立 Trickplay 圖像",
- "TaskRefreshTrickplayImagesDescription": "為已啟用 Trickplay 的媒體庫內的影片建立 Trickplay 預覽圖。"
+ "TaskRefreshTrickplayImagesDescription": "為已啟用 Trickplay 的媒體庫內的影片建立 Trickplay 預覽圖。",
+ "TaskExtractMediaSegments": "掃描媒體段落",
+ "TaskExtractMediaSegmentsDescription": "從MediaSegment中被允許的插件獲取媒體段落。",
+ "TaskDownloadMissingLyrics": "下載欠缺歌詞",
+ "TaskDownloadMissingLyricsDescription": "下載歌詞",
+ "TaskCleanCollectionsAndPlaylists": "整理媒體與播放清單",
+ "TaskAudioNormalization": "音訊同等化",
+ "TaskAudioNormalizationDescription": "掃描檔案裏的音訊同等化資料。",
+ "TaskCleanCollectionsAndPlaylistsDescription": "從資料庫及播放清單中移除已不存在的項目。",
+ "TaskMoveTrickplayImagesDescription": "根據媒體庫設定移動現有的 Trickplay 檔案。",
+ "TaskMoveTrickplayImages": "轉移 Trickplay 影像位置"
}
diff --git a/Emby.Server.Implementations/Localization/Core/zh-TW.json b/Emby.Server.Implementations/Localization/Core/zh-TW.json
index 81d5b83d61..a4ee68fc45 100644
--- a/Emby.Server.Implementations/Localization/Core/zh-TW.json
+++ b/Emby.Server.Implementations/Localization/Core/zh-TW.json
@@ -8,7 +8,7 @@
"CameraImageUploadedFrom": "已從 {0} 成功上傳一張相片",
"Channels": "頻道",
"ChapterNameValue": "章節 {0}",
- "Collections": "系列",
+ "Collections": "系列作",
"DeviceOfflineWithName": "{0} 已中斷連接",
"DeviceOnlineWithName": "{0} 已連接",
"FailedLoginAttemptWithUserName": "來自使用者 {0} 的登入失敗嘗試",
@@ -126,8 +126,8 @@
"HearingImpaired": "聽力障礙",
"TaskRefreshTrickplayImages": "生成快轉縮圖",
"TaskRefreshTrickplayImagesDescription": "為啟用快轉縮圖的媒體庫生成快轉縮圖。",
- "TaskCleanCollectionsAndPlaylists": "清理系列和播放清單",
- "TaskCleanCollectionsAndPlaylistsDescription": "清理系列和播放清單中已不存在的項目。",
+ "TaskCleanCollectionsAndPlaylists": "清理系列作和播放清單",
+ "TaskCleanCollectionsAndPlaylistsDescription": "清理系列作品與播放清單中已不存在的項目。",
"TaskAudioNormalization": "音量標準化",
"TaskAudioNormalizationDescription": "掃描文件以找出音量標準化資料。",
"TaskDownloadMissingLyrics": "下載缺少的歌詞",
diff --git a/Emby.Server.Implementations/Localization/LocalizationManager.cs b/Emby.Server.Implementations/Localization/LocalizationManager.cs
index ac453a5b09..17db7ad4c4 100644
--- a/Emby.Server.Implementations/Localization/LocalizationManager.cs
+++ b/Emby.Server.Implementations/Localization/LocalizationManager.cs
@@ -1,7 +1,8 @@
using System;
using System.Collections.Concurrent;
+using System.Collections.Frozen;
using System.Collections.Generic;
-using System.Globalization;
+using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;
using System.Reflection;
@@ -26,20 +27,20 @@ namespace Emby.Server.Implementations.Localization
private const string CulturesPath = "Emby.Server.Implementations.Localization.iso6392.txt";
private const string CountriesPath = "Emby.Server.Implementations.Localization.countries.json";
private static readonly Assembly _assembly = typeof(LocalizationManager).Assembly;
- private static readonly string[] _unratedValues = { "n/a", "unrated", "not rated", "nr" };
+ private static readonly string[] _unratedValues = ["n/a", "unrated", "not rated", "nr"];
private readonly IServerConfigurationManager _configurationManager;
private readonly ILogger _logger;
- private readonly Dictionary> _allParentalRatings =
- new Dictionary>(StringComparer.OrdinalIgnoreCase);
+ private readonly Dictionary> _allParentalRatings = new(StringComparer.OrdinalIgnoreCase);
- private readonly ConcurrentDictionary> _dictionaries =
- new ConcurrentDictionary>(StringComparer.OrdinalIgnoreCase);
+ private readonly ConcurrentDictionary> _dictionaries = new(StringComparer.OrdinalIgnoreCase);
private readonly JsonSerializerOptions _jsonOptions = JsonDefaults.Options;
- private List _cultures = new List();
+ private List _cultures = [];
+
+ private FrozenDictionary _iso6392BtoT = null!;
///
/// Initializes a new instance of the class.
@@ -68,35 +69,26 @@ namespace Emby.Server.Implementations.Localization
continue;
}
- string countryCode = resource.Substring(RatingsPath.Length, 2);
- var dict = new Dictionary(StringComparer.OrdinalIgnoreCase);
-
- var stream = _assembly.GetManifestResourceStream(resource);
- await using (stream!.ConfigureAwait(false)) // shouldn't be null here, we just got the resource path from Assembly.GetManifestResourceNames()
+ using var stream = _assembly.GetManifestResourceStream(resource);
+ if (stream is not null)
{
- using var reader = new StreamReader(stream!);
- await foreach (var line in reader.ReadAllLinesAsync().ConfigureAwait(false))
+ var ratingSystem = await JsonSerializer.DeserializeAsync(stream, _jsonOptions).ConfigureAwait(false)
+ ?? throw new InvalidOperationException($"Invalid resource path: '{CountriesPath}'");
+
+ var dict = new Dictionary();
+ if (ratingSystem.Ratings is not null)
{
- if (string.IsNullOrWhiteSpace(line))
+ foreach (var ratingEntry in ratingSystem.Ratings)
{
- continue;
+ foreach (var ratingString in ratingEntry.RatingStrings)
+ {
+ dict[ratingString] = ratingEntry.RatingScore;
+ }
}
- string[] parts = line.Split(',');
- if (parts.Length == 2
- && int.TryParse(parts[1], NumberStyles.Integer, CultureInfo.InvariantCulture, out var value))
- {
- var name = parts[0];
- dict.Add(name, new ParentalRating(name, value));
- }
- else
- {
- _logger.LogWarning("Malformed line in ratings file for country {CountryCode}", countryCode);
- }
+ _allParentalRatings[ratingSystem.CountryCode] = dict;
}
}
-
- _allParentalRatings[countryCode] = dict;
}
await LoadCultures().ConfigureAwait(false);
@@ -111,22 +103,30 @@ namespace Emby.Server.Implementations.Localization
private async Task LoadCultures()
{
- List list = new List();
+ List list = [];
+ Dictionary iso6392BtoTdict = new Dictionary();
- await using var stream = _assembly.GetManifestResourceStream(CulturesPath)
- ?? throw new InvalidOperationException($"Invalid resource path: '{CulturesPath}'");
- using var reader = new StreamReader(stream);
- await foreach (var line in reader.ReadAllLinesAsync().ConfigureAwait(false))
+ using var stream = _assembly.GetManifestResourceStream(CulturesPath);
+ if (stream is null)
{
- if (string.IsNullOrWhiteSpace(line))
+ throw new InvalidOperationException($"Invalid resource path: '{CulturesPath}'");
+ }
+ else
+ {
+ using var reader = new StreamReader(stream);
+ await foreach (var line in reader.ReadAllLinesAsync().ConfigureAwait(false))
{
- continue;
- }
+ if (string.IsNullOrWhiteSpace(line))
+ {
+ continue;
+ }
- var parts = line.Split('|');
+ var parts = line.Split('|');
+ if (parts.Length != 5)
+ {
+ throw new InvalidDataException($"Invalid culture data found at: '{line}'");
+ }
- if (parts.Length == 5)
- {
string name = parts[3];
if (string.IsNullOrWhiteSpace(name))
{
@@ -139,21 +139,26 @@ namespace Emby.Server.Implementations.Localization
continue;
}
- string[] threeletterNames;
+ string[] threeLetterNames;
if (string.IsNullOrWhiteSpace(parts[1]))
{
- threeletterNames = new[] { parts[0] };
+ threeLetterNames = [parts[0]];
}
else
{
- threeletterNames = new[] { parts[0], parts[1] };
+ threeLetterNames = [parts[0], parts[1]];
+
+ // In cases where there are two TLN the first one is ISO 639-2/T and the second one is ISO 639-2/B
+ // We need ISO 639-2/T for the .NET cultures so we cultivate a dictionary for the translation B->T
+ iso6392BtoTdict.TryAdd(parts[1], parts[0]);
}
- list.Add(new CultureDto(name, name, twoCharName, threeletterNames));
+ list.Add(new CultureDto(name, name, twoCharName, threeLetterNames));
}
- }
- _cultures = list;
+ _cultures = list;
+ _iso6392BtoT = iso6392BtoTdict.ToFrozenDictionary(StringComparer.OrdinalIgnoreCase);
+ }
}
///
@@ -176,82 +181,80 @@ namespace Emby.Server.Implementations.Localization
}
///
- public IEnumerable GetCountries()
+ public IReadOnlyList GetCountries()
{
- using StreamReader reader = new StreamReader(
- _assembly.GetManifestResourceStream(CountriesPath) ?? throw new InvalidOperationException($"Invalid resource path: '{CountriesPath}'"));
- return JsonSerializer.Deserialize>(reader.ReadToEnd(), _jsonOptions)
- ?? throw new InvalidOperationException($"Resource contains invalid data: '{CountriesPath}'");
+ using var stream = _assembly.GetManifestResourceStream(CountriesPath) ?? throw new InvalidOperationException($"Invalid resource path: '{CountriesPath}'");
+
+ return JsonSerializer.Deserialize>(stream, _jsonOptions) ?? [];
}
///
- public IEnumerable GetParentalRatings()
+ public IReadOnlyList GetParentalRatings()
{
// Use server default language for ratings
// Fall back to empty list if there are no parental ratings for that language
- var ratings = GetParentalRatingsDictionary()?.Values.ToList()
- ?? new List();
+ var ratings = GetParentalRatingsDictionary()?.Select(x => new ParentalRating(x.Key, x.Value)).ToList() ?? [];
// Add common ratings to ensure them being available for selection
// Based on the US rating system due to it being the main source of rating in the metadata providers
// Unrated
- if (!ratings.Any(x => x.Value is null))
+ if (!ratings.Any(x => x is null))
{
- ratings.Add(new ParentalRating("Unrated", null));
+ ratings.Add(new("Unrated", null));
}
// Minimum rating possible
- if (ratings.All(x => x.Value != 0))
+ if (ratings.All(x => x.RatingScore?.Score != 0))
{
- ratings.Add(new ParentalRating("Approved", 0));
+ ratings.Add(new("Approved", new(0, null)));
}
// Matches PG (this has different age restrictions depending on country)
- if (ratings.All(x => x.Value != 10))
+ if (ratings.All(x => x.RatingScore?.Score != 10))
{
- ratings.Add(new ParentalRating("10", 10));
+ ratings.Add(new("10", new(10, null)));
}
// Matches PG-13
- if (ratings.All(x => x.Value != 13))
+ if (ratings.All(x => x.RatingScore?.Score != 13))
{
- ratings.Add(new ParentalRating("13", 13));
+ ratings.Add(new("13", new(13, null)));
}
// Matches TV-14
- if (ratings.All(x => x.Value != 14))
+ if (ratings.All(x => x.RatingScore?.Score != 14))
{
- ratings.Add(new ParentalRating("14", 14));
+ ratings.Add(new("14", new(14, null)));
}
// Catchall if max rating of country is less than 21
// Using 21 instead of 18 to be sure to allow access to all rated content except adult and banned
- if (!ratings.Any(x => x.Value >= 21))
+ if (!ratings.Any(x => x.RatingScore?.Score >= 21))
{
- ratings.Add(new ParentalRating("21", 21));
+ ratings.Add(new ParentalRating("21", new(21, null)));
}
- // A lot of countries don't excplicitly have a seperate rating for adult content
- if (ratings.All(x => x.Value != 1000))
+ // A lot of countries don't explicitly have a separate rating for adult content
+ if (ratings.All(x => x.RatingScore?.Score != 1000))
{
- ratings.Add(new ParentalRating("XXX", 1000));
+ ratings.Add(new ParentalRating("XXX", new(1000, null)));
}
- // A lot of countries don't excplicitly have a seperate rating for banned content
- if (ratings.All(x => x.Value != 1001))
+ // A lot of countries don't explicitly have a separate rating for banned content
+ if (ratings.All(x => x.RatingScore?.Score != 1001))
{
- ratings.Add(new ParentalRating("Banned", 1001));
+ ratings.Add(new ParentalRating("Banned", new(1001, null)));
}
- return ratings.OrderBy(r => r.Value);
+ return [.. ratings.OrderBy(r => r.RatingScore?.Score).ThenBy(r => r.RatingScore?.SubScore)];
}
///
/// Gets the parental ratings dictionary.
///
/// The optional two letter ISO language string.
- /// .
- private Dictionary? GetParentalRatingsDictionary(string? countryCode = null)
+ /// .
+ private Dictionary? GetParentalRatingsDictionary(string? countryCode = null)
{
// Fallback to server default if no country code is specified.
if (string.IsNullOrEmpty(countryCode))
@@ -268,7 +271,7 @@ namespace Emby.Server.Implementations.Localization
}
///
- public int? GetRatingLevel(string rating, string? countryCode = null)
+ public ParentalRatingScore? GetRatingScore(string rating, string? countryCode = null)
{
ArgumentException.ThrowIfNullOrEmpty(rating);
@@ -278,24 +281,26 @@ namespace Emby.Server.Implementations.Localization
return null;
}
- // Convert integers directly
+ // Convert ints directly
// 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))
{
- return ratingAge;
+ return new(ratingAge, null);
}
// Fairly common for some users to have "Rated R" in their rating field
- rating = rating.Replace("Rated :", string.Empty, StringComparison.OrdinalIgnoreCase);
- rating = rating.Replace("Rated ", string.Empty, StringComparison.OrdinalIgnoreCase);
+ rating = rating.Replace("Rated :", string.Empty, StringComparison.OrdinalIgnoreCase)
+ .Replace("Rated:", string.Empty, StringComparison.OrdinalIgnoreCase)
+ .Replace("Rated ", string.Empty, StringComparison.OrdinalIgnoreCase)
+ .Trim();
// Use rating system matching the language
if (!string.IsNullOrEmpty(countryCode))
{
var ratingsDictionary = GetParentalRatingsDictionary(countryCode);
- if (ratingsDictionary is not null && ratingsDictionary.TryGetValue(rating, out ParentalRating? value))
+ if (ratingsDictionary is not null && ratingsDictionary.TryGetValue(rating, out ParentalRatingScore? value))
{
- return value.Value;
+ return value;
}
}
else
@@ -303,9 +308,9 @@ namespace Emby.Server.Implementations.Localization
// Fall back to server default language for ratings check
// If it has no ratings, use the US ratings
var ratingsDictionary = GetParentalRatingsDictionary() ?? GetParentalRatingsDictionary("us");
- if (ratingsDictionary is not null && ratingsDictionary.TryGetValue(rating, out ParentalRating? value))
+ if (ratingsDictionary is not null && ratingsDictionary.TryGetValue(rating, out ParentalRatingScore? value))
{
- return value.Value;
+ return value;
}
}
@@ -314,7 +319,7 @@ namespace Emby.Server.Implementations.Localization
{
if (dictionary.TryGetValue(rating, out var value))
{
- return value.Value;
+ return value;
}
}
@@ -324,7 +329,7 @@ namespace Emby.Server.Implementations.Localization
var ratingLevelRightPart = rating.AsSpan().RightPart(':');
if (ratingLevelRightPart.Length != 0)
{
- return GetRatingLevel(ratingLevelRightPart.ToString());
+ return GetRatingScore(ratingLevelRightPart.ToString());
}
}
@@ -340,7 +345,7 @@ namespace Emby.Server.Implementations.Localization
if (ratingLevelRightPart.Length != 0)
{
// Check rating system of culture
- return GetRatingLevel(ratingLevelRightPart.ToString(), culture?.TwoLetterISOLanguageName);
+ return GetRatingScore(ratingLevelRightPart.ToString(), culture?.TwoLetterISOLanguageName);
}
}
@@ -404,7 +409,7 @@ namespace Emby.Server.Implementations.Localization
private async Task CopyInto(IDictionary dictionary, string resourcePath)
{
- await using var stream = _assembly.GetManifestResourceStream(resourcePath);
+ using var stream = _assembly.GetManifestResourceStream(resourcePath);
// If a Culture doesn't have a translation the stream will be null and it defaults to en-us further up the chain
if (stream is null)
{
@@ -412,12 +417,7 @@ namespace Emby.Server.Implementations.Localization
return;
}
- var dict = await JsonSerializer.DeserializeAsync>(stream, _jsonOptions).ConfigureAwait(false);
- if (dict is null)
- {
- throw new InvalidOperationException($"Resource contains invalid data: '{stream}'");
- }
-
+ var dict = await JsonSerializer.DeserializeAsync>(stream, _jsonOptions).ConfigureAwait(false) ?? throw new InvalidOperationException($"Resource contains invalid data: '{stream}'");
foreach (var key in dict.Keys)
{
dictionary[key] = dict[key];
@@ -515,5 +515,26 @@ namespace Emby.Server.Implementations.Localization
yield return new LocalizationOption("漢語 (繁體字)", "zh-TW");
yield return new LocalizationOption("廣東話 (香港)", "zh-HK");
}
+
+ ///
+ public bool TryGetISO6392TFromB(string isoB, [NotNullWhen(true)] out string? isoT)
+ {
+ // Unlikely case the dictionary is not (yet) initialized properly
+ if (_iso6392BtoT == null)
+ {
+ isoT = null;
+ return false;
+ }
+
+ var result = _iso6392BtoT.TryGetValue(isoB, out isoT) && !string.IsNullOrEmpty(isoT);
+
+ // Ensure the ISO code being null if the result is false
+ if (!result)
+ {
+ isoT = null;
+ }
+
+ return result;
+ }
}
}
diff --git a/Emby.Server.Implementations/Localization/Ratings/0-prefer.csv b/Emby.Server.Implementations/Localization/Ratings/0-prefer.csv
deleted file mode 100644
index 36886ba760..0000000000
--- a/Emby.Server.Implementations/Localization/Ratings/0-prefer.csv
+++ /dev/null
@@ -1,11 +0,0 @@
-E,0
-EC,0
-T,7
-M,18
-AO,18
-UR,18
-RP,18
-X,1000
-XX,1000
-XXX,1000
-XXXX,1000
diff --git a/Emby.Server.Implementations/Localization/Ratings/0-prefer.json b/Emby.Server.Implementations/Localization/Ratings/0-prefer.json
new file mode 100644
index 0000000000..b390151611
--- /dev/null
+++ b/Emby.Server.Implementations/Localization/Ratings/0-prefer.json
@@ -0,0 +1,34 @@
+{
+ "countryCode": "0-prefer",
+ "supportsSubScores": false,
+ "ratings": [
+ {
+ "ratingStrings": ["E", "EC"],
+ "ratingScore": {
+ "score": 0,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["T"],
+ "ratingScore": {
+ "score": 7,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["M", "AO", "UR", "RP"],
+ "ratingScore": {
+ "score": 18,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["X", "XX", "XXX", "XXXX"],
+ "ratingScore": {
+ "score": 1000,
+ "subScore": null
+ }
+ }
+ ]
+}
diff --git a/Emby.Server.Implementations/Localization/Ratings/au.csv b/Emby.Server.Implementations/Localization/Ratings/au.csv
deleted file mode 100644
index 6e12759a46..0000000000
--- a/Emby.Server.Implementations/Localization/Ratings/au.csv
+++ /dev/null
@@ -1,17 +0,0 @@
-Exempt,0
-G,0
-7+,7
-PG,15
-M,15
-MA,15
-MA15+,15
-MA 15+,15
-16+,16
-R,18
-R18+,18
-R 18+,18
-18+,18
-X18+,1000
-X 18+,1000
-X,1000
-RC,1001
diff --git a/Emby.Server.Implementations/Localization/Ratings/au.json b/Emby.Server.Implementations/Localization/Ratings/au.json
new file mode 100644
index 0000000000..a563df899d
--- /dev/null
+++ b/Emby.Server.Implementations/Localization/Ratings/au.json
@@ -0,0 +1,69 @@
+{
+ "countryCode": "au",
+ "supportsSubScores": true,
+ "ratings": [
+ {
+ "ratingStrings": ["Exempt", "G"],
+ "ratingScore": {
+ "score": 0,
+ "subScore": 0
+ }
+ },
+ {
+ "ratingStrings": ["7+"],
+ "ratingScore": {
+ "score": 7,
+ "subScore": 0
+ }
+ },
+ {
+ "ratingStrings": ["PG"],
+ "ratingScore": {
+ "score": 15,
+ "subScore": 1
+ }
+ },
+ {
+ "ratingStrings": ["M"],
+ "ratingScore": {
+ "score": 15,
+ "subScore": 2
+ }
+ },
+ {
+ "ratingStrings": ["MA", "MA 15+", "MA15+"],
+ "ratingScore": {
+ "score": 15,
+ "subScore": 3
+ }
+ },
+ {
+ "ratingStrings": ["16+"],
+ "ratingScore": {
+ "score": 16,
+ "subScore": 0
+ }
+ },
+ {
+ "ratingStrings": ["18+", "R", "R18+", "R 18+"],
+ "ratingScore": {
+ "score": 18,
+ "subScore": 1
+ }
+ },
+ {
+ "ratingStrings": ["X", "X18", "X 18"],
+ "ratingScore": {
+ "score": 1000,
+ "subScore": 0
+ }
+ },
+ {
+ "ratingStrings": ["RC"],
+ "ratingScore": {
+ "score": 1001,
+ "subScore": 0
+ }
+ }
+ ]
+}
diff --git a/Emby.Server.Implementations/Localization/Ratings/be.csv b/Emby.Server.Implementations/Localization/Ratings/be.csv
deleted file mode 100644
index d171a71328..0000000000
--- a/Emby.Server.Implementations/Localization/Ratings/be.csv
+++ /dev/null
@@ -1,11 +0,0 @@
-AL,0
-KT,0
-TOUS,0
-MG6,6
-6,6
-9,9
-KNT,12
-12,12
-14,14
-16,16
-18,18
diff --git a/Emby.Server.Implementations/Localization/Ratings/be.json b/Emby.Server.Implementations/Localization/Ratings/be.json
new file mode 100644
index 0000000000..18ea2c2605
--- /dev/null
+++ b/Emby.Server.Implementations/Localization/Ratings/be.json
@@ -0,0 +1,55 @@
+{
+ "countryCode": "be",
+ "supportsSubScores": false,
+ "ratings": [
+ {
+ "ratingStrings": ["AL", "KT", "TOUS"],
+ "ratingScore": {
+ "score": 0,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["6", "MG6"],
+ "ratingScore": {
+ "score": 6,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["9"],
+ "ratingScore": {
+ "score": 9,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["12", "KNT"],
+ "ratingScore": {
+ "score": 12,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["14"],
+ "ratingScore": {
+ "score": 14,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["16"],
+ "ratingScore": {
+ "score": 16,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["18"],
+ "ratingScore": {
+ "score": 18,
+ "subScore": null
+ }
+ }
+ ]
+}
diff --git a/Emby.Server.Implementations/Localization/Ratings/br.csv b/Emby.Server.Implementations/Localization/Ratings/br.csv
deleted file mode 100644
index 5ec1eb2627..0000000000
--- a/Emby.Server.Implementations/Localization/Ratings/br.csv
+++ /dev/null
@@ -1,8 +0,0 @@
-Livre,0
-L,0
-ER,9
-10,10
-12,12
-14,14
-16,16
-18,18
diff --git a/Emby.Server.Implementations/Localization/Ratings/br.json b/Emby.Server.Implementations/Localization/Ratings/br.json
new file mode 100644
index 0000000000..f455b6643f
--- /dev/null
+++ b/Emby.Server.Implementations/Localization/Ratings/br.json
@@ -0,0 +1,55 @@
+{
+ "countryCode": "br",
+ "supportsSubScores": false,
+ "ratings": [
+ {
+ "ratingStrings": ["L", "AL", "Livre"],
+ "ratingScore": {
+ "score": 0,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["9"],
+ "ratingScore": {
+ "score": 9,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["10", "A10", "ER"],
+ "ratingScore": {
+ "score": 10,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["12", "A12"],
+ "ratingScore": {
+ "score": 12,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["14", "A14"],
+ "ratingScore": {
+ "score": 14,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["16", "A16"],
+ "ratingScore": {
+ "score": 16,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["18", "A18"],
+ "ratingScore": {
+ "score": 18,
+ "subScore": null
+ }
+ }
+ ]
+}
diff --git a/Emby.Server.Implementations/Localization/Ratings/ca.csv b/Emby.Server.Implementations/Localization/Ratings/ca.csv
deleted file mode 100644
index 336ee28067..0000000000
--- a/Emby.Server.Implementations/Localization/Ratings/ca.csv
+++ /dev/null
@@ -1,20 +0,0 @@
-E,0
-G,0
-TV-Y,0
-TV-G,0
-TV-Y7,7
-TV-Y7-FV,7
-PG,9
-TV-PG,9
-PG-13,13
-13+,13
-TV-14,14
-14A,14
-16+,16
-NC-17,17
-R,18
-TV-MA,18
-18A,18
-18+,18
-A,1000
-Prohibited,1001
diff --git a/Emby.Server.Implementations/Localization/Ratings/ca.json b/Emby.Server.Implementations/Localization/Ratings/ca.json
new file mode 100644
index 0000000000..fa43a8f2b7
--- /dev/null
+++ b/Emby.Server.Implementations/Localization/Ratings/ca.json
@@ -0,0 +1,90 @@
+{
+ "countryCode": "ca",
+ "supportsSubScores": true,
+ "ratings": [
+ {
+ "ratingStrings": ["E", "G", "TV-Y", "TV-G"],
+ "ratingScore": {
+ "score": 0,
+ "subScore": 0
+ }
+ },
+ {
+ "ratingStrings": ["TV-Y7"],
+ "ratingScore": {
+ "score": 7,
+ "subScore": 0
+ }
+ },
+ {
+ "ratingStrings": ["TV-Y7-FV"],
+ "ratingScore": {
+ "score": 7,
+ "subScore": 1
+ }
+ },
+ {
+ "ratingStrings": ["PG", "TV-PG"],
+ "ratingScore": {
+ "score": 9,
+ "subScore": 0
+ }
+ },
+ {
+ "ratingStrings": ["14A"],
+ "ratingScore": {
+ "score": 14,
+ "subScore": 0
+ }
+ },
+ {
+ "ratingStrings": ["TV-14"],
+ "ratingScore": {
+ "score": 14,
+ "subScore": 1
+ }
+ },
+ {
+ "ratingStrings": ["16+"],
+ "ratingScore": {
+ "score": 16,
+ "subScore": 0
+ }
+ },
+ {
+ "ratingStrings": ["NC-17"],
+ "ratingScore": {
+ "score": 17,
+ "subScore": 0
+ }
+ },
+ {
+ "ratingStrings": ["18A"],
+ "ratingScore": {
+ "score": 18,
+ "subScore": 0
+ }
+ },
+ {
+ "ratingStrings": ["18+", "TV-MA", "R"],
+ "ratingScore": {
+ "score": 18,
+ "subScore": 1
+ }
+ },
+ {
+ "ratingStrings": ["A"],
+ "ratingScore": {
+ "score": 1000,
+ "subScore": 0
+ }
+ },
+ {
+ "ratingStrings": ["Prohibited"],
+ "ratingScore": {
+ "score": 1001,
+ "subScore": 0
+ }
+ }
+ ]
+}
diff --git a/Emby.Server.Implementations/Localization/Ratings/cl.json b/Emby.Server.Implementations/Localization/Ratings/cl.json
new file mode 100644
index 0000000000..0866194715
--- /dev/null
+++ b/Emby.Server.Implementations/Localization/Ratings/cl.json
@@ -0,0 +1,41 @@
+{
+ "countryCode": "cl",
+ "supportsSubScores": false,
+ "ratings": [
+ {
+ "ratingStrings": ["TE"],
+ "ratingScore": {
+ "score": 0,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["6"],
+ "ratingScore": {
+ "score": 6,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["TE+7"],
+ "ratingScore": {
+ "score": 7,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["14"],
+ "ratingScore": {
+ "score": 14,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["18", "18V", "18S"],
+ "ratingScore": {
+ "score": 18,
+ "subScore": null
+ }
+ }
+ ]
+}
diff --git a/Emby.Server.Implementations/Localization/Ratings/co.csv b/Emby.Server.Implementations/Localization/Ratings/co.csv
deleted file mode 100644
index e1e96c5909..0000000000
--- a/Emby.Server.Implementations/Localization/Ratings/co.csv
+++ /dev/null
@@ -1,7 +0,0 @@
-T,0
-7,7
-12,12
-15,15
-18,18
-X,1000
-Prohibited,1001
diff --git a/Emby.Server.Implementations/Localization/Ratings/co.json b/Emby.Server.Implementations/Localization/Ratings/co.json
new file mode 100644
index 0000000000..4eff6dcc53
--- /dev/null
+++ b/Emby.Server.Implementations/Localization/Ratings/co.json
@@ -0,0 +1,55 @@
+{
+ "countryCode": "co",
+ "supportsSubScores": false,
+ "ratings": [
+ {
+ "ratingStrings": ["T"],
+ "ratingScore": {
+ "score": 0,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["7"],
+ "ratingScore": {
+ "score": 7,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["12"],
+ "ratingScore": {
+ "score": 12,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["15"],
+ "ratingScore": {
+ "score": 15,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["18"],
+ "ratingScore": {
+ "score": 18,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["X"],
+ "ratingScore": {
+ "score": 1000,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["Prohibited"],
+ "ratingScore": {
+ "score": 1001,
+ "subScore": null
+ }
+ }
+ ]
+}
diff --git a/Emby.Server.Implementations/Localization/Ratings/de.csv b/Emby.Server.Implementations/Localization/Ratings/de.csv
deleted file mode 100644
index f6181575e2..0000000000
--- a/Emby.Server.Implementations/Localization/Ratings/de.csv
+++ /dev/null
@@ -1,17 +0,0 @@
-Educational,0
-Infoprogramm,0
-FSK-0,0
-FSK 0,0
-0,0
-FSK-6,6
-FSK 6,6
-6,6
-FSK-12,12
-FSK 12,12
-12,12
-FSK-16,16
-FSK 16,16
-16,16
-FSK-18,18
-FSK 18,18
-18,18
diff --git a/Emby.Server.Implementations/Localization/Ratings/de.json b/Emby.Server.Implementations/Localization/Ratings/de.json
new file mode 100644
index 0000000000..30c34b230c
--- /dev/null
+++ b/Emby.Server.Implementations/Localization/Ratings/de.json
@@ -0,0 +1,41 @@
+{
+ "countryCode": "de",
+ "supportsSubScores": false,
+ "ratings": [
+ {
+ "ratingStrings": ["0", "FSK 0", "FSK-0", "Educational", "Infoprogramm"],
+ "ratingScore": {
+ "score": 0,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["6", "FSK 6", "FSK-6"],
+ "ratingScore": {
+ "score": 6,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["12", "FSK 12", "FSK-12"],
+ "ratingScore": {
+ "score": 12,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["16", "FSK 16", "FSK-16"],
+ "ratingScore": {
+ "score": 16,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["18", "FSK 18", "FSK-18"],
+ "ratingScore": {
+ "score": 18,
+ "subScore": null
+ }
+ }
+ ]
+}
diff --git a/Emby.Server.Implementations/Localization/Ratings/dk.csv b/Emby.Server.Implementations/Localization/Ratings/dk.csv
deleted file mode 100644
index 4ef63b2eac..0000000000
--- a/Emby.Server.Implementations/Localization/Ratings/dk.csv
+++ /dev/null
@@ -1,7 +0,0 @@
-F,0
-A,0
-7,7
-11,11
-12,12
-15,15
-16,16
diff --git a/Emby.Server.Implementations/Localization/Ratings/dk.json b/Emby.Server.Implementations/Localization/Ratings/dk.json
new file mode 100644
index 0000000000..9fcd6d44fd
--- /dev/null
+++ b/Emby.Server.Implementations/Localization/Ratings/dk.json
@@ -0,0 +1,48 @@
+{
+ "countryCode": "dk",
+ "supportsSubScores": false,
+ "ratings": [
+ {
+ "ratingStrings": ["F", "A"],
+ "ratingScore": {
+ "score": 0,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["7"],
+ "ratingScore": {
+ "score": 7,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["11"],
+ "ratingScore": {
+ "score": 11,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["12"],
+ "ratingScore": {
+ "score": 12,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["15"],
+ "ratingScore": {
+ "score": 15,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["16"],
+ "ratingScore": {
+ "score": 16,
+ "subScore": null
+ }
+ }
+ ]
+}
diff --git a/Emby.Server.Implementations/Localization/Ratings/es.csv b/Emby.Server.Implementations/Localization/Ratings/es.csv
deleted file mode 100644
index 619e948d88..0000000000
--- a/Emby.Server.Implementations/Localization/Ratings/es.csv
+++ /dev/null
@@ -1,25 +0,0 @@
-A,0
-A/fig,0
-A/i,0
-A/fig/i,0
-APTA,0
-ERI,0
-TP,0
-0+,0
-6+,6
-7/fig,7
-7/i,7
-7/i/fig,7
-7,7
-9+,9
-10,10
-12,12
-12/fig,12
-13,13
-14,14
-16,16
-16/fig,16
-18,18
-18/fig,18
-X,1000
-Banned,1001
diff --git a/Emby.Server.Implementations/Localization/Ratings/es.json b/Emby.Server.Implementations/Localization/Ratings/es.json
new file mode 100644
index 0000000000..c19629939d
--- /dev/null
+++ b/Emby.Server.Implementations/Localization/Ratings/es.json
@@ -0,0 +1,90 @@
+{
+ "countryCode": "es",
+ "supportsSubScores": false,
+ "ratings": [
+ {
+ "ratingStrings": ["0+", "A", "A/i", "A/fig", "A/i/fig", "APTA", "ERI", "TP"],
+ "ratingScore": {
+ "score": 0,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["6+"],
+ "ratingScore": {
+ "score": 6,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["7", "7/i", "7/fig", "7/i/fig"],
+ "ratingScore": {
+ "score": 11,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["9+"],
+ "ratingScore": {
+ "score": 9,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["10"],
+ "ratingScore": {
+ "score": 10,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["12", "12/fig"],
+ "ratingScore": {
+ "score": 12,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["13"],
+ "ratingScore": {
+ "score": 13,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["14"],
+ "ratingScore": {
+ "score": 14,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["16", "16/fig"],
+ "ratingScore": {
+ "score": 16,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["18", "18/fig"],
+ "ratingScore": {
+ "score": 18,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["X"],
+ "ratingScore": {
+ "score": 1000,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["Banned"],
+ "ratingScore": {
+ "score": 1001,
+ "subScore": null
+ }
+ }
+ ]
+}
diff --git a/Emby.Server.Implementations/Localization/Ratings/fi.csv b/Emby.Server.Implementations/Localization/Ratings/fi.csv
deleted file mode 100644
index 7ff92f259b..0000000000
--- a/Emby.Server.Implementations/Localization/Ratings/fi.csv
+++ /dev/null
@@ -1,10 +0,0 @@
-S,0
-T,0
-K7,7
-7,7
-K12,12
-12,12
-K16,16
-16,16
-K18,18
-18,18
diff --git a/Emby.Server.Implementations/Localization/Ratings/fi.json b/Emby.Server.Implementations/Localization/Ratings/fi.json
new file mode 100644
index 0000000000..3152317b59
--- /dev/null
+++ b/Emby.Server.Implementations/Localization/Ratings/fi.json
@@ -0,0 +1,41 @@
+{
+ "countryCode": "fi",
+ "supportsSubScores": false,
+ "ratings": [
+ {
+ "ratingStrings": ["S", "T"],
+ "ratingScore": {
+ "score": 0,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["7", "K7"],
+ "ratingScore": {
+ "score": 7,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["12", "K12"],
+ "ratingScore": {
+ "score": 12,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["16", "K16"],
+ "ratingScore": {
+ "score": 16,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["18", "K18"],
+ "ratingScore": {
+ "score": 18,
+ "subScore": null
+ }
+ }
+ ]
+}
diff --git a/Emby.Server.Implementations/Localization/Ratings/fr.csv b/Emby.Server.Implementations/Localization/Ratings/fr.csv
deleted file mode 100644
index 139ea376b7..0000000000
--- a/Emby.Server.Implementations/Localization/Ratings/fr.csv
+++ /dev/null
@@ -1,13 +0,0 @@
-Public Averti,0
-Tous Publics,0
-TP,0
-U,0
-0+,0
-6+,6
-9+,9
-10,10
-12,12
-14+,14
-16,16
-18,18
-X,1000
diff --git a/Emby.Server.Implementations/Localization/Ratings/fr.json b/Emby.Server.Implementations/Localization/Ratings/fr.json
new file mode 100644
index 0000000000..e8bafd6b87
--- /dev/null
+++ b/Emby.Server.Implementations/Localization/Ratings/fr.json
@@ -0,0 +1,69 @@
+{
+ "countryCode": "fr",
+ "supportsSubScores": false,
+ "ratings": [
+ {
+ "ratingStrings": ["0+", "Public Averti", "Tous Publics", "TP", "U"],
+ "ratingScore": {
+ "score": 0,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["6+"],
+ "ratingScore": {
+ "score": 6,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["9+"],
+ "ratingScore": {
+ "score": 9,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["10"],
+ "ratingScore": {
+ "score": 10,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["12"],
+ "ratingScore": {
+ "score": 12,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["14+"],
+ "ratingScore": {
+ "score": 14,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["16"],
+ "ratingScore": {
+ "score": 16,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["18"],
+ "ratingScore": {
+ "score": 18,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["X"],
+ "ratingScore": {
+ "score": 1000,
+ "subScore": null
+ }
+ }
+ ]
+}
diff --git a/Emby.Server.Implementations/Localization/Ratings/gb.csv b/Emby.Server.Implementations/Localization/Ratings/gb.csv
deleted file mode 100644
index 75b1c20589..0000000000
--- a/Emby.Server.Implementations/Localization/Ratings/gb.csv
+++ /dev/null
@@ -1,22 +0,0 @@
-All,0
-E,0
-G,0
-U,0
-0+,0
-6+,6
-7+,7
-PG,8
-9+,9
-12,12
-12+,12
-12A,12
-Teen,13
-13+,13
-14+,14
-15,15
-16,16
-Caution,18
-18,18
-Mature,1000
-Adult,1000
-R18,1000
diff --git a/Emby.Server.Implementations/Localization/Ratings/gb.json b/Emby.Server.Implementations/Localization/Ratings/gb.json
new file mode 100644
index 0000000000..7fc88272cf
--- /dev/null
+++ b/Emby.Server.Implementations/Localization/Ratings/gb.json
@@ -0,0 +1,97 @@
+{
+ "countryCode": "gb",
+ "supportsSubScores": true,
+ "ratings": [
+ {
+ "ratingStrings": ["0+", "All", "E", "G", "U"],
+ "ratingScore": {
+ "score": 0,
+ "subScore": 0
+ }
+ },
+ {
+ "ratingStrings": ["6+"],
+ "ratingScore": {
+ "score": 6,
+ "subScore": 0
+ }
+ },
+ {
+ "ratingStrings": ["7+"],
+ "ratingScore": {
+ "score": 7,
+ "subScore": 0
+ }
+ },
+ {
+ "ratingStrings": ["PG"],
+ "ratingScore": {
+ "score": 8,
+ "subScore": 0
+ }
+ },
+ {
+ "ratingStrings": ["9"],
+ "ratingScore": {
+ "score": 9,
+ "subScore": 0
+ }
+ },
+ {
+ "ratingStrings": ["12A", "12PG"],
+ "ratingScore": {
+ "score": 12,
+ "subScore": 0
+ }
+ },
+ {
+ "ratingStrings": ["12", "12+"],
+ "ratingScore": {
+ "score": 12,
+ "subScore": 1
+ }
+ },
+ {
+ "ratingStrings": ["13+", "Teen"],
+ "ratingScore": {
+ "score": 13,
+ "subScore": 0
+ }
+ },
+ {
+ "ratingStrings": ["14+"],
+ "ratingScore": {
+ "score": 14,
+ "subScore": 0
+ }
+ },
+ {
+ "ratingStrings": ["15"],
+ "ratingScore": {
+ "score": 15,
+ "subScore": 3
+ }
+ },
+ {
+ "ratingStrings": ["16"],
+ "ratingScore": {
+ "score": 16,
+ "subScore": 0
+ }
+ },
+ {
+ "ratingStrings": ["18", "Caution"],
+ "ratingScore": {
+ "score": 18,
+ "subScore": 1
+ }
+ },
+ {
+ "ratingStrings": ["Mature", "Adult", "R18"],
+ "ratingScore": {
+ "score": 1000,
+ "subScore": 0
+ }
+ }
+ ]
+}
diff --git a/Emby.Server.Implementations/Localization/Ratings/ie.csv b/Emby.Server.Implementations/Localization/Ratings/ie.csv
deleted file mode 100644
index 6ef2e50128..0000000000
--- a/Emby.Server.Implementations/Localization/Ratings/ie.csv
+++ /dev/null
@@ -1,9 +0,0 @@
-G,4
-PG,12
-12,12
-12A,12
-12PG,12
-15,15
-15A,15
-16,16
-18,18
diff --git a/Emby.Server.Implementations/Localization/Ratings/ie.json b/Emby.Server.Implementations/Localization/Ratings/ie.json
new file mode 100644
index 0000000000..f6cc56ed6d
--- /dev/null
+++ b/Emby.Server.Implementations/Localization/Ratings/ie.json
@@ -0,0 +1,55 @@
+{
+ "countryCode": "ie",
+ "supportsSubScores": true,
+ "ratings": [
+ {
+ "ratingStrings": ["G"],
+ "ratingScore": {
+ "score": 4,
+ "subScore": 0
+ }
+ },
+ {
+ "ratingStrings": ["12A", "12PG", "PG"],
+ "ratingScore": {
+ "score": 12,
+ "subScore": 0
+ }
+ },
+ {
+ "ratingStrings": ["12"],
+ "ratingScore": {
+ "score": 12,
+ "subScore": 1
+ }
+ },
+ {
+ "ratingStrings": ["15A", "15PG"],
+ "ratingScore": {
+ "score": 15,
+ "subScore": 0
+ }
+ },
+ {
+ "ratingStrings": ["15"],
+ "ratingScore": {
+ "score": 15,
+ "subScore": 3
+ }
+ },
+ {
+ "ratingStrings": ["16"],
+ "ratingScore": {
+ "score": 16,
+ "subScore": 0
+ }
+ },
+ {
+ "ratingStrings": ["18"],
+ "ratingScore": {
+ "score": 18,
+ "subScore": 1
+ }
+ }
+ ]
+}
diff --git a/Emby.Server.Implementations/Localization/Ratings/jp.csv b/Emby.Server.Implementations/Localization/Ratings/jp.csv
deleted file mode 100644
index bfb5fdaae9..0000000000
--- a/Emby.Server.Implementations/Localization/Ratings/jp.csv
+++ /dev/null
@@ -1,11 +0,0 @@
-A,0
-G,0
-B,12
-PG12,12
-C,15
-15+,15
-R15+,15
-16+,16
-D,17
-Z,18
-18+,18
diff --git a/Emby.Server.Implementations/Localization/Ratings/jp.json b/Emby.Server.Implementations/Localization/Ratings/jp.json
new file mode 100644
index 0000000000..efff9e92ce
--- /dev/null
+++ b/Emby.Server.Implementations/Localization/Ratings/jp.json
@@ -0,0 +1,62 @@
+{
+ "countryCode": "jp",
+ "supportsSubScores": true,
+ "ratings": [
+ {
+ "ratingStrings": ["A", "G"],
+ "ratingScore": {
+ "score": 0,
+ "subScore": 0
+ }
+ },
+ {
+ "ratingStrings": ["PG12"],
+ "ratingScore": {
+ "score": 12,
+ "subScore": 0
+ }
+ },
+ {
+ "ratingStrings": ["B"],
+ "ratingScore": {
+ "score": 12,
+ "subScore": 1
+ }
+ },
+ {
+ "ratingStrings": ["15A", "15PG"],
+ "ratingScore": {
+ "score": 15,
+ "subScore": 0
+ }
+ },
+ {
+ "ratingStrings": ["C", "15+", "R15+"],
+ "ratingScore": {
+ "score": 15,
+ "subScore": 1
+ }
+ },
+ {
+ "ratingStrings": ["16+"],
+ "ratingScore": {
+ "score": 16,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["D"],
+ "ratingScore": {
+ "score": 17,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["18+", "Z"],
+ "ratingScore": {
+ "score": 18,
+ "subScore": null
+ }
+ }
+ ]
+}
diff --git a/Emby.Server.Implementations/Localization/Ratings/kz.csv b/Emby.Server.Implementations/Localization/Ratings/kz.csv
deleted file mode 100644
index e26b32b67e..0000000000
--- a/Emby.Server.Implementations/Localization/Ratings/kz.csv
+++ /dev/null
@@ -1,6 +0,0 @@
-K,0
-БА,12
-Б14,14
-E16,16
-E18,18
-HA,18
diff --git a/Emby.Server.Implementations/Localization/Ratings/kz.json b/Emby.Server.Implementations/Localization/Ratings/kz.json
new file mode 100644
index 0000000000..0f8f0c68e5
--- /dev/null
+++ b/Emby.Server.Implementations/Localization/Ratings/kz.json
@@ -0,0 +1,41 @@
+{
+ "countryCode": "kz",
+ "supportsSubScores": false,
+ "ratings": [
+ {
+ "ratingStrings": ["K"],
+ "ratingScore": {
+ "score": 0,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["БА"],
+ "ratingScore": {
+ "score": 12,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["Б14"],
+ "ratingScore": {
+ "score": 14,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["E16"],
+ "ratingScore": {
+ "score": 16,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["E18", "HA"],
+ "ratingScore": {
+ "score": 18,
+ "subScore": null
+ }
+ }
+ ]
+}
diff --git a/Emby.Server.Implementations/Localization/Ratings/mx.csv b/Emby.Server.Implementations/Localization/Ratings/mx.csv
deleted file mode 100644
index 305912f239..0000000000
--- a/Emby.Server.Implementations/Localization/Ratings/mx.csv
+++ /dev/null
@@ -1,6 +0,0 @@
-A,0
-AA,0
-B,12
-B-15,15
-C,18
-D,1000
diff --git a/Emby.Server.Implementations/Localization/Ratings/mx.json b/Emby.Server.Implementations/Localization/Ratings/mx.json
new file mode 100644
index 0000000000..9dc3b89bd6
--- /dev/null
+++ b/Emby.Server.Implementations/Localization/Ratings/mx.json
@@ -0,0 +1,41 @@
+{
+ "countryCode": "mx",
+ "supportsSubScores": false,
+ "ratings": [
+ {
+ "ratingStrings": ["A", "AA"],
+ "ratingScore": {
+ "score": 0,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["B"],
+ "ratingScore": {
+ "score": 12,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["B-15"],
+ "ratingScore": {
+ "score": 15,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["C"],
+ "ratingScore": {
+ "score": 18,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["D"],
+ "ratingScore": {
+ "score": 1000,
+ "subScore": null
+ }
+ }
+ ]
+}
diff --git a/Emby.Server.Implementations/Localization/Ratings/nl.csv b/Emby.Server.Implementations/Localization/Ratings/nl.csv
deleted file mode 100644
index 44f372b2d6..0000000000
--- a/Emby.Server.Implementations/Localization/Ratings/nl.csv
+++ /dev/null
@@ -1,8 +0,0 @@
-AL,0
-MG6,6
-6,6
-9,9
-12,12
-14,14
-16,16
-18,18
diff --git a/Emby.Server.Implementations/Localization/Ratings/nl.json b/Emby.Server.Implementations/Localization/Ratings/nl.json
new file mode 100644
index 0000000000..2e43eb83ab
--- /dev/null
+++ b/Emby.Server.Implementations/Localization/Ratings/nl.json
@@ -0,0 +1,55 @@
+{
+ "countryCode": "nl",
+ "supportsSubScores": false,
+ "ratings": [
+ {
+ "ratingStrings": ["AL"],
+ "ratingScore": {
+ "score": 0,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["6", "MG6"],
+ "ratingScore": {
+ "score": 6,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["9"],
+ "ratingScore": {
+ "score": 9,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["12"],
+ "ratingScore": {
+ "score": 12,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["14"],
+ "ratingScore": {
+ "score": 14,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["16"],
+ "ratingScore": {
+ "score": 16,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["18"],
+ "ratingScore": {
+ "score": 18,
+ "subScore": null
+ }
+ }
+ ]
+}
diff --git a/Emby.Server.Implementations/Localization/Ratings/no.csv b/Emby.Server.Implementations/Localization/Ratings/no.csv
deleted file mode 100644
index c8f8e93db7..0000000000
--- a/Emby.Server.Implementations/Localization/Ratings/no.csv
+++ /dev/null
@@ -1,9 +0,0 @@
-A,0
-6,6
-7,7
-9,9
-11,11
-12,12
-15,15
-18,18
-Not approved,1001
diff --git a/Emby.Server.Implementations/Localization/Ratings/no.json b/Emby.Server.Implementations/Localization/Ratings/no.json
new file mode 100644
index 0000000000..a5e9523163
--- /dev/null
+++ b/Emby.Server.Implementations/Localization/Ratings/no.json
@@ -0,0 +1,69 @@
+{
+ "countryCode": "no",
+ "supportsSubScores": false,
+ "ratings": [
+ {
+ "ratingStrings": ["A"],
+ "ratingScore": {
+ "score": 0,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["6"],
+ "ratingScore": {
+ "score": 6,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["7"],
+ "ratingScore": {
+ "score": 7,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["9"],
+ "ratingScore": {
+ "score": 9,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["11"],
+ "ratingScore": {
+ "score": 11,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["12"],
+ "ratingScore": {
+ "score": 12,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["15"],
+ "ratingScore": {
+ "score": 15,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["18"],
+ "ratingScore": {
+ "score": 18,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["Not approved"],
+ "ratingScore": {
+ "score": 1001,
+ "subScore": null
+ }
+ }
+ ]
+}
diff --git a/Emby.Server.Implementations/Localization/Ratings/nz.csv b/Emby.Server.Implementations/Localization/Ratings/nz.csv
deleted file mode 100644
index f617f0c39d..0000000000
--- a/Emby.Server.Implementations/Localization/Ratings/nz.csv
+++ /dev/null
@@ -1,15 +0,0 @@
-Exempt,0
-G,0
-GY,13
-PG,13
-R13,13
-RP13,13
-R15,15
-M,16
-R16,16
-RP16,16
-GA,18
-R18,18
-MA,1000
-R,1001
-Objectionable,1001
diff --git a/Emby.Server.Implementations/Localization/Ratings/nz.json b/Emby.Server.Implementations/Localization/Ratings/nz.json
new file mode 100644
index 0000000000..3c1332271e
--- /dev/null
+++ b/Emby.Server.Implementations/Localization/Ratings/nz.json
@@ -0,0 +1,69 @@
+{
+ "countryCode": "nz",
+ "supportsSubScores": true,
+ "ratings": [
+ {
+ "ratingStrings": ["Exempt", "G"],
+ "ratingScore": {
+ "score": 0,
+ "subScore": 0
+ }
+ },
+ {
+ "ratingStrings": ["RP13", "PG"],
+ "ratingScore": {
+ "score": 13,
+ "subScore": 0
+ }
+ },
+ {
+ "ratingStrings": ["GY", "R13"],
+ "ratingScore": {
+ "score": 13,
+ "subScore": 1
+ }
+ },
+ {
+ "ratingStrings": ["RP16", "M"],
+ "ratingScore": {
+ "score": 16,
+ "subScore": 0
+ }
+ },
+ {
+ "ratingStrings": ["R16"],
+ "ratingScore": {
+ "score": 16,
+ "subScore": 1
+ }
+ },
+ {
+ "ratingStrings": ["RP18"],
+ "ratingScore": {
+ "score": 18,
+ "subScore": 0
+ }
+ },
+ {
+ "ratingStrings": ["R18", "GA"],
+ "ratingScore": {
+ "score": 18,
+ "subScore": 1
+ }
+ },
+ {
+ "ratingStrings": ["MA"],
+ "ratingScore": {
+ "score": 1000,
+ "subScore": 0
+ }
+ },
+ {
+ "ratingStrings": ["Objectionable", "R"],
+ "ratingScore": {
+ "score": 1001,
+ "subScore": 0
+ }
+ }
+ ]
+}
diff --git a/Emby.Server.Implementations/Localization/Ratings/pl.json b/Emby.Server.Implementations/Localization/Ratings/pl.json
new file mode 100644
index 0000000000..c3001ffb37
--- /dev/null
+++ b/Emby.Server.Implementations/Localization/Ratings/pl.json
@@ -0,0 +1,41 @@
+{
+ "countryCode": "pl",
+ "supportsSubScores": false,
+ "ratings": [
+ {
+ "ratingStrings": ["b.o.", "AL"],
+ "ratingScore": {
+ "score": 0,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["7", "od 7 lat"],
+ "ratingScore": {
+ "score": 7,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["12", "od 12 lat"],
+ "ratingScore": {
+ "score": 12,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["16", "od 16 lat"],
+ "ratingScore": {
+ "score": 16,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["18", "od 18 lat", "R"],
+ "ratingScore": {
+ "score": 18,
+ "subScore": null
+ }
+ }
+ ]
+}
diff --git a/Emby.Server.Implementations/Localization/Ratings/ro.csv b/Emby.Server.Implementations/Localization/Ratings/ro.csv
deleted file mode 100644
index 44c23e2486..0000000000
--- a/Emby.Server.Implementations/Localization/Ratings/ro.csv
+++ /dev/null
@@ -1,6 +0,0 @@
-AG,0
-AP-12,12
-N-15,15
-IM-18,18
-IM-18-XXX,1000
-IC,1001
diff --git a/Emby.Server.Implementations/Localization/Ratings/ro.json b/Emby.Server.Implementations/Localization/Ratings/ro.json
new file mode 100644
index 0000000000..9cf735a54c
--- /dev/null
+++ b/Emby.Server.Implementations/Localization/Ratings/ro.json
@@ -0,0 +1,48 @@
+{
+ "countryCode": "ro",
+ "supportsSubScores": false,
+ "ratings": [
+ {
+ "ratingStrings": ["AG"],
+ "ratingScore": {
+ "score": 0,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["AP-12"],
+ "ratingScore": {
+ "score": 12,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["N-15"],
+ "ratingScore": {
+ "score": 15,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["IM-18"],
+ "ratingScore": {
+ "score": 18,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["IM-18-XXX"],
+ "ratingScore": {
+ "score": 1000,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["IC"],
+ "ratingScore": {
+ "score": 1001,
+ "subScore": null
+ }
+ }
+ ]
+}
diff --git a/Emby.Server.Implementations/Localization/Ratings/ru.csv b/Emby.Server.Implementations/Localization/Ratings/ru.csv
deleted file mode 100644
index 8b264070ba..0000000000
--- a/Emby.Server.Implementations/Localization/Ratings/ru.csv
+++ /dev/null
@@ -1,6 +0,0 @@
-0+,0
-6+,6
-12+,12
-16+,16
-18+,18
-Refused classification,1001
diff --git a/Emby.Server.Implementations/Localization/Ratings/ru.json b/Emby.Server.Implementations/Localization/Ratings/ru.json
new file mode 100644
index 0000000000..d1b8b13aa0
--- /dev/null
+++ b/Emby.Server.Implementations/Localization/Ratings/ru.json
@@ -0,0 +1,48 @@
+{
+ "countryCode": "ru",
+ "supportsSubScores": false,
+ "ratings": [
+ {
+ "ratingStrings": ["0+"],
+ "ratingScore": {
+ "score": 0,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["6+"],
+ "ratingScore": {
+ "score": 6,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["12+"],
+ "ratingScore": {
+ "score": 12,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["16+"],
+ "ratingScore": {
+ "score": 16,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["18+"],
+ "ratingScore": {
+ "score": 18,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["Refused classification"],
+ "ratingScore": {
+ "score": 1001,
+ "subScore": null
+ }
+ }
+ ]
+}
diff --git a/Emby.Server.Implementations/Localization/Ratings/se.csv b/Emby.Server.Implementations/Localization/Ratings/se.csv
deleted file mode 100644
index e129c35617..0000000000
--- a/Emby.Server.Implementations/Localization/Ratings/se.csv
+++ /dev/null
@@ -1,10 +0,0 @@
-Alla,0
-Barntillåten,0
-Btl,0
-0+,0
-7,7
-9+,9
-10+,10
-11,11
-14,14
-15,15
diff --git a/Emby.Server.Implementations/Localization/Ratings/se.json b/Emby.Server.Implementations/Localization/Ratings/se.json
new file mode 100644
index 0000000000..70084995d1
--- /dev/null
+++ b/Emby.Server.Implementations/Localization/Ratings/se.json
@@ -0,0 +1,55 @@
+{
+ "countryCode": "se",
+ "supportsSubScores": false,
+ "ratings": [
+ {
+ "ratingStrings": ["0+", "Alla", "Barntillåten", "Btl"],
+ "ratingScore": {
+ "score": 0,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["7"],
+ "ratingScore": {
+ "score": 7,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["9+"],
+ "ratingScore": {
+ "score": 9,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["10+"],
+ "ratingScore": {
+ "score": 10,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["11"],
+ "ratingScore": {
+ "score": 11,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["14"],
+ "ratingScore": {
+ "score": 14,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["15"],
+ "ratingScore": {
+ "score": 15,
+ "subScore": null
+ }
+ }
+ ]
+}
diff --git a/Emby.Server.Implementations/Localization/Ratings/sk.csv b/Emby.Server.Implementations/Localization/Ratings/sk.csv
deleted file mode 100644
index dbafd8efa3..0000000000
--- a/Emby.Server.Implementations/Localization/Ratings/sk.csv
+++ /dev/null
@@ -1,6 +0,0 @@
-NR,0
-U,0
-7,7
-12,12
-15,15
-18,18
diff --git a/Emby.Server.Implementations/Localization/Ratings/sk.json b/Emby.Server.Implementations/Localization/Ratings/sk.json
new file mode 100644
index 0000000000..5ec6111ecd
--- /dev/null
+++ b/Emby.Server.Implementations/Localization/Ratings/sk.json
@@ -0,0 +1,41 @@
+{
+ "countryCode": "sk",
+ "supportsSubScores": false,
+ "ratings": [
+ {
+ "ratingStrings": ["U", "NR"],
+ "ratingScore": {
+ "score": 0,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["7"],
+ "ratingScore": {
+ "score": 7,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["12"],
+ "ratingScore": {
+ "score": 12,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["15"],
+ "ratingScore": {
+ "score": 15,
+ "subScore": null
+ }
+ },
+ {
+ "ratingStrings": ["18"],
+ "ratingScore": {
+ "score": 18,
+ "subScore": null
+ }
+ }
+ ]
+}
diff --git a/Emby.Server.Implementations/Localization/Ratings/uk.csv b/Emby.Server.Implementations/Localization/Ratings/uk.csv
deleted file mode 100644
index 75b1c20589..0000000000
--- a/Emby.Server.Implementations/Localization/Ratings/uk.csv
+++ /dev/null
@@ -1,22 +0,0 @@
-All,0
-E,0
-G,0
-U,0
-0+,0
-6+,6
-7+,7
-PG,8
-9+,9
-12,12
-12+,12
-12A,12
-Teen,13
-13+,13
-14+,14
-15,15
-16,16
-Caution,18
-18,18
-Mature,1000
-Adult,1000
-R18,1000
diff --git a/Emby.Server.Implementations/Localization/Ratings/uk.json b/Emby.Server.Implementations/Localization/Ratings/uk.json
new file mode 100644
index 0000000000..7fc88272cf
--- /dev/null
+++ b/Emby.Server.Implementations/Localization/Ratings/uk.json
@@ -0,0 +1,97 @@
+{
+ "countryCode": "gb",
+ "supportsSubScores": true,
+ "ratings": [
+ {
+ "ratingStrings": ["0+", "All", "E", "G", "U"],
+ "ratingScore": {
+ "score": 0,
+ "subScore": 0
+ }
+ },
+ {
+ "ratingStrings": ["6+"],
+ "ratingScore": {
+ "score": 6,
+ "subScore": 0
+ }
+ },
+ {
+ "ratingStrings": ["7+"],
+ "ratingScore": {
+ "score": 7,
+ "subScore": 0
+ }
+ },
+ {
+ "ratingStrings": ["PG"],
+ "ratingScore": {
+ "score": 8,
+ "subScore": 0
+ }
+ },
+ {
+ "ratingStrings": ["9"],
+ "ratingScore": {
+ "score": 9,
+ "subScore": 0
+ }
+ },
+ {
+ "ratingStrings": ["12A", "12PG"],
+ "ratingScore": {
+ "score": 12,
+ "subScore": 0
+ }
+ },
+ {
+ "ratingStrings": ["12", "12+"],
+ "ratingScore": {
+ "score": 12,
+ "subScore": 1
+ }
+ },
+ {
+ "ratingStrings": ["13+", "Teen"],
+ "ratingScore": {
+ "score": 13,
+ "subScore": 0
+ }
+ },
+ {
+ "ratingStrings": ["14+"],
+ "ratingScore": {
+ "score": 14,
+ "subScore": 0
+ }
+ },
+ {
+ "ratingStrings": ["15"],
+ "ratingScore": {
+ "score": 15,
+ "subScore": 3
+ }
+ },
+ {
+ "ratingStrings": ["16"],
+ "ratingScore": {
+ "score": 16,
+ "subScore": 0
+ }
+ },
+ {
+ "ratingStrings": ["18", "Caution"],
+ "ratingScore": {
+ "score": 18,
+ "subScore": 1
+ }
+ },
+ {
+ "ratingStrings": ["Mature", "Adult", "R18"],
+ "ratingScore": {
+ "score": 1000,
+ "subScore": 0
+ }
+ }
+ ]
+}
diff --git a/Emby.Server.Implementations/Localization/Ratings/us.csv b/Emby.Server.Implementations/Localization/Ratings/us.csv
deleted file mode 100644
index d103ddf42d..0000000000
--- a/Emby.Server.Implementations/Localization/Ratings/us.csv
+++ /dev/null
@@ -1,50 +0,0 @@
-Approved,0
-G,0
-TV-G,0
-TV-Y,0
-TV-Y7,7
-TV-Y7-FV,7
-PG,10
-PG-13,13
-TV-PG,13
-TV-PG-D,13
-TV-PG-L,13
-TV-PG-S,13
-TV-PG-V,13
-TV-PG-DL,13
-TV-PG-DS,13
-TV-PG-DV,13
-TV-PG-LS,13
-TV-PG-LV,13
-TV-PG-SV,13
-TV-PG-DLS,13
-TV-PG-DLV,13
-TV-PG-DSV,13
-TV-PG-LSV,13
-TV-PG-DLSV,13
-TV-14,14
-TV-14-D,14
-TV-14-L,14
-TV-14-S,14
-TV-14-V,14
-TV-14-DL,14
-TV-14-DS,14
-TV-14-DV,14
-TV-14-LS,14
-TV-14-LV,14
-TV-14-SV,14
-TV-14-DLS,14
-TV-14-DLV,14
-TV-14-DSV,14
-TV-14-LSV,14
-TV-14-DLSV,14
-NC-17,17
-R,17
-TV-MA,17
-TV-MA-L,17
-TV-MA-S,17
-TV-MA-V,17
-TV-MA-LS,17
-TV-MA-LV,17
-TV-MA-SV,17
-TV-MA-LSV,17
diff --git a/Emby.Server.Implementations/Localization/Ratings/us.json b/Emby.Server.Implementations/Localization/Ratings/us.json
new file mode 100644
index 0000000000..08a6373129
--- /dev/null
+++ b/Emby.Server.Implementations/Localization/Ratings/us.json
@@ -0,0 +1,83 @@
+{
+ "countryCode": "us",
+ "supportsSubScores": true,
+ "ratings": [
+ {
+ "ratingStrings": ["Approved", "G", "TV-G", "TV-Y"],
+ "ratingScore": {
+ "score": 0,
+ "subScore": 0
+ }
+ },
+ {
+ "ratingStrings": ["TV-Y7"],
+ "ratingScore": {
+ "score": 7,
+ "subScore": 0
+ }
+ },
+ {
+ "ratingStrings": ["TV-Y7-FV"],
+ "ratingScore": {
+ "score": 7,
+ "subScore": 1
+ }
+ },
+ {
+ "ratingStrings": ["PG", "TV-PG"],
+ "ratingScore": {
+ "score": 10,
+ "subScore": 0
+ }
+ },
+ {
+ "ratingStrings": ["TV-PG-D", "TV-PG-L", "TV-PG-S", "TV-PG-V", "TV-PG-DL", "TV-PG-DS", "TV-PG-DV", "TV-PG-LS", "TV-PG-LV", "TV-PG-SV", "TV-PG-DLS", "TV-PG-DLV", "TV-PG-DSV", "TV-PG-LSV", "TV-PG-DLSV"],
+ "ratingScore": {
+ "score": 10,
+ "subScore": 1
+ }
+ },
+ {
+ "ratingStrings": ["PG-13"],
+ "ratingScore": {
+ "score": 13,
+ "subScore": 0
+ }
+ },
+ {
+ "ratingStrings": ["TV-14"],
+ "ratingScore": {
+ "score": 14,
+ "subScore": 0
+ }
+ },
+ {
+ "ratingStrings": ["TV-14-D", "TV-14-L", "TV-14-S", "TV-14-V", "TV-14-DL", "TV-14-DS", "TV-14-DV", "TV-14-LS", "TV-14-LV", "TV-14-SV", "TV-14-DLS", "TV-14-DLV", "TV-14-DSV", "TV-14-LSV", "TV-14-DLSV"],
+ "ratingScore": {
+ "score": 14,
+ "subScore": 1
+ }
+ },
+ {
+ "ratingStrings": ["R"],
+ "ratingScore": {
+ "score": 17,
+ "subScore": 0
+ }
+ },
+ {
+ "ratingStrings": ["NC-17", "TV-MA", "TV-MA-L", "TV-MA-S", "TV-MA-V", "TV-MA-LS", "TV-MA-LV", "TV-MA-SV", "TV-MA-LSV"],
+ "ratingScore": {
+ "score": 17,
+ "subScore": 1
+ }
+ },
+ {
+ "ratingStrings": ["TV-X", "TV-AO"],
+ "ratingScore": {
+ "score": 18,
+ "subScore": 0
+ }
+ }
+ ]
+}
diff --git a/Emby.Server.Implementations/Localization/countries.json b/Emby.Server.Implementations/Localization/countries.json
index 0a11b3e458..d92dc880b1 100644
--- a/Emby.Server.Implementations/Localization/countries.json
+++ b/Emby.Server.Implementations/Localization/countries.json
@@ -336,7 +336,7 @@
"TwoLetterISORegionName": "IE"
},
{
- "DisplayName": "Islamic Republic of Pakistan",
+ "DisplayName": "Pakistan",
"Name": "PK",
"ThreeLetterISORegionName": "PAK",
"TwoLetterISORegionName": "PK"
diff --git a/Emby.Server.Implementations/Localization/iso6392.txt b/Emby.Server.Implementations/Localization/iso6392.txt
index b55c0fa330..00c2aee62d 100644
--- a/Emby.Server.Implementations/Localization/iso6392.txt
+++ b/Emby.Server.Implementations/Localization/iso6392.txt
@@ -10,7 +10,6 @@ afr||af|Afrikaans|afrikaans
ain|||Ainu|aïnou
aka||ak|Akan|akan
akk|||Akkadian|akkadien
-alb|sqi|sq|Albanian|albanais
ale|||Aleut|aléoute
alg|||Algonquian languages|algonquines, langues
alt|||Southern Altai|altai du Sud
@@ -21,7 +20,6 @@ apa|||Apache languages|apaches, langues
ara||ar|Arabic|arabe
arc|||Official Aramaic (700-300 BCE); Imperial Aramaic (700-300 BCE)|araméen d'empire (700-300 BCE)
arg||an|Aragonese|aragonais
-arm|hye|hy|Armenian|arménien
arn|||Mapudungun; Mapuche|mapudungun; mapuche; mapuce
arp|||Arapaho|arapaho
art|||Artificial languages|artificielles, langues
@@ -41,7 +39,6 @@ bak||ba|Bashkir|bachkir
bal|||Baluchi|baloutchi
bam||bm|Bambara|bambara
ban|||Balinese|balinais
-baq|eus|eu|Basque|basque
bas|||Basa|basa
bat|||Baltic languages|baltes, langues
bej|||Beja; Bedawiyet|bedja
@@ -56,6 +53,7 @@ bin|||Bini; Edo|bini; edo
bis||bi|Bislama|bichlamar
bla|||Siksika|blackfoot
bnt|||Bantu (Other)|bantoues, autres langues
+bod|tib|bo|Tibetan|tibétain
bos||bs|Bosnian|bosniaque
bra|||Braj|braj
bre||br|Breton|breton
@@ -63,7 +61,6 @@ btk|||Batak languages|batak, langues
bua|||Buriat|bouriate
bug|||Buginese|bugi
bul||bg|Bulgarian|bulgare
-bur|mya|my|Burmese|birman
byn|||Blin; Bilin|blin; bilen
cad|||Caddo|caddo
cai|||Central American Indian languages|amérindiennes de L'Amérique centrale, langues
@@ -72,14 +69,11 @@ cat||ca|Catalan; Valencian|catalan; valencien
cau|||Caucasian languages|caucasiennes, langues
ceb|||Cebuano|cebuano
cel|||Celtic languages|celtiques, langues; celtes, langues
+ces|cze|cs|Czech|tchèque
cha||ch|Chamorro|chamorro
chb|||Chibcha|chibcha
che||ce|Chechen|tchétchène
chg|||Chagatai|djaghataï
-chi|zho|zh|Chinese|chinois
-chi|zho|ze|Chinese; Bilingual|chinois
-chi|zho|zh-tw|Chinese; Traditional|chinois
-chi|zho|zh-hk|Chinese; Hong Kong|chinois
chk|||Chuukese|chuuk
chm|||Mari|mari
chn|||Chinook jargon|chinook, jargon
@@ -101,13 +95,14 @@ crh|||Crimean Tatar; Crimean Turkish|tatar de Crimé
crp|||Creoles and pidgins |créoles et pidgins
csb|||Kashubian|kachoube
cus|||Cushitic languages|couchitiques, langues
-cze|ces|cs|Czech|tchèque
+cym|wel|cy|Welsh|gallois
dak|||Dakota|dakota
dan||da|Danish|danois
dar|||Dargwa|dargwa
day|||Land Dayak languages|dayak, langues
del|||Delaware|delaware
den|||Slave (Athapascan)|esclave (athapascan)
+deu|ger|de|German|allemand
dgr|||Dogrib|dogrib
din|||Dinka|dinka
div||dv|Divehi; Dhivehi; Maldivian|maldivien
@@ -116,28 +111,30 @@ dra|||Dravidian languages|dravidiennes, langues
dsb|||Lower Sorbian|bas-sorabe
dua|||Duala|douala
dum|||Dutch, Middle (ca.1050-1350)|néerlandais moyen (ca. 1050-1350)
-dut|nld|nl|Dutch; Flemish|néerlandais; flamand
dyu|||Dyula|dioula
dzo||dz|Dzongkha|dzongkha
efi|||Efik|efik
egy|||Egyptian (Ancient)|égyptien
eka|||Ekajuk|ekajuk
+ell|gre|el|Greek, Modern (1453-)|grec moderne (après 1453)
elx|||Elamite|élamite
eng||en|English|anglais
enm|||English, Middle (1100-1500)|anglais moyen (1100-1500)
epo||eo|Esperanto|espéranto
est||et|Estonian|estonien
+eus|baq|eu|Basque|basque
ewe||ee|Ewe|éwé
ewo|||Ewondo|éwondo
fan|||Fang|fang
fao||fo|Faroese|féroïen
+fas|per|fa|Persian|persan
fat|||Fanti|fanti
fij||fj|Fijian|fidjien
fil|||Filipino; Pilipino|filipino; pilipino
fin||fi|Finnish|finnois
fiu|||Finno-Ugrian languages|finno-ougriennes, langues
fon|||Fon|fon
-fre|fra|fr|French|français
+fra|fre|fr|French|français
frm|||French, Middle (ca.1400-1600)|français moyen (1400-1600)
fro|||French, Old (842-ca.1400)|français ancien (842-ca.1400)
frc||fr-ca|French (Canada)|french
@@ -150,8 +147,6 @@ gaa|||Ga|ga
gay|||Gayo|gayo
gba|||Gbaya|gbaya
gem|||Germanic languages|germaniques, langues
-geo|kat|ka|Georgian|géorgien
-ger|deu|de|German|allemand
gez|||Geez|guèze
gil|||Gilbertese|kiribati
gla||gd|Gaelic; Scottish Gaelic|gaélique; gaélique écossais
@@ -165,7 +160,6 @@ gor|||Gorontalo|gorontalo
got|||Gothic|gothique
grb|||Grebo|grebo
grc|||Greek, Ancient (to 1453)|grec ancien (jusqu'à 1453)
-gre|ell|el|Greek, Modern (1453-)|grec moderne (après 1453)
grn||gn|Guarani|guarani
gsw|||Swiss German; Alemannic; Alsatian|suisse alémanique; alémanique; alsacien
guj||gu|Gujarati|goudjrati
@@ -186,9 +180,10 @@ hrv||hr|Croatian|croate
hsb|||Upper Sorbian|haut-sorabe
hun||hu|Hungarian|hongrois
hup|||Hupa|hupa
+hye|arm|hy|Armenian|arménien
iba|||Iban|iban
ibo||ig|Igbo|igbo
-ice|isl|is|Icelandic|islandais
+isl|ice|is|Icelandic|islandais
ido||io|Ido|ido
iii||ii|Sichuan Yi; Nuosu|yi de Sichuan
ijo|||Ijo languages|ijo, langues
@@ -217,6 +212,7 @@ kam|||Kamba|kamba
kan||kn|Kannada|kannada
kar|||Karen languages|karen, langues
kas||ks|Kashmiri|kashmiri
+kat|geo|ka|Georgian|géorgien
kau||kr|Kanuri|kanouri
kaw|||Kawi|kawi
kaz||kk|Kazakh|kazakh
@@ -263,7 +259,6 @@ lui|||Luiseno|luiseno
lun|||Lunda|lunda
luo|||Luo (Kenya and Tanzania)|luo (Kenya et Tanzanie)
lus|||Lushai|lushai
-mac|mkd|mk|Macedonian|macédonien
mad|||Madurese|madourais
mag|||Magahi|magahi
mah||mh|Marshallese|marshall
@@ -271,11 +266,9 @@ mai|||Maithili|maithili
mak|||Makasar|makassar
mal||ml|Malayalam|malayalam
man|||Mandingo|mandingue
-mao|mri|mi|Maori|maori
map|||Austronesian languages|austronésiennes, langues
mar||mr|Marathi|marathe
mas|||Masai|massaï
-may|msa|ms|Malay|malais
mdf|||Moksha|moksa
mdr|||Mandar|mandar
men|||Mende|mendé
@@ -283,6 +276,7 @@ mga|||Irish, Middle (900-1200)|irlandais moyen (900-1200)
mic|||Mi'kmaq; Micmac|mi'kmaq; micmac
min|||Minangkabau|minangkabau
mis|||Uncoded languages|langues non codées
+mkd|mac|mk|Macedonian|macédonien
mkh|||Mon-Khmer languages|môn-khmer, langues
mlg||mg|Malagasy|malgache
mlt||mt|Maltese|maltais
@@ -292,11 +286,14 @@ mno|||Manobo languages|manobo, langues
moh|||Mohawk|mohawk
mon||mn|Mongolian|mongol
mos|||Mossi|moré
+mri|mao|mi|Maori|maori
+msa|may|ms|Malay|malais
mul|||Multiple languages|multilingue
mun|||Munda languages|mounda, langues
mus|||Creek|muskogee
mwl|||Mirandese|mirandais
mwr|||Marwari|marvari
+mya|bur|my|Burmese|birman
myn|||Mayan languages|maya, langues
myv|||Erzya|erza
nah|||Nahuatl languages|nahuatl, langues
@@ -313,6 +310,7 @@ new|||Nepal Bhasa; Newari|nepal bhasa; newari
nia|||Nias|nias
nic|||Niger-Kordofanian languages|nigéro-kordofaniennes, langues
niu|||Niuean|niué
+nld|dut|nl|Dutch; Flemish|néerlandais; flamand
nno||nn|Norwegian Nynorsk; Nynorsk, Norwegian|norvégien nynorsk; nynorsk, norvégien
nob||nb|Bokmål, Norwegian; Norwegian Bokmål|norvégien bokmål
nog|||Nogai|nogaï; nogay
@@ -343,7 +341,6 @@ pan||pa|Panjabi; Punjabi|pendjabi
pap|||Papiamento|papiamento
pau|||Palauan|palau
peo|||Persian, Old (ca.600-400 B.C.)|perse, vieux (ca. 600-400 av. J.-C.)
-per|fas|fa|Persian|persan
phi|||Philippine languages|philippines, langues
phn|||Phoenician|phénicien
pli||pi|Pali|pali
@@ -363,7 +360,7 @@ rar|||Rarotongan; Cook Islands Maori|rarotonga; maori des îles Cook
roa|||Romance languages|romanes, langues
roh||rm|Romansh|romanche
rom|||Romany|tsigane
-rum|ron|ro|Romanian; Moldavian; Moldovan|roumain; moldave
+ron|rum|ro|Romanian; Moldavian; Moldovan|roumain; moldave
run||rn|Rundi|rundi
rup|||Aromanian; Arumanian; Macedo-Romanian|aroumain; macédo-roumain
rus||ru|Russian|russe
@@ -376,6 +373,7 @@ sam|||Samaritan Aramaic|samaritain
san||sa|Sanskrit|sanskrit
sas|||Sasak|sasak
sat|||Santali|santal
+scc|srp|sr|Serbian|serbe
scn|||Sicilian|sicilien
sco|||Scots|écossais
sel|||Selkup|selkoupe
@@ -388,7 +386,7 @@ sin||si|Sinhala; Sinhalese|singhalais
sio|||Siouan languages|sioux, langues
sit|||Sino-Tibetan languages|sino-tibétaines, langues
sla|||Slavic languages|slaves, langues
-slo|slk|sk|Slovak|slovaque
+slk|slo|sk|Slovak|slovaque
slv||sl|Slovenian|slovène
sma|||Southern Sami|sami du Sud
sme||se|Northern Sami|sami du Nord
@@ -406,9 +404,9 @@ son|||Songhai languages|songhai, langues
sot||st|Sotho, Southern|sotho du Sud
spa||es-mx|Spanish; Latin|espagnol; Latin
spa||es|Spanish; Castilian|espagnol; castillan
+sqi|alb|sq|Albanian|albanais
srd||sc|Sardinian|sarde
srn|||Sranan Tongo|sranan tongo
-srp|scc|sr|Serbian|serbe
srr|||Serer|sérère
ssa|||Nilo-Saharan languages|nilo-sahariennes, langues
ssw||ss|Swati|swati
@@ -431,7 +429,6 @@ tet|||Tetum|tetum
tgk||tg|Tajik|tadjik
tgl||tl|Tagalog|tagalog
tha||th|Thai|thaï
-tib|bod|bo|Tibetan|tibétain
tig|||Tigre|tigré
tir||ti|Tigrinya|tigrigna
tiv|||Tiv|tiv
@@ -470,7 +467,6 @@ wak|||Wakashan languages|wakashanes, langues
wal|||Walamo|walamo
war|||Waray|waray
was|||Washo|washo
-wel|cym|cy|Welsh|gallois
wen|||Sorbian languages|sorabes, langues
wln||wa|Walloon|wallon
wol||wo|Wolof|wolof
@@ -486,6 +482,10 @@ zbl|||Blissymbols; Blissymbolics; Bliss|symboles Bliss; Bliss
zen|||Zenaga|zenaga
zgh|||Standard Moroccan Tamazight|amazighe standard marocain
zha||za|Zhuang; Chuang|zhuang; chuang
+zho|chi|zh|Chinese|chinois
+zho|chi|ze|Chinese; Bilingual|chinois
+zho|chi|zh-tw|Chinese; Traditional|chinois
+zho|chi|zh-hk|Chinese; Hong Kong|chinois
znd|||Zande languages|zandé, langues
zul||zu|Zulu|zoulou
zun|||Zuni|zuni
diff --git a/Emby.Server.Implementations/MediaEncoder/EncodingManager.cs b/Emby.Server.Implementations/MediaEncoder/EncodingManager.cs
index eb55e32c50..ea78968617 100644
--- a/Emby.Server.Implementations/MediaEncoder/EncodingManager.cs
+++ b/Emby.Server.Implementations/MediaEncoder/EncodingManager.cs
@@ -28,7 +28,7 @@ namespace Emby.Server.Implementations.MediaEncoder
private readonly IFileSystem _fileSystem;
private readonly ILogger _logger;
private readonly IMediaEncoder _encoder;
- private readonly IChapterManager _chapterManager;
+ private readonly IChapterRepository _chapterManager;
private readonly ILibraryManager _libraryManager;
///
@@ -40,7 +40,7 @@ namespace Emby.Server.Implementations.MediaEncoder
ILogger logger,
IFileSystem fileSystem,
IMediaEncoder encoder,
- IChapterManager chapterManager,
+ IChapterRepository chapterManager,
ILibraryManager libraryManager)
{
_logger = logger;
diff --git a/Emby.Server.Implementations/Playlists/PlaylistManager.cs b/Emby.Server.Implementations/Playlists/PlaylistManager.cs
index 47ff22c0b3..98a43b6c98 100644
--- a/Emby.Server.Implementations/Playlists/PlaylistManager.cs
+++ b/Emby.Server.Implementations/Playlists/PlaylistManager.cs
@@ -9,8 +9,8 @@ using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
-using Jellyfin.Data.Entities;
using Jellyfin.Data.Enums;
+using Jellyfin.Database.Implementations.Entities;
using Jellyfin.Extensions;
using MediaBrowser.Controller.Dto;
using MediaBrowser.Controller.Entities;
@@ -216,14 +216,11 @@ namespace Emby.Server.Implementations.Playlists
var newItems = GetPlaylistItems(newItemIds, user, options)
.Where(i => i.SupportsAddingToPlaylist);
- // Filter out duplicate items, if necessary
- if (!_appConfig.DoPlaylistsAllowDuplicates())
- {
- var existingIds = playlist.LinkedChildren.Select(c => c.ItemId).ToHashSet();
- newItems = newItems
- .Where(i => !existingIds.Contains(i.Id))
- .Distinct();
- }
+ // 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
var childrenToAdd = newItems
@@ -269,7 +266,7 @@ namespace Emby.Server.Implementations.Playlists
var idList = entryIds.ToList();
- var removals = children.Where(i => idList.Contains(i.Item1.Id));
+ var removals = children.Where(i => idList.Contains(i.Item1.ItemId?.ToString("N", CultureInfo.InvariantCulture)));
playlist.LinkedChildren = children.Except(removals)
.Select(i => i.Item1)
@@ -286,26 +283,49 @@ namespace Emby.Server.Implementations.Playlists
RefreshPriority.High);
}
- public async Task MoveItemAsync(string playlistId, string entryId, int newIndex)
+ internal static int DetermineAdjustedIndex(int newPriorIndexAllChildren, int newIndex)
+ {
+ if (newIndex == 0)
+ {
+ return newPriorIndexAllChildren > 0 ? newPriorIndexAllChildren - 1 : 0;
+ }
+
+ return newPriorIndexAllChildren + 1;
+ }
+
+ public async Task MoveItemAsync(string playlistId, string entryId, int newIndex, Guid callingUserId)
{
if (_libraryManager.GetItemById(playlistId) is not Playlist playlist)
{
throw new ArgumentException("No Playlist exists with the supplied Id");
}
+ var user = _userManager.GetUserById(callingUserId);
var children = playlist.GetManageableItems().ToList();
+ var accessibleChildren = children.Where(c => c.Item2.IsVisible(user)).ToArray();
- var oldIndex = children.FindIndex(i => string.Equals(entryId, i.Item1.Id, StringComparison.OrdinalIgnoreCase));
+ var oldIndexAll = children.FindIndex(i => string.Equals(entryId, i.Item1.ItemId?.ToString("N", CultureInfo.InvariantCulture), StringComparison.OrdinalIgnoreCase));
+ var oldIndexAccessible = accessibleChildren.FindIndex(i => string.Equals(entryId, i.Item1.ItemId?.ToString("N", CultureInfo.InvariantCulture), StringComparison.OrdinalIgnoreCase));
- if (oldIndex == newIndex)
+ if (oldIndexAccessible == newIndex)
{
return;
}
- var item = playlist.LinkedChildren[oldIndex];
+ var newPriorItemIndex = newIndex > oldIndexAccessible ? newIndex : newIndex - 1 < 0 ? 0 : newIndex - 1;
+ var newPriorItemId = accessibleChildren[newPriorItemIndex].Item1.ItemId;
+ var newPriorItemIndexOnAllChildren = children.FindIndex(c => c.Item1.ItemId.Equals(newPriorItemId));
+ var adjustedNewIndex = DetermineAdjustedIndex(newPriorItemIndexOnAllChildren, newIndex);
+
+ var item = playlist.LinkedChildren.FirstOrDefault(i => string.Equals(entryId, i.ItemId?.ToString("N", CultureInfo.InvariantCulture), StringComparison.OrdinalIgnoreCase));
+ if (item is null)
+ {
+ _logger.LogWarning("Modified item not found in playlist. ItemId: {ItemId}, PlaylistId: {PlaylistId}", entryId, playlistId);
+
+ return;
+ }
var newList = playlist.LinkedChildren.ToList();
-
newList.Remove(item);
if (newIndex >= newList.Count)
@@ -314,7 +334,7 @@ namespace Emby.Server.Implementations.Playlists
}
else
{
- newList.Insert(newIndex, item);
+ newList.Insert(adjustedNewIndex, item);
}
playlist.LinkedChildren = [.. newList];
diff --git a/Emby.Server.Implementations/Playlists/PlaylistsFolder.cs b/Emby.Server.Implementations/Playlists/PlaylistsFolder.cs
index f65d609c71..a5be2b616e 100644
--- a/Emby.Server.Implementations/Playlists/PlaylistsFolder.cs
+++ b/Emby.Server.Implementations/Playlists/PlaylistsFolder.cs
@@ -3,14 +3,16 @@
using System.Collections.Generic;
using System.Linq;
using System.Text.Json.Serialization;
-using Jellyfin.Data.Entities;
using Jellyfin.Data.Enums;
+using Jellyfin.Database.Implementations.Entities;
+using MediaBrowser.Common;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Playlists;
using MediaBrowser.Model.Querying;
namespace Emby.Server.Implementations.Playlists
{
+ [RequiresSourceSerialisation]
public class PlaylistsFolder : BasePluginFolder
{
public PlaylistsFolder()
diff --git a/Emby.Server.Implementations/Plugins/PluginManager.cs b/Emby.Server.Implementations/Plugins/PluginManager.cs
index db82a2900a..8eeca3667e 100644
--- a/Emby.Server.Implementations/Plugins/PluginManager.cs
+++ b/Emby.Server.Implementations/Plugins/PluginManager.cs
@@ -119,7 +119,7 @@ namespace Emby.Server.Implementations.Plugins
// Now load the assemblies..
foreach (var plugin in _plugins)
{
- UpdatePluginSuperceedStatus(plugin);
+ UpdatePluginSupersededStatus(plugin);
if (plugin.IsEnabledAndSupported == false)
{
@@ -214,7 +214,7 @@ namespace Emby.Server.Implementations.Plugins
continue;
}
- UpdatePluginSuperceedStatus(plugin);
+ UpdatePluginSupersededStatus(plugin);
if (!plugin.IsEnabledAndSupported)
{
continue;
@@ -624,9 +624,9 @@ namespace Emby.Server.Implementations.Plugins
}
}
- private void UpdatePluginSuperceedStatus(LocalPlugin plugin)
+ private void UpdatePluginSupersededStatus(LocalPlugin plugin)
{
- if (plugin.Manifest.Status != PluginStatus.Superceded)
+ if (plugin.Manifest.Status != PluginStatus.Superseded)
{
return;
}
@@ -785,30 +785,27 @@ namespace Emby.Server.Implementations.Plugins
var cleaned = false;
var path = entry.Path;
- if (_config.RemoveOldPlugins)
+ // Attempt a cleanup of old folders.
+ try
{
- // Attempt a cleanup of old folders.
- try
- {
- _logger.LogDebug("Deleting {Path}", path);
- Directory.Delete(path, true);
- cleaned = true;
- }
+ _logger.LogDebug("Deleting {Path}", path);
+ Directory.Delete(path, true);
+ cleaned = true;
+ }
#pragma warning disable CA1031 // Do not catch general exception types
- catch (Exception e)
+ catch (Exception e)
#pragma warning restore CA1031 // Do not catch general exception types
- {
- _logger.LogWarning(e, "Unable to delete {Path}", path);
- }
+ {
+ _logger.LogWarning(e, "Unable to delete {Path}", path);
+ }
- if (cleaned)
- {
- versions.RemoveAt(x);
- }
- else
- {
- ChangePluginState(entry, PluginStatus.Deleted);
- }
+ if (cleaned)
+ {
+ versions.RemoveAt(x);
+ }
+ else
+ {
+ ChangePluginState(entry, PluginStatus.Deleted);
}
}
@@ -835,7 +832,7 @@ namespace Emby.Server.Implementations.Plugins
/// If the is null.
private bool TryGetPluginDlls(LocalPlugin plugin, out IReadOnlyList whitelistedDlls)
{
- ArgumentNullException.ThrowIfNull(nameof(plugin));
+ ArgumentNullException.ThrowIfNull(plugin);
IReadOnlyList pluginDlls = Directory.GetFiles(plugin.Path, "*.dll", SearchOption.AllDirectories);
@@ -879,7 +876,7 @@ namespace Emby.Server.Implementations.Plugins
}
///
- /// Changes the status of the other versions of the plugin to "Superceded".
+ /// Changes the status of the other versions of the plugin to "Superseded".
///
/// The that's master.
private void ProcessAlternative(LocalPlugin plugin)
@@ -899,11 +896,11 @@ namespace Emby.Server.Implementations.Plugins
return;
}
- if (plugin.Manifest.Status == PluginStatus.Active && !ChangePluginState(previousVersion, PluginStatus.Superceded))
+ if (plugin.Manifest.Status == PluginStatus.Active && !ChangePluginState(previousVersion, PluginStatus.Superseded))
{
_logger.LogError("Unable to enable version {Version} of {Name}", previousVersion.Version, previousVersion.Name);
}
- else if (plugin.Manifest.Status == PluginStatus.Superceded && !ChangePluginState(previousVersion, PluginStatus.Active))
+ else if (plugin.Manifest.Status == PluginStatus.Superseded && !ChangePluginState(previousVersion, PluginStatus.Active))
{
_logger.LogError("Unable to supercede version {Version} of {Name}", previousVersion.Version, previousVersion.Name);
}
diff --git a/Emby.Server.Implementations/ScheduledTasks/ScheduledTaskWorker.cs b/Emby.Server.Implementations/ScheduledTasks/ScheduledTaskWorker.cs
index 9b342cfbe1..985f0a8f85 100644
--- a/Emby.Server.Implementations/ScheduledTasks/ScheduledTaskWorker.cs
+++ b/Emby.Server.Implementations/ScheduledTasks/ScheduledTaskWorker.cs
@@ -27,7 +27,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
private readonly IApplicationPaths _applicationPaths;
private readonly ILogger _logger;
private readonly ITaskManager _taskManager;
- private readonly object _lastExecutionResultSyncLock = new();
+ private readonly Lock _lastExecutionResultSyncLock = new();
private bool _readFromFile;
private TaskResult _lastExecutionResult;
private Task _currentTask;
@@ -471,7 +471,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
new()
{
IntervalTicks = TimeSpan.FromDays(1).Ticks,
- Type = TaskTriggerInfo.TriggerInterval
+ Type = TaskTriggerInfoType.IntervalTrigger
}
];
}
@@ -543,7 +543,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
{
DisposeTriggers();
- var wassRunning = State == TaskState.Running;
+ var wasRunning = State == TaskState.Running;
var startTime = CurrentExecutionStartTime;
var token = CurrentCancellationTokenSource;
@@ -596,7 +596,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
}
}
- if (wassRunning)
+ if (wasRunning)
{
OnTaskCompleted(startTime, DateTime.UtcNow, TaskCompletionStatus.Aborted, null);
}
@@ -616,7 +616,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
MaxRuntimeTicks = info.MaxRuntimeTicks
};
- if (info.Type.Equals(nameof(DailyTrigger), StringComparison.OrdinalIgnoreCase))
+ if (info.Type == TaskTriggerInfoType.DailyTrigger)
{
if (!info.TimeOfDayTicks.HasValue)
{
@@ -626,7 +626,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
return new DailyTrigger(TimeSpan.FromTicks(info.TimeOfDayTicks.Value), options);
}
- if (info.Type.Equals(nameof(WeeklyTrigger), StringComparison.OrdinalIgnoreCase))
+ if (info.Type == TaskTriggerInfoType.WeeklyTrigger)
{
if (!info.TimeOfDayTicks.HasValue)
{
@@ -641,7 +641,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
return new WeeklyTrigger(TimeSpan.FromTicks(info.TimeOfDayTicks.Value), info.DayOfWeek.Value, options);
}
- if (info.Type.Equals(nameof(IntervalTrigger), StringComparison.OrdinalIgnoreCase))
+ if (info.Type == TaskTriggerInfoType.IntervalTrigger)
{
if (!info.IntervalTicks.HasValue)
{
@@ -651,7 +651,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
return new IntervalTrigger(TimeSpan.FromTicks(info.IntervalTicks.Value), options);
}
- if (info.Type.Equals(nameof(StartupTrigger), StringComparison.OrdinalIgnoreCase))
+ if (info.Type == TaskTriggerInfoType.StartupTrigger)
{
return new StartupTrigger(options);
}
diff --git a/Emby.Server.Implementations/ScheduledTasks/Tasks/AudioNormalizationTask.cs b/Emby.Server.Implementations/ScheduledTasks/Tasks/AudioNormalizationTask.cs
index eb6afe05d0..8d1d509ff7 100644
--- a/Emby.Server.Implementations/ScheduledTasks/Tasks/AudioNormalizationTask.cs
+++ b/Emby.Server.Implementations/ScheduledTasks/Tasks/AudioNormalizationTask.cs
@@ -116,6 +116,7 @@ public partial class AudioNormalizationTask : IScheduledTask
{
a.LUFS = await CalculateLUFSAsync(
string.Format(CultureInfo.InvariantCulture, "-f concat -safe 0 -i \"{0}\"", tempFile),
+ OperatingSystem.IsWindows(), // Wait for process to exit on Windows before we try deleting the concat file
cancellationToken).ConfigureAwait(false);
}
finally
@@ -142,7 +143,10 @@ public partial class AudioNormalizationTask : IScheduledTask
continue;
}
- t.LUFS = await CalculateLUFSAsync(string.Format(CultureInfo.InvariantCulture, "-i \"{0}\"", t.Path.Replace("\"", "\\\"", StringComparison.Ordinal)), cancellationToken).ConfigureAwait(false);
+ t.LUFS = await CalculateLUFSAsync(
+ string.Format(CultureInfo.InvariantCulture, "-i \"{0}\"", t.Path.Replace("\"", "\\\"", StringComparison.Ordinal)),
+ false,
+ cancellationToken).ConfigureAwait(false);
}
_itemRepository.SaveItems(tracks, cancellationToken);
@@ -156,13 +160,13 @@ public partial class AudioNormalizationTask : IScheduledTask
[
new TaskTriggerInfo
{
- Type = TaskTriggerInfo.TriggerInterval,
+ Type = TaskTriggerInfoType.IntervalTrigger,
IntervalTicks = TimeSpan.FromHours(24).Ticks
}
];
}
- private async Task CalculateLUFSAsync(string inputArgs, CancellationToken cancellationToken)
+ private async Task CalculateLUFSAsync(string inputArgs, bool waitForExit, CancellationToken cancellationToken)
{
var args = $"-hide_banner {inputArgs} -af ebur128=framelog=verbose -f null -";
@@ -189,18 +193,28 @@ public partial class AudioNormalizationTask : IScheduledTask
}
using var reader = process.StandardError;
+ float? lufs = null;
await foreach (var line in reader.ReadAllLinesAsync(cancellationToken))
{
Match match = LUFSRegex().Match(line);
-
if (match.Success)
{
- return float.Parse(match.Groups[1].ValueSpan, CultureInfo.InvariantCulture.NumberFormat);
+ lufs = float.Parse(match.Groups[1].ValueSpan, CultureInfo.InvariantCulture.NumberFormat);
+ break;
}
}
- _logger.LogError("Failed to find LUFS value in output");
- return null;
+ if (lufs is null)
+ {
+ _logger.LogError("Failed to find LUFS value in output");
+ }
+
+ if (waitForExit)
+ {
+ await process.WaitForExitAsync(cancellationToken).ConfigureAwait(false);
+ }
+
+ return lufs;
}
}
}
diff --git a/Emby.Server.Implementations/ScheduledTasks/Tasks/ChapterImagesTask.cs b/Emby.Server.Implementations/ScheduledTasks/Tasks/ChapterImagesTask.cs
index cb3f5b8363..563e90fbea 100644
--- a/Emby.Server.Implementations/ScheduledTasks/Tasks/ChapterImagesTask.cs
+++ b/Emby.Server.Implementations/ScheduledTasks/Tasks/ChapterImagesTask.cs
@@ -7,6 +7,7 @@ using System.Threading.Tasks;
using Jellyfin.Data.Enums;
using Jellyfin.Extensions;
using MediaBrowser.Common.Configuration;
+using MediaBrowser.Controller.Chapters;
using MediaBrowser.Controller.Dto;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library;
@@ -32,6 +33,7 @@ namespace Emby.Server.Implementations.ScheduledTasks.Tasks
private readonly IEncodingManager _encodingManager;
private readonly IFileSystem _fileSystem;
private readonly ILocalizationManager _localization;
+ private readonly IChapterRepository _chapterRepository;
///
/// Initializes a new instance of the class.
@@ -43,6 +45,7 @@ namespace Emby.Server.Implementations.ScheduledTasks.Tasks
/// Instance of the interface.
/// Instance of the interface.
/// Instance of the interface.
+ /// Instance of the interface.
public ChapterImagesTask(
ILogger logger,
ILibraryManager libraryManager,
@@ -50,7 +53,8 @@ namespace Emby.Server.Implementations.ScheduledTasks.Tasks
IApplicationPaths appPaths,
IEncodingManager encodingManager,
IFileSystem fileSystem,
- ILocalizationManager localization)
+ ILocalizationManager localization,
+ IChapterRepository chapterRepository)
{
_logger = logger;
_libraryManager = libraryManager;
@@ -59,6 +63,7 @@ namespace Emby.Server.Implementations.ScheduledTasks.Tasks
_encodingManager = encodingManager;
_fileSystem = fileSystem;
_localization = localization;
+ _chapterRepository = chapterRepository;
}
///
@@ -80,7 +85,7 @@ namespace Emby.Server.Implementations.ScheduledTasks.Tasks
[
new TaskTriggerInfo
{
- Type = TaskTriggerInfo.TriggerDaily,
+ Type = TaskTriggerInfoType.DailyTrigger,
TimeOfDayTicks = TimeSpan.FromHours(2).Ticks,
MaxRuntimeTicks = TimeSpan.FromHours(4).Ticks
}
@@ -141,7 +146,7 @@ namespace Emby.Server.Implementations.ScheduledTasks.Tasks
try
{
- var chapters = _itemRepo.GetChapters(video);
+ var chapters = _chapterRepository.GetChapters(video.Id);
var success = await _encodingManager.RefreshChapterImages(video, directoryService, chapters, extract, true, cancellationToken).ConfigureAwait(false);
diff --git a/Emby.Server.Implementations/ScheduledTasks/Tasks/CleanupCollectionAndPlaylistPathsTask.cs b/Emby.Server.Implementations/ScheduledTasks/Tasks/CleanupCollectionAndPlaylistPathsTask.cs
index 25e7ebe799..8901390aae 100644
--- a/Emby.Server.Implementations/ScheduledTasks/Tasks/CleanupCollectionAndPlaylistPathsTask.cs
+++ b/Emby.Server.Implementations/ScheduledTasks/Tasks/CleanupCollectionAndPlaylistPathsTask.cs
@@ -84,7 +84,7 @@ public class CleanupCollectionAndPlaylistPathsTask : IScheduledTask
var collection = collections[index];
_logger.LogDebug("Checking boxset {CollectionName}", collection.Name);
- CleanupLinkedChildren(collection, cancellationToken);
+ await CleanupLinkedChildrenAsync(collection, cancellationToken).ConfigureAwait(false);
progress.Report(50D / collections.Length * (index + 1));
}
}
@@ -104,12 +104,12 @@ public class CleanupCollectionAndPlaylistPathsTask : IScheduledTask
var playlist = playlists[index];
_logger.LogDebug("Checking playlist {PlaylistName}", playlist.Name);
- CleanupLinkedChildren(playlist, cancellationToken);
+ await CleanupLinkedChildrenAsync(playlist, cancellationToken).ConfigureAwait(false);
progress.Report(50D / playlists.Length * (index + 1));
}
}
- private void CleanupLinkedChildren(T folder, CancellationToken cancellationToken)
+ private async Task CleanupLinkedChildrenAsync(T folder, CancellationToken cancellationToken)
where T : Folder
{
List? itemsToRemove = null;
@@ -127,14 +127,14 @@ public class CleanupCollectionAndPlaylistPathsTask : IScheduledTask
{
_logger.LogDebug("Updating {FolderName}", folder.Name);
folder.LinkedChildren = folder.LinkedChildren.Except(itemsToRemove).ToArray();
- _providerManager.SaveMetadataAsync(folder, ItemUpdateType.MetadataEdit);
- folder.UpdateToRepositoryAsync(ItemUpdateType.MetadataEdit, cancellationToken);
+ await _providerManager.SaveMetadataAsync(folder, ItemUpdateType.MetadataEdit).ConfigureAwait(false);
+ await folder.UpdateToRepositoryAsync(ItemUpdateType.MetadataEdit, cancellationToken).ConfigureAwait(false);
}
}
///
public IEnumerable GetDefaultTriggers()
{
- return [new TaskTriggerInfo() { Type = TaskTriggerInfo.TriggerStartup }];
+ return [new TaskTriggerInfo() { Type = TaskTriggerInfoType.StartupTrigger }];
}
}
diff --git a/Emby.Server.Implementations/ScheduledTasks/Tasks/DeleteCacheFileTask.cs b/Emby.Server.Implementations/ScheduledTasks/Tasks/DeleteCacheFileTask.cs
index 0325cb9af8..ff295d9b7e 100644
--- a/Emby.Server.Implementations/ScheduledTasks/Tasks/DeleteCacheFileTask.cs
+++ b/Emby.Server.Implementations/ScheduledTasks/Tasks/DeleteCacheFileTask.cs
@@ -73,7 +73,7 @@ namespace Emby.Server.Implementations.ScheduledTasks.Tasks
return
[
// Every so often
- new TaskTriggerInfo { Type = TaskTriggerInfo.TriggerInterval, IntervalTicks = TimeSpan.FromHours(24).Ticks }
+ new TaskTriggerInfo { Type = TaskTriggerInfoType.IntervalTrigger, IntervalTicks = TimeSpan.FromHours(24).Ticks }
];
}
diff --git a/Emby.Server.Implementations/ScheduledTasks/Tasks/DeleteLogFileTask.cs b/Emby.Server.Implementations/ScheduledTasks/Tasks/DeleteLogFileTask.cs
index 9babe8cf9f..a091c2bd90 100644
--- a/Emby.Server.Implementations/ScheduledTasks/Tasks/DeleteLogFileTask.cs
+++ b/Emby.Server.Implementations/ScheduledTasks/Tasks/DeleteLogFileTask.cs
@@ -62,7 +62,7 @@ namespace Emby.Server.Implementations.ScheduledTasks.Tasks
{
return
[
- new TaskTriggerInfo { Type = TaskTriggerInfo.TriggerInterval, IntervalTicks = TimeSpan.FromHours(24).Ticks }
+ new TaskTriggerInfo { Type = TaskTriggerInfoType.IntervalTrigger, IntervalTicks = TimeSpan.FromHours(24).Ticks }
];
}
diff --git a/Emby.Server.Implementations/ScheduledTasks/Tasks/DeleteTranscodeFileTask.cs b/Emby.Server.Implementations/ScheduledTasks/Tasks/DeleteTranscodeFileTask.cs
index 315c245cc5..d0896cc812 100644
--- a/Emby.Server.Implementations/ScheduledTasks/Tasks/DeleteTranscodeFileTask.cs
+++ b/Emby.Server.Implementations/ScheduledTasks/Tasks/DeleteTranscodeFileTask.cs
@@ -69,11 +69,11 @@ namespace Emby.Server.Implementations.ScheduledTasks.Tasks
[
new TaskTriggerInfo
{
- Type = TaskTriggerInfo.TriggerStartup
+ Type = TaskTriggerInfoType.StartupTrigger
},
new TaskTriggerInfo
{
- Type = TaskTriggerInfo.TriggerInterval,
+ Type = TaskTriggerInfoType.IntervalTrigger,
IntervalTicks = TimeSpan.FromHours(24).Ticks
}
];
diff --git a/Emby.Server.Implementations/ScheduledTasks/Tasks/MediaSegmentExtractionTask.cs b/Emby.Server.Implementations/ScheduledTasks/Tasks/MediaSegmentExtractionTask.cs
index d6fad7526b..de1e60d307 100644
--- a/Emby.Server.Implementations/ScheduledTasks/Tasks/MediaSegmentExtractionTask.cs
+++ b/Emby.Server.Implementations/ScheduledTasks/Tasks/MediaSegmentExtractionTask.cs
@@ -111,7 +111,7 @@ public class MediaSegmentExtractionTask : IScheduledTask
{
yield return new TaskTriggerInfo
{
- Type = TaskTriggerInfo.TriggerInterval,
+ Type = TaskTriggerInfoType.IntervalTrigger,
IntervalTicks = TimeSpan.FromHours(12).Ticks
};
}
diff --git a/Emby.Server.Implementations/ScheduledTasks/Tasks/OptimizeDatabaseTask.cs b/Emby.Server.Implementations/ScheduledTasks/Tasks/OptimizeDatabaseTask.cs
index 3e4925f74d..4d3a04377f 100644
--- a/Emby.Server.Implementations/ScheduledTasks/Tasks/OptimizeDatabaseTask.cs
+++ b/Emby.Server.Implementations/ScheduledTasks/Tasks/OptimizeDatabaseTask.cs
@@ -2,7 +2,7 @@ using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
-using Jellyfin.Server.Implementations;
+using Jellyfin.Database.Implementations;
using MediaBrowser.Model.Globalization;
using MediaBrowser.Model.Tasks;
using Microsoft.EntityFrameworkCore;
@@ -18,6 +18,7 @@ namespace Emby.Server.Implementations.ScheduledTasks.Tasks
private readonly ILogger _logger;
private readonly ILocalizationManager _localization;
private readonly IDbContextFactory _provider;
+ private readonly IJellyfinDatabaseProvider _jellyfinDatabaseProvider;
///
/// Initializes a new instance of the class.
@@ -25,14 +26,17 @@ namespace Emby.Server.Implementations.ScheduledTasks.Tasks
/// Instance of the interface.
/// Instance of the interface.
/// Instance of the interface.
+ /// Instance of the JellyfinDatabaseProvider that can be used for provider specific operations.
public OptimizeDatabaseTask(
ILogger logger,
ILocalizationManager localization,
- IDbContextFactory provider)
+ IDbContextFactory provider,
+ IJellyfinDatabaseProvider jellyfinDatabaseProvider)
{
_logger = logger;
_localization = localization;
_provider = provider;
+ _jellyfinDatabaseProvider = jellyfinDatabaseProvider;
}
///
@@ -62,7 +66,7 @@ namespace Emby.Server.Implementations.ScheduledTasks.Tasks
return
[
// Every so often
- new TaskTriggerInfo { Type = TaskTriggerInfo.TriggerInterval, IntervalTicks = TimeSpan.FromHours(24).Ticks }
+ new TaskTriggerInfo { Type = TaskTriggerInfoType.IntervalTrigger, IntervalTicks = TimeSpan.FromHours(24).Ticks }
];
}
@@ -73,20 +77,7 @@ namespace Emby.Server.Implementations.ScheduledTasks.Tasks
try
{
- var context = await _provider.CreateDbContextAsync(cancellationToken).ConfigureAwait(false);
- await using (context.ConfigureAwait(false))
- {
- if (context.Database.IsSqlite())
- {
- await context.Database.ExecuteSqlRawAsync("PRAGMA optimize", cancellationToken).ConfigureAwait(false);
- await context.Database.ExecuteSqlRawAsync("VACUUM", cancellationToken).ConfigureAwait(false);
- _logger.LogInformation("jellyfin.db optimized successfully!");
- }
- else
- {
- _logger.LogInformation("This database doesn't support optimization");
- }
- }
+ await _jellyfinDatabaseProvider.RunScheduledOptimisation(cancellationToken).ConfigureAwait(false);
}
catch (Exception e)
{
diff --git a/Emby.Server.Implementations/ScheduledTasks/Tasks/PeopleValidationTask.cs b/Emby.Server.Implementations/ScheduledTasks/Tasks/PeopleValidationTask.cs
index c63bad4748..2907f18b55 100644
--- a/Emby.Server.Implementations/ScheduledTasks/Tasks/PeopleValidationTask.cs
+++ b/Emby.Server.Implementations/ScheduledTasks/Tasks/PeopleValidationTask.cs
@@ -58,7 +58,7 @@ namespace Emby.Server.Implementations.ScheduledTasks.Tasks
{
new TaskTriggerInfo
{
- Type = TaskTriggerInfo.TriggerInterval,
+ Type = TaskTriggerInfoType.IntervalTrigger,
IntervalTicks = TimeSpan.FromDays(7).Ticks
}
};
diff --git a/Emby.Server.Implementations/ScheduledTasks/Tasks/PluginUpdateTask.cs b/Emby.Server.Implementations/ScheduledTasks/Tasks/PluginUpdateTask.cs
index ad72a4c87e..b74f4d1b25 100644
--- a/Emby.Server.Implementations/ScheduledTasks/Tasks/PluginUpdateTask.cs
+++ b/Emby.Server.Implementations/ScheduledTasks/Tasks/PluginUpdateTask.cs
@@ -60,10 +60,10 @@ namespace Emby.Server.Implementations.ScheduledTasks.Tasks
public IEnumerable GetDefaultTriggers()
{
// At startup
- yield return new TaskTriggerInfo { Type = TaskTriggerInfo.TriggerStartup };
+ yield return new TaskTriggerInfo { Type = TaskTriggerInfoType.StartupTrigger };
// Every so often
- yield return new TaskTriggerInfo { Type = TaskTriggerInfo.TriggerInterval, IntervalTicks = TimeSpan.FromHours(24).Ticks };
+ yield return new TaskTriggerInfo { Type = TaskTriggerInfoType.IntervalTrigger, IntervalTicks = TimeSpan.FromHours(24).Ticks };
}
///
@@ -88,7 +88,7 @@ namespace Emby.Server.Implementations.ScheduledTasks.Tasks
}
catch (OperationCanceledException)
{
- // InstallPackage has it's own inner cancellation token, so only throw this if it's ours
+ // InstallPackage has its own inner cancellation token, so only throw this if it's ours
if (cancellationToken.IsCancellationRequested)
{
throw;
diff --git a/Emby.Server.Implementations/ScheduledTasks/Tasks/RefreshMediaLibraryTask.cs b/Emby.Server.Implementations/ScheduledTasks/Tasks/RefreshMediaLibraryTask.cs
index a59f0f3669..172448ddec 100644
--- a/Emby.Server.Implementations/ScheduledTasks/Tasks/RefreshMediaLibraryTask.cs
+++ b/Emby.Server.Implementations/ScheduledTasks/Tasks/RefreshMediaLibraryTask.cs
@@ -48,7 +48,7 @@ namespace Emby.Server.Implementations.ScheduledTasks.Tasks
{
yield return new TaskTriggerInfo
{
- Type = TaskTriggerInfo.TriggerInterval,
+ Type = TaskTriggerInfoType.IntervalTrigger,
IntervalTicks = TimeSpan.FromHours(12).Ticks
};
}
diff --git a/Emby.Server.Implementations/Session/SessionManager.cs b/Emby.Server.Implementations/Session/SessionManager.cs
index 6a8ad2bdc5..924f502860 100644
--- a/Emby.Server.Implementations/Session/SessionManager.cs
+++ b/Emby.Server.Implementations/Session/SessionManager.cs
@@ -7,11 +7,13 @@ using System.Globalization;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
-using Jellyfin.Data.Entities;
-using Jellyfin.Data.Entities.Security;
+using Jellyfin.Data;
using Jellyfin.Data.Enums;
using Jellyfin.Data.Events;
using Jellyfin.Data.Queries;
+using Jellyfin.Database.Implementations.Entities;
+using Jellyfin.Database.Implementations.Entities.Security;
+using Jellyfin.Database.Implementations.Enums;
using Jellyfin.Extensions;
using MediaBrowser.Common.Events;
using MediaBrowser.Common.Extensions;
@@ -62,6 +64,9 @@ namespace Emby.Server.Implementations.Session
private readonly ConcurrentDictionary _activeConnections
= new(StringComparer.OrdinalIgnoreCase);
+ private readonly ConcurrentDictionary> _activeLiveStreamSessions
+ = new(StringComparer.OrdinalIgnoreCase);
+
private Timer _idleTimer;
private Timer _inactiveTimer;
@@ -309,13 +314,49 @@ namespace Emby.Server.Implementations.Session
_activeConnections.TryRemove(key, out _);
if (!string.IsNullOrEmpty(session.PlayState?.LiveStreamId))
{
- await _mediaSourceManager.CloseLiveStream(session.PlayState.LiveStreamId).ConfigureAwait(false);
+ await CloseLiveStreamIfNeededAsync(session.PlayState.LiveStreamId, session.Id).ConfigureAwait(false);
}
await OnSessionEnded(session).ConfigureAwait(false);
}
}
+ ///
+ public async Task CloseLiveStreamIfNeededAsync(string liveStreamId, string sessionIdOrPlaySessionId)
+ {
+ bool liveStreamNeedsToBeClosed = false;
+
+ if (_activeLiveStreamSessions.TryGetValue(liveStreamId, out var activeSessionMappings))
+ {
+ if (activeSessionMappings.TryRemove(sessionIdOrPlaySessionId, out var correspondingId))
+ {
+ if (!string.IsNullOrEmpty(correspondingId))
+ {
+ activeSessionMappings.TryRemove(correspondingId, out _);
+ }
+
+ liveStreamNeedsToBeClosed = true;
+ }
+
+ if (activeSessionMappings.IsEmpty)
+ {
+ _activeLiveStreamSessions.TryRemove(liveStreamId, out _);
+ }
+ }
+
+ if (liveStreamNeedsToBeClosed)
+ {
+ try
+ {
+ await _mediaSourceManager.CloseLiveStream(liveStreamId).ConfigureAwait(false);
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Error closing live stream");
+ }
+ }
+ }
+
///
public async ValueTask ReportSessionEnded(string sessionId)
{
@@ -343,6 +384,11 @@ namespace Emby.Server.Implementations.Session
/// Task.
private async Task UpdateNowPlayingItem(SessionInfo session, PlaybackProgressInfo info, BaseItem libraryItem, bool updateLastCheckInTime)
{
+ if (session is null)
+ {
+ return;
+ }
+
if (string.IsNullOrEmpty(info.MediaSourceId))
{
info.MediaSourceId = info.ItemId.ToString("N", CultureInfo.InvariantCulture);
@@ -675,6 +721,11 @@ namespace Emby.Server.Implementations.Session
private BaseItem GetNowPlayingItem(SessionInfo session, Guid itemId)
{
+ if (session is null)
+ {
+ return null;
+ }
+
var item = session.FullNowPlayingItem;
if (item is not null && item.Id.Equals(itemId))
{
@@ -725,6 +776,11 @@ namespace Emby.Server.Implementations.Session
}
}
+ if (!string.IsNullOrEmpty(info.LiveStreamId))
+ {
+ UpdateLiveStreamActiveSessionMappings(info.LiveStreamId, info.SessionId, info.PlaySessionId);
+ }
+
var eventArgs = new PlaybackStartEventArgs
{
Item = libraryItem,
@@ -782,6 +838,32 @@ namespace Emby.Server.Implementations.Session
return OnPlaybackProgress(info, false);
}
+ private void UpdateLiveStreamActiveSessionMappings(string liveStreamId, string sessionId, string playSessionId)
+ {
+ var activeSessionMappings = _activeLiveStreamSessions.GetOrAdd(liveStreamId, _ => new ConcurrentDictionary());
+
+ if (!string.IsNullOrEmpty(playSessionId))
+ {
+ if (!activeSessionMappings.TryGetValue(sessionId, out var currentPlaySessionId) || currentPlaySessionId != playSessionId)
+ {
+ if (!string.IsNullOrEmpty(currentPlaySessionId))
+ {
+ activeSessionMappings.TryRemove(currentPlaySessionId, out _);
+ }
+
+ activeSessionMappings[sessionId] = playSessionId;
+ activeSessionMappings[playSessionId] = sessionId;
+ }
+ }
+ else
+ {
+ if (!activeSessionMappings.TryGetValue(sessionId, out _))
+ {
+ activeSessionMappings[sessionId] = string.Empty;
+ }
+ }
+ }
+
///
/// Used to report playback progress for an item.
///
@@ -794,7 +876,11 @@ namespace Emby.Server.Implementations.Session
ArgumentNullException.ThrowIfNull(info);
- var session = GetSession(info.SessionId);
+ var session = GetSession(info.SessionId, false);
+ if (session is null)
+ {
+ return;
+ }
var libraryItem = info.ItemId.IsEmpty()
? null
@@ -818,6 +904,11 @@ namespace Emby.Server.Implementations.Session
}
}
+ if (!string.IsNullOrEmpty(info.LiveStreamId))
+ {
+ UpdateLiveStreamActiveSessionMappings(info.LiveStreamId, info.SessionId, info.PlaySessionId);
+ }
+
var eventArgs = new PlaybackProgressEventArgs
{
Item = libraryItem,
@@ -1000,14 +1091,7 @@ namespace Emby.Server.Implementations.Session
if (!string.IsNullOrEmpty(info.LiveStreamId))
{
- try
- {
- await _mediaSourceManager.CloseLiveStream(info.LiveStreamId).ConfigureAwait(false);
- }
- catch (Exception ex)
- {
- _logger.LogError(ex, "Error closing live stream");
- }
+ await CloseLiveStreamIfNeededAsync(info.LiveStreamId, session.Id).ConfigureAwait(false);
}
var eventArgs = new PlaybackStopEventArgs
@@ -1303,7 +1387,7 @@ namespace Emby.Server.Implementations.Session
if (item is null)
{
- _logger.LogError("A non-existent item Id {0} was passed into TranslateItemForPlayback", id);
+ _logger.LogError("A nonexistent item Id {0} was passed into TranslateItemForPlayback", id);
return Array.Empty();
}
@@ -1356,7 +1440,7 @@ namespace Emby.Server.Implementations.Session
if (item is null)
{
- _logger.LogError("A non-existent item Id {0} was passed into TranslateItemForInstantMix", id);
+ _logger.LogError("A nonexistent item Id {0} was passed into TranslateItemForInstantMix", id);
return new List();
}
@@ -1724,7 +1808,6 @@ namespace Emby.Server.Implementations.Session
fields.Remove(ItemFields.DateLastSaved);
fields.Remove(ItemFields.DisplayPreferencesId);
fields.Remove(ItemFields.Etag);
- fields.Remove(ItemFields.InheritedParentalRatingValue);
fields.Remove(ItemFields.ItemCounts);
fields.Remove(ItemFields.MediaSourceCount);
fields.Remove(ItemFields.MediaStreams);
@@ -1938,7 +2021,11 @@ namespace Emby.Server.Implementations.Session
// Don't report acceleration type for non-admin users.
result = result.Select(r =>
{
- r.TranscodingInfo.HardwareAccelerationType = HardwareAccelerationType.none;
+ if (r.TranscodingInfo is not null)
+ {
+ r.TranscodingInfo.HardwareAccelerationType = HardwareAccelerationType.none;
+ }
+
return r;
});
}
@@ -2051,6 +2138,7 @@ namespace Emby.Server.Implementations.Session
}
_activeConnections.Clear();
+ _activeLiveStreamSessions.Clear();
}
}
}
diff --git a/Emby.Server.Implementations/Session/SessionWebSocketListener.cs b/Emby.Server.Implementations/Session/SessionWebSocketListener.cs
index aba51de8f5..d4606abd2b 100644
--- a/Emby.Server.Implementations/Session/SessionWebSocketListener.cs
+++ b/Emby.Server.Implementations/Session/SessionWebSocketListener.cs
@@ -41,7 +41,7 @@ namespace Emby.Server.Implementations.Session
///
/// Lock used for accessing the WebSockets watchlist.
///
- private readonly object _webSocketsLock = new object();
+ private readonly Lock _webSocketsLock = new();
private readonly ISessionManager _sessionManager;
private readonly ILogger _logger;
@@ -276,11 +276,11 @@ namespace Emby.Server.Implementations.Session
///
/// The WebSocket.
/// Task.
- private Task SendForceKeepAlive(IWebSocketConnection webSocket)
+ private async Task SendForceKeepAlive(IWebSocketConnection webSocket)
{
- return webSocket.SendAsync(
+ await webSocket.SendAsync(
new ForceKeepAliveMessage(WebSocketLostTimeout),
- CancellationToken.None);
+ CancellationToken.None).ConfigureAwait(false);
}
}
}
diff --git a/Emby.Server.Implementations/Session/WebSocketController.cs b/Emby.Server.Implementations/Session/WebSocketController.cs
index cf8e0fb006..c45a4a60f5 100644
--- a/Emby.Server.Implementations/Session/WebSocketController.cs
+++ b/Emby.Server.Implementations/Session/WebSocketController.cs
@@ -21,6 +21,7 @@ namespace Emby.Server.Implementations.Session
private readonly SessionInfo _session;
private readonly List _sockets;
+ private readonly ReaderWriterLockSlim _socketsLock;
private bool _disposed = false;
public WebSocketController(
@@ -31,10 +32,26 @@ namespace Emby.Server.Implementations.Session
_logger = logger;
_session = session;
_sessionManager = sessionManager;
- _sockets = new List();
+ _sockets = new();
+ _socketsLock = new();
}
- private bool HasOpenSockets => GetActiveSockets().Any();
+ private bool HasOpenSockets
+ {
+ get
+ {
+ ObjectDisposedException.ThrowIf(_disposed, this);
+ try
+ {
+ _socketsLock.EnterReadLock();
+ return _sockets.Any(i => i.State == WebSocketState.Open);
+ }
+ finally
+ {
+ _socketsLock.ExitReadLock();
+ }
+ }
+ }
///
public bool SupportsMediaControl => HasOpenSockets;
@@ -42,23 +59,38 @@ namespace Emby.Server.Implementations.Session
///
public bool IsSessionActive => HasOpenSockets;
- private IEnumerable GetActiveSockets()
- => _sockets.Where(i => i.State == WebSocketState.Open);
-
public void AddWebSocket(IWebSocketConnection connection)
{
_logger.LogDebug("Adding websocket to session {Session}", _session.Id);
- _sockets.Add(connection);
-
- connection.Closed += OnConnectionClosed;
+ ObjectDisposedException.ThrowIf(_disposed, this);
+ try
+ {
+ _socketsLock.EnterWriteLock();
+ _sockets.Add(connection);
+ connection.Closed += OnConnectionClosed;
+ }
+ finally
+ {
+ _socketsLock.ExitWriteLock();
+ }
}
private async void OnConnectionClosed(object? sender, EventArgs e)
{
var connection = sender as IWebSocketConnection ?? throw new ArgumentException($"{nameof(sender)} is not of type {nameof(IWebSocketConnection)}", nameof(sender));
_logger.LogDebug("Removing websocket from session {Session}", _session.Id);
- _sockets.Remove(connection);
- connection.Closed -= OnConnectionClosed;
+ ObjectDisposedException.ThrowIf(_disposed, this);
+ try
+ {
+ _socketsLock.EnterWriteLock();
+ _sockets.Remove(connection);
+ connection.Closed -= OnConnectionClosed;
+ }
+ finally
+ {
+ _socketsLock.ExitWriteLock();
+ }
+
await _sessionManager.CloseIfNeededAsync(_session).ConfigureAwait(false);
}
@@ -69,7 +101,17 @@ namespace Emby.Server.Implementations.Session
T data,
CancellationToken cancellationToken)
{
- var socket = GetActiveSockets().MaxBy(i => i.LastActivityDate);
+ ObjectDisposedException.ThrowIf(_disposed, this);
+ IWebSocketConnection? socket;
+ try
+ {
+ _socketsLock.EnterReadLock();
+ socket = _sockets.Where(i => i.State == WebSocketState.Open).MaxBy(i => i.LastActivityDate);
+ }
+ finally
+ {
+ _socketsLock.ExitReadLock();
+ }
if (socket is null)
{
@@ -94,12 +136,23 @@ namespace Emby.Server.Implementations.Session
return;
}
- foreach (var socket in _sockets)
+ try
{
- socket.Closed -= OnConnectionClosed;
- socket.Dispose();
+ _socketsLock.EnterWriteLock();
+ foreach (var socket in _sockets)
+ {
+ socket.Closed -= OnConnectionClosed;
+ socket.Dispose();
+ }
+
+ _sockets.Clear();
+ }
+ finally
+ {
+ _socketsLock.ExitWriteLock();
}
+ _socketsLock.Dispose();
_disposed = true;
}
@@ -110,12 +163,23 @@ namespace Emby.Server.Implementations.Session
return;
}
- foreach (var socket in _sockets)
+ try
{
- socket.Closed -= OnConnectionClosed;
- await socket.DisposeAsync().ConfigureAwait(false);
+ _socketsLock.EnterWriteLock();
+ foreach (var socket in _sockets)
+ {
+ socket.Closed -= OnConnectionClosed;
+ await socket.DisposeAsync().ConfigureAwait(false);
+ }
+
+ _sockets.Clear();
+ }
+ finally
+ {
+ _socketsLock.ExitWriteLock();
}
+ _socketsLock.Dispose();
_disposed = true;
}
}
diff --git a/Emby.Server.Implementations/Sorting/DateLastMediaAddedComparer.cs b/Emby.Server.Implementations/Sorting/DateLastMediaAddedComparer.cs
index e1c26d0121..9afc511086 100644
--- a/Emby.Server.Implementations/Sorting/DateLastMediaAddedComparer.cs
+++ b/Emby.Server.Implementations/Sorting/DateLastMediaAddedComparer.cs
@@ -2,8 +2,8 @@
#pragma warning disable CS1591
using System;
-using Jellyfin.Data.Entities;
using Jellyfin.Data.Enums;
+using Jellyfin.Database.Implementations.Entities;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Sorting;
diff --git a/Emby.Server.Implementations/Sorting/DatePlayedComparer.cs b/Emby.Server.Implementations/Sorting/DatePlayedComparer.cs
index d668c17bfc..4c013a8bd7 100644
--- a/Emby.Server.Implementations/Sorting/DatePlayedComparer.cs
+++ b/Emby.Server.Implementations/Sorting/DatePlayedComparer.cs
@@ -1,8 +1,8 @@
#nullable disable
using System;
-using Jellyfin.Data.Entities;
using Jellyfin.Data.Enums;
+using Jellyfin.Database.Implementations.Entities;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Sorting;
diff --git a/Emby.Server.Implementations/Sorting/IsFavoriteOrLikeComparer.cs b/Emby.Server.Implementations/Sorting/IsFavoriteOrLikeComparer.cs
index 622a341b6a..cf77861673 100644
--- a/Emby.Server.Implementations/Sorting/IsFavoriteOrLikeComparer.cs
+++ b/Emby.Server.Implementations/Sorting/IsFavoriteOrLikeComparer.cs
@@ -1,8 +1,8 @@
#nullable disable
#pragma warning disable CS1591
-using Jellyfin.Data.Entities;
using Jellyfin.Data.Enums;
+using Jellyfin.Database.Implementations.Entities;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Sorting;
diff --git a/Emby.Server.Implementations/Sorting/IsPlayedComparer.cs b/Emby.Server.Implementations/Sorting/IsPlayedComparer.cs
index 2a3e456c2d..e42c8a33a3 100644
--- a/Emby.Server.Implementations/Sorting/IsPlayedComparer.cs
+++ b/Emby.Server.Implementations/Sorting/IsPlayedComparer.cs
@@ -2,8 +2,8 @@
#pragma warning disable CS1591
-using Jellyfin.Data.Entities;
using Jellyfin.Data.Enums;
+using Jellyfin.Database.Implementations.Entities;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Sorting;
diff --git a/Emby.Server.Implementations/Sorting/IsUnplayedComparer.cs b/Emby.Server.Implementations/Sorting/IsUnplayedComparer.cs
index afd8ccf9f3..f54188030b 100644
--- a/Emby.Server.Implementations/Sorting/IsUnplayedComparer.cs
+++ b/Emby.Server.Implementations/Sorting/IsUnplayedComparer.cs
@@ -2,8 +2,8 @@
#pragma warning disable CS1591
-using Jellyfin.Data.Entities;
using Jellyfin.Data.Enums;
+using Jellyfin.Database.Implementations.Entities;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Sorting;
diff --git a/Emby.Server.Implementations/Sorting/OfficialRatingComparer.cs b/Emby.Server.Implementations/Sorting/OfficialRatingComparer.cs
index b4ee2c7234..789af01cc3 100644
--- a/Emby.Server.Implementations/Sorting/OfficialRatingComparer.cs
+++ b/Emby.Server.Implementations/Sorting/OfficialRatingComparer.cs
@@ -1,45 +1,54 @@
-#pragma warning disable CS1591
-
using System;
using Jellyfin.Data.Enums;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Sorting;
+using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Globalization;
-using MediaBrowser.Model.Querying;
-namespace Emby.Server.Implementations.Sorting
+namespace Emby.Server.Implementations.Sorting;
+
+///
+/// Class providing comparison for official ratings.
+///
+public class OfficialRatingComparer : IBaseItemComparer
{
- public class OfficialRatingComparer : IBaseItemComparer
+ private readonly ILocalizationManager _localizationManager;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Instance of the interface.
+ public OfficialRatingComparer(ILocalizationManager localizationManager)
{
- private readonly ILocalizationManager _localization;
+ _localizationManager = localizationManager;
+ }
- public OfficialRatingComparer(ILocalizationManager localization)
+ ///
+ /// Gets the name.
+ ///
+ /// The name.
+ public ItemSortBy Type => ItemSortBy.OfficialRating;
+
+ ///
+ /// Compares the specified x.
+ ///
+ /// The x.
+ /// The y.
+ /// System.Int32.
+ public int Compare(BaseItem? x, BaseItem? y)
+ {
+ ArgumentNullException.ThrowIfNull(x);
+ ArgumentNullException.ThrowIfNull(y);
+ var zeroRating = new ParentalRatingScore(0, 0);
+
+ var ratingX = string.IsNullOrEmpty(x.OfficialRating) ? zeroRating : _localizationManager.GetRatingScore(x.OfficialRating) ?? zeroRating;
+ var ratingY = string.IsNullOrEmpty(y.OfficialRating) ? zeroRating : _localizationManager.GetRatingScore(y.OfficialRating) ?? zeroRating;
+ var scoreCompare = ratingX.Score.CompareTo(ratingY.Score);
+ if (scoreCompare is 0)
{
- _localization = localization;
+ return (ratingX.SubScore ?? 0).CompareTo(ratingY.SubScore ?? 0);
}
- ///
- /// Gets the name.
- ///
- /// The name.
- public ItemSortBy Type => ItemSortBy.OfficialRating;
-
- ///
- /// Compares the specified x.
- ///
- /// The x.
- /// The y.
- /// System.Int32.
- public int Compare(BaseItem? x, BaseItem? y)
- {
- ArgumentNullException.ThrowIfNull(x);
-
- ArgumentNullException.ThrowIfNull(y);
-
- var levelX = string.IsNullOrEmpty(x.OfficialRating) ? 0 : _localization.GetRatingLevel(x.OfficialRating) ?? 0;
- var levelY = string.IsNullOrEmpty(y.OfficialRating) ? 0 : _localization.GetRatingLevel(y.OfficialRating) ?? 0;
-
- return levelX.CompareTo(levelY);
- }
+ return scoreCompare;
}
}
diff --git a/Emby.Server.Implementations/Sorting/PlayCountComparer.cs b/Emby.Server.Implementations/Sorting/PlayCountComparer.cs
index 12f88bf4da..dd2149b578 100644
--- a/Emby.Server.Implementations/Sorting/PlayCountComparer.cs
+++ b/Emby.Server.Implementations/Sorting/PlayCountComparer.cs
@@ -1,7 +1,7 @@
#nullable disable
-using Jellyfin.Data.Entities;
using Jellyfin.Data.Enums;
+using Jellyfin.Database.Implementations.Entities;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Sorting;
diff --git a/Emby.Server.Implementations/SyncPlay/Group.cs b/Emby.Server.Implementations/SyncPlay/Group.cs
index a7821c0e0e..c2e834ad58 100644
--- a/Emby.Server.Implementations/SyncPlay/Group.cs
+++ b/Emby.Server.Implementations/SyncPlay/Group.cs
@@ -5,7 +5,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
-using Jellyfin.Data.Entities;
+using Jellyfin.Database.Implementations.Entities;
using Jellyfin.Extensions;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Session;
@@ -273,7 +273,7 @@ namespace Emby.Server.Implementations.SyncPlay
SetState(waitingState);
}
- var updateSession = NewSyncPlayGroupUpdate(GroupUpdateType.GroupJoined, GetInfo());
+ var updateSession = new SyncPlayGroupJoinedUpdate(GroupId, GetInfo());
SendGroupUpdate(session, SyncPlayBroadcastType.CurrentSession, updateSession, cancellationToken);
_state.SessionJoined(this, _state.Type, session, cancellationToken);
@@ -291,10 +291,10 @@ namespace Emby.Server.Implementations.SyncPlay
{
AddSession(session);
- var updateSession = NewSyncPlayGroupUpdate(GroupUpdateType.GroupJoined, GetInfo());
+ var updateSession = new SyncPlayGroupJoinedUpdate(GroupId, GetInfo());
SendGroupUpdate(session, SyncPlayBroadcastType.CurrentSession, updateSession, cancellationToken);
- var updateOthers = NewSyncPlayGroupUpdate(GroupUpdateType.UserJoined, session.UserName);
+ var updateOthers = new SyncPlayUserJoinedUpdate(GroupId, session.UserName);
SendGroupUpdate(session, SyncPlayBroadcastType.AllExceptCurrentSession, updateOthers, cancellationToken);
_state.SessionJoined(this, _state.Type, session, cancellationToken);
@@ -314,10 +314,10 @@ namespace Emby.Server.Implementations.SyncPlay
RemoveSession(session);
- var updateSession = NewSyncPlayGroupUpdate(GroupUpdateType.GroupLeft, GroupId.ToString());
+ var updateSession = new SyncPlayGroupLeftUpdate(GroupId, GroupId.ToString());
SendGroupUpdate(session, SyncPlayBroadcastType.CurrentSession, updateSession, cancellationToken);
- var updateOthers = NewSyncPlayGroupUpdate(GroupUpdateType.UserLeft, session.UserName);
+ var updateOthers = new SyncPlayUserLeftUpdate(GroupId, session.UserName);
SendGroupUpdate(session, SyncPlayBroadcastType.AllExceptCurrentSession, updateOthers, cancellationToken);
_logger.LogInformation("Session {SessionId} left group {GroupId}.", session.Id, GroupId.ToString());
@@ -425,12 +425,6 @@ namespace Emby.Server.Implementations.SyncPlay
DateTime.UtcNow);
}
- ///
- public GroupUpdate NewSyncPlayGroupUpdate(GroupUpdateType type, T data)
- {
- return new GroupUpdate(GroupId, type, data);
- }
-
///
public long SanitizePositionTicks(long? positionTicks)
{
diff --git a/Emby.Server.Implementations/SyncPlay/SyncPlayManager.cs b/Emby.Server.Implementations/SyncPlay/SyncPlayManager.cs
index 00c655634a..b45d754554 100644
--- a/Emby.Server.Implementations/SyncPlay/SyncPlayManager.cs
+++ b/Emby.Server.Implementations/SyncPlay/SyncPlayManager.cs
@@ -67,7 +67,7 @@ namespace Emby.Server.Implementations.SyncPlay
///
/// This lock has priority on locks made on .
///
- private readonly object _groupsLock = new object();
+ private readonly Lock _groupsLock = new();
private bool _disposed = false;
@@ -100,7 +100,7 @@ namespace Emby.Server.Implementations.SyncPlay
}
///
- public void NewGroup(SessionInfo session, NewGroupRequest request, CancellationToken cancellationToken)
+ public GroupInfoDto NewGroup(SessionInfo session, NewGroupRequest request, CancellationToken cancellationToken)
{
if (session is null)
{
@@ -132,6 +132,7 @@ namespace Emby.Server.Implementations.SyncPlay
UpdateSessionsCounter(session.UserId, 1);
group.CreateGroup(session, request, cancellationToken);
+ return group.GetInfo();
}
}
@@ -159,7 +160,7 @@ namespace Emby.Server.Implementations.SyncPlay
{
_logger.LogWarning("Session {SessionId} tried to join group {GroupId} that does not exist.", session.Id, request.GroupId);
- var error = new GroupUpdate(Guid.Empty, GroupUpdateType.GroupDoesNotExist, string.Empty);
+ var error = new SyncPlayGroupDoesNotExistUpdate(Guid.Empty, string.Empty);
_sessionManager.SendSyncPlayGroupUpdate(session.Id, error, CancellationToken.None);
return;
}
@@ -171,7 +172,7 @@ namespace Emby.Server.Implementations.SyncPlay
{
_logger.LogWarning("Session {SessionId} tried to join group {GroupId} but does not have access to some content of the playing queue.", session.Id, group.GroupId.ToString());
- var error = new GroupUpdate(group.GroupId, GroupUpdateType.LibraryAccessDenied, string.Empty);
+ var error = new SyncPlayLibraryAccessDeniedUpdate(group.GroupId, string.Empty);
_sessionManager.SendSyncPlayGroupUpdate(session.Id, error, CancellationToken.None);
return;
}
@@ -248,7 +249,7 @@ namespace Emby.Server.Implementations.SyncPlay
{
_logger.LogWarning("Session {SessionId} does not belong to any group.", session.Id);
- var error = new GroupUpdate(Guid.Empty, GroupUpdateType.NotInGroup, string.Empty);
+ var error = new SyncPlayNotInGroupUpdate(Guid.Empty, string.Empty);
_sessionManager.SendSyncPlayGroupUpdate(session.Id, error, CancellationToken.None);
}
}
@@ -288,6 +289,31 @@ namespace Emby.Server.Implementations.SyncPlay
return list;
}
+ ///
+ public GroupInfoDto GetGroup(SessionInfo session, Guid groupId)
+ {
+ ArgumentNullException.ThrowIfNull(session);
+
+ var user = _userManager.GetUserById(session.UserId);
+
+ lock (_groupsLock)
+ {
+ foreach (var (_, group) in _groups)
+ {
+ // Locking required as group is not thread-safe.
+ lock (group)
+ {
+ if (group.GroupId.Equals(groupId) && group.HasAccessToPlayQueue(user))
+ {
+ return group.GetInfo();
+ }
+ }
+ }
+ }
+
+ return null;
+ }
+
///
public void HandleRequest(SessionInfo session, IGroupPlaybackRequest request, CancellationToken cancellationToken)
{
@@ -327,7 +353,7 @@ namespace Emby.Server.Implementations.SyncPlay
{
_logger.LogWarning("Session {SessionId} does not belong to any group.", session.Id);
- var error = new GroupUpdate(Guid.Empty, GroupUpdateType.NotInGroup, string.Empty);
+ var error = new SyncPlayNotInGroupUpdate(Guid.Empty, string.Empty);
_sessionManager.SendSyncPlayGroupUpdate(session.Id, error, CancellationToken.None);
}
}
diff --git a/Emby.Server.Implementations/SystemManager.cs b/Emby.Server.Implementations/SystemManager.cs
index c4552474cb..92b59b23cd 100644
--- a/Emby.Server.Implementations/SystemManager.cs
+++ b/Emby.Server.Implementations/SystemManager.cs
@@ -1,9 +1,12 @@
+using System;
using System.Linq;
using System.Threading.Tasks;
+using Jellyfin.Server.Implementations.StorageHelpers;
using MediaBrowser.Common.Configuration;
using MediaBrowser.Common.Updates;
using MediaBrowser.Controller;
using MediaBrowser.Controller.Configuration;
+using MediaBrowser.Controller.Library;
using MediaBrowser.Model.System;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Hosting;
@@ -19,6 +22,7 @@ public class SystemManager : ISystemManager
private readonly IServerConfigurationManager _configurationManager;
private readonly IStartupOptions _startupOptions;
private readonly IInstallationManager _installationManager;
+ private readonly ILibraryManager _libraryManager;
///
/// Initializes a new instance of the class.
@@ -29,13 +33,15 @@ public class SystemManager : ISystemManager
/// Instance of .
/// Instance of .
/// Instance of .
+ /// Instance of .
public SystemManager(
IHostApplicationLifetime applicationLifetime,
IServerApplicationHost applicationHost,
IServerApplicationPaths applicationPaths,
IServerConfigurationManager configurationManager,
IStartupOptions startupOptions,
- IInstallationManager installationManager)
+ IInstallationManager installationManager,
+ ILibraryManager libraryManager)
{
_applicationLifetime = applicationLifetime;
_applicationHost = applicationHost;
@@ -43,6 +49,7 @@ public class SystemManager : ISystemManager
_configurationManager = configurationManager;
_startupOptions = startupOptions;
_installationManager = installationManager;
+ _libraryManager = libraryManager;
}
///
@@ -53,9 +60,11 @@ public class SystemManager : ISystemManager
HasPendingRestart = _applicationHost.HasPendingRestart,
IsShuttingDown = _applicationLifetime.ApplicationStopping.IsCancellationRequested,
Version = _applicationHost.ApplicationVersionString,
+ ProductName = _applicationHost.Name,
WebSocketPortNumber = _applicationHost.HttpPort,
CompletedInstallations = _installationManager.CompletedInstallations.ToArray(),
Id = _applicationHost.SystemId,
+#pragma warning disable CS0618 // Type or member is obsolete
ProgramDataPath = _applicationPaths.ProgramDataPath,
WebPath = _applicationPaths.WebPath,
LogPath = _applicationPaths.LogDirectoryPath,
@@ -63,14 +72,39 @@ public class SystemManager : ISystemManager
InternalMetadataPath = _applicationPaths.InternalMetadataPath,
CachePath = _applicationPaths.CachePath,
TranscodingTempPath = _configurationManager.GetTranscodePath(),
+#pragma warning restore CS0618 // Type or member is obsolete
ServerName = _applicationHost.FriendlyName,
LocalAddress = _applicationHost.GetSmartApiUrl(request),
+ StartupWizardCompleted = _configurationManager.CommonConfiguration.IsStartupWizardCompleted,
SupportsLibraryMonitor = true,
PackageName = _startupOptions.PackageName,
CastReceiverApplications = _configurationManager.Configuration.CastReceiverApplications
};
}
+ ///
+ public SystemStorageInfo GetSystemStorageInfo()
+ {
+ var virtualFolderInfos = _libraryManager.GetVirtualFolders().Select(e => new LibraryStorageInfo()
+ {
+ Id = Guid.Parse(e.ItemId),
+ Name = e.Name,
+ Folders = e.Locations.Select(f => StorageHelper.GetFreeSpaceOf(f)).ToArray()
+ });
+
+ return new SystemStorageInfo()
+ {
+ ProgramDataFolder = StorageHelper.GetFreeSpaceOf(_applicationPaths.ProgramDataPath),
+ WebFolder = StorageHelper.GetFreeSpaceOf(_applicationPaths.WebPath),
+ LogFolder = StorageHelper.GetFreeSpaceOf(_applicationPaths.LogDirectoryPath),
+ ImageCacheFolder = StorageHelper.GetFreeSpaceOf(_applicationPaths.ImageCachePath),
+ InternalMetadataFolder = StorageHelper.GetFreeSpaceOf(_applicationPaths.InternalMetadataPath),
+ CacheFolder = StorageHelper.GetFreeSpaceOf(_applicationPaths.CachePath),
+ TranscodingTempFolder = StorageHelper.GetFreeSpaceOf(_configurationManager.GetTranscodePath()),
+ Libraries = virtualFolderInfos.ToArray()
+ };
+ }
+
///
public PublicSystemInfo GetPublicSystemInfo(HttpRequest request)
{
diff --git a/Emby.Server.Implementations/TV/TVSeriesManager.cs b/Emby.Server.Implementations/TV/TVSeriesManager.cs
index d11b03a2e2..ee2e18f735 100644
--- a/Emby.Server.Implementations/TV/TVSeriesManager.cs
+++ b/Emby.Server.Implementations/TV/TVSeriesManager.cs
@@ -3,8 +3,10 @@
using System;
using System.Collections.Generic;
using System.Linq;
-using Jellyfin.Data.Entities;
+using Jellyfin.Data;
using Jellyfin.Data.Enums;
+using Jellyfin.Database.Implementations.Entities;
+using Jellyfin.Database.Implementations.Enums;
using Jellyfin.Extensions;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Dto;
@@ -91,7 +93,7 @@ namespace Emby.Server.Implementations.TV
if (!string.IsNullOrEmpty(presentationUniqueKey))
{
- return GetResult(GetNextUpEpisodes(request, user, new[] { presentationUniqueKey }, options), request);
+ return GetResult(GetNextUpEpisodes(request, user, [presentationUniqueKey], options), request);
}
if (limit.HasValue)
@@ -99,25 +101,9 @@ namespace Emby.Server.Implementations.TV
limit = limit.Value + 10;
}
- var items = _libraryManager
- .GetItemList(
- new InternalItemsQuery(user)
- {
- IncludeItemTypes = new[] { BaseItemKind.Episode },
- OrderBy = new[] { (ItemSortBy.DatePlayed, SortOrder.Descending) },
- SeriesPresentationUniqueKey = presentationUniqueKey,
- Limit = limit,
- DtoOptions = new DtoOptions { Fields = new[] { ItemFields.SeriesPresentationUniqueKey }, EnableImages = false },
- GroupBySeriesPresentationUniqueKey = true
- },
- parentsFolders.ToList())
- .Cast()
- .Where(episode => !string.IsNullOrEmpty(episode.SeriesPresentationUniqueKey))
- .Select(GetUniqueSeriesKey)
- .ToList();
+ var nextUpSeriesKeys = _libraryManager.GetNextUpSeriesKeys(new InternalItemsQuery(user) { Limit = limit }, parentsFolders, request.NextUpDateCutoff);
- // Avoid implicitly captured closure
- var episodes = GetNextUpEpisodes(request, user, items, options);
+ var episodes = GetNextUpEpisodes(request, user, nextUpSeriesKeys, options);
return GetResult(episodes, request);
}
@@ -133,36 +119,11 @@ namespace Emby.Server.Implementations.TV
.OrderByDescending(i => i.LastWatchedDate);
}
- // If viewing all next up for all series, remove first episodes
- // But if that returns empty, keep those first episodes (avoid completely empty view)
- var alwaysEnableFirstEpisode = !request.SeriesId.IsNullOrEmpty();
- var anyFound = false;
-
return allNextUp
- .Where(i =>
- {
- if (request.DisableFirstEpisode)
- {
- return i.LastWatchedDate != DateTime.MinValue;
- }
-
- if (alwaysEnableFirstEpisode || (i.LastWatchedDate != DateTime.MinValue && i.LastWatchedDate.Date >= request.NextUpDateCutoff))
- {
- anyFound = true;
- return true;
- }
-
- return !anyFound && i.LastWatchedDate == DateTime.MinValue;
- })
.Select(i => i.GetEpisodeFunction())
.Where(i => i is not null)!;
}
- private static string GetUniqueSeriesKey(Episode episode)
- {
- return episode.SeriesPresentationUniqueKey;
- }
-
private static string GetUniqueSeriesKey(Series series)
{
return series.GetPresentationUniqueKey();
@@ -178,13 +139,13 @@ namespace Emby.Server.Implementations.TV
{
AncestorWithPresentationUniqueKey = null,
SeriesPresentationUniqueKey = seriesKey,
- IncludeItemTypes = new[] { BaseItemKind.Episode },
+ IncludeItemTypes = [BaseItemKind.Episode],
IsPlayed = true,
Limit = 1,
ParentIndexNumberNotEquals = 0,
DtoOptions = new DtoOptions
{
- Fields = new[] { ItemFields.SortName },
+ Fields = [ItemFields.SortName],
EnableImages = false
}
};
@@ -202,8 +163,8 @@ namespace Emby.Server.Implementations.TV
{
AncestorWithPresentationUniqueKey = null,
SeriesPresentationUniqueKey = seriesKey,
- IncludeItemTypes = new[] { BaseItemKind.Episode },
- OrderBy = new[] { (ItemSortBy.ParentIndexNumber, SortOrder.Ascending), (ItemSortBy.IndexNumber, SortOrder.Ascending) },
+ IncludeItemTypes = [BaseItemKind.Episode],
+ OrderBy = [(ItemSortBy.ParentIndexNumber, SortOrder.Ascending), (ItemSortBy.IndexNumber, SortOrder.Ascending)],
Limit = 1,
IsPlayed = includePlayed,
IsVirtualItem = false,
@@ -228,7 +189,7 @@ namespace Emby.Server.Implementations.TV
AncestorWithPresentationUniqueKey = null,
SeriesPresentationUniqueKey = seriesKey,
ParentIndexNumber = 0,
- IncludeItemTypes = new[] { BaseItemKind.Episode },
+ IncludeItemTypes = [BaseItemKind.Episode],
IsPlayed = includePlayed,
IsVirtualItem = false,
DtoOptions = dtoOptions
@@ -248,7 +209,7 @@ namespace Emby.Server.Implementations.TV
consideredEpisodes.Add(nextEpisode);
}
- var sortedConsideredEpisodes = _libraryManager.Sort(consideredEpisodes, user, new[] { (ItemSortBy.AiredEpisodeOrder, SortOrder.Ascending) })
+ var sortedConsideredEpisodes = _libraryManager.Sort(consideredEpisodes, user, [(ItemSortBy.AiredEpisodeOrder, SortOrder.Ascending)])
.Cast();
if (lastWatchedEpisode is not null)
{
@@ -262,7 +223,7 @@ namespace Emby.Server.Implementations.TV
{
var userData = _userDataManager.GetUserData(user, nextEpisode);
- if (userData.PlaybackPositionTicks > 0)
+ if (userData?.PlaybackPositionTicks > 0)
{
return null;
}
@@ -275,6 +236,11 @@ namespace Emby.Server.Implementations.TV
{
var userData = _userDataManager.GetUserData(user, lastWatchedEpisode);
+ if (userData is null)
+ {
+ return (DateTime.MinValue, GetEpisode);
+ }
+
var lastWatchedDate = userData.LastPlayedDate ?? DateTime.MinValue.AddDays(1);
return (lastWatchedDate, GetEpisode);
diff --git a/Emby.Server.Implementations/Updates/InstallationManager.cs b/Emby.Server.Implementations/Updates/InstallationManager.cs
index ce3d6cab88..678475b31f 100644
--- a/Emby.Server.Implementations/Updates/InstallationManager.cs
+++ b/Emby.Server.Implementations/Updates/InstallationManager.cs
@@ -48,7 +48,7 @@ namespace Emby.Server.Implementations.Updates
///
/// The application host.
private readonly IServerApplicationHost _applicationHost;
- private readonly object _currentInstallationsLock = new object();
+ private readonly Lock _currentInstallationsLock = new();
///
/// The current installations.
@@ -187,7 +187,7 @@ namespace Emby.Server.Implementations.Updates
await _pluginManager.PopulateManifest(package, version.VersionNumber, plugin.Path, plugin.Manifest.Status).ConfigureAwait(false);
}
- // Remove versions with a target ABI greater then the current application version.
+ // Remove versions with a target ABI greater than the current application version.
if (Version.TryParse(version.TargetAbi, out var targetAbi) && _applicationHost.ApplicationVersion < targetAbi)
{
package.Versions.RemoveAt(i);
diff --git a/Jellyfin.Api/Auth/CustomAuthenticationHandler.cs b/Jellyfin.Api/Auth/CustomAuthenticationHandler.cs
index 2853e69b01..f6f2f59c52 100644
--- a/Jellyfin.Api/Auth/CustomAuthenticationHandler.cs
+++ b/Jellyfin.Api/Auth/CustomAuthenticationHandler.cs
@@ -3,7 +3,8 @@ using System.Security.Claims;
using System.Text.Encodings.Web;
using System.Threading.Tasks;
using Jellyfin.Api.Constants;
-using Jellyfin.Data.Enums;
+using Jellyfin.Data;
+using Jellyfin.Database.Implementations.Enums;
using MediaBrowser.Controller.Authentication;
using MediaBrowser.Controller.Net;
using Microsoft.AspNetCore.Authentication;
@@ -50,7 +51,8 @@ namespace Jellyfin.Api.Auth
}
var role = UserRoles.User;
- if (authorizationInfo.IsApiKey || authorizationInfo.User.HasPermission(PermissionKind.IsAdministrator))
+ if (authorizationInfo.IsApiKey
+ || (authorizationInfo.User?.HasPermission(PermissionKind.IsAdministrator) ?? false))
{
role = UserRoles.Administrator;
}
@@ -60,10 +62,10 @@ namespace Jellyfin.Api.Auth
new Claim(ClaimTypes.Name, authorizationInfo.User?.Username ?? string.Empty),
new Claim(ClaimTypes.Role, role),
new Claim(InternalClaimTypes.UserId, authorizationInfo.UserId.ToString("N", CultureInfo.InvariantCulture)),
- new Claim(InternalClaimTypes.DeviceId, authorizationInfo.DeviceId),
- new Claim(InternalClaimTypes.Device, authorizationInfo.Device),
- new Claim(InternalClaimTypes.Client, authorizationInfo.Client),
- new Claim(InternalClaimTypes.Version, authorizationInfo.Version),
+ new Claim(InternalClaimTypes.DeviceId, authorizationInfo.DeviceId ?? string.Empty),
+ new Claim(InternalClaimTypes.Device, authorizationInfo.Device ?? string.Empty),
+ new Claim(InternalClaimTypes.Client, authorizationInfo.Client ?? string.Empty),
+ new Claim(InternalClaimTypes.Version, authorizationInfo.Version ?? string.Empty),
new Claim(InternalClaimTypes.Token, authorizationInfo.Token),
new Claim(InternalClaimTypes.IsApiKey, authorizationInfo.IsApiKey.ToString(CultureInfo.InvariantCulture))
};
diff --git a/Jellyfin.Api/Auth/DefaultAuthorizationPolicy/DefaultAuthorizationHandler.cs b/Jellyfin.Api/Auth/DefaultAuthorizationPolicy/DefaultAuthorizationHandler.cs
index 4928d5ed24..6b80d537fb 100644
--- a/Jellyfin.Api/Auth/DefaultAuthorizationPolicy/DefaultAuthorizationHandler.cs
+++ b/Jellyfin.Api/Auth/DefaultAuthorizationPolicy/DefaultAuthorizationHandler.cs
@@ -1,7 +1,8 @@
using System.Threading.Tasks;
using Jellyfin.Api.Constants;
using Jellyfin.Api.Extensions;
-using Jellyfin.Data.Enums;
+using Jellyfin.Data;
+using Jellyfin.Database.Implementations.Enums;
using Jellyfin.Extensions;
using MediaBrowser.Common.Extensions;
using MediaBrowser.Common.Net;
diff --git a/Jellyfin.Api/Auth/SyncPlayAccessPolicy/SyncPlayAccessHandler.cs b/Jellyfin.Api/Auth/SyncPlayAccessPolicy/SyncPlayAccessHandler.cs
index 5fcf72fb46..7efb5b1698 100644
--- a/Jellyfin.Api/Auth/SyncPlayAccessPolicy/SyncPlayAccessHandler.cs
+++ b/Jellyfin.Api/Auth/SyncPlayAccessPolicy/SyncPlayAccessHandler.cs
@@ -1,6 +1,7 @@
using System.Threading.Tasks;
using Jellyfin.Api.Extensions;
using Jellyfin.Data.Enums;
+using Jellyfin.Database.Implementations.Enums;
using MediaBrowser.Common.Extensions;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.SyncPlay;
diff --git a/Jellyfin.Api/Auth/UserPermissionPolicy/UserPermissionHandler.cs b/Jellyfin.Api/Auth/UserPermissionPolicy/UserPermissionHandler.cs
index f20779f6cd..d139eab16f 100644
--- a/Jellyfin.Api/Auth/UserPermissionPolicy/UserPermissionHandler.cs
+++ b/Jellyfin.Api/Auth/UserPermissionPolicy/UserPermissionHandler.cs
@@ -1,5 +1,6 @@
using System.Threading.Tasks;
using Jellyfin.Api.Extensions;
+using Jellyfin.Data;
using Jellyfin.Extensions;
using MediaBrowser.Common.Extensions;
using MediaBrowser.Controller.Library;
diff --git a/Jellyfin.Api/Auth/UserPermissionPolicy/UserPermissionRequirement.cs b/Jellyfin.Api/Auth/UserPermissionPolicy/UserPermissionRequirement.cs
index a7c3cce971..152c400cde 100644
--- a/Jellyfin.Api/Auth/UserPermissionPolicy/UserPermissionRequirement.cs
+++ b/Jellyfin.Api/Auth/UserPermissionPolicy/UserPermissionRequirement.cs
@@ -1,5 +1,5 @@
using Jellyfin.Api.Auth.DefaultAuthorizationPolicy;
-using Jellyfin.Data.Enums;
+using Jellyfin.Database.Implementations.Enums;
namespace Jellyfin.Api.Auth.UserPermissionPolicy
{
diff --git a/Jellyfin.Api/Controllers/ArtistsController.cs b/Jellyfin.Api/Controllers/ArtistsController.cs
index 8b931f1621..7ba75dc243 100644
--- a/Jellyfin.Api/Controllers/ArtistsController.cs
+++ b/Jellyfin.Api/Controllers/ArtistsController.cs
@@ -4,8 +4,9 @@ using System.Linq;
using Jellyfin.Api.Extensions;
using Jellyfin.Api.Helpers;
using Jellyfin.Api.ModelBinders;
-using Jellyfin.Data.Entities;
using Jellyfin.Data.Enums;
+using Jellyfin.Database.Implementations.Entities;
+using Jellyfin.Database.Implementations.Enums;
using Jellyfin.Extensions;
using MediaBrowser.Controller.Dto;
using MediaBrowser.Controller.Entities;
@@ -91,31 +92,31 @@ public class ArtistsController : BaseJellyfinApiController
[FromQuery] int? limit,
[FromQuery] string? searchTerm,
[FromQuery] Guid? parentId,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ItemFields[] fields,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] BaseItemKind[] excludeItemTypes,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] BaseItemKind[] includeItemTypes,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ItemFilter[] filters,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ItemFields[] fields,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] BaseItemKind[] excludeItemTypes,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] BaseItemKind[] includeItemTypes,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ItemFilter[] filters,
[FromQuery] bool? isFavorite,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] MediaType[] mediaTypes,
- [FromQuery, ModelBinder(typeof(PipeDelimitedArrayModelBinder))] string[] genres,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] Guid[] genreIds,
- [FromQuery, ModelBinder(typeof(PipeDelimitedArrayModelBinder))] string[] officialRatings,
- [FromQuery, ModelBinder(typeof(PipeDelimitedArrayModelBinder))] string[] tags,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] int[] years,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] MediaType[] mediaTypes,
+ [FromQuery, ModelBinder(typeof(PipeDelimitedCollectionModelBinder))] string[] genres,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] Guid[] genreIds,
+ [FromQuery, ModelBinder(typeof(PipeDelimitedCollectionModelBinder))] string[] officialRatings,
+ [FromQuery, ModelBinder(typeof(PipeDelimitedCollectionModelBinder))] string[] tags,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] int[] years,
[FromQuery] bool? enableUserData,
[FromQuery] int? imageTypeLimit,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ImageType[] enableImageTypes,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ImageType[] enableImageTypes,
[FromQuery] string? person,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] Guid[] personIds,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] string[] personTypes,
- [FromQuery, ModelBinder(typeof(PipeDelimitedArrayModelBinder))] string[] studios,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] Guid[] studioIds,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] Guid[] personIds,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] string[] personTypes,
+ [FromQuery, ModelBinder(typeof(PipeDelimitedCollectionModelBinder))] string[] studios,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] Guid[] studioIds,
[FromQuery] Guid? userId,
[FromQuery] string? nameStartsWithOrGreater,
[FromQuery] string? nameStartsWith,
[FromQuery] string? nameLessThan,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ItemSortBy[] sortBy,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] SortOrder[] sortOrder,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ItemSortBy[] sortBy,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] SortOrder[] sortOrder,
[FromQuery] bool? enableImages = true,
[FromQuery] bool enableTotalRecordCount = true)
{
@@ -295,31 +296,31 @@ public class ArtistsController : BaseJellyfinApiController
[FromQuery] int? limit,
[FromQuery] string? searchTerm,
[FromQuery] Guid? parentId,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ItemFields[] fields,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] BaseItemKind[] excludeItemTypes,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] BaseItemKind[] includeItemTypes,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ItemFilter[] filters,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ItemFields[] fields,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] BaseItemKind[] excludeItemTypes,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] BaseItemKind[] includeItemTypes,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ItemFilter[] filters,
[FromQuery] bool? isFavorite,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] MediaType[] mediaTypes,
- [FromQuery, ModelBinder(typeof(PipeDelimitedArrayModelBinder))] string[] genres,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] Guid[] genreIds,
- [FromQuery, ModelBinder(typeof(PipeDelimitedArrayModelBinder))] string[] officialRatings,
- [FromQuery, ModelBinder(typeof(PipeDelimitedArrayModelBinder))] string[] tags,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] int[] years,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] MediaType[] mediaTypes,
+ [FromQuery, ModelBinder(typeof(PipeDelimitedCollectionModelBinder))] string[] genres,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] Guid[] genreIds,
+ [FromQuery, ModelBinder(typeof(PipeDelimitedCollectionModelBinder))] string[] officialRatings,
+ [FromQuery, ModelBinder(typeof(PipeDelimitedCollectionModelBinder))] string[] tags,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] int[] years,
[FromQuery] bool? enableUserData,
[FromQuery] int? imageTypeLimit,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ImageType[] enableImageTypes,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ImageType[] enableImageTypes,
[FromQuery] string? person,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] Guid[] personIds,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] string[] personTypes,
- [FromQuery, ModelBinder(typeof(PipeDelimitedArrayModelBinder))] string[] studios,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] Guid[] studioIds,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] Guid[] personIds,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] string[] personTypes,
+ [FromQuery, ModelBinder(typeof(PipeDelimitedCollectionModelBinder))] string[] studios,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] Guid[] studioIds,
[FromQuery] Guid? userId,
[FromQuery] string? nameStartsWithOrGreater,
[FromQuery] string? nameStartsWith,
[FromQuery] string? nameLessThan,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ItemSortBy[] sortBy,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] SortOrder[] sortOrder,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ItemSortBy[] sortBy,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] SortOrder[] sortOrder,
[FromQuery] bool? enableImages = true,
[FromQuery] bool enableTotalRecordCount = true)
{
diff --git a/Jellyfin.Api/Controllers/AudioController.cs b/Jellyfin.Api/Controllers/AudioController.cs
index a47c604737..e334e12640 100644
--- a/Jellyfin.Api/Controllers/AudioController.cs
+++ b/Jellyfin.Api/Controllers/AudioController.cs
@@ -92,18 +92,18 @@ public class AudioController : BaseJellyfinApiController
[ProducesAudioFile]
public async Task GetAudioStream(
[FromRoute, Required] Guid itemId,
- [FromQuery] [RegularExpression(EncodingHelper.ValidationRegex)] string? container,
+ [FromQuery] [RegularExpression(EncodingHelper.ContainerValidationRegex)] string? container,
[FromQuery] bool? @static,
[FromQuery] string? @params,
[FromQuery] string? tag,
[FromQuery, ParameterObsolete] string? deviceProfileId,
[FromQuery] string? playSessionId,
- [FromQuery] [RegularExpression(EncodingHelper.ValidationRegex)] string? segmentContainer,
+ [FromQuery] [RegularExpression(EncodingHelper.ContainerValidationRegex)] string? segmentContainer,
[FromQuery] int? segmentLength,
[FromQuery] int? minSegments,
[FromQuery] string? mediaSourceId,
[FromQuery] string? deviceId,
- [FromQuery] [RegularExpression(EncodingHelper.ValidationRegex)] string? audioCodec,
+ [FromQuery] [RegularExpression(EncodingHelper.ContainerValidationRegex)] string? audioCodec,
[FromQuery] bool? enableAutoStreamCopy,
[FromQuery] bool? allowVideoStreamCopy,
[FromQuery] bool? allowAudioStreamCopy,
@@ -114,7 +114,7 @@ public class AudioController : BaseJellyfinApiController
[FromQuery] int? audioChannels,
[FromQuery] int? maxAudioChannels,
[FromQuery] string? profile,
- [FromQuery] string? level,
+ [FromQuery] [RegularExpression(EncodingHelper.LevelValidationRegex)] string? level,
[FromQuery] float? framerate,
[FromQuery] float? maxFramerate,
[FromQuery] bool? copyTimestamps,
@@ -133,8 +133,8 @@ public class AudioController : BaseJellyfinApiController
[FromQuery] int? cpuCoreLimit,
[FromQuery] string? liveStreamId,
[FromQuery] bool? enableMpegtsM2TsMode,
- [FromQuery] [RegularExpression(EncodingHelper.ValidationRegex)] string? videoCodec,
- [FromQuery] [RegularExpression(EncodingHelper.ValidationRegex)] string? subtitleCodec,
+ [FromQuery] [RegularExpression(EncodingHelper.ContainerValidationRegex)] string? videoCodec,
+ [FromQuery] [RegularExpression(EncodingHelper.ContainerValidationRegex)] string? subtitleCodec,
[FromQuery] string? transcodeReasons,
[FromQuery] int? audioStreamIndex,
[FromQuery] int? videoStreamIndex,
@@ -238,7 +238,7 @@ public class AudioController : BaseJellyfinApiController
/// Optional. The maximum video bit depth.
/// Optional. Whether to require avc.
/// Optional. Whether to deinterlace the video.
- /// Optional. Whether to require a non anamporphic stream.
+ /// Optional. Whether to require a non anamorphic stream.
/// Optional. The maximum number of audio channels to transcode.
/// Optional. The limit of how many cpu cores to use.
/// The live stream id.
@@ -259,18 +259,18 @@ public class AudioController : BaseJellyfinApiController
[ProducesAudioFile]
public async Task GetAudioStreamByContainer(
[FromRoute, Required] Guid itemId,
- [FromRoute, Required] string container,
+ [FromRoute, Required] [RegularExpression(EncodingHelper.ContainerValidationRegex)] string container,
[FromQuery] bool? @static,
[FromQuery] string? @params,
[FromQuery] string? tag,
[FromQuery, ParameterObsolete] string? deviceProfileId,
[FromQuery] string? playSessionId,
- [FromQuery] [RegularExpression(EncodingHelper.ValidationRegex)] string? segmentContainer,
+ [FromQuery] [RegularExpression(EncodingHelper.ContainerValidationRegex)] string? segmentContainer,
[FromQuery] int? segmentLength,
[FromQuery] int? minSegments,
[FromQuery] string? mediaSourceId,
[FromQuery] string? deviceId,
- [FromQuery] [RegularExpression(EncodingHelper.ValidationRegex)] string? audioCodec,
+ [FromQuery] [RegularExpression(EncodingHelper.ContainerValidationRegex)] string? audioCodec,
[FromQuery] bool? enableAutoStreamCopy,
[FromQuery] bool? allowVideoStreamCopy,
[FromQuery] bool? allowAudioStreamCopy,
@@ -281,7 +281,7 @@ public class AudioController : BaseJellyfinApiController
[FromQuery] int? audioChannels,
[FromQuery] int? maxAudioChannels,
[FromQuery] string? profile,
- [FromQuery] string? level,
+ [FromQuery] [RegularExpression(EncodingHelper.LevelValidationRegex)] string? level,
[FromQuery] float? framerate,
[FromQuery] float? maxFramerate,
[FromQuery] bool? copyTimestamps,
@@ -300,8 +300,8 @@ public class AudioController : BaseJellyfinApiController
[FromQuery] int? cpuCoreLimit,
[FromQuery] string? liveStreamId,
[FromQuery] bool? enableMpegtsM2TsMode,
- [FromQuery] [RegularExpression(EncodingHelper.ValidationRegex)] string? videoCodec,
- [FromQuery] [RegularExpression(EncodingHelper.ValidationRegex)] string? subtitleCodec,
+ [FromQuery] [RegularExpression(EncodingHelper.ContainerValidationRegex)] string? videoCodec,
+ [FromQuery] [RegularExpression(EncodingHelper.ContainerValidationRegex)] string? subtitleCodec,
[FromQuery] string? transcodeReasons,
[FromQuery] int? audioStreamIndex,
[FromQuery] int? videoStreamIndex,
diff --git a/Jellyfin.Api/Controllers/BrandingController.cs b/Jellyfin.Api/Controllers/BrandingController.cs
index 3c2c4b4dbd..1d948ff206 100644
--- a/Jellyfin.Api/Controllers/BrandingController.cs
+++ b/Jellyfin.Api/Controllers/BrandingController.cs
@@ -29,9 +29,18 @@ public class BrandingController : BaseJellyfinApiController
/// An containing the branding configuration.
[HttpGet("Configuration")]
[ProducesResponseType(StatusCodes.Status200OK)]
- public ActionResult GetBrandingOptions()
+ public ActionResult GetBrandingOptions()
{
- return _serverConfigurationManager.GetConfiguration("branding");
+ var brandingOptions = _serverConfigurationManager.GetConfiguration("branding");
+
+ var brandingOptionsDto = new BrandingOptionsDto
+ {
+ LoginDisclaimer = brandingOptions.LoginDisclaimer,
+ CustomCss = brandingOptions.CustomCss,
+ SplashscreenEnabled = brandingOptions.SplashscreenEnabled
+ };
+
+ return brandingOptionsDto;
}
///
diff --git a/Jellyfin.Api/Controllers/ChannelsController.cs b/Jellyfin.Api/Controllers/ChannelsController.cs
index f83c71b578..880b3a82d4 100644
--- a/Jellyfin.Api/Controllers/ChannelsController.cs
+++ b/Jellyfin.Api/Controllers/ChannelsController.cs
@@ -6,6 +6,7 @@ using System.Threading.Tasks;
using Jellyfin.Api.Helpers;
using Jellyfin.Api.ModelBinders;
using Jellyfin.Data.Enums;
+using Jellyfin.Database.Implementations.Enums;
using Jellyfin.Extensions;
using MediaBrowser.Controller.Channels;
using MediaBrowser.Controller.Dto;
@@ -121,10 +122,10 @@ public class ChannelsController : BaseJellyfinApiController
[FromQuery] Guid? userId,
[FromQuery] int? startIndex,
[FromQuery] int? limit,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] SortOrder[] sortOrder,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ItemFilter[] filters,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ItemSortBy[] sortBy,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ItemFields[] fields)
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] SortOrder[] sortOrder,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ItemFilter[] filters,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ItemSortBy[] sortBy,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ItemFields[] fields)
{
userId = RequestHelpers.GetUserId(User, userId);
var user = userId.IsNullOrEmpty()
@@ -197,9 +198,9 @@ public class ChannelsController : BaseJellyfinApiController
[FromQuery] Guid? userId,
[FromQuery] int? startIndex,
[FromQuery] int? limit,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ItemFilter[] filters,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ItemFields[] fields,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] Guid[] channelIds)
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ItemFilter[] filters,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ItemFields[] fields,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] Guid[] channelIds)
{
userId = RequestHelpers.GetUserId(User, userId);
var user = userId.IsNullOrEmpty()
diff --git a/Jellyfin.Api/Controllers/CollectionController.cs b/Jellyfin.Api/Controllers/CollectionController.cs
index 2d9f1ed69a..c37f376335 100644
--- a/Jellyfin.Api/Controllers/CollectionController.cs
+++ b/Jellyfin.Api/Controllers/CollectionController.cs
@@ -50,7 +50,7 @@ public class CollectionController : BaseJellyfinApiController
[ProducesResponseType(StatusCodes.Status200OK)]
public async Task> CreateCollection(
[FromQuery] string? name,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] string[] ids,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] string[] ids,
[FromQuery] Guid? parentId,
[FromQuery] bool isLocked = false)
{
@@ -86,7 +86,7 @@ public class CollectionController : BaseJellyfinApiController
[ProducesResponseType(StatusCodes.Status204NoContent)]
public async Task AddToCollection(
[FromRoute, Required] Guid collectionId,
- [FromQuery, Required, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] Guid[] ids)
+ [FromQuery, Required, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] Guid[] ids)
{
await _collectionManager.AddToCollectionAsync(collectionId, ids).ConfigureAwait(true);
return NoContent();
@@ -103,7 +103,7 @@ public class CollectionController : BaseJellyfinApiController
[ProducesResponseType(StatusCodes.Status204NoContent)]
public async Task RemoveFromCollection(
[FromRoute, Required] Guid collectionId,
- [FromQuery, Required, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] Guid[] ids)
+ [FromQuery, Required, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] Guid[] ids)
{
await _collectionManager.RemoveFromCollectionAsync(collectionId, ids).ConfigureAwait(false);
return NoContent();
diff --git a/Jellyfin.Api/Controllers/ConfigurationController.cs b/Jellyfin.Api/Controllers/ConfigurationController.cs
index abe8bec2db..8dcaebf6db 100644
--- a/Jellyfin.Api/Controllers/ConfigurationController.cs
+++ b/Jellyfin.Api/Controllers/ConfigurationController.cs
@@ -9,6 +9,7 @@ using Jellyfin.Extensions.Json;
using MediaBrowser.Common.Api;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.MediaEncoding;
+using MediaBrowser.Model.Branding;
using MediaBrowser.Model.Configuration;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
@@ -119,6 +120,30 @@ public class ConfigurationController : BaseJellyfinApiController
return new MetadataOptions();
}
+ ///
+ /// Updates branding configuration.
+ ///
+ /// Branding configuration.
+ /// Branding configuration updated.
+ /// Update status.
+ [HttpPost("Configuration/Branding")]
+ [Authorize(Policy = Policies.RequiresElevation)]
+ [ProducesResponseType(StatusCodes.Status204NoContent)]
+ public ActionResult UpdateBrandingConfiguration([FromBody, Required] BrandingOptionsDto configuration)
+ {
+ // Get the current branding configuration to preserve SplashscreenLocation
+ var currentBranding = (BrandingOptions)_configurationManager.GetConfiguration("branding");
+
+ // Update only the properties from BrandingOptionsDto
+ currentBranding.LoginDisclaimer = configuration.LoginDisclaimer;
+ currentBranding.CustomCss = configuration.CustomCss;
+ currentBranding.SplashscreenEnabled = configuration.SplashscreenEnabled;
+
+ _configurationManager.SaveConfiguration("branding", currentBranding);
+
+ return NoContent();
+ }
+
///
/// Updates the path to the media encoder.
///
diff --git a/Jellyfin.Api/Controllers/DisplayPreferencesController.cs b/Jellyfin.Api/Controllers/DisplayPreferencesController.cs
index 6d94d96f3a..13064882cc 100644
--- a/Jellyfin.Api/Controllers/DisplayPreferencesController.cs
+++ b/Jellyfin.Api/Controllers/DisplayPreferencesController.cs
@@ -4,8 +4,8 @@ using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Linq;
using Jellyfin.Api.Helpers;
-using Jellyfin.Data.Entities;
-using Jellyfin.Data.Enums;
+using Jellyfin.Database.Implementations.Entities;
+using Jellyfin.Database.Implementations.Enums;
using MediaBrowser.Common.Extensions;
using MediaBrowser.Controller;
using MediaBrowser.Model.Dto;
diff --git a/Jellyfin.Api/Controllers/DynamicHlsController.cs b/Jellyfin.Api/Controllers/DynamicHlsController.cs
index 54e0527c90..4cac8ed678 100644
--- a/Jellyfin.Api/Controllers/DynamicHlsController.cs
+++ b/Jellyfin.Api/Controllers/DynamicHlsController.cs
@@ -166,18 +166,18 @@ public class DynamicHlsController : BaseJellyfinApiController
[ProducesPlaylistFile]
public async Task GetLiveHlsStream(
[FromRoute, Required] Guid itemId,
- [FromQuery] [RegularExpression(EncodingHelper.ValidationRegex)] string? container,
+ [FromQuery] [RegularExpression(EncodingHelper.ContainerValidationRegex)] string? container,
[FromQuery] bool? @static,
[FromQuery] string? @params,
[FromQuery] string? tag,
[FromQuery, ParameterObsolete] string? deviceProfileId,
[FromQuery] string? playSessionId,
- [FromQuery] [RegularExpression(EncodingHelper.ValidationRegex)] string? segmentContainer,
+ [FromQuery] [RegularExpression(EncodingHelper.ContainerValidationRegex)] string? segmentContainer,
[FromQuery] int? segmentLength,
[FromQuery] int? minSegments,
[FromQuery] string? mediaSourceId,
[FromQuery] string? deviceId,
- [FromQuery] [RegularExpression(EncodingHelper.ValidationRegex)] string? audioCodec,
+ [FromQuery] [RegularExpression(EncodingHelper.ContainerValidationRegex)] string? audioCodec,
[FromQuery] bool? enableAutoStreamCopy,
[FromQuery] bool? allowVideoStreamCopy,
[FromQuery] bool? allowAudioStreamCopy,
@@ -188,7 +188,7 @@ public class DynamicHlsController : BaseJellyfinApiController
[FromQuery] int? audioChannels,
[FromQuery] int? maxAudioChannels,
[FromQuery] string? profile,
- [FromQuery] string? level,
+ [FromQuery] [RegularExpression(EncodingHelper.LevelValidationRegex)] string? level,
[FromQuery] float? framerate,
[FromQuery] float? maxFramerate,
[FromQuery] bool? copyTimestamps,
@@ -207,8 +207,8 @@ public class DynamicHlsController : BaseJellyfinApiController
[FromQuery] int? cpuCoreLimit,
[FromQuery] string? liveStreamId,
[FromQuery] bool? enableMpegtsM2TsMode,
- [FromQuery] [RegularExpression(EncodingHelper.ValidationRegex)] string? videoCodec,
- [FromQuery] [RegularExpression(EncodingHelper.ValidationRegex)] string? subtitleCodec,
+ [FromQuery] [RegularExpression(EncodingHelper.ContainerValidationRegex)] string? videoCodec,
+ [FromQuery] [RegularExpression(EncodingHelper.ContainerValidationRegex)] string? subtitleCodec,
[FromQuery] string? transcodeReasons,
[FromQuery] int? audioStreamIndex,
[FromQuery] int? videoStreamIndex,
@@ -415,12 +415,12 @@ public class DynamicHlsController : BaseJellyfinApiController
[FromQuery] string? tag,
[FromQuery, ParameterObsolete] string? deviceProfileId,
[FromQuery] string? playSessionId,
- [FromQuery] [RegularExpression(EncodingHelper.ValidationRegex)] string? segmentContainer,
+ [FromQuery] [RegularExpression(EncodingHelper.ContainerValidationRegex)] string? segmentContainer,
[FromQuery] int? segmentLength,
[FromQuery] int? minSegments,
[FromQuery, Required] string mediaSourceId,
[FromQuery] string? deviceId,
- [FromQuery] [RegularExpression(EncodingHelper.ValidationRegex)] string? audioCodec,
+ [FromQuery] [RegularExpression(EncodingHelper.ContainerValidationRegex)] string? audioCodec,
[FromQuery] bool? enableAutoStreamCopy,
[FromQuery] bool? allowVideoStreamCopy,
[FromQuery] bool? allowAudioStreamCopy,
@@ -431,7 +431,7 @@ public class DynamicHlsController : BaseJellyfinApiController
[FromQuery] int? audioChannels,
[FromQuery] int? maxAudioChannels,
[FromQuery] string? profile,
- [FromQuery] string? level,
+ [FromQuery] [RegularExpression(EncodingHelper.LevelValidationRegex)] string? level,
[FromQuery] float? framerate,
[FromQuery] float? maxFramerate,
[FromQuery] bool? copyTimestamps,
@@ -452,14 +452,14 @@ public class DynamicHlsController : BaseJellyfinApiController
[FromQuery] int? cpuCoreLimit,
[FromQuery] string? liveStreamId,
[FromQuery] bool? enableMpegtsM2TsMode,
- [FromQuery] [RegularExpression(EncodingHelper.ValidationRegex)] string? videoCodec,
- [FromQuery] [RegularExpression(EncodingHelper.ValidationRegex)] string? subtitleCodec,
+ [FromQuery] [RegularExpression(EncodingHelper.ContainerValidationRegex)] string? videoCodec,
+ [FromQuery] [RegularExpression(EncodingHelper.ContainerValidationRegex)] string? subtitleCodec,
[FromQuery] string? transcodeReasons,
[FromQuery] int? audioStreamIndex,
[FromQuery] int? videoStreamIndex,
[FromQuery] EncodingContext? context,
[FromQuery] Dictionary streamOptions,
- [FromQuery] bool enableAdaptiveBitrateStreaming = true,
+ [FromQuery] bool enableAdaptiveBitrateStreaming = false,
[FromQuery] bool enableTrickplay = true,
[FromQuery] bool enableAudioVbrEncoding = true,
[FromQuery] bool alwaysBurnInSubtitleWhenTranscoding = false)
@@ -591,12 +591,12 @@ public class DynamicHlsController : BaseJellyfinApiController
[FromQuery] string? tag,
[FromQuery, ParameterObsolete] string? deviceProfileId,
[FromQuery] string? playSessionId,
- [FromQuery] [RegularExpression(EncodingHelper.ValidationRegex)] string? segmentContainer,
+ [FromQuery] [RegularExpression(EncodingHelper.ContainerValidationRegex)] string? segmentContainer,
[FromQuery] int? segmentLength,
[FromQuery] int? minSegments,
[FromQuery, Required] string mediaSourceId,
[FromQuery] string? deviceId,
- [FromQuery] [RegularExpression(EncodingHelper.ValidationRegex)] string? audioCodec,
+ [FromQuery] [RegularExpression(EncodingHelper.ContainerValidationRegex)] string? audioCodec,
[FromQuery] bool? enableAutoStreamCopy,
[FromQuery] bool? allowVideoStreamCopy,
[FromQuery] bool? allowAudioStreamCopy,
@@ -608,7 +608,7 @@ public class DynamicHlsController : BaseJellyfinApiController
[FromQuery] int? audioChannels,
[FromQuery] int? maxAudioChannels,
[FromQuery] string? profile,
- [FromQuery] string? level,
+ [FromQuery] [RegularExpression(EncodingHelper.LevelValidationRegex)] string? level,
[FromQuery] float? framerate,
[FromQuery] float? maxFramerate,
[FromQuery] bool? copyTimestamps,
@@ -627,14 +627,14 @@ public class DynamicHlsController : BaseJellyfinApiController
[FromQuery] int? cpuCoreLimit,
[FromQuery] string? liveStreamId,
[FromQuery] bool? enableMpegtsM2TsMode,
- [FromQuery] [RegularExpression(EncodingHelper.ValidationRegex)] string? videoCodec,
- [FromQuery] [RegularExpression(EncodingHelper.ValidationRegex)] string? subtitleCodec,
+ [FromQuery] [RegularExpression(EncodingHelper.ContainerValidationRegex)] string? videoCodec,
+ [FromQuery] [RegularExpression(EncodingHelper.ContainerValidationRegex)] string? subtitleCodec,
[FromQuery] string? transcodeReasons,
[FromQuery] int? audioStreamIndex,
[FromQuery] int? videoStreamIndex,
[FromQuery] EncodingContext? context,
[FromQuery] Dictionary streamOptions,
- [FromQuery] bool enableAdaptiveBitrateStreaming = true,
+ [FromQuery] bool enableAdaptiveBitrateStreaming = false,
[FromQuery] bool enableAudioVbrEncoding = true)
{
var streamingRequest = new HlsAudioRequestDto
@@ -761,12 +761,12 @@ public class DynamicHlsController : BaseJellyfinApiController
[FromQuery] string? tag,
[FromQuery, ParameterObsolete] string? deviceProfileId,
[FromQuery] string? playSessionId,
- [FromQuery] [RegularExpression(EncodingHelper.ValidationRegex)] string? segmentContainer,
+ [FromQuery] [RegularExpression(EncodingHelper.ContainerValidationRegex)] string? segmentContainer,
[FromQuery] int? segmentLength,
[FromQuery] int? minSegments,
[FromQuery] string? mediaSourceId,
[FromQuery] string? deviceId,
- [FromQuery] [RegularExpression(EncodingHelper.ValidationRegex)] string? audioCodec,
+ [FromQuery] [RegularExpression(EncodingHelper.ContainerValidationRegex)] string? audioCodec,
[FromQuery] bool? enableAutoStreamCopy,
[FromQuery] bool? allowVideoStreamCopy,
[FromQuery] bool? allowAudioStreamCopy,
@@ -777,7 +777,7 @@ public class DynamicHlsController : BaseJellyfinApiController
[FromQuery] int? audioChannels,
[FromQuery] int? maxAudioChannels,
[FromQuery] string? profile,
- [FromQuery] string? level,
+ [FromQuery] [RegularExpression(EncodingHelper.LevelValidationRegex)] string? level,
[FromQuery] float? framerate,
[FromQuery] float? maxFramerate,
[FromQuery] bool? copyTimestamps,
@@ -798,8 +798,8 @@ public class DynamicHlsController : BaseJellyfinApiController
[FromQuery] int? cpuCoreLimit,
[FromQuery] string? liveStreamId,
[FromQuery] bool? enableMpegtsM2TsMode,
- [FromQuery] [RegularExpression(EncodingHelper.ValidationRegex)] string? videoCodec,
- [FromQuery] [RegularExpression(EncodingHelper.ValidationRegex)] string? subtitleCodec,
+ [FromQuery] [RegularExpression(EncodingHelper.ContainerValidationRegex)] string? videoCodec,
+ [FromQuery] [RegularExpression(EncodingHelper.ContainerValidationRegex)] string? subtitleCodec,
[FromQuery] string? transcodeReasons,
[FromQuery] int? audioStreamIndex,
[FromQuery] int? videoStreamIndex,
@@ -933,12 +933,12 @@ public class DynamicHlsController : BaseJellyfinApiController
[FromQuery] string? tag,
[FromQuery, ParameterObsolete] string? deviceProfileId,
[FromQuery] string? playSessionId,
- [FromQuery] [RegularExpression(EncodingHelper.ValidationRegex)] string? segmentContainer,
+ [FromQuery] [RegularExpression(EncodingHelper.ContainerValidationRegex)] string? segmentContainer,
[FromQuery] int? segmentLength,
[FromQuery] int? minSegments,
[FromQuery] string? mediaSourceId,
[FromQuery] string? deviceId,
- [FromQuery] [RegularExpression(EncodingHelper.ValidationRegex)] string? audioCodec,
+ [FromQuery] [RegularExpression(EncodingHelper.ContainerValidationRegex)] string? audioCodec,
[FromQuery] bool? enableAutoStreamCopy,
[FromQuery] bool? allowVideoStreamCopy,
[FromQuery] bool? allowAudioStreamCopy,
@@ -950,7 +950,7 @@ public class DynamicHlsController : BaseJellyfinApiController
[FromQuery] int? audioChannels,
[FromQuery] int? maxAudioChannels,
[FromQuery] string? profile,
- [FromQuery] string? level,
+ [FromQuery] [RegularExpression(EncodingHelper.LevelValidationRegex)] string? level,
[FromQuery] float? framerate,
[FromQuery] float? maxFramerate,
[FromQuery] bool? copyTimestamps,
@@ -969,8 +969,8 @@ public class DynamicHlsController : BaseJellyfinApiController
[FromQuery] int? cpuCoreLimit,
[FromQuery] string? liveStreamId,
[FromQuery] bool? enableMpegtsM2TsMode,
- [FromQuery] [RegularExpression(EncodingHelper.ValidationRegex)] string? videoCodec,
- [FromQuery] [RegularExpression(EncodingHelper.ValidationRegex)] string? subtitleCodec,
+ [FromQuery] [RegularExpression(EncodingHelper.ContainerValidationRegex)] string? videoCodec,
+ [FromQuery] [RegularExpression(EncodingHelper.ContainerValidationRegex)] string? subtitleCodec,
[FromQuery] string? transcodeReasons,
[FromQuery] int? audioStreamIndex,
[FromQuery] int? videoStreamIndex,
@@ -1106,7 +1106,7 @@ public class DynamicHlsController : BaseJellyfinApiController
[FromRoute, Required] Guid itemId,
[FromRoute, Required] string playlistId,
[FromRoute, Required] int segmentId,
- [FromRoute, Required] string container,
+ [FromRoute, Required] [RegularExpression(EncodingHelper.ContainerValidationRegex)] string container,
[FromQuery, Required] long runtimeTicks,
[FromQuery, Required] long actualSegmentLengthTicks,
[FromQuery] bool? @static,
@@ -1114,12 +1114,12 @@ public class DynamicHlsController : BaseJellyfinApiController
[FromQuery] string? tag,
[FromQuery, ParameterObsolete] string? deviceProfileId,
[FromQuery] string? playSessionId,
- [FromQuery] [RegularExpression(EncodingHelper.ValidationRegex)] string? segmentContainer,
+ [FromQuery] [RegularExpression(EncodingHelper.ContainerValidationRegex)] string? segmentContainer,
[FromQuery] int? segmentLength,
[FromQuery] int? minSegments,
[FromQuery] string? mediaSourceId,
[FromQuery] string? deviceId,
- [FromQuery] [RegularExpression(EncodingHelper.ValidationRegex)] string? audioCodec,
+ [FromQuery] [RegularExpression(EncodingHelper.ContainerValidationRegex)] string? audioCodec,
[FromQuery] bool? enableAutoStreamCopy,
[FromQuery] bool? allowVideoStreamCopy,
[FromQuery] bool? allowAudioStreamCopy,
@@ -1130,7 +1130,7 @@ public class DynamicHlsController : BaseJellyfinApiController
[FromQuery] int? audioChannels,
[FromQuery] int? maxAudioChannels,
[FromQuery] string? profile,
- [FromQuery] string? level,
+ [FromQuery] [RegularExpression(EncodingHelper.LevelValidationRegex)] string? level,
[FromQuery] float? framerate,
[FromQuery] float? maxFramerate,
[FromQuery] bool? copyTimestamps,
@@ -1151,8 +1151,8 @@ public class DynamicHlsController : BaseJellyfinApiController
[FromQuery] int? cpuCoreLimit,
[FromQuery] string? liveStreamId,
[FromQuery] bool? enableMpegtsM2TsMode,
- [FromQuery] [RegularExpression(EncodingHelper.ValidationRegex)] string? videoCodec,
- [FromQuery] [RegularExpression(EncodingHelper.ValidationRegex)] string? subtitleCodec,
+ [FromQuery] [RegularExpression(EncodingHelper.ContainerValidationRegex)] string? videoCodec,
+ [FromQuery] [RegularExpression(EncodingHelper.ContainerValidationRegex)] string? subtitleCodec,
[FromQuery] string? transcodeReasons,
[FromQuery] int? audioStreamIndex,
[FromQuery] int? videoStreamIndex,
@@ -1291,7 +1291,7 @@ public class DynamicHlsController : BaseJellyfinApiController
[FromRoute, Required] Guid itemId,
[FromRoute, Required] string playlistId,
[FromRoute, Required] int segmentId,
- [FromRoute, Required] string container,
+ [FromRoute, Required] [RegularExpression(EncodingHelper.ContainerValidationRegex)] string container,
[FromQuery, Required] long runtimeTicks,
[FromQuery, Required] long actualSegmentLengthTicks,
[FromQuery] bool? @static,
@@ -1299,12 +1299,12 @@ public class DynamicHlsController : BaseJellyfinApiController
[FromQuery] string? tag,
[FromQuery, ParameterObsolete] string? deviceProfileId,
[FromQuery] string? playSessionId,
- [FromQuery] [RegularExpression(EncodingHelper.ValidationRegex)] string? segmentContainer,
+ [FromQuery] [RegularExpression(EncodingHelper.ContainerValidationRegex)] string? segmentContainer,
[FromQuery] int? segmentLength,
[FromQuery] int? minSegments,
[FromQuery] string? mediaSourceId,
[FromQuery] string? deviceId,
- [FromQuery] [RegularExpression(EncodingHelper.ValidationRegex)] string? audioCodec,
+ [FromQuery] [RegularExpression(EncodingHelper.ContainerValidationRegex)] string? audioCodec,
[FromQuery] bool? enableAutoStreamCopy,
[FromQuery] bool? allowVideoStreamCopy,
[FromQuery] bool? allowAudioStreamCopy,
@@ -1316,7 +1316,7 @@ public class DynamicHlsController : BaseJellyfinApiController
[FromQuery] int? audioChannels,
[FromQuery] int? maxAudioChannels,
[FromQuery] string? profile,
- [FromQuery] string? level,
+ [FromQuery] [RegularExpression(EncodingHelper.LevelValidationRegex)] string? level,
[FromQuery] float? framerate,
[FromQuery] float? maxFramerate,
[FromQuery] bool? copyTimestamps,
@@ -1335,8 +1335,8 @@ public class DynamicHlsController : BaseJellyfinApiController
[FromQuery] int? cpuCoreLimit,
[FromQuery] string? liveStreamId,
[FromQuery] bool? enableMpegtsM2TsMode,
- [FromQuery] [RegularExpression(EncodingHelper.ValidationRegex)] string? videoCodec,
- [FromQuery] [RegularExpression(EncodingHelper.ValidationRegex)] string? subtitleCodec,
+ [FromQuery] [RegularExpression(EncodingHelper.ContainerValidationRegex)] string? videoCodec,
+ [FromQuery] [RegularExpression(EncodingHelper.ContainerValidationRegex)] string? subtitleCodec,
[FromQuery] string? transcodeReasons,
[FromQuery] int? audioStreamIndex,
[FromQuery] int? videoStreamIndex,
@@ -1419,8 +1419,9 @@ public class DynamicHlsController : BaseJellyfinApiController
TranscodingJobType,
cancellationTokenSource.Token)
.ConfigureAwait(false);
-
+ var mediaSourceId = state.BaseRequest.MediaSourceId;
var request = new CreateMainPlaylistRequest(
+ mediaSourceId is null ? null : Guid.Parse(mediaSourceId),
state.MediaPath,
state.SegmentLength * 1000,
state.RunTimeTicks ?? 0,
@@ -1675,7 +1676,7 @@ public class DynamicHlsController : BaseJellyfinApiController
}
var audioCodec = _encodingHelper.GetAudioEncoder(state);
- var bitStreamArgs = EncodingHelper.GetAudioBitStreamArguments(state, state.Request.SegmentContainer, state.MediaSource.Container);
+ var bitStreamArgs = _encodingHelper.GetAudioBitStreamArguments(state, state.Request.SegmentContainer, state.MediaSource.Container);
// opus, dts, truehd and flac (in FFmpeg 5 and older) are experimental in mp4 muxer
var strictArgs = string.Empty;
@@ -1753,7 +1754,7 @@ public class DynamicHlsController : BaseJellyfinApiController
if (channels.HasValue
&& (channels.Value != 2
- || (state.AudioStream?.Channels != null && !useDownMixAlgorithm)))
+ || (state.AudioStream?.Channels is not null && !useDownMixAlgorithm)))
{
args += " -ac " + channels.Value;
}
@@ -1778,7 +1779,7 @@ public class DynamicHlsController : BaseJellyfinApiController
}
else if (state.AudioStream?.CodecTag is not null && state.AudioStream.CodecTag.Equals("ac-4", StringComparison.Ordinal))
{
- // ac-4 audio tends to hava a super weird sample rate that will fail most encoders
+ // ac-4 audio tends to have a super weird sample rate that will fail most encoders
// force resample it to 48KHz
args += " -ar 48000";
}
@@ -1819,16 +1820,14 @@ public class DynamicHlsController : BaseJellyfinApiController
if (isActualOutputVideoCodecHevc || isActualOutputVideoCodecAv1)
{
var requestedRange = state.GetRequestedRangeTypes(state.ActualOutputVideoCodec);
- var requestHasDOVI = requestedRange.Contains(VideoRangeType.DOVI.ToString(), StringComparison.OrdinalIgnoreCase);
- var requestHasDOVIWithHDR10 = requestedRange.Contains(VideoRangeType.DOVIWithHDR10.ToString(), StringComparison.OrdinalIgnoreCase);
- var requestHasDOVIWithHLG = requestedRange.Contains(VideoRangeType.DOVIWithHLG.ToString(), StringComparison.OrdinalIgnoreCase);
- var requestHasDOVIWithSDR = requestedRange.Contains(VideoRangeType.DOVIWithSDR.ToString(), StringComparison.OrdinalIgnoreCase);
+ // Clients reporting Dolby Vision capabilities with fallbacks may only support the fallback layer.
+ // Only enable Dolby Vision remuxing if the client explicitly declares support for profiles without fallbacks.
+ var clientSupportsDoVi = requestedRange.Contains(VideoRangeType.DOVI.ToString(), StringComparison.OrdinalIgnoreCase);
+ var videoIsDoVi = EncodingHelper.IsDovi(state.VideoStream);
if (EncodingHelper.IsCopyCodec(codec)
- && ((state.VideoStream.VideoRangeType == VideoRangeType.DOVI && requestHasDOVI)
- || (state.VideoStream.VideoRangeType == VideoRangeType.DOVIWithHDR10 && requestHasDOVIWithHDR10)
- || (state.VideoStream.VideoRangeType == VideoRangeType.DOVIWithHLG && requestHasDOVIWithHLG)
- || (state.VideoStream.VideoRangeType == VideoRangeType.DOVIWithSDR && requestHasDOVIWithSDR)))
+ && (videoIsDoVi && clientSupportsDoVi)
+ && !_encodingHelper.IsDoviRemoved(state))
{
if (isActualOutputVideoCodecHevc)
{
@@ -1858,7 +1857,7 @@ public class DynamicHlsController : BaseJellyfinApiController
// If h264_mp4toannexb is ever added, do not use it for live tv.
if (state.VideoStream is not null && !string.Equals(state.VideoStream.NalLengthSize, "0", StringComparison.OrdinalIgnoreCase))
{
- string bitStreamArgs = EncodingHelper.GetBitStreamArgs(state.VideoStream);
+ string bitStreamArgs = _encodingHelper.GetBitStreamArgs(state, MediaStreamType.Video);
if (!string.IsNullOrEmpty(bitStreamArgs))
{
args += " " + bitStreamArgs;
@@ -2059,16 +2058,16 @@ public class DynamicHlsController : BaseJellyfinApiController
}
}
- private Task DeleteLastFile(string playlistPath, string segmentExtension, int retryCount)
+ private async Task DeleteLastFile(string playlistPath, string segmentExtension, int retryCount)
{
var file = GetLastTranscodingFile(playlistPath, segmentExtension, _fileSystem);
if (file is null)
{
- return Task.CompletedTask;
+ return;
}
- return DeleteFile(file.FullName, retryCount);
+ await DeleteFile(file.FullName, retryCount).ConfigureAwait(false);
}
private async Task DeleteFile(string path, int retryCount)
diff --git a/Jellyfin.Api/Controllers/FilterController.cs b/Jellyfin.Api/Controllers/FilterController.cs
index 4abca32713..3f9aa93a64 100644
--- a/Jellyfin.Api/Controllers/FilterController.cs
+++ b/Jellyfin.Api/Controllers/FilterController.cs
@@ -50,8 +50,8 @@ public class FilterController : BaseJellyfinApiController
public ActionResult GetQueryFiltersLegacy(
[FromQuery] Guid? userId,
[FromQuery] Guid? parentId,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] BaseItemKind[] includeItemTypes,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] MediaType[] mediaTypes)
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] BaseItemKind[] includeItemTypes,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] MediaType[] mediaTypes)
{
userId = RequestHelpers.GetUserId(User, userId);
var user = userId.IsNullOrEmpty()
@@ -137,7 +137,7 @@ public class FilterController : BaseJellyfinApiController
public ActionResult GetQueryFilters(
[FromQuery] Guid? userId,
[FromQuery] Guid? parentId,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] BaseItemKind[] includeItemTypes,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] BaseItemKind[] includeItemTypes,
[FromQuery] bool? isAiring,
[FromQuery] bool? isMovie,
[FromQuery] bool? isSports,
diff --git a/Jellyfin.Api/Controllers/GenresController.cs b/Jellyfin.Api/Controllers/GenresController.cs
index 54d48aec21..dd60d01e0c 100644
--- a/Jellyfin.Api/Controllers/GenresController.cs
+++ b/Jellyfin.Api/Controllers/GenresController.cs
@@ -4,8 +4,9 @@ using System.Linq;
using Jellyfin.Api.Extensions;
using Jellyfin.Api.Helpers;
using Jellyfin.Api.ModelBinders;
-using Jellyfin.Data.Entities;
using Jellyfin.Data.Enums;
+using Jellyfin.Database.Implementations.Entities;
+using Jellyfin.Database.Implementations.Enums;
using Jellyfin.Extensions;
using MediaBrowser.Controller.Dto;
using MediaBrowser.Controller.Entities;
@@ -76,18 +77,18 @@ public class GenresController : BaseJellyfinApiController
[FromQuery] int? limit,
[FromQuery] string? searchTerm,
[FromQuery] Guid? parentId,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ItemFields[] fields,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] BaseItemKind[] excludeItemTypes,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] BaseItemKind[] includeItemTypes,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ItemFields[] fields,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] BaseItemKind[] excludeItemTypes,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] BaseItemKind[] includeItemTypes,
[FromQuery] bool? isFavorite,
[FromQuery] int? imageTypeLimit,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ImageType[] enableImageTypes,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ImageType[] enableImageTypes,
[FromQuery] Guid? userId,
[FromQuery] string? nameStartsWithOrGreater,
[FromQuery] string? nameStartsWith,
[FromQuery] string? nameLessThan,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ItemSortBy[] sortBy,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] SortOrder[] sortOrder,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ItemSortBy[] sortBy,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] SortOrder[] sortOrder,
[FromQuery] bool? enableImages = true,
[FromQuery] bool enableTotalRecordCount = true)
{
diff --git a/Jellyfin.Api/Controllers/ImageController.cs b/Jellyfin.Api/Controllers/ImageController.cs
index b711990261..abda053d36 100644
--- a/Jellyfin.Api/Controllers/ImageController.cs
+++ b/Jellyfin.Api/Controllers/ImageController.cs
@@ -130,7 +130,7 @@ public class ImageController : BaseJellyfinApiController
await _userManager.ClearProfileImageAsync(user).ConfigureAwait(false);
}
- user.ProfileImage = new Data.Entities.ImageInfo(Path.Combine(userDataPath, "profile" + extension));
+ user.ProfileImage = new Database.Implementations.Entities.ImageInfo(Path.Combine(userDataPath, "profile" + extension));
await _providerManager
.SaveImage(stream, mimeType, user.ProfileImage.Path)
@@ -1727,7 +1727,8 @@ public class ImageController : BaseJellyfinApiController
[FromQuery, Range(0, 100)] int quality = 90)
{
var brandingOptions = _serverConfigurationManager.GetConfiguration("branding");
- if (!brandingOptions.SplashscreenEnabled)
+ var isAdmin = User.IsInRole(Constants.UserRoles.Administrator);
+ if (!brandingOptions.SplashscreenEnabled && !isAdmin)
{
return NotFound();
}
diff --git a/Jellyfin.Api/Controllers/InstantMixController.cs b/Jellyfin.Api/Controllers/InstantMixController.cs
index dcbacf1d78..c4b9767565 100644
--- a/Jellyfin.Api/Controllers/InstantMixController.cs
+++ b/Jellyfin.Api/Controllers/InstantMixController.cs
@@ -1,10 +1,12 @@
using System;
using System.Collections.Generic;
+using System.Collections.Immutable;
using System.ComponentModel.DataAnnotations;
+using System.Linq;
using Jellyfin.Api.Extensions;
using Jellyfin.Api.Helpers;
using Jellyfin.Api.ModelBinders;
-using Jellyfin.Data.Entities;
+using Jellyfin.Database.Implementations.Entities;
using Jellyfin.Extensions;
using MediaBrowser.Controller.Dto;
using MediaBrowser.Controller.Entities;
@@ -71,11 +73,11 @@ public class InstantMixController : BaseJellyfinApiController
[FromRoute, Required] Guid itemId,
[FromQuery] Guid? userId,
[FromQuery] int? limit,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ItemFields[] fields,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ItemFields[] fields,
[FromQuery] bool? enableImages,
[FromQuery] bool? enableUserData,
[FromQuery] int? imageTypeLimit,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ImageType[] enableImageTypes)
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ImageType[] enableImageTypes)
{
userId = RequestHelpers.GetUserId(User, userId);
var user = userId.IsNullOrEmpty()
@@ -115,11 +117,11 @@ public class InstantMixController : BaseJellyfinApiController
[FromRoute, Required] Guid itemId,
[FromQuery] Guid? userId,
[FromQuery] int? limit,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ItemFields[] fields,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ItemFields[] fields,
[FromQuery] bool? enableImages,
[FromQuery] bool? enableUserData,
[FromQuery] int? imageTypeLimit,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ImageType[] enableImageTypes)
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ImageType[] enableImageTypes)
{
userId = RequestHelpers.GetUserId(User, userId);
var user = userId.IsNullOrEmpty()
@@ -159,11 +161,11 @@ public class InstantMixController : BaseJellyfinApiController
[FromRoute, Required] Guid itemId,
[FromQuery] Guid? userId,
[FromQuery] int? limit,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ItemFields[] fields,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ItemFields[] fields,
[FromQuery] bool? enableImages,
[FromQuery] bool? enableUserData,
[FromQuery] int? imageTypeLimit,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ImageType[] enableImageTypes)
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ImageType[] enableImageTypes)
{
userId = RequestHelpers.GetUserId(User, userId);
var user = userId.IsNullOrEmpty()
@@ -201,11 +203,11 @@ public class InstantMixController : BaseJellyfinApiController
[FromRoute, Required] string name,
[FromQuery] Guid? userId,
[FromQuery] int? limit,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ItemFields[] fields,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ItemFields[] fields,
[FromQuery] bool? enableImages,
[FromQuery] bool? enableUserData,
[FromQuery] int? imageTypeLimit,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ImageType[] enableImageTypes)
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ImageType[] enableImageTypes)
{
userId = RequestHelpers.GetUserId(User, userId);
var user = userId.IsNullOrEmpty()
@@ -239,11 +241,11 @@ public class InstantMixController : BaseJellyfinApiController
[FromRoute, Required] Guid itemId,
[FromQuery] Guid? userId,
[FromQuery] int? limit,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ItemFields[] fields,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ItemFields[] fields,
[FromQuery] bool? enableImages,
[FromQuery] bool? enableUserData,
[FromQuery] int? imageTypeLimit,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ImageType[] enableImageTypes)
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ImageType[] enableImageTypes)
{
userId = RequestHelpers.GetUserId(User, userId);
var user = userId.IsNullOrEmpty()
@@ -283,11 +285,11 @@ public class InstantMixController : BaseJellyfinApiController
[FromRoute, Required] Guid itemId,
[FromQuery] Guid? userId,
[FromQuery] int? limit,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ItemFields[] fields,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ItemFields[] fields,
[FromQuery] bool? enableImages,
[FromQuery] bool? enableUserData,
[FromQuery] int? imageTypeLimit,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ImageType[] enableImageTypes)
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ImageType[] enableImageTypes)
{
userId = RequestHelpers.GetUserId(User, userId);
var user = userId.IsNullOrEmpty()
@@ -328,11 +330,11 @@ public class InstantMixController : BaseJellyfinApiController
[FromQuery, Required] Guid id,
[FromQuery] Guid? userId,
[FromQuery] int? limit,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ItemFields[] fields,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ItemFields[] fields,
[FromQuery] bool? enableImages,
[FromQuery] bool? enableUserData,
[FromQuery] int? imageTypeLimit,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ImageType[] enableImageTypes)
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ImageType[] enableImageTypes)
{
return GetInstantMixFromArtists(
id,
@@ -366,11 +368,11 @@ public class InstantMixController : BaseJellyfinApiController
[FromQuery, Required] Guid id,
[FromQuery] Guid? userId,
[FromQuery] int? limit,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ItemFields[] fields,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ItemFields[] fields,
[FromQuery] bool? enableImages,
[FromQuery] bool? enableUserData,
[FromQuery] int? imageTypeLimit,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ImageType[] enableImageTypes)
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ImageType[] enableImageTypes)
{
userId = RequestHelpers.GetUserId(User, userId);
var user = userId.IsNullOrEmpty()
@@ -389,23 +391,19 @@ public class InstantMixController : BaseJellyfinApiController
return GetResult(items, user, limit, dtoOptions);
}
- private QueryResult GetResult(List items, User? user, int? limit, DtoOptions dtoOptions)
+ private QueryResult GetResult(IReadOnlyList items, User? user, int? limit, DtoOptions dtoOptions)
{
- var list = items;
+ var totalCount = items.Count;
- var totalCount = list.Count;
-
- if (limit.HasValue && limit < list.Count)
+ if (limit.HasValue && limit < items.Count)
{
- list = list.GetRange(0, limit.Value);
+ items = items.Take(limit.Value).ToArray();
}
- var returnList = _dtoService.GetBaseItemDtos(list, dtoOptions, user);
-
var result = new QueryResult(
0,
totalCount,
- returnList);
+ _dtoService.GetBaseItemDtos(items, dtoOptions, user));
return result;
}
diff --git a/Jellyfin.Api/Controllers/ItemRefreshController.cs b/Jellyfin.Api/Controllers/ItemRefreshController.cs
index d7a8c37c4b..7effe61e49 100644
--- a/Jellyfin.Api/Controllers/ItemRefreshController.cs
+++ b/Jellyfin.Api/Controllers/ItemRefreshController.cs
@@ -50,6 +50,7 @@ public class ItemRefreshController : BaseJellyfinApiController
/// (Optional) Specifies the image refresh mode.
/// (Optional) Determines if metadata should be replaced. Only applicable if mode is FullRefresh.
/// (Optional) Determines if images should be replaced. Only applicable if mode is FullRefresh.
+ /// (Optional) Determines if trickplay images should be replaced. Only applicable if mode is FullRefresh.
/// Item metadata refresh queued.
/// Item to refresh not found.
/// An on success, or a if the item could not be found.
@@ -62,7 +63,8 @@ public class ItemRefreshController : BaseJellyfinApiController
[FromQuery] MetadataRefreshMode metadataRefreshMode = MetadataRefreshMode.None,
[FromQuery] MetadataRefreshMode imageRefreshMode = MetadataRefreshMode.None,
[FromQuery] bool replaceAllMetadata = false,
- [FromQuery] bool replaceAllImages = false)
+ [FromQuery] bool replaceAllImages = false,
+ [FromQuery] bool regenerateTrickplay = false)
{
var item = _libraryManager.GetItemById(itemId, User.GetUserId());
if (item is null)
@@ -81,7 +83,8 @@ public class ItemRefreshController : BaseJellyfinApiController
|| replaceAllImages
|| replaceAllMetadata,
IsAutomated = false,
- RemoveOldMetadata = replaceAllMetadata
+ RemoveOldMetadata = replaceAllMetadata,
+ RegenerateTrickplay = regenerateTrickplay
};
_providerManager.QueueRefresh(item.Id, refreshOptions, RefreshPriority.High);
diff --git a/Jellyfin.Api/Controllers/ItemUpdateController.cs b/Jellyfin.Api/Controllers/ItemUpdateController.cs
index 4001a6addb..d49e0753ee 100644
--- a/Jellyfin.Api/Controllers/ItemUpdateController.cs
+++ b/Jellyfin.Api/Controllers/ItemUpdateController.cs
@@ -457,7 +457,7 @@ public class ItemUpdateController : BaseJellyfinApiController
return null;
}
- return (SeriesStatus)Enum.Parse(typeof(SeriesStatus), item.Status, true);
+ return Enum.Parse(item.Status, true);
}
private DateTime NormalizeDateTime(DateTime val)
diff --git a/Jellyfin.Api/Controllers/ItemsController.cs b/Jellyfin.Api/Controllers/ItemsController.cs
index 828bd51740..a491283363 100644
--- a/Jellyfin.Api/Controllers/ItemsController.cs
+++ b/Jellyfin.Api/Controllers/ItemsController.cs
@@ -4,7 +4,9 @@ using System.Linq;
using Jellyfin.Api.Extensions;
using Jellyfin.Api.Helpers;
using Jellyfin.Api.ModelBinders;
+using Jellyfin.Data;
using Jellyfin.Data.Enums;
+using Jellyfin.Database.Implementations.Enums;
using Jellyfin.Extensions;
using MediaBrowser.Common.Extensions;
using MediaBrowser.Controller.Dto;
@@ -171,8 +173,8 @@ public class ItemsController : BaseJellyfinApiController
[FromQuery] bool? hasParentalRating,
[FromQuery] bool? isHd,
[FromQuery] bool? is4K,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] LocationType[] locationTypes,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] LocationType[] excludeLocationTypes,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] LocationType[] locationTypes,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] LocationType[] excludeLocationTypes,
[FromQuery] bool? isMissing,
[FromQuery] bool? isUnaired,
[FromQuery] double? minCommunityRating,
@@ -190,42 +192,42 @@ public class ItemsController : BaseJellyfinApiController
[FromQuery] bool? isNews,
[FromQuery] bool? isKids,
[FromQuery] bool? isSports,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] Guid[] excludeItemIds,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] Guid[] excludeItemIds,
[FromQuery] int? startIndex,
[FromQuery] int? limit,
[FromQuery] bool? recursive,
[FromQuery] string? searchTerm,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] SortOrder[] sortOrder,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] SortOrder[] sortOrder,
[FromQuery] Guid? parentId,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ItemFields[] fields,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] BaseItemKind[] excludeItemTypes,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] BaseItemKind[] includeItemTypes,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ItemFilter[] filters,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ItemFields[] fields,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] BaseItemKind[] excludeItemTypes,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] BaseItemKind[] includeItemTypes,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ItemFilter[] filters,
[FromQuery] bool? isFavorite,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] MediaType[] mediaTypes,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ImageType[] imageTypes,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ItemSortBy[] sortBy,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] MediaType[] mediaTypes,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ImageType[] imageTypes,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ItemSortBy[] sortBy,
[FromQuery] bool? isPlayed,
- [FromQuery, ModelBinder(typeof(PipeDelimitedArrayModelBinder))] string[] genres,
- [FromQuery, ModelBinder(typeof(PipeDelimitedArrayModelBinder))] string[] officialRatings,
- [FromQuery, ModelBinder(typeof(PipeDelimitedArrayModelBinder))] string[] tags,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] int[] years,
+ [FromQuery, ModelBinder(typeof(PipeDelimitedCollectionModelBinder))] string[] genres,
+ [FromQuery, ModelBinder(typeof(PipeDelimitedCollectionModelBinder))] string[] officialRatings,
+ [FromQuery, ModelBinder(typeof(PipeDelimitedCollectionModelBinder))] string[] tags,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] int[] years,
[FromQuery] bool? enableUserData,
[FromQuery] int? imageTypeLimit,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ImageType[] enableImageTypes,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ImageType[] enableImageTypes,
[FromQuery] string? person,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] Guid[] personIds,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] string[] personTypes,
- [FromQuery, ModelBinder(typeof(PipeDelimitedArrayModelBinder))] string[] studios,
- [FromQuery, ModelBinder(typeof(PipeDelimitedArrayModelBinder))] string[] artists,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] Guid[] excludeArtistIds,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] Guid[] artistIds,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] Guid[] albumArtistIds,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] Guid[] contributingArtistIds,
- [FromQuery, ModelBinder(typeof(PipeDelimitedArrayModelBinder))] string[] albums,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] Guid[] albumIds,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] Guid[] ids,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] VideoType[] videoTypes,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] Guid[] personIds,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] string[] personTypes,
+ [FromQuery, ModelBinder(typeof(PipeDelimitedCollectionModelBinder))] string[] studios,
+ [FromQuery, ModelBinder(typeof(PipeDelimitedCollectionModelBinder))] string[] artists,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] Guid[] excludeArtistIds,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] Guid[] artistIds,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] Guid[] albumArtistIds,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] Guid[] contributingArtistIds,
+ [FromQuery, ModelBinder(typeof(PipeDelimitedCollectionModelBinder))] string[] albums,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] Guid[] albumIds,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] Guid[] ids,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] VideoType[] videoTypes,
[FromQuery] string? minOfficialRating,
[FromQuery] bool? isLocked,
[FromQuery] bool? isPlaceHolder,
@@ -236,12 +238,12 @@ public class ItemsController : BaseJellyfinApiController
[FromQuery] int? maxWidth,
[FromQuery] int? maxHeight,
[FromQuery] bool? is3D,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] SeriesStatus[] seriesStatus,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] SeriesStatus[] seriesStatus,
[FromQuery] string? nameStartsWithOrGreater,
[FromQuery] string? nameStartsWith,
[FromQuery] string? nameLessThan,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] Guid[] studioIds,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] Guid[] genreIds,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] Guid[] studioIds,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] Guid[] genreIds,
[FromQuery] bool enableTotalRecordCount = true,
[FromQuery] bool? enableImages = true)
{
@@ -446,13 +448,13 @@ public class ItemsController : BaseJellyfinApiController
// Min official rating
if (!string.IsNullOrWhiteSpace(minOfficialRating))
{
- query.MinParentalRating = _localization.GetRatingLevel(minOfficialRating);
+ query.MinParentalRating = _localization.GetRatingScore(minOfficialRating);
}
// Max official rating
if (!string.IsNullOrWhiteSpace(maxOfficialRating))
{
- query.MaxParentalRating = _localization.GetRatingLevel(maxOfficialRating);
+ query.MaxParentalRating = _localization.GetRatingScore(maxOfficialRating);
}
// Artists
@@ -638,8 +640,8 @@ public class ItemsController : BaseJellyfinApiController
[FromQuery] bool? hasParentalRating,
[FromQuery] bool? isHd,
[FromQuery] bool? is4K,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] LocationType[] locationTypes,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] LocationType[] excludeLocationTypes,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] LocationType[] locationTypes,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] LocationType[] excludeLocationTypes,
[FromQuery] bool? isMissing,
[FromQuery] bool? isUnaired,
[FromQuery] double? minCommunityRating,
@@ -657,42 +659,42 @@ public class ItemsController : BaseJellyfinApiController
[FromQuery] bool? isNews,
[FromQuery] bool? isKids,
[FromQuery] bool? isSports,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] Guid[] excludeItemIds,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] Guid[] excludeItemIds,
[FromQuery] int? startIndex,
[FromQuery] int? limit,
[FromQuery] bool? recursive,
[FromQuery] string? searchTerm,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] SortOrder[] sortOrder,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] SortOrder[] sortOrder,
[FromQuery] Guid? parentId,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ItemFields[] fields,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] BaseItemKind[] excludeItemTypes,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] BaseItemKind[] includeItemTypes,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ItemFilter[] filters,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ItemFields[] fields,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] BaseItemKind[] excludeItemTypes,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] BaseItemKind[] includeItemTypes,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ItemFilter[] filters,
[FromQuery] bool? isFavorite,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] MediaType[] mediaTypes,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ImageType[] imageTypes,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ItemSortBy[] sortBy,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] MediaType[] mediaTypes,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ImageType[] imageTypes,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ItemSortBy[] sortBy,
[FromQuery] bool? isPlayed,
- [FromQuery, ModelBinder(typeof(PipeDelimitedArrayModelBinder))] string[] genres,
- [FromQuery, ModelBinder(typeof(PipeDelimitedArrayModelBinder))] string[] officialRatings,
- [FromQuery, ModelBinder(typeof(PipeDelimitedArrayModelBinder))] string[] tags,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] int[] years,
+ [FromQuery, ModelBinder(typeof(PipeDelimitedCollectionModelBinder))] string[] genres,
+ [FromQuery, ModelBinder(typeof(PipeDelimitedCollectionModelBinder))] string[] officialRatings,
+ [FromQuery, ModelBinder(typeof(PipeDelimitedCollectionModelBinder))] string[] tags,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] int[] years,
[FromQuery] bool? enableUserData,
[FromQuery] int? imageTypeLimit,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ImageType[] enableImageTypes,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ImageType[] enableImageTypes,
[FromQuery] string? person,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] Guid[] personIds,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] string[] personTypes,
- [FromQuery, ModelBinder(typeof(PipeDelimitedArrayModelBinder))] string[] studios,
- [FromQuery, ModelBinder(typeof(PipeDelimitedArrayModelBinder))] string[] artists,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] Guid[] excludeArtistIds,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] Guid[] artistIds,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] Guid[] albumArtistIds,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] Guid[] contributingArtistIds,
- [FromQuery, ModelBinder(typeof(PipeDelimitedArrayModelBinder))] string[] albums,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] Guid[] albumIds,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] Guid[] ids,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] VideoType[] videoTypes,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] Guid[] personIds,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] string[] personTypes,
+ [FromQuery, ModelBinder(typeof(PipeDelimitedCollectionModelBinder))] string[] studios,
+ [FromQuery, ModelBinder(typeof(PipeDelimitedCollectionModelBinder))] string[] artists,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] Guid[] excludeArtistIds,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] Guid[] artistIds,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] Guid[] albumArtistIds,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] Guid[] contributingArtistIds,
+ [FromQuery, ModelBinder(typeof(PipeDelimitedCollectionModelBinder))] string[] albums,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] Guid[] albumIds,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] Guid[] ids,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] VideoType[] videoTypes,
[FromQuery] string? minOfficialRating,
[FromQuery] bool? isLocked,
[FromQuery] bool? isPlaceHolder,
@@ -703,12 +705,12 @@ public class ItemsController : BaseJellyfinApiController
[FromQuery] int? maxWidth,
[FromQuery] int? maxHeight,
[FromQuery] bool? is3D,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] SeriesStatus[] seriesStatus,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] SeriesStatus[] seriesStatus,
[FromQuery] string? nameStartsWithOrGreater,
[FromQuery] string? nameStartsWith,
[FromQuery] string? nameLessThan,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] Guid[] studioIds,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] Guid[] genreIds,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] Guid[] studioIds,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] Guid[] genreIds,
[FromQuery] bool enableTotalRecordCount = true,
[FromQuery] bool? enableImages = true)
=> GetItems(
@@ -827,13 +829,13 @@ public class ItemsController : BaseJellyfinApiController
[FromQuery] int? limit,
[FromQuery] string? searchTerm,
[FromQuery] Guid? parentId,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ItemFields[] fields,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] MediaType[] mediaTypes,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ItemFields[] fields,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] MediaType[] mediaTypes,
[FromQuery] bool? enableUserData,
[FromQuery] int? imageTypeLimit,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ImageType[] enableImageTypes,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] BaseItemKind[] excludeItemTypes,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] BaseItemKind[] includeItemTypes,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ImageType[] enableImageTypes,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] BaseItemKind[] excludeItemTypes,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] BaseItemKind[] includeItemTypes,
[FromQuery] bool enableTotalRecordCount = true,
[FromQuery] bool? enableImages = true,
[FromQuery] bool excludeActiveSessions = false)
@@ -929,13 +931,13 @@ public class ItemsController : BaseJellyfinApiController
[FromQuery] int? limit,
[FromQuery] string? searchTerm,
[FromQuery] Guid? parentId,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ItemFields[] fields,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] MediaType[] mediaTypes,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ItemFields[] fields,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] MediaType[] mediaTypes,
[FromQuery] bool? enableUserData,
[FromQuery] int? imageTypeLimit,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ImageType[] enableImageTypes,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] BaseItemKind[] excludeItemTypes,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] BaseItemKind[] includeItemTypes,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ImageType[] enableImageTypes,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] BaseItemKind[] excludeItemTypes,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] BaseItemKind[] includeItemTypes,
[FromQuery] bool enableTotalRecordCount = true,
[FromQuery] bool? enableImages = true,
[FromQuery] bool excludeActiveSessions = false)
@@ -967,7 +969,7 @@ public class ItemsController : BaseJellyfinApiController
[HttpGet("UserItems/{itemId}/UserData")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
- public ActionResult GetItemUserData(
+ public ActionResult GetItemUserData(
[FromQuery] Guid? userId,
[FromRoute, Required] Guid itemId)
{
@@ -1005,7 +1007,7 @@ public class ItemsController : BaseJellyfinApiController
[ProducesResponseType(StatusCodes.Status404NotFound)]
[Obsolete("Kept for backwards compatibility")]
[ApiExplorerSettings(IgnoreApi = true)]
- public ActionResult GetItemUserDataLegacy(
+ public ActionResult GetItemUserDataLegacy(
[FromRoute, Required] Guid userId,
[FromRoute, Required] Guid itemId)
=> GetItemUserData(userId, itemId);
@@ -1022,7 +1024,7 @@ public class ItemsController : BaseJellyfinApiController
[HttpPost("UserItems/{itemId}/UserData")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
- public ActionResult UpdateItemUserData(
+ public ActionResult UpdateItemUserData(
[FromQuery] Guid? userId,
[FromRoute, Required] Guid itemId,
[FromBody, Required] UpdateUserItemDataDto userDataDto)
@@ -1064,7 +1066,7 @@ public class ItemsController : BaseJellyfinApiController
[ProducesResponseType(StatusCodes.Status404NotFound)]
[Obsolete("Kept for backwards compatibility")]
[ApiExplorerSettings(IgnoreApi = true)]
- public ActionResult UpdateItemUserDataLegacy(
+ public ActionResult UpdateItemUserDataLegacy(
[FromRoute, Required] Guid userId,
[FromRoute, Required] Guid itemId,
[FromBody, Required] UpdateUserItemDataDto userDataDto)
diff --git a/Jellyfin.Api/Controllers/LibraryController.cs b/Jellyfin.Api/Controllers/LibraryController.cs
index afc93c3a8d..bde1758e99 100644
--- a/Jellyfin.Api/Controllers/LibraryController.cs
+++ b/Jellyfin.Api/Controllers/LibraryController.cs
@@ -11,8 +11,9 @@ using Jellyfin.Api.Extensions;
using Jellyfin.Api.Helpers;
using Jellyfin.Api.ModelBinders;
using Jellyfin.Api.Models.LibraryDtos;
-using Jellyfin.Data.Entities;
using Jellyfin.Data.Enums;
+using Jellyfin.Database.Implementations.Entities;
+using Jellyfin.Database.Implementations.Enums;
using Jellyfin.Extensions;
using MediaBrowser.Common.Api;
using MediaBrowser.Common.Extensions;
@@ -144,8 +145,8 @@ public class LibraryController : BaseJellyfinApiController
[FromRoute, Required] Guid itemId,
[FromQuery] Guid? userId,
[FromQuery] bool inheritFromParent = false,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ItemSortBy[]? sortBy = null,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] SortOrder[]? sortOrder = null)
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ItemSortBy[]? sortBy = null,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] SortOrder[]? sortOrder = null)
{
userId = RequestHelpers.GetUserId(User, userId);
var user = userId.IsNullOrEmpty()
@@ -218,8 +219,8 @@ public class LibraryController : BaseJellyfinApiController
[FromRoute, Required] Guid itemId,
[FromQuery] Guid? userId,
[FromQuery] bool inheritFromParent = false,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ItemSortBy[]? sortBy = null,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] SortOrder[]? sortOrder = null)
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ItemSortBy[]? sortBy = null,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] SortOrder[]? sortOrder = null)
{
userId = RequestHelpers.GetUserId(User, userId);
var user = userId.IsNullOrEmpty()
@@ -290,8 +291,8 @@ public class LibraryController : BaseJellyfinApiController
[FromRoute, Required] Guid itemId,
[FromQuery] Guid? userId,
[FromQuery] bool inheritFromParent = false,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ItemSortBy[]? sortBy = null,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] SortOrder[]? sortOrder = null)
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ItemSortBy[]? sortBy = null,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] SortOrder[]? sortOrder = null)
{
var themeSongs = GetThemeSongs(
itemId,
@@ -400,7 +401,7 @@ public class LibraryController : BaseJellyfinApiController
[ProducesResponseType(StatusCodes.Status204NoContent)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
- public ActionResult DeleteItems([FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] Guid[] ids)
+ public ActionResult DeleteItems([FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] Guid[] ids)
{
var isApiKey = User.GetIsApiKey();
var userId = User.GetUserId();
@@ -722,10 +723,10 @@ public class LibraryController : BaseJellyfinApiController
[ProducesResponseType(StatusCodes.Status200OK)]
public ActionResult> GetSimilarItems(
[FromRoute, Required] Guid itemId,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] Guid[] excludeArtistIds,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] Guid[] excludeArtistIds,
[FromQuery] Guid? userId,
[FromQuery] int? limit,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ItemFields[] fields)
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ItemFields[] fields)
{
userId = RequestHelpers.GetUserId(User, userId);
var user = userId.IsNullOrEmpty()
@@ -780,11 +781,9 @@ public class LibraryController : BaseJellyfinApiController
Genres = item.Genres,
Limit = limit,
IncludeItemTypes = includeItemTypes.ToArray(),
- SimilarTo = item,
DtoOptions = dtoOptions,
EnableTotalRecordCount = !isMovie ?? true,
EnableGroupByMetadataKey = isMovie ?? false,
- MinSimilarityScore = 2 // A remnant from album/artist scoring
};
// ExcludeArtistIds
@@ -793,7 +792,7 @@ public class LibraryController : BaseJellyfinApiController
query.ExcludeArtistIds = excludeArtistIds;
}
- List itemsResult = _libraryManager.GetItemList(query);
+ var itemsResult = _libraryManager.GetItemList(query);
var returnList = _dtoService.GetBaseItemDtos(itemsResult, dtoOptions, user);
@@ -867,6 +866,16 @@ public class LibraryController : BaseJellyfinApiController
.DistinctBy(i => i.Name, StringComparer.OrdinalIgnoreCase)
.ToArray();
+ result.MediaSegmentProviders = plugins
+ .SelectMany(i => i.Plugins.Where(p => p.Type == MetadataPluginType.MediaSegmentProvider))
+ .Select(i => new LibraryOptionInfoDto
+ {
+ Name = i.Name,
+ DefaultEnabled = true
+ })
+ .DistinctBy(i => i.Name, StringComparer.OrdinalIgnoreCase)
+ .ToArray();
+
var typeOptions = new List();
foreach (var type in types)
diff --git a/Jellyfin.Api/Controllers/LibraryStructureController.cs b/Jellyfin.Api/Controllers/LibraryStructureController.cs
index 93c2393f33..2a885662b5 100644
--- a/Jellyfin.Api/Controllers/LibraryStructureController.cs
+++ b/Jellyfin.Api/Controllers/LibraryStructureController.cs
@@ -77,7 +77,7 @@ public class LibraryStructureController : BaseJellyfinApiController
public async Task AddVirtualFolder(
[FromQuery] string name,
[FromQuery] CollectionTypeOptions? collectionType,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] string[] paths,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] string[] paths,
[FromBody] AddVirtualFolderDto? libraryOptionsDto,
[FromQuery] bool refreshLibrary = false)
{
@@ -99,6 +99,7 @@ public class LibraryStructureController : BaseJellyfinApiController
/// The name of the folder.
/// Whether to refresh the library.
/// Folder removed.
+ /// Folder not found.
/// A .
[HttpDelete]
[ProducesResponseType(StatusCodes.Status204NoContent)]
@@ -106,7 +107,9 @@ public class LibraryStructureController : BaseJellyfinApiController
[FromQuery] string name,
[FromQuery] bool refreshLibrary = false)
{
+ // TODO: refactor! this relies on an FileNotFound exception to return NotFound when attempting to remove a library that does not exist.
await _libraryManager.RemoveVirtualFolder(name, refreshLibrary).ConfigureAwait(false);
+
return NoContent();
}
diff --git a/Jellyfin.Api/Controllers/LiveTvController.cs b/Jellyfin.Api/Controllers/LiveTvController.cs
index 0ae8baa671..10f1789ad8 100644
--- a/Jellyfin.Api/Controllers/LiveTvController.cs
+++ b/Jellyfin.Api/Controllers/LiveTvController.cs
@@ -15,6 +15,7 @@ using Jellyfin.Api.Helpers;
using Jellyfin.Api.ModelBinders;
using Jellyfin.Api.Models.LiveTvDtos;
using Jellyfin.Data.Enums;
+using Jellyfin.Database.Implementations.Enums;
using Jellyfin.Extensions;
using MediaBrowser.Common.Api;
using MediaBrowser.Common.Configuration;
@@ -159,10 +160,10 @@ public class LiveTvController : BaseJellyfinApiController
[FromQuery] bool? isDisliked,
[FromQuery] bool? enableImages,
[FromQuery] int? imageTypeLimit,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ImageType[] enableImageTypes,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ItemFields[] fields,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ImageType[] enableImageTypes,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ItemFields[] fields,
[FromQuery] bool? enableUserData,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ItemSortBy[] sortBy,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ItemSortBy[] sortBy,
[FromQuery] SortOrder? sortOrder,
[FromQuery] bool enableFavoriteSorting = false,
[FromQuery] bool addCurrentProgram = true)
@@ -283,8 +284,8 @@ public class LiveTvController : BaseJellyfinApiController
[FromQuery] string? seriesTimerId,
[FromQuery] bool? enableImages,
[FromQuery] int? imageTypeLimit,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ImageType[] enableImageTypes,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ItemFields[] fields,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ImageType[] enableImageTypes,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ItemFields[] fields,
[FromQuery] bool? enableUserData,
[FromQuery] bool? isMovie,
[FromQuery] bool? isSeries,
@@ -371,8 +372,8 @@ public class LiveTvController : BaseJellyfinApiController
[FromQuery] string? seriesTimerId,
[FromQuery] bool? enableImages,
[FromQuery] int? imageTypeLimit,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ImageType[] enableImageTypes,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ItemFields[] fields,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ImageType[] enableImageTypes,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ItemFields[] fields,
[FromQuery] bool? enableUserData,
[FromQuery] bool enableTotalRecordCount = true)
{
@@ -566,7 +567,7 @@ public class LiveTvController : BaseJellyfinApiController
[ProducesResponseType(StatusCodes.Status200OK)]
[Authorize(Policy = Policies.LiveTvAccess)]
public async Task>> GetLiveTvPrograms(
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] Guid[] channelIds,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] Guid[] channelIds,
[FromQuery] Guid? userId,
[FromQuery] DateTime? minStartDate,
[FromQuery] bool? hasAired,
@@ -581,17 +582,17 @@ public class LiveTvController : BaseJellyfinApiController
[FromQuery] bool? isSports,
[FromQuery] int? startIndex,
[FromQuery] int? limit,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ItemSortBy[] sortBy,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] SortOrder[] sortOrder,
- [FromQuery, ModelBinder(typeof(PipeDelimitedArrayModelBinder))] string[] genres,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] Guid[] genreIds,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ItemSortBy[] sortBy,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] SortOrder[] sortOrder,
+ [FromQuery, ModelBinder(typeof(PipeDelimitedCollectionModelBinder))] string[] genres,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] Guid[] genreIds,
[FromQuery] bool? enableImages,
[FromQuery] int? imageTypeLimit,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ImageType[] enableImageTypes,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ImageType[] enableImageTypes,
[FromQuery] bool? enableUserData,
[FromQuery] string? seriesTimerId,
[FromQuery] Guid? librarySeriesId,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ItemFields[] fields,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ItemFields[] fields,
[FromQuery] bool enableTotalRecordCount = true)
{
userId = RequestHelpers.GetUserId(User, userId);
@@ -698,6 +699,7 @@ public class LiveTvController : BaseJellyfinApiController
/// Gets recommended live tv epgs.
///
/// Optional. filter by user id.
+ /// Optional. The record index to start at. All items with a lower index will be dropped from the results.
/// Optional. The maximum number of records to return.
/// Optional. Filter by programs that are currently airing, or not.
/// Optional. Filter by programs that have completed airing, or not.
@@ -720,6 +722,7 @@ public class LiveTvController : BaseJellyfinApiController
[ProducesResponseType(StatusCodes.Status200OK)]
public async Task>> GetRecommendedPrograms(
[FromQuery] Guid? userId,
+ [FromQuery] int? startIndex,
[FromQuery] int? limit,
[FromQuery] bool? isAiring,
[FromQuery] bool? hasAired,
@@ -730,9 +733,9 @@ public class LiveTvController : BaseJellyfinApiController
[FromQuery] bool? isSports,
[FromQuery] bool? enableImages,
[FromQuery] int? imageTypeLimit,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ImageType[] enableImageTypes,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] Guid[] genreIds,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ItemFields[] fields,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ImageType[] enableImageTypes,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] Guid[] genreIds,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ItemFields[] fields,
[FromQuery] bool? enableUserData,
[FromQuery] bool enableTotalRecordCount = true)
{
@@ -744,6 +747,7 @@ public class LiveTvController : BaseJellyfinApiController
var query = new InternalItemsQuery(user)
{
IsAiring = isAiring,
+ StartIndex = startIndex,
Limit = limit,
HasAired = hasAired,
IsSeries = isSeries,
@@ -962,9 +966,9 @@ public class LiveTvController : BaseJellyfinApiController
}
///
- /// Get guid info.
+ /// Get guide info.
///
- /// Guid info returned.
+ /// Guide info returned.
/// An containing the guide info.
[HttpGet("GuideInfo")]
[Authorize(Policy = Policies.LiveTvAccess)]
@@ -1186,7 +1190,9 @@ public class LiveTvController : BaseJellyfinApiController
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
[ProducesVideoFile]
- public ActionResult GetLiveStreamFile([FromRoute, Required] string streamId, [FromRoute, Required] string container)
+ public ActionResult GetLiveStreamFile(
+ [FromRoute, Required] string streamId,
+ [FromRoute, Required] [RegularExpression(EncodingHelper.ContainerValidationRegex)] string container)
{
var liveStreamInfo = _mediaSourceManager.GetLiveStreamInfoByUniqueId(streamId);
if (liveStreamInfo is null)
diff --git a/Jellyfin.Api/Controllers/LocalizationController.cs b/Jellyfin.Api/Controllers/LocalizationController.cs
index f65d95c411..bbce5a9e13 100644
--- a/Jellyfin.Api/Controllers/LocalizationController.cs
+++ b/Jellyfin.Api/Controllers/LocalizationController.cs
@@ -1,5 +1,4 @@
using System.Collections.Generic;
-using Jellyfin.Api.Constants;
using MediaBrowser.Common.Api;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Globalization;
@@ -45,7 +44,7 @@ public class LocalizationController : BaseJellyfinApiController
/// An containing the list of countries.
[HttpGet("Countries")]
[ProducesResponseType(StatusCodes.Status200OK)]
- public ActionResult> GetCountries()
+ public ActionResult> GetCountries()
{
return Ok(_localization.GetCountries());
}
@@ -57,7 +56,7 @@ public class LocalizationController : BaseJellyfinApiController
/// An containing the list of parental ratings.
[HttpGet("ParentalRatings")]
[ProducesResponseType(StatusCodes.Status200OK)]
- public ActionResult> GetParentalRatings()
+ public ActionResult> GetParentalRatings()
{
return Ok(_localization.GetParentalRatings());
}
diff --git a/Jellyfin.Api/Controllers/MediaSegmentsController.cs b/Jellyfin.Api/Controllers/MediaSegmentsController.cs
index 3dc5167a2e..e30e2b54e4 100644
--- a/Jellyfin.Api/Controllers/MediaSegmentsController.cs
+++ b/Jellyfin.Api/Controllers/MediaSegmentsController.cs
@@ -4,7 +4,7 @@ using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Threading.Tasks;
using Jellyfin.Api.Extensions;
-using Jellyfin.Data.Enums;
+using Jellyfin.Database.Implementations.Enums;
using MediaBrowser.Controller;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library;
@@ -55,7 +55,7 @@ public class MediaSegmentsController : BaseJellyfinApiController
return NotFound();
}
- var items = await _mediaSegmentManager.GetSegmentsAsync(item.Id, includeSegmentTypes).ConfigureAwait(false);
+ var items = await _mediaSegmentManager.GetSegmentsAsync(item, includeSegmentTypes).ConfigureAwait(false);
return Ok(new QueryResult(items.ToArray()));
}
}
diff --git a/Jellyfin.Api/Controllers/MoviesController.cs b/Jellyfin.Api/Controllers/MoviesController.cs
index 471bcd096e..363acf815a 100644
--- a/Jellyfin.Api/Controllers/MoviesController.cs
+++ b/Jellyfin.Api/Controllers/MoviesController.cs
@@ -5,8 +5,9 @@ using System.Linq;
using Jellyfin.Api.Extensions;
using Jellyfin.Api.Helpers;
using Jellyfin.Api.ModelBinders;
-using Jellyfin.Data.Entities;
using Jellyfin.Data.Enums;
+using Jellyfin.Database.Implementations.Entities;
+using Jellyfin.Database.Implementations.Enums;
using Jellyfin.Extensions;
using MediaBrowser.Common.Extensions;
using MediaBrowser.Controller.Configuration;
@@ -65,7 +66,7 @@ public class MoviesController : BaseJellyfinApiController
public ActionResult> GetMovieRecommendations(
[FromQuery] Guid? userId,
[FromQuery] Guid? parentId,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ItemFields[] fields,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ItemFields[] fields,
[FromQuery] int categoryLimit = 5,
[FromQuery] int itemLimit = 8)
{
@@ -120,7 +121,7 @@ public class MoviesController : BaseJellyfinApiController
DtoOptions = dtoOptions
});
- var mostRecentMovies = recentlyPlayedMovies.GetRange(0, Math.Min(recentlyPlayedMovies.Count, 6));
+ var mostRecentMovies = recentlyPlayedMovies.Take(Math.Min(recentlyPlayedMovies.Count, 6)).ToList();
// Get recently played directors
var recentDirectors = GetDirectors(mostRecentMovies)
.ToList();
@@ -276,7 +277,6 @@ public class MoviesController : BaseJellyfinApiController
Limit = itemLimit,
IncludeItemTypes = itemTypes.ToArray(),
IsMovie = true,
- SimilarTo = item,
EnableGroupByMetadataKey = true,
DtoOptions = dtoOptions
});
diff --git a/Jellyfin.Api/Controllers/MusicGenresController.cs b/Jellyfin.Api/Controllers/MusicGenresController.cs
index 5411baa3e7..1e45e53ca1 100644
--- a/Jellyfin.Api/Controllers/MusicGenresController.cs
+++ b/Jellyfin.Api/Controllers/MusicGenresController.cs
@@ -4,8 +4,9 @@ using System.Linq;
using Jellyfin.Api.Extensions;
using Jellyfin.Api.Helpers;
using Jellyfin.Api.ModelBinders;
-using Jellyfin.Data.Entities;
using Jellyfin.Data.Enums;
+using Jellyfin.Database.Implementations.Entities;
+using Jellyfin.Database.Implementations.Enums;
using Jellyfin.Extensions;
using MediaBrowser.Controller.Dto;
using MediaBrowser.Controller.Entities;
@@ -76,18 +77,18 @@ public class MusicGenresController : BaseJellyfinApiController
[FromQuery] int? limit,
[FromQuery] string? searchTerm,
[FromQuery] Guid? parentId,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ItemFields[] fields,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] BaseItemKind[] excludeItemTypes,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] BaseItemKind[] includeItemTypes,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ItemFields[] fields,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] BaseItemKind[] excludeItemTypes,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] BaseItemKind[] includeItemTypes,
[FromQuery] bool? isFavorite,
[FromQuery] int? imageTypeLimit,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ImageType[] enableImageTypes,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ImageType[] enableImageTypes,
[FromQuery] Guid? userId,
[FromQuery] string? nameStartsWithOrGreater,
[FromQuery] string? nameStartsWith,
[FromQuery] string? nameLessThan,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ItemSortBy[] sortBy,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] SortOrder[] sortOrder,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ItemSortBy[] sortBy,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] SortOrder[] sortOrder,
[FromQuery] bool? enableImages = true,
[FromQuery] bool enableTotalRecordCount = true)
{
diff --git a/Jellyfin.Api/Controllers/PersonsController.cs b/Jellyfin.Api/Controllers/PersonsController.cs
index 6ca3086015..4d12dc18fc 100644
--- a/Jellyfin.Api/Controllers/PersonsController.cs
+++ b/Jellyfin.Api/Controllers/PersonsController.cs
@@ -4,7 +4,7 @@ using System.Linq;
using Jellyfin.Api.Extensions;
using Jellyfin.Api.Helpers;
using Jellyfin.Api.ModelBinders;
-using Jellyfin.Data.Entities;
+using Jellyfin.Database.Implementations.Entities;
using Jellyfin.Extensions;
using MediaBrowser.Controller.Dto;
using MediaBrowser.Controller.Entities;
@@ -67,14 +67,14 @@ public class PersonsController : BaseJellyfinApiController
public ActionResult> GetPersons(
[FromQuery] int? limit,
[FromQuery] string? searchTerm,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ItemFields[] fields,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ItemFilter[] filters,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ItemFields[] fields,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ItemFilter[] filters,
[FromQuery] bool? isFavorite,
[FromQuery] bool? enableUserData,
[FromQuery] int? imageTypeLimit,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ImageType[] enableImageTypes,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] string[] excludePersonTypes,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] string[] personTypes,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ImageType[] enableImageTypes,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] string[] excludePersonTypes,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] string[] personTypes,
[FromQuery] Guid? appearsInItemId,
[FromQuery] Guid? userId,
[FromQuery] bool? enableImages = true)
diff --git a/Jellyfin.Api/Controllers/PlaylistsController.cs b/Jellyfin.Api/Controllers/PlaylistsController.cs
index e6f23b1364..ec5fdab38e 100644
--- a/Jellyfin.Api/Controllers/PlaylistsController.cs
+++ b/Jellyfin.Api/Controllers/PlaylistsController.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
+using System.Globalization;
using System.Linq;
using System.Threading.Tasks;
using Jellyfin.Api.Attributes;
@@ -75,7 +76,7 @@ public class PlaylistsController : BaseJellyfinApiController
[ProducesResponseType(StatusCodes.Status200OK)]
public async Task> CreatePlaylist(
[FromQuery, ParameterObsolete] string? name,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder)), ParameterObsolete] IReadOnlyList ids,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder)), ParameterObsolete] IReadOnlyList ids,
[FromQuery, ParameterObsolete] Guid? userId,
[FromQuery, ParameterObsolete] MediaType? mediaType,
[FromBody(EmptyBodyBehavior = EmptyBodyBehavior.Allow)] CreatePlaylistDto? createPlaylistRequest)
@@ -369,7 +370,7 @@ public class PlaylistsController : BaseJellyfinApiController
[ProducesResponseType(StatusCodes.Status404NotFound)]
public async Task AddItemToPlaylist(
[FromRoute, Required] Guid playlistId,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] Guid[] ids,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] Guid[] ids,
[FromQuery] Guid? userId)
{
userId = RequestHelpers.GetUserId(User, userId);
@@ -426,7 +427,7 @@ public class PlaylistsController : BaseJellyfinApiController
return Forbid();
}
- await _playlistManager.MoveItemAsync(playlistId, itemId, newIndex).ConfigureAwait(false);
+ await _playlistManager.MoveItemAsync(playlistId, itemId, newIndex, callingUserId).ConfigureAwait(false);
return NoContent();
}
@@ -445,7 +446,7 @@ public class PlaylistsController : BaseJellyfinApiController
[ProducesResponseType(StatusCodes.Status404NotFound)]
public async Task RemoveItemFromPlaylist(
[FromRoute, Required] string playlistId,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] string[] entryIds)
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] string[] entryIds)
{
var callingUserId = User.GetUserId();
@@ -492,11 +493,11 @@ public class PlaylistsController : BaseJellyfinApiController
[FromQuery] Guid? userId,
[FromQuery] int? startIndex,
[FromQuery] int? limit,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ItemFields[] fields,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ItemFields[] fields,
[FromQuery] bool? enableImages,
[FromQuery] bool? enableUserData,
[FromQuery] int? imageTypeLimit,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ImageType[] enableImageTypes)
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ImageType[] enableImageTypes)
{
var callingUserId = userId ?? User.GetUserId();
var playlist = _playlistManager.GetPlaylistForUser(playlistId, callingUserId);
@@ -514,7 +515,8 @@ public class PlaylistsController : BaseJellyfinApiController
return Forbid();
}
- var items = playlist.GetManageableItems().ToArray();
+ var user = _userManager.GetUserById(callingUserId);
+ var items = playlist.GetManageableItems().Where(i => i.Item2.IsVisible(user)).ToArray();
var count = items.Length;
if (startIndex.HasValue)
{
@@ -529,11 +531,11 @@ public class PlaylistsController : BaseJellyfinApiController
var dtoOptions = new DtoOptions { Fields = fields }
.AddClientFields(User)
.AddAdditionalDtoOptions(enableImages, enableUserData, imageTypeLimit, enableImageTypes);
- var user = _userManager.GetUserById(callingUserId);
+
var dtos = _dtoService.GetBaseItemDtos(items.Select(i => i.Item2).ToList(), dtoOptions, user);
for (int index = 0; index < dtos.Count; index++)
{
- dtos[index].PlaylistItemId = items[index].Item1.Id;
+ dtos[index].PlaylistItemId = items[index].Item1.ItemId?.ToString("N", CultureInfo.InvariantCulture);
}
var result = new QueryResult(
diff --git a/Jellyfin.Api/Controllers/PlaystateController.cs b/Jellyfin.Api/Controllers/PlaystateController.cs
index 88aa0178f9..1577b45947 100644
--- a/Jellyfin.Api/Controllers/PlaystateController.cs
+++ b/Jellyfin.Api/Controllers/PlaystateController.cs
@@ -5,7 +5,7 @@ using System.Threading.Tasks;
using Jellyfin.Api.Extensions;
using Jellyfin.Api.Helpers;
using Jellyfin.Api.ModelBinders;
-using Jellyfin.Data.Entities;
+using Jellyfin.Database.Implementations.Entities;
using Jellyfin.Extensions;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library;
@@ -72,7 +72,7 @@ public class PlaystateController : BaseJellyfinApiController
[HttpPost("UserPlayedItems/{itemId}")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
- public async Task> MarkPlayedItem(
+ public async Task> MarkPlayedItem(
[FromQuery] Guid? userId,
[FromRoute, Required] Guid itemId,
[FromQuery, ModelBinder(typeof(LegacyDateTimeModelBinder))] DateTime? datePlayed)
@@ -121,7 +121,7 @@ public class PlaystateController : BaseJellyfinApiController
[ProducesResponseType(StatusCodes.Status404NotFound)]
[Obsolete("Kept for backwards compatibility")]
[ApiExplorerSettings(IgnoreApi = true)]
- public Task> MarkPlayedItemLegacy(
+ public Task> MarkPlayedItemLegacy(
[FromRoute, Required] Guid userId,
[FromRoute, Required] Guid itemId,
[FromQuery, ModelBinder(typeof(LegacyDateTimeModelBinder))] DateTime? datePlayed)
@@ -138,7 +138,7 @@ public class PlaystateController : BaseJellyfinApiController
[HttpDelete("UserPlayedItems/{itemId}")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
- public async Task> MarkUnplayedItem(
+ public async Task> MarkUnplayedItem(
[FromQuery] Guid? userId,
[FromRoute, Required] Guid itemId)
{
@@ -185,7 +185,7 @@ public class PlaystateController : BaseJellyfinApiController
[ProducesResponseType(StatusCodes.Status404NotFound)]
[Obsolete("Kept for backwards compatibility")]
[ApiExplorerSettings(IgnoreApi = true)]
- public Task> MarkUnplayedItemLegacy(
+ public Task> MarkUnplayedItemLegacy(
[FromRoute, Required] Guid userId,
[FromRoute, Required] Guid itemId)
=> MarkUnplayedItem(userId, itemId);
@@ -502,7 +502,7 @@ public class PlaystateController : BaseJellyfinApiController
/// if set to true [was played].
/// The date played.
/// Task.
- private UserItemDataDto UpdatePlayedStatus(User user, BaseItem item, bool wasPlayed, DateTime? datePlayed)
+ private UserItemDataDto? UpdatePlayedStatus(User user, BaseItem item, bool wasPlayed, DateTime? datePlayed)
{
if (wasPlayed)
{
diff --git a/Jellyfin.Api/Controllers/SearchController.cs b/Jellyfin.Api/Controllers/SearchController.cs
index 8bae6fb9b6..ecf2335ba0 100644
--- a/Jellyfin.Api/Controllers/SearchController.cs
+++ b/Jellyfin.Api/Controllers/SearchController.cs
@@ -84,9 +84,9 @@ public class SearchController : BaseJellyfinApiController
[FromQuery] int? limit,
[FromQuery] Guid? userId,
[FromQuery, Required] string searchTerm,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] BaseItemKind[] includeItemTypes,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] BaseItemKind[] excludeItemTypes,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] MediaType[] mediaTypes,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] BaseItemKind[] includeItemTypes,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] BaseItemKind[] excludeItemTypes,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] MediaType[] mediaTypes,
[FromQuery] Guid? parentId,
[FromQuery] bool? isMovie,
[FromQuery] bool? isSeries,
diff --git a/Jellyfin.Api/Controllers/SessionController.cs b/Jellyfin.Api/Controllers/SessionController.cs
index 2f9e9f091d..9886d03dee 100644
--- a/Jellyfin.Api/Controllers/SessionController.cs
+++ b/Jellyfin.Api/Controllers/SessionController.cs
@@ -122,7 +122,7 @@ public class SessionController : BaseJellyfinApiController
public async Task Play(
[FromRoute, Required] string sessionId,
[FromQuery, Required] PlayCommand playCommand,
- [FromQuery, Required, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] Guid[] itemIds,
+ [FromQuery, Required, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] Guid[] itemIds,
[FromQuery] long? startPositionTicks,
[FromQuery] string? mediaSourceId,
[FromQuery] int? audioStreamIndex,
@@ -347,8 +347,8 @@ public class SessionController : BaseJellyfinApiController
[ProducesResponseType(StatusCodes.Status204NoContent)]
public async Task PostCapabilities(
[FromQuery] string? id,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] MediaType[] playableMediaTypes,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] GeneralCommandType[] supportedCommands,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] MediaType[] playableMediaTypes,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] GeneralCommandType[] supportedCommands,
[FromQuery] bool supportsMediaControl = false,
[FromQuery] bool supportsPersistentIdentifier = true)
{
diff --git a/Jellyfin.Api/Controllers/StartupController.cs b/Jellyfin.Api/Controllers/StartupController.cs
index 41b0858d19..09f20558fe 100644
--- a/Jellyfin.Api/Controllers/StartupController.cs
+++ b/Jellyfin.Api/Controllers/StartupController.cs
@@ -58,6 +58,7 @@ public class StartupController : BaseJellyfinApiController
{
return new StartupConfigurationDto
{
+ ServerName = _config.Configuration.ServerName,
UICulture = _config.Configuration.UICulture,
MetadataCountryCode = _config.Configuration.MetadataCountryCode,
PreferredMetadataLanguage = _config.Configuration.PreferredMetadataLanguage
@@ -74,6 +75,7 @@ public class StartupController : BaseJellyfinApiController
[ProducesResponseType(StatusCodes.Status204NoContent)]
public ActionResult UpdateInitialConfiguration([FromBody, Required] StartupConfigurationDto startupConfiguration)
{
+ _config.Configuration.ServerName = startupConfiguration.ServerName ?? string.Empty;
_config.Configuration.UICulture = startupConfiguration.UICulture ?? string.Empty;
_config.Configuration.MetadataCountryCode = startupConfiguration.MetadataCountryCode ?? string.Empty;
_config.Configuration.PreferredMetadataLanguage = startupConfiguration.PreferredMetadataLanguage ?? string.Empty;
@@ -93,7 +95,6 @@ public class StartupController : BaseJellyfinApiController
{
NetworkConfiguration settings = _config.GetNetworkConfiguration();
settings.EnableRemoteAccess = startupRemoteAccessDto.EnableRemoteAccess;
- settings.EnableUPnP = startupRemoteAccessDto.EnableAutomaticPortMapping;
_config.SaveConfiguration(NetworkConfigurationStore.StoreKey, settings);
return NoContent();
}
@@ -113,8 +114,7 @@ public class StartupController : BaseJellyfinApiController
var user = _userManager.Users.First();
return new StartupUserDto
{
- Name = user.Username,
- Password = user.Password
+ Name = user.Username
};
}
diff --git a/Jellyfin.Api/Controllers/StudiosController.cs b/Jellyfin.Api/Controllers/StudiosController.cs
index 708fc7436f..52cb87e72c 100644
--- a/Jellyfin.Api/Controllers/StudiosController.cs
+++ b/Jellyfin.Api/Controllers/StudiosController.cs
@@ -3,8 +3,8 @@ using System.ComponentModel.DataAnnotations;
using Jellyfin.Api.Extensions;
using Jellyfin.Api.Helpers;
using Jellyfin.Api.ModelBinders;
-using Jellyfin.Data.Entities;
using Jellyfin.Data.Enums;
+using Jellyfin.Database.Implementations.Entities;
using Jellyfin.Extensions;
using MediaBrowser.Controller.Dto;
using MediaBrowser.Controller.Entities;
@@ -73,13 +73,13 @@ public class StudiosController : BaseJellyfinApiController
[FromQuery] int? limit,
[FromQuery] string? searchTerm,
[FromQuery] Guid? parentId,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ItemFields[] fields,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] BaseItemKind[] excludeItemTypes,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] BaseItemKind[] includeItemTypes,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ItemFields[] fields,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] BaseItemKind[] excludeItemTypes,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] BaseItemKind[] includeItemTypes,
[FromQuery] bool? isFavorite,
[FromQuery] bool? enableUserData,
[FromQuery] int? imageTypeLimit,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ImageType[] enableImageTypes,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ImageType[] enableImageTypes,
[FromQuery] Guid? userId,
[FromQuery] string? nameStartsWithOrGreater,
[FromQuery] string? nameStartsWith,
diff --git a/Jellyfin.Api/Controllers/SubtitleController.cs b/Jellyfin.Api/Controllers/SubtitleController.cs
index 9da1dce93e..e5df873f5b 100644
--- a/Jellyfin.Api/Controllers/SubtitleController.cs
+++ b/Jellyfin.Api/Controllers/SubtitleController.cs
@@ -395,7 +395,7 @@ public class SubtitleController : BaseJellyfinApiController
var url = string.Format(
CultureInfo.InvariantCulture,
- "stream.vtt?CopyTimestamps=true&AddVttTimeMap=true&StartPositionTicks={0}&EndPositionTicks={1}&api_key={2}",
+ "stream.vtt?CopyTimestamps=true&AddVttTimeMap=true&StartPositionTicks={0}&EndPositionTicks={1}&ApiKey={2}",
positionTicks.ToString(CultureInfo.InvariantCulture),
endPositionTicks.ToString(CultureInfo.InvariantCulture),
accessToken);
diff --git a/Jellyfin.Api/Controllers/SuggestionsController.cs b/Jellyfin.Api/Controllers/SuggestionsController.cs
index ad625cc6e0..52982c362d 100644
--- a/Jellyfin.Api/Controllers/SuggestionsController.cs
+++ b/Jellyfin.Api/Controllers/SuggestionsController.cs
@@ -3,8 +3,9 @@ using System.ComponentModel.DataAnnotations;
using Jellyfin.Api.Extensions;
using Jellyfin.Api.Helpers;
using Jellyfin.Api.ModelBinders;
-using Jellyfin.Data.Entities;
using Jellyfin.Data.Enums;
+using Jellyfin.Database.Implementations.Entities;
+using Jellyfin.Database.Implementations.Enums;
using Jellyfin.Extensions;
using MediaBrowser.Controller.Dto;
using MediaBrowser.Controller.Entities;
@@ -59,8 +60,8 @@ public class SuggestionsController : BaseJellyfinApiController
[ProducesResponseType(StatusCodes.Status200OK)]
public ActionResult> GetSuggestions(
[FromQuery] Guid? userId,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] MediaType[] mediaType,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] BaseItemKind[] type,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] MediaType[] mediaType,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] BaseItemKind[] type,
[FromQuery] int? startIndex,
[FromQuery] int? limit,
[FromQuery] bool enableTotalRecordCount = false)
@@ -115,8 +116,8 @@ public class SuggestionsController : BaseJellyfinApiController
[ApiExplorerSettings(IgnoreApi = true)]
public ActionResult> GetSuggestionsLegacy(
[FromRoute, Required] Guid userId,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] MediaType[] mediaType,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] BaseItemKind[] type,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] MediaType[] mediaType,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] BaseItemKind[] type,
[FromQuery] int? startIndex,
[FromQuery] int? limit,
[FromQuery] bool enableTotalRecordCount = false)
diff --git a/Jellyfin.Api/Controllers/SyncPlayController.cs b/Jellyfin.Api/Controllers/SyncPlayController.cs
index 3839781971..fbab2a7845 100644
--- a/Jellyfin.Api/Controllers/SyncPlayController.cs
+++ b/Jellyfin.Api/Controllers/SyncPlayController.cs
@@ -1,9 +1,9 @@
+using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
-using Jellyfin.Api.Constants;
using Jellyfin.Api.Helpers;
using Jellyfin.Api.Models.SyncPlayDtos;
using MediaBrowser.Common.Api;
@@ -50,17 +50,16 @@ public class SyncPlayController : BaseJellyfinApiController
///
/// The settings of the new group.
/// New group created.
- /// A indicating success.
+ /// An for the created group.
[HttpPost("New")]
- [ProducesResponseType(StatusCodes.Status204NoContent)]
+ [ProducesResponseType(StatusCodes.Status200OK)]
[Authorize(Policy = Policies.SyncPlayCreateGroup)]
- public async Task SyncPlayCreateGroup(
+ public async Task> SyncPlayCreateGroup(
[FromBody, Required] NewGroupRequestDto requestData)
{
var currentSession = await RequestHelpers.GetSession(_sessionManager, _userManager, HttpContext).ConfigureAwait(false);
var syncPlayRequest = new NewGroupRequest(requestData.GroupName);
- _syncPlayManager.NewGroup(currentSession, syncPlayRequest, CancellationToken.None);
- return NoContent();
+ return Ok(_syncPlayManager.NewGroup(currentSession, syncPlayRequest, CancellationToken.None));
}
///
@@ -112,6 +111,23 @@ public class SyncPlayController : BaseJellyfinApiController
return Ok(_syncPlayManager.ListGroups(currentSession, syncPlayRequest).AsEnumerable());
}
+ ///
+ /// Gets a SyncPlay group by id.
+ ///
+ /// The id of the group.
+ /// Group returned.
+ /// An for the requested group.
+ [HttpGet("{id:guid}")]
+ [ProducesResponseType(StatusCodes.Status200OK)]
+ [ProducesResponseType(StatusCodes.Status404NotFound)]
+ [Authorize(Policy = Policies.SyncPlayJoinGroup)]
+ public async Task> SyncPlayGetGroup([FromRoute] Guid id)
+ {
+ var currentSession = await RequestHelpers.GetSession(_sessionManager, _userManager, HttpContext).ConfigureAwait(false);
+ var group = _syncPlayManager.GetGroup(currentSession, id);
+ return group == null ? NotFound() : Ok(group);
+ }
+
///
/// Request to set new playlist in SyncPlay group.
///
diff --git a/Jellyfin.Api/Controllers/SystemController.cs b/Jellyfin.Api/Controllers/SystemController.cs
index 6c5ce47158..07a1f76503 100644
--- a/Jellyfin.Api/Controllers/SystemController.cs
+++ b/Jellyfin.Api/Controllers/SystemController.cs
@@ -6,6 +6,7 @@ using System.Linq;
using System.Net.Mime;
using Jellyfin.Api.Attributes;
using Jellyfin.Api.Constants;
+using Jellyfin.Api.Models.SystemInfoDtos;
using MediaBrowser.Common.Api;
using MediaBrowser.Common.Configuration;
using MediaBrowser.Common.Extensions;
@@ -71,6 +72,19 @@ public class SystemController : BaseJellyfinApiController
public ActionResult GetSystemInfo()
=> _systemManager.GetSystemInfo(Request);
+ ///
+ /// Gets information about the server.
+ ///
+ /// Information retrieved.
+ /// User does not have permission to retrieve information.
+ /// A with info about the system.
+ [HttpGet("Info/Storage")]
+ [Authorize(Policy = Policies.RequiresElevation)]
+ [ProducesResponseType(StatusCodes.Status200OK)]
+ [ProducesResponseType(StatusCodes.Status403Forbidden)]
+ public ActionResult GetSystemStorage()
+ => Ok(SystemStorageDto.FromSystemStorageInfo(_systemManager.GetSystemStorageInfo()));
+
///
/// Gets public information about the server.
///
@@ -212,20 +226,4 @@ public class SystemController : BaseJellyfinApiController
FileStream stream = new FileStream(file.FullName, FileMode.Open, FileAccess.Read, fileShare, IODefaults.FileStreamBufferSize, FileOptions.Asynchronous);
return File(stream, "text/plain; charset=utf-8");
}
-
- ///
- /// Gets wake on lan information.
- ///
- /// Information retrieved.
- /// An with the WakeOnLan infos.
- [HttpGet("WakeOnLanInfo")]
- [Authorize]
- [Obsolete("This endpoint is obsolete.")]
- [ProducesResponseType(StatusCodes.Status200OK)]
- public ActionResult> GetWakeOnLanInfo()
- {
- var result = _networkManager.GetMacAddresses()
- .Select(i => new WakeOnLanInfo(i));
- return Ok(result);
- }
}
diff --git a/Jellyfin.Api/Controllers/TrailersController.cs b/Jellyfin.Api/Controllers/TrailersController.cs
index d7d0cc4544..3e4bac89a5 100644
--- a/Jellyfin.Api/Controllers/TrailersController.cs
+++ b/Jellyfin.Api/Controllers/TrailersController.cs
@@ -1,6 +1,7 @@
using System;
using Jellyfin.Api.ModelBinders;
using Jellyfin.Data.Enums;
+using Jellyfin.Database.Implementations.Enums;
using MediaBrowser.Model.Dto;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Querying;
@@ -130,8 +131,8 @@ public class TrailersController : BaseJellyfinApiController
[FromQuery] bool? hasParentalRating,
[FromQuery] bool? isHd,
[FromQuery] bool? is4K,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] LocationType[] locationTypes,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] LocationType[] excludeLocationTypes,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] LocationType[] locationTypes,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] LocationType[] excludeLocationTypes,
[FromQuery] bool? isMissing,
[FromQuery] bool? isUnaired,
[FromQuery] double? minCommunityRating,
@@ -149,41 +150,41 @@ public class TrailersController : BaseJellyfinApiController
[FromQuery] bool? isNews,
[FromQuery] bool? isKids,
[FromQuery] bool? isSports,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] Guid[] excludeItemIds,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] Guid[] excludeItemIds,
[FromQuery] int? startIndex,
[FromQuery] int? limit,
[FromQuery] bool? recursive,
[FromQuery] string? searchTerm,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] SortOrder[] sortOrder,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] SortOrder[] sortOrder,
[FromQuery] Guid? parentId,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ItemFields[] fields,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] BaseItemKind[] excludeItemTypes,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ItemFilter[] filters,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ItemFields[] fields,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] BaseItemKind[] excludeItemTypes,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ItemFilter[] filters,
[FromQuery] bool? isFavorite,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] MediaType[] mediaTypes,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ImageType[] imageTypes,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ItemSortBy[] sortBy,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] MediaType[] mediaTypes,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ImageType[] imageTypes,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ItemSortBy[] sortBy,
[FromQuery] bool? isPlayed,
- [FromQuery, ModelBinder(typeof(PipeDelimitedArrayModelBinder))] string[] genres,
- [FromQuery, ModelBinder(typeof(PipeDelimitedArrayModelBinder))] string[] officialRatings,
- [FromQuery, ModelBinder(typeof(PipeDelimitedArrayModelBinder))] string[] tags,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] int[] years,
+ [FromQuery, ModelBinder(typeof(PipeDelimitedCollectionModelBinder))] string[] genres,
+ [FromQuery, ModelBinder(typeof(PipeDelimitedCollectionModelBinder))] string[] officialRatings,
+ [FromQuery, ModelBinder(typeof(PipeDelimitedCollectionModelBinder))] string[] tags,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] int[] years,
[FromQuery] bool? enableUserData,
[FromQuery] int? imageTypeLimit,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ImageType[] enableImageTypes,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ImageType[] enableImageTypes,
[FromQuery] string? person,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] Guid[] personIds,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] string[] personTypes,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] string[] studios,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] string[] artists,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] Guid[] excludeArtistIds,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] Guid[] artistIds,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] Guid[] albumArtistIds,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] Guid[] contributingArtistIds,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] string[] albums,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] Guid[] albumIds,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] Guid[] ids,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] VideoType[] videoTypes,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] Guid[] personIds,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] string[] personTypes,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] string[] studios,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] string[] artists,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] Guid[] excludeArtistIds,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] Guid[] artistIds,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] Guid[] albumArtistIds,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] Guid[] contributingArtistIds,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] string[] albums,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] Guid[] albumIds,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] Guid[] ids,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] VideoType[] videoTypes,
[FromQuery] string? minOfficialRating,
[FromQuery] bool? isLocked,
[FromQuery] bool? isPlaceHolder,
@@ -194,12 +195,12 @@ public class TrailersController : BaseJellyfinApiController
[FromQuery] int? maxWidth,
[FromQuery] int? maxHeight,
[FromQuery] bool? is3D,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] SeriesStatus[] seriesStatus,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] SeriesStatus[] seriesStatus,
[FromQuery] string? nameStartsWithOrGreater,
[FromQuery] string? nameStartsWith,
[FromQuery] string? nameLessThan,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] Guid[] studioIds,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] Guid[] genreIds,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] Guid[] studioIds,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] Guid[] genreIds,
[FromQuery] bool enableTotalRecordCount = true,
[FromQuery] bool? enableImages = true)
{
diff --git a/Jellyfin.Api/Controllers/TvShowsController.cs b/Jellyfin.Api/Controllers/TvShowsController.cs
index 914ccd7f93..0f08854d24 100644
--- a/Jellyfin.Api/Controllers/TvShowsController.cs
+++ b/Jellyfin.Api/Controllers/TvShowsController.cs
@@ -2,10 +2,12 @@ using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
+using Jellyfin.Api.Attributes;
using Jellyfin.Api.Extensions;
using Jellyfin.Api.Helpers;
using Jellyfin.Api.ModelBinders;
using Jellyfin.Data.Enums;
+using Jellyfin.Database.Implementations.Enums;
using Jellyfin.Extensions;
using MediaBrowser.Controller.Dto;
using MediaBrowser.Controller.Entities;
@@ -77,16 +79,16 @@ public class TvShowsController : BaseJellyfinApiController
[FromQuery] Guid? userId,
[FromQuery] int? startIndex,
[FromQuery] int? limit,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ItemFields[] fields,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ItemFields[] fields,
[FromQuery] Guid? seriesId,
[FromQuery] Guid? parentId,
[FromQuery] bool? enableImages,
[FromQuery] int? imageTypeLimit,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ImageType[] enableImageTypes,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ImageType[] enableImageTypes,
[FromQuery] bool? enableUserData,
[FromQuery] DateTime? nextUpDateCutoff,
[FromQuery] bool enableTotalRecordCount = true,
- [FromQuery] bool disableFirstEpisode = false,
+ [FromQuery][ParameterObsolete] bool disableFirstEpisode = false,
[FromQuery] bool enableResumable = true,
[FromQuery] bool enableRewatching = false)
{
@@ -109,7 +111,6 @@ public class TvShowsController : BaseJellyfinApiController
StartIndex = startIndex,
User = user,
EnableTotalRecordCount = enableTotalRecordCount,
- DisableFirstEpisode = disableFirstEpisode,
NextUpDateCutoff = nextUpDateCutoff ?? DateTime.MinValue,
EnableResumable = enableResumable,
EnableRewatching = enableRewatching
@@ -143,11 +144,11 @@ public class TvShowsController : BaseJellyfinApiController
[FromQuery] Guid? userId,
[FromQuery] int? startIndex,
[FromQuery] int? limit,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ItemFields[] fields,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ItemFields[] fields,
[FromQuery] Guid? parentId,
[FromQuery] bool? enableImages,
[FromQuery] int? imageTypeLimit,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ImageType[] enableImageTypes,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ImageType[] enableImageTypes,
[FromQuery] bool? enableUserData)
{
userId = RequestHelpers.GetUserId(User, userId);
@@ -208,7 +209,7 @@ public class TvShowsController : BaseJellyfinApiController
public ActionResult> GetEpisodes(
[FromRoute, Required] Guid seriesId,
[FromQuery] Guid? userId,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ItemFields[] fields,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ItemFields[] fields,
[FromQuery] int? season,
[FromQuery] Guid? seasonId,
[FromQuery] bool? isMissing,
@@ -218,7 +219,7 @@ public class TvShowsController : BaseJellyfinApiController
[FromQuery] int? limit,
[FromQuery] bool? enableImages,
[FromQuery] int? imageTypeLimit,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ImageType[] enableImageTypes,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ImageType[] enableImageTypes,
[FromQuery] bool? enableUserData,
[FromQuery] ItemSortBy? sortBy)
{
@@ -332,13 +333,13 @@ public class TvShowsController : BaseJellyfinApiController
public ActionResult> GetSeasons(
[FromRoute, Required] Guid seriesId,
[FromQuery] Guid? userId,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ItemFields[] fields,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ItemFields[] fields,
[FromQuery] bool? isSpecialSeason,
[FromQuery] bool? isMissing,
[FromQuery] Guid? adjacentTo,
[FromQuery] bool? enableImages,
[FromQuery] int? imageTypeLimit,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ImageType[] enableImageTypes,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ImageType[] enableImageTypes,
[FromQuery] bool? enableUserData)
{
userId = RequestHelpers.GetUserId(User, userId);
diff --git a/Jellyfin.Api/Controllers/UniversalAudioController.cs b/Jellyfin.Api/Controllers/UniversalAudioController.cs
index 41c4886d4f..fd63347030 100644
--- a/Jellyfin.Api/Controllers/UniversalAudioController.cs
+++ b/Jellyfin.Api/Controllers/UniversalAudioController.cs
@@ -98,17 +98,17 @@ public class UniversalAudioController : BaseJellyfinApiController
[ProducesAudioFile]
public async Task GetUniversalAudioStream(
[FromRoute, Required] Guid itemId,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] string[] container,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] string[] container,
[FromQuery] string? mediaSourceId,
[FromQuery] string? deviceId,
[FromQuery] Guid? userId,
- [FromQuery] [RegularExpression(EncodingHelper.ValidationRegex)] string? audioCodec,
+ [FromQuery] [RegularExpression(EncodingHelper.ContainerValidationRegex)] string? audioCodec,
[FromQuery] int? maxAudioChannels,
[FromQuery] int? transcodingAudioChannels,
[FromQuery] int? maxStreamingBitrate,
[FromQuery] int? audioBitRate,
[FromQuery] long? startTimeTicks,
- [FromQuery] [RegularExpression(EncodingHelper.ValidationRegex)] string? transcodingContainer,
+ [FromQuery] [RegularExpression(EncodingHelper.ContainerValidationRegex)] string? transcodingContainer,
[FromQuery] MediaStreamProtocol? transcodingProtocol,
[FromQuery] int? maxAudioSampleRate,
[FromQuery] int? maxAudioBitDepth,
@@ -222,7 +222,7 @@ public class UniversalAudioController : BaseJellyfinApiController
TranscodeReasons = mediaSource.TranscodeReasons == 0 ? null : mediaSource.TranscodeReasons.ToString(),
Context = EncodingContext.Static,
StreamOptions = new Dictionary(),
- EnableAdaptiveBitrateStreaming = true,
+ EnableAdaptiveBitrateStreaming = false,
EnableAudioVbrEncoding = enableAudioVbrEncoding
};
diff --git a/Jellyfin.Api/Controllers/UserController.cs b/Jellyfin.Api/Controllers/UserController.cs
index d7886d247f..d0ced277a0 100644
--- a/Jellyfin.Api/Controllers/UserController.cs
+++ b/Jellyfin.Api/Controllers/UserController.cs
@@ -7,7 +7,8 @@ using Jellyfin.Api.Constants;
using Jellyfin.Api.Extensions;
using Jellyfin.Api.Helpers;
using Jellyfin.Api.Models.UserDtos;
-using Jellyfin.Data.Enums;
+using Jellyfin.Data;
+using Jellyfin.Database.Implementations.Enums;
using Jellyfin.Extensions;
using MediaBrowser.Common.Api;
using MediaBrowser.Common.Extensions;
diff --git a/Jellyfin.Api/Controllers/UserLibraryController.cs b/Jellyfin.Api/Controllers/UserLibraryController.cs
index e7bf717274..0e04beb14e 100644
--- a/Jellyfin.Api/Controllers/UserLibraryController.cs
+++ b/Jellyfin.Api/Controllers/UserLibraryController.cs
@@ -7,8 +7,8 @@ using System.Threading.Tasks;
using Jellyfin.Api.Extensions;
using Jellyfin.Api.Helpers;
using Jellyfin.Api.ModelBinders;
-using Jellyfin.Data.Entities;
using Jellyfin.Data.Enums;
+using Jellyfin.Database.Implementations.Entities;
using Jellyfin.Extensions;
using MediaBrowser.Controller.Dto;
using MediaBrowser.Controller.Entities;
@@ -305,7 +305,7 @@ public class UserLibraryController : BaseJellyfinApiController
/// An containing the .
[HttpDelete("UserItems/{itemId}/Rating")]
[ProducesResponseType(StatusCodes.Status200OK)]
- public ActionResult DeleteUserItemRating(
+ public ActionResult DeleteUserItemRating(
[FromQuery] Guid? userId,
[FromRoute, Required] Guid itemId)
{
@@ -338,7 +338,7 @@ public class UserLibraryController : BaseJellyfinApiController
[ProducesResponseType(StatusCodes.Status200OK)]
[Obsolete("Kept for backwards compatibility")]
[ApiExplorerSettings(IgnoreApi = true)]
- public ActionResult DeleteUserItemRatingLegacy(
+ public ActionResult DeleteUserItemRatingLegacy(
[FromRoute, Required] Guid userId,
[FromRoute, Required] Guid itemId)
=> DeleteUserItemRating(userId, itemId);
@@ -353,7 +353,7 @@ public class UserLibraryController : BaseJellyfinApiController
/// An containing the .
[HttpPost("UserItems/{itemId}/Rating")]
[ProducesResponseType(StatusCodes.Status200OK)]
- public ActionResult UpdateUserItemRating(
+ public ActionResult UpdateUserItemRating(
[FromQuery] Guid? userId,
[FromRoute, Required] Guid itemId,
[FromQuery] bool? likes)
@@ -388,7 +388,7 @@ public class UserLibraryController : BaseJellyfinApiController
[ProducesResponseType(StatusCodes.Status200OK)]
[Obsolete("Kept for backwards compatibility")]
[ApiExplorerSettings(IgnoreApi = true)]
- public ActionResult UpdateUserItemRatingLegacy(
+ public ActionResult UpdateUserItemRatingLegacy(
[FromRoute, Required] Guid userId,
[FromRoute, Required] Guid itemId,
[FromQuery] bool? likes)
@@ -523,12 +523,12 @@ public class UserLibraryController : BaseJellyfinApiController
public ActionResult> GetLatestMedia(
[FromQuery] Guid? userId,
[FromQuery] Guid? parentId,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ItemFields[] fields,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] BaseItemKind[] includeItemTypes,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ItemFields[] fields,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] BaseItemKind[] includeItemTypes,
[FromQuery] bool? isPlayed,
[FromQuery] bool? enableImages,
[FromQuery] int? imageTypeLimit,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ImageType[] enableImageTypes,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ImageType[] enableImageTypes,
[FromQuery] bool? enableUserData,
[FromQuery] int limit = 20,
[FromQuery] bool groupItems = true)
@@ -608,12 +608,12 @@ public class UserLibraryController : BaseJellyfinApiController
public ActionResult> GetLatestMediaLegacy(
[FromRoute, Required] Guid userId,
[FromQuery] Guid? parentId,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ItemFields[] fields,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] BaseItemKind[] includeItemTypes,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ItemFields[] fields,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] BaseItemKind[] includeItemTypes,
[FromQuery] bool? isPlayed,
[FromQuery] bool? enableImages,
[FromQuery] int? imageTypeLimit,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ImageType[] enableImageTypes,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ImageType[] enableImageTypes,
[FromQuery] bool? enableUserData,
[FromQuery] int limit = 20,
[FromQuery] bool groupItems = true)
@@ -634,10 +634,10 @@ public class UserLibraryController : BaseJellyfinApiController
{
if (item is Person)
{
- var hasMetdata = !string.IsNullOrWhiteSpace(item.Overview) && item.HasImage(ImageType.Primary);
- var performFullRefresh = !hasMetdata && (DateTime.UtcNow - item.DateLastRefreshed).TotalDays >= 3;
+ var hasMetadata = !string.IsNullOrWhiteSpace(item.Overview) && item.HasImage(ImageType.Primary);
+ var performFullRefresh = !hasMetadata && (DateTime.UtcNow - item.DateLastRefreshed).TotalDays >= 3;
- if (!hasMetdata)
+ if (!hasMetadata)
{
var options = new MetadataRefreshOptions(new DirectoryService(_fileSystem))
{
@@ -662,12 +662,15 @@ public class UserLibraryController : BaseJellyfinApiController
// Get the user data for this item
var data = _userDataRepository.GetUserData(user, item);
- // Set favorite status
- data.IsFavorite = isFavorite;
+ if (data is not null)
+ {
+ // Set favorite status
+ data.IsFavorite = isFavorite;
- _userDataRepository.SaveUserData(user, item, data, UserDataSaveReason.UpdateUserRating, CancellationToken.None);
+ _userDataRepository.SaveUserData(user, item, data, UserDataSaveReason.UpdateUserRating, CancellationToken.None);
+ }
- return _userDataRepository.GetUserDataDto(item, user);
+ return _userDataRepository.GetUserDataDto(item, user)!;
}
///
@@ -676,14 +679,17 @@ public class UserLibraryController : BaseJellyfinApiController
/// The user.
/// The item.
/// if set to true [likes].
- private UserItemDataDto UpdateUserItemRatingInternal(User user, BaseItem item, bool? likes)
+ private UserItemDataDto? UpdateUserItemRatingInternal(User user, BaseItem item, bool? likes)
{
// Get the user data for this item
var data = _userDataRepository.GetUserData(user, item);
- data.Likes = likes;
+ if (data is not null)
+ {
+ data.Likes = likes;
- _userDataRepository.SaveUserData(user, item, data, UserDataSaveReason.UpdateUserRating, CancellationToken.None);
+ _userDataRepository.SaveUserData(user, item, data, UserDataSaveReason.UpdateUserRating, CancellationToken.None);
+ }
return _userDataRepository.GetUserDataDto(item, user);
}
diff --git a/Jellyfin.Api/Controllers/UserViewsController.cs b/Jellyfin.Api/Controllers/UserViewsController.cs
index e24f78a888..64b2dffb32 100644
--- a/Jellyfin.Api/Controllers/UserViewsController.cs
+++ b/Jellyfin.Api/Controllers/UserViewsController.cs
@@ -66,7 +66,7 @@ public class UserViewsController : BaseJellyfinApiController
public QueryResult GetUserViews(
[FromQuery] Guid? userId,
[FromQuery] bool? includeExternalContent,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] CollectionType?[] presetViews,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] CollectionType?[] presetViews,
[FromQuery] bool includeHidden = false)
{
userId = RequestHelpers.GetUserId(User, userId);
@@ -110,7 +110,7 @@ public class UserViewsController : BaseJellyfinApiController
public QueryResult GetUserViewsLegacy(
[FromRoute, Required] Guid userId,
[FromQuery] bool? includeExternalContent,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] CollectionType?[] presetViews,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] CollectionType?[] presetViews,
[FromQuery] bool includeHidden = false)
=> GetUserViews(userId, includeExternalContent, presetViews, includeHidden);
diff --git a/Jellyfin.Api/Controllers/VideosController.cs b/Jellyfin.Api/Controllers/VideosController.cs
index 8348fd937d..97f3239bbc 100644
--- a/Jellyfin.Api/Controllers/VideosController.cs
+++ b/Jellyfin.Api/Controllers/VideosController.cs
@@ -184,7 +184,7 @@ public class VideosController : BaseJellyfinApiController
[Authorize(Policy = Policies.RequiresElevation)]
[ProducesResponseType(StatusCodes.Status204NoContent)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
- public async Task MergeVersions([FromQuery, Required, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] Guid[] ids)
+ public async Task MergeVersions([FromQuery, Required, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] Guid[] ids)
{
var userId = User.GetUserId();
var items = ids
@@ -315,18 +315,18 @@ public class VideosController : BaseJellyfinApiController
[ProducesVideoFile]
public async Task GetVideoStream(
[FromRoute, Required] Guid itemId,
- [FromQuery] [RegularExpression(EncodingHelper.ValidationRegex)] string? container,
+ [FromQuery] [RegularExpression(EncodingHelper.ContainerValidationRegex)] string? container,
[FromQuery] bool? @static,
[FromQuery] string? @params,
[FromQuery] string? tag,
[FromQuery, ParameterObsolete] string? deviceProfileId,
[FromQuery] string? playSessionId,
- [FromQuery] [RegularExpression(EncodingHelper.ValidationRegex)] string? segmentContainer,
+ [FromQuery] [RegularExpression(EncodingHelper.ContainerValidationRegex)] string? segmentContainer,
[FromQuery] int? segmentLength,
[FromQuery] int? minSegments,
[FromQuery] string? mediaSourceId,
[FromQuery] string? deviceId,
- [FromQuery] [RegularExpression(EncodingHelper.ValidationRegex)] string? audioCodec,
+ [FromQuery] [RegularExpression(EncodingHelper.ContainerValidationRegex)] string? audioCodec,
[FromQuery] bool? enableAutoStreamCopy,
[FromQuery] bool? allowVideoStreamCopy,
[FromQuery] bool? allowAudioStreamCopy,
@@ -337,7 +337,7 @@ public class VideosController : BaseJellyfinApiController
[FromQuery] int? audioChannels,
[FromQuery] int? maxAudioChannels,
[FromQuery] string? profile,
- [FromQuery] string? level,
+ [FromQuery] [RegularExpression(EncodingHelper.LevelValidationRegex)] string? level,
[FromQuery] float? framerate,
[FromQuery] float? maxFramerate,
[FromQuery] bool? copyTimestamps,
@@ -358,8 +358,8 @@ public class VideosController : BaseJellyfinApiController
[FromQuery] int? cpuCoreLimit,
[FromQuery] string? liveStreamId,
[FromQuery] bool? enableMpegtsM2TsMode,
- [FromQuery] [RegularExpression(EncodingHelper.ValidationRegex)] string? videoCodec,
- [FromQuery] [RegularExpression(EncodingHelper.ValidationRegex)] string? subtitleCodec,
+ [FromQuery] [RegularExpression(EncodingHelper.ContainerValidationRegex)] string? videoCodec,
+ [FromQuery] [RegularExpression(EncodingHelper.ContainerValidationRegex)] string? subtitleCodec,
[FromQuery] string? transcodeReasons,
[FromQuery] int? audioStreamIndex,
[FromQuery] int? videoStreamIndex,
@@ -556,18 +556,18 @@ public class VideosController : BaseJellyfinApiController
[ProducesVideoFile]
public Task GetVideoStreamByContainer(
[FromRoute, Required] Guid itemId,
- [FromRoute, Required] string container,
+ [FromRoute, Required] [RegularExpression(EncodingHelper.ContainerValidationRegex)] string container,
[FromQuery] bool? @static,
[FromQuery] string? @params,
[FromQuery] string? tag,
[FromQuery] string? deviceProfileId,
[FromQuery] string? playSessionId,
- [FromQuery] [RegularExpression(EncodingHelper.ValidationRegex)] string? segmentContainer,
+ [FromQuery] [RegularExpression(EncodingHelper.ContainerValidationRegex)] string? segmentContainer,
[FromQuery] int? segmentLength,
[FromQuery] int? minSegments,
[FromQuery] string? mediaSourceId,
[FromQuery] string? deviceId,
- [FromQuery] [RegularExpression(EncodingHelper.ValidationRegex)] string? audioCodec,
+ [FromQuery] [RegularExpression(EncodingHelper.ContainerValidationRegex)] string? audioCodec,
[FromQuery] bool? enableAutoStreamCopy,
[FromQuery] bool? allowVideoStreamCopy,
[FromQuery] bool? allowAudioStreamCopy,
@@ -578,7 +578,7 @@ public class VideosController : BaseJellyfinApiController
[FromQuery] int? audioChannels,
[FromQuery] int? maxAudioChannels,
[FromQuery] string? profile,
- [FromQuery] string? level,
+ [FromQuery] [RegularExpression(EncodingHelper.LevelValidationRegex)] string? level,
[FromQuery] float? framerate,
[FromQuery] float? maxFramerate,
[FromQuery] bool? copyTimestamps,
@@ -599,8 +599,8 @@ public class VideosController : BaseJellyfinApiController
[FromQuery] int? cpuCoreLimit,
[FromQuery] string? liveStreamId,
[FromQuery] bool? enableMpegtsM2TsMode,
- [FromQuery] [RegularExpression(EncodingHelper.ValidationRegex)] string? videoCodec,
- [FromQuery] [RegularExpression(EncodingHelper.ValidationRegex)] string? subtitleCodec,
+ [FromQuery] [RegularExpression(EncodingHelper.ContainerValidationRegex)] string? videoCodec,
+ [FromQuery] [RegularExpression(EncodingHelper.ContainerValidationRegex)] string? subtitleCodec,
[FromQuery] string? transcodeReasons,
[FromQuery] int? audioStreamIndex,
[FromQuery] int? videoStreamIndex,
diff --git a/Jellyfin.Api/Controllers/YearsController.cs b/Jellyfin.Api/Controllers/YearsController.cs
index e4aa0ea42d..ebf98da456 100644
--- a/Jellyfin.Api/Controllers/YearsController.cs
+++ b/Jellyfin.Api/Controllers/YearsController.cs
@@ -1,12 +1,14 @@
using System;
using System.Collections.Generic;
+using System.Collections.Immutable;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using Jellyfin.Api.Extensions;
using Jellyfin.Api.Helpers;
using Jellyfin.Api.ModelBinders;
-using Jellyfin.Data.Entities;
using Jellyfin.Data.Enums;
+using Jellyfin.Database.Implementations.Entities;
+using Jellyfin.Database.Implementations.Enums;
using Jellyfin.Extensions;
using MediaBrowser.Controller.Dto;
using MediaBrowser.Controller.Entities;
@@ -71,16 +73,16 @@ public class YearsController : BaseJellyfinApiController
public ActionResult> GetYears(
[FromQuery] int? startIndex,
[FromQuery] int? limit,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] SortOrder[] sortOrder,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] SortOrder[] sortOrder,
[FromQuery] Guid? parentId,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ItemFields[] fields,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] BaseItemKind[] excludeItemTypes,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] BaseItemKind[] includeItemTypes,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] MediaType[] mediaTypes,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ItemSortBy[] sortBy,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ItemFields[] fields,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] BaseItemKind[] excludeItemTypes,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] BaseItemKind[] includeItemTypes,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] MediaType[] mediaTypes,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ItemSortBy[] sortBy,
[FromQuery] bool? enableUserData,
[FromQuery] int? imageTypeLimit,
- [FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ImageType[] enableImageTypes,
+ [FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ImageType[] enableImageTypes,
[FromQuery] Guid? userId,
[FromQuery] bool recursive = true,
[FromQuery] bool? enableImages = true)
@@ -105,18 +107,18 @@ public class YearsController : BaseJellyfinApiController
bool Filter(BaseItem i) => FilterItem(i, excludeItemTypes, includeItemTypes, mediaTypes);
- IList items;
+ IReadOnlyList items;
if (parentItem.IsFolder)
{
var folder = (Folder)parentItem;
if (userId.IsNullOrEmpty())
{
- items = recursive ? folder.GetRecursiveChildren(Filter) : folder.Children.Where(Filter).ToList();
+ items = recursive ? folder.GetRecursiveChildren(Filter) : folder.Children.Where(Filter).ToArray();
}
else
{
- items = recursive ? folder.GetRecursiveChildren(user, query).ToList() : folder.GetChildren(user, true).Where(Filter).ToList();
+ items = recursive ? folder.GetRecursiveChildren(user, query) : folder.GetChildren(user, true).Where(Filter).ToArray();
}
}
else
diff --git a/Jellyfin.Api/Formatters/CssOutputFormatter.cs b/Jellyfin.Api/Formatters/CssOutputFormatter.cs
index 495f771e1f..9ad1c863ea 100644
--- a/Jellyfin.Api/Formatters/CssOutputFormatter.cs
+++ b/Jellyfin.Api/Formatters/CssOutputFormatter.cs
@@ -1,6 +1,4 @@
-using System.Text;
-using System.Threading.Tasks;
-using Microsoft.AspNetCore.Http;
+using System.Net.Mime;
using Microsoft.AspNetCore.Mvc.Formatters;
namespace Jellyfin.Api.Formatters;
@@ -8,28 +6,14 @@ namespace Jellyfin.Api.Formatters;
///
/// Css output formatter.
///
-public class CssOutputFormatter : TextOutputFormatter
+public sealed class CssOutputFormatter : StringOutputFormatter
{
///
/// Initializes a new instance of the class.
///
public CssOutputFormatter()
{
- SupportedMediaTypes.Add("text/css");
-
- SupportedEncodings.Add(Encoding.UTF8);
- SupportedEncodings.Add(Encoding.Unicode);
- }
-
- ///
- /// Write context object to stream.
- ///
- /// Writer context.
- /// Unused. Writer encoding.
- /// Write stream task.
- public override Task WriteResponseBodyAsync(OutputFormatterWriteContext context, Encoding selectedEncoding)
- {
- var stringResponse = context.Object?.ToString();
- return stringResponse is null ? Task.CompletedTask : context.HttpContext.Response.WriteAsync(stringResponse);
+ SupportedMediaTypes.Clear();
+ SupportedMediaTypes.Add(MediaTypeNames.Text.Css);
}
}
diff --git a/Jellyfin.Api/Formatters/XmlOutputFormatter.cs b/Jellyfin.Api/Formatters/XmlOutputFormatter.cs
index 1c9feedcb7..8dbb91d0aa 100644
--- a/Jellyfin.Api/Formatters/XmlOutputFormatter.cs
+++ b/Jellyfin.Api/Formatters/XmlOutputFormatter.cs
@@ -1,7 +1,4 @@
using System.Net.Mime;
-using System.Text;
-using System.Threading.Tasks;
-using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc.Formatters;
namespace Jellyfin.Api.Formatters;
@@ -9,7 +6,7 @@ namespace Jellyfin.Api.Formatters;
///
/// Xml output formatter.
///
-public class XmlOutputFormatter : TextOutputFormatter
+public sealed class XmlOutputFormatter : StringOutputFormatter
{
///
/// Initializes a new instance of the class.
@@ -18,15 +15,5 @@ public class XmlOutputFormatter : TextOutputFormatter
{
SupportedMediaTypes.Clear();
SupportedMediaTypes.Add(MediaTypeNames.Text.Xml);
-
- SupportedEncodings.Add(Encoding.UTF8);
- SupportedEncodings.Add(Encoding.Unicode);
- }
-
- ///
- public override Task WriteResponseBodyAsync(OutputFormatterWriteContext context, Encoding selectedEncoding)
- {
- var stringResponse = context.Object?.ToString();
- return stringResponse is null ? Task.CompletedTask : context.HttpContext.Response.WriteAsync(stringResponse);
}
}
diff --git a/Jellyfin.Api/Helpers/DynamicHlsHelper.cs b/Jellyfin.Api/Helpers/DynamicHlsHelper.cs
index 0e620e72a9..a38ad379cc 100644
--- a/Jellyfin.Api/Helpers/DynamicHlsHelper.cs
+++ b/Jellyfin.Api/Helpers/DynamicHlsHelper.cs
@@ -8,8 +8,8 @@ using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Jellyfin.Api.Extensions;
-using Jellyfin.Data.Entities;
using Jellyfin.Data.Enums;
+using Jellyfin.Database.Implementations.Entities;
using Jellyfin.Extensions;
using MediaBrowser.Common.Configuration;
using MediaBrowser.Common.Extensions;
@@ -267,7 +267,7 @@ public class DynamicHlsHelper
if (EnableAdaptiveBitrateStreaming(state, isLiveStream, enableAdaptiveBitrateStreaming, _httpContextAccessor.HttpContext.GetNormalizedRemoteIP()))
{
- var requestedVideoBitrate = state.VideoRequest is null ? 0 : state.VideoRequest.VideoBitRate ?? 0;
+ var requestedVideoBitrate = state.VideoRequest?.VideoBitRate ?? 0;
// By default, vary by just 200k
var variation = GetBitrateVariation(totalBitrate);
@@ -345,13 +345,15 @@ public class DynamicHlsHelper
if (videoRange == VideoRange.HDR)
{
- if (videoRangeType == VideoRangeType.HLG)
+ switch (videoRangeType)
{
- builder.Append(",VIDEO-RANGE=HLG");
- }
- else
- {
- builder.Append(",VIDEO-RANGE=PQ");
+ case VideoRangeType.HLG:
+ case VideoRangeType.DOVIWithHLG:
+ builder.Append(",VIDEO-RANGE=HLG");
+ break;
+ default:
+ builder.Append(",VIDEO-RANGE=PQ");
+ break;
}
}
}
@@ -418,36 +420,67 @@ public class DynamicHlsHelper
/// StreamState of the current stream.
private void AppendPlaylistSupplementalCodecsField(StringBuilder builder, StreamState state)
{
- // Dolby Vision currently cannot exist when transcoding
+ // HDR dynamic metadata currently cannot exist when transcoding
if (!EncodingHelper.IsCopyCodec(state.OutputVideoCodec))
{
return;
}
- var dvProfile = state.VideoStream.DvProfile;
- var dvLevel = state.VideoStream.DvLevel;
- var dvRangeString = state.VideoStream.VideoRangeType switch
+ if (EncodingHelper.IsDovi(state.VideoStream) && !_encodingHelper.IsDoviRemoved(state))
{
- VideoRangeType.DOVIWithHDR10 => "db1p",
- VideoRangeType.DOVIWithHLG => "db4h",
- _ => string.Empty
- };
-
- if (dvProfile is null || dvLevel is null || string.IsNullOrEmpty(dvRangeString))
+ AppendDvString();
+ }
+ else if (EncodingHelper.IsHdr10Plus(state.VideoStream) && !_encodingHelper.IsHdr10PlusRemoved(state))
{
- return;
+ AppendHdr10PlusString();
}
- var dvFourCc = string.Equals(state.ActualOutputVideoCodec, "av1", StringComparison.OrdinalIgnoreCase) ? "dav1" : "dvh1";
- builder.Append(",SUPPLEMENTAL-CODECS=\"")
- .Append(dvFourCc)
- .Append('.')
- .Append(dvProfile.Value.ToString("D2", CultureInfo.InvariantCulture))
- .Append('.')
- .Append(dvLevel.Value.ToString("D2", CultureInfo.InvariantCulture))
- .Append('/')
- .Append(dvRangeString)
- .Append('"');
+ return;
+
+ void AppendDvString()
+ {
+ var dvProfile = state.VideoStream.DvProfile;
+ var dvLevel = state.VideoStream.DvLevel;
+ var dvRangeString = state.VideoStream.VideoRangeType switch
+ {
+ VideoRangeType.DOVIWithHDR10 => "db1p",
+ VideoRangeType.DOVIWithHLG => "db4h",
+ VideoRangeType.DOVIWithHDR10Plus => "db1p", // The HDR10+ metadata would be removed if Dovi metadata is not removed
+ _ => string.Empty // Don't label Dovi with EL and SDR due to compatability issues, ignore invalid configurations
+ };
+
+ if (dvProfile is null || dvLevel is null || string.IsNullOrEmpty(dvRangeString))
+ {
+ return;
+ }
+
+ var dvFourCc = string.Equals(state.ActualOutputVideoCodec, "av1", StringComparison.OrdinalIgnoreCase) ? "dav1" : "dvh1";
+ builder.Append(",SUPPLEMENTAL-CODECS=\"")
+ .Append(dvFourCc)
+ .Append('.')
+ .Append(dvProfile.Value.ToString("D2", CultureInfo.InvariantCulture))
+ .Append('.')
+ .Append(dvLevel.Value.ToString("D2", CultureInfo.InvariantCulture))
+ .Append('/')
+ .Append(dvRangeString)
+ .Append('"');
+ }
+
+ void AppendHdr10PlusString()
+ {
+ var videoCodecLevel = GetOutputVideoCodecLevel(state);
+ if (string.IsNullOrEmpty(state.ActualOutputVideoCodec) || videoCodecLevel is null)
+ {
+ return;
+ }
+
+ var videoCodecString = GetPlaylistVideoCodecs(state, state.ActualOutputVideoCodec, videoCodecLevel.Value);
+ builder.Append(",SUPPLEMENTAL-CODECS=\"")
+ .Append(videoCodecString)
+ .Append('/')
+ .Append("cdm4")
+ .Append('"');
+ }
}
///
@@ -526,9 +559,7 @@ public class DynamicHlsHelper
return false;
}
- // Having problems in android
- return false;
- // return state.VideoRequest.VideoBitRate.HasValue;
+ return state.VideoRequest?.VideoBitRate.HasValue ?? false;
}
private void AddSubtitles(StreamState state, IEnumerable subtitles, StringBuilder builder, ClaimsPrincipal user)
@@ -550,7 +581,7 @@ public class DynamicHlsHelper
var url = string.Format(
CultureInfo.InvariantCulture,
- "{0}/Subtitles/{1}/subtitles.m3u8?SegmentLength={2}&api_key={3}",
+ "{0}/Subtitles/{1}/subtitles.m3u8?SegmentLength={2}&ApiKey={3}",
state.Request.MediaSourceId,
stream.Index.ToString(CultureInfo.InvariantCulture),
30.ToString(CultureInfo.InvariantCulture),
@@ -587,7 +618,7 @@ public class DynamicHlsHelper
var url = string.Format(
CultureInfo.InvariantCulture,
- "Trickplay/{0}/tiles.m3u8?MediaSourceId={1}&api_key={2}",
+ "Trickplay/{0}/tiles.m3u8?MediaSourceId={1}&ApiKey={2}",
width.ToString(CultureInfo.InvariantCulture),
state.Request.MediaSourceId,
user.GetToken());
@@ -616,7 +647,7 @@ public class DynamicHlsHelper
&& state.VideoStream is not null
&& state.VideoStream.Level.HasValue)
{
- levelString = state.VideoStream.Level.Value.ToString(CultureInfo.InvariantCulture) ?? string.Empty;
+ levelString = state.VideoStream.Level.Value.ToString(CultureInfo.InvariantCulture);
}
else
{
diff --git a/Jellyfin.Api/Helpers/MediaInfoHelper.cs b/Jellyfin.Api/Helpers/MediaInfoHelper.cs
index 4adda0b695..454d3f08e3 100644
--- a/Jellyfin.Api/Helpers/MediaInfoHelper.cs
+++ b/Jellyfin.Api/Helpers/MediaInfoHelper.cs
@@ -7,8 +7,10 @@ using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
using Jellyfin.Api.Extensions;
-using Jellyfin.Data.Entities;
+using Jellyfin.Data;
using Jellyfin.Data.Enums;
+using Jellyfin.Database.Implementations.Entities;
+using Jellyfin.Database.Implementations.Enums;
using Jellyfin.Extensions;
using MediaBrowser.Common.Extensions;
using MediaBrowser.Common.Net;
@@ -127,6 +129,13 @@ public class MediaInfoHelper
var mediaSourcesClone = JsonSerializer.Deserialize(JsonSerializer.SerializeToUtf8Bytes(mediaSources));
if (mediaSourcesClone is not null)
{
+ // Carry over the default audio index source.
+ // This field is not intended to be exposed to API clients, but it is used internally by the server
+ for (int i = 0; i < mediaSourcesClone.Length && i < mediaSources.Length; i++)
+ {
+ mediaSourcesClone[i].DefaultAudioIndexSource = mediaSources[i].DefaultAudioIndexSource;
+ }
+
result.MediaSources = mediaSourcesClone;
}
@@ -288,9 +297,7 @@ public class MediaInfoHelper
mediaSource.SupportsDirectPlay = false;
mediaSource.SupportsDirectStream = false;
- mediaSource.TranscodingUrl = streamInfo.ToUrl("-", claimsPrincipal.GetToken()).TrimStart('-');
- mediaSource.TranscodingUrl += "&allowVideoStreamCopy=false";
- mediaSource.TranscodingUrl += "&allowAudioStreamCopy=false";
+ mediaSource.TranscodingUrl = streamInfo.ToUrl(null, claimsPrincipal.GetToken(), "&allowVideoStreamCopy=false&allowAudioStreamCopy=false");
mediaSource.TranscodingContainer = streamInfo.Container;
mediaSource.TranscodingSubProtocol = streamInfo.SubProtocol;
if (streamInfo.AlwaysBurnInSubtitleWhenTranscoding)
@@ -303,7 +310,7 @@ public class MediaInfoHelper
if (!mediaSource.SupportsDirectPlay && (mediaSource.SupportsTranscoding || mediaSource.SupportsDirectStream))
{
streamInfo.PlayMethod = PlayMethod.Transcode;
- mediaSource.TranscodingUrl = streamInfo.ToUrl("-", claimsPrincipal.GetToken()).TrimStart('-');
+ mediaSource.TranscodingUrl = streamInfo.ToUrl(null, claimsPrincipal.GetToken(), null);
if (!allowVideoStreamCopy)
{
diff --git a/Jellyfin.Api/Helpers/RequestHelpers.cs b/Jellyfin.Api/Helpers/RequestHelpers.cs
index eb83a37ba4..e10e940f21 100644
--- a/Jellyfin.Api/Helpers/RequestHelpers.cs
+++ b/Jellyfin.Api/Helpers/RequestHelpers.cs
@@ -5,8 +5,9 @@ using System.Security.Claims;
using System.Threading.Tasks;
using Jellyfin.Api.Constants;
using Jellyfin.Api.Extensions;
-using Jellyfin.Data.Entities;
using Jellyfin.Data.Enums;
+using Jellyfin.Database.Implementations.Entities;
+using Jellyfin.Database.Implementations.Enums;
using Jellyfin.Extensions;
using MediaBrowser.Common.Extensions;
using MediaBrowser.Controller.Dto;
diff --git a/Jellyfin.Api/Helpers/StreamingHelpers.cs b/Jellyfin.Api/Helpers/StreamingHelpers.cs
index 3a5db2f3fb..2601fa3be8 100644
--- a/Jellyfin.Api/Helpers/StreamingHelpers.cs
+++ b/Jellyfin.Api/Helpers/StreamingHelpers.cs
@@ -132,7 +132,7 @@ public static class StreamingHelpers
mediaSource = string.IsNullOrEmpty(streamingRequest.MediaSourceId)
? mediaSources[0]
- : mediaSources.Find(i => string.Equals(i.Id, streamingRequest.MediaSourceId, StringComparison.Ordinal));
+ : mediaSources.FirstOrDefault(i => string.Equals(i.Id, streamingRequest.MediaSourceId, StringComparison.Ordinal));
if (mediaSource is null && Guid.Parse(streamingRequest.MediaSourceId).Equals(streamingRequest.Id))
{
@@ -210,7 +210,7 @@ public static class StreamingHelpers
&& state.VideoRequest.VideoBitRate.Value >= state.VideoStream.BitRate.Value)
{
// Don't downscale the resolution if the width/height/MaxWidth/MaxHeight is not requested,
- // and the requested video bitrate is higher than source video bitrate.
+ // and the requested video bitrate is greater than source video bitrate.
if (state.VideoStream.Width.HasValue || state.VideoStream.Height.HasValue)
{
state.VideoRequest.MaxWidth = state.VideoStream?.Width;
@@ -235,6 +235,11 @@ public static class StreamingHelpers
state.VideoRequest.MaxHeight = resolution.MaxHeight;
}
}
+
+ if (state.AudioStream is not null && !EncodingHelper.IsCopyCodec(state.OutputAudioCodec) && string.Equals(state.AudioStream.Codec, state.OutputAudioCodec, StringComparison.OrdinalIgnoreCase) && state.OutputAudioBitrate.HasValue)
+ {
+ state.OutputAudioCodec = state.SupportedAudioCodecs.Where(c => !EncodingHelper.LosslessAudioCodecs.Contains(c)).FirstOrDefault(mediaEncoder.CanEncodeToAudioCodec);
+ }
}
var ext = string.IsNullOrWhiteSpace(state.OutputContainer)
diff --git a/Jellyfin.Api/Jellyfin.Api.csproj b/Jellyfin.Api/Jellyfin.Api.csproj
index 5f86a6b6be..25feaa2d75 100644
--- a/Jellyfin.Api/Jellyfin.Api.csproj
+++ b/Jellyfin.Api/Jellyfin.Api.csproj
@@ -6,7 +6,7 @@
- net8.0
+ net9.0
true
diff --git a/Jellyfin.Api/ModelBinders/CommaDelimitedArrayModelBinder.cs b/Jellyfin.Api/ModelBinders/CommaDelimitedCollectionModelBinder.cs
similarity index 88%
rename from Jellyfin.Api/ModelBinders/CommaDelimitedArrayModelBinder.cs
rename to Jellyfin.Api/ModelBinders/CommaDelimitedCollectionModelBinder.cs
index 3e3604b2ad..25b84cbcc5 100644
--- a/Jellyfin.Api/ModelBinders/CommaDelimitedArrayModelBinder.cs
+++ b/Jellyfin.Api/ModelBinders/CommaDelimitedCollectionModelBinder.cs
@@ -8,18 +8,18 @@ using Microsoft.Extensions.Logging;
namespace Jellyfin.Api.ModelBinders;
///
-/// Comma delimited array model binder.
+/// Comma delimited collection model binder.
/// Returns an empty array of specified type if there is no query parameter.
///
-public class CommaDelimitedArrayModelBinder : IModelBinder
+public class CommaDelimitedCollectionModelBinder : IModelBinder
{
- private readonly ILogger _logger;
+ private readonly ILogger _logger;
///
- /// Initializes a new instance of the class.
+ /// Initializes a new instance of the class.
///
- /// Instance of the interface.
- public CommaDelimitedArrayModelBinder(ILogger logger)
+ /// Instance of the interface.
+ public CommaDelimitedCollectionModelBinder(ILogger logger)
{
_logger = logger;
}
diff --git a/Jellyfin.Api/ModelBinders/PipeDelimitedArrayModelBinder.cs b/Jellyfin.Api/ModelBinders/PipeDelimitedCollectionModelBinder.cs
similarity index 85%
rename from Jellyfin.Api/ModelBinders/PipeDelimitedArrayModelBinder.cs
rename to Jellyfin.Api/ModelBinders/PipeDelimitedCollectionModelBinder.cs
index ae9f0a8cdb..7d0fb2e191 100644
--- a/Jellyfin.Api/ModelBinders/PipeDelimitedArrayModelBinder.cs
+++ b/Jellyfin.Api/ModelBinders/PipeDelimitedCollectionModelBinder.cs
@@ -8,18 +8,18 @@ using Microsoft.Extensions.Logging;
namespace Jellyfin.Api.ModelBinders;
///
-/// Comma delimited array model binder.
-/// Returns an empty array of specified type if there is no query parameter.
+/// Comma delimited collection model binder.
+/// Returns an empty collection of specified type if there is no query parameter.
///
-public class PipeDelimitedArrayModelBinder : IModelBinder
+public class PipeDelimitedCollectionModelBinder : IModelBinder
{
- private readonly ILogger _logger;
+ private readonly ILogger _logger;
///
- /// Initializes a new instance of the class.
+ /// Initializes a new instance of the class.
///
- /// Instance of the interface.
- public PipeDelimitedArrayModelBinder(ILogger logger)
+ /// Instance of the interface.
+ public PipeDelimitedCollectionModelBinder(ILogger logger)
{
_logger = logger;
}
diff --git a/Jellyfin.Api/Models/LibraryDtos/LibraryOptionsResultDto.cs b/Jellyfin.Api/Models/LibraryDtos/LibraryOptionsResultDto.cs
index d07349bdf6..c492436689 100644
--- a/Jellyfin.Api/Models/LibraryDtos/LibraryOptionsResultDto.cs
+++ b/Jellyfin.Api/Models/LibraryDtos/LibraryOptionsResultDto.cs
@@ -28,6 +28,11 @@ public class LibraryOptionsResultDto
///
public IReadOnlyList LyricFetchers { get; set; } = Array.Empty();
+ ///
+ /// Gets or sets the list of MediaSegment Providers.
+ ///
+ public IReadOnlyList MediaSegmentProviders { get; set; } = Array.Empty();
+
///
/// Gets or sets the type options.
///
diff --git a/Jellyfin.Api/Models/LiveTvDtos/GetProgramsDto.cs b/Jellyfin.Api/Models/LiveTvDtos/GetProgramsDto.cs
index 190d90681f..2616694d83 100644
--- a/Jellyfin.Api/Models/LiveTvDtos/GetProgramsDto.cs
+++ b/Jellyfin.Api/Models/LiveTvDtos/GetProgramsDto.cs
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.ComponentModel;
using System.Text.Json.Serialization;
using Jellyfin.Data.Enums;
+using Jellyfin.Database.Implementations.Enums;
using Jellyfin.Extensions.Json.Converters;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Querying;
@@ -17,7 +18,7 @@ public class GetProgramsDto
///
/// Gets or sets the channels to return guide information for.
///
- [JsonConverter(typeof(JsonCommaDelimitedArrayConverterFactory))]
+ [JsonConverter(typeof(JsonCommaDelimitedCollectionConverterFactory))]
public IReadOnlyList? ChannelIds { get; set; }
///
@@ -93,25 +94,25 @@ public class GetProgramsDto
///
/// Gets or sets specify one or more sort orders, comma delimited. Options: Name, StartDate.
///
- [JsonConverter(typeof(JsonCommaDelimitedArrayConverterFactory))]
+ [JsonConverter(typeof(JsonCommaDelimitedCollectionConverterFactory))]
public IReadOnlyList? SortBy { get; set; }
///
/// Gets or sets sort order.
///
- [JsonConverter(typeof(JsonCommaDelimitedArrayConverterFactory))]
+ [JsonConverter(typeof(JsonCommaDelimitedCollectionConverterFactory))]
public IReadOnlyList? SortOrder { get; set; }
///
/// Gets or sets the genres to return guide information for.
///
- [JsonConverter(typeof(JsonPipeDelimitedArrayConverterFactory))]
+ [JsonConverter(typeof(JsonPipeDelimitedCollectionConverterFactory))]
public IReadOnlyList? Genres { get; set; }
///
/// Gets or sets the genre ids to return guide information for.
///
- [JsonConverter(typeof(JsonCommaDelimitedArrayConverterFactory))]
+ [JsonConverter(typeof(JsonCommaDelimitedCollectionConverterFactory))]
public IReadOnlyList? GenreIds { get; set; }
///
@@ -133,7 +134,7 @@ public class GetProgramsDto
///
/// Gets or sets the image types to include in the output.
///
- [JsonConverter(typeof(JsonCommaDelimitedArrayConverterFactory))]
+ [JsonConverter(typeof(JsonCommaDelimitedCollectionConverterFactory))]
public IReadOnlyList? EnableImageTypes { get; set; }
///
@@ -154,6 +155,6 @@ public class GetProgramsDto
///
/// Gets or sets specify additional fields of information to return in the output.
///
- [JsonConverter(typeof(JsonCommaDelimitedArrayConverterFactory))]
+ [JsonConverter(typeof(JsonCommaDelimitedCollectionConverterFactory))]
public IReadOnlyList? Fields { get; set; }
}
diff --git a/Jellyfin.Api/Models/MediaInfoDtos/OpenLiveStreamDto.cs b/Jellyfin.Api/Models/MediaInfoDtos/OpenLiveStreamDto.cs
index 978e99b35c..758c89938e 100644
--- a/Jellyfin.Api/Models/MediaInfoDtos/OpenLiveStreamDto.cs
+++ b/Jellyfin.Api/Models/MediaInfoDtos/OpenLiveStreamDto.cs
@@ -61,7 +61,7 @@ public class OpenLiveStreamDto
public bool? EnableDirectPlay { get; set; }
///
- /// Gets or sets a value indicating whether to enale direct stream.
+ /// Gets or sets a value indicating whether to enable direct stream.
///
public bool? EnableDirectStream { get; set; }
diff --git a/Jellyfin.Api/Models/MediaInfoDtos/PlaybackInfoDto.cs b/Jellyfin.Api/Models/MediaInfoDtos/PlaybackInfoDto.cs
index 82f603ca1e..73ab76817c 100644
--- a/Jellyfin.Api/Models/MediaInfoDtos/PlaybackInfoDto.cs
+++ b/Jellyfin.Api/Models/MediaInfoDtos/PlaybackInfoDto.cs
@@ -4,7 +4,7 @@ using MediaBrowser.Model.Dlna;
namespace Jellyfin.Api.Models.MediaInfoDtos;
///
-/// Plabyback info dto.
+/// Playback info dto.
///
public class PlaybackInfoDto
{
diff --git a/Jellyfin.Api/Models/PlaylistDtos/CreatePlaylistDto.cs b/Jellyfin.Api/Models/PlaylistDtos/CreatePlaylistDto.cs
index 61a3f2ed60..891d758c48 100644
--- a/Jellyfin.Api/Models/PlaylistDtos/CreatePlaylistDto.cs
+++ b/Jellyfin.Api/Models/PlaylistDtos/CreatePlaylistDto.cs
@@ -20,7 +20,7 @@ public class CreatePlaylistDto
///
/// Gets or sets item ids to add to the playlist.
///
- [JsonConverter(typeof(JsonCommaDelimitedArrayConverterFactory))]
+ [JsonConverter(typeof(JsonCommaDelimitedCollectionConverterFactory))]
public IReadOnlyList Ids { get; set; } = [];
///
diff --git a/Jellyfin.Api/Models/PlaylistDtos/UpdatePlaylistDto.cs b/Jellyfin.Api/Models/PlaylistDtos/UpdatePlaylistDto.cs
index 80e20995c6..339a0d5d28 100644
--- a/Jellyfin.Api/Models/PlaylistDtos/UpdatePlaylistDto.cs
+++ b/Jellyfin.Api/Models/PlaylistDtos/UpdatePlaylistDto.cs
@@ -19,7 +19,7 @@ public class UpdatePlaylistDto
///
/// Gets or sets item ids of the playlist.
///
- [JsonConverter(typeof(JsonCommaDelimitedArrayConverterFactory))]
+ [JsonConverter(typeof(JsonCommaDelimitedCollectionConverterFactory))]
public IReadOnlyList? Ids { get; set; }
///
diff --git a/Jellyfin.Api/Models/StartupDtos/StartupConfigurationDto.cs b/Jellyfin.Api/Models/StartupDtos/StartupConfigurationDto.cs
index 4027078190..1ba23339d0 100644
--- a/Jellyfin.Api/Models/StartupDtos/StartupConfigurationDto.cs
+++ b/Jellyfin.Api/Models/StartupDtos/StartupConfigurationDto.cs
@@ -5,6 +5,11 @@ namespace Jellyfin.Api.Models.StartupDtos;
///
public class StartupConfigurationDto
{
+ ///
+ /// Gets or sets the server name.
+ ///
+ public string? ServerName { get; set; }
+
///
/// Gets or sets UI language culture.
///
diff --git a/Jellyfin.Api/Models/StartupDtos/StartupRemoteAccessDto.cs b/Jellyfin.Api/Models/StartupDtos/StartupRemoteAccessDto.cs
index 1ae2cad4b6..9c29e372cf 100644
--- a/Jellyfin.Api/Models/StartupDtos/StartupRemoteAccessDto.cs
+++ b/Jellyfin.Api/Models/StartupDtos/StartupRemoteAccessDto.cs
@@ -1,3 +1,4 @@
+using System;
using System.ComponentModel.DataAnnotations;
namespace Jellyfin.Api.Models.StartupDtos;
@@ -17,5 +18,6 @@ public class StartupRemoteAccessDto
/// Gets or sets a value indicating whether enable automatic port mapping.
///
[Required]
+ [Obsolete("No longer supported")]
public bool EnableAutomaticPortMapping { get; set; }
}
diff --git a/Jellyfin.Api/Models/SystemInfoDtos/FolderStorageDto.cs b/Jellyfin.Api/Models/SystemInfoDtos/FolderStorageDto.cs
new file mode 100644
index 0000000000..00a965898c
--- /dev/null
+++ b/Jellyfin.Api/Models/SystemInfoDtos/FolderStorageDto.cs
@@ -0,0 +1,46 @@
+using MediaBrowser.Model.System;
+
+namespace Jellyfin.Api.Models.SystemInfoDtos;
+
+///
+/// Contains information about a specific folder.
+///
+public record FolderStorageDto
+{
+ ///
+ /// Gets the path of the folder in question.
+ ///
+ public required string Path { get; init; }
+
+ ///
+ /// Gets the free space of the underlying storage device of the .
+ ///
+ public long FreeSpace { get; init; }
+
+ ///
+ /// Gets the used space of the underlying storage device of the .
+ ///
+ public long UsedSpace { get; init; }
+
+ ///
+ /// Gets the kind of storage device of the .
+ ///
+ public string? StorageType { get; init; }
+
+ ///
+ /// Gets the Device Identifier.
+ ///
+ public string? DeviceId { get; init; }
+
+ internal static FolderStorageDto FromFolderStorageInfo(FolderStorageInfo model)
+ {
+ return new()
+ {
+ Path = model.Path,
+ FreeSpace = model.FreeSpace,
+ UsedSpace = model.UsedSpace,
+ StorageType = model.StorageType,
+ DeviceId = model.DeviceId
+ };
+ }
+}
diff --git a/Jellyfin.Api/Models/SystemInfoDtos/LibraryStorageDto.cs b/Jellyfin.Api/Models/SystemInfoDtos/LibraryStorageDto.cs
new file mode 100644
index 0000000000..c138324d2e
--- /dev/null
+++ b/Jellyfin.Api/Models/SystemInfoDtos/LibraryStorageDto.cs
@@ -0,0 +1,37 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using MediaBrowser.Model.System;
+
+namespace Jellyfin.Api.Models.SystemInfoDtos;
+
+///
+/// Contains informations about a libraries storage informations.
+///
+public record LibraryStorageDto
+{
+ ///
+ /// Gets or sets the Library Id.
+ ///
+ public required Guid Id { get; set; }
+
+ ///
+ /// Gets or sets the name of the library.
+ ///
+ public required string Name { get; set; }
+
+ ///
+ /// Gets or sets the storage informations about the folders used in a library.
+ ///
+ public required IReadOnlyCollection Folders { get; set; }
+
+ internal static LibraryStorageDto FromLibraryStorageModel(LibraryStorageInfo model)
+ {
+ return new()
+ {
+ Id = model.Id,
+ Name = model.Name,
+ Folders = model.Folders.Select(FolderStorageDto.FromFolderStorageInfo).ToArray()
+ };
+ }
+}
diff --git a/Jellyfin.Api/Models/SystemInfoDtos/SystemStorageDto.cs b/Jellyfin.Api/Models/SystemInfoDtos/SystemStorageDto.cs
new file mode 100644
index 0000000000..a09042439a
--- /dev/null
+++ b/Jellyfin.Api/Models/SystemInfoDtos/SystemStorageDto.cs
@@ -0,0 +1,67 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using MediaBrowser.Model.System;
+
+namespace Jellyfin.Api.Models.SystemInfoDtos;
+
+///
+/// Contains informations about the systems storage.
+///
+public record SystemStorageDto
+{
+ ///
+ /// Gets or sets the Storage information of the program data folder.
+ ///
+ public required FolderStorageDto ProgramDataFolder { get; set; }
+
+ ///
+ /// Gets or sets the Storage information of the web UI resources folder.
+ ///
+ public required FolderStorageDto WebFolder { get; set; }
+
+ ///
+ /// Gets or sets the Storage information of the folder where images are cached.
+ ///
+ public required FolderStorageDto ImageCacheFolder { get; set; }
+
+ ///
+ /// Gets or sets the Storage information of the cache folder.
+ ///
+ public required FolderStorageDto CacheFolder { get; set; }
+
+ ///
+ /// Gets or sets the Storage information of the folder where logfiles are saved to.
+ ///
+ public required FolderStorageDto LogFolder { get; set; }
+
+ ///
+ /// Gets or sets the Storage information of the folder where metadata is stored.
+ ///
+ public required FolderStorageDto InternalMetadataFolder { get; set; }
+
+ ///
+ /// Gets or sets the Storage information of the transcoding cache.
+ ///
+ public required FolderStorageDto TranscodingTempFolder { get; set; }
+
+ ///
+ /// Gets or sets the storage informations of all libraries.
+ ///
+ public required IReadOnlyCollection Libraries { get; set; }
+
+ internal static SystemStorageDto FromSystemStorageInfo(SystemStorageInfo model)
+ {
+ return new SystemStorageDto()
+ {
+ ProgramDataFolder = FolderStorageDto.FromFolderStorageInfo(model.ProgramDataFolder),
+ WebFolder = FolderStorageDto.FromFolderStorageInfo(model.WebFolder),
+ ImageCacheFolder = FolderStorageDto.FromFolderStorageInfo(model.ImageCacheFolder),
+ CacheFolder = FolderStorageDto.FromFolderStorageInfo(model.CacheFolder),
+ LogFolder = FolderStorageDto.FromFolderStorageInfo(model.LogFolder),
+ InternalMetadataFolder = FolderStorageDto.FromFolderStorageInfo(model.InternalMetadataFolder),
+ TranscodingTempFolder = FolderStorageDto.FromFolderStorageInfo(model.TranscodingTempFolder),
+ Libraries = model.Libraries.Select(LibraryStorageDto.FromLibraryStorageModel).ToArray()
+ };
+ }
+}
diff --git a/Jellyfin.Api/WebSocketListeners/ActivityLogWebSocketListener.cs b/Jellyfin.Api/WebSocketListeners/ActivityLogWebSocketListener.cs
index 99516e9384..60379f4152 100644
--- a/Jellyfin.Api/WebSocketListeners/ActivityLogWebSocketListener.cs
+++ b/Jellyfin.Api/WebSocketListeners/ActivityLogWebSocketListener.cs
@@ -1,7 +1,8 @@
using System;
using System.Threading.Tasks;
-using Jellyfin.Data.Enums;
+using Jellyfin.Data;
using Jellyfin.Data.Events;
+using Jellyfin.Database.Implementations.Enums;
using MediaBrowser.Controller.Authentication;
using MediaBrowser.Controller.Net;
using MediaBrowser.Model.Activity;
@@ -70,7 +71,9 @@ public class ActivityLogWebSocketListener : BasePeriodicWebSocketListenerThe message.
protected override void Start(WebSocketMessageInfo message)
{
- if (!message.Connection.AuthorizationInfo.User.HasPermission(PermissionKind.IsAdministrator))
+ if (!message.Connection.AuthorizationInfo.IsApiKey
+ && (message.Connection.AuthorizationInfo.User is null
+ || !message.Connection.AuthorizationInfo.User.HasPermission(PermissionKind.IsAdministrator)))
{
throw new AuthenticationException("Only admin users can retrieve the activity log.");
}
diff --git a/Jellyfin.Api/WebSocketListeners/SessionInfoWebSocketListener.cs b/Jellyfin.Api/WebSocketListeners/SessionInfoWebSocketListener.cs
index a6cfe4d56c..9d149cc85a 100644
--- a/Jellyfin.Api/WebSocketListeners/SessionInfoWebSocketListener.cs
+++ b/Jellyfin.Api/WebSocketListeners/SessionInfoWebSocketListener.cs
@@ -1,6 +1,7 @@
using System.Collections.Generic;
using System.Threading.Tasks;
-using Jellyfin.Data.Enums;
+using Jellyfin.Data;
+using Jellyfin.Database.Implementations.Enums;
using MediaBrowser.Controller.Authentication;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Net;
@@ -79,7 +80,9 @@ public class SessionInfoWebSocketListener : BasePeriodicWebSocketListenerThe message.
protected override void Start(WebSocketMessageInfo message)
{
- if (!message.Connection.AuthorizationInfo.User.HasPermission(PermissionKind.IsAdministrator))
+ if (!message.Connection.AuthorizationInfo.IsApiKey
+ && (message.Connection.AuthorizationInfo.User is null
+ || !message.Connection.AuthorizationInfo.User.HasPermission(PermissionKind.IsAdministrator)))
{
throw new AuthenticationException("Only admin users can subscribe to session information.");
}
diff --git a/Jellyfin.Data/DayOfWeekHelper.cs b/Jellyfin.Data/DayOfWeekHelper.cs
index 82abfb8313..836860e0ea 100644
--- a/Jellyfin.Data/DayOfWeekHelper.cs
+++ b/Jellyfin.Data/DayOfWeekHelper.cs
@@ -1,7 +1,7 @@
#pragma warning disable CS1591
using System;
-using Jellyfin.Data.Enums;
+using Jellyfin.Database.Implementations.Enums;
namespace Jellyfin.Data
{
diff --git a/Jellyfin.Data/Enums/ArtKind.cs b/Jellyfin.Data/Enums/ArtKind.cs
deleted file mode 100644
index f7a73848c8..0000000000
--- a/Jellyfin.Data/Enums/ArtKind.cs
+++ /dev/null
@@ -1,33 +0,0 @@
-namespace Jellyfin.Data.Enums
-{
- ///
- /// An enum representing types of art.
- ///
- public enum ArtKind
- {
- ///
- /// Another type of art, not covered by the other members.
- ///
- Other = 0,
-
- ///
- /// A poster.
- ///
- Poster = 1,
-
- ///
- /// A banner.
- ///
- Banner = 2,
-
- ///
- /// A thumbnail.
- ///
- Thumbnail = 3,
-
- ///
- /// A logo.
- ///
- Logo = 4
- }
-}
diff --git a/Jellyfin.Data/Enums/ChromecastVersion.cs b/Jellyfin.Data/Enums/ChromecastVersion.cs
deleted file mode 100644
index c9c8a4a625..0000000000
--- a/Jellyfin.Data/Enums/ChromecastVersion.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-namespace Jellyfin.Data.Enums
-{
- ///
- /// An enum representing the version of Chromecast to be used by clients.
- ///
- public enum ChromecastVersion
- {
- ///
- /// Stable Chromecast version.
- ///
- Stable = 0,
-
- ///
- /// Unstable Chromecast version.
- ///
- Unstable = 1
- }
-}
diff --git a/Jellyfin.Data/Enums/DynamicDayOfWeek.cs b/Jellyfin.Data/Enums/DynamicDayOfWeek.cs
deleted file mode 100644
index d3d8dd8227..0000000000
--- a/Jellyfin.Data/Enums/DynamicDayOfWeek.cs
+++ /dev/null
@@ -1,58 +0,0 @@
-namespace Jellyfin.Data.Enums
-{
- ///
- /// An enum that represents a day of the week, weekdays, weekends, or all days.
- ///
- public enum DynamicDayOfWeek
- {
- ///
- /// Sunday.
- ///
- Sunday = 0,
-
- ///
- /// Monday.
- ///
- Monday = 1,
-
- ///
- /// Tuesday.
- ///
- Tuesday = 2,
-
- ///
- /// Wednesday.
- ///
- Wednesday = 3,
-
- ///
- /// Thursday.
- ///
- Thursday = 4,
-
- ///
- /// Friday.
- ///
- Friday = 5,
-
- ///
- /// Saturday.
- ///
- Saturday = 6,
-
- ///
- /// All days of the week.
- ///
- Everyday = 7,
-
- ///
- /// A week day, or Monday-Friday.
- ///
- Weekday = 8,
-
- ///
- /// Saturday and Sunday.
- ///
- Weekend = 9
- }
-}
diff --git a/Jellyfin.Data/Enums/HomeSectionType.cs b/Jellyfin.Data/Enums/HomeSectionType.cs
deleted file mode 100644
index 62da8c3fff..0000000000
--- a/Jellyfin.Data/Enums/HomeSectionType.cs
+++ /dev/null
@@ -1,58 +0,0 @@
-namespace Jellyfin.Data.Enums
-{
- ///
- /// An enum representing the different options for the home screen sections.
- ///
- public enum HomeSectionType
- {
- ///
- /// None.
- ///
- None = 0,
-
- ///
- /// My Media.
- ///
- SmallLibraryTiles = 1,
-
- ///
- /// My Media Small.
- ///
- LibraryButtons = 2,
-
- ///
- /// Active Recordings.
- ///
- ActiveRecordings = 3,
-
- ///
- /// Continue Watching.
- ///
- Resume = 4,
-
- ///
- /// Continue Listening.
- ///
- ResumeAudio = 5,
-
- ///
- /// Latest Media.
- ///
- LatestMedia = 6,
-
- ///
- /// Next Up.
- ///
- NextUp = 7,
-
- ///
- /// Live TV.
- ///
- LiveTv = 8,
-
- ///
- /// Continue Reading.
- ///
- ResumeBook = 9
- }
-}
diff --git a/Jellyfin.Data/Enums/IndexingKind.cs b/Jellyfin.Data/Enums/IndexingKind.cs
deleted file mode 100644
index 3967712b03..0000000000
--- a/Jellyfin.Data/Enums/IndexingKind.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-namespace Jellyfin.Data.Enums
-{
- ///
- /// An enum representing a type of indexing in a user's display preferences.
- ///
- public enum IndexingKind
- {
- ///
- /// Index by the premiere date.
- ///
- PremiereDate = 0,
-
- ///
- /// Index by the production year.
- ///
- ProductionYear = 1,
-
- ///
- /// Index by the community rating.
- ///
- CommunityRating = 2
- }
-}
diff --git a/Jellyfin.Data/Enums/ItemSortBy.cs b/Jellyfin.Data/Enums/ItemSortBy.cs
index 17bf1166de..ef76502947 100644
--- a/Jellyfin.Data/Enums/ItemSortBy.cs
+++ b/Jellyfin.Data/Enums/ItemSortBy.cs
@@ -154,14 +154,4 @@ public enum ItemSortBy
/// The index number.
///
IndexNumber = 29,
-
- ///
- /// The similarity score.
- ///
- SimilarityScore = 30,
-
- ///
- /// The search score.
- ///
- SearchScore = 31,
}
diff --git a/Jellyfin.Data/Enums/MediaFileKind.cs b/Jellyfin.Data/Enums/MediaFileKind.cs
deleted file mode 100644
index 797c26ec27..0000000000
--- a/Jellyfin.Data/Enums/MediaFileKind.cs
+++ /dev/null
@@ -1,33 +0,0 @@
-namespace Jellyfin.Data.Enums
-{
- ///
- /// An enum representing the type of media file.
- ///
- public enum MediaFileKind
- {
- ///
- /// The main file.
- ///
- Main = 0,
-
- ///
- /// A sidecar file.
- ///
- Sidecar = 1,
-
- ///
- /// An additional part to the main file.
- ///
- AdditionalPart = 2,
-
- ///
- /// An alternative format to the main file.
- ///
- AlternativeFormat = 3,
-
- ///
- /// An additional stream for the main file.
- ///
- AdditionalStream = 4
- }
-}
diff --git a/Jellyfin.Data/Enums/PermissionKind.cs b/Jellyfin.Data/Enums/PermissionKind.cs
deleted file mode 100644
index c3d6705c24..0000000000
--- a/Jellyfin.Data/Enums/PermissionKind.cs
+++ /dev/null
@@ -1,128 +0,0 @@
-namespace Jellyfin.Data.Enums
-{
- ///
- /// The types of user permissions.
- ///
- public enum PermissionKind
- {
- ///
- /// Whether the user is an administrator.
- ///
- IsAdministrator = 0,
-
- ///
- /// Whether the user is hidden.
- ///
- IsHidden = 1,
-
- ///
- /// Whether the user is disabled.
- ///
- IsDisabled = 2,
-
- ///
- /// Whether the user can control shared devices.
- ///
- EnableSharedDeviceControl = 3,
-
- ///
- /// Whether the user can access the server remotely.
- ///
- EnableRemoteAccess = 4,
-
- ///
- /// Whether the user can manage live tv.
- ///
- EnableLiveTvManagement = 5,
-
- ///
- /// Whether the user can access live tv.
- ///
- EnableLiveTvAccess = 6,
-
- ///
- /// Whether the user can play media.
- ///
- EnableMediaPlayback = 7,
-
- ///
- /// Whether the server should transcode audio for the user if requested.
- ///
- EnableAudioPlaybackTranscoding = 8,
-
- ///
- /// Whether the server should transcode video for the user if requested.
- ///
- EnableVideoPlaybackTranscoding = 9,
-
- ///
- /// Whether the user can delete content.
- ///
- EnableContentDeletion = 10,
-
- ///
- /// Whether the user can download content.
- ///
- EnableContentDownloading = 11,
-
- ///
- /// Whether to enable sync transcoding for the user.
- ///
- EnableSyncTranscoding = 12,
-
- ///
- /// Whether the user can do media conversion.
- ///
- EnableMediaConversion = 13,
-
- ///
- /// Whether the user has access to all devices.
- ///
- EnableAllDevices = 14,
-
- ///
- /// Whether the user has access to all channels.
- ///
- EnableAllChannels = 15,
-
- ///
- /// Whether the user has access to all folders.
- ///
- EnableAllFolders = 16,
-
- ///
- /// Whether to enable public sharing for the user.
- ///
- EnablePublicSharing = 17,
-
- ///
- /// Whether the user can remotely control other users.
- ///
- EnableRemoteControlOfOtherUsers = 18,
-
- ///
- /// Whether the user is permitted to do playback remuxing.
- ///
- EnablePlaybackRemuxing = 19,
-
- ///
- /// Whether the server should force transcoding on remote connections for the user.
- ///
- ForceRemoteSourceTranscoding = 20,
-
- ///
- /// Whether the user can create, modify and delete collections.
- ///
- EnableCollectionManagement = 21,
-
- ///
- /// Whether the user can edit subtitles.
- ///
- EnableSubtitleManagement = 22,
-
- ///
- /// Whether the user can edit lyrics.
- ///
- EnableLyricManagement = 23,
- }
-}
diff --git a/Jellyfin.Data/Enums/PersonRoleType.cs b/Jellyfin.Data/Enums/PersonRoleType.cs
deleted file mode 100644
index 1e619f5eef..0000000000
--- a/Jellyfin.Data/Enums/PersonRoleType.cs
+++ /dev/null
@@ -1,68 +0,0 @@
-namespace Jellyfin.Data.Enums
-{
- ///
- /// An enum representing a person's role in a specific media item.
- ///
- public enum PersonRoleType
- {
- ///
- /// Another role, not covered by the other types.
- ///
- Other = 0,
-
- ///
- /// The director of the media.
- ///
- Director = 1,
-
- ///
- /// An artist.
- ///
- Artist = 2,
-
- ///
- /// The original artist.
- ///
- OriginalArtist = 3,
-
- ///
- /// An actor.
- ///
- Actor = 4,
-
- ///
- /// A voice actor.
- ///
- VoiceActor = 5,
-
- ///
- /// A producer.
- ///
- Producer = 6,
-
- ///
- /// A remixer.
- ///
- Remixer = 7,
-
- ///
- /// A conductor.
- ///
- Conductor = 8,
-
- ///
- /// A composer.
- ///
- Composer = 9,
-
- ///
- /// An author.
- ///
- Author = 10,
-
- ///
- /// An editor.
- ///
- Editor = 11
- }
-}
diff --git a/Jellyfin.Data/Enums/PreferenceKind.cs b/Jellyfin.Data/Enums/PreferenceKind.cs
deleted file mode 100644
index d2b412e459..0000000000
--- a/Jellyfin.Data/Enums/PreferenceKind.cs
+++ /dev/null
@@ -1,73 +0,0 @@
-namespace Jellyfin.Data.Enums
-{
- ///
- /// The types of user preferences.
- ///
- public enum PreferenceKind
- {
- ///
- /// A list of blocked tags.
- ///
- BlockedTags = 0,
-
- ///
- /// A list of blocked channels.
- ///
- BlockedChannels = 1,
-
- ///
- /// A list of blocked media folders.
- ///
- BlockedMediaFolders = 2,
-
- ///
- /// A list of enabled devices.
- ///
- EnabledDevices = 3,
-
- ///
- /// A list of enabled channels.
- ///
- EnabledChannels = 4,
-
- ///
- /// A list of enabled folders.
- ///
- EnabledFolders = 5,
-
- ///
- /// A list of folders to allow content deletion from.
- ///
- EnableContentDeletionFromFolders = 6,
-
- ///
- /// A list of latest items to exclude.
- ///
- LatestItemExcludes = 7,
-
- ///
- /// A list of media to exclude.
- ///
- MyMediaExcludes = 8,
-
- ///
- /// A list of grouped folders.
- ///
- GroupedFolders = 9,
-
- ///
- /// A list of unrated items to block.
- ///
- BlockUnratedItems = 10,
-
- ///
- /// A list of ordered views.
- ///
- OrderedViews = 11,
-
- ///
- /// A list of allowed tags.
- ///
- AllowedTags = 12
- }
-}
diff --git a/Jellyfin.Data/Enums/ScrollDirection.cs b/Jellyfin.Data/Enums/ScrollDirection.cs
deleted file mode 100644
index 29c50e2c4e..0000000000
--- a/Jellyfin.Data/Enums/ScrollDirection.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-namespace Jellyfin.Data.Enums
-{
- ///
- /// An enum representing the axis that should be scrolled.
- ///
- public enum ScrollDirection
- {
- ///
- /// Horizontal scrolling direction.
- ///
- Horizontal = 0,
-
- ///
- /// Vertical scrolling direction.
- ///
- Vertical = 1
- }
-}
diff --git a/Jellyfin.Data/Enums/SortOrder.cs b/Jellyfin.Data/Enums/SortOrder.cs
deleted file mode 100644
index 4151448e4e..0000000000
--- a/Jellyfin.Data/Enums/SortOrder.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-namespace Jellyfin.Data.Enums
-{
- ///
- /// An enum representing the sorting order.
- ///
- public enum SortOrder
- {
- ///
- /// Sort in increasing order.
- ///
- Ascending = 0,
-
- ///
- /// Sort in decreasing order.
- ///
- Descending = 1
- }
-}
diff --git a/Jellyfin.Data/Enums/SubtitlePlaybackMode.cs b/Jellyfin.Data/Enums/SubtitlePlaybackMode.cs
deleted file mode 100644
index 79693d321a..0000000000
--- a/Jellyfin.Data/Enums/SubtitlePlaybackMode.cs
+++ /dev/null
@@ -1,33 +0,0 @@
-namespace Jellyfin.Data.Enums
-{
- ///
- /// An enum representing a subtitle playback mode.
- ///
- public enum SubtitlePlaybackMode
- {
- ///
- /// The default subtitle playback mode.
- ///
- Default = 0,
-
- ///
- /// Always show subtitles.
- ///
- Always = 1,
-
- ///
- /// Only show forced subtitles.
- ///
- OnlyForced = 2,
-
- ///
- /// Don't show subtitles.
- ///
- None = 3,
-
- ///
- /// Only show subtitles when the current audio stream is in a different language.
- ///
- Smart = 4
- }
-}
diff --git a/Jellyfin.Data/Enums/SyncPlayUserAccessType.cs b/Jellyfin.Data/Enums/SyncPlayUserAccessType.cs
deleted file mode 100644
index 030d16fb90..0000000000
--- a/Jellyfin.Data/Enums/SyncPlayUserAccessType.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-namespace Jellyfin.Data.Enums
-{
- ///
- /// Enum SyncPlayUserAccessType.
- ///
- public enum SyncPlayUserAccessType
- {
- ///
- /// User can create groups and join them.
- ///
- CreateAndJoinGroups = 0,
-
- ///
- /// User can only join already existing groups.
- ///
- JoinGroups = 1,
-
- ///
- /// SyncPlay is disabled for the user.
- ///
- None = 2
- }
-}
diff --git a/Jellyfin.Data/Enums/VideoRangeType.cs b/Jellyfin.Data/Enums/VideoRangeType.cs
index 853c2c73db..ce232d73c3 100644
--- a/Jellyfin.Data/Enums/VideoRangeType.cs
+++ b/Jellyfin.Data/Enums/VideoRangeType.cs
@@ -45,6 +45,27 @@ public enum VideoRangeType
///
DOVIWithSDR,
+ ///
+ /// Dolby Vision with Enhancment Layer (Profile 7).
+ ///
+ DOVIWithEL,
+
+ ///
+ /// Dolby Vision and HDR10+ Metadata coexists.
+ ///
+ DOVIWithHDR10Plus,
+
+ ///
+ /// Dolby Vision with Enhancment Layer (Profile 7) and HDR10+ Metadata coexists.
+ ///
+ DOVIWithELHDR10Plus,
+
+ ///
+ /// Dolby Vision with invalid configuration. e.g. Profile 8 compat id 6.
+ /// When using this range, the server would assume the video is still HDR10 after removing the Dolby Vision metadata.
+ ///
+ DOVIInvalid,
+
///
/// HDR10+ video range type (10bit to 16bit).
///
diff --git a/Jellyfin.Data/Enums/ViewType.cs b/Jellyfin.Data/Enums/ViewType.cs
deleted file mode 100644
index c0fd7d448b..0000000000
--- a/Jellyfin.Data/Enums/ViewType.cs
+++ /dev/null
@@ -1,113 +0,0 @@
-namespace Jellyfin.Data.Enums
-{
- ///
- /// An enum representing the type of view for a library or collection.
- ///
- public enum ViewType
- {
- ///
- /// Shows albums.
- ///
- Albums = 0,
-
- ///
- /// Shows album artists.
- ///
- AlbumArtists = 1,
-
- ///
- /// Shows artists.
- ///
- Artists = 2,
-
- ///
- /// Shows channels.
- ///
- Channels = 3,
-
- ///
- /// Shows collections.
- ///
- Collections = 4,
-
- ///
- /// Shows episodes.
- ///
- Episodes = 5,
-
- ///
- /// Shows favorites.
- ///
- Favorites = 6,
-
- ///
- /// Shows genres.
- ///
- Genres = 7,
-
- ///
- /// Shows guide.
- ///
- Guide = 8,
-
- ///
- /// Shows movies.
- ///
- Movies = 9,
-
- ///
- /// Shows networks.
- ///
- Networks = 10,
-
- ///
- /// Shows playlists.
- ///
- Playlists = 11,
-
- ///
- /// Shows programs.
- ///
- Programs = 12,
-
- ///
- /// Shows recordings.
- ///
- Recordings = 13,
-
- ///
- /// Shows schedule.
- ///
- Schedule = 14,
-
- ///
- /// Shows series.
- ///
- Series = 15,
-
- ///
- /// Shows shows.
- ///
- Shows = 16,
-
- ///
- /// Shows songs.
- ///
- Songs = 17,
-
- ///
- /// Shows songs.
- ///
- Suggestions = 18,
-
- ///
- /// Shows trailers.
- ///
- Trailers = 19,
-
- ///
- /// Shows upcoming.
- ///
- Upcoming = 20
- }
-}
diff --git a/Jellyfin.Data/Events/Users/UserCreatedEventArgs.cs b/Jellyfin.Data/Events/Users/UserCreatedEventArgs.cs
index b3b8d28318..8de34fec2c 100644
--- a/Jellyfin.Data/Events/Users/UserCreatedEventArgs.cs
+++ b/Jellyfin.Data/Events/Users/UserCreatedEventArgs.cs
@@ -1,4 +1,4 @@
-using Jellyfin.Data.Entities;
+using Jellyfin.Database.Implementations.Entities;
namespace Jellyfin.Data.Events.Users
{
diff --git a/Jellyfin.Data/Events/Users/UserDeletedEventArgs.cs b/Jellyfin.Data/Events/Users/UserDeletedEventArgs.cs
index d57c917c9f..c85de34ded 100644
--- a/Jellyfin.Data/Events/Users/UserDeletedEventArgs.cs
+++ b/Jellyfin.Data/Events/Users/UserDeletedEventArgs.cs
@@ -1,4 +1,4 @@
-using Jellyfin.Data.Entities;
+using Jellyfin.Database.Implementations.Entities;
namespace Jellyfin.Data.Events.Users
{
diff --git a/Jellyfin.Data/Events/Users/UserLockedOutEventArgs.cs b/Jellyfin.Data/Events/Users/UserLockedOutEventArgs.cs
index 4475948219..46b399d26d 100644
--- a/Jellyfin.Data/Events/Users/UserLockedOutEventArgs.cs
+++ b/Jellyfin.Data/Events/Users/UserLockedOutEventArgs.cs
@@ -1,4 +1,4 @@
-using Jellyfin.Data.Entities;
+using Jellyfin.Database.Implementations.Entities;
namespace Jellyfin.Data.Events.Users
{
diff --git a/Jellyfin.Data/Events/Users/UserPasswordChangedEventArgs.cs b/Jellyfin.Data/Events/Users/UserPasswordChangedEventArgs.cs
index a235ccada9..ee41147d5d 100644
--- a/Jellyfin.Data/Events/Users/UserPasswordChangedEventArgs.cs
+++ b/Jellyfin.Data/Events/Users/UserPasswordChangedEventArgs.cs
@@ -1,4 +1,4 @@
-using Jellyfin.Data.Entities;
+using Jellyfin.Database.Implementations.Entities;
namespace Jellyfin.Data.Events.Users
{
diff --git a/Jellyfin.Data/Events/Users/UserUpdatedEventArgs.cs b/Jellyfin.Data/Events/Users/UserUpdatedEventArgs.cs
index 780ace6abe..0f2763f366 100644
--- a/Jellyfin.Data/Events/Users/UserUpdatedEventArgs.cs
+++ b/Jellyfin.Data/Events/Users/UserUpdatedEventArgs.cs
@@ -1,4 +1,4 @@
-using Jellyfin.Data.Entities;
+using Jellyfin.Database.Implementations.Entities;
namespace Jellyfin.Data.Events.Users
{
diff --git a/Jellyfin.Data/Interfaces/IHasConcurrencyToken.cs b/Jellyfin.Data/Interfaces/IHasConcurrencyToken.cs
deleted file mode 100644
index 2c4091493e..0000000000
--- a/Jellyfin.Data/Interfaces/IHasConcurrencyToken.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-namespace Jellyfin.Data.Interfaces
-{
- ///
- /// An interface abstracting an entity that has a concurrency token.
- ///
- public interface IHasConcurrencyToken
- {
- ///
- /// Gets the version of this row. Acts as a concurrency token.
- ///
- uint RowVersion { get; }
-
- ///
- /// Called when saving changes to this entity.
- ///
- void OnSavingChanges();
- }
-}
diff --git a/Jellyfin.Data/Interfaces/IHasPermissions.cs b/Jellyfin.Data/Interfaces/IHasPermissions.cs
deleted file mode 100644
index bf8ec9d887..0000000000
--- a/Jellyfin.Data/Interfaces/IHasPermissions.cs
+++ /dev/null
@@ -1,31 +0,0 @@
-using System.Collections.Generic;
-using Jellyfin.Data.Entities;
-using Jellyfin.Data.Enums;
-
-namespace Jellyfin.Data.Interfaces
-{
- ///
- /// An abstraction representing an entity that has permissions.
- ///
- public interface IHasPermissions
- {
- ///
- /// Gets a collection containing this entity's permissions.
- ///
- ICollection Permissions { get; }
-
- ///
- /// Checks whether this entity has the specified permission kind.
- ///
- /// The kind of permission.
- /// true if this entity has the specified permission, false otherwise.
- bool HasPermission(PermissionKind kind);
-
- ///
- /// Sets the specified permission to the provided value.
- ///
- /// The kind of permission.
- /// The value to set.
- void SetPermission(PermissionKind kind, bool value);
- }
-}
diff --git a/Jellyfin.Data/Interfaces/IHasReleases.cs b/Jellyfin.Data/Interfaces/IHasReleases.cs
deleted file mode 100644
index 3b615893ed..0000000000
--- a/Jellyfin.Data/Interfaces/IHasReleases.cs
+++ /dev/null
@@ -1,16 +0,0 @@
-using System.Collections.Generic;
-using Jellyfin.Data.Entities.Libraries;
-
-namespace Jellyfin.Data.Interfaces
-{
- ///
- /// An abstraction representing an entity that has releases.
- ///
- public interface IHasReleases
- {
- ///
- /// Gets a collection containing this entity's releases.
- ///
- ICollection Releases { get; }
- }
-}
diff --git a/Jellyfin.Data/Jellyfin.Data.csproj b/Jellyfin.Data/Jellyfin.Data.csproj
index e24e37740d..45374c22f7 100644
--- a/Jellyfin.Data/Jellyfin.Data.csproj
+++ b/Jellyfin.Data/Jellyfin.Data.csproj
@@ -1,7 +1,7 @@
- net8.0
+ net9.0
false
true
true
@@ -18,7 +18,7 @@
Jellyfin Contributors
Jellyfin.Data
- 10.10.0
+ 10.11.0
https://github.com/jellyfin/jellyfin
GPL-3.0-only
@@ -38,6 +38,10 @@
+
+
+
+
diff --git a/Jellyfin.Data/UserEntityExtensions.cs b/Jellyfin.Data/UserEntityExtensions.cs
new file mode 100644
index 0000000000..149fc9042d
--- /dev/null
+++ b/Jellyfin.Data/UserEntityExtensions.cs
@@ -0,0 +1,220 @@
+using System;
+using System.ComponentModel;
+using System.Linq;
+using Jellyfin.Database.Implementations.Entities;
+using Jellyfin.Database.Implementations.Enums;
+using Jellyfin.Database.Implementations.Interfaces;
+
+namespace Jellyfin.Data;
+
+///
+/// Contains extension methods for manipulation of entities.
+///
+public static class UserEntityExtensions
+{
+ ///
+ /// The values being delimited here are Guids, so commas work as they do not appear in Guids.
+ ///
+ private const char Delimiter = ',';
+
+ ///
+ /// Checks whether the user has the specified permission.
+ ///
+ /// The entity to update.
+ /// The permission kind.
+ /// True if the user has the specified permission.
+ public static bool HasPermission(this IHasPermissions entity, PermissionKind kind)
+ {
+ return entity.Permissions.FirstOrDefault(p => p.Kind == kind)?.Value ?? false;
+ }
+
+ ///
+ /// Sets the given permission kind to the provided value.
+ ///
+ /// The entity to update.
+ /// The permission kind.
+ /// The value to set.
+ public static void SetPermission(this IHasPermissions entity, PermissionKind kind, bool value)
+ {
+ var currentPermission = entity.Permissions.FirstOrDefault(p => p.Kind == kind);
+ if (currentPermission is null)
+ {
+ entity.Permissions.Add(new Permission(kind, value));
+ }
+ else
+ {
+ currentPermission.Value = value;
+ }
+ }
+
+ ///
+ /// Gets the user's preferences for the given preference kind.
+ ///
+ /// The entity to update.
+ /// The preference kind.
+ /// A string array containing the user's preferences.
+ public static string[] GetPreference(this User entity, PreferenceKind preference)
+ {
+ var val = entity.Preferences.FirstOrDefault(p => p.Kind == preference)?.Value;
+
+ return string.IsNullOrEmpty(val) ? Array.Empty() : val.Split(Delimiter);
+ }
+
+ ///
+ /// Gets the user's preferences for the given preference kind.
+ ///
+ /// The entity to update.
+ /// The preference kind.
+ /// Type of preference.
+ /// A {T} array containing the user's preference.
+ public static T[] GetPreferenceValues(this User entity, PreferenceKind preference)
+ {
+ var val = entity.Preferences.FirstOrDefault(p => p.Kind == preference)?.Value;
+ if (string.IsNullOrEmpty(val))
+ {
+ return Array.Empty();
+ }
+
+ // Convert array of {string} to array of {T}
+ var converter = TypeDescriptor.GetConverter(typeof(T));
+ var stringValues = val.Split(Delimiter);
+ var convertedCount = 0;
+ var parsedValues = new T[stringValues.Length];
+ for (var i = 0; i < stringValues.Length; i++)
+ {
+ try
+ {
+ var parsedValue = converter.ConvertFromString(stringValues[i].Trim());
+ if (parsedValue is not null)
+ {
+ parsedValues[convertedCount++] = (T)parsedValue;
+ }
+ }
+ catch (FormatException)
+ {
+ // Unable to convert value
+ }
+ }
+
+ return parsedValues[..convertedCount];
+ }
+
+ ///
+ /// Sets the specified preference to the given value.
+ ///
+ /// The entity to update.
+ /// The preference kind.
+ /// The values.
+ public static void SetPreference(this User entity, PreferenceKind preference, string[] values)
+ {
+ var value = string.Join(Delimiter, values);
+ var currentPreference = entity.Preferences.FirstOrDefault(p => p.Kind == preference);
+ if (currentPreference is null)
+ {
+ entity.Preferences.Add(new Preference(preference, value));
+ }
+ else
+ {
+ currentPreference.Value = value;
+ }
+ }
+
+ ///
+ /// Sets the specified preference to the given value.
+ ///
+ /// The entity to update.
+ /// The preference kind.
+ /// The values.
+ /// The type of value.
+ public static void SetPreference(this User entity, PreferenceKind preference, T[] values)
+ {
+ var value = string.Join(Delimiter, values);
+ var currentPreference = entity.Preferences.FirstOrDefault(p => p.Kind == preference);
+ if (currentPreference is null)
+ {
+ entity.Preferences.Add(new Preference(preference, value));
+ }
+ else
+ {
+ currentPreference.Value = value;
+ }
+ }
+
+ ///
+ /// Checks whether this user is currently allowed to use the server.
+ ///
+ /// The entity to update.
+ /// True if the current time is within an access schedule, or there are no access schedules.
+ public static bool IsParentalScheduleAllowed(this User entity)
+ {
+ return entity.AccessSchedules.Count == 0
+ || entity.AccessSchedules.Any(i => IsParentalScheduleAllowed(i, DateTime.UtcNow));
+ }
+
+ ///
+ /// Checks whether the provided folder is in this user's grouped folders.
+ ///
+ /// The entity to update.
+ /// The Guid of the folder.
+ /// True if the folder is in the user's grouped folders.
+ public static bool IsFolderGrouped(this User entity, Guid id)
+ {
+ return Array.IndexOf(GetPreferenceValues(entity, PreferenceKind.GroupedFolders), id) != -1;
+ }
+
+ ///
+ /// Initializes the default permissions for a user. Should only be called on user creation.
+ ///
+ /// The entity to update.
+ // TODO: make these user configurable?
+ public static void AddDefaultPermissions(this User entity)
+ {
+ entity.Permissions.Add(new Permission(PermissionKind.IsAdministrator, false));
+ entity.Permissions.Add(new Permission(PermissionKind.IsDisabled, false));
+ entity.Permissions.Add(new Permission(PermissionKind.IsHidden, true));
+ entity.Permissions.Add(new Permission(PermissionKind.EnableAllChannels, true));
+ entity.Permissions.Add(new Permission(PermissionKind.EnableAllDevices, true));
+ entity.Permissions.Add(new Permission(PermissionKind.EnableAllFolders, true));
+ entity.Permissions.Add(new Permission(PermissionKind.EnableContentDeletion, false));
+ entity.Permissions.Add(new Permission(PermissionKind.EnableContentDownloading, true));
+ entity.Permissions.Add(new Permission(PermissionKind.EnableMediaConversion, true));
+ entity.Permissions.Add(new Permission(PermissionKind.EnableMediaPlayback, true));
+ entity.Permissions.Add(new Permission(PermissionKind.EnablePlaybackRemuxing, true));
+ entity.Permissions.Add(new Permission(PermissionKind.EnablePublicSharing, true));
+ entity.Permissions.Add(new Permission(PermissionKind.EnableRemoteAccess, true));
+ entity.Permissions.Add(new Permission(PermissionKind.EnableSyncTranscoding, true));
+ entity.Permissions.Add(new Permission(PermissionKind.EnableAudioPlaybackTranscoding, true));
+ entity.Permissions.Add(new Permission(PermissionKind.EnableLiveTvAccess, true));
+ entity.Permissions.Add(new Permission(PermissionKind.EnableLiveTvManagement, true));
+ entity.Permissions.Add(new Permission(PermissionKind.EnableSharedDeviceControl, true));
+ entity.Permissions.Add(new Permission(PermissionKind.EnableVideoPlaybackTranscoding, true));
+ entity.Permissions.Add(new Permission(PermissionKind.ForceRemoteSourceTranscoding, false));
+ entity.Permissions.Add(new Permission(PermissionKind.EnableRemoteControlOfOtherUsers, false));
+ entity.Permissions.Add(new Permission(PermissionKind.EnableCollectionManagement, false));
+ entity.Permissions.Add(new Permission(PermissionKind.EnableSubtitleManagement, false));
+ entity.Permissions.Add(new Permission(PermissionKind.EnableLyricManagement, false));
+ }
+
+ ///
+ /// Initializes the default preferences. Should only be called on user creation.
+ ///
+ /// The entity to update.
+ public static void AddDefaultPreferences(this User entity)
+ {
+ foreach (var val in Enum.GetValues())
+ {
+ entity.Preferences.Add(new Preference(val, string.Empty));
+ }
+ }
+
+ private static bool IsParentalScheduleAllowed(AccessSchedule schedule, DateTime date)
+ {
+ var localTime = date.ToLocalTime();
+ var hour = localTime.TimeOfDay.TotalHours;
+ var currentDayOfWeek = localTime.DayOfWeek;
+
+ return schedule.DayOfWeek.Contains(currentDayOfWeek)
+ && hour >= schedule.StartHour
+ && hour <= schedule.EndHour;
+ }
+}
diff --git a/Jellyfin.Server.Implementations/Activity/ActivityManager.cs b/Jellyfin.Server.Implementations/Activity/ActivityManager.cs
index 54272aeafa..8d492f7cd7 100644
--- a/Jellyfin.Server.Implementations/Activity/ActivityManager.cs
+++ b/Jellyfin.Server.Implementations/Activity/ActivityManager.cs
@@ -1,9 +1,10 @@
using System;
using System.Linq;
using System.Threading.Tasks;
-using Jellyfin.Data.Entities;
using Jellyfin.Data.Events;
using Jellyfin.Data.Queries;
+using Jellyfin.Database.Implementations;
+using Jellyfin.Database.Implementations.Entities;
using MediaBrowser.Model.Activity;
using MediaBrowser.Model.Querying;
using Microsoft.EntityFrameworkCore;
diff --git a/Jellyfin.Server.Implementations/DbConfiguration/DatabaseConfigurationFactory.cs b/Jellyfin.Server.Implementations/DbConfiguration/DatabaseConfigurationFactory.cs
new file mode 100644
index 0000000000..26d32f4173
--- /dev/null
+++ b/Jellyfin.Server.Implementations/DbConfiguration/DatabaseConfigurationFactory.cs
@@ -0,0 +1,17 @@
+using System;
+using System.Collections.Generic;
+using MediaBrowser.Common.Configuration;
+
+namespace Jellyfin.Server.Implementations.DatabaseConfiguration;
+
+///
+/// Factory for constructing a database configuration.
+///
+public class DatabaseConfigurationFactory : IConfigurationFactory
+{
+ ///
+ public IEnumerable GetConfigurations()
+ {
+ yield return new DatabaseConfigurationStore();
+ }
+}
diff --git a/Jellyfin.Server.Implementations/DbConfiguration/DatabaseConfigurationStore.cs b/Jellyfin.Server.Implementations/DbConfiguration/DatabaseConfigurationStore.cs
new file mode 100644
index 0000000000..537630561c
--- /dev/null
+++ b/Jellyfin.Server.Implementations/DbConfiguration/DatabaseConfigurationStore.cs
@@ -0,0 +1,26 @@
+using System;
+using System.Collections.Generic;
+using Jellyfin.Database.Implementations.DbConfiguration;
+using MediaBrowser.Common.Configuration;
+
+namespace Jellyfin.Server.Implementations.DatabaseConfiguration;
+
+///
+/// A configuration that stores database related settings.
+///
+public class DatabaseConfigurationStore : ConfigurationStore
+{
+ ///
+ /// The name of the configuration in the storage.
+ ///
+ public const string StoreKey = "database";
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public DatabaseConfigurationStore()
+ {
+ ConfigurationType = typeof(DatabaseConfigurationOptions);
+ Key = StoreKey;
+ }
+}
diff --git a/Jellyfin.Server.Implementations/Devices/DeviceManager.cs b/Jellyfin.Server.Implementations/Devices/DeviceManager.cs
index d3bff2936c..51a1186452 100644
--- a/Jellyfin.Server.Implementations/Devices/DeviceManager.cs
+++ b/Jellyfin.Server.Implementations/Devices/DeviceManager.cs
@@ -3,12 +3,14 @@ using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
+using Jellyfin.Data;
using Jellyfin.Data.Dtos;
-using Jellyfin.Data.Entities;
-using Jellyfin.Data.Entities.Security;
-using Jellyfin.Data.Enums;
using Jellyfin.Data.Events;
using Jellyfin.Data.Queries;
+using Jellyfin.Database.Implementations;
+using Jellyfin.Database.Implementations.Entities;
+using Jellyfin.Database.Implementations.Entities.Security;
+using Jellyfin.Database.Implementations.Enums;
using Jellyfin.Extensions;
using MediaBrowser.Common.Extensions;
using MediaBrowser.Controller.Devices;
diff --git a/Jellyfin.Server.Implementations/Events/Consumers/Library/LyricDownloadFailureLogger.cs b/Jellyfin.Server.Implementations/Events/Consumers/Library/LyricDownloadFailureLogger.cs
index 0d52bb9856..5f4864e953 100644
--- a/Jellyfin.Server.Implementations/Events/Consumers/Library/LyricDownloadFailureLogger.cs
+++ b/Jellyfin.Server.Implementations/Events/Consumers/Library/LyricDownloadFailureLogger.cs
@@ -1,7 +1,7 @@
using System;
using System.Globalization;
using System.Threading.Tasks;
-using Jellyfin.Data.Entities;
+using Jellyfin.Database.Implementations.Entities;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Audio;
using MediaBrowser.Controller.Events;
diff --git a/Jellyfin.Server.Implementations/Events/Consumers/Library/SubtitleDownloadFailureLogger.cs b/Jellyfin.Server.Implementations/Events/Consumers/Library/SubtitleDownloadFailureLogger.cs
index 0a8c064a99..8fe380e4f4 100644
--- a/Jellyfin.Server.Implementations/Events/Consumers/Library/SubtitleDownloadFailureLogger.cs
+++ b/Jellyfin.Server.Implementations/Events/Consumers/Library/SubtitleDownloadFailureLogger.cs
@@ -1,7 +1,7 @@
using System;
using System.Globalization;
using System.Threading.Tasks;
-using Jellyfin.Data.Entities;
+using Jellyfin.Database.Implementations.Entities;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Audio;
using MediaBrowser.Controller.Events;
diff --git a/Jellyfin.Server.Implementations/Events/Consumers/Security/AuthenticationFailedLogger.cs b/Jellyfin.Server.Implementations/Events/Consumers/Security/AuthenticationFailedLogger.cs
index a4424c7391..1a8931a6dc 100644
--- a/Jellyfin.Server.Implementations/Events/Consumers/Security/AuthenticationFailedLogger.cs
+++ b/Jellyfin.Server.Implementations/Events/Consumers/Security/AuthenticationFailedLogger.cs
@@ -1,7 +1,7 @@
using System;
using System.Globalization;
using System.Threading.Tasks;
-using Jellyfin.Data.Entities;
+using Jellyfin.Database.Implementations.Entities;
using MediaBrowser.Controller.Events;
using MediaBrowser.Controller.Events.Authentication;
using MediaBrowser.Model.Activity;
diff --git a/Jellyfin.Server.Implementations/Events/Consumers/Security/AuthenticationSucceededLogger.cs b/Jellyfin.Server.Implementations/Events/Consumers/Security/AuthenticationSucceededLogger.cs
index e0ecef2a5d..584d559e44 100644
--- a/Jellyfin.Server.Implementations/Events/Consumers/Security/AuthenticationSucceededLogger.cs
+++ b/Jellyfin.Server.Implementations/Events/Consumers/Security/AuthenticationSucceededLogger.cs
@@ -1,6 +1,6 @@
using System.Globalization;
using System.Threading.Tasks;
-using Jellyfin.Data.Entities;
+using Jellyfin.Database.Implementations.Entities;
using MediaBrowser.Controller.Events;
using MediaBrowser.Controller.Events.Authentication;
using MediaBrowser.Model.Activity;
diff --git a/Jellyfin.Server.Implementations/Events/Consumers/Session/PlaybackStartLogger.cs b/Jellyfin.Server.Implementations/Events/Consumers/Session/PlaybackStartLogger.cs
index 0ef929a99b..73323acb37 100644
--- a/Jellyfin.Server.Implementations/Events/Consumers/Session/PlaybackStartLogger.cs
+++ b/Jellyfin.Server.Implementations/Events/Consumers/Session/PlaybackStartLogger.cs
@@ -1,8 +1,8 @@
using System;
using System.Globalization;
using System.Threading.Tasks;
-using Jellyfin.Data.Entities;
using Jellyfin.Data.Enums;
+using Jellyfin.Database.Implementations.Entities;
using MediaBrowser.Controller.Events;
using MediaBrowser.Controller.Library;
using MediaBrowser.Model.Activity;
diff --git a/Jellyfin.Server.Implementations/Events/Consumers/Session/PlaybackStopLogger.cs b/Jellyfin.Server.Implementations/Events/Consumers/Session/PlaybackStopLogger.cs
index 7d452ea2fd..b75567539c 100644
--- a/Jellyfin.Server.Implementations/Events/Consumers/Session/PlaybackStopLogger.cs
+++ b/Jellyfin.Server.Implementations/Events/Consumers/Session/PlaybackStopLogger.cs
@@ -1,8 +1,8 @@
using System;
using System.Globalization;
using System.Threading.Tasks;
-using Jellyfin.Data.Entities;
using Jellyfin.Data.Enums;
+using Jellyfin.Database.Implementations.Entities;
using MediaBrowser.Controller.Events;
using MediaBrowser.Controller.Library;
using MediaBrowser.Model.Activity;
diff --git a/Jellyfin.Server.Implementations/Events/Consumers/Session/SessionEndedLogger.cs b/Jellyfin.Server.Implementations/Events/Consumers/Session/SessionEndedLogger.cs
index 77e7859c6f..b90708a2f2 100644
--- a/Jellyfin.Server.Implementations/Events/Consumers/Session/SessionEndedLogger.cs
+++ b/Jellyfin.Server.Implementations/Events/Consumers/Session/SessionEndedLogger.cs
@@ -1,6 +1,6 @@
using System.Globalization;
using System.Threading.Tasks;
-using Jellyfin.Data.Entities;
+using Jellyfin.Database.Implementations.Entities;
using MediaBrowser.Controller.Events;
using MediaBrowser.Controller.Events.Session;
using MediaBrowser.Model.Activity;
diff --git a/Jellyfin.Server.Implementations/Events/Consumers/Session/SessionStartedLogger.cs b/Jellyfin.Server.Implementations/Events/Consumers/Session/SessionStartedLogger.cs
index 141dc20ea3..139c2e2acb 100644
--- a/Jellyfin.Server.Implementations/Events/Consumers/Session/SessionStartedLogger.cs
+++ b/Jellyfin.Server.Implementations/Events/Consumers/Session/SessionStartedLogger.cs
@@ -1,6 +1,6 @@
using System.Globalization;
using System.Threading.Tasks;
-using Jellyfin.Data.Entities;
+using Jellyfin.Database.Implementations.Entities;
using MediaBrowser.Controller.Events;
using MediaBrowser.Controller.Events.Session;
using MediaBrowser.Model.Activity;
diff --git a/Jellyfin.Server.Implementations/Events/Consumers/System/TaskCompletedLogger.cs b/Jellyfin.Server.Implementations/Events/Consumers/System/TaskCompletedLogger.cs
index b0a9393eb6..da82a3b30f 100644
--- a/Jellyfin.Server.Implementations/Events/Consumers/System/TaskCompletedLogger.cs
+++ b/Jellyfin.Server.Implementations/Events/Consumers/System/TaskCompletedLogger.cs
@@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.Globalization;
using System.Text;
using System.Threading.Tasks;
-using Jellyfin.Data.Entities;
+using Jellyfin.Database.Implementations.Entities;
using MediaBrowser.Controller.Events;
using MediaBrowser.Model.Activity;
using MediaBrowser.Model.Globalization;
diff --git a/Jellyfin.Server.Implementations/Events/Consumers/Updates/PluginInstallationFailedLogger.cs b/Jellyfin.Server.Implementations/Events/Consumers/Updates/PluginInstallationFailedLogger.cs
index 0ae9b7f66f..632f30c7ad 100644
--- a/Jellyfin.Server.Implementations/Events/Consumers/Updates/PluginInstallationFailedLogger.cs
+++ b/Jellyfin.Server.Implementations/Events/Consumers/Updates/PluginInstallationFailedLogger.cs
@@ -1,7 +1,7 @@
using System;
using System.Globalization;
using System.Threading.Tasks;
-using Jellyfin.Data.Entities;
+using Jellyfin.Database.Implementations.Entities;
using MediaBrowser.Common.Updates;
using MediaBrowser.Controller.Events;
using MediaBrowser.Model.Activity;
diff --git a/Jellyfin.Server.Implementations/Events/Consumers/Updates/PluginInstalledLogger.cs b/Jellyfin.Server.Implementations/Events/Consumers/Updates/PluginInstalledLogger.cs
index 287ba578ba..4b49b714cf 100644
--- a/Jellyfin.Server.Implementations/Events/Consumers/Updates/PluginInstalledLogger.cs
+++ b/Jellyfin.Server.Implementations/Events/Consumers/Updates/PluginInstalledLogger.cs
@@ -1,7 +1,7 @@
using System;
using System.Globalization;
using System.Threading.Tasks;
-using Jellyfin.Data.Entities;
+using Jellyfin.Database.Implementations.Entities;
using MediaBrowser.Controller.Events;
using MediaBrowser.Controller.Events.Updates;
using MediaBrowser.Model.Activity;
diff --git a/Jellyfin.Server.Implementations/Events/Consumers/Updates/PluginUninstalledLogger.cs b/Jellyfin.Server.Implementations/Events/Consumers/Updates/PluginUninstalledLogger.cs
index 2de207b152..2d24de7fc6 100644
--- a/Jellyfin.Server.Implementations/Events/Consumers/Updates/PluginUninstalledLogger.cs
+++ b/Jellyfin.Server.Implementations/Events/Consumers/Updates/PluginUninstalledLogger.cs
@@ -1,7 +1,7 @@
using System;
using System.Globalization;
using System.Threading.Tasks;
-using Jellyfin.Data.Entities;
+using Jellyfin.Database.Implementations.Entities;
using MediaBrowser.Controller.Events;
using MediaBrowser.Controller.Events.Updates;
using MediaBrowser.Model.Activity;
diff --git a/Jellyfin.Server.Implementations/Events/Consumers/Updates/PluginUpdatedLogger.cs b/Jellyfin.Server.Implementations/Events/Consumers/Updates/PluginUpdatedLogger.cs
index 08d6bf9c25..e892d3dd9a 100644
--- a/Jellyfin.Server.Implementations/Events/Consumers/Updates/PluginUpdatedLogger.cs
+++ b/Jellyfin.Server.Implementations/Events/Consumers/Updates/PluginUpdatedLogger.cs
@@ -1,7 +1,7 @@
using System;
using System.Globalization;
using System.Threading.Tasks;
-using Jellyfin.Data.Entities;
+using Jellyfin.Database.Implementations.Entities;
using MediaBrowser.Controller.Events;
using MediaBrowser.Controller.Events.Updates;
using MediaBrowser.Model.Activity;
diff --git a/Jellyfin.Server.Implementations/Events/Consumers/Users/UserCreatedLogger.cs b/Jellyfin.Server.Implementations/Events/Consumers/Users/UserCreatedLogger.cs
index a09c344f61..4f063f6a1b 100644
--- a/Jellyfin.Server.Implementations/Events/Consumers/Users/UserCreatedLogger.cs
+++ b/Jellyfin.Server.Implementations/Events/Consumers/Users/UserCreatedLogger.cs
@@ -1,7 +1,7 @@
using System.Globalization;
using System.Threading.Tasks;
-using Jellyfin.Data.Entities;
using Jellyfin.Data.Events.Users;
+using Jellyfin.Database.Implementations.Entities;
using MediaBrowser.Controller.Events;
using MediaBrowser.Model.Activity;
using MediaBrowser.Model.Globalization;
diff --git a/Jellyfin.Server.Implementations/Events/Consumers/Users/UserDeletedLogger.cs b/Jellyfin.Server.Implementations/Events/Consumers/Users/UserDeletedLogger.cs
index 46da8044a1..ba4a072e84 100644
--- a/Jellyfin.Server.Implementations/Events/Consumers/Users/UserDeletedLogger.cs
+++ b/Jellyfin.Server.Implementations/Events/Consumers/Users/UserDeletedLogger.cs
@@ -1,8 +1,8 @@
using System;
using System.Globalization;
using System.Threading.Tasks;
-using Jellyfin.Data.Entities;
using Jellyfin.Data.Events.Users;
+using Jellyfin.Database.Implementations.Entities;
using MediaBrowser.Controller.Events;
using MediaBrowser.Model.Activity;
using MediaBrowser.Model.Globalization;
diff --git a/Jellyfin.Server.Implementations/Events/Consumers/Users/UserLockedOutLogger.cs b/Jellyfin.Server.Implementations/Events/Consumers/Users/UserLockedOutLogger.cs
index 1d0d016a74..bbc00567d1 100644
--- a/Jellyfin.Server.Implementations/Events/Consumers/Users/UserLockedOutLogger.cs
+++ b/Jellyfin.Server.Implementations/Events/Consumers/Users/UserLockedOutLogger.cs
@@ -1,7 +1,7 @@
using System.Globalization;
using System.Threading.Tasks;
-using Jellyfin.Data.Entities;
using Jellyfin.Data.Events.Users;
+using Jellyfin.Database.Implementations.Entities;
using MediaBrowser.Controller.Events;
using MediaBrowser.Model.Activity;
using MediaBrowser.Model.Globalization;
diff --git a/Jellyfin.Server.Implementations/Events/Consumers/Users/UserPasswordChangedLogger.cs b/Jellyfin.Server.Implementations/Events/Consumers/Users/UserPasswordChangedLogger.cs
index 2b8f966a80..7219704ec6 100644
--- a/Jellyfin.Server.Implementations/Events/Consumers/Users/UserPasswordChangedLogger.cs
+++ b/Jellyfin.Server.Implementations/Events/Consumers/Users/UserPasswordChangedLogger.cs
@@ -1,7 +1,7 @@
using System.Globalization;
using System.Threading.Tasks;
-using Jellyfin.Data.Entities;
using Jellyfin.Data.Events.Users;
+using Jellyfin.Database.Implementations.Entities;
using MediaBrowser.Controller.Events;
using MediaBrowser.Model.Activity;
using MediaBrowser.Model.Globalization;
diff --git a/Jellyfin.Server.Implementations/Extensions/ExpressionExtensions.cs b/Jellyfin.Server.Implementations/Extensions/ExpressionExtensions.cs
new file mode 100644
index 0000000000..d70ac672f2
--- /dev/null
+++ b/Jellyfin.Server.Implementations/Extensions/ExpressionExtensions.cs
@@ -0,0 +1,70 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Linq.Expressions;
+
+namespace Jellyfin.Server.Implementations.Extensions;
+
+///
+/// Provides extension methods.
+///
+public static class ExpressionExtensions
+{
+ ///
+ /// Combines two predicates into a single predicate using a logical OR operation.
+ ///
+ /// The predicate parameter type.
+ /// The first predicate expression to combine.
+ /// The second predicate expression to combine.
+ /// A new expression representing the OR combination of the input predicates.
+ public static Expression> Or(this Expression> firstPredicate, Expression> secondPredicate)
+ {
+ ArgumentNullException.ThrowIfNull(firstPredicate);
+ ArgumentNullException.ThrowIfNull(secondPredicate);
+
+ var invokedExpression = Expression.Invoke(secondPredicate, firstPredicate.Parameters);
+ return Expression.Lambda>(Expression.OrElse(firstPredicate.Body, invokedExpression), firstPredicate.Parameters);
+ }
+
+ ///
+ /// Combines multiple predicates into a single predicate using a logical OR operation.
+ ///
+ /// The predicate parameter type.
+ /// A collection of predicate expressions to combine.
+ /// A new expression representing the OR combination of all input predicates.
+ public static Expression> Or(this IEnumerable>> predicates)
+ {
+ ArgumentNullException.ThrowIfNull(predicates);
+
+ return predicates.Aggregate((aggregatePredicate, nextPredicate) => aggregatePredicate.Or(nextPredicate));
+ }
+
+ ///
+ /// Combines two predicates into a single predicate using a logical AND operation.
+ ///
+ /// The predicate parameter type.
+ /// The first predicate expression to combine.
+ /// The second predicate expression to combine.
+ /// A new expression representing the AND combination of the input predicates.
+ public static Expression> And(this Expression> firstPredicate, Expression> secondPredicate)
+ {
+ ArgumentNullException.ThrowIfNull(firstPredicate);
+ ArgumentNullException.ThrowIfNull(secondPredicate);
+
+ var invokedExpression = Expression.Invoke(secondPredicate, firstPredicate.Parameters);
+ return Expression.Lambda>(Expression.AndAlso(firstPredicate.Body, invokedExpression), firstPredicate.Parameters);
+ }
+
+ ///
+ /// Combines multiple predicates into a single predicate using a logical AND operation.
+ ///
+ /// The predicate parameter type.
+ /// A collection of predicate expressions to combine.
+ /// A new expression representing the AND combination of all input predicates.
+ public static Expression> And(this IEnumerable>> predicates)
+ {
+ ArgumentNullException.ThrowIfNull(predicates);
+
+ return predicates.Aggregate((aggregatePredicate, nextPredicate) => aggregatePredicate.And(nextPredicate));
+ }
+}
diff --git a/Jellyfin.Server.Implementations/Extensions/ServiceCollectionExtensions.cs b/Jellyfin.Server.Implementations/Extensions/ServiceCollectionExtensions.cs
index ddb393d675..fbbb5bca73 100644
--- a/Jellyfin.Server.Implementations/Extensions/ServiceCollectionExtensions.cs
+++ b/Jellyfin.Server.Implementations/Extensions/ServiceCollectionExtensions.cs
@@ -1,8 +1,15 @@
using System;
-using System.IO;
+using System.Collections.Generic;
+using System.Reflection;
+using Jellyfin.Database.Implementations;
+using Jellyfin.Database.Implementations.DbConfiguration;
+using Jellyfin.Database.Providers.Sqlite;
using MediaBrowser.Common.Configuration;
+using MediaBrowser.Controller.Configuration;
using Microsoft.EntityFrameworkCore;
+using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
+using JellyfinDbProviderFactory = System.Func;
namespace Jellyfin.Server.Implementations.Extensions;
@@ -11,17 +18,77 @@ namespace Jellyfin.Server.Implementations.Extensions;
///
public static class ServiceCollectionExtensions
{
+ private static IEnumerable DatabaseProviderTypes()
+ {
+ yield return typeof(SqliteDatabaseProvider);
+ }
+
+ private static IDictionary GetSupportedDbProviders()
+ {
+ var items = new Dictionary(StringComparer.InvariantCultureIgnoreCase);
+ foreach (var providerType in DatabaseProviderTypes())
+ {
+ var keyAttribute = providerType.GetCustomAttribute();
+ if (keyAttribute is null || string.IsNullOrWhiteSpace(keyAttribute.DatabaseProviderKey))
+ {
+ continue;
+ }
+
+ var provider = providerType;
+ items[keyAttribute.DatabaseProviderKey] = (services) => (IJellyfinDatabaseProvider)ActivatorUtilities.CreateInstance(services, providerType);
+ }
+
+ return items;
+ }
+
///
/// Adds the interface to the service collection with second level caching enabled.
///
/// An instance of the interface.
+ /// The server configuration manager.
+ /// The startup Configuration.
/// The updated service collection.
- public static IServiceCollection AddJellyfinDbContext(this IServiceCollection serviceCollection)
+ public static IServiceCollection AddJellyfinDbContext(
+ this IServiceCollection serviceCollection,
+ IServerConfigurationManager configurationManager,
+ IConfiguration configuration)
{
+ var efCoreConfiguration = configurationManager.GetConfiguration("database");
+ var providers = GetSupportedDbProviders();
+ JellyfinDbProviderFactory? providerFactory = null;
+
+ if (efCoreConfiguration?.DatabaseType is null)
+ {
+ var cmdMigrationArgument = configuration.GetValue("migration-provider");
+ if (!string.IsNullOrWhiteSpace(cmdMigrationArgument))
+ {
+ efCoreConfiguration = new DatabaseConfigurationOptions()
+ {
+ DatabaseType = cmdMigrationArgument,
+ };
+ }
+ else
+ {
+ // when nothing is setup via new Database configuration, fallback to SQLite with default settings.
+ efCoreConfiguration = new DatabaseConfigurationOptions()
+ {
+ DatabaseType = "Jellyfin-SQLite",
+ };
+ configurationManager.SaveConfiguration("database", efCoreConfiguration);
+ }
+ }
+
+ if (!providers.TryGetValue(efCoreConfiguration.DatabaseType.ToUpperInvariant(), out providerFactory!))
+ {
+ throw new InvalidOperationException($"Jellyfin cannot find the database provider of type '{efCoreConfiguration.DatabaseType}'. Supported types are {string.Join(", ", providers.Keys)}");
+ }
+
+ serviceCollection.AddSingleton(providerFactory!);
+
serviceCollection.AddPooledDbContextFactory((serviceProvider, opt) =>
{
- var applicationPaths = serviceProvider.GetRequiredService();
- opt.UseSqlite($"Filename={Path.Combine(applicationPaths.DataPath, "jellyfin.db")}");
+ var provider = serviceProvider.GetRequiredService();
+ provider.Initialise(opt);
});
return serviceCollection;
diff --git a/Jellyfin.Server.Implementations/Item/BaseItemRepository.cs b/Jellyfin.Server.Implementations/Item/BaseItemRepository.cs
new file mode 100644
index 0000000000..7f4364cf61
--- /dev/null
+++ b/Jellyfin.Server.Implementations/Item/BaseItemRepository.cs
@@ -0,0 +1,2232 @@
+#pragma warning disable RS0030 // Do not use banned APIs
+// Do not enforce that because EFCore cannot deal with cultures well.
+#pragma warning disable CA1304 // Specify CultureInfo
+#pragma warning disable CA1311 // Specify a culture or use an invariant version
+#pragma warning disable CA1862 // Use the 'StringComparison' method overloads to perform case-insensitive string comparisons
+
+using System;
+using System.Collections.Concurrent;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Linq.Expressions;
+using System.Reflection;
+using System.Text;
+using System.Text.Json;
+using System.Threading;
+using Jellyfin.Data.Enums;
+using Jellyfin.Database.Implementations;
+using Jellyfin.Database.Implementations.Entities;
+using Jellyfin.Database.Implementations.Enums;
+using Jellyfin.Extensions;
+using Jellyfin.Extensions.Json;
+using Jellyfin.Server.Implementations.Extensions;
+using MediaBrowser.Common;
+using MediaBrowser.Controller;
+using MediaBrowser.Controller.Channels;
+using MediaBrowser.Controller.Configuration;
+using MediaBrowser.Controller.Entities;
+using MediaBrowser.Controller.Entities.Audio;
+using MediaBrowser.Controller.Entities.TV;
+using MediaBrowser.Controller.LiveTv;
+using MediaBrowser.Controller.Persistence;
+using MediaBrowser.Model.Dto;
+using MediaBrowser.Model.Entities;
+using MediaBrowser.Model.LiveTv;
+using MediaBrowser.Model.Querying;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.Extensions.Logging;
+using BaseItemDto = MediaBrowser.Controller.Entities.BaseItem;
+using BaseItemEntity = Jellyfin.Database.Implementations.Entities.BaseItemEntity;
+
+namespace Jellyfin.Server.Implementations.Item;
+
+/*
+ All queries in this class and all other nullable enabled EFCore repository classes will make liberal use of the null-forgiving operator "!".
+ This is done as the code isn't actually executed client side, but only the expressions are interpret and the compiler cannot know that.
+ This is your only warning/message regarding this topic.
+*/
+
+///
+/// Handles all storage logic for BaseItems.
+///
+public sealed class BaseItemRepository
+ : IItemRepository
+{
+ ///
+ /// This holds all the types in the running assemblies
+ /// so that we can de-serialize properly when we don't have strong types.
+ ///
+ private static readonly ConcurrentDictionary _typeMap = new ConcurrentDictionary();
+ private readonly IDbContextFactory _dbProvider;
+ private readonly IServerApplicationHost _appHost;
+ private readonly IItemTypeLookup _itemTypeLookup;
+ private readonly IServerConfigurationManager _serverConfigurationManager;
+ private readonly ILogger _logger;
+
+ private static readonly IReadOnlyList _getAllArtistsValueTypes = [ItemValueType.Artist, ItemValueType.AlbumArtist];
+ private static readonly IReadOnlyList _getArtistValueTypes = [ItemValueType.Artist];
+ private static readonly IReadOnlyList _getAlbumArtistValueTypes = [ItemValueType.AlbumArtist];
+ private static readonly IReadOnlyList _getStudiosValueTypes = [ItemValueType.Studios];
+ private static readonly IReadOnlyList _getGenreValueTypes = [ItemValueType.Genre];
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The db factory.
+ /// The Application host.
+ /// The static type lookup.
+ /// The server Configuration manager.
+ /// System logger.
+ public BaseItemRepository(
+ IDbContextFactory dbProvider,
+ IServerApplicationHost appHost,
+ IItemTypeLookup itemTypeLookup,
+ IServerConfigurationManager serverConfigurationManager,
+ ILogger logger)
+ {
+ _dbProvider = dbProvider;
+ _appHost = appHost;
+ _itemTypeLookup = itemTypeLookup;
+ _serverConfigurationManager = serverConfigurationManager;
+ _logger = logger;
+ }
+
+ ///
+ public void DeleteItem(Guid id)
+ {
+ if (id.IsEmpty())
+ {
+ throw new ArgumentException("Guid can't be empty", nameof(id));
+ }
+
+ using var context = _dbProvider.CreateDbContext();
+ using var transaction = context.Database.BeginTransaction();
+ context.AncestorIds.Where(e => e.ItemId == id || e.ParentItemId == id).ExecuteDelete();
+ context.AttachmentStreamInfos.Where(e => e.ItemId == id).ExecuteDelete();
+ context.BaseItemImageInfos.Where(e => e.ItemId == id).ExecuteDelete();
+ context.BaseItemMetadataFields.Where(e => e.ItemId == id).ExecuteDelete();
+ context.BaseItemProviders.Where(e => e.ItemId == id).ExecuteDelete();
+ context.BaseItemTrailerTypes.Where(e => e.ItemId == id).ExecuteDelete();
+ context.BaseItems.Where(e => e.Id == id).ExecuteDelete();
+ context.Chapters.Where(e => e.ItemId == id).ExecuteDelete();
+ context.CustomItemDisplayPreferences.Where(e => e.ItemId == id).ExecuteDelete();
+ context.ItemDisplayPreferences.Where(e => e.ItemId == id).ExecuteDelete();
+ context.ItemValues.Where(e => e.BaseItemsMap!.Count == 0).ExecuteDelete();
+ context.ItemValuesMap.Where(e => e.ItemId == id).ExecuteDelete();
+ context.KeyframeData.Where(e => e.ItemId == id).ExecuteDelete();
+ context.MediaSegments.Where(e => e.ItemId == id).ExecuteDelete();
+ context.MediaStreamInfos.Where(e => e.ItemId == id).ExecuteDelete();
+ context.PeopleBaseItemMap.Where(e => e.ItemId == id).ExecuteDelete();
+ context.Peoples.Where(e => e.BaseItems!.Count == 0).ExecuteDelete();
+ context.TrickplayInfos.Where(e => e.ItemId == id).ExecuteDelete();
+ context.SaveChanges();
+ transaction.Commit();
+ }
+
+ ///
+ public void UpdateInheritedValues()
+ {
+ using var context = _dbProvider.CreateDbContext();
+ using var transaction = context.Database.BeginTransaction();
+
+ context.ItemValuesMap.Where(e => e.ItemValue.Type == ItemValueType.InheritedTags).ExecuteDelete();
+ // ItemValue Inheritance is now correctly mapped via AncestorId on demand
+ context.SaveChanges();
+
+ transaction.Commit();
+ }
+
+ ///
+ public IReadOnlyList GetItemIdsList(InternalItemsQuery filter)
+ {
+ ArgumentNullException.ThrowIfNull(filter);
+ PrepareFilterQuery(filter);
+
+ using var context = _dbProvider.CreateDbContext();
+ return ApplyQueryFilter(context.BaseItems.AsNoTracking(), context, filter).Select(e => e.Id).ToArray();
+ }
+
+ ///
+ public QueryResult<(BaseItemDto Item, ItemCounts ItemCounts)> GetAllArtists(InternalItemsQuery filter)
+ {
+ return GetItemValues(filter, _getAllArtistsValueTypes, _itemTypeLookup.BaseItemKindNames[BaseItemKind.MusicArtist]);
+ }
+
+ ///
+ public QueryResult<(BaseItemDto Item, ItemCounts ItemCounts)> GetArtists(InternalItemsQuery filter)
+ {
+ return GetItemValues(filter, _getArtistValueTypes, _itemTypeLookup.BaseItemKindNames[BaseItemKind.MusicArtist]);
+ }
+
+ ///
+ public QueryResult<(BaseItemDto Item, ItemCounts ItemCounts)> GetAlbumArtists(InternalItemsQuery filter)
+ {
+ return GetItemValues(filter, _getAlbumArtistValueTypes, _itemTypeLookup.BaseItemKindNames[BaseItemKind.MusicArtist]);
+ }
+
+ ///
+ public QueryResult<(BaseItemDto Item, ItemCounts ItemCounts)> GetStudios(InternalItemsQuery filter)
+ {
+ return GetItemValues(filter, _getStudiosValueTypes, _itemTypeLookup.BaseItemKindNames[BaseItemKind.Studio]);
+ }
+
+ ///
+ public QueryResult<(BaseItemDto Item, ItemCounts ItemCounts)> GetGenres(InternalItemsQuery filter)
+ {
+ return GetItemValues(filter, _getGenreValueTypes, _itemTypeLookup.BaseItemKindNames[BaseItemKind.Genre]);
+ }
+
+ ///
+ public QueryResult<(BaseItemDto Item, ItemCounts ItemCounts)> GetMusicGenres(InternalItemsQuery filter)
+ {
+ return GetItemValues(filter, _getGenreValueTypes, _itemTypeLookup.BaseItemKindNames[BaseItemKind.MusicGenre]);
+ }
+
+ ///
+ public IReadOnlyList GetStudioNames()
+ {
+ return GetItemValueNames(_getStudiosValueTypes, [], []);
+ }
+
+ ///
+ public IReadOnlyList GetAllArtistNames()
+ {
+ return GetItemValueNames(_getAllArtistsValueTypes, [], []);
+ }
+
+ ///
+ public IReadOnlyList GetMusicGenreNames()
+ {
+ return GetItemValueNames(
+ _getGenreValueTypes,
+ _itemTypeLookup.MusicGenreTypes,
+ []);
+ }
+
+ ///
+ public IReadOnlyList GetGenreNames()
+ {
+ return GetItemValueNames(
+ _getGenreValueTypes,
+ [],
+ _itemTypeLookup.MusicGenreTypes);
+ }
+
+ ///
+ public QueryResult GetItems(InternalItemsQuery filter)
+ {
+ ArgumentNullException.ThrowIfNull(filter);
+ if (!filter.EnableTotalRecordCount || (!filter.Limit.HasValue && (filter.StartIndex ?? 0) == 0))
+ {
+ var returnList = GetItemList(filter);
+ return new QueryResult(
+ filter.StartIndex,
+ returnList.Count,
+ returnList);
+ }
+
+ PrepareFilterQuery(filter);
+ var result = new QueryResult();
+
+ using var context = _dbProvider.CreateDbContext();
+
+ IQueryable dbQuery = PrepareItemQuery(context, filter);
+
+ dbQuery = TranslateQuery(dbQuery, context, filter);
+ if (filter.EnableTotalRecordCount)
+ {
+ result.TotalRecordCount = dbQuery.Count();
+ }
+
+ dbQuery = ApplyGroupingFilter(dbQuery, filter);
+ dbQuery = ApplyQueryPaging(dbQuery, filter);
+
+ result.Items = dbQuery.AsEnumerable().Where(e => e is not null).Select(w => DeserialiseBaseItem(w, filter.SkipDeserialization)).ToArray();
+ result.StartIndex = filter.StartIndex ?? 0;
+ return result;
+ }
+
+ ///
+ public IReadOnlyList GetItemList(InternalItemsQuery filter)
+ {
+ ArgumentNullException.ThrowIfNull(filter);
+ PrepareFilterQuery(filter);
+
+ using var context = _dbProvider.CreateDbContext();
+ IQueryable dbQuery = PrepareItemQuery(context, filter);
+
+ dbQuery = TranslateQuery(dbQuery, context, filter);
+
+ dbQuery = ApplyGroupingFilter(dbQuery, filter);
+ dbQuery = ApplyQueryPaging(dbQuery, filter);
+
+ return dbQuery.AsEnumerable().Where(e => e is not null).Select(w => DeserialiseBaseItem(w, filter.SkipDeserialization)).ToArray();
+ }
+
+ ///
+ public IReadOnlyList GetLatestItemList(InternalItemsQuery filter, CollectionType collectionType)
+ {
+ ArgumentNullException.ThrowIfNull(filter);
+ PrepareFilterQuery(filter);
+
+ // Early exit if collection type is not tvshows or music
+ if (collectionType != CollectionType.tvshows && collectionType != CollectionType.music)
+ {
+ return Array.Empty();
+ }
+
+ using var context = _dbProvider.CreateDbContext();
+
+ // Subquery to group by SeriesNames/Album and get the max Date Created for each group.
+ var subquery = PrepareItemQuery(context, filter);
+ subquery = TranslateQuery(subquery, context, filter);
+ var subqueryGrouped = subquery.GroupBy(g => collectionType == CollectionType.tvshows ? g.SeriesName : g.Album)
+ .Select(g => new
+ {
+ Key = g.Key,
+ MaxDateCreated = g.Max(a => a.DateCreated)
+ })
+ .OrderByDescending(g => g.MaxDateCreated)
+ .Select(g => g);
+
+ if (filter.Limit.HasValue)
+ {
+ subqueryGrouped = subqueryGrouped.Take(filter.Limit.Value);
+ }
+
+ filter.Limit = null;
+
+ var mainquery = PrepareItemQuery(context, filter);
+ mainquery = TranslateQuery(mainquery, context, filter);
+ mainquery = mainquery.Where(g => g.DateCreated >= subqueryGrouped.Min(s => s.MaxDateCreated));
+ mainquery = ApplyGroupingFilter(mainquery, filter);
+ mainquery = ApplyQueryPaging(mainquery, filter);
+
+ return mainquery.AsEnumerable().Where(e => e is not null).Select(w => DeserialiseBaseItem(w, filter.SkipDeserialization)).ToArray();
+ }
+
+ ///
+ public IReadOnlyList GetNextUpSeriesKeys(InternalItemsQuery filter, DateTime dateCutoff)
+ {
+ ArgumentNullException.ThrowIfNull(filter);
+ ArgumentNullException.ThrowIfNull(filter.User);
+
+ using var context = _dbProvider.CreateDbContext();
+
+ var query = context.BaseItems
+ .AsNoTracking()
+ .Where(i => filter.TopParentIds.Contains(i.TopParentId!.Value))
+ .Where(i => i.Type == _itemTypeLookup.BaseItemKindNames[BaseItemKind.Episode])
+ .Join(
+ context.UserData.AsNoTracking(),
+ i => new { UserId = filter.User.Id, ItemId = i.Id },
+ u => new { UserId = u.UserId, ItemId = u.ItemId },
+ (entity, data) => new { Item = entity, UserData = data })
+ .GroupBy(g => g.Item.SeriesPresentationUniqueKey)
+ .Select(g => new { g.Key, LastPlayedDate = g.Max(u => u.UserData.LastPlayedDate) })
+ .Where(g => g.Key != null && g.LastPlayedDate != null && g.LastPlayedDate >= dateCutoff)
+ .OrderByDescending(g => g.LastPlayedDate)
+ .Select(g => g.Key!);
+
+ if (filter.Limit.HasValue)
+ {
+ query = query.Take(filter.Limit.Value);
+ }
+
+ return query.ToArray();
+ }
+
+ private IQueryable ApplyGroupingFilter(IQueryable dbQuery, InternalItemsQuery filter)
+ {
+ // This whole block is needed to filter duplicate entries on request
+ // for the time being it cannot be used because it would destroy the ordering
+ // this results in "duplicate" responses for queries that try to lookup individual series or multiple versions but
+ // for that case the invoker has to run a DistinctBy(e => e.PresentationUniqueKey) on their own
+
+ // var enableGroupByPresentationUniqueKey = EnableGroupByPresentationUniqueKey(filter);
+ // if (enableGroupByPresentationUniqueKey && filter.GroupBySeriesPresentationUniqueKey)
+ // {
+ // dbQuery = ApplyOrder(dbQuery, filter);
+ // dbQuery = dbQuery.GroupBy(e => new { e.PresentationUniqueKey, e.SeriesPresentationUniqueKey }).Select(e => e.First());
+ // }
+ // else if (enableGroupByPresentationUniqueKey)
+ // {
+ // dbQuery = ApplyOrder(dbQuery, filter);
+ // dbQuery = dbQuery.GroupBy(e => e.PresentationUniqueKey).Select(e => e.First());
+ // }
+ // else if (filter.GroupBySeriesPresentationUniqueKey)
+ // {
+ // dbQuery = ApplyOrder(dbQuery, filter);
+ // dbQuery = dbQuery.GroupBy(e => e.SeriesPresentationUniqueKey).Select(e => e.First());
+ // }
+ // else
+ // {
+ // dbQuery = dbQuery.Distinct();
+ // dbQuery = ApplyOrder(dbQuery, filter);
+ // }
+ dbQuery = dbQuery.Distinct();
+ dbQuery = ApplyOrder(dbQuery, filter);
+
+ return dbQuery;
+ }
+
+ private IQueryable ApplyQueryPaging(IQueryable dbQuery, InternalItemsQuery filter)
+ {
+ if (filter.Limit.HasValue || filter.StartIndex.HasValue)
+ {
+ var offset = filter.StartIndex ?? 0;
+
+ if (offset > 0)
+ {
+ dbQuery = dbQuery.Skip(offset);
+ }
+
+ if (filter.Limit.HasValue)
+ {
+ dbQuery = dbQuery.Take(filter.Limit.Value);
+ }
+ }
+
+ return dbQuery;
+ }
+
+ private IQueryable ApplyQueryFilter(IQueryable dbQuery, JellyfinDbContext context, InternalItemsQuery filter)
+ {
+ dbQuery = TranslateQuery(dbQuery, context, filter);
+ dbQuery = ApplyOrder(dbQuery, filter);
+ dbQuery = ApplyGroupingFilter(dbQuery, filter);
+ dbQuery = ApplyQueryPaging(dbQuery, filter);
+ return dbQuery;
+ }
+
+ private IQueryable PrepareItemQuery(JellyfinDbContext context, InternalItemsQuery filter)
+ {
+ IQueryable dbQuery = context.BaseItems.AsNoTracking().AsSplitQuery()
+ .Include(e => e.TrailerTypes)
+ .Include(e => e.Provider)
+ .Include(e => e.LockedFields);
+
+ if (filter.DtoOptions.EnableImages)
+ {
+ dbQuery = dbQuery.Include(e => e.Images);
+ }
+
+ return dbQuery;
+ }
+
+ ///
+ public int GetCount(InternalItemsQuery filter)
+ {
+ ArgumentNullException.ThrowIfNull(filter);
+ // Hack for right now since we currently don't support filtering out these duplicates within a query
+ PrepareFilterQuery(filter);
+
+ using var context = _dbProvider.CreateDbContext();
+ var dbQuery = TranslateQuery(context.BaseItems.AsNoTracking(), context, filter);
+
+ return dbQuery.Count();
+ }
+
+#pragma warning disable CA1307 // Specify StringComparison for clarity
+ ///
+ /// Gets the type.
+ ///
+ /// Name of the type.
+ /// Type.
+ /// typeName is null.
+ private static Type? GetType(string typeName)
+ {
+ ArgumentException.ThrowIfNullOrEmpty(typeName);
+
+ // TODO: this isn't great. Refactor later to be both globally handled by a dedicated service not just an static variable and be loaded eagerly.
+ // currently this is done so that plugins may introduce their own type of baseitems as we dont know when we are first called, before or after plugins are loaded
+ return _typeMap.GetOrAdd(typeName, k => AppDomain.CurrentDomain.GetAssemblies()
+ .Select(a => a.GetType(k))
+ .FirstOrDefault(t => t is not null));
+ }
+
+ ///
+ public void SaveImages(BaseItemDto item)
+ {
+ ArgumentNullException.ThrowIfNull(item);
+
+ var images = item.ImageInfos.Select(e => Map(item.Id, e));
+ using var context = _dbProvider.CreateDbContext();
+ using var transaction = context.Database.BeginTransaction();
+ context.BaseItemImageInfos.Where(e => e.ItemId == item.Id).ExecuteDelete();
+ context.BaseItemImageInfos.AddRange(images);
+ context.SaveChanges();
+ transaction.Commit();
+ }
+
+ ///
+ public void SaveItems(IReadOnlyList items, CancellationToken cancellationToken)
+ {
+ UpdateOrInsertItems(items, cancellationToken);
+ }
+
+ ///
+ public void UpdateOrInsertItems(IReadOnlyList items, CancellationToken cancellationToken)
+ {
+ ArgumentNullException.ThrowIfNull(items);
+ cancellationToken.ThrowIfCancellationRequested();
+
+ var tuples = new List<(BaseItemDto Item, List? AncestorIds, BaseItemDto TopParent, IEnumerable UserDataKey, List InheritedTags)>();
+ foreach (var item in items.GroupBy(e => e.Id).Select(e => e.Last()))
+ {
+ var ancestorIds = item.SupportsAncestors ?
+ item.GetAncestorIds().Distinct().ToList() :
+ null;
+
+ var topParent = item.GetTopParent();
+
+ var userdataKey = item.GetUserDataKeys();
+ var inheritedTags = item.GetInheritedTags();
+
+ tuples.Add((item, ancestorIds, topParent, userdataKey, inheritedTags));
+ }
+
+ var localItemValueCache = new Dictionary<(int MagicNumber, string Value), Guid>();
+
+ using var context = _dbProvider.CreateDbContext();
+ using var transaction = context.Database.BeginTransaction();
+ foreach (var item in tuples)
+ {
+ var entity = Map(item.Item);
+ // TODO: refactor this "inconsistency"
+ entity.TopParentId = item.TopParent?.Id;
+
+ if (!context.BaseItems.Any(e => e.Id == entity.Id))
+ {
+ context.BaseItems.Add(entity);
+ }
+ else
+ {
+ context.BaseItemProviders.Where(e => e.ItemId == entity.Id).ExecuteDelete();
+ context.BaseItems.Attach(entity).State = EntityState.Modified;
+ }
+
+ context.AncestorIds.Where(e => e.ItemId == entity.Id).ExecuteDelete();
+ if (item.Item.SupportsAncestors && item.AncestorIds != null)
+ {
+ foreach (var ancestorId in item.AncestorIds)
+ {
+ if (!context.BaseItems.Any(f => f.Id == ancestorId))
+ {
+ continue;
+ }
+
+ context.AncestorIds.Add(new AncestorId()
+ {
+ ParentItemId = ancestorId,
+ ItemId = entity.Id,
+ Item = null!,
+ ParentItem = null!
+ });
+ }
+ }
+
+ // Never save duplicate itemValues as they are now mapped anyway.
+ var itemValuesToSave = GetItemValuesToSave(item.Item, item.InheritedTags).DistinctBy(e => (GetCleanValue(e.Value), e.MagicNumber));
+ context.ItemValuesMap.Where(e => e.ItemId == entity.Id).ExecuteDelete();
+ foreach (var itemValue in itemValuesToSave)
+ {
+ if (!localItemValueCache.TryGetValue(itemValue, out var refValue))
+ {
+ refValue = context.ItemValues
+ .Where(f => f.Value == itemValue.Value && (int)f.Type == itemValue.MagicNumber)
+ .Select(e => e.ItemValueId)
+ .FirstOrDefault();
+ }
+
+ if (refValue.IsEmpty())
+ {
+ context.ItemValues.Add(new ItemValue()
+ {
+ CleanValue = GetCleanValue(itemValue.Value),
+ Type = (ItemValueType)itemValue.MagicNumber,
+ ItemValueId = refValue = Guid.NewGuid(),
+ Value = itemValue.Value
+ });
+ localItemValueCache[itemValue] = refValue;
+ }
+
+ context.ItemValuesMap.Add(new ItemValueMap()
+ {
+ Item = null!,
+ ItemId = entity.Id,
+ ItemValue = null!,
+ ItemValueId = refValue
+ });
+ }
+ }
+
+ context.SaveChanges();
+ transaction.Commit();
+ }
+
+ ///
+ public BaseItemDto? RetrieveItem(Guid id)
+ {
+ if (id.IsEmpty())
+ {
+ throw new ArgumentException("Guid can't be empty", nameof(id));
+ }
+
+ using var context = _dbProvider.CreateDbContext();
+ var item = PrepareItemQuery(context, new()
+ {
+ DtoOptions = new()
+ {
+ EnableImages = true
+ }
+ }).FirstOrDefault(e => e.Id == id);
+ if (item is null)
+ {
+ return null;
+ }
+
+ return DeserialiseBaseItem(item);
+ }
+
+ ///
+ /// Maps a Entity to the DTO.
+ ///
+ /// The entity.
+ /// The dto base instance.
+ /// The Application server Host.
+ /// The dto to map.
+ public static BaseItemDto Map(BaseItemEntity entity, BaseItemDto dto, IServerApplicationHost? appHost)
+ {
+ dto.Id = entity.Id;
+ dto.ParentId = entity.ParentId.GetValueOrDefault();
+ dto.Path = appHost?.ExpandVirtualPath(entity.Path) ?? entity.Path;
+ dto.EndDate = entity.EndDate;
+ dto.CommunityRating = entity.CommunityRating;
+ dto.CustomRating = entity.CustomRating;
+ dto.IndexNumber = entity.IndexNumber;
+ dto.IsLocked = entity.IsLocked;
+ dto.Name = entity.Name;
+ dto.OfficialRating = entity.OfficialRating;
+ dto.Overview = entity.Overview;
+ dto.ParentIndexNumber = entity.ParentIndexNumber;
+ dto.PremiereDate = entity.PremiereDate;
+ dto.ProductionYear = entity.ProductionYear;
+ dto.SortName = entity.SortName;
+ dto.ForcedSortName = entity.ForcedSortName;
+ dto.RunTimeTicks = entity.RunTimeTicks;
+ dto.PreferredMetadataLanguage = entity.PreferredMetadataLanguage;
+ dto.PreferredMetadataCountryCode = entity.PreferredMetadataCountryCode;
+ dto.IsInMixedFolder = entity.IsInMixedFolder;
+ dto.InheritedParentalRatingValue = entity.InheritedParentalRatingValue;
+ dto.InheritedParentalRatingSubValue = entity.InheritedParentalRatingSubValue;
+ dto.CriticRating = entity.CriticRating;
+ dto.PresentationUniqueKey = entity.PresentationUniqueKey;
+ dto.OriginalTitle = entity.OriginalTitle;
+ dto.Album = entity.Album;
+ dto.LUFS = entity.LUFS;
+ dto.NormalizationGain = entity.NormalizationGain;
+ dto.IsVirtualItem = entity.IsVirtualItem;
+ dto.ExternalSeriesId = entity.ExternalSeriesId;
+ dto.Tagline = entity.Tagline;
+ dto.TotalBitrate = entity.TotalBitrate;
+ dto.ExternalId = entity.ExternalId;
+ dto.Size = entity.Size;
+ dto.Genres = entity.Genres?.Split('|') ?? [];
+ dto.DateCreated = entity.DateCreated.GetValueOrDefault();
+ dto.DateModified = entity.DateModified.GetValueOrDefault();
+ dto.ChannelId = entity.ChannelId ?? Guid.Empty;
+ dto.DateLastRefreshed = entity.DateLastRefreshed.GetValueOrDefault();
+ dto.DateLastSaved = entity.DateLastSaved.GetValueOrDefault();
+ dto.OwnerId = string.IsNullOrWhiteSpace(entity.OwnerId) ? Guid.Empty : (Guid.TryParse(entity.OwnerId, out var ownerId) ? ownerId : Guid.Empty);
+ dto.Width = entity.Width.GetValueOrDefault();
+ dto.Height = entity.Height.GetValueOrDefault();
+ if (entity.Provider is not null)
+ {
+ dto.ProviderIds = entity.Provider.ToDictionary(e => e.ProviderId, e => e.ProviderValue);
+ }
+
+ if (entity.ExtraType is not null)
+ {
+ dto.ExtraType = (ExtraType)entity.ExtraType;
+ }
+
+ if (entity.LockedFields is not null)
+ {
+ dto.LockedFields = entity.LockedFields?.Select(e => (MetadataField)e.Id).ToArray() ?? [];
+ }
+
+ if (entity.Audio is not null)
+ {
+ dto.Audio = (ProgramAudio)entity.Audio;
+ }
+
+ dto.ExtraIds = string.IsNullOrWhiteSpace(entity.ExtraIds) ? [] : entity.ExtraIds.Split('|').Select(e => Guid.Parse(e)).ToArray();
+ dto.ProductionLocations = entity.ProductionLocations?.Split('|') ?? [];
+ dto.Studios = entity.Studios?.Split('|') ?? [];
+ dto.Tags = entity.Tags?.Split('|') ?? [];
+
+ if (dto is IHasProgramAttributes hasProgramAttributes)
+ {
+ hasProgramAttributes.IsMovie = entity.IsMovie;
+ hasProgramAttributes.IsSeries = entity.IsSeries;
+ hasProgramAttributes.EpisodeTitle = entity.EpisodeTitle;
+ hasProgramAttributes.IsRepeat = entity.IsRepeat;
+ }
+
+ if (dto is LiveTvChannel liveTvChannel)
+ {
+ liveTvChannel.ServiceName = entity.ExternalServiceId;
+ }
+
+ if (dto is Trailer trailer)
+ {
+ trailer.TrailerTypes = entity.TrailerTypes?.Select(e => (TrailerType)e.Id).ToArray() ?? [];
+ }
+
+ if (dto is Video video)
+ {
+ video.PrimaryVersionId = entity.PrimaryVersionId;
+ }
+
+ if (dto is IHasSeries hasSeriesName)
+ {
+ hasSeriesName.SeriesName = entity.SeriesName;
+ hasSeriesName.SeriesId = entity.SeriesId.GetValueOrDefault();
+ hasSeriesName.SeriesPresentationUniqueKey = entity.SeriesPresentationUniqueKey;
+ }
+
+ if (dto is Episode episode)
+ {
+ episode.SeasonName = entity.SeasonName;
+ episode.SeasonId = entity.SeasonId.GetValueOrDefault();
+ }
+
+ if (dto is IHasArtist hasArtists)
+ {
+ hasArtists.Artists = entity.Artists?.Split('|', StringSplitOptions.RemoveEmptyEntries) ?? [];
+ }
+
+ if (dto is IHasAlbumArtist hasAlbumArtists)
+ {
+ hasAlbumArtists.AlbumArtists = entity.AlbumArtists?.Split('|', StringSplitOptions.RemoveEmptyEntries) ?? [];
+ }
+
+ if (dto is LiveTvProgram program)
+ {
+ program.ShowId = entity.ShowId;
+ }
+
+ if (entity.Images is not null)
+ {
+ dto.ImageInfos = entity.Images.Select(e => Map(e, appHost)).ToArray();
+ }
+
+ // dto.Type = entity.Type;
+ // dto.Data = entity.Data;
+ // dto.MediaType = Enum.TryParse(entity.MediaType);
+ if (dto is IHasStartDate hasStartDate)
+ {
+ hasStartDate.StartDate = entity.StartDate.GetValueOrDefault();
+ }
+
+ // Fields that are present in the DB but are never actually used
+ // dto.UnratedType = entity.UnratedType;
+ // dto.TopParentId = entity.TopParentId;
+ // dto.CleanName = entity.CleanName;
+ // dto.UserDataKey = entity.UserDataKey;
+
+ if (dto is Folder folder)
+ {
+ folder.DateLastMediaAdded = entity.DateLastMediaAdded;
+ }
+
+ return dto;
+ }
+
+ ///
+ /// Maps a Entity to the DTO.
+ ///
+ /// The entity.
+ /// The dto to map.
+ public BaseItemEntity Map(BaseItemDto dto)
+ {
+ var dtoType = dto.GetType();
+ var entity = new BaseItemEntity()
+ {
+ Type = dtoType.ToString(),
+ Id = dto.Id
+ };
+
+ if (TypeRequiresDeserialization(dtoType))
+ {
+ entity.Data = JsonSerializer.Serialize(dto, dtoType, JsonDefaults.Options);
+ }
+
+ entity.ParentId = !dto.ParentId.IsEmpty() ? dto.ParentId : null;
+ entity.Path = GetPathToSave(dto.Path);
+ entity.EndDate = dto.EndDate;
+ entity.CommunityRating = dto.CommunityRating;
+ entity.CustomRating = dto.CustomRating;
+ entity.IndexNumber = dto.IndexNumber;
+ entity.IsLocked = dto.IsLocked;
+ entity.Name = dto.Name;
+ entity.CleanName = GetCleanValue(dto.Name);
+ entity.OfficialRating = dto.OfficialRating;
+ entity.Overview = dto.Overview;
+ entity.ParentIndexNumber = dto.ParentIndexNumber;
+ entity.PremiereDate = dto.PremiereDate;
+ entity.ProductionYear = dto.ProductionYear;
+ entity.SortName = dto.SortName;
+ entity.ForcedSortName = dto.ForcedSortName;
+ entity.RunTimeTicks = dto.RunTimeTicks;
+ entity.PreferredMetadataLanguage = dto.PreferredMetadataLanguage;
+ entity.PreferredMetadataCountryCode = dto.PreferredMetadataCountryCode;
+ entity.IsInMixedFolder = dto.IsInMixedFolder;
+ entity.InheritedParentalRatingValue = dto.InheritedParentalRatingValue;
+ entity.InheritedParentalRatingSubValue = dto.InheritedParentalRatingSubValue;
+ entity.CriticRating = dto.CriticRating;
+ entity.PresentationUniqueKey = dto.PresentationUniqueKey;
+ entity.OriginalTitle = dto.OriginalTitle;
+ entity.Album = dto.Album;
+ entity.LUFS = dto.LUFS;
+ entity.NormalizationGain = dto.NormalizationGain;
+ entity.IsVirtualItem = dto.IsVirtualItem;
+ entity.ExternalSeriesId = dto.ExternalSeriesId;
+ entity.Tagline = dto.Tagline;
+ entity.TotalBitrate = dto.TotalBitrate;
+ entity.ExternalId = dto.ExternalId;
+ entity.Size = dto.Size;
+ entity.Genres = string.Join('|', dto.Genres);
+ entity.DateCreated = dto.DateCreated;
+ entity.DateModified = dto.DateModified;
+ entity.ChannelId = dto.ChannelId;
+ entity.DateLastRefreshed = dto.DateLastRefreshed;
+ entity.DateLastSaved = dto.DateLastSaved;
+ entity.OwnerId = dto.OwnerId.ToString();
+ entity.Width = dto.Width;
+ entity.Height = dto.Height;
+ entity.Provider = dto.ProviderIds.Select(e => new BaseItemProvider()
+ {
+ Item = entity,
+ ProviderId = e.Key,
+ ProviderValue = e.Value
+ }).ToList();
+
+ if (dto.Audio.HasValue)
+ {
+ entity.Audio = (ProgramAudioEntity)dto.Audio;
+ }
+
+ if (dto.ExtraType.HasValue)
+ {
+ entity.ExtraType = (BaseItemExtraType)dto.ExtraType;
+ }
+
+ entity.ExtraIds = dto.ExtraIds is not null ? string.Join('|', dto.ExtraIds) : null;
+ entity.ProductionLocations = dto.ProductionLocations is not null ? string.Join('|', dto.ProductionLocations) : null;
+ entity.Studios = dto.Studios is not null ? string.Join('|', dto.Studios) : null;
+ entity.Tags = dto.Tags is not null ? string.Join('|', dto.Tags) : null;
+ entity.LockedFields = dto.LockedFields is not null ? dto.LockedFields
+ .Select(e => new BaseItemMetadataField()
+ {
+ Id = (int)e,
+ Item = entity,
+ ItemId = entity.Id
+ })
+ .ToArray() : null;
+
+ if (dto is IHasProgramAttributes hasProgramAttributes)
+ {
+ entity.IsMovie = hasProgramAttributes.IsMovie;
+ entity.IsSeries = hasProgramAttributes.IsSeries;
+ entity.EpisodeTitle = hasProgramAttributes.EpisodeTitle;
+ entity.IsRepeat = hasProgramAttributes.IsRepeat;
+ }
+
+ if (dto is LiveTvChannel liveTvChannel)
+ {
+ entity.ExternalServiceId = liveTvChannel.ServiceName;
+ }
+
+ if (dto is Video video)
+ {
+ entity.PrimaryVersionId = video.PrimaryVersionId;
+ }
+
+ if (dto is IHasSeries hasSeriesName)
+ {
+ entity.SeriesName = hasSeriesName.SeriesName;
+ entity.SeriesId = hasSeriesName.SeriesId;
+ entity.SeriesPresentationUniqueKey = hasSeriesName.SeriesPresentationUniqueKey;
+ }
+
+ if (dto is Episode episode)
+ {
+ entity.SeasonName = episode.SeasonName;
+ entity.SeasonId = episode.SeasonId;
+ }
+
+ if (dto is IHasArtist hasArtists)
+ {
+ entity.Artists = hasArtists.Artists is not null ? string.Join('|', hasArtists.Artists) : null;
+ }
+
+ if (dto is IHasAlbumArtist hasAlbumArtists)
+ {
+ entity.AlbumArtists = hasAlbumArtists.AlbumArtists is not null ? string.Join('|', hasAlbumArtists.AlbumArtists) : null;
+ }
+
+ if (dto is LiveTvProgram program)
+ {
+ entity.ShowId = program.ShowId;
+ }
+
+ if (dto.ImageInfos is not null)
+ {
+ entity.Images = dto.ImageInfos.Select(f => Map(dto.Id, f)).ToArray();
+ }
+
+ if (dto is Trailer trailer)
+ {
+ entity.TrailerTypes = trailer.TrailerTypes?.Select(e => new BaseItemTrailerType()
+ {
+ Id = (int)e,
+ Item = entity,
+ ItemId = entity.Id
+ }).ToArray() ?? [];
+ }
+
+ // dto.Type = entity.Type;
+ // dto.Data = entity.Data;
+ entity.MediaType = dto.MediaType.ToString();
+ if (dto is IHasStartDate hasStartDate)
+ {
+ entity.StartDate = hasStartDate.StartDate;
+ }
+
+ entity.UnratedType = dto.GetBlockUnratedType().ToString();
+
+ // Fields that are present in the DB but are never actually used
+ // dto.UserDataKey = entity.UserDataKey;
+
+ if (dto is Folder folder)
+ {
+ entity.DateLastMediaAdded = folder.DateLastMediaAdded;
+ entity.IsFolder = folder.IsFolder;
+ }
+
+ return entity;
+ }
+
+ private string[] GetItemValueNames(IReadOnlyList itemValueTypes, IReadOnlyList withItemTypes, IReadOnlyList excludeItemTypes)
+ {
+ using var context = _dbProvider.CreateDbContext();
+
+ var query = context.ItemValuesMap
+ .AsNoTracking()
+ .Where(e => itemValueTypes.Any(w => (ItemValueType)w == e.ItemValue.Type));
+ if (withItemTypes.Count > 0)
+ {
+ query = query.Where(e => withItemTypes.Contains(e.Item.Type));
+ }
+
+ if (excludeItemTypes.Count > 0)
+ {
+ query = query.Where(e => !excludeItemTypes.Contains(e.Item.Type));
+ }
+
+ // query = query.DistinctBy(e => e.CleanValue);
+ return query.Select(e => e.ItemValue)
+ .GroupBy(e => e.CleanValue)
+ .Select(e => e.First().Value)
+ .ToArray();
+ }
+
+ private static bool TypeRequiresDeserialization(Type type)
+ {
+ return type.GetCustomAttribute() == null;
+ }
+
+ private BaseItemDto DeserialiseBaseItem(BaseItemEntity baseItemEntity, bool skipDeserialization = false)
+ {
+ ArgumentNullException.ThrowIfNull(baseItemEntity, nameof(baseItemEntity));
+ if (_serverConfigurationManager?.Configuration is null)
+ {
+ throw new InvalidOperationException("Server Configuration manager or configuration is null");
+ }
+
+ var typeToSerialise = GetType(baseItemEntity.Type);
+ return BaseItemRepository.DeserialiseBaseItem(
+ baseItemEntity,
+ _logger,
+ _appHost,
+ skipDeserialization || (_serverConfigurationManager.Configuration.SkipDeserializationForBasicTypes && (typeToSerialise == typeof(Channel) || typeToSerialise == typeof(UserRootFolder))));
+ }
+
+ ///
+ /// Deserialises a BaseItemEntity and sets all properties.
+ ///
+ /// The DB entity.
+ /// Logger.
+ /// The application server Host.
+ /// If only mapping should be processed.
+ /// A mapped BaseItem.
+ /// Will be thrown if an invalid serialisation is requested.
+ public static BaseItemDto DeserialiseBaseItem(BaseItemEntity baseItemEntity, ILogger logger, IServerApplicationHost? appHost, bool skipDeserialization = false)
+ {
+ var type = GetType(baseItemEntity.Type) ?? throw new InvalidOperationException("Cannot deserialise unknown type.");
+ BaseItemDto? dto = null;
+ if (TypeRequiresDeserialization(type) && baseItemEntity.Data is not null && !skipDeserialization)
+ {
+ try
+ {
+ dto = JsonSerializer.Deserialize(baseItemEntity.Data, type, JsonDefaults.Options) as BaseItemDto;
+ }
+ catch (JsonException ex)
+ {
+ logger.LogError(ex, "Error deserializing item with JSON: {Data}", baseItemEntity.Data);
+ }
+ }
+
+ if (dto is null)
+ {
+ dto = Activator.CreateInstance(type) as BaseItemDto ?? throw new InvalidOperationException("Cannot deserialise unknown type.");
+ }
+
+ return Map(baseItemEntity, dto, appHost);
+ }
+
+ private QueryResult<(BaseItemDto Item, ItemCounts ItemCounts)> GetItemValues(InternalItemsQuery filter, IReadOnlyList itemValueTypes, string returnType)
+ {
+ ArgumentNullException.ThrowIfNull(filter);
+
+ if (!filter.Limit.HasValue)
+ {
+ filter.EnableTotalRecordCount = false;
+ }
+
+ using var context = _dbProvider.CreateDbContext();
+
+ var query = TranslateQuery(context.BaseItems.AsNoTracking(), context, filter);
+
+ query = query.Where(e => e.Type == returnType);
+ // this does not seem to be nesseary but it does not make any sense why this isn't working.
+ // && e.ItemValues!.Any(f => e.CleanName == f.ItemValue.CleanValue && itemValueTypes.Any(w => (ItemValueType)w == f.ItemValue.Type)));
+
+ if (filter.OrderBy.Count != 0
+ || !string.IsNullOrEmpty(filter.SearchTerm))
+ {
+ query = ApplyOrder(query, filter);
+ }
+ else
+ {
+ query = query.OrderBy(e => e.SortName);
+ }
+
+ if (filter.Limit.HasValue || filter.StartIndex.HasValue)
+ {
+ var offset = filter.StartIndex ?? 0;
+
+ if (offset > 0)
+ {
+ query = query.Skip(offset);
+ }
+
+ if (filter.Limit.HasValue)
+ {
+ query = query.Take(filter.Limit.Value);
+ }
+ }
+
+ var result = new QueryResult<(BaseItemDto, ItemCounts)>();
+ if (filter.EnableTotalRecordCount)
+ {
+ result.TotalRecordCount = query.GroupBy(e => e.PresentationUniqueKey).Select(e => e.First()).Count();
+ }
+
+ var seriesTypeName = _itemTypeLookup.BaseItemKindNames[BaseItemKind.Series];
+ var movieTypeName = _itemTypeLookup.BaseItemKindNames[BaseItemKind.Movie];
+ var episodeTypeName = _itemTypeLookup.BaseItemKindNames[BaseItemKind.Episode];
+ var musicAlbumTypeName = _itemTypeLookup.BaseItemKindNames[BaseItemKind.MusicAlbum];
+ var musicArtistTypeName = _itemTypeLookup.BaseItemKindNames[BaseItemKind.MusicArtist];
+ var audioTypeName = _itemTypeLookup.BaseItemKindNames[BaseItemKind.Audio];
+ var trailerTypeName = _itemTypeLookup.BaseItemKindNames[BaseItemKind.Trailer];
+
+ var resultQuery = query.Select(e => new
+ {
+ item = e,
+ // TODO: This is bad refactor!
+ itemCount = new ItemCounts()
+ {
+ SeriesCount = e.ItemValues!.Count(f => f.Item.Type == seriesTypeName),
+ EpisodeCount = e.ItemValues!.Count(f => f.Item.Type == episodeTypeName),
+ MovieCount = e.ItemValues!.Count(f => f.Item.Type == movieTypeName),
+ AlbumCount = e.ItemValues!.Count(f => f.Item.Type == musicAlbumTypeName),
+ ArtistCount = e.ItemValues!.Count(f => f.Item.Type == musicArtistTypeName),
+ SongCount = e.ItemValues!.Count(f => f.Item.Type == audioTypeName),
+ TrailerCount = e.ItemValues!.Count(f => f.Item.Type == trailerTypeName),
+ }
+ });
+
+ result.StartIndex = filter.StartIndex ?? 0;
+ result.Items = resultQuery.ToArray().Where(e => e is not null).Select(e =>
+ {
+ return (DeserialiseBaseItem(e.item, filter.SkipDeserialization), e.itemCount);
+ }).ToArray();
+
+ return result;
+ }
+
+ private static void PrepareFilterQuery(InternalItemsQuery query)
+ {
+ if (query.Limit.HasValue && query.EnableGroupByMetadataKey)
+ {
+ query.Limit = query.Limit.Value + 4;
+ }
+
+ if (query.IsResumable ?? false)
+ {
+ query.IsVirtualItem = false;
+ }
+ }
+
+ private string GetCleanValue(string value)
+ {
+ if (string.IsNullOrWhiteSpace(value))
+ {
+ return value;
+ }
+
+ return value.RemoveDiacritics().ToLowerInvariant();
+ }
+
+ private List<(int MagicNumber, string Value)> GetItemValuesToSave(BaseItemDto item, List inheritedTags)
+ {
+ var list = new List<(int, string)>();
+
+ if (item is IHasArtist hasArtist)
+ {
+ list.AddRange(hasArtist.Artists.Select(i => (0, i)));
+ }
+
+ if (item is IHasAlbumArtist hasAlbumArtist)
+ {
+ list.AddRange(hasAlbumArtist.AlbumArtists.Select(i => (1, i)));
+ }
+
+ list.AddRange(item.Genres.Select(i => (2, i)));
+ list.AddRange(item.Studios.Select(i => (3, i)));
+ list.AddRange(item.Tags.Select(i => (4, i)));
+
+ // keywords was 5
+
+ list.AddRange(inheritedTags.Select(i => (6, i)));
+
+ // Remove all invalid values.
+ list.RemoveAll(i => string.IsNullOrWhiteSpace(i.Item2));
+
+ return list;
+ }
+
+ private static BaseItemImageInfo Map(Guid baseItemId, ItemImageInfo e)
+ {
+ return new BaseItemImageInfo()
+ {
+ ItemId = baseItemId,
+ Id = Guid.NewGuid(),
+ Path = e.Path,
+ Blurhash = e.BlurHash is null ? null : Encoding.UTF8.GetBytes(e.BlurHash),
+ DateModified = e.DateModified,
+ Height = e.Height,
+ Width = e.Width,
+ ImageType = (ImageInfoImageType)e.Type,
+ Item = null!
+ };
+ }
+
+ private static ItemImageInfo Map(BaseItemImageInfo e, IServerApplicationHost? appHost)
+ {
+ return new ItemImageInfo()
+ {
+ Path = appHost?.ExpandVirtualPath(e.Path) ?? e.Path,
+ BlurHash = e.Blurhash is null ? null : Encoding.UTF8.GetString(e.Blurhash),
+ DateModified = e.DateModified,
+ Height = e.Height,
+ Width = e.Width,
+ Type = (ImageType)e.ImageType
+ };
+ }
+
+ private string? GetPathToSave(string path)
+ {
+ if (path is null)
+ {
+ return null;
+ }
+
+ return _appHost.ReverseVirtualPath(path);
+ }
+
+ private List GetItemByNameTypesInQuery(InternalItemsQuery query)
+ {
+ var list = new List();
+
+ if (IsTypeInQuery(BaseItemKind.Person, query))
+ {
+ list.Add(_itemTypeLookup.BaseItemKindNames[BaseItemKind.Person]!);
+ }
+
+ if (IsTypeInQuery(BaseItemKind.Genre, query))
+ {
+ list.Add(_itemTypeLookup.BaseItemKindNames[BaseItemKind.Genre]!);
+ }
+
+ if (IsTypeInQuery(BaseItemKind.MusicGenre, query))
+ {
+ list.Add(_itemTypeLookup.BaseItemKindNames[BaseItemKind.MusicGenre]!);
+ }
+
+ if (IsTypeInQuery(BaseItemKind.MusicArtist, query))
+ {
+ list.Add(_itemTypeLookup.BaseItemKindNames[BaseItemKind.MusicArtist]!);
+ }
+
+ if (IsTypeInQuery(BaseItemKind.Studio, query))
+ {
+ list.Add(_itemTypeLookup.BaseItemKindNames[BaseItemKind.Studio]!);
+ }
+
+ return list;
+ }
+
+ private bool IsTypeInQuery(BaseItemKind type, InternalItemsQuery query)
+ {
+ if (query.ExcludeItemTypes.Contains(type))
+ {
+ return false;
+ }
+
+ return query.IncludeItemTypes.Length == 0 || query.IncludeItemTypes.Contains(type);
+ }
+
+ private bool EnableGroupByPresentationUniqueKey(InternalItemsQuery query)
+ {
+ if (!query.GroupByPresentationUniqueKey)
+ {
+ return false;
+ }
+
+ if (query.GroupBySeriesPresentationUniqueKey)
+ {
+ return false;
+ }
+
+ if (!string.IsNullOrWhiteSpace(query.PresentationUniqueKey))
+ {
+ return false;
+ }
+
+ if (query.User is null)
+ {
+ return false;
+ }
+
+ if (query.IncludeItemTypes.Length == 0)
+ {
+ return true;
+ }
+
+ return query.IncludeItemTypes.Contains(BaseItemKind.Episode)
+ || query.IncludeItemTypes.Contains(BaseItemKind.Video)
+ || query.IncludeItemTypes.Contains(BaseItemKind.Movie)
+ || query.IncludeItemTypes.Contains(BaseItemKind.MusicVideo)
+ || query.IncludeItemTypes.Contains(BaseItemKind.Series)
+ || query.IncludeItemTypes.Contains(BaseItemKind.Season);
+ }
+
+ private IQueryable ApplyOrder(IQueryable query, InternalItemsQuery filter)
+ {
+ var orderBy = filter.OrderBy;
+ var hasSearch = !string.IsNullOrEmpty(filter.SearchTerm);
+
+ if (hasSearch)
+ {
+ orderBy = filter.OrderBy = [(ItemSortBy.SortName, SortOrder.Ascending), .. orderBy];
+ }
+ else if (orderBy.Count == 0)
+ {
+ return query;
+ }
+
+ IOrderedQueryable? orderedQuery = null;
+
+ var firstOrdering = orderBy.FirstOrDefault();
+ if (firstOrdering != default)
+ {
+ var expression = OrderMapper.MapOrderByField(firstOrdering.OrderBy, filter);
+ if (firstOrdering.SortOrder == SortOrder.Ascending)
+ {
+ orderedQuery = query.OrderBy(expression);
+ }
+ else
+ {
+ orderedQuery = query.OrderByDescending(expression);
+ }
+
+ if (firstOrdering.OrderBy is ItemSortBy.Default or ItemSortBy.SortName)
+ {
+ if (firstOrdering.SortOrder is SortOrder.Ascending)
+ {
+ orderedQuery = orderedQuery.ThenBy(e => e.Name);
+ }
+ else
+ {
+ orderedQuery = orderedQuery.ThenByDescending(e => e.Name);
+ }
+ }
+ }
+
+ foreach (var item in orderBy.Skip(1))
+ {
+ var expression = OrderMapper.MapOrderByField(item.OrderBy, filter);
+ if (item.SortOrder == SortOrder.Ascending)
+ {
+ orderedQuery = orderedQuery!.ThenBy(expression);
+ }
+ else
+ {
+ orderedQuery = orderedQuery!.ThenByDescending(expression);
+ }
+ }
+
+ return orderedQuery ?? query;
+ }
+
+ private IQueryable TranslateQuery(
+ IQueryable baseQuery,
+ JellyfinDbContext context,
+ InternalItemsQuery filter)
+ {
+ const int HDWidth = 1200;
+ const int UHDWidth = 3800;
+ const int UHDHeight = 2100;
+
+ var minWidth = filter.MinWidth;
+ var maxWidth = filter.MaxWidth;
+ var now = DateTime.UtcNow;
+
+ if (filter.IsHD.HasValue || filter.Is4K.HasValue)
+ {
+ bool includeSD = false;
+ bool includeHD = false;
+ bool include4K = false;
+
+ if (filter.IsHD.HasValue && !filter.IsHD.Value)
+ {
+ includeSD = true;
+ }
+
+ if (filter.IsHD.HasValue && filter.IsHD.Value)
+ {
+ includeHD = true;
+ }
+
+ if (filter.Is4K.HasValue && filter.Is4K.Value)
+ {
+ include4K = true;
+ }
+
+ baseQuery = baseQuery.Where(e =>
+ (includeSD && e.Width < HDWidth) ||
+ (includeHD && e.Width >= HDWidth && !(e.Width >= UHDWidth || e.Height >= UHDHeight)) ||
+ (include4K && (e.Width >= UHDWidth || e.Height >= UHDHeight)));
+ }
+
+ if (minWidth.HasValue)
+ {
+ baseQuery = baseQuery.Where(e => e.Width >= minWidth);
+ }
+
+ if (filter.MinHeight.HasValue)
+ {
+ baseQuery = baseQuery.Where(e => e.Height >= filter.MinHeight);
+ }
+
+ if (maxWidth.HasValue)
+ {
+ baseQuery = baseQuery.Where(e => e.Width >= maxWidth);
+ }
+
+ if (filter.MaxHeight.HasValue)
+ {
+ baseQuery = baseQuery.Where(e => e.Height <= filter.MaxHeight);
+ }
+
+ if (filter.IsLocked.HasValue)
+ {
+ baseQuery = baseQuery.Where(e => e.IsLocked == filter.IsLocked);
+ }
+
+ var tags = filter.Tags.ToList();
+ var excludeTags = filter.ExcludeTags.ToList();
+
+ if (filter.IsMovie == true)
+ {
+ if (filter.IncludeItemTypes.Length == 0
+ || filter.IncludeItemTypes.Contains(BaseItemKind.Movie)
+ || filter.IncludeItemTypes.Contains(BaseItemKind.Trailer))
+ {
+ baseQuery = baseQuery.Where(e => e.IsMovie);
+ }
+ }
+ else if (filter.IsMovie.HasValue)
+ {
+ baseQuery = baseQuery.Where(e => e.IsMovie == filter.IsMovie);
+ }
+
+ if (filter.IsSeries.HasValue)
+ {
+ baseQuery = baseQuery.Where(e => e.IsSeries == filter.IsSeries);
+ }
+
+ if (filter.IsSports.HasValue)
+ {
+ if (filter.IsSports.Value)
+ {
+ tags.Add("Sports");
+ }
+ else
+ {
+ excludeTags.Add("Sports");
+ }
+ }
+
+ if (filter.IsNews.HasValue)
+ {
+ if (filter.IsNews.Value)
+ {
+ tags.Add("News");
+ }
+ else
+ {
+ excludeTags.Add("News");
+ }
+ }
+
+ if (filter.IsKids.HasValue)
+ {
+ if (filter.IsKids.Value)
+ {
+ tags.Add("Kids");
+ }
+ else
+ {
+ excludeTags.Add("Kids");
+ }
+ }
+
+ if (!string.IsNullOrEmpty(filter.SearchTerm))
+ {
+ var searchTerm = filter.SearchTerm.ToLower();
+ baseQuery = baseQuery.Where(e => e.CleanName!.ToLower().Contains(searchTerm) || (e.OriginalTitle != null && e.OriginalTitle.ToLower().Contains(searchTerm)));
+ }
+
+ if (filter.IsFolder.HasValue)
+ {
+ baseQuery = baseQuery.Where(e => e.IsFolder == filter.IsFolder);
+ }
+
+ var includeTypes = filter.IncludeItemTypes;
+ // Only specify excluded types if no included types are specified
+ if (filter.IncludeItemTypes.Length == 0)
+ {
+ var excludeTypes = filter.ExcludeItemTypes;
+ if (excludeTypes.Length == 1)
+ {
+ if (_itemTypeLookup.BaseItemKindNames.TryGetValue(excludeTypes[0], out var excludeTypeName))
+ {
+ baseQuery = baseQuery.Where(e => e.Type != excludeTypeName);
+ }
+ }
+ else if (excludeTypes.Length > 1)
+ {
+ var excludeTypeName = new List();
+ foreach (var excludeType in excludeTypes)
+ {
+ if (_itemTypeLookup.BaseItemKindNames.TryGetValue(excludeType, out var baseItemKindName))
+ {
+ excludeTypeName.Add(baseItemKindName!);
+ }
+ }
+
+ baseQuery = baseQuery.Where(e => !excludeTypeName.Contains(e.Type));
+ }
+ }
+ else if (includeTypes.Length == 1)
+ {
+ if (_itemTypeLookup.BaseItemKindNames.TryGetValue(includeTypes[0], out var includeTypeName))
+ {
+ baseQuery = baseQuery.Where(e => e.Type == includeTypeName);
+ }
+ }
+ else if (includeTypes.Length > 1)
+ {
+ var includeTypeName = new List();
+ foreach (var includeType in includeTypes)
+ {
+ if (_itemTypeLookup.BaseItemKindNames.TryGetValue(includeType, out var baseItemKindName))
+ {
+ includeTypeName.Add(baseItemKindName!);
+ }
+ }
+
+ baseQuery = baseQuery.Where(e => includeTypeName.Contains(e.Type));
+ }
+
+ if (filter.ChannelIds.Count > 0)
+ {
+ baseQuery = baseQuery.Where(e => e.ChannelId != null && filter.ChannelIds.Contains(e.ChannelId.Value));
+ }
+
+ if (!filter.ParentId.IsEmpty())
+ {
+ baseQuery = baseQuery.Where(e => e.ParentId!.Value == filter.ParentId);
+ }
+
+ if (!string.IsNullOrWhiteSpace(filter.Path))
+ {
+ baseQuery = baseQuery.Where(e => e.Path == filter.Path);
+ }
+
+ if (!string.IsNullOrWhiteSpace(filter.PresentationUniqueKey))
+ {
+ baseQuery = baseQuery.Where(e => e.PresentationUniqueKey == filter.PresentationUniqueKey);
+ }
+
+ if (filter.MinCommunityRating.HasValue)
+ {
+ baseQuery = baseQuery.Where(e => e.CommunityRating >= filter.MinCommunityRating);
+ }
+
+ if (filter.MinIndexNumber.HasValue)
+ {
+ baseQuery = baseQuery.Where(e => e.IndexNumber >= filter.MinIndexNumber);
+ }
+
+ if (filter.MinParentAndIndexNumber.HasValue)
+ {
+ baseQuery = baseQuery
+ .Where(e => (e.ParentIndexNumber == filter.MinParentAndIndexNumber.Value.ParentIndexNumber && e.IndexNumber >= filter.MinParentAndIndexNumber.Value.IndexNumber) || e.ParentIndexNumber > filter.MinParentAndIndexNumber.Value.ParentIndexNumber);
+ }
+
+ if (filter.MinDateCreated.HasValue)
+ {
+ baseQuery = baseQuery.Where(e => e.DateCreated >= filter.MinDateCreated);
+ }
+
+ if (filter.MinDateLastSaved.HasValue)
+ {
+ baseQuery = baseQuery.Where(e => e.DateLastSaved != null && e.DateLastSaved >= filter.MinDateLastSaved.Value);
+ }
+
+ if (filter.MinDateLastSavedForUser.HasValue)
+ {
+ baseQuery = baseQuery.Where(e => e.DateLastSaved != null && e.DateLastSaved >= filter.MinDateLastSavedForUser.Value);
+ }
+
+ if (filter.IndexNumber.HasValue)
+ {
+ baseQuery = baseQuery.Where(e => e.IndexNumber == filter.IndexNumber.Value);
+ }
+
+ if (filter.ParentIndexNumber.HasValue)
+ {
+ baseQuery = baseQuery.Where(e => e.ParentIndexNumber == filter.ParentIndexNumber.Value);
+ }
+
+ if (filter.ParentIndexNumberNotEquals.HasValue)
+ {
+ baseQuery = baseQuery.Where(e => e.ParentIndexNumber != filter.ParentIndexNumberNotEquals.Value || e.ParentIndexNumber == null);
+ }
+
+ var minEndDate = filter.MinEndDate;
+ var maxEndDate = filter.MaxEndDate;
+
+ if (filter.HasAired.HasValue)
+ {
+ if (filter.HasAired.Value)
+ {
+ maxEndDate = DateTime.UtcNow;
+ }
+ else
+ {
+ minEndDate = DateTime.UtcNow;
+ }
+ }
+
+ if (minEndDate.HasValue)
+ {
+ baseQuery = baseQuery.Where(e => e.EndDate >= minEndDate);
+ }
+
+ if (maxEndDate.HasValue)
+ {
+ baseQuery = baseQuery.Where(e => e.EndDate <= maxEndDate);
+ }
+
+ if (filter.MinStartDate.HasValue)
+ {
+ baseQuery = baseQuery.Where(e => e.StartDate >= filter.MinStartDate.Value);
+ }
+
+ if (filter.MaxStartDate.HasValue)
+ {
+ baseQuery = baseQuery.Where(e => e.StartDate <= filter.MaxStartDate.Value);
+ }
+
+ if (filter.MinPremiereDate.HasValue)
+ {
+ baseQuery = baseQuery.Where(e => e.PremiereDate <= filter.MinPremiereDate.Value);
+ }
+
+ if (filter.MaxPremiereDate.HasValue)
+ {
+ baseQuery = baseQuery.Where(e => e.PremiereDate <= filter.MaxPremiereDate.Value);
+ }
+
+ if (filter.TrailerTypes.Length > 0)
+ {
+ var trailerTypes = filter.TrailerTypes.Select(e => (int)e).ToArray();
+ baseQuery = baseQuery.Where(e => trailerTypes.Any(f => e.TrailerTypes!.Any(w => w.Id == f)));
+ }
+
+ if (filter.IsAiring.HasValue)
+ {
+ if (filter.IsAiring.Value)
+ {
+ baseQuery = baseQuery.Where(e => e.StartDate <= now && e.EndDate >= now);
+ }
+ else
+ {
+ baseQuery = baseQuery.Where(e => e.StartDate > now && e.EndDate < now);
+ }
+ }
+
+ if (filter.PersonIds.Length > 0)
+ {
+ baseQuery = baseQuery
+ .Where(e =>
+ context.PeopleBaseItemMap.Where(w => context.BaseItems.Where(r => filter.PersonIds.Contains(r.Id)).Any(f => f.Name == w.People.Name))
+ .Any(f => f.ItemId == e.Id));
+ }
+
+ if (!string.IsNullOrWhiteSpace(filter.Person))
+ {
+ baseQuery = baseQuery.Where(e => e.Peoples!.Any(f => f.People.Name == filter.Person));
+ }
+
+ if (!string.IsNullOrWhiteSpace(filter.MinSortName))
+ {
+ // this does not makes sense.
+ // baseQuery = baseQuery.Where(e => e.SortName >= query.MinSortName);
+ // whereClauses.Add("SortName>=@MinSortName");
+ // statement?.TryBind("@MinSortName", query.MinSortName);
+ }
+
+ if (!string.IsNullOrWhiteSpace(filter.ExternalSeriesId))
+ {
+ baseQuery = baseQuery.Where(e => e.ExternalSeriesId == filter.ExternalSeriesId);
+ }
+
+ if (!string.IsNullOrWhiteSpace(filter.ExternalId))
+ {
+ baseQuery = baseQuery.Where(e => e.ExternalId == filter.ExternalId);
+ }
+
+ if (!string.IsNullOrWhiteSpace(filter.Name))
+ {
+ var cleanName = GetCleanValue(filter.Name);
+ baseQuery = baseQuery.Where(e => e.CleanName == cleanName);
+ }
+
+ // These are the same, for now
+ var nameContains = filter.NameContains;
+ if (!string.IsNullOrWhiteSpace(nameContains))
+ {
+ baseQuery = baseQuery.Where(e =>
+ e.CleanName!.Contains(nameContains)
+ || e.OriginalTitle!.ToLower().Contains(nameContains!));
+ }
+
+ if (!string.IsNullOrWhiteSpace(filter.NameStartsWith))
+ {
+ baseQuery = baseQuery.Where(e => e.SortName!.StartsWith(filter.NameStartsWith) || e.Name!.StartsWith(filter.NameStartsWith));
+ }
+
+ if (!string.IsNullOrWhiteSpace(filter.NameStartsWithOrGreater))
+ {
+ // i hate this
+ baseQuery = baseQuery.Where(e => e.SortName!.FirstOrDefault() > filter.NameStartsWithOrGreater[0] || e.Name!.FirstOrDefault() > filter.NameStartsWithOrGreater[0]);
+ }
+
+ if (!string.IsNullOrWhiteSpace(filter.NameLessThan))
+ {
+ // i hate this
+ baseQuery = baseQuery.Where(e => e.SortName!.FirstOrDefault() < filter.NameLessThan[0] || e.Name!.FirstOrDefault() < filter.NameLessThan[0]);
+ }
+
+ if (filter.ImageTypes.Length > 0)
+ {
+ var imgTypes = filter.ImageTypes.Select(e => (ImageInfoImageType)e).ToArray();
+ baseQuery = baseQuery.Where(e => imgTypes.Any(f => e.Images!.Any(w => w.ImageType == f)));
+ }
+
+ if (filter.IsLiked.HasValue)
+ {
+ baseQuery = baseQuery
+ .Where(e => e.UserData!.FirstOrDefault(f => f.UserId == filter.User!.Id)!.Rating >= UserItemData.MinLikeValue);
+ }
+
+ if (filter.IsFavoriteOrLiked.HasValue)
+ {
+ baseQuery = baseQuery
+ .Where(e => e.UserData!.FirstOrDefault(f => f.UserId == filter.User!.Id)!.IsFavorite == filter.IsFavoriteOrLiked);
+ }
+
+ if (filter.IsFavorite.HasValue)
+ {
+ baseQuery = baseQuery
+ .Where(e => e.UserData!.FirstOrDefault(f => f.UserId == filter.User!.Id)!.IsFavorite == filter.IsFavorite);
+ }
+
+ if (filter.IsPlayed.HasValue)
+ {
+ // We should probably figure this out for all folders, but for right now, this is the only place where we need it
+ if (filter.IncludeItemTypes.Length == 1 && filter.IncludeItemTypes[0] == BaseItemKind.Series)
+ {
+ baseQuery = baseQuery.Where(e => context.BaseItems
+ .Where(e => e.IsFolder == false && e.IsVirtualItem == false)
+ .Where(f => f.UserData!.FirstOrDefault(e => e.UserId == filter.User!.Id && e.Played)!.Played)
+ .Any(f => f.SeriesPresentationUniqueKey == e.PresentationUniqueKey) == filter.IsPlayed);
+ }
+ else
+ {
+ baseQuery = baseQuery
+ .Select(e => new
+ {
+ IsPlayed = e.UserData!.Where(f => f.UserId == filter.User!.Id).Select(f => (bool?)f.Played).FirstOrDefault() ?? false,
+ Item = e
+ })
+ .Where(e => e.IsPlayed == filter.IsPlayed)
+ .Select(f => f.Item);
+ }
+ }
+
+ if (filter.IsResumable.HasValue)
+ {
+ if (filter.IsResumable.Value)
+ {
+ baseQuery = baseQuery
+ .Where(e => e.UserData!.FirstOrDefault(f => f.UserId == filter.User!.Id)!.PlaybackPositionTicks > 0);
+ }
+ else
+ {
+ baseQuery = baseQuery
+ .Where(e => e.UserData!.FirstOrDefault(f => f.UserId == filter.User!.Id)!.PlaybackPositionTicks == 0);
+ }
+ }
+
+ if (filter.ArtistIds.Length > 0)
+ {
+ baseQuery = baseQuery
+ .Where(e => e.ItemValues!.Any(f => f.ItemValue.Type <= ItemValueType.Artist && filter.ArtistIds.Contains(f.ItemId)));
+ }
+
+ if (filter.AlbumArtistIds.Length > 0)
+ {
+ baseQuery = baseQuery
+ .Where(e => e.ItemValues!.Any(f => f.ItemValue.Type == ItemValueType.Artist && filter.AlbumArtistIds.Contains(f.ItemId)));
+ }
+
+ if (filter.ContributingArtistIds.Length > 0)
+ {
+ baseQuery = baseQuery
+ .Where(e => e.ItemValues!.Any(f => f.ItemValue.Type == ItemValueType.Artist && filter.ContributingArtistIds.Contains(f.ItemId)));
+ }
+
+ if (filter.AlbumIds.Length > 0)
+ {
+ baseQuery = baseQuery.Where(e => context.BaseItems.Where(f => filter.AlbumIds.Contains(f.Id)).Any(f => f.Name == e.Album));
+ }
+
+ if (filter.ExcludeArtistIds.Length > 0)
+ {
+ baseQuery = baseQuery
+ .Where(e => !e.ItemValues!.Any(f => f.ItemValue.Type == ItemValueType.Artist && filter.ExcludeArtistIds.Contains(f.ItemId)));
+ }
+
+ if (filter.GenreIds.Count > 0)
+ {
+ baseQuery = baseQuery
+ .Where(e => e.ItemValues!.Any(f => f.ItemValue.Type == ItemValueType.Genre && filter.GenreIds.Contains(f.ItemId)));
+ }
+
+ if (filter.Genres.Count > 0)
+ {
+ var cleanGenres = filter.Genres.Select(e => GetCleanValue(e)).ToArray();
+ baseQuery = baseQuery
+ .Where(e => e.ItemValues!.Any(f => f.ItemValue.Type == ItemValueType.Genre && cleanGenres.Contains(f.ItemValue.CleanValue)));
+ }
+
+ if (tags.Count > 0)
+ {
+ var cleanValues = tags.Select(e => GetCleanValue(e)).ToArray();
+ baseQuery = baseQuery
+ .Where(e => e.ItemValues!.Any(f => f.ItemValue.Type == ItemValueType.Tags && cleanValues.Contains(f.ItemValue.CleanValue)));
+ }
+
+ if (excludeTags.Count > 0)
+ {
+ var cleanValues = excludeTags.Select(e => GetCleanValue(e)).ToArray();
+ baseQuery = baseQuery
+ .Where(e => !e.ItemValues!.Any(f => f.ItemValue.Type == ItemValueType.Tags && cleanValues.Contains(f.ItemValue.CleanValue)));
+ }
+
+ if (filter.StudioIds.Length > 0)
+ {
+ baseQuery = baseQuery
+ .Where(e => e.ItemValues!.Any(f => f.ItemValue.Type == ItemValueType.Studios && filter.StudioIds.Contains(f.ItemId)));
+ }
+
+ if (filter.OfficialRatings.Length > 0)
+ {
+ baseQuery = baseQuery
+ .Where(e => filter.OfficialRatings.Contains(e.OfficialRating));
+ }
+
+ Expression>? minParentalRatingFilter = null;
+ if (filter.MinParentalRating != null)
+ {
+ var min = filter.MinParentalRating;
+ minParentalRatingFilter = e => e.InheritedParentalRatingValue >= min.Score || e.InheritedParentalRatingValue == null;
+ if (min.SubScore != null)
+ {
+ minParentalRatingFilter = minParentalRatingFilter.And(e => e.InheritedParentalRatingValue >= min.SubScore || e.InheritedParentalRatingValue == null);
+ }
+ }
+
+ Expression>? maxParentalRatingFilter = null;
+ if (filter.MaxParentalRating != null)
+ {
+ var max = filter.MaxParentalRating;
+ maxParentalRatingFilter = e => e.InheritedParentalRatingValue <= max.Score || e.InheritedParentalRatingValue == null;
+ if (max.SubScore != null)
+ {
+ maxParentalRatingFilter = maxParentalRatingFilter.And(e => e.InheritedParentalRatingValue <= max.SubScore || e.InheritedParentalRatingValue == null);
+ }
+ }
+
+ if (filter.HasParentalRating ?? false)
+ {
+ if (minParentalRatingFilter != null)
+ {
+ baseQuery = baseQuery.Where(minParentalRatingFilter);
+ }
+
+ if (maxParentalRatingFilter != null)
+ {
+ baseQuery = baseQuery.Where(maxParentalRatingFilter);
+ }
+ }
+ else if (filter.BlockUnratedItems.Length > 0)
+ {
+ var unratedItemTypes = filter.BlockUnratedItems.Select(f => f.ToString()).ToArray();
+ Expression> unratedItemFilter = e => e.InheritedParentalRatingValue != null || !unratedItemTypes.Contains(e.UnratedType);
+
+ if (minParentalRatingFilter != null && maxParentalRatingFilter != null)
+ {
+ baseQuery = baseQuery.Where(unratedItemFilter.And(minParentalRatingFilter.And(maxParentalRatingFilter)));
+ }
+ else if (minParentalRatingFilter != null)
+ {
+ baseQuery = baseQuery.Where(unratedItemFilter.And(minParentalRatingFilter));
+ }
+ else if (maxParentalRatingFilter != null)
+ {
+ baseQuery = baseQuery.Where(unratedItemFilter.And(maxParentalRatingFilter));
+ }
+ else
+ {
+ baseQuery = baseQuery.Where(unratedItemFilter);
+ }
+ }
+ else if (minParentalRatingFilter != null || maxParentalRatingFilter != null)
+ {
+ if (minParentalRatingFilter != null)
+ {
+ baseQuery = baseQuery.Where(minParentalRatingFilter);
+ }
+
+ if (maxParentalRatingFilter != null)
+ {
+ baseQuery = baseQuery.Where(maxParentalRatingFilter);
+ }
+ }
+ else if (!filter.HasParentalRating ?? false)
+ {
+ baseQuery = baseQuery
+ .Where(e => e.InheritedParentalRatingValue == null);
+ }
+
+ if (filter.HasOfficialRating.HasValue)
+ {
+ if (filter.HasOfficialRating.Value)
+ {
+ baseQuery = baseQuery
+ .Where(e => e.OfficialRating != null && e.OfficialRating != string.Empty);
+ }
+ else
+ {
+ baseQuery = baseQuery
+ .Where(e => e.OfficialRating == null || e.OfficialRating == string.Empty);
+ }
+ }
+
+ if (filter.HasOverview.HasValue)
+ {
+ if (filter.HasOverview.Value)
+ {
+ baseQuery = baseQuery
+ .Where(e => e.Overview != null && e.Overview != string.Empty);
+ }
+ else
+ {
+ baseQuery = baseQuery
+ .Where(e => e.Overview == null || e.Overview == string.Empty);
+ }
+ }
+
+ if (filter.HasOwnerId.HasValue)
+ {
+ if (filter.HasOwnerId.Value)
+ {
+ baseQuery = baseQuery
+ .Where(e => e.OwnerId != null);
+ }
+ else
+ {
+ baseQuery = baseQuery
+ .Where(e => e.OwnerId == null);
+ }
+ }
+
+ if (!string.IsNullOrWhiteSpace(filter.HasNoAudioTrackWithLanguage))
+ {
+ baseQuery = baseQuery
+ .Where(e => !e.MediaStreams!.Any(f => f.StreamType == MediaStreamTypeEntity.Audio && f.Language == filter.HasNoAudioTrackWithLanguage));
+ }
+
+ if (!string.IsNullOrWhiteSpace(filter.HasNoInternalSubtitleTrackWithLanguage))
+ {
+ baseQuery = baseQuery
+ .Where(e => !e.MediaStreams!.Any(f => f.StreamType == MediaStreamTypeEntity.Subtitle && !f.IsExternal && f.Language == filter.HasNoInternalSubtitleTrackWithLanguage));
+ }
+
+ if (!string.IsNullOrWhiteSpace(filter.HasNoExternalSubtitleTrackWithLanguage))
+ {
+ baseQuery = baseQuery
+ .Where(e => !e.MediaStreams!.Any(f => f.StreamType == MediaStreamTypeEntity.Subtitle && f.IsExternal && f.Language == filter.HasNoExternalSubtitleTrackWithLanguage));
+ }
+
+ if (!string.IsNullOrWhiteSpace(filter.HasNoSubtitleTrackWithLanguage))
+ {
+ baseQuery = baseQuery
+ .Where(e => !e.MediaStreams!.Any(f => f.StreamType == MediaStreamTypeEntity.Subtitle && f.Language == filter.HasNoSubtitleTrackWithLanguage));
+ }
+
+ if (filter.HasSubtitles.HasValue)
+ {
+ baseQuery = baseQuery
+ .Where(e => e.MediaStreams!.Any(f => f.StreamType == MediaStreamTypeEntity.Subtitle) == filter.HasSubtitles.Value);
+ }
+
+ if (filter.HasChapterImages.HasValue)
+ {
+ baseQuery = baseQuery
+ .Where(e => e.Chapters!.Any(f => f.ImagePath != null) == filter.HasChapterImages.Value);
+ }
+
+ if (filter.HasDeadParentId.HasValue && filter.HasDeadParentId.Value)
+ {
+ baseQuery = baseQuery
+ .Where(e => e.ParentId.HasValue && !context.BaseItems.Any(f => f.Id == e.ParentId.Value));
+ }
+
+ if (filter.IsDeadArtist.HasValue && filter.IsDeadArtist.Value)
+ {
+ baseQuery = baseQuery
+ .Where(e => !context.ItemValues.Where(f => _getAllArtistsValueTypes.Contains(f.Type)).Any(f => f.Value == e.Name));
+ }
+
+ if (filter.IsDeadStudio.HasValue && filter.IsDeadStudio.Value)
+ {
+ baseQuery = baseQuery
+ .Where(e => !context.ItemValues.Where(f => _getStudiosValueTypes.Contains(f.Type)).Any(f => f.Value == e.Name));
+ }
+
+ if (filter.IsDeadGenre.HasValue && filter.IsDeadGenre.Value)
+ {
+ baseQuery = baseQuery
+ .Where(e => !context.ItemValues.Where(f => _getGenreValueTypes.Contains(f.Type)).Any(f => f.Value == e.Name));
+ }
+
+ if (filter.IsDeadPerson.HasValue && filter.IsDeadPerson.Value)
+ {
+ baseQuery = baseQuery
+ .Where(e => !context.Peoples.Any(f => f.Name == e.Name));
+ }
+
+ if (filter.Years.Length == 1)
+ {
+ baseQuery = baseQuery
+ .Where(e => e.ProductionYear == filter.Years[0]);
+ }
+ else if (filter.Years.Length > 1)
+ {
+ baseQuery = baseQuery
+ .Where(e => filter.Years.Any(f => f == e.ProductionYear));
+ }
+
+ var isVirtualItem = filter.IsVirtualItem ?? filter.IsMissing;
+ if (isVirtualItem.HasValue)
+ {
+ baseQuery = baseQuery
+ .Where(e => e.IsVirtualItem == isVirtualItem.Value);
+ }
+
+ if (filter.IsSpecialSeason.HasValue)
+ {
+ if (filter.IsSpecialSeason.Value)
+ {
+ baseQuery = baseQuery
+ .Where(e => e.IndexNumber == 0);
+ }
+ else
+ {
+ baseQuery = baseQuery
+ .Where(e => e.IndexNumber != 0);
+ }
+ }
+
+ if (filter.IsUnaired.HasValue)
+ {
+ if (filter.IsUnaired.Value)
+ {
+ baseQuery = baseQuery
+ .Where(e => e.PremiereDate >= now);
+ }
+ else
+ {
+ baseQuery = baseQuery
+ .Where(e => e.PremiereDate < now);
+ }
+ }
+
+ if (filter.MediaTypes.Length > 0)
+ {
+ var mediaTypes = filter.MediaTypes.Select(f => f.ToString()).ToArray();
+ baseQuery = baseQuery
+ .Where(e => mediaTypes.Contains(e.MediaType));
+ }
+
+ if (filter.ItemIds.Length > 0)
+ {
+ baseQuery = baseQuery
+ .Where(e => filter.ItemIds.Contains(e.Id));
+ }
+
+ if (filter.ExcludeItemIds.Length > 0)
+ {
+ baseQuery = baseQuery
+ .Where(e => !filter.ItemIds.Contains(e.Id));
+ }
+
+ if (filter.ExcludeProviderIds is not null && filter.ExcludeProviderIds.Count > 0)
+ {
+ baseQuery = baseQuery.Where(e => !e.Provider!.All(f => !filter.ExcludeProviderIds.All(w => f.ProviderId == w.Key && f.ProviderValue == w.Value)));
+ }
+
+ if (filter.HasAnyProviderId is not null && filter.HasAnyProviderId.Count > 0)
+ {
+ baseQuery = baseQuery.Where(e => e.Provider!.Any(f => !filter.HasAnyProviderId.Any(w => f.ProviderId == w.Key && f.ProviderValue == w.Value)));
+ }
+
+ if (filter.HasImdbId.HasValue)
+ {
+ baseQuery = baseQuery.Where(e => e.Provider!.Any(f => f.ProviderId == "imdb"));
+ }
+
+ if (filter.HasTmdbId.HasValue)
+ {
+ baseQuery = baseQuery.Where(e => e.Provider!.Any(f => f.ProviderId == "tmdb"));
+ }
+
+ if (filter.HasTvdbId.HasValue)
+ {
+ baseQuery = baseQuery.Where(e => e.Provider!.Any(f => f.ProviderId == "tvdb"));
+ }
+
+ var queryTopParentIds = filter.TopParentIds;
+
+ if (queryTopParentIds.Length > 0)
+ {
+ var includedItemByNameTypes = GetItemByNameTypesInQuery(filter);
+ var enableItemsByName = (filter.IncludeItemsByName ?? false) && includedItemByNameTypes.Count > 0;
+ if (enableItemsByName && includedItemByNameTypes.Count > 0)
+ {
+ baseQuery = baseQuery.Where(e => includedItemByNameTypes.Contains(e.Type) || queryTopParentIds.Any(w => w == e.TopParentId!.Value));
+ }
+ else
+ {
+ baseQuery = baseQuery.Where(e => queryTopParentIds.Contains(e.TopParentId!.Value));
+ }
+ }
+
+ if (filter.AncestorIds.Length > 0)
+ {
+ baseQuery = baseQuery.Where(e => e.Children!.Any(f => filter.AncestorIds.Contains(f.ParentItemId)));
+ }
+
+ if (!string.IsNullOrWhiteSpace(filter.AncestorWithPresentationUniqueKey))
+ {
+ baseQuery = baseQuery
+ .Where(e => context.BaseItems.Where(f => f.PresentationUniqueKey == filter.AncestorWithPresentationUniqueKey).Any(f => f.Children!.Any(w => w.ItemId == e.Id)));
+ }
+
+ if (!string.IsNullOrWhiteSpace(filter.SeriesPresentationUniqueKey))
+ {
+ baseQuery = baseQuery
+ .Where(e => e.SeriesPresentationUniqueKey == filter.SeriesPresentationUniqueKey);
+ }
+
+ if (filter.ExcludeInheritedTags.Length > 0)
+ {
+ baseQuery = baseQuery
+ .Where(e => !e.ItemValues!.Where(w => w.ItemValue.Type == ItemValueType.InheritedTags)
+ .Any(f => filter.ExcludeInheritedTags.Contains(f.ItemValue.CleanValue)));
+ }
+
+ if (filter.IncludeInheritedTags.Length > 0)
+ {
+ // Episodes do not store inherit tags from their parents in the database, and the tag may be still required by the client.
+ // In addition to the tags for the episodes themselves, we need to manually query its parent (the season)'s tags as well.
+ if (includeTypes.Length == 1 && includeTypes.FirstOrDefault() is BaseItemKind.Episode)
+ {
+ baseQuery = baseQuery
+ .Where(e => e.ItemValues!.Where(f => f.ItemValue.Type == ItemValueType.InheritedTags)
+ .Any(f => filter.IncludeInheritedTags.Contains(f.ItemValue.CleanValue))
+ ||
+ (e.ParentId.HasValue && context.ItemValuesMap.Where(w => w.ItemId == e.ParentId.Value)!.Where(w => w.ItemValue.Type == ItemValueType.InheritedTags)
+ .Any(f => filter.IncludeInheritedTags.Contains(f.ItemValue.CleanValue))));
+ }
+
+ // A playlist should be accessible to its owner regardless of allowed tags.
+ else if (includeTypes.Length == 1 && includeTypes.FirstOrDefault() is BaseItemKind.Playlist)
+ {
+ baseQuery = baseQuery
+ .Where(e =>
+ e.Parents!
+ .Any(f =>
+ f.ParentItem.ItemValues!.Any(w => w.ItemValue.Type == ItemValueType.Tags && filter.IncludeInheritedTags.Contains(w.ItemValue.CleanValue))
+ || e.Data!.Contains($"OwnerUserId\":\"{filter.User!.Id:N}\"")));
+ // d ^^ this is stupid it hate this.
+ }
+ else
+ {
+ baseQuery = baseQuery
+ .Where(e => e.Parents!.Any(f => f.ParentItem.ItemValues!.Any(w => w.ItemValue.Type == ItemValueType.Tags && filter.IncludeInheritedTags.Contains(w.ItemValue.CleanValue))));
+ }
+ }
+
+ if (filter.SeriesStatuses.Length > 0)
+ {
+ var seriesStatus = filter.SeriesStatuses.Select(e => e.ToString()).ToArray();
+ baseQuery = baseQuery
+ .Where(e => seriesStatus.Any(f => e.Data!.Contains(f)));
+ }
+
+ if (filter.BoxSetLibraryFolders.Length > 0)
+ {
+ var boxsetFolders = filter.BoxSetLibraryFolders.Select(e => e.ToString("N", CultureInfo.InvariantCulture)).ToArray();
+ baseQuery = baseQuery
+ .Where(e => boxsetFolders.Any(f => e.Data!.Contains(f)));
+ }
+
+ if (filter.VideoTypes.Length > 0)
+ {
+ var videoTypeBs = filter.VideoTypes.Select(e => $"\"VideoType\":\"{e}\"");
+ baseQuery = baseQuery
+ .Where(e => videoTypeBs.Any(f => e.Data!.Contains(f)));
+ }
+
+ if (filter.Is3D.HasValue)
+ {
+ if (filter.Is3D.Value)
+ {
+ baseQuery = baseQuery
+ .Where(e => e.Data!.Contains("Video3DFormat"));
+ }
+ else
+ {
+ baseQuery = baseQuery
+ .Where(e => !e.Data!.Contains("Video3DFormat"));
+ }
+ }
+
+ if (filter.IsPlaceHolder.HasValue)
+ {
+ if (filter.IsPlaceHolder.Value)
+ {
+ baseQuery = baseQuery
+ .Where(e => e.Data!.Contains("IsPlaceHolder\":true"));
+ }
+ else
+ {
+ baseQuery = baseQuery
+ .Where(e => !e.Data!.Contains("IsPlaceHolder\":true"));
+ }
+ }
+
+ if (filter.HasSpecialFeature.HasValue)
+ {
+ if (filter.HasSpecialFeature.Value)
+ {
+ baseQuery = baseQuery
+ .Where(e => e.ExtraIds != null);
+ }
+ else
+ {
+ baseQuery = baseQuery
+ .Where(e => e.ExtraIds == null);
+ }
+ }
+
+ if (filter.HasTrailer.HasValue || filter.HasThemeSong.HasValue || filter.HasThemeVideo.HasValue)
+ {
+ if (filter.HasTrailer.GetValueOrDefault() || filter.HasThemeSong.GetValueOrDefault() || filter.HasThemeVideo.GetValueOrDefault())
+ {
+ baseQuery = baseQuery
+ .Where(e => e.ExtraIds != null);
+ }
+ else
+ {
+ baseQuery = baseQuery
+ .Where(e => e.ExtraIds == null);
+ }
+ }
+
+ return baseQuery;
+ }
+}
diff --git a/Jellyfin.Server.Implementations/Item/ChapterRepository.cs b/Jellyfin.Server.Implementations/Item/ChapterRepository.cs
new file mode 100644
index 0000000000..93e15735c9
--- /dev/null
+++ b/Jellyfin.Server.Implementations/Item/ChapterRepository.cs
@@ -0,0 +1,124 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.Immutable;
+using System.Linq;
+using Jellyfin.Database.Implementations;
+using Jellyfin.Database.Implementations.Entities;
+using MediaBrowser.Controller.Chapters;
+using MediaBrowser.Controller.Drawing;
+using MediaBrowser.Model.Dto;
+using MediaBrowser.Model.Entities;
+using Microsoft.EntityFrameworkCore;
+
+namespace Jellyfin.Server.Implementations.Item;
+
+///
+/// The Chapter manager.
+///
+public class ChapterRepository : IChapterRepository
+{
+ private readonly IDbContextFactory _dbProvider;
+ private readonly IImageProcessor _imageProcessor;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The EFCore provider.
+ /// The Image Processor.
+ public ChapterRepository(IDbContextFactory dbProvider, IImageProcessor imageProcessor)
+ {
+ _dbProvider = dbProvider;
+ _imageProcessor = imageProcessor;
+ }
+
+ ///
+ public ChapterInfo? GetChapter(BaseItemDto baseItem, int index)
+ {
+ return GetChapter(baseItem.Id, index);
+ }
+
+ ///
+ public IReadOnlyList GetChapters(BaseItemDto baseItem)
+ {
+ return GetChapters(baseItem.Id);
+ }
+
+ ///
+ public ChapterInfo? GetChapter(Guid baseItemId, int index)
+ {
+ using var context = _dbProvider.CreateDbContext();
+ var chapter = context.Chapters.AsNoTracking()
+ .Select(e => new
+ {
+ chapter = e,
+ baseItemPath = e.Item.Path
+ })
+ .FirstOrDefault(e => e.chapter.ItemId.Equals(baseItemId) && e.chapter.ChapterIndex == index);
+ if (chapter is not null)
+ {
+ return Map(chapter.chapter, chapter.baseItemPath!);
+ }
+
+ return null;
+ }
+
+ ///
+ public IReadOnlyList GetChapters(Guid baseItemId)
+ {
+ using var context = _dbProvider.CreateDbContext();
+ return context.Chapters.AsNoTracking().Where(e => e.ItemId.Equals(baseItemId))
+ .Select(e => new
+ {
+ chapter = e,
+ baseItemPath = e.Item.Path
+ })
+ .AsEnumerable()
+ .Select(e => Map(e.chapter, e.baseItemPath!))
+ .ToArray();
+ }
+
+ ///
+ public void SaveChapters(Guid itemId, IReadOnlyList chapters)
+ {
+ using var context = _dbProvider.CreateDbContext();
+ using (var transaction = context.Database.BeginTransaction())
+ {
+ context.Chapters.Where(e => e.ItemId.Equals(itemId)).ExecuteDelete();
+ for (var i = 0; i < chapters.Count; i++)
+ {
+ var chapter = chapters[i];
+ context.Chapters.Add(Map(chapter, i, itemId));
+ }
+
+ context.SaveChanges();
+ transaction.Commit();
+ }
+ }
+
+ private Chapter Map(ChapterInfo chapterInfo, int index, Guid itemId)
+ {
+ return new Chapter()
+ {
+ ChapterIndex = index,
+ StartPositionTicks = chapterInfo.StartPositionTicks,
+ ImageDateModified = chapterInfo.ImageDateModified,
+ ImagePath = chapterInfo.ImagePath,
+ ItemId = itemId,
+ Name = chapterInfo.Name,
+ Item = null!
+ };
+ }
+
+ private ChapterInfo Map(Chapter chapterInfo, string baseItemPath)
+ {
+ var chapterEntity = new ChapterInfo()
+ {
+ StartPositionTicks = chapterInfo.StartPositionTicks,
+ ImageDateModified = chapterInfo.ImageDateModified.GetValueOrDefault(),
+ ImagePath = chapterInfo.ImagePath,
+ Name = chapterInfo.Name,
+ };
+ chapterEntity.ImageTag = _imageProcessor.GetImageCacheTag(baseItemPath, chapterEntity.ImageDateModified);
+ return chapterEntity;
+ }
+}
diff --git a/Jellyfin.Server.Implementations/Item/KeyframeRepository.cs b/Jellyfin.Server.Implementations/Item/KeyframeRepository.cs
new file mode 100644
index 0000000000..a2267700fb
--- /dev/null
+++ b/Jellyfin.Server.Implementations/Item/KeyframeRepository.cs
@@ -0,0 +1,64 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading;
+using System.Threading.Tasks;
+using Jellyfin.Database.Implementations;
+using Jellyfin.Database.Implementations.Entities;
+using MediaBrowser.Controller.Persistence;
+using Microsoft.EntityFrameworkCore;
+
+namespace Jellyfin.Server.Implementations.Item;
+
+///
+/// Repository for obtaining Keyframe data.
+///
+public class KeyframeRepository : IKeyframeRepository
+{
+ private readonly IDbContextFactory _dbProvider;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The EFCore db factory.
+ public KeyframeRepository(IDbContextFactory dbProvider)
+ {
+ _dbProvider = dbProvider;
+ }
+
+ private static MediaEncoding.Keyframes.KeyframeData Map(KeyframeData entity)
+ {
+ return new MediaEncoding.Keyframes.KeyframeData(
+ entity.TotalDuration,
+ (entity.KeyframeTicks ?? []).ToList());
+ }
+
+ private KeyframeData Map(MediaEncoding.Keyframes.KeyframeData dto, Guid itemId)
+ {
+ return new()
+ {
+ ItemId = itemId,
+ TotalDuration = dto.TotalDuration,
+ KeyframeTicks = dto.KeyframeTicks.ToList()
+ };
+ }
+
+ ///
+ public IReadOnlyList GetKeyframeData(Guid itemId)
+ {
+ using var context = _dbProvider.CreateDbContext();
+
+ return context.KeyframeData.AsNoTracking().Where(e => e.ItemId.Equals(itemId)).Select(e => Map(e)).ToList();
+ }
+
+ ///
+ public async Task SaveKeyframeDataAsync(Guid itemId, MediaEncoding.Keyframes.KeyframeData data, CancellationToken cancellationToken)
+ {
+ using var context = _dbProvider.CreateDbContext();
+ using var transaction = await context.Database.BeginTransactionAsync(cancellationToken).ConfigureAwait(false);
+ await context.KeyframeData.Where(e => e.ItemId.Equals(itemId)).ExecuteDeleteAsync(cancellationToken).ConfigureAwait(false);
+ await context.KeyframeData.AddAsync(Map(data, itemId), cancellationToken).ConfigureAwait(false);
+ await context.SaveChangesAsync(cancellationToken).ConfigureAwait(false);
+ await transaction.CommitAsync(cancellationToken).ConfigureAwait(false);
+ }
+}
diff --git a/Jellyfin.Server.Implementations/Item/MediaAttachmentRepository.cs b/Jellyfin.Server.Implementations/Item/MediaAttachmentRepository.cs
new file mode 100644
index 0000000000..3ae6dbd702
--- /dev/null
+++ b/Jellyfin.Server.Implementations/Item/MediaAttachmentRepository.cs
@@ -0,0 +1,74 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.Immutable;
+using System.Linq;
+using System.Threading;
+using Jellyfin.Database.Implementations;
+using Jellyfin.Database.Implementations.Entities;
+using MediaBrowser.Controller.Persistence;
+using MediaBrowser.Model.Entities;
+using Microsoft.EntityFrameworkCore;
+
+namespace Jellyfin.Server.Implementations.Item;
+
+///
+/// Manager for handling Media Attachments.
+///
+/// Efcore Factory.
+public class MediaAttachmentRepository(IDbContextFactory dbProvider) : IMediaAttachmentRepository
+{
+ ///
+ public void SaveMediaAttachments(
+ Guid id,
+ IReadOnlyList attachments,
+ CancellationToken cancellationToken)
+ {
+ using var context = dbProvider.CreateDbContext();
+ using var transaction = context.Database.BeginTransaction();
+ context.AttachmentStreamInfos.Where(e => e.ItemId.Equals(id)).ExecuteDelete();
+ context.AttachmentStreamInfos.AddRange(attachments.Select(e => Map(e, id)));
+ context.SaveChanges();
+ transaction.Commit();
+ }
+
+ ///
+ public IReadOnlyList GetMediaAttachments(MediaAttachmentQuery filter)
+ {
+ using var context = dbProvider.CreateDbContext();
+ var query = context.AttachmentStreamInfos.AsNoTracking().Where(e => e.ItemId.Equals(filter.ItemId));
+ if (filter.Index.HasValue)
+ {
+ query = query.Where(e => e.Index == filter.Index);
+ }
+
+ return query.AsEnumerable().Select(Map).ToArray();
+ }
+
+ private MediaAttachment Map(AttachmentStreamInfo attachment)
+ {
+ return new MediaAttachment()
+ {
+ Codec = attachment.Codec,
+ CodecTag = attachment.CodecTag,
+ Comment = attachment.Comment,
+ FileName = attachment.Filename,
+ Index = attachment.Index,
+ MimeType = attachment.MimeType,
+ };
+ }
+
+ private AttachmentStreamInfo Map(MediaAttachment attachment, Guid id)
+ {
+ return new AttachmentStreamInfo()
+ {
+ Codec = attachment.Codec,
+ CodecTag = attachment.CodecTag,
+ Comment = attachment.Comment,
+ Filename = attachment.FileName,
+ Index = attachment.Index,
+ MimeType = attachment.MimeType,
+ ItemId = id,
+ Item = null!
+ };
+ }
+}
diff --git a/Jellyfin.Server.Implementations/Item/MediaStreamRepository.cs b/Jellyfin.Server.Implementations/Item/MediaStreamRepository.cs
new file mode 100644
index 0000000000..7eb13b7408
--- /dev/null
+++ b/Jellyfin.Server.Implementations/Item/MediaStreamRepository.cs
@@ -0,0 +1,227 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.Immutable;
+using System.Linq;
+using System.Threading;
+using Jellyfin.Database.Implementations;
+using Jellyfin.Database.Implementations.Entities;
+using MediaBrowser.Controller;
+using MediaBrowser.Controller.Persistence;
+using MediaBrowser.Model.Entities;
+using MediaBrowser.Model.Globalization;
+using Microsoft.EntityFrameworkCore;
+
+namespace Jellyfin.Server.Implementations.Item;
+
+///
+/// Repository for obtaining MediaStreams.
+///
+public class MediaStreamRepository : IMediaStreamRepository
+{
+ private readonly IDbContextFactory _dbProvider;
+ private readonly IServerApplicationHost _serverApplicationHost;
+ private readonly ILocalizationManager _localization;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The EFCore db factory.
+ /// The Application host.
+ /// The Localisation Provider.
+ public MediaStreamRepository(IDbContextFactory dbProvider, IServerApplicationHost serverApplicationHost, ILocalizationManager localization)
+ {
+ _dbProvider = dbProvider;
+ _serverApplicationHost = serverApplicationHost;
+ _localization = localization;
+ }
+
+ ///
+ public void SaveMediaStreams(Guid id, IReadOnlyList streams, CancellationToken cancellationToken)
+ {
+ using var context = _dbProvider.CreateDbContext();
+ using var transaction = context.Database.BeginTransaction();
+
+ context.MediaStreamInfos.Where(e => e.ItemId.Equals(id)).ExecuteDelete();
+ context.MediaStreamInfos.AddRange(streams.Select(f => Map(f, id)));
+ context.SaveChanges();
+
+ transaction.Commit();
+ }
+
+ ///
+ public IReadOnlyList GetMediaStreams(MediaStreamQuery filter)
+ {
+ using var context = _dbProvider.CreateDbContext();
+ return TranslateQuery(context.MediaStreamInfos.AsNoTracking(), filter).AsEnumerable().Select(Map).ToArray();
+ }
+
+ private string? GetPathToSave(string? path)
+ {
+ if (path is null)
+ {
+ return null;
+ }
+
+ return _serverApplicationHost.ReverseVirtualPath(path);
+ }
+
+ private string? RestorePath(string? path)
+ {
+ if (path is null)
+ {
+ return null;
+ }
+
+ return _serverApplicationHost.ExpandVirtualPath(path);
+ }
+
+ private IQueryable TranslateQuery(IQueryable query, MediaStreamQuery filter)
+ {
+ query = query.Where(e => e.ItemId.Equals(filter.ItemId));
+ if (filter.Index.HasValue)
+ {
+ query = query.Where(e => e.StreamIndex == filter.Index);
+ }
+
+ if (filter.Type.HasValue)
+ {
+ var typeValue = (MediaStreamTypeEntity)filter.Type.Value;
+ query = query.Where(e => e.StreamType == typeValue);
+ }
+
+ return query.OrderBy(e => e.StreamIndex);
+ }
+
+ private MediaStream Map(MediaStreamInfo entity)
+ {
+ var dto = new MediaStream();
+ dto.Index = entity.StreamIndex;
+ dto.Type = (MediaStreamType)entity.StreamType;
+
+ dto.IsAVC = entity.IsAvc;
+ dto.Codec = entity.Codec;
+
+ var language = entity.Language;
+
+ // Check if the language has multiple three letter ISO codes
+ // if yes choose the first as that is the ISO 639-2/T code we're needing
+ if (language != null && _localization.TryGetISO6392TFromB(language, out string? isoT))
+ {
+ language = isoT;
+ }
+
+ dto.Language = language;
+
+ dto.ChannelLayout = entity.ChannelLayout;
+ dto.Profile = entity.Profile;
+ dto.AspectRatio = entity.AspectRatio;
+ dto.Path = RestorePath(entity.Path);
+ dto.IsInterlaced = entity.IsInterlaced.GetValueOrDefault();
+ dto.BitRate = entity.BitRate;
+ dto.Channels = entity.Channels;
+ dto.SampleRate = entity.SampleRate;
+ dto.IsDefault = entity.IsDefault;
+ dto.IsForced = entity.IsForced;
+ dto.IsExternal = entity.IsExternal;
+ dto.Height = entity.Height;
+ dto.Width = entity.Width;
+ dto.AverageFrameRate = entity.AverageFrameRate;
+ dto.RealFrameRate = entity.RealFrameRate;
+ dto.Level = entity.Level;
+ dto.PixelFormat = entity.PixelFormat;
+ dto.BitDepth = entity.BitDepth;
+ dto.IsAnamorphic = entity.IsAnamorphic;
+ dto.RefFrames = entity.RefFrames;
+ dto.CodecTag = entity.CodecTag;
+ dto.Comment = entity.Comment;
+ dto.NalLengthSize = entity.NalLengthSize;
+ dto.Title = entity.Title;
+ dto.TimeBase = entity.TimeBase;
+ dto.CodecTimeBase = entity.CodecTimeBase;
+ dto.ColorPrimaries = entity.ColorPrimaries;
+ dto.ColorSpace = entity.ColorSpace;
+ dto.ColorTransfer = entity.ColorTransfer;
+ dto.DvVersionMajor = entity.DvVersionMajor;
+ dto.DvVersionMinor = entity.DvVersionMinor;
+ dto.DvProfile = entity.DvProfile;
+ dto.DvLevel = entity.DvLevel;
+ dto.RpuPresentFlag = entity.RpuPresentFlag;
+ dto.ElPresentFlag = entity.ElPresentFlag;
+ dto.BlPresentFlag = entity.BlPresentFlag;
+ dto.DvBlSignalCompatibilityId = entity.DvBlSignalCompatibilityId;
+ dto.IsHearingImpaired = entity.IsHearingImpaired.GetValueOrDefault();
+ dto.Rotation = entity.Rotation;
+ dto.Hdr10PlusPresentFlag = entity.Hdr10PlusPresentFlag;
+
+ if (dto.Type is MediaStreamType.Audio or MediaStreamType.Subtitle)
+ {
+ dto.LocalizedDefault = _localization.GetLocalizedString("Default");
+ dto.LocalizedExternal = _localization.GetLocalizedString("External");
+
+ if (dto.Type is MediaStreamType.Subtitle)
+ {
+ dto.LocalizedUndefined = _localization.GetLocalizedString("Undefined");
+ dto.LocalizedForced = _localization.GetLocalizedString("Forced");
+ dto.LocalizedHearingImpaired = _localization.GetLocalizedString("HearingImpaired");
+ }
+ }
+
+ return dto;
+ }
+
+ private MediaStreamInfo Map(MediaStream dto, Guid itemId)
+ {
+ var entity = new MediaStreamInfo
+ {
+ Item = null!,
+ ItemId = itemId,
+ StreamIndex = dto.Index,
+ StreamType = (MediaStreamTypeEntity)dto.Type,
+ IsAvc = dto.IsAVC,
+
+ Codec = dto.Codec,
+ Language = dto.Language,
+ ChannelLayout = dto.ChannelLayout,
+ Profile = dto.Profile,
+ AspectRatio = dto.AspectRatio,
+ Path = GetPathToSave(dto.Path) ?? dto.Path,
+ IsInterlaced = dto.IsInterlaced,
+ BitRate = dto.BitRate,
+ Channels = dto.Channels,
+ SampleRate = dto.SampleRate,
+ IsDefault = dto.IsDefault,
+ IsForced = dto.IsForced,
+ IsExternal = dto.IsExternal,
+ Height = dto.Height,
+ Width = dto.Width,
+ AverageFrameRate = dto.AverageFrameRate,
+ RealFrameRate = dto.RealFrameRate,
+ Level = dto.Level.HasValue ? (float)dto.Level : null,
+ PixelFormat = dto.PixelFormat,
+ BitDepth = dto.BitDepth,
+ IsAnamorphic = dto.IsAnamorphic,
+ RefFrames = dto.RefFrames,
+ CodecTag = dto.CodecTag,
+ Comment = dto.Comment,
+ NalLengthSize = dto.NalLengthSize,
+ Title = dto.Title,
+ TimeBase = dto.TimeBase,
+ CodecTimeBase = dto.CodecTimeBase,
+ ColorPrimaries = dto.ColorPrimaries,
+ ColorSpace = dto.ColorSpace,
+ ColorTransfer = dto.ColorTransfer,
+ DvVersionMajor = dto.DvVersionMajor,
+ DvVersionMinor = dto.DvVersionMinor,
+ DvProfile = dto.DvProfile,
+ DvLevel = dto.DvLevel,
+ RpuPresentFlag = dto.RpuPresentFlag,
+ ElPresentFlag = dto.ElPresentFlag,
+ BlPresentFlag = dto.BlPresentFlag,
+ DvBlSignalCompatibilityId = dto.DvBlSignalCompatibilityId,
+ IsHearingImpaired = dto.IsHearingImpaired,
+ Rotation = dto.Rotation,
+ Hdr10PlusPresentFlag = dto.Hdr10PlusPresentFlag,
+ };
+ return entity;
+ }
+}
diff --git a/Jellyfin.Server.Implementations/Item/OrderMapper.cs b/Jellyfin.Server.Implementations/Item/OrderMapper.cs
new file mode 100644
index 0000000000..03249b9274
--- /dev/null
+++ b/Jellyfin.Server.Implementations/Item/OrderMapper.cs
@@ -0,0 +1,57 @@
+using System;
+using System.Linq;
+using System.Linq.Expressions;
+using Jellyfin.Data.Enums;
+using Jellyfin.Database.Implementations.Entities;
+using MediaBrowser.Controller.Entities;
+using Microsoft.EntityFrameworkCore;
+
+namespace Jellyfin.Server.Implementations.Item;
+
+///
+/// Static class for methods which maps types of ordering to their respecting ordering functions.
+///
+public static class OrderMapper
+{
+ ///
+ /// Creates Func to be executed later with a given BaseItemEntity input for sorting items on query.
+ ///
+ /// Item property to sort by.
+ /// Context Query.
+ /// Func to be executed later for sorting query.
+ public static Expression> MapOrderByField(ItemSortBy sortBy, InternalItemsQuery query)
+ {
+ return sortBy switch
+ {
+ ItemSortBy.AirTime => e => e.SortName, // TODO
+ ItemSortBy.Runtime => e => e.RunTimeTicks,
+ ItemSortBy.Random => e => EF.Functions.Random(),
+ ItemSortBy.DatePlayed => e => e.UserData!.FirstOrDefault(f => f.UserId.Equals(query.User!.Id))!.LastPlayedDate,
+ ItemSortBy.PlayCount => e => e.UserData!.FirstOrDefault(f => f.UserId.Equals(query.User!.Id))!.PlayCount,
+ ItemSortBy.IsFavoriteOrLiked => e => e.UserData!.FirstOrDefault(f => f.UserId.Equals(query.User!.Id))!.IsFavorite,
+ ItemSortBy.IsFolder => e => e.IsFolder,
+ ItemSortBy.IsPlayed => e => e.UserData!.FirstOrDefault(f => f.UserId.Equals(query.User!.Id))!.Played,
+ ItemSortBy.IsUnplayed => e => !e.UserData!.FirstOrDefault(f => f.UserId.Equals(query.User!.Id))!.Played,
+ ItemSortBy.DateLastContentAdded => e => e.DateLastMediaAdded,
+ ItemSortBy.Artist => e => e.ItemValues!.Where(f => f.ItemValue.Type == ItemValueType.Artist).Select(f => f.ItemValue.CleanValue).FirstOrDefault(),
+ ItemSortBy.AlbumArtist => e => e.ItemValues!.Where(f => f.ItemValue.Type == ItemValueType.AlbumArtist).Select(f => f.ItemValue.CleanValue).FirstOrDefault(),
+ ItemSortBy.Studio => e => e.ItemValues!.Where(f => f.ItemValue.Type == ItemValueType.Studios).Select(f => f.ItemValue.CleanValue).FirstOrDefault(),
+ ItemSortBy.OfficialRating => e => e.InheritedParentalRatingValue,
+ // ItemSortBy.SeriesDatePlayed => "(Select MAX(LastPlayedDate) from TypedBaseItems B" + GetJoinUserDataText(query) + " where Played=1 and B.SeriesPresentationUniqueKey=A.PresentationUniqueKey)",
+ ItemSortBy.SeriesSortName => e => e.SeriesName,
+ // ItemSortBy.AiredEpisodeOrder => "AiredEpisodeOrder",
+ ItemSortBy.Album => e => e.Album,
+ ItemSortBy.DateCreated => e => e.DateCreated,
+ ItemSortBy.PremiereDate => e => (e.PremiereDate ?? (e.ProductionYear.HasValue ? DateTime.MinValue.AddYears(e.ProductionYear.Value - 1) : null)),
+ ItemSortBy.StartDate => e => e.StartDate,
+ ItemSortBy.Name => e => e.Name,
+ ItemSortBy.CommunityRating => e => e.CommunityRating,
+ ItemSortBy.ProductionYear => e => e.ProductionYear,
+ ItemSortBy.CriticRating => e => e.CriticRating,
+ ItemSortBy.VideoBitRate => e => e.TotalBitrate,
+ ItemSortBy.ParentIndexNumber => e => e.ParentIndexNumber,
+ ItemSortBy.IndexNumber => e => e.IndexNumber,
+ _ => e => e.SortName
+ };
+ }
+}
diff --git a/Jellyfin.Server.Implementations/Item/PeopleRepository.cs b/Jellyfin.Server.Implementations/Item/PeopleRepository.cs
new file mode 100644
index 0000000000..77877835e0
--- /dev/null
+++ b/Jellyfin.Server.Implementations/Item/PeopleRepository.cs
@@ -0,0 +1,200 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.Immutable;
+using System.Linq;
+using Jellyfin.Data.Enums;
+using Jellyfin.Database.Implementations;
+using Jellyfin.Database.Implementations.Entities;
+using Jellyfin.Extensions;
+using MediaBrowser.Controller.Entities;
+using MediaBrowser.Controller.Persistence;
+using Microsoft.EntityFrameworkCore;
+
+namespace Jellyfin.Server.Implementations.Item;
+#pragma warning disable RS0030 // Do not use banned APIs
+#pragma warning disable CA1304 // Specify CultureInfo
+#pragma warning disable CA1311 // Specify a culture or use an invariant version
+#pragma warning disable CA1862 // Use the 'StringComparison' method overloads to perform case-insensitive string comparisons
+
+///
+/// Manager for handling people.
+///
+/// Efcore Factory.
+/// Items lookup service.
+///
+/// Initializes a new instance of the class.
+///
+public class PeopleRepository(IDbContextFactory dbProvider, IItemTypeLookup itemTypeLookup) : IPeopleRepository
+{
+ private readonly IDbContextFactory _dbProvider = dbProvider;
+
+ ///
+ public IReadOnlyList GetPeople(InternalPeopleQuery filter)
+ {
+ using var context = _dbProvider.CreateDbContext();
+ var dbQuery = TranslateQuery(context.Peoples.AsNoTracking(), context, filter);
+
+ // dbQuery = dbQuery.OrderBy(e => e.ListOrder);
+ if (filter.Limit > 0)
+ {
+ dbQuery = dbQuery.Take(filter.Limit);
+ }
+
+ // Include PeopleBaseItemMap
+ if (!filter.ItemId.IsEmpty())
+ {
+ dbQuery = dbQuery.Include(p => p.BaseItems!.Where(m => m.ItemId == filter.ItemId));
+ }
+
+ return dbQuery.AsEnumerable().Select(Map).ToArray();
+ }
+
+ ///
+ public IReadOnlyList GetPeopleNames(InternalPeopleQuery filter)
+ {
+ using var context = _dbProvider.CreateDbContext();
+ var dbQuery = TranslateQuery(context.Peoples.AsNoTracking(), context, filter);
+
+ // dbQuery = dbQuery.OrderBy(e => e.ListOrder);
+ if (filter.Limit > 0)
+ {
+ dbQuery = dbQuery.Take(filter.Limit);
+ }
+
+ return dbQuery.Select(e => e.Name).ToArray();
+ }
+
+ ///
+ public void UpdatePeople(Guid itemId, IReadOnlyList people)
+ {
+ using var context = _dbProvider.CreateDbContext();
+ using var transaction = context.Database.BeginTransaction();
+
+ context.PeopleBaseItemMap.Where(e => e.ItemId == itemId).ExecuteDelete();
+ // TODO: yes for __SOME__ reason there can be duplicates.
+ foreach (var item in people.DistinctBy(e => e.Id))
+ {
+ var personEntity = Map(item);
+ var existingEntity = context.Peoples.FirstOrDefault(e => e.Id == personEntity.Id);
+ if (existingEntity is null)
+ {
+ context.Peoples.Add(personEntity);
+ existingEntity = personEntity;
+ }
+
+ context.PeopleBaseItemMap.Add(new PeopleBaseItemMap()
+ {
+ Item = null!,
+ ItemId = itemId,
+ People = existingEntity,
+ PeopleId = existingEntity.Id,
+ ListOrder = item.SortOrder,
+ SortOrder = item.SortOrder,
+ Role = item.Role
+ });
+ }
+
+ context.SaveChanges();
+ transaction.Commit();
+ }
+
+ private PersonInfo Map(People people)
+ {
+ var mapping = people.BaseItems?.FirstOrDefault();
+ var personInfo = new PersonInfo()
+ {
+ Id = people.Id,
+ Name = people.Name,
+ Role = mapping?.Role,
+ SortOrder = mapping?.SortOrder
+ };
+ if (Enum.TryParse(people.PersonType, out var kind))
+ {
+ personInfo.Type = kind;
+ }
+
+ return personInfo;
+ }
+
+ private People Map(PersonInfo people)
+ {
+ var personInfo = new People()
+ {
+ Name = people.Name,
+ PersonType = people.Type.ToString(),
+ Id = people.Id,
+ };
+
+ return personInfo;
+ }
+
+ private IQueryable TranslateQuery(IQueryable query, JellyfinDbContext context, InternalPeopleQuery filter)
+ {
+ if (filter.User is not null && filter.IsFavorite.HasValue)
+ {
+ var personType = itemTypeLookup.BaseItemKindNames[BaseItemKind.Person];
+ query = query.Where(e => e.PersonType == personType)
+ .Where(e => context.BaseItems.Where(d => d.UserData!.Any(w => w.IsFavorite == filter.IsFavorite && w.UserId.Equals(filter.User.Id)))
+ .Select(f => f.Name).Contains(e.Name));
+ }
+
+ if (!filter.ItemId.IsEmpty())
+ {
+ query = query.Where(e => e.BaseItems!.Any(w => w.ItemId.Equals(filter.ItemId)));
+ }
+
+ if (!filter.AppearsInItemId.IsEmpty())
+ {
+ query = query.Where(e => e.BaseItems!.Any(w => w.ItemId.Equals(filter.AppearsInItemId)));
+ }
+
+ var queryPersonTypes = filter.PersonTypes.Where(IsValidPersonType).ToList();
+ if (queryPersonTypes.Count > 0)
+ {
+ query = query.Where(e => queryPersonTypes.Contains(e.PersonType));
+ }
+
+ var queryExcludePersonTypes = filter.ExcludePersonTypes.Where(IsValidPersonType).ToList();
+
+ if (queryExcludePersonTypes.Count > 0)
+ {
+ query = query.Where(e => !queryPersonTypes.Contains(e.PersonType));
+ }
+
+ if (filter.MaxListOrder.HasValue && !filter.ItemId.IsEmpty())
+ {
+ query = query.Where(e => e.BaseItems!.First(w => w.ItemId == filter.ItemId).ListOrder <= filter.MaxListOrder.Value);
+ }
+
+ if (!string.IsNullOrWhiteSpace(filter.NameContains))
+ {
+ var nameContainsUpper = filter.NameContains.ToUpper();
+ query = query.Where(e => e.Name.ToUpper().Contains(nameContainsUpper));
+ }
+
+ return query;
+ }
+
+ private bool IsAlphaNumeric(string str)
+ {
+ if (string.IsNullOrWhiteSpace(str))
+ {
+ return false;
+ }
+
+ for (int i = 0; i < str.Length; i++)
+ {
+ if (!char.IsLetter(str[i]) && !char.IsNumber(str[i]))
+ {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ private bool IsValidPersonType(string value)
+ {
+ return IsAlphaNumeric(value);
+ }
+}
diff --git a/Jellyfin.Server.Implementations/Jellyfin.Server.Implementations.csproj b/Jellyfin.Server.Implementations/Jellyfin.Server.Implementations.csproj
index 20944ee4b2..6693ab8dbd 100644
--- a/Jellyfin.Server.Implementations/Jellyfin.Server.Implementations.csproj
+++ b/Jellyfin.Server.Implementations/Jellyfin.Server.Implementations.csproj
@@ -1,7 +1,7 @@
- net8.0
+ net9.0
false
true
@@ -28,22 +28,15 @@
-
-
- all
- runtime; build; native; contentfiles; analyzers; buildtransitive
-
-
- all
- runtime; build; native; contentfiles; analyzers; buildtransitive
-
+
+
diff --git a/Jellyfin.Server.Implementations/MediaSegments/MediaSegmentManager.cs b/Jellyfin.Server.Implementations/MediaSegments/MediaSegmentManager.cs
index d641f521b9..d6eeafacc3 100644
--- a/Jellyfin.Server.Implementations/MediaSegments/MediaSegmentManager.cs
+++ b/Jellyfin.Server.Implementations/MediaSegments/MediaSegmentManager.cs
@@ -5,8 +5,9 @@ using System.Globalization;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
-using Jellyfin.Data.Entities;
-using Jellyfin.Data.Enums;
+using Jellyfin.Database.Implementations;
+using Jellyfin.Database.Implementations.Entities;
+using Jellyfin.Database.Implementations.Enums;
using Jellyfin.Extensions;
using MediaBrowser.Common.Extensions;
using MediaBrowser.Controller;
@@ -22,7 +23,7 @@ using Microsoft.Extensions.Logging;
namespace Jellyfin.Server.Implementations.MediaSegments;
///
-/// Manages media segments retrival and storage.
+/// Manages media segments retrieval and storage.
///
public class MediaSegmentManager : IMediaSegmentManager
{
@@ -61,7 +62,7 @@ public class MediaSegmentManager : IMediaSegmentManager
.Where(e => !libraryOptions.DisabledMediaSegmentProviders.Contains(GetProviderId(e.Name)))
.OrderBy(i =>
{
- var index = libraryOptions.MediaSegmentProvideOrder.IndexOf(i.Name);
+ var index = libraryOptions.MediaSegmentProviderOrder.IndexOf(i.Name);
return index == -1 ? int.MaxValue : index;
})
.ToList();
@@ -139,23 +140,53 @@ public class MediaSegmentManager : IMediaSegmentManager
}
///
- public async Task> GetSegmentsAsync(Guid itemId, IEnumerable? typeFilter)
+ public async Task> GetSegmentsAsync(Guid itemId, IEnumerable? typeFilter, bool filterByProvider = true)
+ {
+ var baseItem = _libraryManager.GetItemById(itemId);
+
+ if (baseItem is null)
+ {
+ _logger.LogError("Tried to request segments for an invalid item");
+ return [];
+ }
+
+ return await GetSegmentsAsync(baseItem, typeFilter, filterByProvider).ConfigureAwait(false);
+ }
+
+ ///
+ public async Task> GetSegmentsAsync(BaseItem item, IEnumerable? typeFilter, bool filterByProvider = true)
{
using var db = await _dbProvider.CreateDbContextAsync().ConfigureAwait(false);
var query = db.MediaSegments
- .Where(e => e.ItemId.Equals(itemId));
+ .Where(e => e.ItemId.Equals(item.Id));
if (typeFilter is not null)
{
query = query.Where(e => typeFilter.Contains(e.Type));
}
+ if (filterByProvider)
+ {
+ var libraryOptions = _libraryManager.GetLibraryOptions(item);
+ var providerIds = _segmentProviders
+ .Where(e => !libraryOptions.DisabledMediaSegmentProviders.Contains(GetProviderId(e.Name)))
+ .Select(f => GetProviderId(f.Name))
+ .ToArray();
+ if (providerIds.Length == 0)
+ {
+ return [];
+ }
+
+ query = query.Where(e => providerIds.Contains(e.SegmentProviderId));
+ }
+
return query
.OrderBy(e => e.StartTicks)
.AsNoTracking()
- .ToImmutableList()
- .Select(Map);
+ .AsEnumerable()
+ .Select(Map)
+ .ToArray();
}
private static MediaSegmentDto Map(MediaSegment segment)
diff --git a/Jellyfin.Server.Implementations/Migrations/DesignTimeJellyfinDbFactory.cs b/Jellyfin.Server.Implementations/Migrations/DesignTimeJellyfinDbFactory.cs
deleted file mode 100644
index 940cf7c5d5..0000000000
--- a/Jellyfin.Server.Implementations/Migrations/DesignTimeJellyfinDbFactory.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-using Microsoft.EntityFrameworkCore;
-using Microsoft.EntityFrameworkCore.Design;
-
-namespace Jellyfin.Server.Implementations.Migrations
-{
- ///
- /// The design time factory for .
- /// This is only used for the creation of migrations and not during runtime.
- ///
- internal class DesignTimeJellyfinDbFactory : IDesignTimeDbContextFactory
- {
- public JellyfinDbContext CreateDbContext(string[] args)
- {
- var optionsBuilder = new DbContextOptionsBuilder();
- optionsBuilder.UseSqlite("Data Source=jellyfin.db");
-
- return new JellyfinDbContext(optionsBuilder.Options);
- }
- }
-}
diff --git a/Jellyfin.Server.Implementations/Migrations/JellyfinDbModelSnapshot.cs b/Jellyfin.Server.Implementations/Migrations/JellyfinDbModelSnapshot.cs
deleted file mode 100644
index 6e1f985ba7..0000000000
--- a/Jellyfin.Server.Implementations/Migrations/JellyfinDbModelSnapshot.cs
+++ /dev/null
@@ -1,709 +0,0 @@
-//
-using System;
-using Jellyfin.Server.Implementations;
-using Microsoft.EntityFrameworkCore;
-using Microsoft.EntityFrameworkCore.Infrastructure;
-using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
-
-#nullable disable
-
-namespace Jellyfin.Server.Implementations.Migrations
-{
- [DbContext(typeof(JellyfinDbContext))]
- partial class JellyfinDbModelSnapshot : ModelSnapshot
- {
- protected override void BuildModel(ModelBuilder modelBuilder)
- {
-#pragma warning disable 612, 618
- modelBuilder.HasAnnotation("ProductVersion", "8.0.8");
-
- modelBuilder.Entity("Jellyfin.Data.Entities.AccessSchedule", b =>
- {
- b.Property("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("INTEGER");
-
- b.Property("DayOfWeek")
- .HasColumnType("INTEGER");
-
- b.Property("EndHour")
- .HasColumnType("REAL");
-
- b.Property("StartHour")
- .HasColumnType("REAL");
-
- b.Property("UserId")
- .HasColumnType("TEXT");
-
- b.HasKey("Id");
-
- b.HasIndex("UserId");
-
- b.ToTable("AccessSchedules");
- });
-
- modelBuilder.Entity("Jellyfin.Data.Entities.ActivityLog", b =>
- {
- b.Property("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("INTEGER");
-
- b.Property("DateCreated")
- .HasColumnType("TEXT");
-
- b.Property("ItemId")
- .HasMaxLength(256)
- .HasColumnType("TEXT");
-
- b.Property("LogSeverity")
- .HasColumnType("INTEGER");
-
- b.Property("Name")
- .IsRequired()
- .HasMaxLength(512)
- .HasColumnType("TEXT");
-
- b.Property("Overview")
- .HasMaxLength(512)
- .HasColumnType("TEXT");
-
- b.Property("RowVersion")
- .IsConcurrencyToken()
- .HasColumnType("INTEGER");
-
- b.Property("ShortOverview")
- .HasMaxLength(512)
- .HasColumnType("TEXT");
-
- b.Property("Type")
- .IsRequired()
- .HasMaxLength(256)
- .HasColumnType("TEXT");
-
- b.Property("UserId")
- .HasColumnType("TEXT");
-
- b.HasKey("Id");
-
- b.HasIndex("DateCreated");
-
- b.ToTable("ActivityLogs");
- });
-
- modelBuilder.Entity("Jellyfin.Data.Entities.CustomItemDisplayPreferences", b =>
- {
- b.Property("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("INTEGER");
-
- b.Property("Client")
- .IsRequired()
- .HasMaxLength(32)
- .HasColumnType("TEXT");
-
- b.Property("ItemId")
- .HasColumnType("TEXT");
-
- b.Property("Key")
- .IsRequired()
- .HasColumnType("TEXT");
-
- b.Property("UserId")
- .HasColumnType("TEXT");
-
- b.Property("Value")
- .HasColumnType("TEXT");
-
- b.HasKey("Id");
-
- b.HasIndex("UserId", "ItemId", "Client", "Key")
- .IsUnique();
-
- b.ToTable("CustomItemDisplayPreferences");
- });
-
- modelBuilder.Entity("Jellyfin.Data.Entities.DisplayPreferences", b =>
- {
- b.Property("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("INTEGER");
-
- b.Property("ChromecastVersion")
- .HasColumnType("INTEGER");
-
- b.Property("Client")
- .IsRequired()
- .HasMaxLength(32)
- .HasColumnType("TEXT");
-
- b.Property("DashboardTheme")
- .HasMaxLength(32)
- .HasColumnType("TEXT");
-
- b.Property("EnableNextVideoInfoOverlay")
- .HasColumnType("INTEGER");
-
- b.Property("IndexBy")
- .HasColumnType("INTEGER");
-
- b.Property("ItemId")
- .HasColumnType("TEXT");
-
- b.Property("ScrollDirection")
- .HasColumnType("INTEGER");
-
- b.Property("ShowBackdrop")
- .HasColumnType("INTEGER");
-
- b.Property("ShowSidebar")
- .HasColumnType("INTEGER");
-
- b.Property("SkipBackwardLength")
- .HasColumnType("INTEGER");
-
- b.Property("SkipForwardLength")
- .HasColumnType("INTEGER");
-
- b.Property("TvHome")
- .HasMaxLength(32)
- .HasColumnType("TEXT");
-
- b.Property("UserId")
- .HasColumnType("TEXT");
-
- b.HasKey("Id");
-
- b.HasIndex("UserId", "ItemId", "Client")
- .IsUnique();
-
- b.ToTable("DisplayPreferences");
- });
-
- modelBuilder.Entity("Jellyfin.Data.Entities.HomeSection", b =>
- {
- b.Property("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("INTEGER");
-
- b.Property("DisplayPreferencesId")
- .HasColumnType("INTEGER");
-
- b.Property("Order")
- .HasColumnType("INTEGER");
-
- b.Property("Type")
- .HasColumnType("INTEGER");
-
- b.HasKey("Id");
-
- b.HasIndex("DisplayPreferencesId");
-
- b.ToTable("HomeSection");
- });
-
- modelBuilder.Entity("Jellyfin.Data.Entities.ImageInfo", b =>
- {
- b.Property("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("INTEGER");
-
- b.Property("LastModified")
- .HasColumnType("TEXT");
-
- b.Property("Path")
- .IsRequired()
- .HasMaxLength(512)
- .HasColumnType("TEXT");
-
- b.Property("UserId")
- .HasColumnType("TEXT");
-
- b.HasKey("Id");
-
- b.HasIndex("UserId")
- .IsUnique();
-
- b.ToTable("ImageInfos");
- });
-
- modelBuilder.Entity("Jellyfin.Data.Entities.ItemDisplayPreferences", b =>
- {
- b.Property("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("INTEGER");
-
- b.Property("Client")
- .IsRequired()
- .HasMaxLength(32)
- .HasColumnType("TEXT");
-
- b.Property("IndexBy")
- .HasColumnType("INTEGER");
-
- b.Property("ItemId")
- .HasColumnType("TEXT");
-
- b.Property("RememberIndexing")
- .HasColumnType("INTEGER");
-
- b.Property("RememberSorting")
- .HasColumnType("INTEGER");
-
- b.Property("SortBy")
- .IsRequired()
- .HasMaxLength(64)
- .HasColumnType("TEXT");
-
- b.Property("SortOrder")
- .HasColumnType("INTEGER");
-
- b.Property("UserId")
- .HasColumnType("TEXT");
-
- b.Property("ViewType")
- .HasColumnType("INTEGER");
-
- b.HasKey("Id");
-
- b.HasIndex("UserId");
-
- b.ToTable("ItemDisplayPreferences");
- });
-
- modelBuilder.Entity("Jellyfin.Data.Entities.MediaSegment", b =>
- {
- b.Property("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("TEXT");
-
- b.Property("EndTicks")
- .HasColumnType("INTEGER");
-
- b.Property("ItemId")
- .HasColumnType("TEXT");
-
- b.Property("SegmentProviderId")
- .IsRequired()
- .HasColumnType("TEXT");
-
- b.Property("StartTicks")
- .HasColumnType("INTEGER");
-
- b.Property("Type")
- .HasColumnType("INTEGER");
-
- b.HasKey("Id");
-
- b.ToTable("MediaSegments");
- });
-
- modelBuilder.Entity("Jellyfin.Data.Entities.Permission", b =>
- {
- b.Property("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("INTEGER");
-
- b.Property("Kind")
- .HasColumnType("INTEGER");
-
- b.Property("Permission_Permissions_Guid")
- .HasColumnType("TEXT");
-
- b.Property("RowVersion")
- .IsConcurrencyToken()
- .HasColumnType("INTEGER");
-
- b.Property("UserId")
- .HasColumnType("TEXT");
-
- b.Property("Value")
- .HasColumnType("INTEGER");
-
- b.HasKey("Id");
-
- b.HasIndex("UserId", "Kind")
- .IsUnique()
- .HasFilter("[UserId] IS NOT NULL");
-
- b.ToTable("Permissions");
- });
-
- modelBuilder.Entity("Jellyfin.Data.Entities.Preference", b =>
- {
- b.Property("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("INTEGER");
-
- b.Property("Kind")
- .HasColumnType("INTEGER");
-
- b.Property("Preference_Preferences_Guid")
- .HasColumnType("TEXT");
-
- b.Property("RowVersion")
- .IsConcurrencyToken()
- .HasColumnType("INTEGER");
-
- b.Property("UserId")
- .HasColumnType("TEXT");
-
- b.Property("Value")
- .IsRequired()
- .HasMaxLength(65535)
- .HasColumnType("TEXT");
-
- b.HasKey("Id");
-
- b.HasIndex("UserId", "Kind")
- .IsUnique()
- .HasFilter("[UserId] IS NOT NULL");
-
- b.ToTable("Preferences");
- });
-
- modelBuilder.Entity("Jellyfin.Data.Entities.Security.ApiKey", b =>
- {
- b.Property("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("INTEGER");
-
- b.Property("AccessToken")
- .IsRequired()
- .HasColumnType("TEXT");
-
- b.Property("DateCreated")
- .HasColumnType("TEXT");
-
- b.Property("DateLastActivity")
- .HasColumnType("TEXT");
-
- b.Property("Name")
- .IsRequired()
- .HasMaxLength(64)
- .HasColumnType("TEXT");
-
- b.HasKey("Id");
-
- b.HasIndex("AccessToken")
- .IsUnique();
-
- b.ToTable("ApiKeys");
- });
-
- modelBuilder.Entity("Jellyfin.Data.Entities.Security.Device", b =>
- {
- b.Property("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("INTEGER");
-
- b.Property("AccessToken")
- .IsRequired()
- .HasColumnType("TEXT");
-
- b.Property("AppName")
- .IsRequired()
- .HasMaxLength(64)
- .HasColumnType("TEXT");
-
- b.Property("AppVersion")
- .IsRequired()
- .HasMaxLength(32)
- .HasColumnType("TEXT");
-
- b.Property("DateCreated")
- .HasColumnType("TEXT");
-
- b.Property("DateLastActivity")
- .HasColumnType("TEXT");
-
- b.Property("DateModified")
- .HasColumnType("TEXT");
-
- b.Property("DeviceId")
- .IsRequired()
- .HasMaxLength(256)
- .HasColumnType("TEXT");
-
- b.Property("DeviceName")
- .IsRequired()
- .HasMaxLength(64)
- .HasColumnType("TEXT");
-
- b.Property("IsActive")
- .HasColumnType("INTEGER");
-
- b.Property("UserId")
- .HasColumnType("TEXT");
-
- b.HasKey("Id");
-
- b.HasIndex("DeviceId");
-
- b.HasIndex("AccessToken", "DateLastActivity");
-
- b.HasIndex("DeviceId", "DateLastActivity");
-
- b.HasIndex("UserId", "DeviceId");
-
- b.ToTable("Devices");
- });
-
- modelBuilder.Entity("Jellyfin.Data.Entities.Security.DeviceOptions", b =>
- {
- b.Property("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("INTEGER");
-
- b.Property("CustomName")
- .HasColumnType("TEXT");
-
- b.Property("DeviceId")
- .IsRequired()
- .HasColumnType("TEXT");
-
- b.HasKey("Id");
-
- b.HasIndex("DeviceId")
- .IsUnique();
-
- b.ToTable("DeviceOptions");
- });
-
- modelBuilder.Entity("Jellyfin.Data.Entities.TrickplayInfo", b =>
- {
- b.Property("ItemId")
- .HasColumnType("TEXT");
-
- b.Property("Width")
- .HasColumnType("INTEGER");
-
- b.Property("Bandwidth")
- .HasColumnType("INTEGER");
-
- b.Property("Height")
- .HasColumnType("INTEGER");
-
- b.Property("Interval")
- .HasColumnType("INTEGER");
-
- b.Property("ThumbnailCount")
- .HasColumnType("INTEGER");
-
- b.Property("TileHeight")
- .HasColumnType("INTEGER");
-
- b.Property("TileWidth")
- .HasColumnType("INTEGER");
-
- b.HasKey("ItemId", "Width");
-
- b.ToTable("TrickplayInfos");
- });
-
- modelBuilder.Entity("Jellyfin.Data.Entities.User", b =>
- {
- b.Property("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("TEXT");
-
- b.Property("AudioLanguagePreference")
- .HasMaxLength(255)
- .HasColumnType("TEXT");
-
- b.Property("AuthenticationProviderId")
- .IsRequired()
- .HasMaxLength(255)
- .HasColumnType("TEXT");
-
- b.Property("CastReceiverId")
- .HasMaxLength(32)
- .HasColumnType("TEXT");
-
- b.Property("DisplayCollectionsView")
- .HasColumnType("INTEGER");
-
- b.Property("DisplayMissingEpisodes")
- .HasColumnType("INTEGER");
-
- b.Property("EnableAutoLogin")
- .HasColumnType("INTEGER");
-
- b.Property("EnableLocalPassword")
- .HasColumnType("INTEGER");
-
- b.Property("EnableNextEpisodeAutoPlay")
- .HasColumnType("INTEGER");
-
- b.Property("EnableUserPreferenceAccess")
- .HasColumnType("INTEGER");
-
- b.Property("HidePlayedInLatest")
- .HasColumnType("INTEGER");
-
- b.Property("InternalId")
- .HasColumnType("INTEGER");
-
- b.Property("InvalidLoginAttemptCount")
- .HasColumnType("INTEGER");
-
- b.Property("LastActivityDate")
- .HasColumnType("TEXT");
-
- b.Property("LastLoginDate")
- .HasColumnType("TEXT");
-
- b.Property("LoginAttemptsBeforeLockout")
- .HasColumnType("INTEGER");
-
- b.Property("MaxActiveSessions")
- .HasColumnType("INTEGER");
-
- b.Property("MaxParentalAgeRating")
- .HasColumnType("INTEGER");
-
- b.Property("MustUpdatePassword")
- .HasColumnType("INTEGER");
-
- b.Property("Password")
- .HasMaxLength(65535)
- .HasColumnType("TEXT");
-
- b.Property("PasswordResetProviderId")
- .IsRequired()
- .HasMaxLength(255)
- .HasColumnType("TEXT");
-
- b.Property("PlayDefaultAudioTrack")
- .HasColumnType("INTEGER");
-
- b.Property("RememberAudioSelections")
- .HasColumnType("INTEGER");
-
- b.Property("RememberSubtitleSelections")
- .HasColumnType("INTEGER");
-
- b.Property("RemoteClientBitrateLimit")
- .HasColumnType("INTEGER");
-
- b.Property("RowVersion")
- .IsConcurrencyToken()
- .HasColumnType("INTEGER");
-
- b.Property("SubtitleLanguagePreference")
- .HasMaxLength(255)
- .HasColumnType("TEXT");
-
- b.Property("SubtitleMode")
- .HasColumnType("INTEGER");
-
- b.Property("SyncPlayAccess")
- .HasColumnType("INTEGER");
-
- b.Property("Username")
- .IsRequired()
- .HasMaxLength(255)
- .HasColumnType("TEXT")
- .UseCollation("NOCASE");
-
- b.HasKey("Id");
-
- b.HasIndex("Username")
- .IsUnique();
-
- b.ToTable("Users");
- });
-
- modelBuilder.Entity("Jellyfin.Data.Entities.AccessSchedule", b =>
- {
- b.HasOne("Jellyfin.Data.Entities.User", null)
- .WithMany("AccessSchedules")
- .HasForeignKey("UserId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
- });
-
- modelBuilder.Entity("Jellyfin.Data.Entities.DisplayPreferences", b =>
- {
- b.HasOne("Jellyfin.Data.Entities.User", null)
- .WithMany("DisplayPreferences")
- .HasForeignKey("UserId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
- });
-
- modelBuilder.Entity("Jellyfin.Data.Entities.HomeSection", b =>
- {
- b.HasOne("Jellyfin.Data.Entities.DisplayPreferences", null)
- .WithMany("HomeSections")
- .HasForeignKey("DisplayPreferencesId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
- });
-
- modelBuilder.Entity("Jellyfin.Data.Entities.ImageInfo", b =>
- {
- b.HasOne("Jellyfin.Data.Entities.User", null)
- .WithOne("ProfileImage")
- .HasForeignKey("Jellyfin.Data.Entities.ImageInfo", "UserId")
- .OnDelete(DeleteBehavior.Cascade);
- });
-
- modelBuilder.Entity("Jellyfin.Data.Entities.ItemDisplayPreferences", b =>
- {
- b.HasOne("Jellyfin.Data.Entities.User", null)
- .WithMany("ItemDisplayPreferences")
- .HasForeignKey("UserId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
- });
-
- modelBuilder.Entity("Jellyfin.Data.Entities.Permission", b =>
- {
- b.HasOne("Jellyfin.Data.Entities.User", null)
- .WithMany("Permissions")
- .HasForeignKey("UserId")
- .OnDelete(DeleteBehavior.Cascade);
- });
-
- modelBuilder.Entity("Jellyfin.Data.Entities.Preference", b =>
- {
- b.HasOne("Jellyfin.Data.Entities.User", null)
- .WithMany("Preferences")
- .HasForeignKey("UserId")
- .OnDelete(DeleteBehavior.Cascade);
- });
-
- modelBuilder.Entity("Jellyfin.Data.Entities.Security.Device", b =>
- {
- b.HasOne("Jellyfin.Data.Entities.User", "User")
- .WithMany()
- .HasForeignKey("UserId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
-
- b.Navigation("User");
- });
-
- modelBuilder.Entity("Jellyfin.Data.Entities.DisplayPreferences", b =>
- {
- b.Navigation("HomeSections");
- });
-
- modelBuilder.Entity("Jellyfin.Data.Entities.User", b =>
- {
- b.Navigation("AccessSchedules");
-
- b.Navigation("DisplayPreferences");
-
- b.Navigation("ItemDisplayPreferences");
-
- b.Navigation("Permissions");
-
- b.Navigation("Preferences");
-
- b.Navigation("ProfileImage");
- });
-#pragma warning restore 612, 618
- }
- }
-}
diff --git a/Jellyfin.Server.Implementations/ModelBuilderExtensions.cs b/Jellyfin.Server.Implementations/ModelBuilderExtensions.cs
deleted file mode 100644
index 79ae1661aa..0000000000
--- a/Jellyfin.Server.Implementations/ModelBuilderExtensions.cs
+++ /dev/null
@@ -1,48 +0,0 @@
-using System;
-using Jellyfin.Server.Implementations.ValueConverters;
-using Microsoft.EntityFrameworkCore;
-using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
-
-namespace Jellyfin.Server.Implementations
-{
- ///
- /// Model builder extensions.
- ///
- public static class ModelBuilderExtensions
- {
- ///
- /// Specify value converter for the object type.
- ///
- /// The model builder.
- /// The .
- /// The type to convert.
- /// The modified .
- public static ModelBuilder UseValueConverterForType(this ModelBuilder modelBuilder, ValueConverter converter)
- {
- var type = typeof(T);
- foreach (var entityType in modelBuilder.Model.GetEntityTypes())
- {
- foreach (var property in entityType.GetProperties())
- {
- if (property.ClrType == type)
- {
- property.SetValueConverter(converter);
- }
- }
- }
-
- return modelBuilder;
- }
-
- ///
- /// Specify the default .
- ///
- /// The model builder to extend.
- /// The to specify.
- public static void SetDefaultDateTimeKind(this ModelBuilder modelBuilder, DateTimeKind kind)
- {
- modelBuilder.UseValueConverterForType(new DateTimeKindValueConverter(kind));
- modelBuilder.UseValueConverterForType(new DateTimeKindValueConverter(kind));
- }
- }
-}
diff --git a/Jellyfin.Server.Implementations/Security/AuthenticationManager.cs b/Jellyfin.Server.Implementations/Security/AuthenticationManager.cs
index 1c9f54ab03..cf0293463f 100644
--- a/Jellyfin.Server.Implementations/Security/AuthenticationManager.cs
+++ b/Jellyfin.Server.Implementations/Security/AuthenticationManager.cs
@@ -1,7 +1,8 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
-using Jellyfin.Data.Entities.Security;
+using Jellyfin.Database.Implementations;
+using Jellyfin.Database.Implementations.Entities.Security;
using MediaBrowser.Controller.Security;
using Microsoft.EntityFrameworkCore;
diff --git a/Jellyfin.Server.Implementations/Security/AuthorizationContext.cs b/Jellyfin.Server.Implementations/Security/AuthorizationContext.cs
index 2ae722982a..e3fe517c49 100644
--- a/Jellyfin.Server.Implementations/Security/AuthorizationContext.cs
+++ b/Jellyfin.Server.Implementations/Security/AuthorizationContext.cs
@@ -5,8 +5,10 @@ using System.Collections.Generic;
using System.Net;
using System.Threading.Tasks;
using Jellyfin.Data.Queries;
+using Jellyfin.Database.Implementations;
using Jellyfin.Extensions;
using MediaBrowser.Controller;
+using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Devices;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Net;
@@ -22,17 +24,20 @@ namespace Jellyfin.Server.Implementations.Security
private readonly IUserManager _userManager;
private readonly IDeviceManager _deviceManager;
private readonly IServerApplicationHost _serverApplicationHost;
+ private readonly IServerConfigurationManager _configurationManager;
public AuthorizationContext(
IDbContextFactory jellyfinDb,
IUserManager userManager,
IDeviceManager deviceManager,
- IServerApplicationHost serverApplicationHost)
+ IServerApplicationHost serverApplicationHost,
+ IServerConfigurationManager configurationManager)
{
_jellyfinDbProvider = jellyfinDb;
_userManager = userManager;
_deviceManager = deviceManager;
_serverApplicationHost = serverApplicationHost;
+ _configurationManager = configurationManager;
}
public Task GetAuthorizationInfo(HttpContext requestContext)
@@ -85,12 +90,12 @@ namespace Jellyfin.Server.Implementations.Security
auth.TryGetValue("Token", out token);
}
- if (string.IsNullOrEmpty(token))
+ if (_configurationManager.Configuration.EnableLegacyAuthorization && string.IsNullOrEmpty(token))
{
token = headers["X-Emby-Token"];
}
- if (string.IsNullOrEmpty(token))
+ if (_configurationManager.Configuration.EnableLegacyAuthorization && string.IsNullOrEmpty(token))
{
token = headers["X-MediaBrowser-Token"];
}
@@ -100,8 +105,7 @@ namespace Jellyfin.Server.Implementations.Security
token = queryString["ApiKey"];
}
- // TODO deprecate this query parameter.
- if (string.IsNullOrEmpty(token))
+ if (_configurationManager.Configuration.EnableLegacyAuthorization && string.IsNullOrEmpty(token))
{
token = queryString["api_key"];
}
@@ -113,25 +117,20 @@ namespace Jellyfin.Server.Implementations.Security
DeviceId = deviceId,
Version = version,
Token = token,
- IsAuthenticated = false,
- HasToken = false
+ IsAuthenticated = false
};
- if (string.IsNullOrWhiteSpace(token))
+ if (!authInfo.HasToken)
{
// Request doesn't contain a token.
return authInfo;
}
- authInfo.HasToken = true;
var dbContext = await _jellyfinDbProvider.CreateDbContextAsync().ConfigureAwait(false);
await using (dbContext.ConfigureAwait(false))
{
var device = _deviceManager.GetDevices(
- new DeviceQuery
- {
- AccessToken = token
- }).Items.FirstOrDefault();
+ new DeviceQuery { AccessToken = token }).Items.FirstOrDefault();
if (device is not null)
{
@@ -227,13 +226,13 @@ namespace Jellyfin.Server.Implementations.Security
///
/// The HTTP request.
/// Dictionary{System.StringSystem.String}.
- private static Dictionary? GetAuthorizationDictionary(HttpRequest httpReq)
+ private Dictionary? GetAuthorizationDictionary(HttpRequest httpReq)
{
- var auth = httpReq.Headers["X-Emby-Authorization"];
+ var auth = httpReq.Headers[HeaderNames.Authorization];
- if (string.IsNullOrEmpty(auth))
+ if (_configurationManager.Configuration.EnableLegacyAuthorization && string.IsNullOrEmpty(auth))
{
- auth = httpReq.Headers[HeaderNames.Authorization];
+ auth = httpReq.Headers["X-Emby-Authorization"];
}
return auth.Count > 0 ? GetAuthorization(auth[0]) : null;
@@ -244,7 +243,7 @@ namespace Jellyfin.Server.Implementations.Security
///
/// The authorization header.
/// Dictionary{System.StringSystem.String}.
- private static Dictionary? GetAuthorization(ReadOnlySpan authorizationHeader)
+ private Dictionary? GetAuthorization(ReadOnlySpan