mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-12-11 19:43:07 +03:00
Compare commits
32 Commits
openapi-ca
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d70e0fe9cf | ||
|
|
053cc9406d | ||
|
|
0f85120c5e | ||
|
|
25aef7fabf | ||
|
|
492ea66841 | ||
|
|
8b2a8b94b6 | ||
|
|
f24e80701c | ||
|
|
0b3d6676d1 | ||
|
|
c3a8734adf | ||
|
|
8fd59d6f33 | ||
|
|
da3bff3edf | ||
|
|
45cb5a0008 | ||
|
|
ea097fb1a3 | ||
|
|
a25b48b151 | ||
|
|
873f1d9e83 | ||
|
|
294439bf74 | ||
|
|
6e74be0d46 | ||
|
|
deb81eae10 | ||
|
|
70dcf3f7b3 | ||
|
|
ebcfed83c4 | ||
|
|
5d46278584 | ||
|
|
4f020a947a | ||
|
|
3460d1de3c | ||
|
|
7d2e4cd817 | ||
|
|
8cd6ef37c4 | ||
|
|
e4daaf0d83 | ||
|
|
69c98af9f9 | ||
|
|
7425a493ee | ||
|
|
691c194152 | ||
|
|
2f8896c375 | ||
|
|
5182aec13f | ||
|
|
217ea488df |
11
.github/ISSUE_TEMPLATE/issue report.yml
vendored
11
.github/ISSUE_TEMPLATE/issue report.yml
vendored
@@ -87,6 +87,7 @@ body:
|
||||
label: Jellyfin Server version
|
||||
description: What version of Jellyfin are you using?
|
||||
options:
|
||||
- 10.11.4
|
||||
- 10.11.3
|
||||
- 10.11.2
|
||||
- 10.11.1
|
||||
@@ -139,13 +140,14 @@ body:
|
||||
- **FFmpeg Version**: [e.g. 5.1.2-Jellyfin]
|
||||
- **Playback**: [Direct Play, Remux, Direct Stream, Transcode]
|
||||
- **Hardware Acceleration**: [e.g. none, VAAPI, NVENC, etc.]
|
||||
- **CPU Model**: [e.g. AMD Ryzen 5 9600X, Intel Core i7-8565U, etc.]
|
||||
- **GPU Model**: [e.g. none, UHD630, GTX1050, etc.]
|
||||
- **Installed Plugins**: [e.g. none, Fanart, Anime, etc.]
|
||||
- **Reverse Proxy**: [e.g. none, nginx, apache, etc.]
|
||||
- **Base URL**: [e.g. none, yes: /example]
|
||||
- **Networking**: [e.g. Host, Bridge/NAT]
|
||||
- **Jellyfin Data Storage**: [e.g. local SATA SSD, local HDD]
|
||||
- **Media Storage**: [e.g. Local HDD, SMB Share]
|
||||
- **Jellyfin Data Storage & Filesystem**: [e.g. local SATA SSD - ext4, local HDD - NTFS]
|
||||
- **Media Storage & Filesystem**: [e.g. Local HDD - ext4, SMB Share]
|
||||
- **External Integrations**: [e.g. Jellystat, Jellyseerr]
|
||||
value: |
|
||||
- OS:
|
||||
@@ -156,13 +158,14 @@ body:
|
||||
- FFmpeg Version:
|
||||
- Playback Method:
|
||||
- Hardware Acceleration:
|
||||
- CPU Model:
|
||||
- GPU Model:
|
||||
- Plugins:
|
||||
- Reverse Proxy:
|
||||
- Base URL:
|
||||
- Networking:
|
||||
- Jellyfin Data Storage:
|
||||
- Media Storage:
|
||||
- Jellyfin Data Storage & Filesystem:
|
||||
- Media Storage & Filesystem:
|
||||
- External Integrations:
|
||||
render: markdown
|
||||
validations:
|
||||
|
||||
8
.github/workflows/ci-codeql-analysis.yml
vendored
8
.github/workflows/ci-codeql-analysis.yml
vendored
@@ -20,18 +20,18 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
|
||||
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
||||
- name: Setup .NET
|
||||
uses: actions/setup-dotnet@2016bd2012dba4e32de620c46fe006a3ac9f0602 # v5.0.1
|
||||
with:
|
||||
dotnet-version: '9.0.x'
|
||||
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@fdbfb4d2750291e159f0156def62b853c2798ca2 # v4.31.5
|
||||
uses: github/codeql-action/init@cf1bb45a277cb3c205638b2cd5c984db1c46a412 # v4.31.7
|
||||
with:
|
||||
languages: ${{ matrix.language }}
|
||||
queries: +security-extended
|
||||
- name: Autobuild
|
||||
uses: github/codeql-action/autobuild@fdbfb4d2750291e159f0156def62b853c2798ca2 # v4.31.5
|
||||
uses: github/codeql-action/autobuild@cf1bb45a277cb3c205638b2cd5c984db1c46a412 # v4.31.7
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@fdbfb4d2750291e159f0156def62b853c2798ca2 # v4.31.5
|
||||
uses: github/codeql-action/analyze@cf1bb45a277cb3c205638b2cd5c984db1c46a412 # v4.31.7
|
||||
|
||||
4
.github/workflows/ci-compat.yml
vendored
4
.github/workflows/ci-compat.yml
vendored
@@ -11,7 +11,7 @@ jobs:
|
||||
permissions: read-all
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
|
||||
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
||||
with:
|
||||
ref: ${{ github.event.pull_request.head.sha }}
|
||||
repository: ${{ github.event.pull_request.head.repo.full_name }}
|
||||
@@ -40,7 +40,7 @@ jobs:
|
||||
permissions: read-all
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
|
||||
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
||||
with:
|
||||
ref: ${{ github.event.pull_request.head.sha }}
|
||||
repository: ${{ github.event.pull_request.head.repo.full_name }}
|
||||
|
||||
4
.github/workflows/ci-openapi.yml
vendored
4
.github/workflows/ci-openapi.yml
vendored
@@ -16,7 +16,7 @@ jobs:
|
||||
permissions: read-all
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
|
||||
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
||||
with:
|
||||
ref: ${{ github.event.pull_request.head.sha }}
|
||||
repository: ${{ github.event.pull_request.head.repo.full_name }}
|
||||
@@ -41,7 +41,7 @@ jobs:
|
||||
permissions: read-all
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
|
||||
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
||||
with:
|
||||
ref: ${{ github.event.pull_request.head.sha }}
|
||||
repository: ${{ github.event.pull_request.head.repo.full_name }}
|
||||
|
||||
4
.github/workflows/ci-tests.yml
vendored
4
.github/workflows/ci-tests.yml
vendored
@@ -20,7 +20,7 @@ jobs:
|
||||
|
||||
runs-on: "${{ matrix.os }}"
|
||||
steps:
|
||||
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
|
||||
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
||||
|
||||
- uses: actions/setup-dotnet@2016bd2012dba4e32de620c46fe006a3ac9f0602 # v5.0.1
|
||||
with:
|
||||
@@ -35,7 +35,7 @@ jobs:
|
||||
--verbosity minimal
|
||||
|
||||
- name: Merge code coverage results
|
||||
uses: danielpalme/ReportGenerator-GitHub-Action@dcdfb6e704e87df6b2ed0cf123a6c9f69e364869 # v5.5.0
|
||||
uses: danielpalme/ReportGenerator-GitHub-Action@ee0ae774f6d3afedcbd1683c1ab21b83670bdf8e # v5.5.1
|
||||
with:
|
||||
reports: "**/coverage.cobertura.xml"
|
||||
targetdir: "merged/"
|
||||
|
||||
4
.github/workflows/commands.yml
vendored
4
.github/workflows/commands.yml
vendored
@@ -24,7 +24,7 @@ jobs:
|
||||
reactions: '+1'
|
||||
|
||||
- name: Checkout the latest code
|
||||
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
|
||||
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
||||
with:
|
||||
token: ${{ secrets.JF_BOT_TOKEN }}
|
||||
fetch-depth: 0
|
||||
@@ -40,7 +40,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: pull in script
|
||||
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
|
||||
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
||||
with:
|
||||
repository: jellyfin/jellyfin-triage-script
|
||||
- name: install python
|
||||
|
||||
2
.github/workflows/issue-stale.yml
vendored
2
.github/workflows/issue-stale.yml
vendored
@@ -16,7 +16,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
if: ${{ contains(github.repository, 'jellyfin/') }}
|
||||
steps:
|
||||
- uses: actions/stale@5f858e3efba33a5ca4407a664cc011ad407f2008 # v10.1.0
|
||||
- uses: actions/stale@997185467fa4f803885201cee163a9f38240193d # v10.1.1
|
||||
with:
|
||||
repo-token: ${{ secrets.JF_BOT_TOKEN }}
|
||||
ascending: true
|
||||
|
||||
2
.github/workflows/issue-template-check.yml
vendored
2
.github/workflows/issue-template-check.yml
vendored
@@ -10,7 +10,7 @@ jobs:
|
||||
issues: write
|
||||
steps:
|
||||
- name: pull in script
|
||||
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
|
||||
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
||||
with:
|
||||
repository: jellyfin/jellyfin-triage-script
|
||||
- name: install python
|
||||
|
||||
2
.github/workflows/pull-request-stale.yaml
vendored
2
.github/workflows/pull-request-stale.yaml
vendored
@@ -15,7 +15,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
if: ${{ contains(github.repository, 'jellyfin/') }}
|
||||
steps:
|
||||
- uses: actions/stale@5f858e3efba33a5ca4407a664cc011ad407f2008 # v10.1.0
|
||||
- uses: actions/stale@997185467fa4f803885201cee163a9f38240193d # v10.1.1
|
||||
with:
|
||||
repo-token: ${{ secrets.JF_BOT_TOKEN }}
|
||||
ascending: true
|
||||
|
||||
4
.github/workflows/release-bump-version.yaml
vendored
4
.github/workflows/release-bump-version.yaml
vendored
@@ -33,7 +33,7 @@ jobs:
|
||||
yq-version: v4.9.8
|
||||
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
|
||||
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
||||
with:
|
||||
ref: ${{ env.TAG_BRANCH }}
|
||||
|
||||
@@ -66,7 +66,7 @@ jobs:
|
||||
NEXT_VERSION: ${{ github.event.inputs.NEXT_VERSION }}
|
||||
steps:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
|
||||
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
||||
with:
|
||||
ref: ${{ env.TAG_BRANCH }}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
</PropertyGroup>
|
||||
<!-- Run "dotnet list package (dash,dash)outdated" to see the latest versions of each package.-->
|
||||
<ItemGroup Label="Package Dependencies">
|
||||
<PackageVersion Include="AsyncKeyedLock" Version="7.1.7" />
|
||||
<PackageVersion Include="AsyncKeyedLock" Version="7.1.8" />
|
||||
<PackageVersion Include="AutoFixture.AutoMoq" Version="4.18.1" />
|
||||
<PackageVersion Include="AutoFixture.Xunit2" Version="4.18.1" />
|
||||
<PackageVersion Include="AutoFixture" Version="4.18.1" />
|
||||
@@ -74,9 +74,9 @@
|
||||
<PackageVersion Include="SerilogAnalyzer" Version="0.15.0" />
|
||||
<PackageVersion Include="SharpFuzz" Version="2.2.0" />
|
||||
<!-- Pinned to 3.116.1 because https://github.com/jellyfin/jellyfin/pull/14255 -->
|
||||
<PackageVersion Include="SkiaSharp" Version="3.116.1" />
|
||||
<PackageVersion Include="SkiaSharp.HarfBuzz" Version="3.116.1" />
|
||||
<PackageVersion Include="SkiaSharp.NativeAssets.Linux" Version="3.116.1" />
|
||||
<PackageVersion Include="SkiaSharp" Version="[3.116.1]" />
|
||||
<PackageVersion Include="SkiaSharp.HarfBuzz" Version="[3.116.1]" />
|
||||
<PackageVersion Include="SkiaSharp.NativeAssets.Linux" Version="[3.116.1]" />
|
||||
<PackageVersion Include="SmartAnalyzers.MultithreadingAnalyzer" Version="1.1.31" />
|
||||
<PackageVersion Include="StyleCop.Analyzers" Version="1.2.0-beta.556" />
|
||||
<PackageVersion Include="Svg.Skia" Version="3.2.1" />
|
||||
@@ -96,4 +96,4 @@
|
||||
<PackageVersion Include="Xunit.SkippableFact" Version="1.5.23" />
|
||||
<PackageVersion Include="xunit" Version="2.9.3" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
|
||||
@@ -497,8 +497,17 @@ namespace Emby.Server.Implementations.IO
|
||||
/// <inheritdoc />
|
||||
public virtual bool AreEqual(string path1, string path2)
|
||||
{
|
||||
return Path.TrimEndingDirectorySeparator(path1).Equals(
|
||||
Path.TrimEndingDirectorySeparator(path2),
|
||||
if (string.IsNullOrWhiteSpace(path1) || string.IsNullOrWhiteSpace(path2))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var normalized1 = Path.TrimEndingDirectorySeparator(path1);
|
||||
var normalized2 = Path.TrimEndingDirectorySeparator(path2);
|
||||
|
||||
return string.Equals(
|
||||
normalized1,
|
||||
normalized2,
|
||||
_isEnvironmentCaseInsensitive ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal);
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace Emby.Server.Implementations.Library
|
||||
results = results.GetRange(query.StartIndex.Value, totalRecordCount - query.StartIndex.Value);
|
||||
}
|
||||
|
||||
if (query.Limit.HasValue)
|
||||
if (query.Limit.HasValue && query.Limit.Value > 0)
|
||||
{
|
||||
results = results.GetRange(0, Math.Min(query.Limit.Value, results.Count));
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
"Folders": "المجلدات",
|
||||
"Genres": "التصنيفات",
|
||||
"HeaderAlbumArtists": "فناني الألبوم",
|
||||
"HeaderContinueWatching": "إستئناف المشاهدة",
|
||||
"HeaderContinueWatching": "أكمل المشاهدة",
|
||||
"HeaderFavoriteAlbums": "الألبومات المفضلة",
|
||||
"HeaderFavoriteArtists": "الفنانون المفضلون",
|
||||
"HeaderFavoriteEpisodes": "الحلقات المفضلة",
|
||||
|
||||
9
Emby.Server.Implementations/Localization/Core/mi.json
Normal file
9
Emby.Server.Implementations/Localization/Core/mi.json
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"Albums": "Pukaemi",
|
||||
"AppDeviceValues": "Taupānga: {0}, Pūrere: {1}",
|
||||
"Application": "Taupānga",
|
||||
"Artists": "Kaiwaiata",
|
||||
"AuthenticationSucceededWithUserName": "{0} has been successfully authenticated",
|
||||
"Books": "Ngā pukapuka",
|
||||
"CameraImageUploadedFrom": "Kua tuku ake he whakaahua kāmera hou mai i {0}"
|
||||
}
|
||||
1
Emby.Server.Implementations/Localization/Core/sw.json
Normal file
1
Emby.Server.Implementations/Localization/Core/sw.json
Normal file
@@ -0,0 +1 @@
|
||||
{}
|
||||
@@ -266,7 +266,7 @@ namespace Emby.Server.Implementations.TV
|
||||
items = items.Skip(query.StartIndex.Value);
|
||||
}
|
||||
|
||||
if (query.Limit.HasValue)
|
||||
if (query.Limit.HasValue && query.Limit.Value > 0)
|
||||
{
|
||||
items = items.Take(query.Limit.Value);
|
||||
}
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Jellyfin.Api.Constants;
|
||||
using Jellyfin.Data.Enums;
|
||||
using Jellyfin.Data.Queries;
|
||||
using Jellyfin.Database.Implementations.Enums;
|
||||
using MediaBrowser.Common.Api;
|
||||
using MediaBrowser.Model.Activity;
|
||||
using MediaBrowser.Model.Querying;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Jellyfin.Api.Controllers;
|
||||
|
||||
@@ -32,10 +35,19 @@ public class ActivityLogController : BaseJellyfinApiController
|
||||
/// <summary>
|
||||
/// Gets activity log entries.
|
||||
/// </summary>
|
||||
/// <param name="startIndex">Optional. The record index to start at. All items with a lower index will be dropped from the results.</param>
|
||||
/// <param name="limit">Optional. The maximum number of records to return.</param>
|
||||
/// <param name="minDate">Optional. The minimum date. Format = ISO.</param>
|
||||
/// <param name="hasUserId">Optional. Filter log entries if it has user id, or not.</param>
|
||||
/// <param name="startIndex">The record index to start at. All items with a lower index will be dropped from the results.</param>
|
||||
/// <param name="limit">The maximum number of records to return.</param>
|
||||
/// <param name="minDate">The minimum date.</param>
|
||||
/// <param name="hasUserId">Filter log entries if it has user id, or not.</param>
|
||||
/// <param name="name">Filter by name.</param>
|
||||
/// <param name="overview">Filter by overview.</param>
|
||||
/// <param name="shortOverview">Filter by short overview.</param>
|
||||
/// <param name="type">Filter by type.</param>
|
||||
/// <param name="itemId">Filter by item id.</param>
|
||||
/// <param name="username">Filter by username.</param>
|
||||
/// <param name="severity">Filter by log severity.</param>
|
||||
/// <param name="sortBy">Specify one or more sort orders. Format: SortBy=Name,Type.</param>
|
||||
/// <param name="sortOrder">Sort Order..</param>
|
||||
/// <response code="200">Activity log returned.</response>
|
||||
/// <returns>A <see cref="QueryResult{ActivityLogEntry}"/> containing the log entries.</returns>
|
||||
[HttpGet("Entries")]
|
||||
@@ -44,14 +56,60 @@ public class ActivityLogController : BaseJellyfinApiController
|
||||
[FromQuery] int? startIndex,
|
||||
[FromQuery] int? limit,
|
||||
[FromQuery] DateTime? minDate,
|
||||
[FromQuery] bool? hasUserId)
|
||||
[FromQuery] bool? hasUserId,
|
||||
[FromQuery] string? name,
|
||||
[FromQuery] string? overview,
|
||||
[FromQuery] string? shortOverview,
|
||||
[FromQuery] string? type,
|
||||
[FromQuery] Guid? itemId,
|
||||
[FromQuery] string? username,
|
||||
[FromQuery] LogLevel? severity,
|
||||
[FromQuery] ActivityLogSortBy[]? sortBy,
|
||||
[FromQuery] SortOrder[]? sortOrder)
|
||||
{
|
||||
return await _activityManager.GetPagedResultAsync(new ActivityLogQuery
|
||||
var query = new ActivityLogQuery
|
||||
{
|
||||
Skip = startIndex,
|
||||
Limit = limit,
|
||||
MinDate = minDate,
|
||||
HasUserId = hasUserId
|
||||
}).ConfigureAwait(false);
|
||||
HasUserId = hasUserId,
|
||||
Name = name,
|
||||
Overview = overview,
|
||||
ShortOverview = shortOverview,
|
||||
Type = type,
|
||||
ItemId = itemId,
|
||||
Username = username,
|
||||
Severity = severity,
|
||||
OrderBy = GetOrderBy(sortBy ?? [], sortOrder ?? []),
|
||||
};
|
||||
|
||||
return await _activityManager.GetPagedResultAsync(query).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
private static (ActivityLogSortBy SortBy, SortOrder SortOrder)[] GetOrderBy(
|
||||
IReadOnlyList<ActivityLogSortBy> sortBy,
|
||||
IReadOnlyList<SortOrder> requestedSortOrder)
|
||||
{
|
||||
if (sortBy.Count == 0)
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
var result = new (ActivityLogSortBy, SortOrder)[sortBy.Count];
|
||||
var i = 0;
|
||||
for (; i < requestedSortOrder.Count; i++)
|
||||
{
|
||||
result[i] = (sortBy[i], requestedSortOrder[i]);
|
||||
}
|
||||
|
||||
// Add remaining elements with the first specified SortOrder
|
||||
// or the default one if no SortOrders are specified
|
||||
var order = requestedSortOrder.Count > 0 ? requestedSortOrder[0] : SortOrder.Ascending;
|
||||
for (; i < sortBy.Count; i++)
|
||||
{
|
||||
result[i] = (sortBy[i], order);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ using Jellyfin.Extensions;
|
||||
using MediaBrowser.Controller.Dto;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Entities.Audio;
|
||||
using MediaBrowser.Controller.Entities.TV;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Controller.Providers;
|
||||
using MediaBrowser.Model.Dto;
|
||||
@@ -568,7 +569,7 @@ public class UserLibraryController : BaseJellyfinApiController
|
||||
var item = i.Item2[0];
|
||||
var childCount = 0;
|
||||
|
||||
if (i.Item1 is not null && (i.Item2.Count > 1 || i.Item1 is MusicAlbum))
|
||||
if (i.Item1 is not null && (i.Item2.Count > 1 || i.Item1 is MusicAlbum || i.Item1 is Series ))
|
||||
{
|
||||
item = i.Item1;
|
||||
childCount = i.Item2.Count;
|
||||
|
||||
49
Jellyfin.Data/Enums/ActivityLogSortBy.cs
Normal file
49
Jellyfin.Data/Enums/ActivityLogSortBy.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
namespace Jellyfin.Data.Enums;
|
||||
|
||||
/// <summary>
|
||||
/// Activity log sorting options.
|
||||
/// </summary>
|
||||
public enum ActivityLogSortBy
|
||||
{
|
||||
/// <summary>
|
||||
/// Sort by name.
|
||||
/// </summary>
|
||||
Name = 0,
|
||||
|
||||
/// <summary>
|
||||
/// Sort by overview.
|
||||
/// </summary>
|
||||
Overiew = 1,
|
||||
|
||||
/// <summary>
|
||||
/// Sort by short overview.
|
||||
/// </summary>
|
||||
ShortOverview = 2,
|
||||
|
||||
/// <summary>
|
||||
/// Sort by type.
|
||||
/// </summary>
|
||||
Type = 3,
|
||||
|
||||
/*
|
||||
/// <summary>
|
||||
/// Sort by item name.
|
||||
/// </summary>
|
||||
Item = 4,
|
||||
*/
|
||||
|
||||
/// <summary>
|
||||
/// Sort by date.
|
||||
/// </summary>
|
||||
DateCreated = 5,
|
||||
|
||||
/// <summary>
|
||||
/// Sort by username.
|
||||
/// </summary>
|
||||
Username = 6,
|
||||
|
||||
/// <summary>
|
||||
/// Sort by severity.
|
||||
/// </summary>
|
||||
LogSeverity = 7
|
||||
}
|
||||
@@ -1,20 +1,63 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Jellyfin.Data.Enums;
|
||||
using Jellyfin.Database.Implementations.Enums;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Jellyfin.Data.Queries
|
||||
namespace Jellyfin.Data.Queries;
|
||||
|
||||
/// <summary>
|
||||
/// A class representing a query to the activity logs.
|
||||
/// </summary>
|
||||
public class ActivityLogQuery : PaginatedQuery
|
||||
{
|
||||
/// <summary>
|
||||
/// A class representing a query to the activity logs.
|
||||
/// Gets or sets a value indicating whether to take entries with a user id.
|
||||
/// </summary>
|
||||
public class ActivityLogQuery : PaginatedQuery
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether to take entries with a user id.
|
||||
/// </summary>
|
||||
public bool? HasUserId { get; set; }
|
||||
public bool? HasUserId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the minimum date to query for.
|
||||
/// </summary>
|
||||
public DateTime? MinDate { get; set; }
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets or sets the minimum date to query for.
|
||||
/// </summary>
|
||||
public DateTime? MinDate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the name filter.
|
||||
/// </summary>
|
||||
public string? Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the overview filter.
|
||||
/// </summary>
|
||||
public string? Overview { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the short overview filter.
|
||||
/// </summary>
|
||||
public string? ShortOverview { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the type filter.
|
||||
/// </summary>
|
||||
public string? Type { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the item filter.
|
||||
/// </summary>
|
||||
public Guid? ItemId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the username filter.
|
||||
/// </summary>
|
||||
public string? Username { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the log level filter.
|
||||
/// </summary>
|
||||
public LogLevel? Severity { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the result ordering.
|
||||
/// </summary>
|
||||
public IReadOnlyCollection<(ActivityLogSortBy, SortOrder)>? OrderBy { get; set; }
|
||||
}
|
||||
|
||||
@@ -1,103 +1,198 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Threading.Tasks;
|
||||
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.Enums;
|
||||
using Jellyfin.Extensions;
|
||||
using MediaBrowser.Model.Activity;
|
||||
using MediaBrowser.Model.Querying;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Jellyfin.Server.Implementations.Activity
|
||||
namespace Jellyfin.Server.Implementations.Activity;
|
||||
|
||||
/// <summary>
|
||||
/// Manages the storage and retrieval of <see cref="ActivityLog"/> instances.
|
||||
/// </summary>
|
||||
public class ActivityManager : IActivityManager
|
||||
{
|
||||
private readonly IDbContextFactory<JellyfinDbContext> _provider;
|
||||
|
||||
/// <summary>
|
||||
/// Manages the storage and retrieval of <see cref="ActivityLog"/> instances.
|
||||
/// Initializes a new instance of the <see cref="ActivityManager"/> class.
|
||||
/// </summary>
|
||||
public class ActivityManager : IActivityManager
|
||||
/// <param name="provider">The Jellyfin database provider.</param>
|
||||
public ActivityManager(IDbContextFactory<JellyfinDbContext> provider)
|
||||
{
|
||||
private readonly IDbContextFactory<JellyfinDbContext> _provider;
|
||||
_provider = provider;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ActivityManager"/> class.
|
||||
/// </summary>
|
||||
/// <param name="provider">The Jellyfin database provider.</param>
|
||||
public ActivityManager(IDbContextFactory<JellyfinDbContext> provider)
|
||||
/// <inheritdoc/>
|
||||
public event EventHandler<GenericEventArgs<ActivityLogEntry>>? EntryCreated;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public async Task CreateAsync(ActivityLog entry)
|
||||
{
|
||||
var dbContext = await _provider.CreateDbContextAsync().ConfigureAwait(false);
|
||||
await using (dbContext.ConfigureAwait(false))
|
||||
{
|
||||
_provider = provider;
|
||||
dbContext.ActivityLogs.Add(entry);
|
||||
await dbContext.SaveChangesAsync().ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public event EventHandler<GenericEventArgs<ActivityLogEntry>>? EntryCreated;
|
||||
EntryCreated?.Invoke(this, new GenericEventArgs<ActivityLogEntry>(ConvertToOldModel(entry)));
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public async Task CreateAsync(ActivityLog entry)
|
||||
/// <inheritdoc/>
|
||||
public async Task<QueryResult<ActivityLogEntry>> GetPagedResultAsync(ActivityLogQuery query)
|
||||
{
|
||||
// TODO allow sorting and filtering by item id. Currently not possible because ActivityLog stores the item id as a string.
|
||||
|
||||
var dbContext = await _provider.CreateDbContextAsync().ConfigureAwait(false);
|
||||
await using (dbContext.ConfigureAwait(false))
|
||||
{
|
||||
var dbContext = await _provider.CreateDbContextAsync().ConfigureAwait(false);
|
||||
await using (dbContext.ConfigureAwait(false))
|
||||
// TODO switch to LeftJoin in .NET 10.
|
||||
var entries = from a in dbContext.ActivityLogs
|
||||
join u in dbContext.Users on a.UserId equals u.Id into ugj
|
||||
from u in ugj.DefaultIfEmpty()
|
||||
select new ExpandedActivityLog { ActivityLog = a, Username = u.Username };
|
||||
|
||||
if (query.HasUserId is not null)
|
||||
{
|
||||
dbContext.ActivityLogs.Add(entry);
|
||||
await dbContext.SaveChangesAsync().ConfigureAwait(false);
|
||||
entries = entries.Where(e => e.ActivityLog.UserId.Equals(default) != query.HasUserId.Value);
|
||||
}
|
||||
|
||||
EntryCreated?.Invoke(this, new GenericEventArgs<ActivityLogEntry>(ConvertToOldModel(entry)));
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public async Task<QueryResult<ActivityLogEntry>> GetPagedResultAsync(ActivityLogQuery query)
|
||||
{
|
||||
var dbContext = await _provider.CreateDbContextAsync().ConfigureAwait(false);
|
||||
await using (dbContext.ConfigureAwait(false))
|
||||
if (query.MinDate is not null)
|
||||
{
|
||||
var entries = dbContext.ActivityLogs
|
||||
.OrderByDescending(entry => entry.DateCreated)
|
||||
.Where(entry => query.MinDate == null || entry.DateCreated >= query.MinDate)
|
||||
.Where(entry => !query.HasUserId.HasValue || entry.UserId.Equals(default) != query.HasUserId.Value);
|
||||
|
||||
return new QueryResult<ActivityLogEntry>(
|
||||
query.Skip,
|
||||
await entries.CountAsync().ConfigureAwait(false),
|
||||
await entries
|
||||
.Skip(query.Skip ?? 0)
|
||||
.Take(query.Limit ?? 100)
|
||||
.Select(entity => new ActivityLogEntry(entity.Name, entity.Type, entity.UserId)
|
||||
{
|
||||
Id = entity.Id,
|
||||
Overview = entity.Overview,
|
||||
ShortOverview = entity.ShortOverview,
|
||||
ItemId = entity.ItemId,
|
||||
Date = entity.DateCreated,
|
||||
Severity = entity.LogSeverity
|
||||
})
|
||||
.ToListAsync()
|
||||
.ConfigureAwait(false));
|
||||
entries = entries.Where(e => e.ActivityLog.DateCreated >= query.MinDate.Value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task CleanAsync(DateTime startDate)
|
||||
{
|
||||
var dbContext = await _provider.CreateDbContextAsync().ConfigureAwait(false);
|
||||
await using (dbContext.ConfigureAwait(false))
|
||||
if (!string.IsNullOrEmpty(query.Name))
|
||||
{
|
||||
await dbContext.ActivityLogs
|
||||
.Where(entry => entry.DateCreated <= startDate)
|
||||
.ExecuteDeleteAsync()
|
||||
.ConfigureAwait(false);
|
||||
entries = entries.Where(e => EF.Functions.Like(e.ActivityLog.Name, $"%{query.Name}%"));
|
||||
}
|
||||
}
|
||||
|
||||
private static ActivityLogEntry ConvertToOldModel(ActivityLog entry)
|
||||
{
|
||||
return new ActivityLogEntry(entry.Name, entry.Type, entry.UserId)
|
||||
if (!string.IsNullOrEmpty(query.Overview))
|
||||
{
|
||||
Id = entry.Id,
|
||||
Overview = entry.Overview,
|
||||
ShortOverview = entry.ShortOverview,
|
||||
ItemId = entry.ItemId,
|
||||
Date = entry.DateCreated,
|
||||
Severity = entry.LogSeverity
|
||||
};
|
||||
entries = entries.Where(e => EF.Functions.Like(e.ActivityLog.Overview, $"%{query.Overview}%"));
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(query.ShortOverview))
|
||||
{
|
||||
entries = entries.Where(e => EF.Functions.Like(e.ActivityLog.ShortOverview, $"%{query.ShortOverview}%"));
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(query.Type))
|
||||
{
|
||||
entries = entries.Where(e => EF.Functions.Like(e.ActivityLog.Type, $"%{query.Type}%"));
|
||||
}
|
||||
|
||||
if (!query.ItemId.IsNullOrEmpty())
|
||||
{
|
||||
var itemId = query.ItemId.Value.ToString("N");
|
||||
entries = entries.Where(e => e.ActivityLog.ItemId == itemId);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(query.Username))
|
||||
{
|
||||
entries = entries.Where(e => EF.Functions.Like(e.Username, $"%{query.Username}%"));
|
||||
}
|
||||
|
||||
if (query.Severity is not null)
|
||||
{
|
||||
entries = entries.Where(e => e.ActivityLog.LogSeverity == query.Severity);
|
||||
}
|
||||
|
||||
return new QueryResult<ActivityLogEntry>(
|
||||
query.Skip,
|
||||
await entries.CountAsync().ConfigureAwait(false),
|
||||
await ApplyOrdering(entries, query.OrderBy)
|
||||
.Skip(query.Skip ?? 0)
|
||||
.Take(query.Limit ?? 100)
|
||||
.Select(entity => new ActivityLogEntry(entity.ActivityLog.Name, entity.ActivityLog.Type, entity.ActivityLog.UserId)
|
||||
{
|
||||
Id = entity.ActivityLog.Id,
|
||||
Overview = entity.ActivityLog.Overview,
|
||||
ShortOverview = entity.ActivityLog.ShortOverview,
|
||||
ItemId = entity.ActivityLog.ItemId,
|
||||
Date = entity.ActivityLog.DateCreated,
|
||||
Severity = entity.ActivityLog.LogSeverity
|
||||
})
|
||||
.ToListAsync()
|
||||
.ConfigureAwait(false));
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task CleanAsync(DateTime startDate)
|
||||
{
|
||||
var dbContext = await _provider.CreateDbContextAsync().ConfigureAwait(false);
|
||||
await using (dbContext.ConfigureAwait(false))
|
||||
{
|
||||
await dbContext.ActivityLogs
|
||||
.Where(entry => entry.DateCreated <= startDate)
|
||||
.ExecuteDeleteAsync()
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
private static ActivityLogEntry ConvertToOldModel(ActivityLog entry)
|
||||
{
|
||||
return new ActivityLogEntry(entry.Name, entry.Type, entry.UserId)
|
||||
{
|
||||
Id = entry.Id,
|
||||
Overview = entry.Overview,
|
||||
ShortOverview = entry.ShortOverview,
|
||||
ItemId = entry.ItemId,
|
||||
Date = entry.DateCreated,
|
||||
Severity = entry.LogSeverity
|
||||
};
|
||||
}
|
||||
|
||||
private IOrderedQueryable<ExpandedActivityLog> ApplyOrdering(IQueryable<ExpandedActivityLog> query, IReadOnlyCollection<(ActivityLogSortBy, SortOrder)>? sorting)
|
||||
{
|
||||
if (sorting is null || sorting.Count == 0)
|
||||
{
|
||||
return query.OrderByDescending(e => e.ActivityLog.DateCreated);
|
||||
}
|
||||
|
||||
IOrderedQueryable<ExpandedActivityLog> ordered = null!;
|
||||
|
||||
foreach (var (sortBy, sortOrder) in sorting)
|
||||
{
|
||||
var orderBy = MapOrderBy(sortBy);
|
||||
ordered = sortOrder == SortOrder.Ascending
|
||||
? (ordered ?? query).OrderBy(orderBy)
|
||||
: (ordered ?? query).OrderByDescending(orderBy);
|
||||
}
|
||||
|
||||
return ordered;
|
||||
}
|
||||
|
||||
private Expression<Func<ExpandedActivityLog, object?>> MapOrderBy(ActivityLogSortBy sortBy)
|
||||
{
|
||||
return sortBy switch
|
||||
{
|
||||
ActivityLogSortBy.Name => e => e.ActivityLog.Name,
|
||||
ActivityLogSortBy.Overiew => e => e.ActivityLog.Overview,
|
||||
ActivityLogSortBy.ShortOverview => e => e.ActivityLog.ShortOverview,
|
||||
ActivityLogSortBy.Type => e => e.ActivityLog.Type,
|
||||
ActivityLogSortBy.DateCreated => e => e.ActivityLog.DateCreated,
|
||||
ActivityLogSortBy.Username => e => e.Username,
|
||||
ActivityLogSortBy.LogSeverity => e => e.ActivityLog.LogSeverity,
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(sortBy), sortBy, "Unhandled ActivityLogSortBy")
|
||||
};
|
||||
}
|
||||
|
||||
private class ExpandedActivityLog
|
||||
{
|
||||
public ActivityLog ActivityLog { get; set; } = null!;
|
||||
|
||||
public string? Username { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -158,7 +158,7 @@ namespace Jellyfin.Server.Implementations.Devices
|
||||
devices = devices.Skip(query.Skip.Value);
|
||||
}
|
||||
|
||||
if (query.Limit.HasValue)
|
||||
if (query.Limit.HasValue && query.Limit.Value > 0)
|
||||
{
|
||||
devices = devices.Take(query.Limit.Value);
|
||||
}
|
||||
|
||||
@@ -250,7 +250,7 @@ public sealed class BaseItemRepository
|
||||
public QueryResult<BaseItemDto> GetItems(InternalItemsQuery filter)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(filter);
|
||||
if (!filter.EnableTotalRecordCount || (!filter.Limit.HasValue && (filter.StartIndex ?? 0) == 0))
|
||||
if (!filter.EnableTotalRecordCount || ((filter.Limit ?? 0) == 0 && (filter.StartIndex ?? 0) == 0))
|
||||
{
|
||||
var returnList = GetItemList(filter);
|
||||
return new QueryResult<BaseItemDto>(
|
||||
@@ -326,7 +326,7 @@ public sealed class BaseItemRepository
|
||||
.OrderByDescending(g => g.MaxDateCreated)
|
||||
.Select(g => g);
|
||||
|
||||
if (filter.Limit.HasValue)
|
||||
if (filter.Limit.HasValue && filter.Limit.Value > 0)
|
||||
{
|
||||
subqueryGrouped = subqueryGrouped.Take(filter.Limit.Value);
|
||||
}
|
||||
@@ -367,7 +367,7 @@ public sealed class BaseItemRepository
|
||||
.OrderByDescending(g => g.LastPlayedDate)
|
||||
.Select(g => g.Key!);
|
||||
|
||||
if (filter.Limit.HasValue)
|
||||
if (filter.Limit.HasValue && filter.Limit.Value > 0)
|
||||
{
|
||||
query = query.Take(filter.Limit.Value);
|
||||
}
|
||||
@@ -425,19 +425,14 @@ public sealed class BaseItemRepository
|
||||
|
||||
private IQueryable<BaseItemEntity> ApplyQueryPaging(IQueryable<BaseItemEntity> dbQuery, InternalItemsQuery filter)
|
||||
{
|
||||
if (filter.Limit.HasValue || filter.StartIndex.HasValue)
|
||||
if (filter.StartIndex.HasValue && filter.StartIndex.Value > 0)
|
||||
{
|
||||
var offset = filter.StartIndex ?? 0;
|
||||
dbQuery = dbQuery.Skip(filter.StartIndex.Value);
|
||||
}
|
||||
|
||||
if (offset > 0)
|
||||
{
|
||||
dbQuery = dbQuery.Skip(offset);
|
||||
}
|
||||
|
||||
if (filter.Limit.HasValue)
|
||||
{
|
||||
dbQuery = dbQuery.Take(filter.Limit.Value);
|
||||
}
|
||||
if (filter.Limit.HasValue && filter.Limit.Value > 0)
|
||||
{
|
||||
dbQuery = dbQuery.Take(filter.Limit.Value);
|
||||
}
|
||||
|
||||
return dbQuery;
|
||||
@@ -618,12 +613,18 @@ public sealed class BaseItemRepository
|
||||
{
|
||||
context.BaseItemProviders.Where(e => e.ItemId == entity.Id).ExecuteDelete();
|
||||
context.BaseItemImageInfos.Where(e => e.ItemId == entity.Id).ExecuteDelete();
|
||||
context.BaseItemMetadataFields.Where(e => e.ItemId == entity.Id).ExecuteDelete();
|
||||
|
||||
if (entity.Images is { Count: > 0 })
|
||||
{
|
||||
context.BaseItemImageInfos.AddRange(entity.Images);
|
||||
}
|
||||
|
||||
if (entity.LockedFields is { Count: > 0 })
|
||||
{
|
||||
context.BaseItemMetadataFields.AddRange(entity.LockedFields);
|
||||
}
|
||||
|
||||
context.BaseItems.Attach(entity).State = EntityState.Modified;
|
||||
}
|
||||
}
|
||||
@@ -1184,7 +1185,7 @@ public sealed class BaseItemRepository
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(filter);
|
||||
|
||||
if (!filter.Limit.HasValue)
|
||||
if (!(filter.Limit.HasValue && filter.Limit.Value > 0))
|
||||
{
|
||||
filter.EnableTotalRecordCount = false;
|
||||
}
|
||||
@@ -1263,19 +1264,14 @@ public sealed class BaseItemRepository
|
||||
result.TotalRecordCount = query.Count();
|
||||
}
|
||||
|
||||
if (filter.Limit.HasValue || filter.StartIndex.HasValue)
|
||||
if (filter.StartIndex.HasValue && filter.StartIndex.Value > 0)
|
||||
{
|
||||
var offset = filter.StartIndex ?? 0;
|
||||
query = query.Skip(filter.StartIndex.Value);
|
||||
}
|
||||
|
||||
if (offset > 0)
|
||||
{
|
||||
query = query.Skip(offset);
|
||||
}
|
||||
|
||||
if (filter.Limit.HasValue)
|
||||
{
|
||||
query = query.Take(filter.Limit.Value);
|
||||
}
|
||||
if (filter.Limit.HasValue && filter.Limit.Value > 0)
|
||||
{
|
||||
query = query.Take(filter.Limit.Value);
|
||||
}
|
||||
|
||||
IQueryable<BaseItemEntity>? itemCountQuery = null;
|
||||
@@ -1356,7 +1352,7 @@ public sealed class BaseItemRepository
|
||||
|
||||
private static void PrepareFilterQuery(InternalItemsQuery query)
|
||||
{
|
||||
if (query.Limit.HasValue && query.EnableGroupByMetadataKey)
|
||||
if (query.Limit.HasValue && query.Limit.Value > 0 && query.EnableGroupByMetadataKey)
|
||||
{
|
||||
query.Limit = query.Limit.Value + 4;
|
||||
}
|
||||
@@ -1367,14 +1363,54 @@ public sealed class BaseItemRepository
|
||||
}
|
||||
}
|
||||
|
||||
private string GetCleanValue(string value)
|
||||
/// <summary>
|
||||
/// Gets the clean value for search and sorting purposes.
|
||||
/// </summary>
|
||||
/// <param name="value">The value to clean.</param>
|
||||
/// <returns>The cleaned value.</returns>
|
||||
public static string GetCleanValue(string value)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(value))
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
return value.RemoveDiacritics().ToLowerInvariant();
|
||||
var noDiacritics = value.RemoveDiacritics();
|
||||
|
||||
// Build a string where any punctuation or symbol is treated as a separator (space).
|
||||
var sb = new StringBuilder(noDiacritics.Length);
|
||||
var previousWasSpace = false;
|
||||
foreach (var ch in noDiacritics)
|
||||
{
|
||||
char outCh;
|
||||
if (char.IsLetterOrDigit(ch) || char.IsWhiteSpace(ch))
|
||||
{
|
||||
outCh = ch;
|
||||
}
|
||||
else
|
||||
{
|
||||
outCh = ' ';
|
||||
}
|
||||
|
||||
// normalize any whitespace character to a single ASCII space.
|
||||
if (char.IsWhiteSpace(outCh))
|
||||
{
|
||||
if (!previousWasSpace)
|
||||
{
|
||||
sb.Append(' ');
|
||||
previousWasSpace = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.Append(outCh);
|
||||
previousWasSpace = false;
|
||||
}
|
||||
}
|
||||
|
||||
// trim leading/trailing spaces that may have been added.
|
||||
var collapsed = sb.ToString().Trim();
|
||||
return collapsed.ToLowerInvariant();
|
||||
}
|
||||
|
||||
private List<(ItemValueType MagicNumber, string Value)> GetItemValuesToSave(BaseItemDto item, List<string> inheritedTags)
|
||||
@@ -1647,19 +1683,18 @@ public sealed class BaseItemRepository
|
||||
var tags = filter.Tags.ToList();
|
||||
var excludeTags = filter.ExcludeTags.ToList();
|
||||
|
||||
if (filter.IsMovie == true)
|
||||
if (filter.IsMovie.HasValue)
|
||||
{
|
||||
if (filter.IncludeItemTypes.Length == 0
|
||||
|| filter.IncludeItemTypes.Contains(BaseItemKind.Movie)
|
||||
|| filter.IncludeItemTypes.Contains(BaseItemKind.Trailer))
|
||||
var shouldIncludeAllMovieTypes = filter.IsMovie.Value
|
||||
&& (filter.IncludeItemTypes.Length == 0
|
||||
|| filter.IncludeItemTypes.Contains(BaseItemKind.Movie)
|
||||
|| filter.IncludeItemTypes.Contains(BaseItemKind.Trailer));
|
||||
|
||||
if (!shouldIncludeAllMovieTypes)
|
||||
{
|
||||
baseQuery = baseQuery.Where(e => e.IsMovie);
|
||||
baseQuery = baseQuery.Where(e => e.IsMovie == filter.IsMovie.Value);
|
||||
}
|
||||
}
|
||||
else if (filter.IsMovie.HasValue)
|
||||
{
|
||||
baseQuery = baseQuery.Where(e => e.IsMovie == filter.IsMovie);
|
||||
}
|
||||
|
||||
if (filter.IsSeries.HasValue)
|
||||
{
|
||||
|
||||
@@ -33,9 +33,11 @@ using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Cors.Infrastructure;
|
||||
using Microsoft.AspNetCore.HttpOverrides;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||
using Microsoft.OpenApi.Any;
|
||||
using Microsoft.OpenApi.Interfaces;
|
||||
using Microsoft.OpenApi.Models;
|
||||
using Swashbuckle.AspNetCore.Swagger;
|
||||
using Swashbuckle.AspNetCore.SwaggerGen;
|
||||
using AuthenticationSchemes = Jellyfin.Api.Constants.AuthenticationSchemes;
|
||||
|
||||
@@ -259,7 +261,8 @@ namespace Jellyfin.Server.Extensions
|
||||
c.OperationFilter<FileRequestFilter>();
|
||||
c.OperationFilter<ParameterObsoleteFilter>();
|
||||
c.DocumentFilter<AdditionalModelFilter>();
|
||||
});
|
||||
})
|
||||
.Replace(ServiceDescriptor.Transient<ISwaggerProvider, CachingOpenApiProvider>());
|
||||
}
|
||||
|
||||
private static void AddPolicy(this AuthorizationOptions authorizationOptions, string policyName, IAuthorizationRequirement authorizationRequirement)
|
||||
|
||||
79
Jellyfin.Server/Filters/CachingOpenApiProvider.cs
Normal file
79
Jellyfin.Server/Filters/CachingOpenApiProvider.cs
Normal file
@@ -0,0 +1,79 @@
|
||||
using System;
|
||||
using AsyncKeyedLock;
|
||||
using Microsoft.AspNetCore.Mvc.ApiExplorer;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Microsoft.OpenApi.Models;
|
||||
using Swashbuckle.AspNetCore.Swagger;
|
||||
using Swashbuckle.AspNetCore.SwaggerGen;
|
||||
|
||||
namespace Jellyfin.Server.Filters;
|
||||
|
||||
/// <summary>
|
||||
/// OpenApi provider with caching.
|
||||
/// </summary>
|
||||
internal sealed class CachingOpenApiProvider : ISwaggerProvider
|
||||
{
|
||||
private const string CacheKey = "openapi.json";
|
||||
|
||||
private static readonly MemoryCacheEntryOptions _cacheOptions = new() { SlidingExpiration = TimeSpan.FromMinutes(5) };
|
||||
private static readonly AsyncNonKeyedLocker _lock = new(1);
|
||||
private static readonly TimeSpan _lockTimeout = TimeSpan.FromSeconds(1);
|
||||
|
||||
private readonly IMemoryCache _memoryCache;
|
||||
private readonly SwaggerGenerator _swaggerGenerator;
|
||||
private readonly SwaggerGeneratorOptions _swaggerGeneratorOptions;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="CachingOpenApiProvider"/> class.
|
||||
/// </summary>
|
||||
/// <param name="optionsAccessor">The options accessor.</param>
|
||||
/// <param name="apiDescriptionsProvider">The api descriptions provider.</param>
|
||||
/// <param name="schemaGenerator">The schema generator.</param>
|
||||
/// <param name="memoryCache">The memory cache.</param>
|
||||
public CachingOpenApiProvider(
|
||||
IOptions<SwaggerGeneratorOptions> optionsAccessor,
|
||||
IApiDescriptionGroupCollectionProvider apiDescriptionsProvider,
|
||||
ISchemaGenerator schemaGenerator,
|
||||
IMemoryCache memoryCache)
|
||||
{
|
||||
_swaggerGeneratorOptions = optionsAccessor.Value;
|
||||
_swaggerGenerator = new SwaggerGenerator(_swaggerGeneratorOptions, apiDescriptionsProvider, schemaGenerator);
|
||||
_memoryCache = memoryCache;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public OpenApiDocument GetSwagger(string documentName, string? host = null, string? basePath = null)
|
||||
{
|
||||
if (_memoryCache.TryGetValue(CacheKey, out OpenApiDocument? openApiDocument) && openApiDocument is not null)
|
||||
{
|
||||
return AdjustDocument(openApiDocument, host, basePath);
|
||||
}
|
||||
|
||||
using var acquired = _lock.LockOrNull(_lockTimeout);
|
||||
if (_memoryCache.TryGetValue(CacheKey, out openApiDocument) && openApiDocument is not null)
|
||||
{
|
||||
return AdjustDocument(openApiDocument, host, basePath);
|
||||
}
|
||||
|
||||
if (acquired is null)
|
||||
{
|
||||
throw new InvalidOperationException("OpenApi document is generating");
|
||||
}
|
||||
|
||||
openApiDocument = _swaggerGenerator.GetSwagger(documentName);
|
||||
_memoryCache.Set(CacheKey, openApiDocument, _cacheOptions);
|
||||
return AdjustDocument(openApiDocument, host, basePath);
|
||||
}
|
||||
|
||||
private OpenApiDocument AdjustDocument(OpenApiDocument document, string? host, string? basePath)
|
||||
{
|
||||
document.Servers = _swaggerGeneratorOptions.Servers.Count != 0
|
||||
? _swaggerGeneratorOptions.Servers
|
||||
: string.IsNullOrEmpty(host) && string.IsNullOrEmpty(basePath)
|
||||
? []
|
||||
: [new OpenApiServer { Url = $"{host}{basePath}" }];
|
||||
|
||||
return document;
|
||||
}
|
||||
}
|
||||
105
Jellyfin.Server/Migrations/Routines/RefreshCleanNames.cs
Normal file
105
Jellyfin.Server/Migrations/Routines/RefreshCleanNames.cs
Normal file
@@ -0,0 +1,105 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Jellyfin.Database.Implementations;
|
||||
using Jellyfin.Database.Implementations.Entities;
|
||||
using Jellyfin.Extensions;
|
||||
using Jellyfin.Server.Implementations.Item;
|
||||
using Jellyfin.Server.ServerSetupApp;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Jellyfin.Server.Migrations.Routines;
|
||||
|
||||
/// <summary>
|
||||
/// Migration to refresh CleanName values for all library items.
|
||||
/// </summary>
|
||||
[JellyfinMigration("2025-10-08T12:00:00", nameof(RefreshCleanNames))]
|
||||
[JellyfinMigrationBackup(JellyfinDb = true)]
|
||||
public class RefreshCleanNames : IAsyncMigrationRoutine
|
||||
{
|
||||
private readonly IStartupLogger<RefreshCleanNames> _logger;
|
||||
private readonly IDbContextFactory<JellyfinDbContext> _dbProvider;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="RefreshCleanNames"/> class.
|
||||
/// </summary>
|
||||
/// <param name="logger">The logger.</param>
|
||||
/// <param name="dbProvider">Instance of the <see cref="IDbContextFactory{JellyfinDbContext}"/> interface.</param>
|
||||
public RefreshCleanNames(
|
||||
IStartupLogger<RefreshCleanNames> logger,
|
||||
IDbContextFactory<JellyfinDbContext> dbProvider)
|
||||
{
|
||||
_logger = logger;
|
||||
_dbProvider = dbProvider;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task PerformAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
const int Limit = 1000;
|
||||
int itemCount = 0;
|
||||
|
||||
var sw = Stopwatch.StartNew();
|
||||
|
||||
using var context = _dbProvider.CreateDbContext();
|
||||
var records = context.BaseItems.Count(b => !string.IsNullOrEmpty(b.Name));
|
||||
_logger.LogInformation("Refreshing CleanName for {Count} library items", records);
|
||||
|
||||
var processedInPartition = 0;
|
||||
|
||||
await foreach (var item in context.BaseItems
|
||||
.Where(b => !string.IsNullOrEmpty(b.Name))
|
||||
.OrderBy(e => e.Id)
|
||||
.WithPartitionProgress((partition) => _logger.LogInformation("Processed: {Offset}/{Total} - Updated: {UpdatedCount} - Time: {Elapsed}", partition * Limit, records, itemCount, sw.Elapsed))
|
||||
.PartitionEagerAsync(Limit, cancellationToken)
|
||||
.WithCancellation(cancellationToken)
|
||||
.ConfigureAwait(false))
|
||||
{
|
||||
try
|
||||
{
|
||||
var newCleanName = string.IsNullOrWhiteSpace(item.Name) ? string.Empty : BaseItemRepository.GetCleanValue(item.Name);
|
||||
if (!string.Equals(newCleanName, item.CleanName, StringComparison.Ordinal))
|
||||
{
|
||||
_logger.LogDebug(
|
||||
"Updating CleanName for item {Id}: '{OldValue}' -> '{NewValue}'",
|
||||
item.Id,
|
||||
item.CleanName,
|
||||
newCleanName);
|
||||
item.CleanName = newCleanName;
|
||||
itemCount++;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogWarning(ex, "Failed to update CleanName for item {Id} ({Name})", item.Id, item.Name);
|
||||
}
|
||||
|
||||
processedInPartition++;
|
||||
|
||||
if (processedInPartition >= Limit)
|
||||
{
|
||||
await context.SaveChangesAsync(cancellationToken).ConfigureAwait(false);
|
||||
// Clear tracked entities to avoid memory growth across partitions
|
||||
context.ChangeTracker.Clear();
|
||||
processedInPartition = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Save any remaining changes after the loop
|
||||
if (processedInPartition > 0)
|
||||
{
|
||||
await context.SaveChangesAsync(cancellationToken).ConfigureAwait(false);
|
||||
context.ChangeTracker.Clear();
|
||||
}
|
||||
|
||||
_logger.LogInformation(
|
||||
"Refreshed CleanName for {UpdatedCount} out of {TotalCount} items in {Time}",
|
||||
itemCount,
|
||||
records,
|
||||
sw.Elapsed);
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.30503.244
|
||||
# Visual Studio Version 18
|
||||
VisualStudioVersion = 18.0.11222.15 d18.0
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Jellyfin.Server", "Jellyfin.Server\Jellyfin.Server.csproj", "{07E39F42-A2C6-4B32-AF8C-725F957A73FF}"
|
||||
EndProject
|
||||
@@ -30,6 +30,7 @@ EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{41093F42-C7CC-4D07-956B-6182CBEDE2EC}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
.editorconfig = .editorconfig
|
||||
Directory.Packages.props = Directory.Packages.props
|
||||
SharedVersion.cs = SharedVersion.cs
|
||||
EndProjectSection
|
||||
EndProject
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<!-- ProjectGuid is only included as a requirement for SonarQube analysis -->
|
||||
<PropertyGroup>
|
||||
|
||||
@@ -1409,7 +1409,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
if (this is BoxSet && (query.OrderBy is null || query.OrderBy.Count == 0))
|
||||
{
|
||||
realChildren = realChildren
|
||||
.OrderBy(e => e.ProductionYear ?? int.MaxValue)
|
||||
.OrderBy(e => e.PremiereDate ?? DateTime.MaxValue)
|
||||
.ToArray();
|
||||
}
|
||||
|
||||
|
||||
@@ -455,7 +455,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
var itemsArray = totalRecordLimit.HasValue ? items.Take(totalRecordLimit.Value).ToArray() : items.ToArray();
|
||||
var totalCount = itemsArray.Length;
|
||||
|
||||
if (query.Limit.HasValue)
|
||||
if (query.Limit.HasValue && query.Limit.Value > 0)
|
||||
{
|
||||
itemsArray = itemsArray.Skip(query.StartIndex ?? 0).Take(query.Limit.Value).ToArray();
|
||||
}
|
||||
|
||||
@@ -63,6 +63,29 @@ public static class FileSystemHelper
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resolves a single link hop for the specified path.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Returns <c>null</c> if the path is not a symbolic link or the filesystem does not support link resolution (e.g., exFAT).
|
||||
/// </remarks>
|
||||
/// <param name="path">The file path to resolve.</param>
|
||||
/// <returns>
|
||||
/// A <see cref="FileInfo"/> representing the next link target if the path is a link; otherwise, <c>null</c>.
|
||||
/// </returns>
|
||||
private static FileInfo? Resolve(string path)
|
||||
{
|
||||
try
|
||||
{
|
||||
return File.ResolveLinkTarget(path, returnFinalTarget: false) as FileInfo;
|
||||
}
|
||||
catch (IOException)
|
||||
{
|
||||
// Filesystem doesn't support links (e.g., exFAT).
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the target of the specified file link.
|
||||
/// </summary>
|
||||
@@ -84,23 +107,26 @@ public static class FileSystemHelper
|
||||
|
||||
if (!returnFinalTarget)
|
||||
{
|
||||
return File.ResolveLinkTarget(linkPath, returnFinalTarget: false) as FileInfo;
|
||||
return Resolve(linkPath);
|
||||
}
|
||||
|
||||
if (File.ResolveLinkTarget(linkPath, returnFinalTarget: false) is not FileInfo targetInfo)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!targetInfo.Exists)
|
||||
var targetInfo = Resolve(linkPath);
|
||||
if (targetInfo is null || !targetInfo.Exists)
|
||||
{
|
||||
return targetInfo;
|
||||
}
|
||||
|
||||
var currentPath = targetInfo.FullName;
|
||||
var visited = new HashSet<string>(StringComparer.Ordinal) { linkPath, currentPath };
|
||||
while (File.ResolveLinkTarget(currentPath, returnFinalTarget: false) is FileInfo linkInfo)
|
||||
|
||||
while (true)
|
||||
{
|
||||
var linkInfo = Resolve(currentPath);
|
||||
if (linkInfo is null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
var targetPath = linkInfo.FullName;
|
||||
|
||||
// If an infinite loop is detected, return the file info for the
|
||||
|
||||
@@ -2378,6 +2378,13 @@ namespace MediaBrowser.Controller.MediaEncoding
|
||||
var requestHasSDR = requestedRangeTypes.Contains(VideoRangeType.SDR.ToString(), StringComparison.OrdinalIgnoreCase);
|
||||
var requestHasDOVI = requestedRangeTypes.Contains(VideoRangeType.DOVI.ToString(), StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
// If SDR is the only supported range, we should not copy any of the HDR streams.
|
||||
// All the following copy check assumes at least one HDR format is supported.
|
||||
if (requestedRangeTypes.Length == 1 && requestHasSDR && videoStream.VideoRangeType != VideoRangeType.SDR)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// If the client does not support DOVI and the video stream is DOVI without fallback, we should not copy it.
|
||||
if (!requestHasDOVI && videoStream.VideoRangeType == VideoRangeType.DOVI)
|
||||
{
|
||||
@@ -5942,28 +5949,37 @@ namespace MediaBrowser.Controller.MediaEncoding
|
||||
|
||||
var isFullAfbcPipeline = isEncoderSupportAfbc && isDrmInDrmOut && !doOclTonemap;
|
||||
var swapOutputWandH = doRkVppTranspose && swapWAndH;
|
||||
var outFormat = doOclTonemap ? "p010" : (isMjpegEncoder ? "bgra" : "nv12"); // RGA only support full range in rgb fmts
|
||||
var outFormat = doOclTonemap ? "p010" : "nv12";
|
||||
var hwScaleFilter = GetHwScaleFilter("vpp", "rkrga", outFormat, swapOutputWandH, swpInW, swpInH, reqW, reqH, reqMaxW, reqMaxH);
|
||||
var doScaling = GetHwScaleFilter("vpp", "rkrga", string.Empty, swapOutputWandH, swpInW, swpInH, reqW, reqH, reqMaxW, reqMaxH);
|
||||
var doScaling = !string.IsNullOrEmpty(GetHwScaleFilter("vpp", "rkrga", string.Empty, swapOutputWandH, swpInW, swpInH, reqW, reqH, reqMaxW, reqMaxH));
|
||||
|
||||
if (!hasSubs
|
||||
|| doRkVppTranspose
|
||||
|| !isFullAfbcPipeline
|
||||
|| !string.IsNullOrEmpty(doScaling))
|
||||
|| doScaling)
|
||||
{
|
||||
var isScaleRatioSupported = IsScaleRatioSupported(inW, inH, reqW, reqH, reqMaxW, reqMaxH, 8.0f);
|
||||
|
||||
// RGA3 hardware only support (1/8 ~ 8) scaling in each blit operation,
|
||||
// but in Trickplay there's a case: (3840/320 == 12), enable 2pass for it
|
||||
if (!string.IsNullOrEmpty(doScaling)
|
||||
&& !IsScaleRatioSupported(inW, inH, reqW, reqH, reqMaxW, reqMaxH, 8.0f))
|
||||
if (doScaling && !isScaleRatioSupported)
|
||||
{
|
||||
// Vendor provided BSP kernel has an RGA driver bug that causes the output to be corrupted for P010 format.
|
||||
// Use NV15 instead of P010 to avoid the issue.
|
||||
// SDR inputs are using BGRA formats already which is not affected.
|
||||
var intermediateFormat = string.Equals(outFormat, "p010", StringComparison.OrdinalIgnoreCase) ? "nv15" : outFormat;
|
||||
var intermediateFormat = doOclTonemap ? "nv15" : (isMjpegEncoder ? "bgra" : outFormat);
|
||||
var hwScaleFilterFirstPass = $"scale_rkrga=w=iw/7.9:h=ih/7.9:format={intermediateFormat}:force_original_aspect_ratio=increase:force_divisible_by=4:afbc=1";
|
||||
mainFilters.Add(hwScaleFilterFirstPass);
|
||||
}
|
||||
|
||||
// The RKMPP MJPEG encoder on some newer chip models no longer supports RGB input.
|
||||
// Use 2pass here to enable RGA output of full-range YUV in the 2nd pass.
|
||||
if (isMjpegEncoder && !doOclTonemap && ((doScaling && isScaleRatioSupported) || !doScaling))
|
||||
{
|
||||
var hwScaleFilterFirstPass = "vpp_rkrga=format=bgra:afbc=1";
|
||||
mainFilters.Add(hwScaleFilterFirstPass);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(hwScaleFilter) && doRkVppTranspose)
|
||||
{
|
||||
hwScaleFilter += $":transpose={transposeDir}";
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using BDInfo.IO;
|
||||
@@ -58,6 +59,8 @@ public class BdInfoDirectoryInfo : IDirectoryInfo
|
||||
}
|
||||
}
|
||||
|
||||
private static bool IsHidden(ReadOnlySpan<char> name) => name.StartsWith('.');
|
||||
|
||||
/// <summary>
|
||||
/// Gets the directories.
|
||||
/// </summary>
|
||||
@@ -65,6 +68,7 @@ public class BdInfoDirectoryInfo : IDirectoryInfo
|
||||
public IDirectoryInfo[] GetDirectories()
|
||||
{
|
||||
return _fileSystem.GetDirectories(_impl.FullName)
|
||||
.Where(d => !IsHidden(d.Name))
|
||||
.Select(x => new BdInfoDirectoryInfo(_fileSystem, x))
|
||||
.ToArray();
|
||||
}
|
||||
@@ -76,6 +80,7 @@ public class BdInfoDirectoryInfo : IDirectoryInfo
|
||||
public IFileInfo[] GetFiles()
|
||||
{
|
||||
return _fileSystem.GetFiles(_impl.FullName)
|
||||
.Where(d => !IsHidden(d.Name))
|
||||
.Select(x => new BdInfoFileInfo(x))
|
||||
.ToArray();
|
||||
}
|
||||
@@ -88,6 +93,7 @@ public class BdInfoDirectoryInfo : IDirectoryInfo
|
||||
public IFileInfo[] GetFiles(string searchPattern)
|
||||
{
|
||||
return _fileSystem.GetFiles(_impl.FullName, new[] { searchPattern }, false, false)
|
||||
.Where(d => !IsHidden(d.Name))
|
||||
.Select(x => new BdInfoFileInfo(x))
|
||||
.ToArray();
|
||||
}
|
||||
@@ -105,6 +111,7 @@ public class BdInfoDirectoryInfo : IDirectoryInfo
|
||||
new[] { searchPattern },
|
||||
false,
|
||||
searchOption == SearchOption.AllDirectories)
|
||||
.Where(d => !IsHidden(d.Name))
|
||||
.Select(x => new BdInfoFileInfo(x))
|
||||
.ToArray();
|
||||
}
|
||||
|
||||
@@ -511,7 +511,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
||||
? "{0} -i {1} -threads {2} -v warning -print_format json -show_streams -show_chapters -show_format"
|
||||
: "{0} -i {1} -threads {2} -v warning -print_format json -show_streams -show_format";
|
||||
|
||||
if (!isAudio && _proberSupportsFirstVideoFrame)
|
||||
if (protocol == MediaProtocol.File && !isAudio && _proberSupportsFirstVideoFrame)
|
||||
{
|
||||
args += " -show_frames -only_first_vframe";
|
||||
}
|
||||
|
||||
@@ -13,8 +13,10 @@ using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using AsyncKeyedLock;
|
||||
using MediaBrowser.Common;
|
||||
using MediaBrowser.Common.Configuration;
|
||||
using MediaBrowser.Common.Extensions;
|
||||
using MediaBrowser.Common.Net;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.IO;
|
||||
using MediaBrowser.Controller.Library;
|
||||
@@ -37,6 +39,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles
|
||||
private readonly IMediaSourceManager _mediaSourceManager;
|
||||
private readonly ISubtitleParser _subtitleParser;
|
||||
private readonly IPathManager _pathManager;
|
||||
private readonly IServerConfigurationManager _serverConfigurationManager;
|
||||
|
||||
/// <summary>
|
||||
/// The _semaphoreLocks.
|
||||
@@ -54,7 +57,8 @@ namespace MediaBrowser.MediaEncoding.Subtitles
|
||||
IHttpClientFactory httpClientFactory,
|
||||
IMediaSourceManager mediaSourceManager,
|
||||
ISubtitleParser subtitleParser,
|
||||
IPathManager pathManager)
|
||||
IPathManager pathManager,
|
||||
IServerConfigurationManager serverConfigurationManager)
|
||||
{
|
||||
_logger = logger;
|
||||
_fileSystem = fileSystem;
|
||||
@@ -63,6 +67,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles
|
||||
_mediaSourceManager = mediaSourceManager;
|
||||
_subtitleParser = subtitleParser;
|
||||
_pathManager = pathManager;
|
||||
_serverConfigurationManager = serverConfigurationManager;
|
||||
}
|
||||
|
||||
private MemoryStream ConvertSubtitles(
|
||||
@@ -394,7 +399,8 @@ namespace MediaBrowser.MediaEncoding.Subtitles
|
||||
|
||||
try
|
||||
{
|
||||
await process.WaitForExitAsync(TimeSpan.FromMinutes(30)).ConfigureAwait(false);
|
||||
var timeoutMinutes = _serverConfigurationManager.GetEncodingOptions().SubtitleExtractionTimeoutMinutes;
|
||||
await process.WaitForExitAsync(TimeSpan.FromMinutes(timeoutMinutes)).ConfigureAwait(false);
|
||||
exitCode = process.ExitCode;
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
@@ -677,7 +683,8 @@ namespace MediaBrowser.MediaEncoding.Subtitles
|
||||
|
||||
try
|
||||
{
|
||||
await process.WaitForExitAsync(TimeSpan.FromMinutes(30)).ConfigureAwait(false);
|
||||
var timeoutMinutes = _serverConfigurationManager.GetEncodingOptions().SubtitleExtractionTimeoutMinutes;
|
||||
await process.WaitForExitAsync(TimeSpan.FromMinutes(timeoutMinutes)).ConfigureAwait(false);
|
||||
exitCode = process.ExitCode;
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
@@ -828,7 +835,8 @@ namespace MediaBrowser.MediaEncoding.Subtitles
|
||||
|
||||
try
|
||||
{
|
||||
await process.WaitForExitAsync(TimeSpan.FromMinutes(30)).ConfigureAwait(false);
|
||||
var timeoutMinutes = _serverConfigurationManager.GetEncodingOptions().SubtitleExtractionTimeoutMinutes;
|
||||
await process.WaitForExitAsync(TimeSpan.FromMinutes(timeoutMinutes)).ConfigureAwait(false);
|
||||
exitCode = process.ExitCode;
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#pragma warning disable CS1591
|
||||
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Jellyfin.Data.Events;
|
||||
@@ -7,21 +5,36 @@ using Jellyfin.Data.Queries;
|
||||
using Jellyfin.Database.Implementations.Entities;
|
||||
using MediaBrowser.Model.Querying;
|
||||
|
||||
namespace MediaBrowser.Model.Activity
|
||||
namespace MediaBrowser.Model.Activity;
|
||||
|
||||
/// <summary>
|
||||
/// Interface for the activity manager.
|
||||
/// </summary>
|
||||
public interface IActivityManager
|
||||
{
|
||||
public interface IActivityManager
|
||||
{
|
||||
event EventHandler<GenericEventArgs<ActivityLogEntry>> EntryCreated;
|
||||
/// <summary>
|
||||
/// The event that is triggered when an entity is created.
|
||||
/// </summary>
|
||||
event EventHandler<GenericEventArgs<ActivityLogEntry>> EntryCreated;
|
||||
|
||||
Task CreateAsync(ActivityLog entry);
|
||||
/// <summary>
|
||||
/// Create a new activity log entry.
|
||||
/// </summary>
|
||||
/// <param name="entry">The entry to create.</param>
|
||||
/// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
|
||||
Task CreateAsync(ActivityLog entry);
|
||||
|
||||
Task<QueryResult<ActivityLogEntry>> GetPagedResultAsync(ActivityLogQuery query);
|
||||
/// <summary>
|
||||
/// Get a paged list of activity log entries.
|
||||
/// </summary>
|
||||
/// <param name="query">The activity log query.</param>
|
||||
/// <returns>The page of entries.</returns>
|
||||
Task<QueryResult<ActivityLogEntry>> GetPagedResultAsync(ActivityLogQuery query);
|
||||
|
||||
/// <summary>
|
||||
/// Remove all activity logs before the specified date.
|
||||
/// </summary>
|
||||
/// <param name="startDate">Activity log start date.</param>
|
||||
/// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
|
||||
Task CleanAsync(DateTime startDate);
|
||||
}
|
||||
/// <summary>
|
||||
/// Remove all activity logs before the specified date.
|
||||
/// </summary>
|
||||
/// <param name="startDate">Activity log start date.</param>
|
||||
/// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
|
||||
Task CleanAsync(DateTime startDate);
|
||||
}
|
||||
|
||||
@@ -57,6 +57,7 @@ public class EncodingOptions
|
||||
AllowHevcEncoding = false;
|
||||
AllowAv1Encoding = false;
|
||||
EnableSubtitleExtraction = true;
|
||||
SubtitleExtractionTimeoutMinutes = 30;
|
||||
AllowOnDemandMetadataBasedKeyframeExtractionForExtensions = ["mkv"];
|
||||
HardwareDecodingCodecs = ["h264", "vc1"];
|
||||
}
|
||||
@@ -286,6 +287,11 @@ public class EncodingOptions
|
||||
/// </summary>
|
||||
public bool EnableSubtitleExtraction { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the timeout for subtitle extraction in minutes.
|
||||
/// </summary>
|
||||
public int SubtitleExtractionTimeoutMinutes { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the codecs hardware encoding is used for.
|
||||
/// </summary>
|
||||
|
||||
@@ -151,9 +151,9 @@ namespace MediaBrowser.Providers.Manager
|
||||
.ConfigureAwait(false);
|
||||
updateType |= beforeSaveResult;
|
||||
|
||||
if (!isFirstRefresh)
|
||||
if (isFirstRefresh)
|
||||
{
|
||||
updateType = await SaveInternal(item, refreshOptions, updateType, isFirstRefresh, requiresRefresh, metadataResult, cancellationToken).ConfigureAwait(false);
|
||||
await SaveItemAsync(metadataResult, ItemUpdateType.MetadataImport, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
// Next run metadata providers
|
||||
|
||||
@@ -240,12 +240,9 @@ namespace Jellyfin.LiveTv.Channels
|
||||
var all = channels;
|
||||
var totalCount = all.Count;
|
||||
|
||||
if (query.StartIndex.HasValue || query.Limit.HasValue)
|
||||
{
|
||||
int startIndex = query.StartIndex ?? 0;
|
||||
int count = query.Limit is null ? totalCount - startIndex : Math.Min(query.Limit.Value, totalCount - startIndex);
|
||||
all = all.GetRange(startIndex, count);
|
||||
}
|
||||
int startIndex = query.StartIndex ?? 0;
|
||||
int count = (query.Limit ?? 0) > 0 ? Math.Min(query.Limit.Value, totalCount - startIndex) : totalCount - startIndex;
|
||||
all = all.GetRange(query.StartIndex ?? 0, count);
|
||||
|
||||
if (query.RefreshLatestChannelItems)
|
||||
{
|
||||
|
||||
@@ -287,7 +287,7 @@ namespace Jellyfin.LiveTv
|
||||
GenreIds = query.GenreIds
|
||||
};
|
||||
|
||||
if (query.Limit.HasValue)
|
||||
if (query.Limit.HasValue && query.Limit.Value > 0)
|
||||
{
|
||||
internalQuery.Limit = Math.Max(query.Limit.Value * 4, 200);
|
||||
}
|
||||
@@ -305,7 +305,7 @@ namespace Jellyfin.LiveTv
|
||||
|
||||
IEnumerable<BaseItem> programs = orderedPrograms;
|
||||
|
||||
if (query.Limit.HasValue)
|
||||
if (query.Limit.HasValue && query.Limit.Value > 0)
|
||||
{
|
||||
programs = programs.Take(query.Limit.Value);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,109 @@
|
||||
using System;
|
||||
using AutoFixture;
|
||||
using AutoFixture.AutoMoq;
|
||||
using Jellyfin.Server.Implementations.Item;
|
||||
using MediaBrowser.Controller.Entities.TV;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Moq;
|
||||
using Xunit;
|
||||
|
||||
namespace Jellyfin.Server.Implementations.Tests.Data
|
||||
{
|
||||
public class SearchPunctuationTests
|
||||
{
|
||||
private readonly IFixture _fixture;
|
||||
private readonly BaseItemRepository _repo;
|
||||
|
||||
public SearchPunctuationTests()
|
||||
{
|
||||
var appHost = new Mock<MediaBrowser.Controller.IServerApplicationHost>();
|
||||
appHost.Setup(x => x.ExpandVirtualPath(It.IsAny<string>()))
|
||||
.Returns((string x) => x);
|
||||
appHost.Setup(x => x.ReverseVirtualPath(It.IsAny<string>()))
|
||||
.Returns((string x) => x);
|
||||
|
||||
var configSection = new Mock<IConfigurationSection>();
|
||||
configSection
|
||||
.SetupGet(x => x[It.Is<string>(s => s == MediaBrowser.Controller.Extensions.ConfigurationExtensions.SqliteCacheSizeKey)])
|
||||
.Returns("0");
|
||||
var config = new Mock<IConfiguration>();
|
||||
config
|
||||
.Setup(x => x.GetSection(It.Is<string>(s => s == MediaBrowser.Controller.Extensions.ConfigurationExtensions.SqliteCacheSizeKey)))
|
||||
.Returns(configSection.Object);
|
||||
|
||||
_fixture = new Fixture().Customize(new AutoMoqCustomization { ConfigureMembers = true });
|
||||
_fixture.Inject(appHost.Object);
|
||||
_fixture.Inject(config.Object);
|
||||
|
||||
_repo = _fixture.Create<BaseItemRepository>();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CleanName_keeps_punctuation_and_search_without_punctuation_passes()
|
||||
{
|
||||
var series = new Series
|
||||
{
|
||||
Id = Guid.NewGuid(),
|
||||
Name = "Mr. Robot"
|
||||
};
|
||||
|
||||
series.SortName = "Mr. Robot";
|
||||
|
||||
var entity = _repo.Map(series);
|
||||
Assert.Equal("mr robot", entity.CleanName);
|
||||
|
||||
var searchTerm = "Mr Robot".ToLowerInvariant();
|
||||
|
||||
Assert.Contains(searchTerm, entity.CleanName ?? string.Empty, StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("Spider-Man: Homecoming", "spider man homecoming")]
|
||||
[InlineData("Beyoncé — Live!", "beyonce live")]
|
||||
[InlineData("Hello, World!", "hello world")]
|
||||
[InlineData("(The) Good, the Bad & the Ugly", "the good the bad the ugly")]
|
||||
[InlineData("Wall-E", "wall e")]
|
||||
[InlineData("No. 1: The Beginning", "no 1 the beginning")]
|
||||
[InlineData("Café-au-lait", "cafe au lait")]
|
||||
public void CleanName_normalizes_various_punctuation(string title, string expectedClean)
|
||||
{
|
||||
var series = new Series
|
||||
{
|
||||
Id = Guid.NewGuid(),
|
||||
Name = title
|
||||
};
|
||||
|
||||
series.SortName = title;
|
||||
|
||||
var entity = _repo.Map(series);
|
||||
|
||||
Assert.Equal(expectedClean, entity.CleanName);
|
||||
|
||||
// Ensure a search term without punctuation would match
|
||||
var searchTerm = expectedClean;
|
||||
Assert.Contains(searchTerm, entity.CleanName ?? string.Empty, StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("Face/Off", "face off")]
|
||||
[InlineData("V/H/S", "v h s")]
|
||||
public void CleanName_normalizes_titles_withslashes(string title, string expectedClean)
|
||||
{
|
||||
var series = new Series
|
||||
{
|
||||
Id = Guid.NewGuid(),
|
||||
Name = title
|
||||
};
|
||||
|
||||
series.SortName = title;
|
||||
|
||||
var entity = _repo.Map(series);
|
||||
|
||||
Assert.Equal(expectedClean, entity.CleanName);
|
||||
|
||||
// Ensure a search term without punctuation would match
|
||||
var searchTerm = expectedClean;
|
||||
Assert.Contains(searchTerm, entity.CleanName ?? string.Empty, StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user