Merge remote-tracking branch 'upstream/master' into library_scan_speed
This commit is contained in:
commit
4a22380565
|
@ -7,7 +7,7 @@ parameters:
|
||||||
default: "ubuntu-latest"
|
default: "ubuntu-latest"
|
||||||
- name: DotNetSdkVersion
|
- name: DotNetSdkVersion
|
||||||
type: string
|
type: string
|
||||||
default: 3.1.100
|
default: 5.0.100
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
- job: CompatibilityCheck
|
- job: CompatibilityCheck
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
jobs:
|
jobs:
|
||||||
- job: GenerateApiClients
|
- job: GenerateApiClients
|
||||||
displayName: 'Generate Api Clients'
|
displayName: 'Generate Api Clients'
|
||||||
|
condition: startsWith(variables['Build.SourceBranch'], 'refs/tags/v')
|
||||||
dependsOn: Test
|
dependsOn: Test
|
||||||
|
|
||||||
pool:
|
pool:
|
||||||
|
@ -35,17 +36,8 @@ jobs:
|
||||||
customEndpoint: 'jellyfin-bot for NPM'
|
customEndpoint: 'jellyfin-bot for NPM'
|
||||||
|
|
||||||
## Generate npm api client
|
## Generate npm api client
|
||||||
# Unstable
|
|
||||||
- task: CmdLine@2
|
|
||||||
displayName: 'Build unstable typescript axios client'
|
|
||||||
condition: startsWith(variables['Build.SourceBranch'], 'refs/heads/master')
|
|
||||||
inputs:
|
|
||||||
script: "bash ./apiclient/templates/typescript/axios/generate.sh $(System.ArtifactsDirectory) $(Build.BuildNumber)"
|
|
||||||
|
|
||||||
# Stable
|
|
||||||
- task: CmdLine@2
|
- task: CmdLine@2
|
||||||
displayName: 'Build stable typescript axios client'
|
displayName: 'Build stable typescript axios client'
|
||||||
condition: startsWith(variables['Build.SourceBranch'], 'refs/tags/v')
|
|
||||||
inputs:
|
inputs:
|
||||||
script: "bash ./apiclient/templates/typescript/axios/generate.sh $(System.ArtifactsDirectory)"
|
script: "bash ./apiclient/templates/typescript/axios/generate.sh $(System.ArtifactsDirectory)"
|
||||||
|
|
||||||
|
@ -57,20 +49,8 @@ jobs:
|
||||||
workingDir: ./apiclient/generated/typescript/axios
|
workingDir: ./apiclient/generated/typescript/axios
|
||||||
|
|
||||||
## Publish npm packages
|
## Publish npm packages
|
||||||
# Unstable
|
|
||||||
- task: Npm@1
|
|
||||||
displayName: 'Publish unstable typescript axios client'
|
|
||||||
condition: startsWith(variables['Build.SourceBranch'], 'refs/heads/master')
|
|
||||||
inputs:
|
|
||||||
command: publish
|
|
||||||
publishRegistry: useFeed
|
|
||||||
publishFeed: 'jellyfin/unstable'
|
|
||||||
workingDir: ./apiclient/generated/typescript/axios
|
|
||||||
|
|
||||||
# Stable
|
|
||||||
- task: Npm@1
|
- task: Npm@1
|
||||||
displayName: 'Publish stable typescript axios client'
|
displayName: 'Publish stable typescript axios client'
|
||||||
condition: startsWith(variables['Build.SourceBranch'], 'refs/tags/v')
|
|
||||||
inputs:
|
inputs:
|
||||||
command: publish
|
command: publish
|
||||||
publishRegistry: useExternalRegistry
|
publishRegistry: useExternalRegistry
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
parameters:
|
parameters:
|
||||||
LinuxImage: 'ubuntu-latest'
|
LinuxImage: 'ubuntu-latest'
|
||||||
RestoreBuildProjects: 'Jellyfin.Server/Jellyfin.Server.csproj'
|
RestoreBuildProjects: 'Jellyfin.Server/Jellyfin.Server.csproj'
|
||||||
DotNetSdkVersion: 3.1.100
|
DotNetSdkVersion: 5.0.100
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
- job: Build
|
- job: Build
|
||||||
|
|
|
@ -188,6 +188,12 @@ jobs:
|
||||||
vmImage: 'ubuntu-latest'
|
vmImage: 'ubuntu-latest'
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
|
- task: UseDotNet@2
|
||||||
|
displayName: 'Use .NET 5.0 sdk'
|
||||||
|
inputs:
|
||||||
|
packageType: 'sdk'
|
||||||
|
version: '5.0.x'
|
||||||
|
|
||||||
- task: DotNetCoreCLI@2
|
- task: DotNetCoreCLI@2
|
||||||
displayName: 'Build Stable Nuget packages'
|
displayName: 'Build Stable Nuget packages'
|
||||||
condition: startsWith(variables['Build.SourceBranch'], 'refs/tags/v')
|
condition: startsWith(variables['Build.SourceBranch'], 'refs/tags/v')
|
||||||
|
|
|
@ -10,7 +10,7 @@ parameters:
|
||||||
default: "tests/**/*Tests.csproj"
|
default: "tests/**/*Tests.csproj"
|
||||||
- name: DotNetSdkVersion
|
- name: DotNetSdkVersion
|
||||||
type: string
|
type: string
|
||||||
default: 3.1.100
|
default: 5.0.100
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
- job: Test
|
- job: Test
|
||||||
|
@ -94,5 +94,5 @@ jobs:
|
||||||
displayName: 'Publish OpenAPI Artifact'
|
displayName: 'Publish OpenAPI Artifact'
|
||||||
condition: and(succeeded(), eq(variables['Agent.OS'], 'Linux'))
|
condition: and(succeeded(), eq(variables['Agent.OS'], 'Linux'))
|
||||||
inputs:
|
inputs:
|
||||||
targetPath: "tests/Jellyfin.Api.Tests/bin/Release/netcoreapp3.1/openapi.json"
|
targetPath: "tests/Jellyfin.Api.Tests/bin/Release/net5.0/openapi.json"
|
||||||
artifactName: 'OpenAPI Spec'
|
artifactName: 'OpenAPI Spec'
|
||||||
|
|
|
@ -6,7 +6,7 @@ variables:
|
||||||
- name: RestoreBuildProjects
|
- name: RestoreBuildProjects
|
||||||
value: 'Jellyfin.Server/Jellyfin.Server.csproj'
|
value: 'Jellyfin.Server/Jellyfin.Server.csproj'
|
||||||
- name: DotNetSdkVersion
|
- name: DotNetSdkVersion
|
||||||
value: 3.1.100
|
value: 5.0.100
|
||||||
|
|
||||||
pr:
|
pr:
|
||||||
autoCancel: true
|
autoCancel: true
|
||||||
|
|
4
.vscode/launch.json
vendored
4
.vscode/launch.json
vendored
|
@ -6,7 +6,7 @@
|
||||||
"type": "coreclr",
|
"type": "coreclr",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"preLaunchTask": "build",
|
"preLaunchTask": "build",
|
||||||
"program": "${workspaceFolder}/Jellyfin.Server/bin/Debug/netcoreapp3.1/jellyfin.dll",
|
"program": "${workspaceFolder}/Jellyfin.Server/bin/Debug/net5.0/jellyfin.dll",
|
||||||
"args": [],
|
"args": [],
|
||||||
"cwd": "${workspaceFolder}/Jellyfin.Server",
|
"cwd": "${workspaceFolder}/Jellyfin.Server",
|
||||||
"console": "internalConsole",
|
"console": "internalConsole",
|
||||||
|
@ -22,7 +22,7 @@
|
||||||
"type": "coreclr",
|
"type": "coreclr",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"preLaunchTask": "build",
|
"preLaunchTask": "build",
|
||||||
"program": "${workspaceFolder}/Jellyfin.Server/bin/Debug/netcoreapp3.1/jellyfin.dll",
|
"program": "${workspaceFolder}/Jellyfin.Server/bin/Debug/net5.0/jellyfin.dll",
|
||||||
"args": ["--nowebclient"],
|
"args": ["--nowebclient"],
|
||||||
"cwd": "${workspaceFolder}/Jellyfin.Server",
|
"cwd": "${workspaceFolder}/Jellyfin.Server",
|
||||||
"console": "internalConsole",
|
"console": "internalConsole",
|
||||||
|
|
|
@ -104,6 +104,7 @@
|
||||||
- [sorinyo2004](https://github.com/sorinyo2004)
|
- [sorinyo2004](https://github.com/sorinyo2004)
|
||||||
- [sparky8251](https://github.com/sparky8251)
|
- [sparky8251](https://github.com/sparky8251)
|
||||||
- [spookbits](https://github.com/spookbits)
|
- [spookbits](https://github.com/spookbits)
|
||||||
|
- [ssenart] (https://github.com/ssenart)
|
||||||
- [stanionascu](https://github.com/stanionascu)
|
- [stanionascu](https://github.com/stanionascu)
|
||||||
- [stevehayles](https://github.com/stevehayles)
|
- [stevehayles](https://github.com/stevehayles)
|
||||||
- [SuperSandro2000](https://github.com/SuperSandro2000)
|
- [SuperSandro2000](https://github.com/SuperSandro2000)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
ARG DOTNET_VERSION=3.1
|
ARG DOTNET_VERSION=5.0
|
||||||
|
|
||||||
FROM node:alpine as web-builder
|
FROM node:alpine as web-builder
|
||||||
ARG JELLYFIN_WEB_VERSION=master
|
ARG JELLYFIN_WEB_VERSION=master
|
||||||
|
@ -8,7 +8,7 @@ RUN apk add curl git zlib zlib-dev autoconf g++ make libpng-dev gifsicle alpine-
|
||||||
&& yarn install \
|
&& yarn install \
|
||||||
&& mv dist /dist
|
&& mv dist /dist
|
||||||
|
|
||||||
FROM mcr.microsoft.com/dotnet/core/sdk:${DOTNET_VERSION}-buster as builder
|
FROM mcr.microsoft.com/dotnet/sdk:${DOTNET_VERSION}-buster-slim as builder
|
||||||
WORKDIR /repo
|
WORKDIR /repo
|
||||||
COPY . .
|
COPY . .
|
||||||
ENV DOTNET_CLI_TELEMETRY_OPTOUT=1
|
ENV DOTNET_CLI_TELEMETRY_OPTOUT=1
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#####################################
|
#####################################
|
||||||
# Requires binfm_misc registration
|
# Requires binfm_misc registration
|
||||||
# https://github.com/multiarch/qemu-user-static#binfmt_misc-register
|
# https://github.com/multiarch/qemu-user-static#binfmt_misc-register
|
||||||
ARG DOTNET_VERSION=3.1
|
ARG DOTNET_VERSION=5.0
|
||||||
|
|
||||||
|
|
||||||
FROM node:alpine as web-builder
|
FROM node:alpine as web-builder
|
||||||
|
@ -14,7 +14,7 @@ RUN apk add curl git zlib zlib-dev autoconf g++ make libpng-dev gifsicle alpine-
|
||||||
&& mv dist /dist
|
&& mv dist /dist
|
||||||
|
|
||||||
|
|
||||||
FROM mcr.microsoft.com/dotnet/core/sdk:${DOTNET_VERSION} as builder
|
FROM mcr.microsoft.com/dotnet/sdk:${DOTNET_VERSION} as builder
|
||||||
WORKDIR /repo
|
WORKDIR /repo
|
||||||
COPY . .
|
COPY . .
|
||||||
ENV DOTNET_CLI_TELEMETRY_OPTOUT=1
|
ENV DOTNET_CLI_TELEMETRY_OPTOUT=1
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#####################################
|
#####################################
|
||||||
# Requires binfm_misc registration
|
# Requires binfm_misc registration
|
||||||
# https://github.com/multiarch/qemu-user-static#binfmt_misc-register
|
# https://github.com/multiarch/qemu-user-static#binfmt_misc-register
|
||||||
ARG DOTNET_VERSION=3.1
|
ARG DOTNET_VERSION=5.0
|
||||||
|
|
||||||
|
|
||||||
FROM node:alpine as web-builder
|
FROM node:alpine as web-builder
|
||||||
|
@ -14,7 +14,7 @@ RUN apk add curl git zlib zlib-dev autoconf g++ make libpng-dev gifsicle alpine-
|
||||||
&& mv dist /dist
|
&& mv dist /dist
|
||||||
|
|
||||||
|
|
||||||
FROM mcr.microsoft.com/dotnet/core/sdk:${DOTNET_VERSION} as builder
|
FROM mcr.microsoft.com/dotnet/sdk:${DOTNET_VERSION} as builder
|
||||||
WORKDIR /repo
|
WORKDIR /repo
|
||||||
COPY . .
|
COPY . .
|
||||||
ENV DOTNET_CLI_TELEMETRY_OPTOUT=1
|
ENV DOTNET_CLI_TELEMETRY_OPTOUT=1
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netstandard2.1</TargetFramework>
|
<TargetFramework>net5.0</TargetFramework>
|
||||||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
||||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||||
|
|
|
@ -31,7 +31,7 @@ namespace DvdLib.Ifo
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
var nums = ifo.Name.Split(new[] { '_' }, StringSplitOptions.RemoveEmptyEntries);
|
var nums = ifo.Name.Split('_', StringSplitOptions.RemoveEmptyEntries);
|
||||||
if (nums.Length >= 2 && ushort.TryParse(nums[1], out var ifoNumber))
|
if (nums.Length >= 2 && ushort.TryParse(nums[1], out var ifoNumber))
|
||||||
{
|
{
|
||||||
ReadVTS(ifoNumber, ifo.FullName);
|
ReadVTS(ifoNumber, ifo.FullName);
|
||||||
|
|
|
@ -1,13 +1,23 @@
|
||||||
#pragma warning disable CS1591
|
|
||||||
|
|
||||||
namespace Emby.Dlna.Common
|
namespace Emby.Dlna.Common
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// DLNA Query parameter type, used when querying DLNA devices via SOAP.
|
||||||
|
/// </summary>
|
||||||
public class Argument
|
public class Argument
|
||||||
{
|
{
|
||||||
public string Name { get; set; }
|
/// <summary>
|
||||||
|
/// Gets or sets name of the DLNA argument.
|
||||||
|
/// </summary>
|
||||||
|
public string Name { get; set; } = string.Empty;
|
||||||
|
|
||||||
public string Direction { get; set; }
|
/// <summary>
|
||||||
|
/// Gets or sets the direction of the parameter.
|
||||||
|
/// </summary>
|
||||||
|
public string Direction { get; set; } = string.Empty;
|
||||||
|
|
||||||
public string RelatedStateVariable { get; set; }
|
/// <summary>
|
||||||
|
/// Gets or sets the related DLNA state variable for this argument.
|
||||||
|
/// </summary>
|
||||||
|
public string RelatedStateVariable { get; set; } = string.Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,29 +1,41 @@
|
||||||
#pragma warning disable CS1591
|
|
||||||
|
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
|
|
||||||
namespace Emby.Dlna.Common
|
namespace Emby.Dlna.Common
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Defines the <see cref="DeviceIcon" />.
|
||||||
|
/// </summary>
|
||||||
public class DeviceIcon
|
public class DeviceIcon
|
||||||
{
|
{
|
||||||
public string Url { get; set; }
|
/// <summary>
|
||||||
|
/// Gets or sets the Url.
|
||||||
|
/// </summary>
|
||||||
|
public string Url { get; set; } = string.Empty;
|
||||||
|
|
||||||
public string MimeType { get; set; }
|
/// <summary>
|
||||||
|
/// Gets or sets the MimeType.
|
||||||
|
/// </summary>
|
||||||
|
public string MimeType { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the Width.
|
||||||
|
/// </summary>
|
||||||
public int Width { get; set; }
|
public int Width { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the Height.
|
||||||
|
/// </summary>
|
||||||
public int Height { get; set; }
|
public int Height { get; set; }
|
||||||
|
|
||||||
public string Depth { get; set; }
|
/// <summary>
|
||||||
|
/// Gets or sets the Depth.
|
||||||
|
/// </summary>
|
||||||
|
public string Depth { get; set; } = string.Empty;
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
return string.Format(
|
return string.Format(CultureInfo.InvariantCulture, "{0}x{1}", Height, Width);
|
||||||
CultureInfo.InvariantCulture,
|
|
||||||
"{0}x{1}",
|
|
||||||
Height,
|
|
||||||
Width);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,21 +1,36 @@
|
||||||
#pragma warning disable CS1591
|
|
||||||
|
|
||||||
namespace Emby.Dlna.Common
|
namespace Emby.Dlna.Common
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Defines the <see cref="DeviceService" />.
|
||||||
|
/// </summary>
|
||||||
public class DeviceService
|
public class DeviceService
|
||||||
{
|
{
|
||||||
public string ServiceType { get; set; }
|
/// <summary>
|
||||||
|
/// Gets or sets the Service Type.
|
||||||
|
/// </summary>
|
||||||
|
public string ServiceType { get; set; } = string.Empty;
|
||||||
|
|
||||||
public string ServiceId { get; set; }
|
/// <summary>
|
||||||
|
/// Gets or sets the Service Id.
|
||||||
|
/// </summary>
|
||||||
|
public string ServiceId { get; set; } = string.Empty;
|
||||||
|
|
||||||
public string ScpdUrl { get; set; }
|
/// <summary>
|
||||||
|
/// Gets or sets the Scpd Url.
|
||||||
|
/// </summary>
|
||||||
|
public string ScpdUrl { get; set; } = string.Empty;
|
||||||
|
|
||||||
public string ControlUrl { get; set; }
|
/// <summary>
|
||||||
|
/// Gets or sets the Control Url.
|
||||||
|
/// </summary>
|
||||||
|
public string ControlUrl { get; set; } = string.Empty;
|
||||||
|
|
||||||
public string EventSubUrl { get; set; }
|
/// <summary>
|
||||||
|
/// Gets or sets the EventSubUrl.
|
||||||
|
/// </summary>
|
||||||
|
public string EventSubUrl { get; set; } = string.Empty;
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override string ToString()
|
public override string ToString() => ServiceId;
|
||||||
=> ServiceId;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,24 +1,31 @@
|
||||||
#pragma warning disable CS1591
|
|
||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Emby.Dlna.Common
|
namespace Emby.Dlna.Common
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Defines the <see cref="ServiceAction" />.
|
||||||
|
/// </summary>
|
||||||
public class ServiceAction
|
public class ServiceAction
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="ServiceAction"/> class.
|
||||||
|
/// </summary>
|
||||||
public ServiceAction()
|
public ServiceAction()
|
||||||
{
|
{
|
||||||
ArgumentList = new List<Argument>();
|
ArgumentList = new List<Argument>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Name { get; set; }
|
/// <summary>
|
||||||
|
/// Gets or sets the name of the action.
|
||||||
|
/// </summary>
|
||||||
|
public string Name { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the ArgumentList.
|
||||||
|
/// </summary>
|
||||||
public List<Argument> ArgumentList { get; }
|
public List<Argument> ArgumentList { get; }
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override string ToString()
|
public override string ToString() => Name;
|
||||||
{
|
|
||||||
return Name;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,27 +1,34 @@
|
||||||
#pragma warning disable CS1591
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Emby.Dlna.Common
|
namespace Emby.Dlna.Common
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Defines the <see cref="StateVariable" />.
|
||||||
|
/// </summary>
|
||||||
public class StateVariable
|
public class StateVariable
|
||||||
{
|
{
|
||||||
public StateVariable()
|
/// <summary>
|
||||||
{
|
/// Gets or sets the name of the state variable.
|
||||||
AllowedValues = Array.Empty<string>();
|
/// </summary>
|
||||||
}
|
public string Name { get; set; } = string.Empty;
|
||||||
|
|
||||||
public string Name { get; set; }
|
/// <summary>
|
||||||
|
/// Gets or sets the data type of the state variable.
|
||||||
public string DataType { get; set; }
|
/// </summary>
|
||||||
|
public string DataType { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether it sends events.
|
||||||
|
/// </summary>
|
||||||
public bool SendsEvents { get; set; }
|
public bool SendsEvents { get; set; }
|
||||||
|
|
||||||
public IReadOnlyList<string> AllowedValues { get; set; }
|
/// <summary>
|
||||||
|
/// Gets or sets the allowed values range.
|
||||||
|
/// </summary>
|
||||||
|
public IReadOnlyList<string> AllowedValues { get; set; } = Array.Empty<string>();
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override string ToString()
|
public override string ToString() => Name;
|
||||||
=> Name;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,14 @@
|
||||||
|
|
||||||
namespace Emby.Dlna.Configuration
|
namespace Emby.Dlna.Configuration
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The DlnaOptions class contains the user definable parameters for the dlna subsystems.
|
||||||
|
/// </summary>
|
||||||
public class DlnaOptions
|
public class DlnaOptions
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="DlnaOptions"/> class.
|
||||||
|
/// </summary>
|
||||||
public DlnaOptions()
|
public DlnaOptions()
|
||||||
{
|
{
|
||||||
EnablePlayTo = true;
|
EnablePlayTo = true;
|
||||||
|
@ -11,23 +17,76 @@ namespace Emby.Dlna.Configuration
|
||||||
BlastAliveMessages = true;
|
BlastAliveMessages = true;
|
||||||
SendOnlyMatchedHost = true;
|
SendOnlyMatchedHost = true;
|
||||||
ClientDiscoveryIntervalSeconds = 60;
|
ClientDiscoveryIntervalSeconds = 60;
|
||||||
BlastAliveMessageIntervalSeconds = 1800;
|
AliveMessageIntervalSeconds = 1800;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether gets or sets a value to indicate the status of the dlna playTo subsystem.
|
||||||
|
/// </summary>
|
||||||
public bool EnablePlayTo { get; set; }
|
public bool EnablePlayTo { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether gets or sets a value to indicate the status of the dlna server subsystem.
|
||||||
|
/// </summary>
|
||||||
public bool EnableServer { get; set; }
|
public bool EnableServer { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether detailed dlna server logs are sent to the console/log.
|
||||||
|
/// If the setting "Emby.Dlna": "Debug" msut be set in logging.default.json for this property to work.
|
||||||
|
/// </summary>
|
||||||
public bool EnableDebugLog { get; set; }
|
public bool EnableDebugLog { get; set; }
|
||||||
|
|
||||||
public bool BlastAliveMessages { get; set; }
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether whether detailed playTo debug logs are sent to the console/log.
|
||||||
public bool SendOnlyMatchedHost { get; set; }
|
/// If the setting "Emby.Dlna.PlayTo": "Debug" msut be set in logging.default.json for this property to work.
|
||||||
|
/// </summary>
|
||||||
|
public bool EnablePlayToTracing { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the ssdp client discovery interval time (in seconds).
|
||||||
|
/// This is the time after which the server will send a ssdp search request.
|
||||||
|
/// </summary>
|
||||||
public int ClientDiscoveryIntervalSeconds { get; set; }
|
public int ClientDiscoveryIntervalSeconds { get; set; }
|
||||||
|
|
||||||
public int BlastAliveMessageIntervalSeconds { get; set; }
|
/// <summary>
|
||||||
|
/// Gets or sets the frequency at which ssdp alive notifications are transmitted.
|
||||||
|
/// </summary>
|
||||||
|
public int AliveMessageIntervalSeconds { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the frequency at which ssdp alive notifications are transmitted. MIGRATING - TO BE REMOVED ONCE WEB HAS BEEN ALTERED.
|
||||||
|
/// </summary>
|
||||||
|
public int BlastAliveMessageIntervalSeconds
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return AliveMessageIntervalSeconds;
|
||||||
|
}
|
||||||
|
|
||||||
|
set
|
||||||
|
{
|
||||||
|
AliveMessageIntervalSeconds = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the default user account that the dlna server uses.
|
||||||
|
/// </summary>
|
||||||
public string DefaultUserId { get; set; }
|
public string DefaultUserId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether playTo device profiles should be created.
|
||||||
|
/// </summary>
|
||||||
|
public bool AutoCreatePlayToProfiles { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether to blast alive messages.
|
||||||
|
/// </summary>
|
||||||
|
public bool BlastAliveMessages { get; set; } = true;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// gets or sets a value indicating whether to send only matched host.
|
||||||
|
/// </summary>
|
||||||
|
public bool SendOnlyMatchedHost { get; set; } = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,11 +9,21 @@ using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
namespace Emby.Dlna.ConnectionManager
|
namespace Emby.Dlna.ConnectionManager
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Defines the <see cref="ConnectionManagerService" />.
|
||||||
|
/// </summary>
|
||||||
public class ConnectionManagerService : BaseService, IConnectionManager
|
public class ConnectionManagerService : BaseService, IConnectionManager
|
||||||
{
|
{
|
||||||
private readonly IDlnaManager _dlna;
|
private readonly IDlnaManager _dlna;
|
||||||
private readonly IServerConfigurationManager _config;
|
private readonly IServerConfigurationManager _config;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="ConnectionManagerService"/> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="dlna">The <see cref="IDlnaManager"/> for use with the <see cref="ConnectionManagerService"/> instance.</param>
|
||||||
|
/// <param name="config">The <see cref="IServerConfigurationManager"/> for use with the <see cref="ConnectionManagerService"/> instance.</param>
|
||||||
|
/// <param name="logger">The <see cref="ILogger{ConnectionManagerService}"/> for use with the <see cref="ConnectionManagerService"/> instance..</param>
|
||||||
|
/// <param name="httpClientFactory">The <see cref="IHttpClientFactory"/> for use with the <see cref="ConnectionManagerService"/> instance..</param>
|
||||||
public ConnectionManagerService(
|
public ConnectionManagerService(
|
||||||
IDlnaManager dlna,
|
IDlnaManager dlna,
|
||||||
IServerConfigurationManager config,
|
IServerConfigurationManager config,
|
||||||
|
@ -28,7 +38,7 @@ namespace Emby.Dlna.ConnectionManager
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public string GetServiceXml()
|
public string GetServiceXml()
|
||||||
{
|
{
|
||||||
return new ConnectionManagerXmlBuilder().GetXml();
|
return ConnectionManagerXmlBuilder.GetXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
|
|
|
@ -6,45 +6,57 @@ using Emby.Dlna.Service;
|
||||||
|
|
||||||
namespace Emby.Dlna.ConnectionManager
|
namespace Emby.Dlna.ConnectionManager
|
||||||
{
|
{
|
||||||
public class ConnectionManagerXmlBuilder
|
/// <summary>
|
||||||
|
/// Defines the <see cref="ConnectionManagerXmlBuilder" />.
|
||||||
|
/// </summary>
|
||||||
|
public static class ConnectionManagerXmlBuilder
|
||||||
{
|
{
|
||||||
public string GetXml()
|
/// <summary>
|
||||||
|
/// Gets the ConnectionManager:1 service template.
|
||||||
|
/// See http://upnp.org/specs/av/UPnP-av-ConnectionManager-v1-Service.pdf.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>An XML description of this service.</returns>
|
||||||
|
public static string GetXml()
|
||||||
{
|
{
|
||||||
return new ServiceXmlBuilder().GetXml(new ServiceActionListBuilder().GetActions(), GetStateVariables());
|
return new ServiceXmlBuilder().GetXml(ServiceActionListBuilder.GetActions(), GetStateVariables());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get the list of state variables for this invocation.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The <see cref="IEnumerable{StateVariable}"/>.</returns>
|
||||||
private static IEnumerable<StateVariable> GetStateVariables()
|
private static IEnumerable<StateVariable> GetStateVariables()
|
||||||
{
|
{
|
||||||
var list = new List<StateVariable>();
|
var list = new List<StateVariable>
|
||||||
|
|
||||||
list.Add(new StateVariable
|
|
||||||
{
|
{
|
||||||
Name = "SourceProtocolInfo",
|
new StateVariable
|
||||||
DataType = "string",
|
{
|
||||||
SendsEvents = true
|
Name = "SourceProtocolInfo",
|
||||||
});
|
DataType = "string",
|
||||||
|
SendsEvents = true
|
||||||
|
},
|
||||||
|
|
||||||
list.Add(new StateVariable
|
new StateVariable
|
||||||
{
|
{
|
||||||
Name = "SinkProtocolInfo",
|
Name = "SinkProtocolInfo",
|
||||||
DataType = "string",
|
DataType = "string",
|
||||||
SendsEvents = true
|
SendsEvents = true
|
||||||
});
|
},
|
||||||
|
|
||||||
list.Add(new StateVariable
|
new StateVariable
|
||||||
{
|
{
|
||||||
Name = "CurrentConnectionIDs",
|
Name = "CurrentConnectionIDs",
|
||||||
DataType = "string",
|
DataType = "string",
|
||||||
SendsEvents = true
|
SendsEvents = true
|
||||||
});
|
},
|
||||||
|
|
||||||
list.Add(new StateVariable
|
new StateVariable
|
||||||
{
|
{
|
||||||
Name = "A_ARG_TYPE_ConnectionStatus",
|
Name = "A_ARG_TYPE_ConnectionStatus",
|
||||||
DataType = "string",
|
DataType = "string",
|
||||||
SendsEvents = false,
|
SendsEvents = false,
|
||||||
|
|
||||||
AllowedValues = new[]
|
AllowedValues = new[]
|
||||||
{
|
{
|
||||||
"OK",
|
"OK",
|
||||||
"ContentFormatMismatch",
|
"ContentFormatMismatch",
|
||||||
|
@ -52,55 +64,56 @@ namespace Emby.Dlna.ConnectionManager
|
||||||
"UnreliableChannel",
|
"UnreliableChannel",
|
||||||
"Unknown"
|
"Unknown"
|
||||||
}
|
}
|
||||||
});
|
},
|
||||||
|
|
||||||
list.Add(new StateVariable
|
new StateVariable
|
||||||
{
|
{
|
||||||
Name = "A_ARG_TYPE_ConnectionManager",
|
Name = "A_ARG_TYPE_ConnectionManager",
|
||||||
DataType = "string",
|
DataType = "string",
|
||||||
SendsEvents = false
|
SendsEvents = false
|
||||||
});
|
},
|
||||||
|
|
||||||
list.Add(new StateVariable
|
new StateVariable
|
||||||
{
|
{
|
||||||
Name = "A_ARG_TYPE_Direction",
|
Name = "A_ARG_TYPE_Direction",
|
||||||
DataType = "string",
|
DataType = "string",
|
||||||
SendsEvents = false,
|
SendsEvents = false,
|
||||||
|
|
||||||
AllowedValues = new[]
|
AllowedValues = new[]
|
||||||
{
|
{
|
||||||
"Output",
|
"Output",
|
||||||
"Input"
|
"Input"
|
||||||
}
|
}
|
||||||
});
|
},
|
||||||
|
|
||||||
list.Add(new StateVariable
|
new StateVariable
|
||||||
{
|
{
|
||||||
Name = "A_ARG_TYPE_ProtocolInfo",
|
Name = "A_ARG_TYPE_ProtocolInfo",
|
||||||
DataType = "string",
|
DataType = "string",
|
||||||
SendsEvents = false
|
SendsEvents = false
|
||||||
});
|
},
|
||||||
|
|
||||||
list.Add(new StateVariable
|
new StateVariable
|
||||||
{
|
{
|
||||||
Name = "A_ARG_TYPE_ConnectionID",
|
Name = "A_ARG_TYPE_ConnectionID",
|
||||||
DataType = "ui4",
|
DataType = "ui4",
|
||||||
SendsEvents = false
|
SendsEvents = false
|
||||||
});
|
},
|
||||||
|
|
||||||
list.Add(new StateVariable
|
new StateVariable
|
||||||
{
|
{
|
||||||
Name = "A_ARG_TYPE_AVTransportID",
|
Name = "A_ARG_TYPE_AVTransportID",
|
||||||
DataType = "ui4",
|
DataType = "ui4",
|
||||||
SendsEvents = false
|
SendsEvents = false
|
||||||
});
|
},
|
||||||
|
|
||||||
list.Add(new StateVariable
|
new StateVariable
|
||||||
{
|
{
|
||||||
Name = "A_ARG_TYPE_RcsID",
|
Name = "A_ARG_TYPE_RcsID",
|
||||||
DataType = "ui4",
|
DataType = "ui4",
|
||||||
SendsEvents = false
|
SendsEvents = false
|
||||||
});
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,10 +11,19 @@ using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
namespace Emby.Dlna.ConnectionManager
|
namespace Emby.Dlna.ConnectionManager
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Defines the <see cref="ControlHandler" />.
|
||||||
|
/// </summary>
|
||||||
public class ControlHandler : BaseControlHandler
|
public class ControlHandler : BaseControlHandler
|
||||||
{
|
{
|
||||||
private readonly DeviceProfile _profile;
|
private readonly DeviceProfile _profile;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="ControlHandler"/> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="config">The <see cref="IServerConfigurationManager"/> for use with the <see cref="ControlHandler"/> instance.</param>
|
||||||
|
/// <param name="logger">The <see cref="ILogger"/> for use with the <see cref="ControlHandler"/> instance.</param>
|
||||||
|
/// <param name="profile">The <see cref="DeviceProfile"/> for use with the <see cref="ControlHandler"/> instance.</param>
|
||||||
public ControlHandler(IServerConfigurationManager config, ILogger logger, DeviceProfile profile)
|
public ControlHandler(IServerConfigurationManager config, ILogger logger, DeviceProfile profile)
|
||||||
: base(config, logger)
|
: base(config, logger)
|
||||||
{
|
{
|
||||||
|
@ -33,6 +42,10 @@ namespace Emby.Dlna.ConnectionManager
|
||||||
throw new ResourceNotFoundException("Unexpected control request name: " + methodName);
|
throw new ResourceNotFoundException("Unexpected control request name: " + methodName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Builds the response to the GetProtocolInfo request.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="xmlWriter">The <see cref="XmlWriter"/>.</param>
|
||||||
private void HandleGetProtocolInfo(XmlWriter xmlWriter)
|
private void HandleGetProtocolInfo(XmlWriter xmlWriter)
|
||||||
{
|
{
|
||||||
xmlWriter.WriteElementString("Source", _profile.ProtocolInfo);
|
xmlWriter.WriteElementString("Source", _profile.ProtocolInfo);
|
||||||
|
|
|
@ -5,9 +5,16 @@ using Emby.Dlna.Common;
|
||||||
|
|
||||||
namespace Emby.Dlna.ConnectionManager
|
namespace Emby.Dlna.ConnectionManager
|
||||||
{
|
{
|
||||||
public class ServiceActionListBuilder
|
/// <summary>
|
||||||
|
/// Defines the <see cref="ServiceActionListBuilder" />.
|
||||||
|
/// </summary>
|
||||||
|
public static class ServiceActionListBuilder
|
||||||
{
|
{
|
||||||
public IEnumerable<ServiceAction> GetActions()
|
/// <summary>
|
||||||
|
/// Returns an enumerable of the ConnectionManagar:1 DLNA actions.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>An <see cref="IEnumerable{ServiceAction}"/>.</returns>
|
||||||
|
public static IEnumerable<ServiceAction> GetActions()
|
||||||
{
|
{
|
||||||
var list = new List<ServiceAction>
|
var list = new List<ServiceAction>
|
||||||
{
|
{
|
||||||
|
@ -21,6 +28,10 @@ namespace Emby.Dlna.ConnectionManager
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the action details for "PrepareForConnection".
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The <see cref="ServiceAction"/>.</returns>
|
||||||
private static ServiceAction PrepareForConnection()
|
private static ServiceAction PrepareForConnection()
|
||||||
{
|
{
|
||||||
var action = new ServiceAction
|
var action = new ServiceAction
|
||||||
|
@ -80,6 +91,10 @@ namespace Emby.Dlna.ConnectionManager
|
||||||
return action;
|
return action;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the action details for "GetCurrentConnectionInfo".
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The <see cref="ServiceAction"/>.</returns>
|
||||||
private static ServiceAction GetCurrentConnectionInfo()
|
private static ServiceAction GetCurrentConnectionInfo()
|
||||||
{
|
{
|
||||||
var action = new ServiceAction
|
var action = new ServiceAction
|
||||||
|
@ -146,7 +161,11 @@ namespace Emby.Dlna.ConnectionManager
|
||||||
return action;
|
return action;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ServiceAction GetProtocolInfo()
|
/// <summary>
|
||||||
|
/// Returns the action details for "GetProtocolInfo".
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The <see cref="ServiceAction"/>.</returns>
|
||||||
|
private static ServiceAction GetProtocolInfo()
|
||||||
{
|
{
|
||||||
var action = new ServiceAction
|
var action = new ServiceAction
|
||||||
{
|
{
|
||||||
|
@ -170,7 +189,11 @@ namespace Emby.Dlna.ConnectionManager
|
||||||
return action;
|
return action;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ServiceAction GetCurrentConnectionIDs()
|
/// <summary>
|
||||||
|
/// Returns the action details for "GetCurrentConnectionIDs".
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The <see cref="ServiceAction"/>.</returns>
|
||||||
|
private static ServiceAction GetCurrentConnectionIDs()
|
||||||
{
|
{
|
||||||
var action = new ServiceAction
|
var action = new ServiceAction
|
||||||
{
|
{
|
||||||
|
@ -187,7 +210,11 @@ namespace Emby.Dlna.ConnectionManager
|
||||||
return action;
|
return action;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ServiceAction ConnectionComplete()
|
/// <summary>
|
||||||
|
/// Returns the action details for "ConnectionComplete".
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The <see cref="ServiceAction"/>.</returns>
|
||||||
|
private static ServiceAction ConnectionComplete()
|
||||||
{
|
{
|
||||||
var action = new ServiceAction
|
var action = new ServiceAction
|
||||||
{
|
{
|
||||||
|
|
|
@ -19,6 +19,9 @@ using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
namespace Emby.Dlna.ContentDirectory
|
namespace Emby.Dlna.ContentDirectory
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Defines the <see cref="ContentDirectoryService" />.
|
||||||
|
/// </summary>
|
||||||
public class ContentDirectoryService : BaseService, IContentDirectory
|
public class ContentDirectoryService : BaseService, IContentDirectory
|
||||||
{
|
{
|
||||||
private readonly ILibraryManager _libraryManager;
|
private readonly ILibraryManager _libraryManager;
|
||||||
|
@ -33,6 +36,22 @@ namespace Emby.Dlna.ContentDirectory
|
||||||
private readonly IMediaEncoder _mediaEncoder;
|
private readonly IMediaEncoder _mediaEncoder;
|
||||||
private readonly ITVSeriesManager _tvSeriesManager;
|
private readonly ITVSeriesManager _tvSeriesManager;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="ContentDirectoryService"/> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="dlna">The <see cref="IDlnaManager"/> to use in the <see cref="ContentDirectoryService"/> instance.</param>
|
||||||
|
/// <param name="userDataManager">The <see cref="IUserDataManager"/> to use in the <see cref="ContentDirectoryService"/> instance.</param>
|
||||||
|
/// <param name="imageProcessor">The <see cref="IImageProcessor"/> to use in the <see cref="ContentDirectoryService"/> instance.</param>
|
||||||
|
/// <param name="libraryManager">The <see cref="ILibraryManager"/> to use in the <see cref="ContentDirectoryService"/> instance.</param>
|
||||||
|
/// <param name="config">The <see cref="IServerConfigurationManager"/> to use in the <see cref="ContentDirectoryService"/> instance.</param>
|
||||||
|
/// <param name="userManager">The <see cref="IUserManager"/> to use in the <see cref="ContentDirectoryService"/> instance.</param>
|
||||||
|
/// <param name="logger">The <see cref="ILogger{ContentDirectoryService}"/> to use in the <see cref="ContentDirectoryService"/> instance.</param>
|
||||||
|
/// <param name="httpClient">The <see cref="IHttpClientFactory"/> to use in the <see cref="ContentDirectoryService"/> instance.</param>
|
||||||
|
/// <param name="localization">The <see cref="ILocalizationManager"/> to use in the <see cref="ContentDirectoryService"/> instance.</param>
|
||||||
|
/// <param name="mediaSourceManager">The <see cref="IMediaSourceManager"/> to use in the <see cref="ContentDirectoryService"/> instance.</param>
|
||||||
|
/// <param name="userViewManager">The <see cref="IUserViewManager"/> to use in the <see cref="ContentDirectoryService"/> instance.</param>
|
||||||
|
/// <param name="mediaEncoder">The <see cref="IMediaEncoder"/> to use in the <see cref="ContentDirectoryService"/> instance.</param>
|
||||||
|
/// <param name="tvSeriesManager">The <see cref="ITVSeriesManager"/> to use in the <see cref="ContentDirectoryService"/> instance.</param>
|
||||||
public ContentDirectoryService(
|
public ContentDirectoryService(
|
||||||
IDlnaManager dlna,
|
IDlnaManager dlna,
|
||||||
IUserDataManager userDataManager,
|
IUserDataManager userDataManager,
|
||||||
|
@ -62,7 +81,10 @@ namespace Emby.Dlna.ContentDirectory
|
||||||
_tvSeriesManager = tvSeriesManager;
|
_tvSeriesManager = tvSeriesManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int SystemUpdateId
|
/// <summary>
|
||||||
|
/// Gets the system id. (A unique id which changes on when our definition changes.)
|
||||||
|
/// </summary>
|
||||||
|
private static int SystemUpdateId
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
|
@ -75,14 +97,18 @@ namespace Emby.Dlna.ContentDirectory
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public string GetServiceXml()
|
public string GetServiceXml()
|
||||||
{
|
{
|
||||||
return new ContentDirectoryXmlBuilder().GetXml();
|
return ContentDirectoryXmlBuilder.GetXml();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public Task<ControlResponse> ProcessControlRequestAsync(ControlRequest request)
|
public Task<ControlResponse> ProcessControlRequestAsync(ControlRequest request)
|
||||||
{
|
{
|
||||||
var profile = _dlna.GetProfile(request.Headers) ??
|
if (request == null)
|
||||||
_dlna.GetDefaultProfile();
|
{
|
||||||
|
throw new ArgumentNullException(nameof(request));
|
||||||
|
}
|
||||||
|
|
||||||
|
var profile = _dlna.GetProfile(request.Headers) ?? _dlna.GetDefaultProfile();
|
||||||
|
|
||||||
var serverAddress = request.RequestedUrl.Substring(0, request.RequestedUrl.IndexOf("/dlna", StringComparison.OrdinalIgnoreCase));
|
var serverAddress = request.RequestedUrl.Substring(0, request.RequestedUrl.IndexOf("/dlna", StringComparison.OrdinalIgnoreCase));
|
||||||
|
|
||||||
|
@ -107,6 +133,11 @@ namespace Emby.Dlna.ContentDirectory
|
||||||
.ProcessControlRequestAsync(request);
|
.ProcessControlRequestAsync(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get the user stored in the device profile.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="profile">The <see cref="DeviceProfile"/>.</param>
|
||||||
|
/// <returns>The <see cref="User"/>.</returns>
|
||||||
private User GetUser(DeviceProfile profile)
|
private User GetUser(DeviceProfile profile)
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty(profile.UserId))
|
if (!string.IsNullOrEmpty(profile.UserId))
|
||||||
|
|
|
@ -6,143 +6,154 @@ using Emby.Dlna.Service;
|
||||||
|
|
||||||
namespace Emby.Dlna.ContentDirectory
|
namespace Emby.Dlna.ContentDirectory
|
||||||
{
|
{
|
||||||
public class ContentDirectoryXmlBuilder
|
/// <summary>
|
||||||
|
/// Defines the <see cref="ContentDirectoryXmlBuilder" />.
|
||||||
|
/// </summary>
|
||||||
|
public static class ContentDirectoryXmlBuilder
|
||||||
{
|
{
|
||||||
public string GetXml()
|
/// <summary>
|
||||||
|
/// Gets the ContentDirectory:1 service template.
|
||||||
|
/// See http://upnp.org/specs/av/UPnP-av-ContentDirectory-v1-Service.pdf.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>An XML description of this service.</returns>
|
||||||
|
public static string GetXml()
|
||||||
{
|
{
|
||||||
return new ServiceXmlBuilder().GetXml(
|
return new ServiceXmlBuilder().GetXml(ServiceActionListBuilder.GetActions(), GetStateVariables());
|
||||||
new ServiceActionListBuilder().GetActions(),
|
|
||||||
GetStateVariables());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get the list of state variables for this invocation.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The <see cref="IEnumerable{StateVariable}"/>.</returns>
|
||||||
private static IEnumerable<StateVariable> GetStateVariables()
|
private static IEnumerable<StateVariable> GetStateVariables()
|
||||||
{
|
{
|
||||||
var list = new List<StateVariable>();
|
var list = new List<StateVariable>
|
||||||
|
|
||||||
list.Add(new StateVariable
|
|
||||||
{
|
{
|
||||||
Name = "A_ARG_TYPE_Filter",
|
new StateVariable
|
||||||
DataType = "string",
|
{
|
||||||
SendsEvents = false
|
Name = "A_ARG_TYPE_Filter",
|
||||||
});
|
DataType = "string",
|
||||||
|
SendsEvents = false
|
||||||
|
},
|
||||||
|
|
||||||
list.Add(new StateVariable
|
new StateVariable
|
||||||
{
|
{
|
||||||
Name = "A_ARG_TYPE_SortCriteria",
|
Name = "A_ARG_TYPE_SortCriteria",
|
||||||
DataType = "string",
|
DataType = "string",
|
||||||
SendsEvents = false
|
SendsEvents = false
|
||||||
});
|
},
|
||||||
|
|
||||||
list.Add(new StateVariable
|
new StateVariable
|
||||||
{
|
{
|
||||||
Name = "A_ARG_TYPE_Index",
|
Name = "A_ARG_TYPE_Index",
|
||||||
DataType = "ui4",
|
DataType = "ui4",
|
||||||
SendsEvents = false
|
SendsEvents = false
|
||||||
});
|
},
|
||||||
|
|
||||||
list.Add(new StateVariable
|
new StateVariable
|
||||||
{
|
{
|
||||||
Name = "A_ARG_TYPE_Count",
|
Name = "A_ARG_TYPE_Count",
|
||||||
DataType = "ui4",
|
DataType = "ui4",
|
||||||
SendsEvents = false
|
SendsEvents = false
|
||||||
});
|
},
|
||||||
|
|
||||||
list.Add(new StateVariable
|
new StateVariable
|
||||||
{
|
{
|
||||||
Name = "A_ARG_TYPE_UpdateID",
|
Name = "A_ARG_TYPE_UpdateID",
|
||||||
DataType = "ui4",
|
DataType = "ui4",
|
||||||
SendsEvents = false
|
SendsEvents = false
|
||||||
});
|
},
|
||||||
|
|
||||||
list.Add(new StateVariable
|
new StateVariable
|
||||||
{
|
{
|
||||||
Name = "SearchCapabilities",
|
Name = "SearchCapabilities",
|
||||||
DataType = "string",
|
DataType = "string",
|
||||||
SendsEvents = false
|
SendsEvents = false
|
||||||
});
|
},
|
||||||
|
|
||||||
list.Add(new StateVariable
|
new StateVariable
|
||||||
{
|
{
|
||||||
Name = "SortCapabilities",
|
Name = "SortCapabilities",
|
||||||
DataType = "string",
|
DataType = "string",
|
||||||
SendsEvents = false
|
SendsEvents = false
|
||||||
});
|
},
|
||||||
|
|
||||||
list.Add(new StateVariable
|
new StateVariable
|
||||||
{
|
{
|
||||||
Name = "SystemUpdateID",
|
Name = "SystemUpdateID",
|
||||||
DataType = "ui4",
|
DataType = "ui4",
|
||||||
SendsEvents = true
|
SendsEvents = true
|
||||||
});
|
},
|
||||||
|
|
||||||
list.Add(new StateVariable
|
new StateVariable
|
||||||
{
|
{
|
||||||
Name = "A_ARG_TYPE_SearchCriteria",
|
Name = "A_ARG_TYPE_SearchCriteria",
|
||||||
DataType = "string",
|
DataType = "string",
|
||||||
SendsEvents = false
|
SendsEvents = false
|
||||||
});
|
},
|
||||||
|
|
||||||
list.Add(new StateVariable
|
new StateVariable
|
||||||
{
|
{
|
||||||
Name = "A_ARG_TYPE_Result",
|
Name = "A_ARG_TYPE_Result",
|
||||||
DataType = "string",
|
DataType = "string",
|
||||||
SendsEvents = false
|
SendsEvents = false
|
||||||
});
|
},
|
||||||
|
|
||||||
list.Add(new StateVariable
|
new StateVariable
|
||||||
{
|
{
|
||||||
Name = "A_ARG_TYPE_ObjectID",
|
Name = "A_ARG_TYPE_ObjectID",
|
||||||
DataType = "string",
|
DataType = "string",
|
||||||
SendsEvents = false
|
SendsEvents = false
|
||||||
});
|
},
|
||||||
|
|
||||||
list.Add(new StateVariable
|
new StateVariable
|
||||||
{
|
{
|
||||||
Name = "A_ARG_TYPE_BrowseFlag",
|
Name = "A_ARG_TYPE_BrowseFlag",
|
||||||
DataType = "string",
|
DataType = "string",
|
||||||
SendsEvents = false,
|
SendsEvents = false,
|
||||||
|
|
||||||
AllowedValues = new[]
|
AllowedValues = new[]
|
||||||
{
|
{
|
||||||
"BrowseMetadata",
|
"BrowseMetadata",
|
||||||
"BrowseDirectChildren"
|
"BrowseDirectChildren"
|
||||||
}
|
}
|
||||||
});
|
},
|
||||||
|
|
||||||
list.Add(new StateVariable
|
new StateVariable
|
||||||
{
|
{
|
||||||
Name = "A_ARG_TYPE_BrowseLetter",
|
Name = "A_ARG_TYPE_BrowseLetter",
|
||||||
DataType = "string",
|
DataType = "string",
|
||||||
SendsEvents = false
|
SendsEvents = false
|
||||||
});
|
},
|
||||||
|
|
||||||
list.Add(new StateVariable
|
new StateVariable
|
||||||
{
|
{
|
||||||
Name = "A_ARG_TYPE_CategoryType",
|
Name = "A_ARG_TYPE_CategoryType",
|
||||||
DataType = "ui4",
|
DataType = "ui4",
|
||||||
SendsEvents = false
|
SendsEvents = false
|
||||||
});
|
},
|
||||||
|
|
||||||
list.Add(new StateVariable
|
new StateVariable
|
||||||
{
|
{
|
||||||
Name = "A_ARG_TYPE_RID",
|
Name = "A_ARG_TYPE_RID",
|
||||||
DataType = "ui4",
|
DataType = "ui4",
|
||||||
SendsEvents = false
|
SendsEvents = false
|
||||||
});
|
},
|
||||||
|
|
||||||
list.Add(new StateVariable
|
new StateVariable
|
||||||
{
|
{
|
||||||
Name = "A_ARG_TYPE_PosSec",
|
Name = "A_ARG_TYPE_PosSec",
|
||||||
DataType = "ui4",
|
DataType = "ui4",
|
||||||
SendsEvents = false
|
SendsEvents = false
|
||||||
});
|
},
|
||||||
|
|
||||||
list.Add(new StateVariable
|
new StateVariable
|
||||||
{
|
{
|
||||||
Name = "A_ARG_TYPE_Featurelist",
|
Name = "A_ARG_TYPE_Featurelist",
|
||||||
DataType = "string",
|
DataType = "string",
|
||||||
SendsEvents = false
|
SendsEvents = false
|
||||||
});
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
#pragma warning disable CS1591
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
@ -8,6 +7,7 @@ using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
|
using Emby.Dlna.Configuration;
|
||||||
using Emby.Dlna.Didl;
|
using Emby.Dlna.Didl;
|
||||||
using Emby.Dlna.Service;
|
using Emby.Dlna.Service;
|
||||||
using Jellyfin.Data.Entities;
|
using Jellyfin.Data.Entities;
|
||||||
|
@ -38,6 +38,9 @@ using Series = MediaBrowser.Controller.Entities.TV.Series;
|
||||||
|
|
||||||
namespace Emby.Dlna.ContentDirectory
|
namespace Emby.Dlna.ContentDirectory
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Defines the <see cref="ControlHandler" />.
|
||||||
|
/// </summary>
|
||||||
public class ControlHandler : BaseControlHandler
|
public class ControlHandler : BaseControlHandler
|
||||||
{
|
{
|
||||||
private const string NsDc = "http://purl.org/dc/elements/1.1/";
|
private const string NsDc = "http://purl.org/dc/elements/1.1/";
|
||||||
|
@ -58,6 +61,24 @@ namespace Emby.Dlna.ContentDirectory
|
||||||
|
|
||||||
private readonly DeviceProfile _profile;
|
private readonly DeviceProfile _profile;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="ControlHandler"/> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="logger">The <see cref="ILogger"/> for use with the <see cref="ControlHandler"/> instance.</param>
|
||||||
|
/// <param name="libraryManager">The <see cref="ILibraryManager"/> for use with the <see cref="ControlHandler"/> instance.</param>
|
||||||
|
/// <param name="profile">The <see cref="DeviceProfile"/> for use with the <see cref="ControlHandler"/> instance.</param>
|
||||||
|
/// <param name="serverAddress">The server address to use in this instance> for use with the <see cref="ControlHandler"/> instance.</param>
|
||||||
|
/// <param name="accessToken">The <see cref="string"/> for use with the <see cref="ControlHandler"/> instance.</param>
|
||||||
|
/// <param name="imageProcessor">The <see cref="IImageProcessor"/> for use with the <see cref="ControlHandler"/> instance.</param>
|
||||||
|
/// <param name="userDataManager">The <see cref="IUserDataManager"/> for use with the <see cref="ControlHandler"/> instance.</param>
|
||||||
|
/// <param name="user">The <see cref="User"/> for use with the <see cref="ControlHandler"/> instance.</param>
|
||||||
|
/// <param name="systemUpdateId">The system id for use with the <see cref="ControlHandler"/> instance.</param>
|
||||||
|
/// <param name="config">The <see cref="IServerConfigurationManager"/> for use with the <see cref="ControlHandler"/> instance.</param>
|
||||||
|
/// <param name="localization">The <see cref="ILocalizationManager"/> for use with the <see cref="ControlHandler"/> instance.</param>
|
||||||
|
/// <param name="mediaSourceManager">The <see cref="IMediaSourceManager"/> for use with the <see cref="ControlHandler"/> instance.</param>
|
||||||
|
/// <param name="userViewManager">The <see cref="IUserViewManager"/> for use with the <see cref="ControlHandler"/> instance.</param>
|
||||||
|
/// <param name="mediaEncoder">The <see cref="IMediaEncoder"/> for use with the <see cref="ControlHandler"/> instance.</param>
|
||||||
|
/// <param name="tvSeriesManager">The <see cref="ITVSeriesManager"/> for use with the <see cref="ControlHandler"/> instance.</param>
|
||||||
public ControlHandler(
|
public ControlHandler(
|
||||||
ILogger logger,
|
ILogger logger,
|
||||||
ILibraryManager libraryManager,
|
ILibraryManager libraryManager,
|
||||||
|
@ -102,6 +123,16 @@ namespace Emby.Dlna.ContentDirectory
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
protected override void WriteResult(string methodName, IDictionary<string, string> methodParams, XmlWriter xmlWriter)
|
protected override void WriteResult(string methodName, IDictionary<string, string> methodParams, XmlWriter xmlWriter)
|
||||||
{
|
{
|
||||||
|
if (xmlWriter == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(xmlWriter));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (methodParams == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(methodParams));
|
||||||
|
}
|
||||||
|
|
||||||
const string DeviceId = "test";
|
const string DeviceId = "test";
|
||||||
|
|
||||||
if (string.Equals(methodName, "GetSearchCapabilities", StringComparison.OrdinalIgnoreCase))
|
if (string.Equals(methodName, "GetSearchCapabilities", StringComparison.OrdinalIgnoreCase))
|
||||||
|
@ -167,6 +198,10 @@ namespace Emby.Dlna.ContentDirectory
|
||||||
throw new ResourceNotFoundException("Unexpected control request name: " + methodName);
|
throw new ResourceNotFoundException("Unexpected control request name: " + methodName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Adds a "XSetBookmark" element to the xml document.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sparams">The <see cref="IDictionary"/>.</param>
|
||||||
private void HandleXSetBookmark(IDictionary<string, string> sparams)
|
private void HandleXSetBookmark(IDictionary<string, string> sparams)
|
||||||
{
|
{
|
||||||
var id = sparams["ObjectID"];
|
var id = sparams["ObjectID"];
|
||||||
|
@ -189,41 +224,69 @@ namespace Emby.Dlna.ContentDirectory
|
||||||
CancellationToken.None);
|
CancellationToken.None);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void HandleGetSearchCapabilities(XmlWriter xmlWriter)
|
/// <summary>
|
||||||
|
/// Adds the "SearchCaps" element to the xml document.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="xmlWriter">The <see cref="XmlWriter"/>.</param>
|
||||||
|
private static void HandleGetSearchCapabilities(XmlWriter xmlWriter)
|
||||||
{
|
{
|
||||||
xmlWriter.WriteElementString(
|
xmlWriter.WriteElementString(
|
||||||
"SearchCaps",
|
"SearchCaps",
|
||||||
"res@resolution,res@size,res@duration,dc:title,dc:creator,upnp:actor,upnp:artist,upnp:genre,upnp:album,dc:date,upnp:class,@id,@refID,@protocolInfo,upnp:author,dc:description,pv:avKeywords");
|
"res@resolution,res@size,res@duration,dc:title,dc:creator,upnp:actor,upnp:artist,upnp:genre,upnp:album,dc:date,upnp:class,@id,@refID,@protocolInfo,upnp:author,dc:description,pv:avKeywords");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void HandleGetSortCapabilities(XmlWriter xmlWriter)
|
/// <summary>
|
||||||
|
/// Adds the "SortCaps" element to the xml document.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="xmlWriter">The <see cref="XmlWriter"/>.</param>
|
||||||
|
private static void HandleGetSortCapabilities(XmlWriter xmlWriter)
|
||||||
{
|
{
|
||||||
xmlWriter.WriteElementString(
|
xmlWriter.WriteElementString(
|
||||||
"SortCaps",
|
"SortCaps",
|
||||||
"res@duration,res@size,res@bitrate,dc:date,dc:title,dc:size,upnp:album,upnp:artist,upnp:albumArtist,upnp:episodeNumber,upnp:genre,upnp:originalTrackNumber,upnp:rating");
|
"res@duration,res@size,res@bitrate,dc:date,dc:title,dc:size,upnp:album,upnp:artist,upnp:albumArtist,upnp:episodeNumber,upnp:genre,upnp:originalTrackNumber,upnp:rating");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void HandleGetSortExtensionCapabilities(XmlWriter xmlWriter)
|
/// <summary>
|
||||||
|
/// Adds the "SortExtensionCaps" element to the xml document.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="xmlWriter">The <see cref="XmlWriter"/>.</param>
|
||||||
|
private static void HandleGetSortExtensionCapabilities(XmlWriter xmlWriter)
|
||||||
{
|
{
|
||||||
xmlWriter.WriteElementString(
|
xmlWriter.WriteElementString(
|
||||||
"SortExtensionCaps",
|
"SortExtensionCaps",
|
||||||
"res@duration,res@size,res@bitrate,dc:date,dc:title,dc:size,upnp:album,upnp:artist,upnp:albumArtist,upnp:episodeNumber,upnp:genre,upnp:originalTrackNumber,upnp:rating");
|
"res@duration,res@size,res@bitrate,dc:date,dc:title,dc:size,upnp:album,upnp:artist,upnp:albumArtist,upnp:episodeNumber,upnp:genre,upnp:originalTrackNumber,upnp:rating");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Adds the "Id" element to the xml document.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="xmlWriter">The <see cref="XmlWriter"/>.</param>
|
||||||
private void HandleGetSystemUpdateID(XmlWriter xmlWriter)
|
private void HandleGetSystemUpdateID(XmlWriter xmlWriter)
|
||||||
{
|
{
|
||||||
xmlWriter.WriteElementString("Id", _systemUpdateId.ToString(CultureInfo.InvariantCulture));
|
xmlWriter.WriteElementString("Id", _systemUpdateId.ToString(CultureInfo.InvariantCulture));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void HandleGetFeatureList(XmlWriter xmlWriter)
|
/// <summary>
|
||||||
|
/// Adds the "FeatureList" element to the xml document.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="xmlWriter">The <see cref="XmlWriter"/>.</param>
|
||||||
|
private static void HandleGetFeatureList(XmlWriter xmlWriter)
|
||||||
{
|
{
|
||||||
xmlWriter.WriteElementString("FeatureList", WriteFeatureListXml());
|
xmlWriter.WriteElementString("FeatureList", WriteFeatureListXml());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void HandleXGetFeatureList(XmlWriter xmlWriter)
|
/// <summary>
|
||||||
|
/// Adds the "FeatureList" element to the xml document.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="xmlWriter">The <see cref="XmlWriter"/>.</param>
|
||||||
|
private static void HandleXGetFeatureList(XmlWriter xmlWriter)
|
||||||
=> HandleGetFeatureList(xmlWriter);
|
=> HandleGetFeatureList(xmlWriter);
|
||||||
|
|
||||||
private string WriteFeatureListXml()
|
/// <summary>
|
||||||
|
/// Builds a static feature list.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The xml feature list.</returns>
|
||||||
|
private static string WriteFeatureListXml()
|
||||||
{
|
{
|
||||||
// TODO: clean this up
|
// TODO: clean this up
|
||||||
var builder = new StringBuilder();
|
var builder = new StringBuilder();
|
||||||
|
@ -242,9 +305,16 @@ namespace Emby.Dlna.ContentDirectory
|
||||||
return builder.ToString();
|
return builder.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetValueOrDefault(IDictionary<string, string> sparams, string key, string defaultValue)
|
/// <summary>
|
||||||
|
/// Returns the value in the key of the dictionary, or defaultValue if it doesn't exist.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sparams">The <see cref="IDictionary"/>.</param>
|
||||||
|
/// <param name="key">The key.</param>
|
||||||
|
/// <param name="defaultValue">The defaultValue.</param>
|
||||||
|
/// <returns>The <see cref="string"/>.</returns>
|
||||||
|
public static string GetValueOrDefault(IDictionary<string, string> sparams, string key, string defaultValue)
|
||||||
{
|
{
|
||||||
if (sparams.TryGetValue(key, out string val))
|
if (sparams != null && sparams.TryGetValue(key, out string val))
|
||||||
{
|
{
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
@ -252,6 +322,12 @@ namespace Emby.Dlna.ContentDirectory
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Builds the "Browse" xml response.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="xmlWriter">The <see cref="XmlWriter"/>.</param>
|
||||||
|
/// <param name="sparams">The <see cref="IDictionary"/>.</param>
|
||||||
|
/// <param name="deviceId">The device Id to use.</param>
|
||||||
private void HandleBrowse(XmlWriter xmlWriter, IDictionary<string, string> sparams, string deviceId)
|
private void HandleBrowse(XmlWriter xmlWriter, IDictionary<string, string> sparams, string deviceId)
|
||||||
{
|
{
|
||||||
var id = sparams["ObjectID"];
|
var id = sparams["ObjectID"];
|
||||||
|
@ -313,7 +389,6 @@ namespace Emby.Dlna.ContentDirectory
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var dlnaOptions = _config.GetDlnaConfiguration();
|
|
||||||
_didlBuilder.WriteItemElement(writer, item, _user, null, null, deviceId, filter);
|
_didlBuilder.WriteItemElement(writer, item, _user, null, null, deviceId, filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -326,7 +401,6 @@ namespace Emby.Dlna.ContentDirectory
|
||||||
|
|
||||||
provided = childrenResult.Items.Count;
|
provided = childrenResult.Items.Count;
|
||||||
|
|
||||||
var dlnaOptions = _config.GetDlnaConfiguration();
|
|
||||||
foreach (var i in childrenResult.Items)
|
foreach (var i in childrenResult.Items)
|
||||||
{
|
{
|
||||||
var childItem = i.Item;
|
var childItem = i.Item;
|
||||||
|
@ -357,12 +431,24 @@ namespace Emby.Dlna.ContentDirectory
|
||||||
xmlWriter.WriteElementString("UpdateID", _systemUpdateId.ToString(CultureInfo.InvariantCulture));
|
xmlWriter.WriteElementString("UpdateID", _systemUpdateId.ToString(CultureInfo.InvariantCulture));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Builds the response to the "X_BrowseByLetter request.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="xmlWriter">The <see cref="XmlWriter"/>.</param>
|
||||||
|
/// <param name="sparams">The <see cref="IDictionary"/>.</param>
|
||||||
|
/// <param name="deviceId">The device id.</param>
|
||||||
private void HandleXBrowseByLetter(XmlWriter xmlWriter, IDictionary<string, string> sparams, string deviceId)
|
private void HandleXBrowseByLetter(XmlWriter xmlWriter, IDictionary<string, string> sparams, string deviceId)
|
||||||
{
|
{
|
||||||
// TODO: Implement this method
|
// TODO: Implement this method
|
||||||
HandleSearch(xmlWriter, sparams, deviceId);
|
HandleSearch(xmlWriter, sparams, deviceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Builds a response to the "Search" request.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="xmlWriter">The xmlWriter<see cref="XmlWriter"/>.</param>
|
||||||
|
/// <param name="sparams">The sparams<see cref="IDictionary"/>.</param>
|
||||||
|
/// <param name="deviceId">The deviceId<see cref="string"/>.</param>
|
||||||
private void HandleSearch(XmlWriter xmlWriter, IDictionary<string, string> sparams, string deviceId)
|
private void HandleSearch(XmlWriter xmlWriter, IDictionary<string, string> sparams, string deviceId)
|
||||||
{
|
{
|
||||||
var searchCriteria = new SearchCriteria(GetValueOrDefault(sparams, "SearchCriteria", string.Empty));
|
var searchCriteria = new SearchCriteria(GetValueOrDefault(sparams, "SearchCriteria", string.Empty));
|
||||||
|
@ -442,7 +528,17 @@ namespace Emby.Dlna.ContentDirectory
|
||||||
xmlWriter.WriteElementString("UpdateID", _systemUpdateId.ToString(CultureInfo.InvariantCulture));
|
xmlWriter.WriteElementString("UpdateID", _systemUpdateId.ToString(CultureInfo.InvariantCulture));
|
||||||
}
|
}
|
||||||
|
|
||||||
private QueryResult<BaseItem> GetChildrenSorted(BaseItem item, User user, SearchCriteria search, SortCriteria sort, int? startIndex, int? limit)
|
/// <summary>
|
||||||
|
/// Returns the child items meeting the criteria.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="item">The <see cref="BaseItem"/>.</param>
|
||||||
|
/// <param name="user">The <see cref="User"/>.</param>
|
||||||
|
/// <param name="search">The <see cref="SearchCriteria"/>.</param>
|
||||||
|
/// <param name="sort">The <see cref="SortCriteria"/>.</param>
|
||||||
|
/// <param name="startIndex">The start index.</param>
|
||||||
|
/// <param name="limit">The maximum number to return.</param>
|
||||||
|
/// <returns>The <see cref="QueryResult{BaseItem}"/>.</returns>
|
||||||
|
private static QueryResult<BaseItem> GetChildrenSorted(BaseItem item, User user, SearchCriteria search, SortCriteria sort, int? startIndex, int? limit)
|
||||||
{
|
{
|
||||||
var folder = (Folder)item;
|
var folder = (Folder)item;
|
||||||
|
|
||||||
|
@ -494,11 +590,25 @@ namespace Emby.Dlna.ContentDirectory
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private DtoOptions GetDtoOptions()
|
/// <summary>
|
||||||
|
/// Returns a new DtoOptions object.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The <see cref="DtoOptions"/>.</returns>
|
||||||
|
private static DtoOptions GetDtoOptions()
|
||||||
{
|
{
|
||||||
return new DtoOptions(true);
|
return new DtoOptions(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the User items meeting the criteria.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="item">The <see cref="BaseItem"/>.</param>
|
||||||
|
/// <param name="stubType">The <see cref="StubType"/>.</param>
|
||||||
|
/// <param name="user">The <see cref="User"/>.</param>
|
||||||
|
/// <param name="sort">The <see cref="SortCriteria"/>.</param>
|
||||||
|
/// <param name="startIndex">The start index.</param>
|
||||||
|
/// <param name="limit">The maximum number to return.</param>
|
||||||
|
/// <returns>The <see cref="QueryResult{ServerItem}"/>.</returns>
|
||||||
private QueryResult<ServerItem> GetUserItems(BaseItem item, StubType? stubType, User user, SortCriteria sort, int? startIndex, int? limit)
|
private QueryResult<ServerItem> GetUserItems(BaseItem item, StubType? stubType, User user, SortCriteria sort, int? startIndex, int? limit)
|
||||||
{
|
{
|
||||||
if (item is MusicGenre)
|
if (item is MusicGenre)
|
||||||
|
@ -568,6 +678,14 @@ namespace Emby.Dlna.ContentDirectory
|
||||||
return ToResult(queryResult);
|
return ToResult(queryResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the Live Tv Channels meeting the criteria.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="user">The <see cref="User"/>.</param>
|
||||||
|
/// <param name="sort">The <see cref="SortCriteria"/>.</param>
|
||||||
|
/// <param name="startIndex">The start index.</param>
|
||||||
|
/// <param name="limit">The maximum number to return.</param>
|
||||||
|
/// <returns>The <see cref="QueryResult{ServerItem}"/>.</returns>
|
||||||
private QueryResult<ServerItem> GetLiveTvChannels(User user, SortCriteria sort, int? startIndex, int? limit)
|
private QueryResult<ServerItem> GetLiveTvChannels(User user, SortCriteria sort, int? startIndex, int? limit)
|
||||||
{
|
{
|
||||||
var query = new InternalItemsQuery(user)
|
var query = new InternalItemsQuery(user)
|
||||||
|
@ -584,6 +702,16 @@ namespace Emby.Dlna.ContentDirectory
|
||||||
return ToResult(result);
|
return ToResult(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the music folders meeting the criteria.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="item">The <see cref="BaseItem"/>.</param>
|
||||||
|
/// <param name="user">The <see cref="User"/>.</param>
|
||||||
|
/// <param name="stubType">The <see cref="StubType"/>.</param>
|
||||||
|
/// <param name="sort">The <see cref="SortCriteria"/>.</param>
|
||||||
|
/// <param name="startIndex">The start index.</param>
|
||||||
|
/// <param name="limit">The maximum number to return.</param>
|
||||||
|
/// <returns>The <see cref="QueryResult{ServerItem}"/>.</returns>
|
||||||
private QueryResult<ServerItem> GetMusicFolders(BaseItem item, User user, StubType? stubType, SortCriteria sort, int? startIndex, int? limit)
|
private QueryResult<ServerItem> GetMusicFolders(BaseItem item, User user, StubType? stubType, SortCriteria sort, int? startIndex, int? limit)
|
||||||
{
|
{
|
||||||
var query = new InternalItemsQuery(user)
|
var query = new InternalItemsQuery(user)
|
||||||
|
@ -643,57 +771,58 @@ namespace Emby.Dlna.ContentDirectory
|
||||||
return GetMusicGenres(item, user, query);
|
return GetMusicGenres(item, user, query);
|
||||||
}
|
}
|
||||||
|
|
||||||
var list = new List<ServerItem>();
|
var list = new List<ServerItem>
|
||||||
|
|
||||||
list.Add(new ServerItem(item)
|
|
||||||
{
|
{
|
||||||
StubType = StubType.Latest
|
new ServerItem(item)
|
||||||
});
|
{
|
||||||
|
StubType = StubType.Latest
|
||||||
|
},
|
||||||
|
|
||||||
list.Add(new ServerItem(item)
|
new ServerItem(item)
|
||||||
{
|
{
|
||||||
StubType = StubType.Playlists
|
StubType = StubType.Playlists
|
||||||
});
|
},
|
||||||
|
|
||||||
list.Add(new ServerItem(item)
|
new ServerItem(item)
|
||||||
{
|
{
|
||||||
StubType = StubType.Albums
|
StubType = StubType.Albums
|
||||||
});
|
},
|
||||||
|
|
||||||
list.Add(new ServerItem(item)
|
new ServerItem(item)
|
||||||
{
|
{
|
||||||
StubType = StubType.AlbumArtists
|
StubType = StubType.AlbumArtists
|
||||||
});
|
},
|
||||||
|
|
||||||
list.Add(new ServerItem(item)
|
new ServerItem(item)
|
||||||
{
|
{
|
||||||
StubType = StubType.Artists
|
StubType = StubType.Artists
|
||||||
});
|
},
|
||||||
|
|
||||||
list.Add(new ServerItem(item)
|
new ServerItem(item)
|
||||||
{
|
{
|
||||||
StubType = StubType.Songs
|
StubType = StubType.Songs
|
||||||
});
|
},
|
||||||
|
|
||||||
list.Add(new ServerItem(item)
|
new ServerItem(item)
|
||||||
{
|
{
|
||||||
StubType = StubType.Genres
|
StubType = StubType.Genres
|
||||||
});
|
},
|
||||||
|
|
||||||
list.Add(new ServerItem(item)
|
new ServerItem(item)
|
||||||
{
|
{
|
||||||
StubType = StubType.FavoriteArtists
|
StubType = StubType.FavoriteArtists
|
||||||
});
|
},
|
||||||
|
|
||||||
list.Add(new ServerItem(item)
|
new ServerItem(item)
|
||||||
{
|
{
|
||||||
StubType = StubType.FavoriteAlbums
|
StubType = StubType.FavoriteAlbums
|
||||||
});
|
},
|
||||||
|
|
||||||
list.Add(new ServerItem(item)
|
new ServerItem(item)
|
||||||
{
|
{
|
||||||
StubType = StubType.FavoriteSongs
|
StubType = StubType.FavoriteSongs
|
||||||
});
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return new QueryResult<ServerItem>
|
return new QueryResult<ServerItem>
|
||||||
{
|
{
|
||||||
|
@ -702,6 +831,16 @@ namespace Emby.Dlna.ContentDirectory
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the movie folders meeting the criteria.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="item">The <see cref="BaseItem"/>.</param>
|
||||||
|
/// <param name="user">The <see cref="User"/>.</param>
|
||||||
|
/// <param name="stubType">The <see cref="StubType"/>.</param>
|
||||||
|
/// <param name="sort">The <see cref="SortCriteria"/>.</param>
|
||||||
|
/// <param name="startIndex">The start index.</param>
|
||||||
|
/// <param name="limit">The maximum number to return.</param>
|
||||||
|
/// <returns>The <see cref="QueryResult{ServerItem}"/>.</returns>
|
||||||
private QueryResult<ServerItem> GetMovieFolders(BaseItem item, User user, StubType? stubType, SortCriteria sort, int? startIndex, int? limit)
|
private QueryResult<ServerItem> GetMovieFolders(BaseItem item, User user, StubType? stubType, SortCriteria sort, int? startIndex, int? limit)
|
||||||
{
|
{
|
||||||
var query = new InternalItemsQuery(user)
|
var query = new InternalItemsQuery(user)
|
||||||
|
@ -776,6 +915,13 @@ namespace Emby.Dlna.ContentDirectory
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the folders meeting the criteria.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="user">The <see cref="User"/>.</param>
|
||||||
|
/// <param name="startIndex">The start index.</param>
|
||||||
|
/// <param name="limit">The maximum number to return.</param>
|
||||||
|
/// <returns>The <see cref="QueryResult{ServerItem}"/>.</returns>
|
||||||
private QueryResult<ServerItem> GetFolders(User user, int? startIndex, int? limit)
|
private QueryResult<ServerItem> GetFolders(User user, int? startIndex, int? limit)
|
||||||
{
|
{
|
||||||
var folders = _libraryManager.GetUserRootFolder().GetChildren(user, true)
|
var folders = _libraryManager.GetUserRootFolder().GetChildren(user, true)
|
||||||
|
@ -796,6 +942,16 @@ namespace Emby.Dlna.ContentDirectory
|
||||||
limit);
|
limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the TV folders meeting the criteria.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="item">The <see cref="BaseItem"/>.</param>
|
||||||
|
/// <param name="user">The <see cref="User"/>.</param>
|
||||||
|
/// <param name="stubType">The <see cref="StubType"/>.</param>
|
||||||
|
/// <param name="sort">The <see cref="SortCriteria"/>.</param>
|
||||||
|
/// <param name="startIndex">The start index.</param>
|
||||||
|
/// <param name="limit">The maximum number to return.</param>
|
||||||
|
/// <returns>The <see cref="QueryResult{ServerItem}"/>.</returns>
|
||||||
private QueryResult<ServerItem> GetTvFolders(BaseItem item, User user, StubType? stubType, SortCriteria sort, int? startIndex, int? limit)
|
private QueryResult<ServerItem> GetTvFolders(BaseItem item, User user, StubType? stubType, SortCriteria sort, int? startIndex, int? limit)
|
||||||
{
|
{
|
||||||
var query = new InternalItemsQuery(user)
|
var query = new InternalItemsQuery(user)
|
||||||
|
@ -840,42 +996,43 @@ namespace Emby.Dlna.ContentDirectory
|
||||||
return GetGenres(item, user, query);
|
return GetGenres(item, user, query);
|
||||||
}
|
}
|
||||||
|
|
||||||
var list = new List<ServerItem>();
|
var list = new List<ServerItem>
|
||||||
|
|
||||||
list.Add(new ServerItem(item)
|
|
||||||
{
|
{
|
||||||
StubType = StubType.ContinueWatching
|
new ServerItem(item)
|
||||||
});
|
{
|
||||||
|
StubType = StubType.ContinueWatching
|
||||||
|
},
|
||||||
|
|
||||||
list.Add(new ServerItem(item)
|
new ServerItem(item)
|
||||||
{
|
{
|
||||||
StubType = StubType.NextUp
|
StubType = StubType.NextUp
|
||||||
});
|
},
|
||||||
|
|
||||||
list.Add(new ServerItem(item)
|
new ServerItem(item)
|
||||||
{
|
{
|
||||||
StubType = StubType.Latest
|
StubType = StubType.Latest
|
||||||
});
|
},
|
||||||
|
|
||||||
list.Add(new ServerItem(item)
|
new ServerItem(item)
|
||||||
{
|
{
|
||||||
StubType = StubType.Series
|
StubType = StubType.Series
|
||||||
});
|
},
|
||||||
|
|
||||||
list.Add(new ServerItem(item)
|
new ServerItem(item)
|
||||||
{
|
{
|
||||||
StubType = StubType.FavoriteSeries
|
StubType = StubType.FavoriteSeries
|
||||||
});
|
},
|
||||||
|
|
||||||
list.Add(new ServerItem(item)
|
new ServerItem(item)
|
||||||
{
|
{
|
||||||
StubType = StubType.FavoriteEpisodes
|
StubType = StubType.FavoriteEpisodes
|
||||||
});
|
},
|
||||||
|
|
||||||
list.Add(new ServerItem(item)
|
new ServerItem(item)
|
||||||
{
|
{
|
||||||
StubType = StubType.Genres
|
StubType = StubType.Genres
|
||||||
});
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return new QueryResult<ServerItem>
|
return new QueryResult<ServerItem>
|
||||||
{
|
{
|
||||||
|
@ -884,6 +1041,13 @@ namespace Emby.Dlna.ContentDirectory
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the Movies that are part watched that meet the criteria.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="parent">The <see cref="BaseItem"/>.</param>
|
||||||
|
/// <param name="user">The <see cref="User"/>.</param>
|
||||||
|
/// <param name="query">The <see cref="InternalItemsQuery"/>.</param>
|
||||||
|
/// <returns>The <see cref="QueryResult{ServerItem}"/>.</returns>
|
||||||
private QueryResult<ServerItem> GetMovieContinueWatching(BaseItem parent, User user, InternalItemsQuery query)
|
private QueryResult<ServerItem> GetMovieContinueWatching(BaseItem parent, User user, InternalItemsQuery query)
|
||||||
{
|
{
|
||||||
query.Recursive = true;
|
query.Recursive = true;
|
||||||
|
@ -904,6 +1068,13 @@ namespace Emby.Dlna.ContentDirectory
|
||||||
return ToResult(result);
|
return ToResult(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the series meeting the criteria.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="parent">The <see cref="BaseItem"/>.</param>
|
||||||
|
/// <param name="user">The <see cref="User"/>.</param>
|
||||||
|
/// <param name="query">The <see cref="InternalItemsQuery"/>.</param>
|
||||||
|
/// <returns>The <see cref="QueryResult{ServerItem}"/>.</returns>
|
||||||
private QueryResult<ServerItem> GetSeries(BaseItem parent, User user, InternalItemsQuery query)
|
private QueryResult<ServerItem> GetSeries(BaseItem parent, User user, InternalItemsQuery query)
|
||||||
{
|
{
|
||||||
query.Recursive = true;
|
query.Recursive = true;
|
||||||
|
@ -917,6 +1088,13 @@ namespace Emby.Dlna.ContentDirectory
|
||||||
return ToResult(result);
|
return ToResult(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the Movie folders meeting the criteria.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="parent">The <see cref="BaseItem"/>.</param>
|
||||||
|
/// <param name="user">The <see cref="User"/>.</param>
|
||||||
|
/// <param name="query">The <see cref="InternalItemsQuery"/>.</param>
|
||||||
|
/// <returns>The <see cref="QueryResult{ServerItem}"/>.</returns>
|
||||||
private QueryResult<ServerItem> GetMovieMovies(BaseItem parent, User user, InternalItemsQuery query)
|
private QueryResult<ServerItem> GetMovieMovies(BaseItem parent, User user, InternalItemsQuery query)
|
||||||
{
|
{
|
||||||
query.Recursive = true;
|
query.Recursive = true;
|
||||||
|
@ -930,6 +1108,12 @@ namespace Emby.Dlna.ContentDirectory
|
||||||
return ToResult(result);
|
return ToResult(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the Movie collections meeting the criteria.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="user">The see cref="User"/>.</param>
|
||||||
|
/// <param name="query">The see cref="InternalItemsQuery"/>.</param>
|
||||||
|
/// <returns>The <see cref="QueryResult{ServerItem}"/>.</returns>
|
||||||
private QueryResult<ServerItem> GetMovieCollections(User user, InternalItemsQuery query)
|
private QueryResult<ServerItem> GetMovieCollections(User user, InternalItemsQuery query)
|
||||||
{
|
{
|
||||||
query.Recursive = true;
|
query.Recursive = true;
|
||||||
|
@ -943,6 +1127,13 @@ namespace Emby.Dlna.ContentDirectory
|
||||||
return ToResult(result);
|
return ToResult(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the Music albums meeting the criteria.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="parent">The <see cref="BaseItem"/>.</param>
|
||||||
|
/// <param name="user">The <see cref="User"/>.</param>
|
||||||
|
/// <param name="query">The <see cref="InternalItemsQuery"/>.</param>
|
||||||
|
/// <returns>The <see cref="QueryResult{ServerItem}"/>.</returns>
|
||||||
private QueryResult<ServerItem> GetMusicAlbums(BaseItem parent, User user, InternalItemsQuery query)
|
private QueryResult<ServerItem> GetMusicAlbums(BaseItem parent, User user, InternalItemsQuery query)
|
||||||
{
|
{
|
||||||
query.Recursive = true;
|
query.Recursive = true;
|
||||||
|
@ -956,6 +1147,13 @@ namespace Emby.Dlna.ContentDirectory
|
||||||
return ToResult(result);
|
return ToResult(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the Music songs meeting the criteria.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="parent">The <see cref="BaseItem"/>.</param>
|
||||||
|
/// <param name="user">The <see cref="User"/>.</param>
|
||||||
|
/// <param name="query">The <see cref="InternalItemsQuery"/>.</param>
|
||||||
|
/// <returns>The <see cref="QueryResult{ServerItem}"/>.</returns>
|
||||||
private QueryResult<ServerItem> GetMusicSongs(BaseItem parent, User user, InternalItemsQuery query)
|
private QueryResult<ServerItem> GetMusicSongs(BaseItem parent, User user, InternalItemsQuery query)
|
||||||
{
|
{
|
||||||
query.Recursive = true;
|
query.Recursive = true;
|
||||||
|
@ -969,6 +1167,13 @@ namespace Emby.Dlna.ContentDirectory
|
||||||
return ToResult(result);
|
return ToResult(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the songs tagged as favourite that meet the criteria.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="parent">The <see cref="BaseItem"/>.</param>
|
||||||
|
/// <param name="user">The <see cref="User"/>.</param>
|
||||||
|
/// <param name="query">The <see cref="InternalItemsQuery"/>.</param>
|
||||||
|
/// <returns>The <see cref="QueryResult{ServerItem}"/>.</returns>
|
||||||
private QueryResult<ServerItem> GetFavoriteSongs(BaseItem parent, User user, InternalItemsQuery query)
|
private QueryResult<ServerItem> GetFavoriteSongs(BaseItem parent, User user, InternalItemsQuery query)
|
||||||
{
|
{
|
||||||
query.Recursive = true;
|
query.Recursive = true;
|
||||||
|
@ -982,6 +1187,13 @@ namespace Emby.Dlna.ContentDirectory
|
||||||
return ToResult(result);
|
return ToResult(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the series tagged as favourite that meet the criteria.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="parent">The <see cref="BaseItem"/>.</param>
|
||||||
|
/// <param name="user">The <see cref="User"/>.</param>
|
||||||
|
/// <param name="query">The <see cref="InternalItemsQuery"/>.</param>
|
||||||
|
/// <returns>The <see cref="QueryResult{ServerItem}"/>.</returns>
|
||||||
private QueryResult<ServerItem> GetFavoriteSeries(BaseItem parent, User user, InternalItemsQuery query)
|
private QueryResult<ServerItem> GetFavoriteSeries(BaseItem parent, User user, InternalItemsQuery query)
|
||||||
{
|
{
|
||||||
query.Recursive = true;
|
query.Recursive = true;
|
||||||
|
@ -995,6 +1207,13 @@ namespace Emby.Dlna.ContentDirectory
|
||||||
return ToResult(result);
|
return ToResult(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the episodes tagged as favourite that meet the criteria.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="parent">The <see cref="BaseItem"/>.</param>
|
||||||
|
/// <param name="user">The <see cref="User"/>.</param>
|
||||||
|
/// <param name="query">The <see cref="InternalItemsQuery"/>.</param>
|
||||||
|
/// <returns>The <see cref="QueryResult{ServerItem}"/>.</returns>
|
||||||
private QueryResult<ServerItem> GetFavoriteEpisodes(BaseItem parent, User user, InternalItemsQuery query)
|
private QueryResult<ServerItem> GetFavoriteEpisodes(BaseItem parent, User user, InternalItemsQuery query)
|
||||||
{
|
{
|
||||||
query.Recursive = true;
|
query.Recursive = true;
|
||||||
|
@ -1008,6 +1227,13 @@ namespace Emby.Dlna.ContentDirectory
|
||||||
return ToResult(result);
|
return ToResult(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the movies tagged as favourite that meet the criteria.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="parent">The <see cref="BaseItem"/>.</param>
|
||||||
|
/// <param name="user">The <see cref="User"/>.</param>
|
||||||
|
/// <param name="query">The <see cref="InternalItemsQuery"/>.</param>
|
||||||
|
/// <returns>The <see cref="QueryResult{ServerItem}"/>.</returns>
|
||||||
private QueryResult<ServerItem> GetMovieFavorites(BaseItem parent, User user, InternalItemsQuery query)
|
private QueryResult<ServerItem> GetMovieFavorites(BaseItem parent, User user, InternalItemsQuery query)
|
||||||
{
|
{
|
||||||
query.Recursive = true;
|
query.Recursive = true;
|
||||||
|
@ -1021,6 +1247,13 @@ namespace Emby.Dlna.ContentDirectory
|
||||||
return ToResult(result);
|
return ToResult(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// /// Returns the albums tagged as favourite that meet the criteria.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="parent">The <see cref="BaseItem"/>.</param>
|
||||||
|
/// <param name="user">The <see cref="User"/>.</param>
|
||||||
|
/// <param name="query">The <see cref="InternalItemsQuery"/>.</param>
|
||||||
|
/// <returns>The <see cref="QueryResult{ServerItem}"/>.</returns>
|
||||||
private QueryResult<ServerItem> GetFavoriteAlbums(BaseItem parent, User user, InternalItemsQuery query)
|
private QueryResult<ServerItem> GetFavoriteAlbums(BaseItem parent, User user, InternalItemsQuery query)
|
||||||
{
|
{
|
||||||
query.Recursive = true;
|
query.Recursive = true;
|
||||||
|
@ -1034,6 +1267,14 @@ namespace Emby.Dlna.ContentDirectory
|
||||||
return ToResult(result);
|
return ToResult(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the genres meeting the criteria.
|
||||||
|
/// The GetGenres.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="parent">The <see cref="BaseItem"/>.</param>
|
||||||
|
/// <param name="user">The <see cref="User"/>.</param>
|
||||||
|
/// <param name="query">The <see cref="InternalItemsQuery"/>.</param>
|
||||||
|
/// <returns>The <see cref="QueryResult{ServerItem}"/>.</returns>
|
||||||
private QueryResult<ServerItem> GetGenres(BaseItem parent, User user, InternalItemsQuery query)
|
private QueryResult<ServerItem> GetGenres(BaseItem parent, User user, InternalItemsQuery query)
|
||||||
{
|
{
|
||||||
var genresResult = _libraryManager.GetGenres(new InternalItemsQuery(user)
|
var genresResult = _libraryManager.GetGenres(new InternalItemsQuery(user)
|
||||||
|
@ -1052,6 +1293,13 @@ namespace Emby.Dlna.ContentDirectory
|
||||||
return ToResult(result);
|
return ToResult(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the music genres meeting the criteria.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="parent">The <see cref="BaseItem"/>.</param>
|
||||||
|
/// <param name="user">The <see cref="User"/>.</param>
|
||||||
|
/// <param name="query">The <see cref="InternalItemsQuery"/>.</param>
|
||||||
|
/// <returns>The <see cref="QueryResult{ServerItem}"/>.</returns>
|
||||||
private QueryResult<ServerItem> GetMusicGenres(BaseItem parent, User user, InternalItemsQuery query)
|
private QueryResult<ServerItem> GetMusicGenres(BaseItem parent, User user, InternalItemsQuery query)
|
||||||
{
|
{
|
||||||
var genresResult = _libraryManager.GetMusicGenres(new InternalItemsQuery(user)
|
var genresResult = _libraryManager.GetMusicGenres(new InternalItemsQuery(user)
|
||||||
|
@ -1070,6 +1318,13 @@ namespace Emby.Dlna.ContentDirectory
|
||||||
return ToResult(result);
|
return ToResult(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the music albums by artist that meet the criteria.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="parent">The <see cref="BaseItem"/>.</param>
|
||||||
|
/// <param name="user">The <see cref="User"/>.</param>
|
||||||
|
/// <param name="query">The <see cref="InternalItemsQuery"/>.</param>
|
||||||
|
/// <returns>The <see cref="QueryResult{ServerItem}"/>.</returns>
|
||||||
private QueryResult<ServerItem> GetMusicAlbumArtists(BaseItem parent, User user, InternalItemsQuery query)
|
private QueryResult<ServerItem> GetMusicAlbumArtists(BaseItem parent, User user, InternalItemsQuery query)
|
||||||
{
|
{
|
||||||
var artists = _libraryManager.GetAlbumArtists(new InternalItemsQuery(user)
|
var artists = _libraryManager.GetAlbumArtists(new InternalItemsQuery(user)
|
||||||
|
@ -1088,6 +1343,13 @@ namespace Emby.Dlna.ContentDirectory
|
||||||
return ToResult(result);
|
return ToResult(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the music artists meeting the criteria.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="parent">The <see cref="BaseItem"/>.</param>
|
||||||
|
/// <param name="user">The <see cref="User"/>.</param>
|
||||||
|
/// <param name="query">The <see cref="InternalItemsQuery"/>.</param>
|
||||||
|
/// <returns>The <see cref="QueryResult{ServerItem}"/>.</returns>
|
||||||
private QueryResult<ServerItem> GetMusicArtists(BaseItem parent, User user, InternalItemsQuery query)
|
private QueryResult<ServerItem> GetMusicArtists(BaseItem parent, User user, InternalItemsQuery query)
|
||||||
{
|
{
|
||||||
var artists = _libraryManager.GetArtists(new InternalItemsQuery(user)
|
var artists = _libraryManager.GetArtists(new InternalItemsQuery(user)
|
||||||
|
@ -1106,6 +1368,13 @@ namespace Emby.Dlna.ContentDirectory
|
||||||
return ToResult(result);
|
return ToResult(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the artists tagged as favourite that meet the criteria.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="parent">The <see cref="BaseItem"/>.</param>
|
||||||
|
/// <param name="user">The <see cref="User"/>.</param>
|
||||||
|
/// <param name="query">The <see cref="InternalItemsQuery"/>.</param>
|
||||||
|
/// <returns>The <see cref="QueryResult{ServerItem}"/>.</returns>
|
||||||
private QueryResult<ServerItem> GetFavoriteArtists(BaseItem parent, User user, InternalItemsQuery query)
|
private QueryResult<ServerItem> GetFavoriteArtists(BaseItem parent, User user, InternalItemsQuery query)
|
||||||
{
|
{
|
||||||
var artists = _libraryManager.GetArtists(new InternalItemsQuery(user)
|
var artists = _libraryManager.GetArtists(new InternalItemsQuery(user)
|
||||||
|
@ -1125,6 +1394,12 @@ namespace Emby.Dlna.ContentDirectory
|
||||||
return ToResult(result);
|
return ToResult(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the music playlists meeting the criteria.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="user">The user<see cref="User"/>.</param>
|
||||||
|
/// <param name="query">The query<see cref="InternalItemsQuery"/>.</param>
|
||||||
|
/// <returns>The <see cref="QueryResult{ServerItem}"/>.</returns>
|
||||||
private QueryResult<ServerItem> GetMusicPlaylists(User user, InternalItemsQuery query)
|
private QueryResult<ServerItem> GetMusicPlaylists(User user, InternalItemsQuery query)
|
||||||
{
|
{
|
||||||
query.Parent = null;
|
query.Parent = null;
|
||||||
|
@ -1137,6 +1412,13 @@ namespace Emby.Dlna.ContentDirectory
|
||||||
return ToResult(result);
|
return ToResult(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the latest music meeting the criteria.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="parent">The <see cref="BaseItem"/>.</param>
|
||||||
|
/// <param name="user">The <see cref="User"/>.</param>
|
||||||
|
/// <param name="query">The <see cref="InternalItemsQuery"/>.</param>
|
||||||
|
/// <returns>The <see cref="QueryResult{ServerItem}"/>.</returns>
|
||||||
private QueryResult<ServerItem> GetMusicLatest(BaseItem parent, User user, InternalItemsQuery query)
|
private QueryResult<ServerItem> GetMusicLatest(BaseItem parent, User user, InternalItemsQuery query)
|
||||||
{
|
{
|
||||||
query.OrderBy = Array.Empty<(string, SortOrder)>();
|
query.OrderBy = Array.Empty<(string, SortOrder)>();
|
||||||
|
@ -1155,6 +1437,12 @@ namespace Emby.Dlna.ContentDirectory
|
||||||
return ToResult(items);
|
return ToResult(items);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the next up item meeting the criteria.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="parent">The <see cref="BaseItem"/>.</param>
|
||||||
|
/// <param name="query">The <see cref="InternalItemsQuery"/>.</param>
|
||||||
|
/// <returns>The <see cref="QueryResult{ServerItem}"/>.</returns>
|
||||||
private QueryResult<ServerItem> GetNextUp(BaseItem parent, InternalItemsQuery query)
|
private QueryResult<ServerItem> GetNextUp(BaseItem parent, InternalItemsQuery query)
|
||||||
{
|
{
|
||||||
query.OrderBy = Array.Empty<(string, SortOrder)>();
|
query.OrderBy = Array.Empty<(string, SortOrder)>();
|
||||||
|
@ -1172,6 +1460,13 @@ namespace Emby.Dlna.ContentDirectory
|
||||||
return ToResult(result);
|
return ToResult(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the latest tv meeting the criteria.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="parent">The <see cref="BaseItem"/>.</param>
|
||||||
|
/// <param name="user">The <see cref="User"/>.</param>
|
||||||
|
/// <param name="query">The <see cref="InternalItemsQuery"/>.</param>
|
||||||
|
/// <returns>The <see cref="QueryResult{ServerItem}"/>.</returns>
|
||||||
private QueryResult<ServerItem> GetTvLatest(BaseItem parent, User user, InternalItemsQuery query)
|
private QueryResult<ServerItem> GetTvLatest(BaseItem parent, User user, InternalItemsQuery query)
|
||||||
{
|
{
|
||||||
query.OrderBy = Array.Empty<(string, SortOrder)>();
|
query.OrderBy = Array.Empty<(string, SortOrder)>();
|
||||||
|
@ -1190,6 +1485,13 @@ namespace Emby.Dlna.ContentDirectory
|
||||||
return ToResult(items);
|
return ToResult(items);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the latest movies meeting the criteria.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="parent">The <see cref="BaseItem"/>.</param>
|
||||||
|
/// <param name="user">The <see cref="User"/>.</param>
|
||||||
|
/// <param name="query">The <see cref="InternalItemsQuery"/>.</param>
|
||||||
|
/// <returns>The <see cref="QueryResult{ServerItem}"/>.</returns>
|
||||||
private QueryResult<ServerItem> GetMovieLatest(BaseItem parent, User user, InternalItemsQuery query)
|
private QueryResult<ServerItem> GetMovieLatest(BaseItem parent, User user, InternalItemsQuery query)
|
||||||
{
|
{
|
||||||
query.OrderBy = Array.Empty<(string, SortOrder)>();
|
query.OrderBy = Array.Empty<(string, SortOrder)>();
|
||||||
|
@ -1208,6 +1510,16 @@ namespace Emby.Dlna.ContentDirectory
|
||||||
return ToResult(items);
|
return ToResult(items);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns music artist items that meet the criteria.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="item">The <see cref="BaseItem"/>.</param>
|
||||||
|
/// <param name="parentId">The <see cref="Guid"/>.</param>
|
||||||
|
/// <param name="user">The <see cref="User"/>.</param>
|
||||||
|
/// <param name="sort">The <see cref="SortCriteria"/>.</param>
|
||||||
|
/// <param name="startIndex">The start index.</param>
|
||||||
|
/// <param name="limit">The maximum number to return.</param>
|
||||||
|
/// <returns>The <see cref="QueryResult{ServerItem}"/>.</returns>
|
||||||
private QueryResult<ServerItem> GetMusicArtistItems(BaseItem item, Guid parentId, User user, SortCriteria sort, int? startIndex, int? limit)
|
private QueryResult<ServerItem> GetMusicArtistItems(BaseItem item, Guid parentId, User user, SortCriteria sort, int? startIndex, int? limit)
|
||||||
{
|
{
|
||||||
var query = new InternalItemsQuery(user)
|
var query = new InternalItemsQuery(user)
|
||||||
|
@ -1228,6 +1540,16 @@ namespace Emby.Dlna.ContentDirectory
|
||||||
return ToResult(result);
|
return ToResult(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the genre items meeting the criteria.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="item">The <see cref="BaseItem"/>.</param>
|
||||||
|
/// <param name="parentId">The <see cref="Guid"/>.</param>
|
||||||
|
/// <param name="user">The <see cref="User"/>.</param>
|
||||||
|
/// <param name="sort">The <see cref="SortCriteria"/>.</param>
|
||||||
|
/// <param name="startIndex">The start index.</param>
|
||||||
|
/// <param name="limit">The maximum number to return.</param>
|
||||||
|
/// <returns>The <see cref="QueryResult{ServerItem}"/>.</returns>
|
||||||
private QueryResult<ServerItem> GetGenreItems(BaseItem item, Guid parentId, User user, SortCriteria sort, int? startIndex, int? limit)
|
private QueryResult<ServerItem> GetGenreItems(BaseItem item, Guid parentId, User user, SortCriteria sort, int? startIndex, int? limit)
|
||||||
{
|
{
|
||||||
var query = new InternalItemsQuery(user)
|
var query = new InternalItemsQuery(user)
|
||||||
|
@ -1252,6 +1574,16 @@ namespace Emby.Dlna.ContentDirectory
|
||||||
return ToResult(result);
|
return ToResult(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the music genre items meeting the criteria.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="item">The <see cref="BaseItem"/>.</param>
|
||||||
|
/// <param name="parentId">The <see cref="Guid"/>.</param>
|
||||||
|
/// <param name="user">The <see cref="User"/>.</param>
|
||||||
|
/// <param name="sort">The <see cref="SortCriteria"/>.</param>
|
||||||
|
/// <param name="startIndex">The start index.</param>
|
||||||
|
/// <param name="limit">The maximum number to return.</param>
|
||||||
|
/// <returns>The <see cref="QueryResult{ServerItem}"/>.</returns>
|
||||||
private QueryResult<ServerItem> GetMusicGenreItems(BaseItem item, Guid parentId, User user, SortCriteria sort, int? startIndex, int? limit)
|
private QueryResult<ServerItem> GetMusicGenreItems(BaseItem item, Guid parentId, User user, SortCriteria sort, int? startIndex, int? limit)
|
||||||
{
|
{
|
||||||
var query = new InternalItemsQuery(user)
|
var query = new InternalItemsQuery(user)
|
||||||
|
@ -1272,7 +1604,12 @@ namespace Emby.Dlna.ContentDirectory
|
||||||
return ToResult(result);
|
return ToResult(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
private QueryResult<ServerItem> ToResult(BaseItem[] result)
|
/// <summary>
|
||||||
|
/// Converts a <see cref="BaseItem"/> array into a <see cref="QueryResult{ServerItem}"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="result">An array of <see cref="BaseItem"/>.</param>
|
||||||
|
/// <returns>A <see cref="QueryResult{ServerItem}"/>.</returns>
|
||||||
|
private static QueryResult<ServerItem> ToResult(BaseItem[] result)
|
||||||
{
|
{
|
||||||
var serverItems = result
|
var serverItems = result
|
||||||
.Select(i => new ServerItem(i))
|
.Select(i => new ServerItem(i))
|
||||||
|
@ -1285,7 +1622,12 @@ namespace Emby.Dlna.ContentDirectory
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private QueryResult<ServerItem> ToResult(QueryResult<BaseItem> result)
|
/// <summary>
|
||||||
|
/// Converts a <see cref="QueryResult{BaseItem}"/> to a <see cref="QueryResult{ServerItem}"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="result">A <see cref="QueryResult{BaseItem}"/>.</param>
|
||||||
|
/// <returns>The <see cref="QueryResult{ServerItem}"/>.</returns>
|
||||||
|
private static QueryResult<ServerItem> ToResult(QueryResult<BaseItem> result)
|
||||||
{
|
{
|
||||||
var serverItems = result
|
var serverItems = result
|
||||||
.Items
|
.Items
|
||||||
|
@ -1299,7 +1641,13 @@ namespace Emby.Dlna.ContentDirectory
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetSorting(InternalItemsQuery query, SortCriteria sort, bool isPreSorted)
|
/// <summary>
|
||||||
|
/// Sets the sorting method on a query.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="query">The <see cref="InternalItemsQuery"/>.</param>
|
||||||
|
/// <param name="sort">The <see cref="SortCriteria"/>.</param>
|
||||||
|
/// <param name="isPreSorted">True if pre-sorted.</param>
|
||||||
|
private static void SetSorting(InternalItemsQuery query, SortCriteria sort, bool isPreSorted)
|
||||||
{
|
{
|
||||||
if (isPreSorted)
|
if (isPreSorted)
|
||||||
{
|
{
|
||||||
|
@ -1311,13 +1659,25 @@ namespace Emby.Dlna.ContentDirectory
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private QueryResult<ServerItem> ApplyPaging(QueryResult<ServerItem> result, int? startIndex, int? limit)
|
/// <summary>
|
||||||
|
/// Apply paging to a query.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="result">The <see cref="QueryResult{ServerItem}"/>.</param>
|
||||||
|
/// <param name="startIndex">The start index.</param>
|
||||||
|
/// <param name="limit">The maximum number to return.</param>
|
||||||
|
/// <returns>A <see cref="QueryResult{ServerItem}"/>.</returns>
|
||||||
|
private static QueryResult<ServerItem> ApplyPaging(QueryResult<ServerItem> result, int? startIndex, int? limit)
|
||||||
{
|
{
|
||||||
result.Items = result.Items.Skip(startIndex ?? 0).Take(limit ?? int.MaxValue).ToArray();
|
result.Items = result.Items.Skip(startIndex ?? 0).Take(limit ?? int.MaxValue).ToArray();
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Retrieves the ServerItem id.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id">The id<see cref="string"/>.</param>
|
||||||
|
/// <returns>The <see cref="ServerItem"/>.</returns>
|
||||||
private ServerItem GetItemFromObjectId(string id)
|
private ServerItem GetItemFromObjectId(string id)
|
||||||
{
|
{
|
||||||
return DidlBuilder.IsIdRoot(id)
|
return DidlBuilder.IsIdRoot(id)
|
||||||
|
@ -1326,6 +1686,11 @@ namespace Emby.Dlna.ContentDirectory
|
||||||
: ParseItemId(id);
|
: ParseItemId(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Parses the item id into a <see cref="ServerItem"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id">The <see cref="string"/>.</param>
|
||||||
|
/// <returns>The corresponding <see cref="ServerItem"/>.</returns>
|
||||||
private ServerItem ParseItemId(string id)
|
private ServerItem ParseItemId(string id)
|
||||||
{
|
{
|
||||||
StubType? stubType = null;
|
StubType? stubType = null;
|
||||||
|
|
|
@ -4,8 +4,15 @@ using MediaBrowser.Controller.Entities;
|
||||||
|
|
||||||
namespace Emby.Dlna.ContentDirectory
|
namespace Emby.Dlna.ContentDirectory
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Defines the <see cref="ServerItem" />.
|
||||||
|
/// </summary>
|
||||||
internal class ServerItem
|
internal class ServerItem
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="ServerItem"/> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="item">The <see cref="BaseItem"/>.</param>
|
||||||
public ServerItem(BaseItem item)
|
public ServerItem(BaseItem item)
|
||||||
{
|
{
|
||||||
Item = item;
|
Item = item;
|
||||||
|
@ -16,8 +23,14 @@ namespace Emby.Dlna.ContentDirectory
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the underlying base item.
|
||||||
|
/// </summary>
|
||||||
public BaseItem Item { get; set; }
|
public BaseItem Item { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the DLNA item type.
|
||||||
|
/// </summary>
|
||||||
public StubType? StubType { get; set; }
|
public StubType? StubType { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,18 @@
|
||||||
#pragma warning disable CS1591
|
|
||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Emby.Dlna.Common;
|
using Emby.Dlna.Common;
|
||||||
|
|
||||||
namespace Emby.Dlna.ContentDirectory
|
namespace Emby.Dlna.ContentDirectory
|
||||||
{
|
{
|
||||||
public class ServiceActionListBuilder
|
/// <summary>
|
||||||
|
/// Defines the <see cref="ServiceActionListBuilder" />.
|
||||||
|
/// </summary>
|
||||||
|
public static class ServiceActionListBuilder
|
||||||
{
|
{
|
||||||
public IEnumerable<ServiceAction> GetActions()
|
/// <summary>
|
||||||
|
/// Returns a list of services that this instance provides.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>An <see cref="IEnumerable{ServiceAction}"/>.</returns>
|
||||||
|
public static IEnumerable<ServiceAction> GetActions()
|
||||||
{
|
{
|
||||||
return new[]
|
return new[]
|
||||||
{
|
{
|
||||||
|
@ -22,6 +27,10 @@ namespace Emby.Dlna.ContentDirectory
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the action details for "GetSystemUpdateID".
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The <see cref="ServiceAction"/>.</returns>
|
||||||
private static ServiceAction GetGetSystemUpdateIDAction()
|
private static ServiceAction GetGetSystemUpdateIDAction()
|
||||||
{
|
{
|
||||||
var action = new ServiceAction
|
var action = new ServiceAction
|
||||||
|
@ -39,6 +48,10 @@ namespace Emby.Dlna.ContentDirectory
|
||||||
return action;
|
return action;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the action details for "GetSearchCapabilities".
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The <see cref="ServiceAction"/>.</returns>
|
||||||
private static ServiceAction GetSearchCapabilitiesAction()
|
private static ServiceAction GetSearchCapabilitiesAction()
|
||||||
{
|
{
|
||||||
var action = new ServiceAction
|
var action = new ServiceAction
|
||||||
|
@ -56,6 +69,10 @@ namespace Emby.Dlna.ContentDirectory
|
||||||
return action;
|
return action;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the action details for "GetSortCapabilities".
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The <see cref="ServiceAction"/>.</returns>
|
||||||
private static ServiceAction GetSortCapabilitiesAction()
|
private static ServiceAction GetSortCapabilitiesAction()
|
||||||
{
|
{
|
||||||
var action = new ServiceAction
|
var action = new ServiceAction
|
||||||
|
@ -73,6 +90,10 @@ namespace Emby.Dlna.ContentDirectory
|
||||||
return action;
|
return action;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the action details for "X_GetFeatureList".
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The <see cref="ServiceAction"/>.</returns>
|
||||||
private static ServiceAction GetX_GetFeatureListAction()
|
private static ServiceAction GetX_GetFeatureListAction()
|
||||||
{
|
{
|
||||||
var action = new ServiceAction
|
var action = new ServiceAction
|
||||||
|
@ -90,6 +111,10 @@ namespace Emby.Dlna.ContentDirectory
|
||||||
return action;
|
return action;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the action details for "Search".
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The <see cref="ServiceAction"/>.</returns>
|
||||||
private static ServiceAction GetSearchAction()
|
private static ServiceAction GetSearchAction()
|
||||||
{
|
{
|
||||||
var action = new ServiceAction
|
var action = new ServiceAction
|
||||||
|
@ -170,7 +195,11 @@ namespace Emby.Dlna.ContentDirectory
|
||||||
return action;
|
return action;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ServiceAction GetBrowseAction()
|
/// <summary>
|
||||||
|
/// Returns the action details for "Browse".
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The <see cref="ServiceAction"/>.</returns>
|
||||||
|
private static ServiceAction GetBrowseAction()
|
||||||
{
|
{
|
||||||
var action = new ServiceAction
|
var action = new ServiceAction
|
||||||
{
|
{
|
||||||
|
@ -250,7 +279,11 @@ namespace Emby.Dlna.ContentDirectory
|
||||||
return action;
|
return action;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ServiceAction GetBrowseByLetterAction()
|
/// <summary>
|
||||||
|
/// Returns the action details for "X_BrowseByLetter".
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The <see cref="ServiceAction"/>.</returns>
|
||||||
|
private static ServiceAction GetBrowseByLetterAction()
|
||||||
{
|
{
|
||||||
var action = new ServiceAction
|
var action = new ServiceAction
|
||||||
{
|
{
|
||||||
|
@ -337,7 +370,11 @@ namespace Emby.Dlna.ContentDirectory
|
||||||
return action;
|
return action;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ServiceAction GetXSetBookmarkAction()
|
/// <summary>
|
||||||
|
/// Returns the action details for "X_SetBookmark".
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The <see cref="ServiceAction"/>.</returns>
|
||||||
|
private static ServiceAction GetXSetBookmarkAction()
|
||||||
{
|
{
|
||||||
var action = new ServiceAction
|
var action = new ServiceAction
|
||||||
{
|
{
|
||||||
|
|
|
@ -3,6 +3,9 @@
|
||||||
|
|
||||||
namespace Emby.Dlna.ContentDirectory
|
namespace Emby.Dlna.ContentDirectory
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Defines the DLNA item types.
|
||||||
|
/// </summary>
|
||||||
public enum StubType
|
public enum StubType
|
||||||
{
|
{
|
||||||
Folder = 0,
|
Folder = 0,
|
||||||
|
|
|
@ -18,7 +18,7 @@ namespace Emby.Dlna.Didl
|
||||||
{
|
{
|
||||||
_all = string.Equals(filter, "*", StringComparison.OrdinalIgnoreCase);
|
_all = string.Equals(filter, "*", StringComparison.OrdinalIgnoreCase);
|
||||||
|
|
||||||
_fields = (filter ?? string.Empty).Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
|
_fields = (filter ?? string.Empty).Split(',', StringSplitOptions.RemoveEmptyEntries);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Contains(string field)
|
public bool Contains(string field)
|
||||||
|
|
|
@ -484,10 +484,10 @@ namespace Emby.Dlna
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Recreates the object using serialization, to ensure it's not a subclass.
|
/// Recreates the object using serialization, to ensure it's not a subclass.
|
||||||
/// If it's a subclass it may not serlialize properly to xml (different root element tag name).
|
/// If it's a subclass it may not serialize properly to xml (different root element tag name).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="profile">The device profile.</param>
|
/// <param name="profile">The device profile.</param>
|
||||||
/// <returns>The reserialized device profile.</returns>
|
/// <returns>The re-serialized device profile.</returns>
|
||||||
private DeviceProfile ReserializeProfile(DeviceProfile profile)
|
private DeviceProfile ReserializeProfile(DeviceProfile profile)
|
||||||
{
|
{
|
||||||
if (profile.GetType() == typeof(DeviceProfile))
|
if (profile.GetType() == typeof(DeviceProfile))
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netstandard2.1</TargetFramework>
|
<TargetFramework>net5.0</TargetFramework>
|
||||||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
||||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||||
|
|
|
@ -83,7 +83,7 @@ namespace Emby.Dlna.Eventing
|
||||||
if (!string.IsNullOrEmpty(header))
|
if (!string.IsNullOrEmpty(header))
|
||||||
{
|
{
|
||||||
// Starts with SECOND-
|
// Starts with SECOND-
|
||||||
header = header.Split('-').Last();
|
header = header.Split('-')[^1];
|
||||||
|
|
||||||
if (int.TryParse(header, NumberStyles.Integer, _usCulture, out var val))
|
if (int.TryParse(header, NumberStyles.Integer, _usCulture, out var val))
|
||||||
{
|
{
|
||||||
|
|
|
@ -480,7 +480,7 @@ namespace Emby.Dlna.PlayTo
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we're not playing anything make sure we don't get data more often than neccessry to keep the Session alive
|
// If we're not playing anything make sure we don't get data more often than necessary to keep the Session alive
|
||||||
if (transportState.Value == TransportState.Stopped)
|
if (transportState.Value == TransportState.Stopped)
|
||||||
{
|
{
|
||||||
RestartTimerInactive();
|
RestartTimerInactive();
|
||||||
|
@ -775,7 +775,7 @@ namespace Emby.Dlna.PlayTo
|
||||||
|
|
||||||
if (track == null)
|
if (track == null)
|
||||||
{
|
{
|
||||||
// If track is null, some vendors do this, use GetMediaInfo instead
|
// If track is null, some vendors do this, use GetMediaInfo instead.
|
||||||
return (true, null);
|
return (true, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -812,7 +812,7 @@ namespace Emby.Dlna.PlayTo
|
||||||
|
|
||||||
private XElement ParseResponse(string xml)
|
private XElement ParseResponse(string xml)
|
||||||
{
|
{
|
||||||
// Handle different variations sent back by devices
|
// Handle different variations sent back by devices.
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return XElement.Parse(xml);
|
return XElement.Parse(xml);
|
||||||
|
@ -821,7 +821,7 @@ namespace Emby.Dlna.PlayTo
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
// first try to add a root node with a dlna namesapce
|
// first try to add a root node with a dlna namespace.
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return XElement.Parse("<data xmlns:dlna=\"urn:schemas-dlna-org:device-1-0\">" + xml + "</data>")
|
return XElement.Parse("<data xmlns:dlna=\"urn:schemas-dlna-org:device-1-0\">" + xml + "</data>")
|
||||||
|
|
|
@ -945,7 +945,10 @@ namespace Emby.Dlna.PlayTo
|
||||||
request.DeviceId = values.GetValueOrDefault("DeviceId");
|
request.DeviceId = values.GetValueOrDefault("DeviceId");
|
||||||
request.MediaSourceId = values.GetValueOrDefault("MediaSourceId");
|
request.MediaSourceId = values.GetValueOrDefault("MediaSourceId");
|
||||||
request.LiveStreamId = values.GetValueOrDefault("LiveStreamId");
|
request.LiveStreamId = values.GetValueOrDefault("LiveStreamId");
|
||||||
request.IsDirectStream = string.Equals("true", values.GetValueOrDefault("Static"), StringComparison.OrdinalIgnoreCase);
|
|
||||||
|
// Be careful, IsDirectStream==true by default (Static != false or not in query).
|
||||||
|
// See initialization of StreamingRequestDto in AudioController.GetAudioStream() method : Static = @static ?? true.
|
||||||
|
request.IsDirectStream = !string.Equals("false", values.GetValueOrDefault("Static"), StringComparison.OrdinalIgnoreCase);
|
||||||
|
|
||||||
request.AudioStreamIndex = GetIntValue(values, "AudioStreamIndex");
|
request.AudioStreamIndex = GetIntValue(values, "AudioStreamIndex");
|
||||||
request.SubtitleStreamIndex = GetIntValue(values, "SubtitleStreamIndex");
|
request.SubtitleStreamIndex = GetIntValue(values, "SubtitleStreamIndex");
|
||||||
|
|
|
@ -45,7 +45,7 @@ namespace Emby.Dlna.PlayTo
|
||||||
header,
|
header,
|
||||||
cancellationToken)
|
cancellationToken)
|
||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
await using var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false);
|
await using var stream = await response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
|
||||||
using var reader = new StreamReader(stream, Encoding.UTF8);
|
using var reader = new StreamReader(stream, Encoding.UTF8);
|
||||||
return XDocument.Parse(
|
return XDocument.Parse(
|
||||||
await reader.ReadToEndAsync().ConfigureAwait(false),
|
await reader.ReadToEndAsync().ConfigureAwait(false),
|
||||||
|
@ -94,7 +94,7 @@ namespace Emby.Dlna.PlayTo
|
||||||
options.Headers.UserAgent.ParseAdd(USERAGENT);
|
options.Headers.UserAgent.ParseAdd(USERAGENT);
|
||||||
options.Headers.TryAddWithoutValidation("FriendlyName.DLNA.ORG", FriendlyName);
|
options.Headers.TryAddWithoutValidation("FriendlyName.DLNA.ORG", FriendlyName);
|
||||||
using var response = await _httpClientFactory.CreateClient(NamedClient.Default).SendAsync(options, HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
|
using var response = await _httpClientFactory.CreateClient(NamedClient.Default).SendAsync(options, HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
|
||||||
await using var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false);
|
await using var stream = await response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
|
||||||
using var reader = new StreamReader(stream, Encoding.UTF8);
|
using var reader = new StreamReader(stream, Encoding.UTF8);
|
||||||
return XDocument.Parse(
|
return XDocument.Parse(
|
||||||
await reader.ReadToEndAsync().ConfigureAwait(false),
|
await reader.ReadToEndAsync().ConfigureAwait(false),
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netstandard2.1</TargetFramework>
|
<TargetFramework>net5.0</TargetFramework>
|
||||||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
||||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||||
|
|
|
@ -1,6 +1,3 @@
|
||||||
#nullable enable
|
|
||||||
#pragma warning disable CS1591
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
@ -9,15 +6,27 @@ using Emby.Naming.Common;
|
||||||
|
|
||||||
namespace Emby.Naming.Audio
|
namespace Emby.Naming.Audio
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Helper class to determine if Album is multipart.
|
||||||
|
/// </summary>
|
||||||
public class AlbumParser
|
public class AlbumParser
|
||||||
{
|
{
|
||||||
private readonly NamingOptions _options;
|
private readonly NamingOptions _options;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="AlbumParser"/> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="options">Naming options containing AlbumStackingPrefixes.</param>
|
||||||
public AlbumParser(NamingOptions options)
|
public AlbumParser(NamingOptions options)
|
||||||
{
|
{
|
||||||
_options = options;
|
_options = options;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Function that determines if album is multipart.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="path">Path to file.</param>
|
||||||
|
/// <returns>True if album is multipart.</returns>
|
||||||
public bool IsMultiPart(string path)
|
public bool IsMultiPart(string path)
|
||||||
{
|
{
|
||||||
var filename = Path.GetFileName(path);
|
var filename = Path.GetFileName(path);
|
||||||
|
|
|
@ -1,6 +1,3 @@
|
||||||
#nullable enable
|
|
||||||
#pragma warning disable CS1591
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
@ -8,8 +5,17 @@ using Emby.Naming.Common;
|
||||||
|
|
||||||
namespace Emby.Naming.Audio
|
namespace Emby.Naming.Audio
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Static helper class to determine if file at path is audio file.
|
||||||
|
/// </summary>
|
||||||
public static class AudioFileParser
|
public static class AudioFileParser
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Static helper method to determine if file at path is audio file.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="path">Path to file.</param>
|
||||||
|
/// <param name="options"><see cref="NamingOptions"/> containing AudioFileExtensions.</param>
|
||||||
|
/// <returns>True if file at path is audio file.</returns>
|
||||||
public static bool IsAudioFile(string path, NamingOptions options)
|
public static bool IsAudioFile(string path, NamingOptions options)
|
||||||
{
|
{
|
||||||
var extension = Path.GetExtension(path);
|
var extension = Path.GetExtension(path);
|
||||||
|
|
|
@ -7,6 +7,21 @@ namespace Emby.Naming.AudioBook
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class AudioBookFileInfo : IComparable<AudioBookFileInfo>
|
public class AudioBookFileInfo : IComparable<AudioBookFileInfo>
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="AudioBookFileInfo"/> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="path">Path to audiobook file.</param>
|
||||||
|
/// <param name="container">File type.</param>
|
||||||
|
/// <param name="partNumber">Number of part this file represents.</param>
|
||||||
|
/// <param name="chapterNumber">Number of chapter this file represents.</param>
|
||||||
|
public AudioBookFileInfo(string path, string container, int? partNumber = default, int? chapterNumber = default)
|
||||||
|
{
|
||||||
|
Path = path;
|
||||||
|
Container = container;
|
||||||
|
PartNumber = partNumber;
|
||||||
|
ChapterNumber = chapterNumber;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the path.
|
/// Gets or sets the path.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -31,14 +46,8 @@ namespace Emby.Naming.AudioBook
|
||||||
/// <value>The chapter number.</value>
|
/// <value>The chapter number.</value>
|
||||||
public int? ChapterNumber { get; set; }
|
public int? ChapterNumber { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets a value indicating whether this instance is a directory.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The type.</value>
|
|
||||||
public bool IsDirectory { get; set; }
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public int CompareTo(AudioBookFileInfo other)
|
public int CompareTo(AudioBookFileInfo? other)
|
||||||
{
|
{
|
||||||
if (ReferenceEquals(this, other))
|
if (ReferenceEquals(this, other))
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,6 +1,3 @@
|
||||||
#nullable enable
|
|
||||||
#pragma warning disable CS1591
|
|
||||||
|
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
|
@ -8,15 +5,27 @@ using Emby.Naming.Common;
|
||||||
|
|
||||||
namespace Emby.Naming.AudioBook
|
namespace Emby.Naming.AudioBook
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Parser class to extract part and/or chapter number from audiobook filename.
|
||||||
|
/// </summary>
|
||||||
public class AudioBookFilePathParser
|
public class AudioBookFilePathParser
|
||||||
{
|
{
|
||||||
private readonly NamingOptions _options;
|
private readonly NamingOptions _options;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="AudioBookFilePathParser"/> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="options">Naming options containing AudioBookPartsExpressions.</param>
|
||||||
public AudioBookFilePathParser(NamingOptions options)
|
public AudioBookFilePathParser(NamingOptions options)
|
||||||
{
|
{
|
||||||
_options = options;
|
_options = options;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Based on regex determines if filename includes part/chapter number.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="path">Path to audiobook file.</param>
|
||||||
|
/// <returns>Returns <see cref="AudioBookFilePathParser"/> object.</returns>
|
||||||
public AudioBookFilePathParserResult Parse(string path)
|
public AudioBookFilePathParserResult Parse(string path)
|
||||||
{
|
{
|
||||||
AudioBookFilePathParserResult result = default;
|
AudioBookFilePathParserResult result = default;
|
||||||
|
@ -52,8 +61,6 @@ namespace Emby.Naming.AudioBook
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
result.Success = result.ChapterNumber.HasValue || result.PartNumber.HasValue;
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,18 @@
|
||||||
#nullable enable
|
|
||||||
#pragma warning disable CS1591
|
|
||||||
|
|
||||||
namespace Emby.Naming.AudioBook
|
namespace Emby.Naming.AudioBook
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Data object for passing result of audiobook part/chapter extraction.
|
||||||
|
/// </summary>
|
||||||
public struct AudioBookFilePathParserResult
|
public struct AudioBookFilePathParserResult
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets optional number of path extracted from audiobook filename.
|
||||||
|
/// </summary>
|
||||||
public int? PartNumber { get; set; }
|
public int? PartNumber { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets optional number of chapter extracted from audiobook filename.
|
||||||
|
/// </summary>
|
||||||
public int? ChapterNumber { get; set; }
|
public int? ChapterNumber { get; set; }
|
||||||
|
|
||||||
public bool Success { get; set; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,11 +10,18 @@ namespace Emby.Naming.AudioBook
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="AudioBookInfo" /> class.
|
/// Initializes a new instance of the <see cref="AudioBookInfo" /> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public AudioBookInfo()
|
/// <param name="name">Name of audiobook.</param>
|
||||||
|
/// <param name="year">Year of audiobook release.</param>
|
||||||
|
/// <param name="files">List of files composing the actual audiobook.</param>
|
||||||
|
/// <param name="extras">List of extra files.</param>
|
||||||
|
/// <param name="alternateVersions">Alternative version of files.</param>
|
||||||
|
public AudioBookInfo(string name, int? year, List<AudioBookFileInfo>? files, List<AudioBookFileInfo>? extras, List<AudioBookFileInfo>? alternateVersions)
|
||||||
{
|
{
|
||||||
Files = new List<AudioBookFileInfo>();
|
Name = name;
|
||||||
Extras = new List<AudioBookFileInfo>();
|
Year = year;
|
||||||
AlternateVersions = new List<AudioBookFileInfo>();
|
Files = files ?? new List<AudioBookFileInfo>();
|
||||||
|
Extras = extras ?? new List<AudioBookFileInfo>();
|
||||||
|
AlternateVersions = alternateVersions ?? new List<AudioBookFileInfo>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#pragma warning disable CS1591
|
using System;
|
||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Emby.Naming.Common;
|
using Emby.Naming.Common;
|
||||||
using Emby.Naming.Video;
|
using Emby.Naming.Video;
|
||||||
|
@ -8,40 +8,145 @@ using MediaBrowser.Model.IO;
|
||||||
|
|
||||||
namespace Emby.Naming.AudioBook
|
namespace Emby.Naming.AudioBook
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Class used to resolve Name, Year, alternative files and extras from stack of files.
|
||||||
|
/// </summary>
|
||||||
public class AudioBookListResolver
|
public class AudioBookListResolver
|
||||||
{
|
{
|
||||||
private readonly NamingOptions _options;
|
private readonly NamingOptions _options;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="AudioBookListResolver"/> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="options">Naming options passed along to <see cref="AudioBookResolver"/> and <see cref="AudioBookNameParser"/>.</param>
|
||||||
public AudioBookListResolver(NamingOptions options)
|
public AudioBookListResolver(NamingOptions options)
|
||||||
{
|
{
|
||||||
_options = options;
|
_options = options;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Resolves Name, Year and differentiate alternative files and extras from regular audiobook files.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="files">List of files related to audiobook.</param>
|
||||||
|
/// <returns>Returns IEnumerable of <see cref="AudioBookInfo"/>.</returns>
|
||||||
public IEnumerable<AudioBookInfo> Resolve(IEnumerable<FileSystemMetadata> files)
|
public IEnumerable<AudioBookInfo> Resolve(IEnumerable<FileSystemMetadata> files)
|
||||||
{
|
{
|
||||||
var audioBookResolver = new AudioBookResolver(_options);
|
var audioBookResolver = new AudioBookResolver(_options);
|
||||||
|
|
||||||
|
// File with empty fullname will be sorted out here.
|
||||||
var audiobookFileInfos = files
|
var audiobookFileInfos = files
|
||||||
.Select(i => audioBookResolver.Resolve(i.FullName, i.IsDirectory))
|
.Select(i => audioBookResolver.Resolve(i.FullName))
|
||||||
.Where(i => i != null)
|
.OfType<AudioBookFileInfo>()
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
// Filter out all extras, otherwise they could cause stacks to not be resolved
|
|
||||||
// See the unit test TestStackedWithTrailer
|
|
||||||
var metadata = audiobookFileInfos
|
|
||||||
.Select(i => new FileSystemMetadata { FullName = i.Path, IsDirectory = i.IsDirectory });
|
|
||||||
|
|
||||||
var stackResult = new StackResolver(_options)
|
var stackResult = new StackResolver(_options)
|
||||||
.ResolveAudioBooks(metadata);
|
.ResolveAudioBooks(audiobookFileInfos);
|
||||||
|
|
||||||
foreach (var stack in stackResult)
|
foreach (var stack in stackResult)
|
||||||
{
|
{
|
||||||
var stackFiles = stack.Files.Select(i => audioBookResolver.Resolve(i, stack.IsDirectoryStack)).ToList();
|
var stackFiles = stack.Files
|
||||||
|
.Select(i => audioBookResolver.Resolve(i))
|
||||||
|
.OfType<AudioBookFileInfo>()
|
||||||
|
.ToList();
|
||||||
|
|
||||||
stackFiles.Sort();
|
stackFiles.Sort();
|
||||||
var info = new AudioBookInfo { Files = stackFiles, Name = stack.Name };
|
|
||||||
|
var nameParserResult = new AudioBookNameParser(_options).Parse(stack.Name);
|
||||||
|
|
||||||
|
FindExtraAndAlternativeFiles(ref stackFiles, out var extras, out var alternativeVersions, nameParserResult);
|
||||||
|
|
||||||
|
var info = new AudioBookInfo(
|
||||||
|
nameParserResult.Name,
|
||||||
|
nameParserResult.Year,
|
||||||
|
stackFiles,
|
||||||
|
extras,
|
||||||
|
alternativeVersions);
|
||||||
|
|
||||||
yield return info;
|
yield return info;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void FindExtraAndAlternativeFiles(ref List<AudioBookFileInfo> stackFiles, out List<AudioBookFileInfo> extras, out List<AudioBookFileInfo> alternativeVersions, AudioBookNameParserResult nameParserResult)
|
||||||
|
{
|
||||||
|
extras = new List<AudioBookFileInfo>();
|
||||||
|
alternativeVersions = new List<AudioBookFileInfo>();
|
||||||
|
|
||||||
|
var haveChaptersOrPages = stackFiles.Any(x => x.ChapterNumber != null || x.PartNumber != null);
|
||||||
|
var groupedBy = stackFiles.GroupBy(file => new { file.ChapterNumber, file.PartNumber });
|
||||||
|
var nameWithReplacedDots = nameParserResult.Name.Replace(" ", ".");
|
||||||
|
|
||||||
|
foreach (var group in groupedBy)
|
||||||
|
{
|
||||||
|
if (group.Key.ChapterNumber == null && group.Key.PartNumber == null)
|
||||||
|
{
|
||||||
|
if (group.Count() > 1 || haveChaptersOrPages)
|
||||||
|
{
|
||||||
|
var ex = new List<AudioBookFileInfo>();
|
||||||
|
var alt = new List<AudioBookFileInfo>();
|
||||||
|
|
||||||
|
foreach (var audioFile in group)
|
||||||
|
{
|
||||||
|
var name = Path.GetFileNameWithoutExtension(audioFile.Path);
|
||||||
|
if (name.Equals("audiobook") ||
|
||||||
|
name.Contains(nameParserResult.Name, StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
name.Contains(nameWithReplacedDots, StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
alt.Add(audioFile);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ex.Add(audioFile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ex.Count > 0)
|
||||||
|
{
|
||||||
|
var extra = ex
|
||||||
|
.OrderBy(x => x.Container)
|
||||||
|
.ThenBy(x => x.Path)
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
stackFiles = stackFiles.Except(extra).ToList();
|
||||||
|
extras.AddRange(extra);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (alt.Count > 0)
|
||||||
|
{
|
||||||
|
var alternatives = alt
|
||||||
|
.OrderBy(x => x.Container)
|
||||||
|
.ThenBy(x => x.Path)
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
var main = FindMainAudioBookFile(alternatives, nameParserResult.Name);
|
||||||
|
alternatives.Remove(main);
|
||||||
|
stackFiles = stackFiles.Except(alternatives).ToList();
|
||||||
|
alternativeVersions.AddRange(alternatives);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (group.Count() > 1)
|
||||||
|
{
|
||||||
|
var alternatives = group
|
||||||
|
.OrderBy(x => x.Container)
|
||||||
|
.ThenBy(x => x.Path)
|
||||||
|
.Skip(1)
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
stackFiles = stackFiles.Except(alternatives).ToList();
|
||||||
|
alternativeVersions.AddRange(alternatives);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private AudioBookFileInfo FindMainAudioBookFile(List<AudioBookFileInfo> files, string name)
|
||||||
|
{
|
||||||
|
var main = files.Find(x => Path.GetFileNameWithoutExtension(x.Path).Equals(name, StringComparison.OrdinalIgnoreCase));
|
||||||
|
main ??= files.FirstOrDefault(x => Path.GetFileNameWithoutExtension(x.Path).Equals("audiobook", StringComparison.OrdinalIgnoreCase));
|
||||||
|
main ??= files.OrderBy(x => x.Container)
|
||||||
|
.ThenBy(x => x.Path)
|
||||||
|
.First();
|
||||||
|
|
||||||
|
return main;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
67
Emby.Naming/AudioBook/AudioBookNameParser.cs
Normal file
67
Emby.Naming/AudioBook/AudioBookNameParser.cs
Normal file
|
@ -0,0 +1,67 @@
|
||||||
|
using System.Globalization;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
using Emby.Naming.Common;
|
||||||
|
|
||||||
|
namespace Emby.Naming.AudioBook
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Helper class to retrieve name and year from audiobook previously retrieved name.
|
||||||
|
/// </summary>
|
||||||
|
public class AudioBookNameParser
|
||||||
|
{
|
||||||
|
private readonly NamingOptions _options;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="AudioBookNameParser"/> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="options">Naming options containing AudioBookNamesExpressions.</param>
|
||||||
|
public AudioBookNameParser(NamingOptions options)
|
||||||
|
{
|
||||||
|
_options = options;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Parse name and year from previously determined name of audiobook.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name">Name of the audiobook.</param>
|
||||||
|
/// <returns>Returns <see cref="AudioBookNameParserResult"/> object.</returns>
|
||||||
|
public AudioBookNameParserResult Parse(string name)
|
||||||
|
{
|
||||||
|
AudioBookNameParserResult result = default;
|
||||||
|
foreach (var expression in _options.AudioBookNamesExpressions)
|
||||||
|
{
|
||||||
|
var match = new Regex(expression, RegexOptions.IgnoreCase).Match(name);
|
||||||
|
if (match.Success)
|
||||||
|
{
|
||||||
|
if (result.Name == null)
|
||||||
|
{
|
||||||
|
var value = match.Groups["name"];
|
||||||
|
if (value.Success)
|
||||||
|
{
|
||||||
|
result.Name = value.Value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!result.Year.HasValue)
|
||||||
|
{
|
||||||
|
var value = match.Groups["year"];
|
||||||
|
if (value.Success)
|
||||||
|
{
|
||||||
|
if (int.TryParse(value.Value, NumberStyles.Integer, CultureInfo.InvariantCulture, out var intValue))
|
||||||
|
{
|
||||||
|
result.Year = intValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(result.Name))
|
||||||
|
{
|
||||||
|
result.Name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
18
Emby.Naming/AudioBook/AudioBookNameParserResult.cs
Normal file
18
Emby.Naming/AudioBook/AudioBookNameParserResult.cs
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
namespace Emby.Naming.AudioBook
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Data object used to pass result of name and year parsing.
|
||||||
|
/// </summary>
|
||||||
|
public struct AudioBookNameParserResult
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets name of audiobook.
|
||||||
|
/// </summary>
|
||||||
|
public string Name { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets optional year of release.
|
||||||
|
/// </summary>
|
||||||
|
public int? Year { get; set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,6 +1,3 @@
|
||||||
#nullable enable
|
|
||||||
#pragma warning disable CS1591
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
@ -8,25 +5,32 @@ using Emby.Naming.Common;
|
||||||
|
|
||||||
namespace Emby.Naming.AudioBook
|
namespace Emby.Naming.AudioBook
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Resolve specifics (path, container, partNumber, chapterNumber) about audiobook file.
|
||||||
|
/// </summary>
|
||||||
public class AudioBookResolver
|
public class AudioBookResolver
|
||||||
{
|
{
|
||||||
private readonly NamingOptions _options;
|
private readonly NamingOptions _options;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="AudioBookResolver"/> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="options"><see cref="NamingOptions"/> containing AudioFileExtensions and also used to pass to AudioBookFilePathParser.</param>
|
||||||
public AudioBookResolver(NamingOptions options)
|
public AudioBookResolver(NamingOptions options)
|
||||||
{
|
{
|
||||||
_options = options;
|
_options = options;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AudioBookFileInfo? Resolve(string path, bool isDirectory = false)
|
/// <summary>
|
||||||
|
/// Resolve specifics (path, container, partNumber, chapterNumber) about audiobook file.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="path">Path to audiobook file.</param>
|
||||||
|
/// <returns>Returns <see cref="AudioBookResolver"/> object.</returns>
|
||||||
|
public AudioBookFileInfo? Resolve(string path)
|
||||||
{
|
{
|
||||||
if (path.Length == 0)
|
if (path.Length == 0 || Path.GetFileNameWithoutExtension(path).Length == 0)
|
||||||
{
|
|
||||||
throw new ArgumentException("String can't be empty.", nameof(path));
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO
|
|
||||||
if (isDirectory)
|
|
||||||
{
|
{
|
||||||
|
// Return null to indicate this path will not be used, instead of stopping whole process with exception
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,14 +46,11 @@ namespace Emby.Naming.AudioBook
|
||||||
|
|
||||||
var parsingResult = new AudioBookFilePathParser(_options).Parse(path);
|
var parsingResult = new AudioBookFilePathParser(_options).Parse(path);
|
||||||
|
|
||||||
return new AudioBookFileInfo
|
return new AudioBookFileInfo(
|
||||||
{
|
path,
|
||||||
Path = path,
|
container,
|
||||||
Container = container,
|
chapterNumber: parsingResult.ChapterNumber,
|
||||||
ChapterNumber = parsingResult.ChapterNumber,
|
partNumber: parsingResult.PartNumber);
|
||||||
PartNumber = parsingResult.PartNumber,
|
|
||||||
IsDirectory = isDirectory
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,28 +1,32 @@
|
||||||
#pragma warning disable CS1591
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
namespace Emby.Naming.Common
|
namespace Emby.Naming.Common
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Regular expressions for parsing TV Episodes.
|
||||||
|
/// </summary>
|
||||||
public class EpisodeExpression
|
public class EpisodeExpression
|
||||||
{
|
{
|
||||||
private string _expression;
|
private string _expression;
|
||||||
private Regex _regex;
|
private Regex? _regex;
|
||||||
|
|
||||||
public EpisodeExpression(string expression, bool byDate)
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="EpisodeExpression"/> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="expression">Regular expressions.</param>
|
||||||
|
/// <param name="byDate">True if date is expected.</param>
|
||||||
|
public EpisodeExpression(string expression, bool byDate = false)
|
||||||
{
|
{
|
||||||
Expression = expression;
|
_expression = expression;
|
||||||
IsByDate = byDate;
|
IsByDate = byDate;
|
||||||
DateTimeFormats = Array.Empty<string>();
|
DateTimeFormats = Array.Empty<string>();
|
||||||
SupportsAbsoluteEpisodeNumbers = true;
|
SupportsAbsoluteEpisodeNumbers = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public EpisodeExpression(string expression)
|
/// <summary>
|
||||||
: this(expression, false)
|
/// Gets or sets raw expressions string.
|
||||||
{
|
/// </summary>
|
||||||
}
|
|
||||||
|
|
||||||
public string Expression
|
public string Expression
|
||||||
{
|
{
|
||||||
get => _expression;
|
get => _expression;
|
||||||
|
@ -33,16 +37,34 @@ namespace Emby.Naming.Common
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether gets or sets property indicating if date can be find in expression.
|
||||||
|
/// </summary>
|
||||||
public bool IsByDate { get; set; }
|
public bool IsByDate { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether gets or sets property indicating if expression is optimistic.
|
||||||
|
/// </summary>
|
||||||
public bool IsOptimistic { get; set; }
|
public bool IsOptimistic { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether gets or sets property indicating if expression is named.
|
||||||
|
/// </summary>
|
||||||
public bool IsNamed { get; set; }
|
public bool IsNamed { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether gets or sets property indicating if expression supports episodes with absolute numbers.
|
||||||
|
/// </summary>
|
||||||
public bool SupportsAbsoluteEpisodeNumbers { get; set; }
|
public bool SupportsAbsoluteEpisodeNumbers { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets optional list of date formats used for date parsing.
|
||||||
|
/// </summary>
|
||||||
public string[] DateTimeFormats { get; set; }
|
public string[] DateTimeFormats { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets a <see cref="Regex"/> expressions objects (creates it if null).
|
||||||
|
/// </summary>
|
||||||
public Regex Regex => _regex ??= new Regex(Expression, RegexOptions.IgnoreCase | RegexOptions.Compiled);
|
public Regex Regex => _regex ??= new Regex(Expression, RegexOptions.IgnoreCase | RegexOptions.Compiled);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
#pragma warning disable CS1591
|
|
||||||
|
|
||||||
namespace Emby.Naming.Common
|
namespace Emby.Naming.Common
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Type of audiovisual media.
|
||||||
|
/// </summary>
|
||||||
public enum MediaType
|
public enum MediaType
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -1,15 +1,21 @@
|
||||||
#pragma warning disable CS1591
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using Emby.Naming.Video;
|
using Emby.Naming.Video;
|
||||||
using MediaBrowser.Model.Entities;
|
using MediaBrowser.Model.Entities;
|
||||||
|
|
||||||
|
// ReSharper disable StringLiteralTypo
|
||||||
|
|
||||||
namespace Emby.Naming.Common
|
namespace Emby.Naming.Common
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Big ugly class containing lot of different naming options that should be split and injected instead of passes everywhere.
|
||||||
|
/// </summary>
|
||||||
public class NamingOptions
|
public class NamingOptions
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="NamingOptions"/> class.
|
||||||
|
/// </summary>
|
||||||
public NamingOptions()
|
public NamingOptions()
|
||||||
{
|
{
|
||||||
VideoFileExtensions = new[]
|
VideoFileExtensions = new[]
|
||||||
|
@ -75,63 +81,52 @@ namespace Emby.Naming.Common
|
||||||
|
|
||||||
StubTypes = new[]
|
StubTypes = new[]
|
||||||
{
|
{
|
||||||
new StubTypeRule
|
new StubTypeRule(
|
||||||
{
|
stubType: "dvd",
|
||||||
StubType = "dvd",
|
token: "dvd"),
|
||||||
Token = "dvd"
|
|
||||||
},
|
new StubTypeRule(
|
||||||
new StubTypeRule
|
stubType: "hddvd",
|
||||||
{
|
token: "hddvd"),
|
||||||
StubType = "hddvd",
|
|
||||||
Token = "hddvd"
|
new StubTypeRule(
|
||||||
},
|
stubType: "bluray",
|
||||||
new StubTypeRule
|
token: "bluray"),
|
||||||
{
|
|
||||||
StubType = "bluray",
|
new StubTypeRule(
|
||||||
Token = "bluray"
|
stubType: "bluray",
|
||||||
},
|
token: "brrip"),
|
||||||
new StubTypeRule
|
|
||||||
{
|
new StubTypeRule(
|
||||||
StubType = "bluray",
|
stubType: "bluray",
|
||||||
Token = "brrip"
|
token: "bd25"),
|
||||||
},
|
|
||||||
new StubTypeRule
|
new StubTypeRule(
|
||||||
{
|
stubType: "bluray",
|
||||||
StubType = "bluray",
|
token: "bd50"),
|
||||||
Token = "bd25"
|
|
||||||
},
|
new StubTypeRule(
|
||||||
new StubTypeRule
|
stubType: "vhs",
|
||||||
{
|
token: "vhs"),
|
||||||
StubType = "bluray",
|
|
||||||
Token = "bd50"
|
new StubTypeRule(
|
||||||
},
|
stubType: "tv",
|
||||||
new StubTypeRule
|
token: "HDTV"),
|
||||||
{
|
|
||||||
StubType = "vhs",
|
new StubTypeRule(
|
||||||
Token = "vhs"
|
stubType: "tv",
|
||||||
},
|
token: "PDTV"),
|
||||||
new StubTypeRule
|
|
||||||
{
|
new StubTypeRule(
|
||||||
StubType = "tv",
|
stubType: "tv",
|
||||||
Token = "HDTV"
|
token: "DSR")
|
||||||
},
|
|
||||||
new StubTypeRule
|
|
||||||
{
|
|
||||||
StubType = "tv",
|
|
||||||
Token = "PDTV"
|
|
||||||
},
|
|
||||||
new StubTypeRule
|
|
||||||
{
|
|
||||||
StubType = "tv",
|
|
||||||
Token = "DSR"
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
VideoFileStackingExpressions = new[]
|
VideoFileStackingExpressions = new[]
|
||||||
{
|
{
|
||||||
"(.*?)([ _.-]*(?:cd|dvd|p(?:ar)?t|dis[ck])[ _.-]*[0-9]+)(.*?)(\\.[^.]+)$",
|
"(?<title>.*?)(?<volume>[ _.-]*(?:cd|dvd|p(?:ar)?t|dis[ck])[ _.-]*[0-9]+)(?<ignore>.*?)(?<extension>\\.[^.]+)$",
|
||||||
"(.*?)([ _.-]*(?:cd|dvd|p(?:ar)?t|dis[ck])[ _.-]*[a-d])(.*?)(\\.[^.]+)$",
|
"(?<title>.*?)(?<volume>[ _.-]*(?:cd|dvd|p(?:ar)?t|dis[ck])[ _.-]*[a-d])(?<ignore>.*?)(?<extension>\\.[^.]+)$",
|
||||||
"(.*?)([ ._-]*[a-d])(.*?)(\\.[^.]+)$"
|
"(?<title>.*?)(?<volume>[ ._-]*[a-d])(?<ignore>.*?)(?<extension>\\.[^.]+)$"
|
||||||
};
|
};
|
||||||
|
|
||||||
CleanDateTimes = new[]
|
CleanDateTimes = new[]
|
||||||
|
@ -142,7 +137,7 @@ namespace Emby.Naming.Common
|
||||||
|
|
||||||
CleanStrings = new[]
|
CleanStrings = new[]
|
||||||
{
|
{
|
||||||
@"[ _\,\.\(\)\[\]\-](3d|sbs|tab|hsbs|htab|mvc|HDR|HDC|UHD|UltraHD|4k|ac3|dts|custom|dc|divx|divx5|dsr|dsrip|dutch|dvd|dvdrip|dvdscr|dvdscreener|screener|dvdivx|cam|fragment|fs|hdtv|hdrip|hdtvrip|internal|limited|multisubs|ntsc|ogg|ogm|pal|pdtv|proper|repack|rerip|retail|cd[1-9]|r3|r5|bd5|bd|se|svcd|swedish|german|read.nfo|nfofix|unrated|ws|telesync|ts|telecine|tc|brrip|bdrip|480p|480i|576p|576i|720p|720i|1080p|1080i|2160p|hrhd|hrhdtv|hddvd|bluray|x264|h264|xvid|xvidvd|xxx|www.www|\[.*\])([ _\,\.\(\)\[\]\-]|$)",
|
@"[ _\,\.\(\)\[\]\-](3d|sbs|tab|hsbs|htab|mvc|HDR|HDC|UHD|UltraHD|4k|ac3|dts|custom|dc|divx|divx5|dsr|dsrip|dutch|dvd|dvdrip|dvdscr|dvdscreener|screener|dvdivx|cam|fragment|fs|hdtv|hdrip|hdtvrip|internal|limited|multisubs|ntsc|ogg|ogm|pal|pdtv|proper|repack|rerip|retail|cd[1-9]|r3|r5|bd5|bd|se|svcd|swedish|german|read.nfo|nfofix|unrated|ws|telesync|ts|telecine|tc|brrip|bdrip|480p|480i|576p|576i|720p|720i|1080p|1080i|2160p|hrhd|hrhdtv|hddvd|bluray|blu-ray|x264|x265|h264|xvid|xvidvd|xxx|www.www|AAC|DTS|\[.*\])([ _\,\.\(\)\[\]\-]|$)",
|
||||||
@"(\[.*\])"
|
@"(\[.*\])"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -255,7 +250,7 @@ namespace Emby.Naming.Common
|
||||||
},
|
},
|
||||||
// <!-- foo.ep01, foo.EP_01 -->
|
// <!-- foo.ep01, foo.EP_01 -->
|
||||||
new EpisodeExpression(@"[\._ -]()[Ee][Pp]_?([0-9]+)([^\\/]*)$"),
|
new EpisodeExpression(@"[\._ -]()[Ee][Pp]_?([0-9]+)([^\\/]*)$"),
|
||||||
new EpisodeExpression("([0-9]{4})[\\.-]([0-9]{2})[\\.-]([0-9]{2})", true)
|
new EpisodeExpression("(?<year>[0-9]{4})[\\.-](?<month>[0-9]{2})[\\.-](?<day>[0-9]{2})", true)
|
||||||
{
|
{
|
||||||
DateTimeFormats = new[]
|
DateTimeFormats = new[]
|
||||||
{
|
{
|
||||||
|
@ -264,7 +259,7 @@ namespace Emby.Naming.Common
|
||||||
"yyyy_MM_dd"
|
"yyyy_MM_dd"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
new EpisodeExpression("([0-9]{2})[\\.-]([0-9]{2})[\\.-]([0-9]{4})", true)
|
new EpisodeExpression(@"(?<day>[0-9]{2})[.-](?<month>[0-9]{2})[.-](?<year>[0-9]{4})", true)
|
||||||
{
|
{
|
||||||
DateTimeFormats = new[]
|
DateTimeFormats = new[]
|
||||||
{
|
{
|
||||||
|
@ -286,7 +281,12 @@ namespace Emby.Naming.Common
|
||||||
{
|
{
|
||||||
SupportsAbsoluteEpisodeNumbers = true
|
SupportsAbsoluteEpisodeNumbers = true
|
||||||
},
|
},
|
||||||
new EpisodeExpression(@"[\\\\/\\._ -](?<seriesname>(?![0-9]+[0-9][0-9])([^\\\/])*)[\\\\/\\._ -](?<seasonnumber>[0-9]+)(?<epnumber>[0-9][0-9](?:(?:[a-i]|\\.[1-9])(?![0-9]))?)([\\._ -][^\\\\/]*)$")
|
|
||||||
|
// Case Closed (1996-2007)/Case Closed - 317.mkv
|
||||||
|
// /server/anything_102.mp4
|
||||||
|
// /server/james.corden.2017.04.20.anne.hathaway.720p.hdtv.x264-crooks.mkv
|
||||||
|
// /server/anything_1996.11.14.mp4
|
||||||
|
new EpisodeExpression(@"[\\/._ -](?<seriesname>(?![0-9]+[0-9][0-9])([^\\\/_])*)[\\\/._ -](?<seasonnumber>[0-9]+)(?<epnumber>[0-9][0-9](?:(?:[a-i]|\.[1-9])(?![0-9]))?)([._ -][^\\\/]*)$")
|
||||||
{
|
{
|
||||||
IsOptimistic = true,
|
IsOptimistic = true,
|
||||||
IsNamed = true,
|
IsNamed = true,
|
||||||
|
@ -381,247 +381,193 @@ namespace Emby.Naming.Common
|
||||||
|
|
||||||
VideoExtraRules = new[]
|
VideoExtraRules = new[]
|
||||||
{
|
{
|
||||||
new ExtraRule
|
new ExtraRule(
|
||||||
{
|
ExtraType.Trailer,
|
||||||
ExtraType = ExtraType.Trailer,
|
ExtraRuleType.Filename,
|
||||||
RuleType = ExtraRuleType.Filename,
|
"trailer",
|
||||||
Token = "trailer",
|
MediaType.Video),
|
||||||
MediaType = MediaType.Video
|
|
||||||
},
|
new ExtraRule(
|
||||||
new ExtraRule
|
ExtraType.Trailer,
|
||||||
{
|
ExtraRuleType.Suffix,
|
||||||
ExtraType = ExtraType.Trailer,
|
"-trailer",
|
||||||
RuleType = ExtraRuleType.Suffix,
|
MediaType.Video),
|
||||||
Token = "-trailer",
|
|
||||||
MediaType = MediaType.Video
|
new ExtraRule(
|
||||||
},
|
ExtraType.Trailer,
|
||||||
new ExtraRule
|
ExtraRuleType.Suffix,
|
||||||
{
|
".trailer",
|
||||||
ExtraType = ExtraType.Trailer,
|
MediaType.Video),
|
||||||
RuleType = ExtraRuleType.Suffix,
|
|
||||||
Token = ".trailer",
|
new ExtraRule(
|
||||||
MediaType = MediaType.Video
|
ExtraType.Trailer,
|
||||||
},
|
ExtraRuleType.Suffix,
|
||||||
new ExtraRule
|
"_trailer",
|
||||||
{
|
MediaType.Video),
|
||||||
ExtraType = ExtraType.Trailer,
|
|
||||||
RuleType = ExtraRuleType.Suffix,
|
new ExtraRule(
|
||||||
Token = "_trailer",
|
ExtraType.Trailer,
|
||||||
MediaType = MediaType.Video
|
ExtraRuleType.Suffix,
|
||||||
},
|
" trailer",
|
||||||
new ExtraRule
|
MediaType.Video),
|
||||||
{
|
|
||||||
ExtraType = ExtraType.Trailer,
|
new ExtraRule(
|
||||||
RuleType = ExtraRuleType.Suffix,
|
ExtraType.Sample,
|
||||||
Token = " trailer",
|
ExtraRuleType.Filename,
|
||||||
MediaType = MediaType.Video
|
"sample",
|
||||||
},
|
MediaType.Video),
|
||||||
new ExtraRule
|
|
||||||
{
|
new ExtraRule(
|
||||||
ExtraType = ExtraType.Sample,
|
ExtraType.Sample,
|
||||||
RuleType = ExtraRuleType.Filename,
|
ExtraRuleType.Suffix,
|
||||||
Token = "sample",
|
"-sample",
|
||||||
MediaType = MediaType.Video
|
MediaType.Video),
|
||||||
},
|
|
||||||
new ExtraRule
|
new ExtraRule(
|
||||||
{
|
ExtraType.Sample,
|
||||||
ExtraType = ExtraType.Sample,
|
ExtraRuleType.Suffix,
|
||||||
RuleType = ExtraRuleType.Suffix,
|
".sample",
|
||||||
Token = "-sample",
|
MediaType.Video),
|
||||||
MediaType = MediaType.Video
|
|
||||||
},
|
new ExtraRule(
|
||||||
new ExtraRule
|
ExtraType.Sample,
|
||||||
{
|
ExtraRuleType.Suffix,
|
||||||
ExtraType = ExtraType.Sample,
|
"_sample",
|
||||||
RuleType = ExtraRuleType.Suffix,
|
MediaType.Video),
|
||||||
Token = ".sample",
|
|
||||||
MediaType = MediaType.Video
|
new ExtraRule(
|
||||||
},
|
ExtraType.Sample,
|
||||||
new ExtraRule
|
ExtraRuleType.Suffix,
|
||||||
{
|
" sample",
|
||||||
ExtraType = ExtraType.Sample,
|
MediaType.Video),
|
||||||
RuleType = ExtraRuleType.Suffix,
|
|
||||||
Token = "_sample",
|
new ExtraRule(
|
||||||
MediaType = MediaType.Video
|
ExtraType.ThemeSong,
|
||||||
},
|
ExtraRuleType.Filename,
|
||||||
new ExtraRule
|
"theme",
|
||||||
{
|
MediaType.Audio),
|
||||||
ExtraType = ExtraType.Sample,
|
|
||||||
RuleType = ExtraRuleType.Suffix,
|
new ExtraRule(
|
||||||
Token = " sample",
|
ExtraType.Scene,
|
||||||
MediaType = MediaType.Video
|
ExtraRuleType.Suffix,
|
||||||
},
|
"-scene",
|
||||||
new ExtraRule
|
MediaType.Video),
|
||||||
{
|
|
||||||
ExtraType = ExtraType.ThemeSong,
|
new ExtraRule(
|
||||||
RuleType = ExtraRuleType.Filename,
|
ExtraType.Clip,
|
||||||
Token = "theme",
|
ExtraRuleType.Suffix,
|
||||||
MediaType = MediaType.Audio
|
"-clip",
|
||||||
},
|
MediaType.Video),
|
||||||
new ExtraRule
|
|
||||||
{
|
new ExtraRule(
|
||||||
ExtraType = ExtraType.Scene,
|
ExtraType.Interview,
|
||||||
RuleType = ExtraRuleType.Suffix,
|
ExtraRuleType.Suffix,
|
||||||
Token = "-scene",
|
"-interview",
|
||||||
MediaType = MediaType.Video
|
MediaType.Video),
|
||||||
},
|
|
||||||
new ExtraRule
|
new ExtraRule(
|
||||||
{
|
ExtraType.BehindTheScenes,
|
||||||
ExtraType = ExtraType.Clip,
|
ExtraRuleType.Suffix,
|
||||||
RuleType = ExtraRuleType.Suffix,
|
"-behindthescenes",
|
||||||
Token = "-clip",
|
MediaType.Video),
|
||||||
MediaType = MediaType.Video
|
|
||||||
},
|
new ExtraRule(
|
||||||
new ExtraRule
|
ExtraType.DeletedScene,
|
||||||
{
|
ExtraRuleType.Suffix,
|
||||||
ExtraType = ExtraType.Interview,
|
"-deleted",
|
||||||
RuleType = ExtraRuleType.Suffix,
|
MediaType.Video),
|
||||||
Token = "-interview",
|
|
||||||
MediaType = MediaType.Video
|
new ExtraRule(
|
||||||
},
|
ExtraType.Clip,
|
||||||
new ExtraRule
|
ExtraRuleType.Suffix,
|
||||||
{
|
"-featurette",
|
||||||
ExtraType = ExtraType.BehindTheScenes,
|
MediaType.Video),
|
||||||
RuleType = ExtraRuleType.Suffix,
|
|
||||||
Token = "-behindthescenes",
|
new ExtraRule(
|
||||||
MediaType = MediaType.Video
|
ExtraType.Clip,
|
||||||
},
|
ExtraRuleType.Suffix,
|
||||||
new ExtraRule
|
"-short",
|
||||||
{
|
MediaType.Video),
|
||||||
ExtraType = ExtraType.DeletedScene,
|
|
||||||
RuleType = ExtraRuleType.Suffix,
|
new ExtraRule(
|
||||||
Token = "-deleted",
|
ExtraType.BehindTheScenes,
|
||||||
MediaType = MediaType.Video
|
ExtraRuleType.DirectoryName,
|
||||||
},
|
"behind the scenes",
|
||||||
new ExtraRule
|
MediaType.Video),
|
||||||
{
|
|
||||||
ExtraType = ExtraType.Clip,
|
new ExtraRule(
|
||||||
RuleType = ExtraRuleType.Suffix,
|
ExtraType.DeletedScene,
|
||||||
Token = "-featurette",
|
ExtraRuleType.DirectoryName,
|
||||||
MediaType = MediaType.Video
|
"deleted scenes",
|
||||||
},
|
MediaType.Video),
|
||||||
new ExtraRule
|
|
||||||
{
|
new ExtraRule(
|
||||||
ExtraType = ExtraType.Clip,
|
ExtraType.Interview,
|
||||||
RuleType = ExtraRuleType.Suffix,
|
ExtraRuleType.DirectoryName,
|
||||||
Token = "-short",
|
"interviews",
|
||||||
MediaType = MediaType.Video
|
MediaType.Video),
|
||||||
},
|
|
||||||
new ExtraRule
|
new ExtraRule(
|
||||||
{
|
ExtraType.Scene,
|
||||||
ExtraType = ExtraType.BehindTheScenes,
|
ExtraRuleType.DirectoryName,
|
||||||
RuleType = ExtraRuleType.DirectoryName,
|
"scenes",
|
||||||
Token = "behind the scenes",
|
MediaType.Video),
|
||||||
MediaType = MediaType.Video,
|
|
||||||
},
|
new ExtraRule(
|
||||||
new ExtraRule
|
ExtraType.Sample,
|
||||||
{
|
ExtraRuleType.DirectoryName,
|
||||||
ExtraType = ExtraType.DeletedScene,
|
"samples",
|
||||||
RuleType = ExtraRuleType.DirectoryName,
|
MediaType.Video),
|
||||||
Token = "deleted scenes",
|
|
||||||
MediaType = MediaType.Video,
|
new ExtraRule(
|
||||||
},
|
ExtraType.Clip,
|
||||||
new ExtraRule
|
ExtraRuleType.DirectoryName,
|
||||||
{
|
"shorts",
|
||||||
ExtraType = ExtraType.Interview,
|
MediaType.Video),
|
||||||
RuleType = ExtraRuleType.DirectoryName,
|
|
||||||
Token = "interviews",
|
new ExtraRule(
|
||||||
MediaType = MediaType.Video,
|
ExtraType.Clip,
|
||||||
},
|
ExtraRuleType.DirectoryName,
|
||||||
new ExtraRule
|
"featurettes",
|
||||||
{
|
MediaType.Video),
|
||||||
ExtraType = ExtraType.Scene,
|
|
||||||
RuleType = ExtraRuleType.DirectoryName,
|
new ExtraRule(
|
||||||
Token = "scenes",
|
ExtraType.Unknown,
|
||||||
MediaType = MediaType.Video,
|
ExtraRuleType.DirectoryName,
|
||||||
},
|
"extras",
|
||||||
new ExtraRule
|
MediaType.Video),
|
||||||
{
|
|
||||||
ExtraType = ExtraType.Sample,
|
|
||||||
RuleType = ExtraRuleType.DirectoryName,
|
|
||||||
Token = "samples",
|
|
||||||
MediaType = MediaType.Video,
|
|
||||||
},
|
|
||||||
new ExtraRule
|
|
||||||
{
|
|
||||||
ExtraType = ExtraType.Clip,
|
|
||||||
RuleType = ExtraRuleType.DirectoryName,
|
|
||||||
Token = "shorts",
|
|
||||||
MediaType = MediaType.Video,
|
|
||||||
},
|
|
||||||
new ExtraRule
|
|
||||||
{
|
|
||||||
ExtraType = ExtraType.Clip,
|
|
||||||
RuleType = ExtraRuleType.DirectoryName,
|
|
||||||
Token = "featurettes",
|
|
||||||
MediaType = MediaType.Video,
|
|
||||||
},
|
|
||||||
new ExtraRule
|
|
||||||
{
|
|
||||||
ExtraType = ExtraType.Unknown,
|
|
||||||
RuleType = ExtraRuleType.DirectoryName,
|
|
||||||
Token = "extras",
|
|
||||||
MediaType = MediaType.Video,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Format3DRules = new[]
|
Format3DRules = new[]
|
||||||
{
|
{
|
||||||
// Kodi rules:
|
// Kodi rules:
|
||||||
new Format3DRule
|
new Format3DRule(
|
||||||
{
|
precedingToken: "3d",
|
||||||
PreceedingToken = "3d",
|
token: "hsbs"),
|
||||||
Token = "hsbs"
|
|
||||||
},
|
new Format3DRule(
|
||||||
new Format3DRule
|
precedingToken: "3d",
|
||||||
{
|
token: "sbs"),
|
||||||
PreceedingToken = "3d",
|
|
||||||
Token = "sbs"
|
new Format3DRule(
|
||||||
},
|
precedingToken: "3d",
|
||||||
new Format3DRule
|
token: "htab"),
|
||||||
{
|
|
||||||
PreceedingToken = "3d",
|
new Format3DRule(
|
||||||
Token = "htab"
|
precedingToken: "3d",
|
||||||
},
|
token: "tab"),
|
||||||
new Format3DRule
|
|
||||||
{
|
// Media Browser rules:
|
||||||
PreceedingToken = "3d",
|
new Format3DRule("fsbs"),
|
||||||
Token = "tab"
|
new Format3DRule("hsbs"),
|
||||||
},
|
new Format3DRule("sbs"),
|
||||||
// Media Browser rules:
|
new Format3DRule("ftab"),
|
||||||
new Format3DRule
|
new Format3DRule("htab"),
|
||||||
{
|
new Format3DRule("tab"),
|
||||||
Token = "fsbs"
|
new Format3DRule("sbs3d"),
|
||||||
},
|
new Format3DRule("mvc")
|
||||||
new Format3DRule
|
|
||||||
{
|
|
||||||
Token = "hsbs"
|
|
||||||
},
|
|
||||||
new Format3DRule
|
|
||||||
{
|
|
||||||
Token = "sbs"
|
|
||||||
},
|
|
||||||
new Format3DRule
|
|
||||||
{
|
|
||||||
Token = "ftab"
|
|
||||||
},
|
|
||||||
new Format3DRule
|
|
||||||
{
|
|
||||||
Token = "htab"
|
|
||||||
},
|
|
||||||
new Format3DRule
|
|
||||||
{
|
|
||||||
Token = "tab"
|
|
||||||
},
|
|
||||||
new Format3DRule
|
|
||||||
{
|
|
||||||
Token = "sbs3d"
|
|
||||||
},
|
|
||||||
new Format3DRule
|
|
||||||
{
|
|
||||||
Token = "mvc"
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
AudioBookPartsExpressions = new[]
|
AudioBookPartsExpressions = new[]
|
||||||
{
|
{
|
||||||
// Detect specified chapters, like CH 01
|
// Detect specified chapters, like CH 01
|
||||||
|
@ -631,13 +577,20 @@ namespace Emby.Naming.Common
|
||||||
// Chapter is often beginning of filename
|
// Chapter is often beginning of filename
|
||||||
"^(?<chapter>[0-9]+)",
|
"^(?<chapter>[0-9]+)",
|
||||||
// Part if often ending of filename
|
// Part if often ending of filename
|
||||||
"(?<part>[0-9]+)$",
|
@"(?<!ch(?:apter) )(?<part>[0-9]+)$",
|
||||||
// Sometimes named as 0001_005 (chapter_part)
|
// Sometimes named as 0001_005 (chapter_part)
|
||||||
"(?<chapter>[0-9]+)_(?<part>[0-9]+)",
|
"(?<chapter>[0-9]+)_(?<part>[0-9]+)",
|
||||||
// Some audiobooks are ripped from cd's, and will be named by disk number.
|
// Some audiobooks are ripped from cd's, and will be named by disk number.
|
||||||
@"dis(?:c|k)[\s_-]?(?<chapter>[0-9]+)"
|
@"dis(?:c|k)[\s_-]?(?<chapter>[0-9]+)"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
AudioBookNamesExpressions = new[]
|
||||||
|
{
|
||||||
|
// Detect year usually in brackets after name Batman (2020)
|
||||||
|
@"^(?<name>.+?)\s*\(\s*(?<year>\d{4})\s*\)\s*$",
|
||||||
|
@"^\s*(?<name>[^ ].*?)\s*$"
|
||||||
|
};
|
||||||
|
|
||||||
var extensions = VideoFileExtensions.ToList();
|
var extensions = VideoFileExtensions.ToList();
|
||||||
|
|
||||||
extensions.AddRange(new[]
|
extensions.AddRange(new[]
|
||||||
|
@ -673,7 +626,7 @@ namespace Emby.Naming.Common
|
||||||
".mxf"
|
".mxf"
|
||||||
});
|
});
|
||||||
|
|
||||||
MultipleEpisodeExpressions = new string[]
|
MultipleEpisodeExpressions = new[]
|
||||||
{
|
{
|
||||||
@".*(\\|\/)[sS]?(?<seasonnumber>[0-9]{1,4})[xX](?<epnumber>[0-9]{1,3})((-| - )[0-9]{1,4}[eExX](?<endingepnumber>[0-9]{1,3}))+[^\\\/]*$",
|
@".*(\\|\/)[sS]?(?<seasonnumber>[0-9]{1,4})[xX](?<epnumber>[0-9]{1,3})((-| - )[0-9]{1,4}[eExX](?<endingepnumber>[0-9]{1,3}))+[^\\\/]*$",
|
||||||
@".*(\\|\/)[sS]?(?<seasonnumber>[0-9]{1,4})[xX](?<epnumber>[0-9]{1,3})((-| - )[0-9]{1,4}[xX][eE](?<endingepnumber>[0-9]{1,3}))+[^\\\/]*$",
|
@".*(\\|\/)[sS]?(?<seasonnumber>[0-9]{1,4})[xX](?<epnumber>[0-9]{1,3})((-| - )[0-9]{1,4}[xX][eE](?<endingepnumber>[0-9]{1,3}))+[^\\\/]*$",
|
||||||
|
@ -697,56 +650,139 @@ namespace Emby.Naming.Common
|
||||||
Compile();
|
Compile();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets list of audio file extensions.
|
||||||
|
/// </summary>
|
||||||
public string[] AudioFileExtensions { get; set; }
|
public string[] AudioFileExtensions { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets list of album stacking prefixes.
|
||||||
|
/// </summary>
|
||||||
public string[] AlbumStackingPrefixes { get; set; }
|
public string[] AlbumStackingPrefixes { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets list of subtitle file extensions.
|
||||||
|
/// </summary>
|
||||||
public string[] SubtitleFileExtensions { get; set; }
|
public string[] SubtitleFileExtensions { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets list of subtitles flag delimiters.
|
||||||
|
/// </summary>
|
||||||
public char[] SubtitleFlagDelimiters { get; set; }
|
public char[] SubtitleFlagDelimiters { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets list of subtitle forced flags.
|
||||||
|
/// </summary>
|
||||||
public string[] SubtitleForcedFlags { get; set; }
|
public string[] SubtitleForcedFlags { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets list of subtitle default flags.
|
||||||
|
/// </summary>
|
||||||
public string[] SubtitleDefaultFlags { get; set; }
|
public string[] SubtitleDefaultFlags { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets list of episode regular expressions.
|
||||||
|
/// </summary>
|
||||||
public EpisodeExpression[] EpisodeExpressions { get; set; }
|
public EpisodeExpression[] EpisodeExpressions { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets list of raw episode without season regular expressions strings.
|
||||||
|
/// </summary>
|
||||||
public string[] EpisodeWithoutSeasonExpressions { get; set; }
|
public string[] EpisodeWithoutSeasonExpressions { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets list of raw multi-part episodes regular expressions strings.
|
||||||
|
/// </summary>
|
||||||
public string[] EpisodeMultiPartExpressions { get; set; }
|
public string[] EpisodeMultiPartExpressions { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets list of video file extensions.
|
||||||
|
/// </summary>
|
||||||
public string[] VideoFileExtensions { get; set; }
|
public string[] VideoFileExtensions { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets list of video stub file extensions.
|
||||||
|
/// </summary>
|
||||||
public string[] StubFileExtensions { get; set; }
|
public string[] StubFileExtensions { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets list of raw audiobook parts regular expressions strings.
|
||||||
|
/// </summary>
|
||||||
public string[] AudioBookPartsExpressions { get; set; }
|
public string[] AudioBookPartsExpressions { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets list of raw audiobook names regular expressions strings.
|
||||||
|
/// </summary>
|
||||||
|
public string[] AudioBookNamesExpressions { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets list of stub type rules.
|
||||||
|
/// </summary>
|
||||||
public StubTypeRule[] StubTypes { get; set; }
|
public StubTypeRule[] StubTypes { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets list of video flag delimiters.
|
||||||
|
/// </summary>
|
||||||
public char[] VideoFlagDelimiters { get; set; }
|
public char[] VideoFlagDelimiters { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets list of 3D Format rules.
|
||||||
|
/// </summary>
|
||||||
public Format3DRule[] Format3DRules { get; set; }
|
public Format3DRule[] Format3DRules { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets list of raw video file-stacking expressions strings.
|
||||||
|
/// </summary>
|
||||||
public string[] VideoFileStackingExpressions { get; set; }
|
public string[] VideoFileStackingExpressions { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets list of raw clean DateTimes regular expressions strings.
|
||||||
|
/// </summary>
|
||||||
public string[] CleanDateTimes { get; set; }
|
public string[] CleanDateTimes { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets list of raw clean strings regular expressions strings.
|
||||||
|
/// </summary>
|
||||||
public string[] CleanStrings { get; set; }
|
public string[] CleanStrings { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets list of multi-episode regular expressions.
|
||||||
|
/// </summary>
|
||||||
public EpisodeExpression[] MultipleEpisodeExpressions { get; set; }
|
public EpisodeExpression[] MultipleEpisodeExpressions { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets list of extra rules for videos.
|
||||||
|
/// </summary>
|
||||||
public ExtraRule[] VideoExtraRules { get; set; }
|
public ExtraRule[] VideoExtraRules { get; set; }
|
||||||
|
|
||||||
public Regex[] VideoFileStackingRegexes { get; private set; }
|
/// <summary>
|
||||||
|
/// Gets list of video file-stack regular expressions.
|
||||||
|
/// </summary>
|
||||||
|
public Regex[] VideoFileStackingRegexes { get; private set; } = Array.Empty<Regex>();
|
||||||
|
|
||||||
public Regex[] CleanDateTimeRegexes { get; private set; }
|
/// <summary>
|
||||||
|
/// Gets list of clean datetime regular expressions.
|
||||||
|
/// </summary>
|
||||||
|
public Regex[] CleanDateTimeRegexes { get; private set; } = Array.Empty<Regex>();
|
||||||
|
|
||||||
public Regex[] CleanStringRegexes { get; private set; }
|
/// <summary>
|
||||||
|
/// Gets list of clean string regular expressions.
|
||||||
|
/// </summary>
|
||||||
|
public Regex[] CleanStringRegexes { get; private set; } = Array.Empty<Regex>();
|
||||||
|
|
||||||
public Regex[] EpisodeWithoutSeasonRegexes { get; private set; }
|
/// <summary>
|
||||||
|
/// Gets list of episode without season regular expressions.
|
||||||
|
/// </summary>
|
||||||
|
public Regex[] EpisodeWithoutSeasonRegexes { get; private set; } = Array.Empty<Regex>();
|
||||||
|
|
||||||
public Regex[] EpisodeMultiPartRegexes { get; private set; }
|
/// <summary>
|
||||||
|
/// Gets list of multi-part episode regular expressions.
|
||||||
|
/// </summary>
|
||||||
|
public Regex[] EpisodeMultiPartRegexes { get; private set; } = Array.Empty<Regex>();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Compiles raw regex strings into regexes.
|
||||||
|
/// </summary>
|
||||||
public void Compile()
|
public void Compile()
|
||||||
{
|
{
|
||||||
VideoFileStackingRegexes = VideoFileStackingExpressions.Select(Compile).ToArray();
|
VideoFileStackingRegexes = VideoFileStackingExpressions.Select(Compile).ToArray();
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netstandard2.1</TargetFramework>
|
<TargetFramework>net5.0</TargetFramework>
|
||||||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
||||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||||
|
@ -14,6 +14,7 @@
|
||||||
<EmbedUntrackedSources>true</EmbedUntrackedSources>
|
<EmbedUntrackedSources>true</EmbedUntrackedSources>
|
||||||
<IncludeSymbols>true</IncludeSymbols>
|
<IncludeSymbols>true</IncludeSymbols>
|
||||||
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
|
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup Condition=" '$(Stability)'=='Unstable'">
|
<PropertyGroup Condition=" '$(Stability)'=='Unstable'">
|
||||||
|
@ -38,7 +39,7 @@
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All"/>
|
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<!-- Code Analyzers-->
|
<!-- Code Analyzers-->
|
||||||
|
|
|
@ -1,9 +1,23 @@
|
||||||
#pragma warning disable CS1591
|
|
||||||
|
|
||||||
namespace Emby.Naming.Subtitles
|
namespace Emby.Naming.Subtitles
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Class holding information about subtitle.
|
||||||
|
/// </summary>
|
||||||
public class SubtitleInfo
|
public class SubtitleInfo
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="SubtitleInfo"/> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="path">Path to file.</param>
|
||||||
|
/// <param name="isDefault">Is subtitle default.</param>
|
||||||
|
/// <param name="isForced">Is subtitle forced.</param>
|
||||||
|
public SubtitleInfo(string path, bool isDefault, bool isForced)
|
||||||
|
{
|
||||||
|
Path = path;
|
||||||
|
IsDefault = isDefault;
|
||||||
|
IsForced = isForced;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the path.
|
/// Gets or sets the path.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -14,7 +28,7 @@ namespace Emby.Naming.Subtitles
|
||||||
/// Gets or sets the language.
|
/// Gets or sets the language.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The language.</value>
|
/// <value>The language.</value>
|
||||||
public string Language { get; set; }
|
public string? Language { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets a value indicating whether this instance is default.
|
/// Gets or sets a value indicating whether this instance is default.
|
||||||
|
|
|
@ -1,6 +1,3 @@
|
||||||
#nullable enable
|
|
||||||
#pragma warning disable CS1591
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
@ -8,20 +5,32 @@ using Emby.Naming.Common;
|
||||||
|
|
||||||
namespace Emby.Naming.Subtitles
|
namespace Emby.Naming.Subtitles
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Subtitle Parser class.
|
||||||
|
/// </summary>
|
||||||
public class SubtitleParser
|
public class SubtitleParser
|
||||||
{
|
{
|
||||||
private readonly NamingOptions _options;
|
private readonly NamingOptions _options;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="SubtitleParser"/> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="options"><see cref="NamingOptions"/> object containing SubtitleFileExtensions, SubtitleDefaultFlags, SubtitleForcedFlags and SubtitleFlagDelimiters.</param>
|
||||||
public SubtitleParser(NamingOptions options)
|
public SubtitleParser(NamingOptions options)
|
||||||
{
|
{
|
||||||
_options = options;
|
_options = options;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Parse file to determine if is subtitle and <see cref="SubtitleInfo"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="path">Path to file.</param>
|
||||||
|
/// <returns>Returns null or <see cref="SubtitleInfo"/> object if parsing is successful.</returns>
|
||||||
public SubtitleInfo? ParseFile(string path)
|
public SubtitleInfo? ParseFile(string path)
|
||||||
{
|
{
|
||||||
if (path.Length == 0)
|
if (path.Length == 0)
|
||||||
{
|
{
|
||||||
throw new ArgumentException("File path can't be empty.", nameof(path));
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
var extension = Path.GetExtension(path);
|
var extension = Path.GetExtension(path);
|
||||||
|
@ -31,12 +40,10 @@ namespace Emby.Naming.Subtitles
|
||||||
}
|
}
|
||||||
|
|
||||||
var flags = GetFlags(path);
|
var flags = GetFlags(path);
|
||||||
var info = new SubtitleInfo
|
var info = new SubtitleInfo(
|
||||||
{
|
path,
|
||||||
Path = path,
|
_options.SubtitleDefaultFlags.Any(i => flags.Contains(i, StringComparer.OrdinalIgnoreCase)),
|
||||||
IsDefault = _options.SubtitleDefaultFlags.Any(i => flags.Contains(i, StringComparer.OrdinalIgnoreCase)),
|
_options.SubtitleForcedFlags.Any(i => flags.Contains(i, StringComparer.OrdinalIgnoreCase)));
|
||||||
IsForced = _options.SubtitleForcedFlags.Any(i => flags.Contains(i, StringComparer.OrdinalIgnoreCase))
|
|
||||||
};
|
|
||||||
|
|
||||||
var parts = flags.Where(i => !_options.SubtitleDefaultFlags.Contains(i, StringComparer.OrdinalIgnoreCase)
|
var parts = flags.Where(i => !_options.SubtitleDefaultFlags.Contains(i, StringComparer.OrdinalIgnoreCase)
|
||||||
&& !_options.SubtitleForcedFlags.Contains(i, StringComparer.OrdinalIgnoreCase))
|
&& !_options.SubtitleForcedFlags.Contains(i, StringComparer.OrdinalIgnoreCase))
|
||||||
|
@ -53,7 +60,7 @@ namespace Emby.Naming.Subtitles
|
||||||
|
|
||||||
private string[] GetFlags(string path)
|
private string[] GetFlags(string path)
|
||||||
{
|
{
|
||||||
// Note: the tags need be be surrounded be either a space ( ), hyphen -, dot . or underscore _.
|
// Note: the tags need be surrounded be either a space ( ), hyphen -, dot . or underscore _.
|
||||||
|
|
||||||
var file = Path.GetFileName(path);
|
var file = Path.GetFileName(path);
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,19 @@
|
||||||
#pragma warning disable CS1591
|
|
||||||
|
|
||||||
namespace Emby.Naming.TV
|
namespace Emby.Naming.TV
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Holder object for Episode information.
|
||||||
|
/// </summary>
|
||||||
public class EpisodeInfo
|
public class EpisodeInfo
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="EpisodeInfo"/> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="path">Path to the file.</param>
|
||||||
|
public EpisodeInfo(string path)
|
||||||
|
{
|
||||||
|
Path = path;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the path.
|
/// Gets or sets the path.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -14,19 +24,19 @@ namespace Emby.Naming.TV
|
||||||
/// Gets or sets the container.
|
/// Gets or sets the container.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The container.</value>
|
/// <value>The container.</value>
|
||||||
public string Container { get; set; }
|
public string? Container { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the name of the series.
|
/// Gets or sets the name of the series.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The name of the series.</value>
|
/// <value>The name of the series.</value>
|
||||||
public string SeriesName { get; set; }
|
public string? SeriesName { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the format3 d.
|
/// Gets or sets the format3 d.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The format3 d.</value>
|
/// <value>The format3 d.</value>
|
||||||
public string Format3D { get; set; }
|
public string? Format3D { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets a value indicating whether [is3 d].
|
/// Gets or sets a value indicating whether [is3 d].
|
||||||
|
@ -44,20 +54,41 @@ namespace Emby.Naming.TV
|
||||||
/// Gets or sets the type of the stub.
|
/// Gets or sets the type of the stub.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The type of the stub.</value>
|
/// <value>The type of the stub.</value>
|
||||||
public string StubType { get; set; }
|
public string? StubType { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets optional season number.
|
||||||
|
/// </summary>
|
||||||
public int? SeasonNumber { get; set; }
|
public int? SeasonNumber { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets optional episode number.
|
||||||
|
/// </summary>
|
||||||
public int? EpisodeNumber { get; set; }
|
public int? EpisodeNumber { get; set; }
|
||||||
|
|
||||||
public int? EndingEpsiodeNumber { get; set; }
|
/// <summary>
|
||||||
|
/// Gets or sets optional ending episode number. For multi-episode files 1-13.
|
||||||
|
/// </summary>
|
||||||
|
public int? EndingEpisodeNumber { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets optional year of release.
|
||||||
|
/// </summary>
|
||||||
public int? Year { get; set; }
|
public int? Year { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets optional year of release.
|
||||||
|
/// </summary>
|
||||||
public int? Month { get; set; }
|
public int? Month { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets optional day of release.
|
||||||
|
/// </summary>
|
||||||
public int? Day { get; set; }
|
public int? Day { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether by date expression was used.
|
||||||
|
/// </summary>
|
||||||
public bool IsByDate { get; set; }
|
public bool IsByDate { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,3 @@
|
||||||
#pragma warning disable CS1591
|
|
||||||
#nullable enable
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
|
@ -9,15 +6,32 @@ using Emby.Naming.Common;
|
||||||
|
|
||||||
namespace Emby.Naming.TV
|
namespace Emby.Naming.TV
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Used to parse information about episode from path.
|
||||||
|
/// </summary>
|
||||||
public class EpisodePathParser
|
public class EpisodePathParser
|
||||||
{
|
{
|
||||||
private readonly NamingOptions _options;
|
private readonly NamingOptions _options;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="EpisodePathParser"/> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="options"><see cref="NamingOptions"/> object containing EpisodeExpressions and MultipleEpisodeExpressions.</param>
|
||||||
public EpisodePathParser(NamingOptions options)
|
public EpisodePathParser(NamingOptions options)
|
||||||
{
|
{
|
||||||
_options = options;
|
_options = options;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Parses information about episode from path.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="path">Path.</param>
|
||||||
|
/// <param name="isDirectory">Is path for a directory or file.</param>
|
||||||
|
/// <param name="isNamed">Do we want to use IsNamed expressions.</param>
|
||||||
|
/// <param name="isOptimistic">Do we want to use Optimistic expressions.</param>
|
||||||
|
/// <param name="supportsAbsoluteNumbers">Do we want to use expressions supporting absolute episode numbers.</param>
|
||||||
|
/// <param name="fillExtendedInfo">Should we attempt to retrieve extended information.</param>
|
||||||
|
/// <returns>Returns <see cref="EpisodePathParserResult"/> object.</returns>
|
||||||
public EpisodePathParserResult Parse(
|
public EpisodePathParserResult Parse(
|
||||||
string path,
|
string path,
|
||||||
bool isDirectory,
|
bool isDirectory,
|
||||||
|
@ -146,7 +160,7 @@ namespace Emby.Naming.TV
|
||||||
{
|
{
|
||||||
if (int.TryParse(endingNumberGroup.Value, NumberStyles.Integer, CultureInfo.InvariantCulture, out num))
|
if (int.TryParse(endingNumberGroup.Value, NumberStyles.Integer, CultureInfo.InvariantCulture, out num))
|
||||||
{
|
{
|
||||||
result.EndingEpsiodeNumber = num;
|
result.EndingEpisodeNumber = num;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -186,7 +200,7 @@ namespace Emby.Naming.TV
|
||||||
|
|
||||||
private void FillAdditional(string path, EpisodePathParserResult info)
|
private void FillAdditional(string path, EpisodePathParserResult info)
|
||||||
{
|
{
|
||||||
var expressions = _options.MultipleEpisodeExpressions.ToList();
|
var expressions = _options.MultipleEpisodeExpressions.Where(i => i.IsNamed).ToList();
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(info.SeriesName))
|
if (string.IsNullOrEmpty(info.SeriesName))
|
||||||
{
|
{
|
||||||
|
@ -200,11 +214,6 @@ namespace Emby.Naming.TV
|
||||||
{
|
{
|
||||||
foreach (var i in expressions)
|
foreach (var i in expressions)
|
||||||
{
|
{
|
||||||
if (!i.IsNamed)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
var result = Parse(path, i);
|
var result = Parse(path, i);
|
||||||
|
|
||||||
if (!result.Success)
|
if (!result.Success)
|
||||||
|
@ -217,13 +226,13 @@ namespace Emby.Naming.TV
|
||||||
info.SeriesName = result.SeriesName;
|
info.SeriesName = result.SeriesName;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!info.EndingEpsiodeNumber.HasValue && info.EpisodeNumber.HasValue)
|
if (!info.EndingEpisodeNumber.HasValue && info.EpisodeNumber.HasValue)
|
||||||
{
|
{
|
||||||
info.EndingEpsiodeNumber = result.EndingEpsiodeNumber;
|
info.EndingEpisodeNumber = result.EndingEpisodeNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(info.SeriesName)
|
if (!string.IsNullOrEmpty(info.SeriesName)
|
||||||
&& (!info.EpisodeNumber.HasValue || info.EndingEpsiodeNumber.HasValue))
|
&& (!info.EpisodeNumber.HasValue || info.EndingEpisodeNumber.HasValue))
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,25 +1,54 @@
|
||||||
#pragma warning disable CS1591
|
|
||||||
|
|
||||||
namespace Emby.Naming.TV
|
namespace Emby.Naming.TV
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Holder object for <see cref="EpisodePathParser"/> result.
|
||||||
|
/// </summary>
|
||||||
public class EpisodePathParserResult
|
public class EpisodePathParserResult
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets optional season number.
|
||||||
|
/// </summary>
|
||||||
public int? SeasonNumber { get; set; }
|
public int? SeasonNumber { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets optional episode number.
|
||||||
|
/// </summary>
|
||||||
public int? EpisodeNumber { get; set; }
|
public int? EpisodeNumber { get; set; }
|
||||||
|
|
||||||
public int? EndingEpsiodeNumber { get; set; }
|
/// <summary>
|
||||||
|
/// Gets or sets optional ending episode number. For multi-episode files 1-13.
|
||||||
|
/// </summary>
|
||||||
|
public int? EndingEpisodeNumber { get; set; }
|
||||||
|
|
||||||
public string SeriesName { get; set; }
|
/// <summary>
|
||||||
|
/// Gets or sets the name of the series.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The name of the series.</value>
|
||||||
|
public string? SeriesName { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether parsing was successful.
|
||||||
|
/// </summary>
|
||||||
public bool Success { get; set; }
|
public bool Success { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether by date expression was used.
|
||||||
|
/// </summary>
|
||||||
public bool IsByDate { get; set; }
|
public bool IsByDate { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets optional year of release.
|
||||||
|
/// </summary>
|
||||||
public int? Year { get; set; }
|
public int? Year { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets optional year of release.
|
||||||
|
/// </summary>
|
||||||
public int? Month { get; set; }
|
public int? Month { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets optional day of release.
|
||||||
|
/// </summary>
|
||||||
public int? Day { get; set; }
|
public int? Day { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,3 @@
|
||||||
#pragma warning disable CS1591
|
|
||||||
#nullable enable
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
@ -9,15 +6,32 @@ using Emby.Naming.Video;
|
||||||
|
|
||||||
namespace Emby.Naming.TV
|
namespace Emby.Naming.TV
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Used to resolve information about episode from path.
|
||||||
|
/// </summary>
|
||||||
public class EpisodeResolver
|
public class EpisodeResolver
|
||||||
{
|
{
|
||||||
private readonly NamingOptions _options;
|
private readonly NamingOptions _options;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="EpisodeResolver"/> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="options"><see cref="NamingOptions"/> object containing VideoFileExtensions and passed to <see cref="StubResolver"/>, <see cref="FlagParser"/>, <see cref="Format3DParser"/> and <see cref="EpisodePathParser"/>.</param>
|
||||||
public EpisodeResolver(NamingOptions options)
|
public EpisodeResolver(NamingOptions options)
|
||||||
{
|
{
|
||||||
_options = options;
|
_options = options;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Resolve information about episode from path.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="path">Path.</param>
|
||||||
|
/// <param name="isDirectory">Is path for a directory or file.</param>
|
||||||
|
/// <param name="isNamed">Do we want to use IsNamed expressions.</param>
|
||||||
|
/// <param name="isOptimistic">Do we want to use Optimistic expressions.</param>
|
||||||
|
/// <param name="supportsAbsoluteNumbers">Do we want to use expressions supporting absolute episode numbers.</param>
|
||||||
|
/// <param name="fillExtendedInfo">Should we attempt to retrieve extended information.</param>
|
||||||
|
/// <returns>Returns null or <see cref="EpisodeInfo"/> object if successful.</returns>
|
||||||
public EpisodeInfo? Resolve(
|
public EpisodeInfo? Resolve(
|
||||||
string path,
|
string path,
|
||||||
bool isDirectory,
|
bool isDirectory,
|
||||||
|
@ -54,12 +68,11 @@ namespace Emby.Naming.TV
|
||||||
var parsingResult = new EpisodePathParser(_options)
|
var parsingResult = new EpisodePathParser(_options)
|
||||||
.Parse(path, isDirectory, isNamed, isOptimistic, supportsAbsoluteNumbers, fillExtendedInfo);
|
.Parse(path, isDirectory, isNamed, isOptimistic, supportsAbsoluteNumbers, fillExtendedInfo);
|
||||||
|
|
||||||
return new EpisodeInfo
|
return new EpisodeInfo(path)
|
||||||
{
|
{
|
||||||
Path = path,
|
|
||||||
Container = container,
|
Container = container,
|
||||||
IsStub = isStub,
|
IsStub = isStub,
|
||||||
EndingEpsiodeNumber = parsingResult.EndingEpsiodeNumber,
|
EndingEpisodeNumber = parsingResult.EndingEpisodeNumber,
|
||||||
EpisodeNumber = parsingResult.EpisodeNumber,
|
EpisodeNumber = parsingResult.EpisodeNumber,
|
||||||
SeasonNumber = parsingResult.SeasonNumber,
|
SeasonNumber = parsingResult.SeasonNumber,
|
||||||
SeriesName = parsingResult.SeriesName,
|
SeriesName = parsingResult.SeriesName,
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
#pragma warning disable CS1591
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
|
||||||
namespace Emby.Naming.TV
|
namespace Emby.Naming.TV
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Class to parse season paths.
|
||||||
|
/// </summary>
|
||||||
public static class SeasonPathParser
|
public static class SeasonPathParser
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -23,6 +24,13 @@ namespace Emby.Naming.TV
|
||||||
"stagione"
|
"stagione"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Attempts to parse season number from path.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="path">Path to season.</param>
|
||||||
|
/// <param name="supportSpecialAliases">Support special aliases when parsing.</param>
|
||||||
|
/// <param name="supportNumericSeasonFolders">Support numeric season folders when parsing.</param>
|
||||||
|
/// <returns>Returns <see cref="SeasonPathParserResult"/> object.</returns>
|
||||||
public static SeasonPathParserResult Parse(string path, bool supportSpecialAliases, bool supportNumericSeasonFolders)
|
public static SeasonPathParserResult Parse(string path, bool supportSpecialAliases, bool supportNumericSeasonFolders)
|
||||||
{
|
{
|
||||||
var result = new SeasonPathParserResult();
|
var result = new SeasonPathParserResult();
|
||||||
|
@ -101,9 +109,9 @@ namespace Emby.Naming.TV
|
||||||
}
|
}
|
||||||
|
|
||||||
var parts = filename.Split(new[] { '.', '_', ' ', '-' }, StringSplitOptions.RemoveEmptyEntries);
|
var parts = filename.Split(new[] { '.', '_', ' ', '-' }, StringSplitOptions.RemoveEmptyEntries);
|
||||||
for (int i = 0; i < parts.Length; i++)
|
foreach (var part in parts)
|
||||||
{
|
{
|
||||||
if (TryGetSeasonNumberFromPart(parts[i], out int seasonNumber))
|
if (TryGetSeasonNumberFromPart(part, out int seasonNumber))
|
||||||
{
|
{
|
||||||
return (seasonNumber, true);
|
return (seasonNumber, true);
|
||||||
}
|
}
|
||||||
|
@ -139,7 +147,7 @@ namespace Emby.Naming.TV
|
||||||
var numericStart = -1;
|
var numericStart = -1;
|
||||||
var length = 0;
|
var length = 0;
|
||||||
|
|
||||||
var hasOpenParenth = false;
|
var hasOpenParenthesis = false;
|
||||||
var isSeasonFolder = true;
|
var isSeasonFolder = true;
|
||||||
|
|
||||||
// Find out where the numbers start, and then keep going until they end
|
// Find out where the numbers start, and then keep going until they end
|
||||||
|
@ -147,7 +155,7 @@ namespace Emby.Naming.TV
|
||||||
{
|
{
|
||||||
if (char.IsNumber(path[i]))
|
if (char.IsNumber(path[i]))
|
||||||
{
|
{
|
||||||
if (!hasOpenParenth)
|
if (!hasOpenParenthesis)
|
||||||
{
|
{
|
||||||
if (numericStart == -1)
|
if (numericStart == -1)
|
||||||
{
|
{
|
||||||
|
@ -167,11 +175,11 @@ namespace Emby.Naming.TV
|
||||||
var currentChar = path[i];
|
var currentChar = path[i];
|
||||||
if (currentChar == '(')
|
if (currentChar == '(')
|
||||||
{
|
{
|
||||||
hasOpenParenth = true;
|
hasOpenParenthesis = true;
|
||||||
}
|
}
|
||||||
else if (currentChar == ')')
|
else if (currentChar == ')')
|
||||||
{
|
{
|
||||||
hasOpenParenth = false;
|
hasOpenParenthesis = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
#pragma warning disable CS1591
|
|
||||||
|
|
||||||
namespace Emby.Naming.TV
|
namespace Emby.Naming.TV
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Data object to pass result of <see cref="SeasonPathParser"/>.
|
||||||
|
/// </summary>
|
||||||
public class SeasonPathParserResult
|
public class SeasonPathParserResult
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -16,6 +17,10 @@ namespace Emby.Naming.TV
|
||||||
/// <value><c>true</c> if success; otherwise, <c>false</c>.</value>
|
/// <value><c>true</c> if success; otherwise, <c>false</c>.</value>
|
||||||
public bool Success { get; set; }
|
public bool Success { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether "Is season folder".
|
||||||
|
/// Seems redundant and barely used.
|
||||||
|
/// </summary>
|
||||||
public bool IsSeasonFolder { get; set; }
|
public bool IsSeasonFolder { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,3 @@
|
||||||
#pragma warning disable CS1591
|
|
||||||
#nullable enable
|
|
||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
|
@ -12,9 +9,20 @@ namespace Emby.Naming.Video
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static class CleanDateTimeParser
|
public static class CleanDateTimeParser
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Attempts to clean the name.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name">Name of video.</param>
|
||||||
|
/// <param name="cleanDateTimeRegexes">Optional list of regexes to clean the name.</param>
|
||||||
|
/// <returns>Returns <see cref="CleanDateTimeResult"/> object.</returns>
|
||||||
public static CleanDateTimeResult Clean(string name, IReadOnlyList<Regex> cleanDateTimeRegexes)
|
public static CleanDateTimeResult Clean(string name, IReadOnlyList<Regex> cleanDateTimeRegexes)
|
||||||
{
|
{
|
||||||
CleanDateTimeResult result = new CleanDateTimeResult(name);
|
CleanDateTimeResult result = new CleanDateTimeResult(name);
|
||||||
|
if (string.IsNullOrEmpty(name))
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
var len = cleanDateTimeRegexes.Count;
|
var len = cleanDateTimeRegexes.Count;
|
||||||
for (int i = 0; i < len; i++)
|
for (int i = 0; i < len; i++)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,22 +1,21 @@
|
||||||
#pragma warning disable CS1591
|
|
||||||
#nullable enable
|
|
||||||
|
|
||||||
namespace Emby.Naming.Video
|
namespace Emby.Naming.Video
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Holder structure for name and year.
|
||||||
|
/// </summary>
|
||||||
public readonly struct CleanDateTimeResult
|
public readonly struct CleanDateTimeResult
|
||||||
{
|
{
|
||||||
public CleanDateTimeResult(string name, int? year)
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="CleanDateTimeResult"/> struct.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name">Name of video.</param>
|
||||||
|
/// <param name="year">Year of release.</param>
|
||||||
|
public CleanDateTimeResult(string name, int? year = null)
|
||||||
{
|
{
|
||||||
Name = name;
|
Name = name;
|
||||||
Year = year;
|
Year = year;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CleanDateTimeResult(string name)
|
|
||||||
{
|
|
||||||
Name = name;
|
|
||||||
Year = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the name.
|
/// Gets the name.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -1,6 +1,3 @@
|
||||||
#pragma warning disable CS1591
|
|
||||||
#nullable enable
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
|
@ -12,6 +9,13 @@ namespace Emby.Naming.Video
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static class CleanStringParser
|
public static class CleanStringParser
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Attempts to extract clean name with regular expressions.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name">Name of file.</param>
|
||||||
|
/// <param name="expressions">List of regex to parse name and year from.</param>
|
||||||
|
/// <param name="newName">Parsing result string.</param>
|
||||||
|
/// <returns>True if parsing was successful.</returns>
|
||||||
public static bool TryClean(string name, IReadOnlyList<Regex> expressions, out ReadOnlySpan<char> newName)
|
public static bool TryClean(string name, IReadOnlyList<Regex> expressions, out ReadOnlySpan<char> newName)
|
||||||
{
|
{
|
||||||
var len = expressions.Count;
|
var len = expressions.Count;
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
#pragma warning disable CS1591
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
@ -9,15 +7,27 @@ using Emby.Naming.Common;
|
||||||
|
|
||||||
namespace Emby.Naming.Video
|
namespace Emby.Naming.Video
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Resolve if file is extra for video.
|
||||||
|
/// </summary>
|
||||||
public class ExtraResolver
|
public class ExtraResolver
|
||||||
{
|
{
|
||||||
private readonly NamingOptions _options;
|
private readonly NamingOptions _options;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="ExtraResolver"/> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="options"><see cref="NamingOptions"/> object containing VideoExtraRules and passed to <see cref="AudioFileParser"/> and <see cref="VideoResolver"/>.</param>
|
||||||
public ExtraResolver(NamingOptions options)
|
public ExtraResolver(NamingOptions options)
|
||||||
{
|
{
|
||||||
_options = options;
|
_options = options;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Attempts to resolve if file is extra.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="path">Path to file.</param>
|
||||||
|
/// <returns>Returns <see cref="ExtraResult"/> object.</returns>
|
||||||
public ExtraResult GetExtraInfo(string path)
|
public ExtraResult GetExtraInfo(string path)
|
||||||
{
|
{
|
||||||
return _options.VideoExtraRules
|
return _options.VideoExtraRules
|
||||||
|
@ -43,10 +53,6 @@ namespace Emby.Naming.Video
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (rule.RuleType == ExtraRuleType.Filename)
|
if (rule.RuleType == ExtraRuleType.Filename)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
#pragma warning disable CS1591
|
|
||||||
|
|
||||||
using MediaBrowser.Model.Entities;
|
using MediaBrowser.Model.Entities;
|
||||||
|
|
||||||
namespace Emby.Naming.Video
|
namespace Emby.Naming.Video
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Holder object for passing results from ExtraResolver.
|
||||||
|
/// </summary>
|
||||||
public class ExtraResult
|
public class ExtraResult
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -16,6 +17,6 @@ namespace Emby.Naming.Video
|
||||||
/// Gets or sets the rule.
|
/// Gets or sets the rule.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The rule.</value>
|
/// <value>The rule.</value>
|
||||||
public ExtraRule Rule { get; set; }
|
public ExtraRule? Rule { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
#pragma warning disable CS1591
|
|
||||||
|
|
||||||
using MediaBrowser.Model.Entities;
|
using MediaBrowser.Model.Entities;
|
||||||
using MediaType = Emby.Naming.Common.MediaType;
|
using MediaType = Emby.Naming.Common.MediaType;
|
||||||
|
|
||||||
|
@ -10,6 +8,21 @@ namespace Emby.Naming.Video
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class ExtraRule
|
public class ExtraRule
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="ExtraRule"/> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="extraType">Type of extra.</param>
|
||||||
|
/// <param name="ruleType">Type of rule.</param>
|
||||||
|
/// <param name="token">Token.</param>
|
||||||
|
/// <param name="mediaType">Media type.</param>
|
||||||
|
public ExtraRule(ExtraType extraType, ExtraRuleType ruleType, string token, MediaType mediaType)
|
||||||
|
{
|
||||||
|
Token = token;
|
||||||
|
ExtraType = extraType;
|
||||||
|
RuleType = ruleType;
|
||||||
|
MediaType = mediaType;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the token to use for matching against the file path.
|
/// Gets or sets the token to use for matching against the file path.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
#pragma warning disable CS1591
|
|
||||||
|
|
||||||
namespace Emby.Naming.Video
|
namespace Emby.Naming.Video
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Extra rules type to determine against what <see cref="ExtraRule.Token"/> should be matched.
|
||||||
|
/// </summary>
|
||||||
public enum ExtraRuleType
|
public enum ExtraRuleType
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -22,6 +23,6 @@ namespace Emby.Naming.Video
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Match <see cref="ExtraRule.Token"/> against the name of the directory containing the file.
|
/// Match <see cref="ExtraRule.Token"/> against the name of the directory containing the file.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
DirectoryName = 3,
|
DirectoryName = 3
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,24 +1,43 @@
|
||||||
#pragma warning disable CS1591
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
namespace Emby.Naming.Video
|
namespace Emby.Naming.Video
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Object holding list of files paths with additional information.
|
||||||
|
/// </summary>
|
||||||
public class FileStack
|
public class FileStack
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="FileStack"/> class.
|
||||||
|
/// </summary>
|
||||||
public FileStack()
|
public FileStack()
|
||||||
{
|
{
|
||||||
Files = new List<string>();
|
Files = new List<string>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Name { get; set; }
|
/// <summary>
|
||||||
|
/// Gets or sets name of file stack.
|
||||||
|
/// </summary>
|
||||||
|
public string Name { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets list of paths in stack.
|
||||||
|
/// </summary>
|
||||||
public List<string> Files { get; set; }
|
public List<string> Files { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether stack is directory stack.
|
||||||
|
/// </summary>
|
||||||
public bool IsDirectoryStack { get; set; }
|
public bool IsDirectoryStack { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Helper function to determine if path is in the stack.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="file">Path of desired file.</param>
|
||||||
|
/// <param name="isDirectory">Requested type of stack.</param>
|
||||||
|
/// <returns>True if file is in the stack.</returns>
|
||||||
public bool ContainsFile(string file, bool isDirectory)
|
public bool ContainsFile(string file, bool isDirectory)
|
||||||
{
|
{
|
||||||
if (IsDirectoryStack == isDirectory)
|
if (IsDirectoryStack == isDirectory)
|
||||||
|
|
|
@ -1,37 +1,53 @@
|
||||||
#pragma warning disable CS1591
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using Emby.Naming.Common;
|
using Emby.Naming.Common;
|
||||||
|
|
||||||
namespace Emby.Naming.Video
|
namespace Emby.Naming.Video
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Parses list of flags from filename based on delimiters.
|
||||||
|
/// </summary>
|
||||||
public class FlagParser
|
public class FlagParser
|
||||||
{
|
{
|
||||||
private readonly NamingOptions _options;
|
private readonly NamingOptions _options;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="FlagParser"/> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="options"><see cref="NamingOptions"/> object containing VideoFlagDelimiters.</param>
|
||||||
public FlagParser(NamingOptions options)
|
public FlagParser(NamingOptions options)
|
||||||
{
|
{
|
||||||
_options = options;
|
_options = options;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Calls GetFlags function with _options.VideoFlagDelimiters parameter.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="path">Path to file.</param>
|
||||||
|
/// <returns>List of found flags.</returns>
|
||||||
public string[] GetFlags(string path)
|
public string[] GetFlags(string path)
|
||||||
{
|
{
|
||||||
return GetFlags(path, _options.VideoFlagDelimiters);
|
return GetFlags(path, _options.VideoFlagDelimiters);
|
||||||
}
|
}
|
||||||
|
|
||||||
public string[] GetFlags(string path, char[] delimeters)
|
/// <summary>
|
||||||
|
/// Parses flags from filename based on delimiters.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="path">Path to file.</param>
|
||||||
|
/// <param name="delimiters">Delimiters used to extract flags.</param>
|
||||||
|
/// <returns>List of found flags.</returns>
|
||||||
|
public string[] GetFlags(string path, char[] delimiters)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(path))
|
if (string.IsNullOrEmpty(path))
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException(nameof(path));
|
return Array.Empty<string>();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Note: the tags need be be surrounded be either a space ( ), hyphen -, dot . or underscore _.
|
// Note: the tags need be be surrounded be either a space ( ), hyphen -, dot . or underscore _.
|
||||||
|
|
||||||
var file = Path.GetFileName(path);
|
var file = Path.GetFileName(path);
|
||||||
|
|
||||||
return file.Split(delimeters, StringSplitOptions.RemoveEmptyEntries);
|
return file.Split(delimiters, StringSplitOptions.RemoveEmptyEntries);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,28 +1,38 @@
|
||||||
#pragma warning disable CS1591
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Emby.Naming.Common;
|
using Emby.Naming.Common;
|
||||||
|
|
||||||
namespace Emby.Naming.Video
|
namespace Emby.Naming.Video
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Parste 3D format related flags.
|
||||||
|
/// </summary>
|
||||||
public class Format3DParser
|
public class Format3DParser
|
||||||
{
|
{
|
||||||
private readonly NamingOptions _options;
|
private readonly NamingOptions _options;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="Format3DParser"/> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="options"><see cref="NamingOptions"/> object containing VideoFlagDelimiters and passes options to <see cref="FlagParser"/>.</param>
|
||||||
public Format3DParser(NamingOptions options)
|
public Format3DParser(NamingOptions options)
|
||||||
{
|
{
|
||||||
_options = options;
|
_options = options;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Parse 3D format related flags.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="path">Path to file.</param>
|
||||||
|
/// <returns>Returns <see cref="Format3DResult"/> object.</returns>
|
||||||
public Format3DResult Parse(string path)
|
public Format3DResult Parse(string path)
|
||||||
{
|
{
|
||||||
int oldLen = _options.VideoFlagDelimiters.Length;
|
int oldLen = _options.VideoFlagDelimiters.Length;
|
||||||
var delimeters = new char[oldLen + 1];
|
var delimiters = new char[oldLen + 1];
|
||||||
_options.VideoFlagDelimiters.CopyTo(delimeters, 0);
|
_options.VideoFlagDelimiters.CopyTo(delimiters, 0);
|
||||||
delimeters[oldLen] = ' ';
|
delimiters[oldLen] = ' ';
|
||||||
|
|
||||||
return Parse(new FlagParser(_options).GetFlags(path, delimeters));
|
return Parse(new FlagParser(_options).GetFlags(path, delimiters));
|
||||||
}
|
}
|
||||||
|
|
||||||
internal Format3DResult Parse(string[] videoFlags)
|
internal Format3DResult Parse(string[] videoFlags)
|
||||||
|
@ -44,7 +54,7 @@ namespace Emby.Naming.Video
|
||||||
{
|
{
|
||||||
var result = new Format3DResult();
|
var result = new Format3DResult();
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(rule.PreceedingToken))
|
if (string.IsNullOrEmpty(rule.PrecedingToken))
|
||||||
{
|
{
|
||||||
result.Format3D = new[] { rule.Token }.FirstOrDefault(i => videoFlags.Contains(i, StringComparer.OrdinalIgnoreCase));
|
result.Format3D = new[] { rule.Token }.FirstOrDefault(i => videoFlags.Contains(i, StringComparer.OrdinalIgnoreCase));
|
||||||
result.Is3D = !string.IsNullOrEmpty(result.Format3D);
|
result.Is3D = !string.IsNullOrEmpty(result.Format3D);
|
||||||
|
@ -57,13 +67,13 @@ namespace Emby.Naming.Video
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var foundPrefix = false;
|
var foundPrefix = false;
|
||||||
string format = null;
|
string? format = null;
|
||||||
|
|
||||||
foreach (var flag in videoFlags)
|
foreach (var flag in videoFlags)
|
||||||
{
|
{
|
||||||
if (foundPrefix)
|
if (foundPrefix)
|
||||||
{
|
{
|
||||||
result.Tokens.Add(rule.PreceedingToken);
|
result.Tokens.Add(rule.PrecedingToken);
|
||||||
|
|
||||||
if (string.Equals(rule.Token, flag, StringComparison.OrdinalIgnoreCase))
|
if (string.Equals(rule.Token, flag, StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
|
@ -74,7 +84,7 @@ namespace Emby.Naming.Video
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
foundPrefix = string.Equals(flag, rule.PreceedingToken, StringComparison.OrdinalIgnoreCase);
|
foundPrefix = string.Equals(flag, rule.PrecedingToken, StringComparison.OrdinalIgnoreCase);
|
||||||
}
|
}
|
||||||
|
|
||||||
result.Is3D = foundPrefix && !string.IsNullOrEmpty(format);
|
result.Is3D = foundPrefix && !string.IsNullOrEmpty(format);
|
||||||
|
|
|
@ -1,11 +1,15 @@
|
||||||
#pragma warning disable CS1591
|
|
||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Emby.Naming.Video
|
namespace Emby.Naming.Video
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Helper object to return data from <see cref="Format3DParser"/>.
|
||||||
|
/// </summary>
|
||||||
public class Format3DResult
|
public class Format3DResult
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="Format3DResult"/> class.
|
||||||
|
/// </summary>
|
||||||
public Format3DResult()
|
public Format3DResult()
|
||||||
{
|
{
|
||||||
Tokens = new List<string>();
|
Tokens = new List<string>();
|
||||||
|
@ -21,7 +25,7 @@ namespace Emby.Naming.Video
|
||||||
/// Gets or sets the format3 d.
|
/// Gets or sets the format3 d.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The format3 d.</value>
|
/// <value>The format3 d.</value>
|
||||||
public string Format3D { get; set; }
|
public string? Format3D { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the tokens.
|
/// Gets or sets the tokens.
|
||||||
|
|
|
@ -1,9 +1,21 @@
|
||||||
#pragma warning disable CS1591
|
|
||||||
|
|
||||||
namespace Emby.Naming.Video
|
namespace Emby.Naming.Video
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Data holder class for 3D format rule.
|
||||||
|
/// </summary>
|
||||||
public class Format3DRule
|
public class Format3DRule
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="Format3DRule"/> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="token">Token.</param>
|
||||||
|
/// <param name="precedingToken">Token present before current token.</param>
|
||||||
|
public Format3DRule(string token, string? precedingToken = null)
|
||||||
|
{
|
||||||
|
Token = token;
|
||||||
|
PrecedingToken = precedingToken;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the token.
|
/// Gets or sets the token.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -11,9 +23,9 @@ namespace Emby.Naming.Video
|
||||||
public string Token { get; set; }
|
public string Token { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the preceeding token.
|
/// Gets or sets the preceding token.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The preceeding token.</value>
|
/// <value>The preceding token.</value>
|
||||||
public string PreceedingToken { get; set; }
|
public string? PrecedingToken { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,58 +1,88 @@
|
||||||
#pragma warning disable CS1591
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
|
using Emby.Naming.AudioBook;
|
||||||
using Emby.Naming.Common;
|
using Emby.Naming.Common;
|
||||||
using MediaBrowser.Model.IO;
|
using MediaBrowser.Model.IO;
|
||||||
|
|
||||||
namespace Emby.Naming.Video
|
namespace Emby.Naming.Video
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Resolve <see cref="FileStack"/> from list of paths.
|
||||||
|
/// </summary>
|
||||||
public class StackResolver
|
public class StackResolver
|
||||||
{
|
{
|
||||||
private readonly NamingOptions _options;
|
private readonly NamingOptions _options;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="StackResolver"/> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="options"><see cref="NamingOptions"/> object containing VideoFileStackingRegexes and passes options to <see cref="VideoResolver"/>.</param>
|
||||||
public StackResolver(NamingOptions options)
|
public StackResolver(NamingOptions options)
|
||||||
{
|
{
|
||||||
_options = options;
|
_options = options;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Resolves only directories from paths.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="files">List of paths.</param>
|
||||||
|
/// <returns>Enumerable <see cref="FileStack"/> of directories.</returns>
|
||||||
public IEnumerable<FileStack> ResolveDirectories(IEnumerable<string> files)
|
public IEnumerable<FileStack> ResolveDirectories(IEnumerable<string> files)
|
||||||
{
|
{
|
||||||
return Resolve(files.Select(i => new FileSystemMetadata { FullName = i, IsDirectory = true }));
|
return Resolve(files.Select(i => new FileSystemMetadata { FullName = i, IsDirectory = true }));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Resolves only files from paths.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="files">List of paths.</param>
|
||||||
|
/// <returns>Enumerable <see cref="FileStack"/> of files.</returns>
|
||||||
public IEnumerable<FileStack> ResolveFiles(IEnumerable<string> files)
|
public IEnumerable<FileStack> ResolveFiles(IEnumerable<string> files)
|
||||||
{
|
{
|
||||||
return Resolve(files.Select(i => new FileSystemMetadata { FullName = i, IsDirectory = false }));
|
return Resolve(files.Select(i => new FileSystemMetadata { FullName = i, IsDirectory = false }));
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<FileStack> ResolveAudioBooks(IEnumerable<FileSystemMetadata> files)
|
/// <summary>
|
||||||
|
/// Resolves audiobooks from paths.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="files">List of paths.</param>
|
||||||
|
/// <returns>Enumerable <see cref="FileStack"/> of directories.</returns>
|
||||||
|
public IEnumerable<FileStack> ResolveAudioBooks(IEnumerable<AudioBookFileInfo> files)
|
||||||
{
|
{
|
||||||
var groupedDirectoryFiles = files.GroupBy(file =>
|
var groupedDirectoryFiles = files.GroupBy(file => Path.GetDirectoryName(file.Path));
|
||||||
file.IsDirectory
|
|
||||||
? file.FullName
|
|
||||||
: Path.GetDirectoryName(file.FullName));
|
|
||||||
|
|
||||||
foreach (var directory in groupedDirectoryFiles)
|
foreach (var directory in groupedDirectoryFiles)
|
||||||
{
|
{
|
||||||
var stack = new FileStack { Name = Path.GetFileName(directory.Key), IsDirectoryStack = false };
|
if (string.IsNullOrEmpty(directory.Key))
|
||||||
foreach (var file in directory)
|
|
||||||
{
|
{
|
||||||
if (file.IsDirectory)
|
foreach (var file in directory)
|
||||||
{
|
{
|
||||||
continue;
|
var stack = new FileStack { Name = Path.GetFileNameWithoutExtension(file.Path), IsDirectoryStack = false };
|
||||||
|
stack.Files.Add(file.Path);
|
||||||
|
yield return stack;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var stack = new FileStack { Name = Path.GetFileName(directory.Key), IsDirectoryStack = false };
|
||||||
|
foreach (var file in directory)
|
||||||
|
{
|
||||||
|
stack.Files.Add(file.Path);
|
||||||
}
|
}
|
||||||
|
|
||||||
stack.Files.Add(file.FullName);
|
yield return stack;
|
||||||
}
|
}
|
||||||
|
|
||||||
yield return stack;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Resolves videos from paths.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="files">List of paths.</param>
|
||||||
|
/// <returns>Enumerable <see cref="FileStack"/> of videos.</returns>
|
||||||
public IEnumerable<FileStack> Resolve(IEnumerable<FileSystemMetadata> files)
|
public IEnumerable<FileStack> Resolve(IEnumerable<FileSystemMetadata> files)
|
||||||
{
|
{
|
||||||
var resolver = new VideoResolver(_options);
|
var resolver = new VideoResolver(_options);
|
||||||
|
@ -81,10 +111,10 @@ namespace Emby.Naming.Video
|
||||||
|
|
||||||
if (match1.Success)
|
if (match1.Success)
|
||||||
{
|
{
|
||||||
var title1 = match1.Groups[1].Value;
|
var title1 = match1.Groups["title"].Value;
|
||||||
var volume1 = match1.Groups[2].Value;
|
var volume1 = match1.Groups["volume"].Value;
|
||||||
var ignore1 = match1.Groups[3].Value;
|
var ignore1 = match1.Groups["ignore"].Value;
|
||||||
var extension1 = match1.Groups[4].Value;
|
var extension1 = match1.Groups["extension"].Value;
|
||||||
|
|
||||||
var j = i + 1;
|
var j = i + 1;
|
||||||
while (j < list.Count)
|
while (j < list.Count)
|
||||||
|
|
|
@ -1,6 +1,3 @@
|
||||||
#pragma warning disable CS1591
|
|
||||||
#nullable enable
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
@ -8,13 +5,23 @@ using Emby.Naming.Common;
|
||||||
|
|
||||||
namespace Emby.Naming.Video
|
namespace Emby.Naming.Video
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Resolve if file is stub (.disc).
|
||||||
|
/// </summary>
|
||||||
public static class StubResolver
|
public static class StubResolver
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Tries to resolve if file is stub (.disc).
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="path">Path to file.</param>
|
||||||
|
/// <param name="options">NamingOptions containing StubFileExtensions and StubTypes.</param>
|
||||||
|
/// <param name="stubType">Stub type.</param>
|
||||||
|
/// <returns>True if file is a stub.</returns>
|
||||||
public static bool TryResolveFile(string path, NamingOptions options, out string? stubType)
|
public static bool TryResolveFile(string path, NamingOptions options, out string? stubType)
|
||||||
{
|
{
|
||||||
stubType = default;
|
stubType = default;
|
||||||
|
|
||||||
if (path == null)
|
if (string.IsNullOrEmpty(path))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,19 +0,0 @@
|
||||||
#pragma warning disable CS1591
|
|
||||||
|
|
||||||
namespace Emby.Naming.Video
|
|
||||||
{
|
|
||||||
public struct StubResult
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets a value indicating whether this instance is stub.
|
|
||||||
/// </summary>
|
|
||||||
/// <value><c>true</c> if this instance is stub; otherwise, <c>false</c>.</value>
|
|
||||||
public bool IsStub { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the type of the stub.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The type of the stub.</value>
|
|
||||||
public string StubType { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,9 +1,21 @@
|
||||||
#pragma warning disable CS1591
|
|
||||||
|
|
||||||
namespace Emby.Naming.Video
|
namespace Emby.Naming.Video
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Data class holding information about Stub type rule.
|
||||||
|
/// </summary>
|
||||||
public class StubTypeRule
|
public class StubTypeRule
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="StubTypeRule"/> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="token">Token.</param>
|
||||||
|
/// <param name="stubType">Stub type.</param>
|
||||||
|
public StubTypeRule(string token, string stubType)
|
||||||
|
{
|
||||||
|
Token = token;
|
||||||
|
StubType = stubType;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the token.
|
/// Gets or sets the token.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -7,6 +7,35 @@ namespace Emby.Naming.Video
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class VideoFileInfo
|
public class VideoFileInfo
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="VideoFileInfo"/> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name">Name of file.</param>
|
||||||
|
/// <param name="path">Path to the file.</param>
|
||||||
|
/// <param name="container">Container type.</param>
|
||||||
|
/// <param name="year">Year of release.</param>
|
||||||
|
/// <param name="extraType">Extra type.</param>
|
||||||
|
/// <param name="extraRule">Extra rule.</param>
|
||||||
|
/// <param name="format3D">Format 3D.</param>
|
||||||
|
/// <param name="is3D">Is 3D.</param>
|
||||||
|
/// <param name="isStub">Is Stub.</param>
|
||||||
|
/// <param name="stubType">Stub type.</param>
|
||||||
|
/// <param name="isDirectory">Is directory.</param>
|
||||||
|
public VideoFileInfo(string name, string path, string? container, int? year = default, ExtraType? extraType = default, ExtraRule? extraRule = default, string? format3D = default, bool is3D = default, bool isStub = default, string? stubType = default, bool isDirectory = default)
|
||||||
|
{
|
||||||
|
Path = path;
|
||||||
|
Container = container;
|
||||||
|
Name = name;
|
||||||
|
Year = year;
|
||||||
|
ExtraType = extraType;
|
||||||
|
ExtraRule = extraRule;
|
||||||
|
Format3D = format3D;
|
||||||
|
Is3D = is3D;
|
||||||
|
IsStub = isStub;
|
||||||
|
StubType = stubType;
|
||||||
|
IsDirectory = isDirectory;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the path.
|
/// Gets or sets the path.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -17,7 +46,7 @@ namespace Emby.Naming.Video
|
||||||
/// Gets or sets the container.
|
/// Gets or sets the container.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The container.</value>
|
/// <value>The container.</value>
|
||||||
public string Container { get; set; }
|
public string? Container { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the name.
|
/// Gets or sets the name.
|
||||||
|
@ -41,13 +70,13 @@ namespace Emby.Naming.Video
|
||||||
/// Gets or sets the extra rule.
|
/// Gets or sets the extra rule.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The extra rule.</value>
|
/// <value>The extra rule.</value>
|
||||||
public ExtraRule ExtraRule { get; set; }
|
public ExtraRule? ExtraRule { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the format3 d.
|
/// Gets or sets the format3 d.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The format3 d.</value>
|
/// <value>The format3 d.</value>
|
||||||
public string Format3D { get; set; }
|
public string? Format3D { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets a value indicating whether [is3 d].
|
/// Gets or sets a value indicating whether [is3 d].
|
||||||
|
@ -65,7 +94,7 @@ namespace Emby.Naming.Video
|
||||||
/// Gets or sets the type of the stub.
|
/// Gets or sets the type of the stub.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The type of the stub.</value>
|
/// <value>The type of the stub.</value>
|
||||||
public string StubType { get; set; }
|
public string? StubType { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets a value indicating whether this instance is a directory.
|
/// Gets or sets a value indicating whether this instance is a directory.
|
||||||
|
@ -84,8 +113,7 @@ namespace Emby.Naming.Video
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
// Makes debugging easier
|
return "VideoFileInfo(Name: '" + Name + "')";
|
||||||
return Name ?? base.ToString();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ namespace Emby.Naming.Video
|
||||||
/// Initializes a new instance of the <see cref="VideoInfo" /> class.
|
/// Initializes a new instance of the <see cref="VideoInfo" /> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="name">The name.</param>
|
/// <param name="name">The name.</param>
|
||||||
public VideoInfo(string name)
|
public VideoInfo(string? name)
|
||||||
{
|
{
|
||||||
Name = name;
|
Name = name;
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ namespace Emby.Naming.Video
|
||||||
/// Gets or sets the name.
|
/// Gets or sets the name.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The name.</value>
|
/// <value>The name.</value>
|
||||||
public string Name { get; set; }
|
public string? Name { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the year.
|
/// Gets or sets the year.
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
#pragma warning disable CS1591
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
@ -11,22 +9,35 @@ using MediaBrowser.Model.IO;
|
||||||
|
|
||||||
namespace Emby.Naming.Video
|
namespace Emby.Naming.Video
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Resolves alternative versions and extras from list of video files.
|
||||||
|
/// </summary>
|
||||||
public class VideoListResolver
|
public class VideoListResolver
|
||||||
{
|
{
|
||||||
private readonly NamingOptions _options;
|
private readonly NamingOptions _options;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="VideoListResolver"/> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="options"><see cref="NamingOptions"/> object containing CleanStringRegexes and VideoFlagDelimiters and passes options to <see cref="StackResolver"/> and <see cref="VideoResolver"/>.</param>
|
||||||
public VideoListResolver(NamingOptions options)
|
public VideoListResolver(NamingOptions options)
|
||||||
{
|
{
|
||||||
_options = options;
|
_options = options;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Resolves alternative versions and extras from list of video files.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="files">List of related video files.</param>
|
||||||
|
/// <param name="supportMultiVersion">Indication we should consider multi-versions of content.</param>
|
||||||
|
/// <returns>Returns enumerable of <see cref="VideoInfo"/> which groups files together when related.</returns>
|
||||||
public IEnumerable<VideoInfo> Resolve(List<FileSystemMetadata> files, bool supportMultiVersion = true)
|
public IEnumerable<VideoInfo> Resolve(List<FileSystemMetadata> files, bool supportMultiVersion = true)
|
||||||
{
|
{
|
||||||
var videoResolver = new VideoResolver(_options);
|
var videoResolver = new VideoResolver(_options);
|
||||||
|
|
||||||
var videoInfos = files
|
var videoInfos = files
|
||||||
.Select(i => videoResolver.Resolve(i.FullName, i.IsDirectory))
|
.Select(i => videoResolver.Resolve(i.FullName, i.IsDirectory))
|
||||||
.Where(i => i != null)
|
.OfType<VideoFileInfo>()
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
// Filter out all extras, otherwise they could cause stacks to not be resolved
|
// Filter out all extras, otherwise they could cause stacks to not be resolved
|
||||||
|
@ -39,7 +50,7 @@ namespace Emby.Naming.Video
|
||||||
.Resolve(nonExtras).ToList();
|
.Resolve(nonExtras).ToList();
|
||||||
|
|
||||||
var remainingFiles = videoInfos
|
var remainingFiles = videoInfos
|
||||||
.Where(i => !stackResult.Any(s => s.ContainsFile(i.Path, i.IsDirectory)))
|
.Where(i => !stackResult.Any(s => i.Path != null && s.ContainsFile(i.Path, i.IsDirectory)))
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
var list = new List<VideoInfo>();
|
var list = new List<VideoInfo>();
|
||||||
|
@ -48,7 +59,9 @@ namespace Emby.Naming.Video
|
||||||
{
|
{
|
||||||
var info = new VideoInfo(stack.Name)
|
var info = new VideoInfo(stack.Name)
|
||||||
{
|
{
|
||||||
Files = stack.Files.Select(i => videoResolver.Resolve(i, stack.IsDirectoryStack)).ToList()
|
Files = stack.Files.Select(i => videoResolver.Resolve(i, stack.IsDirectoryStack))
|
||||||
|
.OfType<VideoFileInfo>()
|
||||||
|
.ToList()
|
||||||
};
|
};
|
||||||
|
|
||||||
info.Year = info.Files[0].Year;
|
info.Year = info.Files[0].Year;
|
||||||
|
@ -133,7 +146,7 @@ namespace Emby.Naming.Video
|
||||||
}
|
}
|
||||||
|
|
||||||
// If there's only one video, accept all trailers
|
// If there's only one video, accept all trailers
|
||||||
// Be lenient because people use all kinds of mish mash conventions with trailers
|
// Be lenient because people use all kinds of mishmash conventions with trailers.
|
||||||
if (list.Count == 1)
|
if (list.Count == 1)
|
||||||
{
|
{
|
||||||
var trailers = remainingFiles
|
var trailers = remainingFiles
|
||||||
|
@ -203,15 +216,21 @@ namespace Emby.Naming.Video
|
||||||
return videos.Select(i => i.Year ?? -1).Distinct().Count() < 2;
|
return videos.Select(i => i.Year ?? -1).Distinct().Count() < 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool IsEligibleForMultiVersion(string folderName, string testFilename)
|
private bool IsEligibleForMultiVersion(string folderName, string? testFilename)
|
||||||
{
|
{
|
||||||
testFilename = Path.GetFileNameWithoutExtension(testFilename) ?? string.Empty;
|
testFilename = Path.GetFileNameWithoutExtension(testFilename) ?? string.Empty;
|
||||||
|
|
||||||
if (testFilename.StartsWith(folderName, StringComparison.OrdinalIgnoreCase))
|
if (testFilename.StartsWith(folderName, StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
|
if (CleanStringParser.TryClean(testFilename, _options.CleanStringRegexes, out var cleanName))
|
||||||
|
{
|
||||||
|
testFilename = cleanName.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
testFilename = testFilename.Substring(folderName.Length).Trim();
|
testFilename = testFilename.Substring(folderName.Length).Trim();
|
||||||
return string.IsNullOrEmpty(testFilename)
|
return string.IsNullOrEmpty(testFilename)
|
||||||
|| testFilename[0] == '-'
|
|| testFilename[0].Equals('-')
|
||||||
|
|| testFilename[0].Equals('_')
|
||||||
|| string.IsNullOrWhiteSpace(Regex.Replace(testFilename, @"\[([^]]*)\]", string.Empty));
|
|| string.IsNullOrWhiteSpace(Regex.Replace(testFilename, @"\[([^]]*)\]", string.Empty));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,3 @@
|
||||||
#pragma warning disable CS1591
|
|
||||||
#nullable enable
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
@ -8,10 +5,18 @@ using Emby.Naming.Common;
|
||||||
|
|
||||||
namespace Emby.Naming.Video
|
namespace Emby.Naming.Video
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Resolves <see cref="VideoFileInfo"/> from file path.
|
||||||
|
/// </summary>
|
||||||
public class VideoResolver
|
public class VideoResolver
|
||||||
{
|
{
|
||||||
private readonly NamingOptions _options;
|
private readonly NamingOptions _options;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="VideoResolver"/> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="options"><see cref="NamingOptions"/> object containing VideoFileExtensions, StubFileExtensions, CleanStringRegexes and CleanDateTimeRegexes
|
||||||
|
/// and passes options in <see cref="StubResolver"/>, <see cref="FlagParser"/>, <see cref="Format3DParser"/> and <see cref="ExtraResolver"/>.</param>
|
||||||
public VideoResolver(NamingOptions options)
|
public VideoResolver(NamingOptions options)
|
||||||
{
|
{
|
||||||
_options = options;
|
_options = options;
|
||||||
|
@ -22,7 +27,7 @@ namespace Emby.Naming.Video
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="path">The path.</param>
|
/// <param name="path">The path.</param>
|
||||||
/// <returns>VideoFileInfo.</returns>
|
/// <returns>VideoFileInfo.</returns>
|
||||||
public VideoFileInfo? ResolveDirectory(string path)
|
public VideoFileInfo? ResolveDirectory(string? path)
|
||||||
{
|
{
|
||||||
return Resolve(path, true);
|
return Resolve(path, true);
|
||||||
}
|
}
|
||||||
|
@ -32,7 +37,7 @@ namespace Emby.Naming.Video
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="path">The path.</param>
|
/// <param name="path">The path.</param>
|
||||||
/// <returns>VideoFileInfo.</returns>
|
/// <returns>VideoFileInfo.</returns>
|
||||||
public VideoFileInfo? ResolveFile(string path)
|
public VideoFileInfo? ResolveFile(string? path)
|
||||||
{
|
{
|
||||||
return Resolve(path, false);
|
return Resolve(path, false);
|
||||||
}
|
}
|
||||||
|
@ -45,11 +50,11 @@ namespace Emby.Naming.Video
|
||||||
/// <param name="parseName">Whether or not the name should be parsed for info.</param>
|
/// <param name="parseName">Whether or not the name should be parsed for info.</param>
|
||||||
/// <returns>VideoFileInfo.</returns>
|
/// <returns>VideoFileInfo.</returns>
|
||||||
/// <exception cref="ArgumentNullException"><c>path</c> is <c>null</c>.</exception>
|
/// <exception cref="ArgumentNullException"><c>path</c> is <c>null</c>.</exception>
|
||||||
public VideoFileInfo? Resolve(string path, bool isDirectory, bool parseName = true)
|
public VideoFileInfo? Resolve(string? path, bool isDirectory, bool parseName = true)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(path))
|
if (string.IsNullOrEmpty(path))
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException(nameof(path));
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isStub = false;
|
bool isStub = false;
|
||||||
|
@ -99,39 +104,58 @@ namespace Emby.Naming.Video
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new VideoFileInfo
|
return new VideoFileInfo(
|
||||||
{
|
path: path,
|
||||||
Path = path,
|
container: container,
|
||||||
Container = container,
|
isStub: isStub,
|
||||||
IsStub = isStub,
|
name: name,
|
||||||
Name = name,
|
year: year,
|
||||||
Year = year,
|
stubType: stubType,
|
||||||
StubType = stubType,
|
is3D: format3DResult.Is3D,
|
||||||
Is3D = format3DResult.Is3D,
|
format3D: format3DResult.Format3D,
|
||||||
Format3D = format3DResult.Format3D,
|
extraType: extraResult.ExtraType,
|
||||||
ExtraType = extraResult.ExtraType,
|
isDirectory: isDirectory,
|
||||||
IsDirectory = isDirectory,
|
extraRule: extraResult.Rule);
|
||||||
ExtraRule = extraResult.Rule
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Determines if path is video file based on extension.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="path">Path to file.</param>
|
||||||
|
/// <returns>True if is video file.</returns>
|
||||||
public bool IsVideoFile(string path)
|
public bool IsVideoFile(string path)
|
||||||
{
|
{
|
||||||
var extension = Path.GetExtension(path) ?? string.Empty;
|
var extension = Path.GetExtension(path) ?? string.Empty;
|
||||||
return _options.VideoFileExtensions.Contains(extension, StringComparer.OrdinalIgnoreCase);
|
return _options.VideoFileExtensions.Contains(extension, StringComparer.OrdinalIgnoreCase);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Determines if path is video file stub based on extension.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="path">Path to file.</param>
|
||||||
|
/// <returns>True if is video file stub.</returns>
|
||||||
public bool IsStubFile(string path)
|
public bool IsStubFile(string path)
|
||||||
{
|
{
|
||||||
var extension = Path.GetExtension(path) ?? string.Empty;
|
var extension = Path.GetExtension(path) ?? string.Empty;
|
||||||
return _options.StubFileExtensions.Contains(extension, StringComparer.OrdinalIgnoreCase);
|
return _options.StubFileExtensions.Contains(extension, StringComparer.OrdinalIgnoreCase);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Tries to clean name of clutter.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name">Raw name.</param>
|
||||||
|
/// <param name="newName">Clean name.</param>
|
||||||
|
/// <returns>True if cleaning of name was successful.</returns>
|
||||||
public bool TryCleanString(string name, out ReadOnlySpan<char> newName)
|
public bool TryCleanString(string name, out ReadOnlySpan<char> newName)
|
||||||
{
|
{
|
||||||
return CleanStringParser.TryClean(name, _options.CleanStringRegexes, out newName);
|
return CleanStringParser.TryClean(name, _options.CleanStringRegexes, out newName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Tries to get name and year from raw name.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name">Raw name.</param>
|
||||||
|
/// <returns>Returns <see cref="CleanDateTimeResult"/> with name and optional year.</returns>
|
||||||
public CleanDateTimeResult CleanDateTime(string name)
|
public CleanDateTimeResult CleanDateTime(string name)
|
||||||
{
|
{
|
||||||
return CleanDateTimeParser.Clean(name, _options.CleanDateTimeRegexes);
|
return CleanDateTimeParser.Clean(name, _options.CleanDateTimeRegexes);
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netstandard2.1</TargetFramework>
|
<TargetFramework>net5.0</TargetFramework>
|
||||||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
||||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||||
|
|
|
@ -83,7 +83,7 @@ namespace Emby.Notifications
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void OnAppHostHasPendingRestartChanged(object sender, EventArgs e)
|
private async void OnAppHostHasPendingRestartChanged(object? sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var type = NotificationType.ServerRestartRequired.ToString();
|
var type = NotificationType.ServerRestartRequired.ToString();
|
||||||
|
|
||||||
|
@ -99,7 +99,7 @@ namespace Emby.Notifications
|
||||||
await SendNotification(notification, null).ConfigureAwait(false);
|
await SendNotification(notification, null).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void OnActivityManagerEntryCreated(object sender, GenericEventArgs<ActivityLogEntry> e)
|
private async void OnActivityManagerEntryCreated(object? sender, GenericEventArgs<ActivityLogEntry> e)
|
||||||
{
|
{
|
||||||
var entry = e.Argument;
|
var entry = e.Argument;
|
||||||
|
|
||||||
|
@ -132,7 +132,7 @@ namespace Emby.Notifications
|
||||||
return _config.GetConfiguration<NotificationOptions>("notifications");
|
return _config.GetConfiguration<NotificationOptions>("notifications");
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void OnAppHostHasUpdateAvailableChanged(object sender, EventArgs e)
|
private async void OnAppHostHasUpdateAvailableChanged(object? sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (!_appHost.HasUpdateAvailable)
|
if (!_appHost.HasUpdateAvailable)
|
||||||
{
|
{
|
||||||
|
@ -151,7 +151,7 @@ namespace Emby.Notifications
|
||||||
await SendNotification(notification, null).ConfigureAwait(false);
|
await SendNotification(notification, null).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnLibraryManagerItemAdded(object sender, ItemChangeEventArgs e)
|
private void OnLibraryManagerItemAdded(object? sender, ItemChangeEventArgs e)
|
||||||
{
|
{
|
||||||
if (!FilterItem(e.Item))
|
if (!FilterItem(e.Item))
|
||||||
{
|
{
|
||||||
|
@ -197,7 +197,7 @@ namespace Emby.Notifications
|
||||||
return item.SourceType == SourceType.Library;
|
return item.SourceType == SourceType.Library;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void LibraryUpdateTimerCallback(object state)
|
private async void LibraryUpdateTimerCallback(object? state)
|
||||||
{
|
{
|
||||||
List<BaseItem> items;
|
List<BaseItem> items;
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netstandard2.1</TargetFramework>
|
<TargetFramework>net5.0</TargetFramework>
|
||||||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
||||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||||
|
|
|
@ -133,6 +133,33 @@ namespace Emby.Server.Implementations.AppBase
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Manually pre-loads a factory so that it is available pre system initialisation.
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T">Class to register.</typeparam>
|
||||||
|
public virtual void RegisterConfiguration<T>()
|
||||||
|
where T : IConfigurationFactory
|
||||||
|
{
|
||||||
|
IConfigurationFactory factory = Activator.CreateInstance<T>();
|
||||||
|
|
||||||
|
if (_configurationFactories == null)
|
||||||
|
{
|
||||||
|
_configurationFactories = new[] { factory };
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var oldLen = _configurationFactories.Length;
|
||||||
|
var arr = new IConfigurationFactory[oldLen + 1];
|
||||||
|
_configurationFactories.CopyTo(arr, 0);
|
||||||
|
arr[oldLen] = factory;
|
||||||
|
_configurationFactories = arr;
|
||||||
|
}
|
||||||
|
|
||||||
|
_configurationStores = _configurationFactories
|
||||||
|
.SelectMany(i => i.GetConfigurations())
|
||||||
|
.ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Adds parts.
|
/// Adds parts.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using MediaBrowser.Common.Extensions;
|
||||||
using MediaBrowser.Model.Serialization;
|
using MediaBrowser.Model.Serialization;
|
||||||
|
|
||||||
namespace Emby.Server.Implementations.AppBase
|
namespace Emby.Server.Implementations.AppBase
|
||||||
|
@ -35,7 +36,7 @@ namespace Emby.Server.Implementations.AppBase
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
configuration = Activator.CreateInstance(type);
|
configuration = Activator.CreateInstance(type) ?? throw new ArgumentException($"Provided path ({type}) is not valid.", nameof(type));
|
||||||
}
|
}
|
||||||
|
|
||||||
using var stream = new MemoryStream(buffer?.Length ?? 0);
|
using var stream = new MemoryStream(buffer?.Length ?? 0);
|
||||||
|
@ -48,8 +49,9 @@ namespace Emby.Server.Implementations.AppBase
|
||||||
// If the file didn't exist before, or if something has changed, re-save
|
// If the file didn't exist before, or if something has changed, re-save
|
||||||
if (buffer == null || !newBytes.AsSpan(0, newBytesLen).SequenceEqual(buffer))
|
if (buffer == null || !newBytes.AsSpan(0, newBytesLen).SequenceEqual(buffer))
|
||||||
{
|
{
|
||||||
Directory.CreateDirectory(Path.GetDirectoryName(path));
|
var directory = Path.GetDirectoryName(path) ?? throw new ArgumentException($"Provided path ({path}) is not valid.", nameof(path));
|
||||||
|
|
||||||
|
Directory.CreateDirectory(directory);
|
||||||
// Save it after load in case we got new items
|
// Save it after load in case we got new items
|
||||||
using (var fs = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.Read))
|
using (var fs = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.Read))
|
||||||
{
|
{
|
||||||
|
|
|
@ -94,7 +94,6 @@ using MediaBrowser.Model.System;
|
||||||
using MediaBrowser.Model.Tasks;
|
using MediaBrowser.Model.Tasks;
|
||||||
using MediaBrowser.Providers.Chapters;
|
using MediaBrowser.Providers.Chapters;
|
||||||
using MediaBrowser.Providers.Manager;
|
using MediaBrowser.Providers.Manager;
|
||||||
using MediaBrowser.Providers.Plugins.TheTvdb;
|
|
||||||
using MediaBrowser.Providers.Plugins.Tmdb;
|
using MediaBrowser.Providers.Plugins.Tmdb;
|
||||||
using MediaBrowser.Providers.Subtitles;
|
using MediaBrowser.Providers.Subtitles;
|
||||||
using MediaBrowser.XbmcMetadata.Providers;
|
using MediaBrowser.XbmcMetadata.Providers;
|
||||||
|
@ -126,7 +125,6 @@ namespace Emby.Server.Implementations
|
||||||
private IMediaEncoder _mediaEncoder;
|
private IMediaEncoder _mediaEncoder;
|
||||||
private ISessionManager _sessionManager;
|
private ISessionManager _sessionManager;
|
||||||
private IHttpClientFactory _httpClientFactory;
|
private IHttpClientFactory _httpClientFactory;
|
||||||
|
|
||||||
private string[] _urlPrefixes;
|
private string[] _urlPrefixes;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -497,24 +495,11 @@ namespace Emby.Server.Implementations
|
||||||
HttpsPort = ServerConfiguration.DefaultHttpsPort;
|
HttpsPort = ServerConfiguration.DefaultHttpsPort;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Plugins != null)
|
|
||||||
{
|
|
||||||
var pluginBuilder = new StringBuilder();
|
|
||||||
|
|
||||||
foreach (var plugin in Plugins)
|
|
||||||
{
|
|
||||||
pluginBuilder.Append(plugin.Name)
|
|
||||||
.Append(' ')
|
|
||||||
.Append(plugin.Version)
|
|
||||||
.AppendLine();
|
|
||||||
}
|
|
||||||
|
|
||||||
Logger.LogInformation("Plugins: {Plugins}", pluginBuilder.ToString());
|
|
||||||
}
|
|
||||||
|
|
||||||
DiscoverTypes();
|
DiscoverTypes();
|
||||||
|
|
||||||
RegisterServices();
|
RegisterServices();
|
||||||
|
|
||||||
|
RegisterPluginServices();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -534,7 +519,6 @@ namespace Emby.Server.Implementations
|
||||||
ServiceCollection.AddSingleton<IJsonSerializer, JsonSerializer>();
|
ServiceCollection.AddSingleton<IJsonSerializer, JsonSerializer>();
|
||||||
|
|
||||||
ServiceCollection.AddSingleton(_fileSystemManager);
|
ServiceCollection.AddSingleton(_fileSystemManager);
|
||||||
ServiceCollection.AddSingleton<TvdbClientManager>();
|
|
||||||
ServiceCollection.AddSingleton<TmdbClientManager>();
|
ServiceCollection.AddSingleton<TmdbClientManager>();
|
||||||
|
|
||||||
ServiceCollection.AddSingleton(_networkManager);
|
ServiceCollection.AddSingleton(_networkManager);
|
||||||
|
@ -779,10 +763,24 @@ namespace Emby.Server.Implementations
|
||||||
|
|
||||||
ConfigurationManager.AddParts(GetExports<IConfigurationFactory>());
|
ConfigurationManager.AddParts(GetExports<IConfigurationFactory>());
|
||||||
_plugins = GetExports<IPlugin>()
|
_plugins = GetExports<IPlugin>()
|
||||||
.Select(LoadPlugin)
|
|
||||||
.Where(i => i != null)
|
.Where(i => i != null)
|
||||||
.ToArray();
|
.ToArray();
|
||||||
|
|
||||||
|
if (Plugins != null)
|
||||||
|
{
|
||||||
|
var pluginBuilder = new StringBuilder();
|
||||||
|
|
||||||
|
foreach (var plugin in Plugins)
|
||||||
|
{
|
||||||
|
pluginBuilder.Append(plugin.Name)
|
||||||
|
.Append(' ')
|
||||||
|
.Append(plugin.Version)
|
||||||
|
.AppendLine();
|
||||||
|
}
|
||||||
|
|
||||||
|
Logger.LogInformation("Plugins: {Plugins}", pluginBuilder.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
_urlPrefixes = GetUrlPrefixes().ToArray();
|
_urlPrefixes = GetUrlPrefixes().ToArray();
|
||||||
|
|
||||||
Resolve<ILibraryManager>().AddParts(
|
Resolve<ILibraryManager>().AddParts(
|
||||||
|
@ -812,21 +810,6 @@ namespace Emby.Server.Implementations
|
||||||
Resolve<IIsoManager>().AddParts(GetExports<IIsoMounter>());
|
Resolve<IIsoManager>().AddParts(GetExports<IIsoMounter>());
|
||||||
}
|
}
|
||||||
|
|
||||||
private IPlugin LoadPlugin(IPlugin plugin)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
plugin.RegisterServices(ServiceCollection);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
Logger.LogError(ex, "Error loading plugin {PluginName}", plugin.GetType().FullName);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return plugin;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Discovers the types.
|
/// Discovers the types.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -837,6 +820,22 @@ namespace Emby.Server.Implementations
|
||||||
_allConcreteTypes = GetTypes(GetComposablePartAssemblies()).ToArray();
|
_allConcreteTypes = GetTypes(GetComposablePartAssemblies()).ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void RegisterPluginServices()
|
||||||
|
{
|
||||||
|
foreach (var pluginServiceRegistrator in GetExportTypes<IPluginServiceRegistrator>())
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var instance = (IPluginServiceRegistrator)Activator.CreateInstance(pluginServiceRegistrator);
|
||||||
|
instance.RegisterServices(ServiceCollection);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Logger.LogError(ex, "Error registering plugin services from {Assembly}.", pluginServiceRegistrator.Assembly);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private IEnumerable<Type> GetTypes(IEnumerable<Assembly> assemblies)
|
private IEnumerable<Type> GetTypes(IEnumerable<Assembly> assemblies)
|
||||||
{
|
{
|
||||||
foreach (var ass in assemblies)
|
foreach (var ass in assemblies)
|
||||||
|
@ -996,6 +995,12 @@ namespace Emby.Server.Implementations
|
||||||
{
|
{
|
||||||
var minimumVersion = new Version(0, 0, 0, 1);
|
var minimumVersion = new Version(0, 0, 0, 1);
|
||||||
var versions = new List<LocalPlugin>();
|
var versions = new List<LocalPlugin>();
|
||||||
|
if (!Directory.Exists(path))
|
||||||
|
{
|
||||||
|
// Plugin path doesn't exist, don't try to enumerate subfolders.
|
||||||
|
return Enumerable.Empty<LocalPlugin>();
|
||||||
|
}
|
||||||
|
|
||||||
var directories = Directory.EnumerateDirectories(path, "*.*", SearchOption.TopDirectoryOnly);
|
var directories = Directory.EnumerateDirectories(path, "*.*", SearchOption.TopDirectoryOnly);
|
||||||
|
|
||||||
foreach (var dir in directories)
|
foreach (var dir in directories)
|
||||||
|
@ -1026,7 +1031,7 @@ namespace Emby.Server.Implementations
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// No metafile, so lets see if the folder is versioned.
|
// No metafile, so lets see if the folder is versioned.
|
||||||
metafile = dir.Split(new[] { Path.DirectorySeparatorChar }, StringSplitOptions.RemoveEmptyEntries)[^1];
|
metafile = dir.Split(Path.DirectorySeparatorChar, StringSplitOptions.RemoveEmptyEntries)[^1];
|
||||||
|
|
||||||
int versionIndex = dir.LastIndexOf('_');
|
int versionIndex = dir.LastIndexOf('_');
|
||||||
if (versionIndex != -1 && Version.TryParse(dir.Substring(versionIndex + 1), out Version parsedVersion))
|
if (versionIndex != -1 && Version.TryParse(dir.Substring(versionIndex + 1), out Version parsedVersion))
|
||||||
|
@ -1063,7 +1068,6 @@ namespace Emby.Server.Implementations
|
||||||
if (!string.IsNullOrEmpty(lastName) && cleanup)
|
if (!string.IsNullOrEmpty(lastName) && cleanup)
|
||||||
{
|
{
|
||||||
// Attempt a cleanup of old folders.
|
// Attempt a cleanup of old folders.
|
||||||
versions.RemoveAt(x);
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Logger.LogDebug("Deleting {Path}", versions[x].Path);
|
Logger.LogDebug("Deleting {Path}", versions[x].Path);
|
||||||
|
@ -1073,6 +1077,8 @@ namespace Emby.Server.Implementations
|
||||||
{
|
{
|
||||||
Logger.LogWarning(e, "Unable to delete {Path}", versions[x].Path);
|
Logger.LogWarning(e, "Unable to delete {Path}", versions[x].Path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
versions.RemoveAt(x);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1371,7 +1377,7 @@ namespace Emby.Server.Implementations
|
||||||
using var response = await _httpClientFactory.CreateClient(NamedClient.Default)
|
using var response = await _httpClientFactory.CreateClient(NamedClient.Default)
|
||||||
.SendAsync(request, HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
|
.SendAsync(request, HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
await using var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false);
|
await using var stream = await response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
|
||||||
var result = await System.Text.Json.JsonSerializer.DeserializeAsync<string>(stream, JsonDefaults.GetOptions(), cancellationToken).ConfigureAwait(false);
|
var result = await System.Text.Json.JsonSerializer.DeserializeAsync<string>(stream, JsonDefaults.GetOptions(), cancellationToken).ConfigureAwait(false);
|
||||||
var valid = string.Equals(Name, result, StringComparison.OrdinalIgnoreCase);
|
var valid = string.Equals(Name, result, StringComparison.OrdinalIgnoreCase);
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Security.Cryptography;
|
using System.Security.Cryptography;
|
||||||
|
using MediaBrowser.Common.Extensions;
|
||||||
using MediaBrowser.Model.Cryptography;
|
using MediaBrowser.Model.Cryptography;
|
||||||
using static MediaBrowser.Common.Cryptography.Constants;
|
using static MediaBrowser.Common.Cryptography.Constants;
|
||||||
|
|
||||||
|
@ -80,7 +81,7 @@ namespace Emby.Server.Implementations.Cryptography
|
||||||
throw new CryptographicException($"Requested hash method is not supported: {hashMethod}");
|
throw new CryptographicException($"Requested hash method is not supported: {hashMethod}");
|
||||||
}
|
}
|
||||||
|
|
||||||
using var h = HashAlgorithm.Create(hashMethod);
|
using var h = HashAlgorithm.Create(hashMethod) ?? throw new ResourceNotFoundException($"Unknown hash method: {hashMethod}.");
|
||||||
if (salt.Length == 0)
|
if (salt.Length == 0)
|
||||||
{
|
{
|
||||||
return h.ComputeHash(bytes);
|
return h.ComputeHash(bytes);
|
||||||
|
|
|
@ -107,20 +107,6 @@ namespace Emby.Server.Implementations.Data
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Attach(SQLiteDatabaseConnection db, string path, string alias)
|
|
||||||
{
|
|
||||||
var commandText = string.Format(
|
|
||||||
CultureInfo.InvariantCulture,
|
|
||||||
"attach @path as {0};",
|
|
||||||
alias);
|
|
||||||
|
|
||||||
using (var statement = db.PrepareStatement(commandText))
|
|
||||||
{
|
|
||||||
statement.TryBind("@path", path);
|
|
||||||
statement.MoveNext();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool IsDBNull(this IReadOnlyList<IResultSetValue> result, int index)
|
public static bool IsDBNull(this IReadOnlyList<IResultSetValue> result, int index)
|
||||||
{
|
{
|
||||||
return result[index].SQLiteType == SQLiteType.Null;
|
return result[index].SQLiteType == SQLiteType.Null;
|
||||||
|
|
|
@ -1007,7 +1007,7 @@ namespace Emby.Server.Implementations.Data
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var parts = value.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
|
var parts = value.Split('|', StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
|
||||||
foreach (var part in parts)
|
foreach (var part in parts)
|
||||||
{
|
{
|
||||||
|
@ -1057,7 +1057,7 @@ namespace Emby.Server.Implementations.Data
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var parts = value.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
|
var parts = value.Split('|' , StringSplitOptions.RemoveEmptyEntries);
|
||||||
var list = new List<ItemImageInfo>();
|
var list = new List<ItemImageInfo>();
|
||||||
foreach (var part in parts)
|
foreach (var part in parts)
|
||||||
{
|
{
|
||||||
|
@ -1096,7 +1096,7 @@ namespace Emby.Server.Implementations.Data
|
||||||
|
|
||||||
public ItemImageInfo ItemImageInfoFromValueString(string value)
|
public ItemImageInfo ItemImageInfoFromValueString(string value)
|
||||||
{
|
{
|
||||||
var parts = value.Split(new[] { '*' }, StringSplitOptions.None);
|
var parts = value.Split('*', StringSplitOptions.None);
|
||||||
|
|
||||||
if (parts.Length < 3)
|
if (parts.Length < 3)
|
||||||
{
|
{
|
||||||
|
@ -1532,7 +1532,7 @@ namespace Emby.Server.Implementations.Data
|
||||||
{
|
{
|
||||||
if (!reader.IsDBNull(index))
|
if (!reader.IsDBNull(index))
|
||||||
{
|
{
|
||||||
item.Genres = reader.GetString(index).Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
|
item.Genres = reader.GetString(index).Split('|', StringSplitOptions.RemoveEmptyEntries);
|
||||||
}
|
}
|
||||||
|
|
||||||
index++;
|
index++;
|
||||||
|
@ -1593,7 +1593,7 @@ namespace Emby.Server.Implementations.Data
|
||||||
{
|
{
|
||||||
IEnumerable<MetadataField> GetLockedFields(string s)
|
IEnumerable<MetadataField> GetLockedFields(string s)
|
||||||
{
|
{
|
||||||
foreach (var i in s.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries))
|
foreach (var i in s.Split('|', StringSplitOptions.RemoveEmptyEntries))
|
||||||
{
|
{
|
||||||
if (Enum.TryParse(i, true, out MetadataField parsedValue))
|
if (Enum.TryParse(i, true, out MetadataField parsedValue))
|
||||||
{
|
{
|
||||||
|
@ -1612,7 +1612,7 @@ namespace Emby.Server.Implementations.Data
|
||||||
{
|
{
|
||||||
if (!reader.IsDBNull(index))
|
if (!reader.IsDBNull(index))
|
||||||
{
|
{
|
||||||
item.Studios = reader.GetString(index).Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
|
item.Studios = reader.GetString(index).Split('|', StringSplitOptions.RemoveEmptyEntries);
|
||||||
}
|
}
|
||||||
|
|
||||||
index++;
|
index++;
|
||||||
|
@ -1622,7 +1622,7 @@ namespace Emby.Server.Implementations.Data
|
||||||
{
|
{
|
||||||
if (!reader.IsDBNull(index))
|
if (!reader.IsDBNull(index))
|
||||||
{
|
{
|
||||||
item.Tags = reader.GetString(index).Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
|
item.Tags = reader.GetString(index).Split('|', StringSplitOptions.RemoveEmptyEntries);
|
||||||
}
|
}
|
||||||
|
|
||||||
index++;
|
index++;
|
||||||
|
@ -1636,7 +1636,7 @@ namespace Emby.Server.Implementations.Data
|
||||||
{
|
{
|
||||||
IEnumerable<TrailerType> GetTrailerTypes(string s)
|
IEnumerable<TrailerType> GetTrailerTypes(string s)
|
||||||
{
|
{
|
||||||
foreach (var i in s.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries))
|
foreach (var i in s.Split('|', StringSplitOptions.RemoveEmptyEntries))
|
||||||
{
|
{
|
||||||
if (Enum.TryParse(i, true, out TrailerType parsedValue))
|
if (Enum.TryParse(i, true, out TrailerType parsedValue))
|
||||||
{
|
{
|
||||||
|
@ -1811,7 +1811,7 @@ namespace Emby.Server.Implementations.Data
|
||||||
{
|
{
|
||||||
if (!reader.IsDBNull(index))
|
if (!reader.IsDBNull(index))
|
||||||
{
|
{
|
||||||
item.ProductionLocations = reader.GetString(index).Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries).ToArray();
|
item.ProductionLocations = reader.GetString(index).Split('|', StringSplitOptions.RemoveEmptyEntries).ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
index++;
|
index++;
|
||||||
|
@ -1848,14 +1848,14 @@ namespace Emby.Server.Implementations.Data
|
||||||
{
|
{
|
||||||
if (item is IHasArtist hasArtists && !reader.IsDBNull(index))
|
if (item is IHasArtist hasArtists && !reader.IsDBNull(index))
|
||||||
{
|
{
|
||||||
hasArtists.Artists = reader.GetString(index).Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
|
hasArtists.Artists = reader.GetString(index).Split('|', StringSplitOptions.RemoveEmptyEntries);
|
||||||
}
|
}
|
||||||
|
|
||||||
index++;
|
index++;
|
||||||
|
|
||||||
if (item is IHasAlbumArtist hasAlbumArtists && !reader.IsDBNull(index))
|
if (item is IHasAlbumArtist hasAlbumArtists && !reader.IsDBNull(index))
|
||||||
{
|
{
|
||||||
hasAlbumArtists.AlbumArtists = reader.GetString(index).Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
|
hasAlbumArtists.AlbumArtists = reader.GetString(index).Split('|', StringSplitOptions.RemoveEmptyEntries);
|
||||||
}
|
}
|
||||||
|
|
||||||
index++;
|
index++;
|
||||||
|
@ -2403,11 +2403,11 @@ namespace Emby.Server.Implementations.Data
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(item.OfficialRating))
|
if (string.IsNullOrEmpty(item.OfficialRating))
|
||||||
{
|
{
|
||||||
builder.Append("((OfficialRating is null) * 10)");
|
builder.Append("(OfficialRating is null * 10)");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
builder.Append("((OfficialRating=@ItemOfficialRating) * 10)");
|
builder.Append("(OfficialRating=@ItemOfficialRating * 10)");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item.ProductionYear.HasValue)
|
if (item.ProductionYear.HasValue)
|
||||||
|
@ -2416,8 +2416,26 @@ namespace Emby.Server.Implementations.Data
|
||||||
builder.Append("+(Select Case When Abs(COALESCE(ProductionYear, 0) - @ItemProductionYear) < 5 Then 5 Else 0 End )");
|
builder.Append("+(Select Case When Abs(COALESCE(ProductionYear, 0) - @ItemProductionYear) < 5 Then 5 Else 0 End )");
|
||||||
}
|
}
|
||||||
|
|
||||||
//// genres, tags
|
// genres, tags, studios, person, year?
|
||||||
builder.Append("+ ((Select count(CleanValue) from ItemValues where ItemId=Guid and CleanValue in (select CleanValue from itemvalues where ItemId=@SimilarItemId)) * 10)");
|
builder.Append("+ (Select count(1) * 10 from ItemValues where ItemId=Guid and CleanValue in (select CleanValue from itemvalues 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");
|
builder.Append(") as SimilarityScore");
|
||||||
|
|
||||||
|
@ -5052,7 +5070,7 @@ where AncestorIdText not null and ItemValues.Value not null and ItemValues.Type
|
||||||
|
|
||||||
CheckDisposed();
|
CheckDisposed();
|
||||||
|
|
||||||
var commandText = "select ItemId, Name, Role, PersonType, SortOrder from People";
|
var commandText = "select ItemId, Name, Role, PersonType, SortOrder from People p";
|
||||||
|
|
||||||
var whereClauses = GetPeopleWhereClauses(query, null);
|
var whereClauses = GetPeopleWhereClauses(query, null);
|
||||||
|
|
||||||
|
@ -5593,7 +5611,7 @@ where AncestorIdText not null and ItemValues.Value not null and ItemValues.Type
|
||||||
return counts;
|
return counts;
|
||||||
}
|
}
|
||||||
|
|
||||||
var allTypes = typeString.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries)
|
var allTypes = typeString.Split('|', StringSplitOptions.RemoveEmptyEntries)
|
||||||
.ToLookup(x => x);
|
.ToLookup(x => x);
|
||||||
|
|
||||||
foreach (var type in allTypes)
|
foreach (var type in allTypes)
|
||||||
|
|
|
@ -275,7 +275,7 @@ namespace Emby.Server.Implementations.Dto
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
var containers = container.Split(new[] { ',' });
|
var containers = container.Split(',');
|
||||||
if (containers.Length < 2)
|
if (containers.Length < 2)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -32,13 +32,13 @@
|
||||||
<PackageReference Include="Microsoft.AspNetCore.ResponseCompression" Version="2.2.0" />
|
<PackageReference Include="Microsoft.AspNetCore.ResponseCompression" Version="2.2.0" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="2.2.0" />
|
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="2.2.0" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.WebSockets" Version="2.2.1" />
|
<PackageReference Include="Microsoft.AspNetCore.WebSockets" Version="2.2.1" />
|
||||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.1.9" />
|
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="5.0.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="3.1.9" />
|
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="5.0.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="3.1.9" />
|
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="5.0.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="3.1.9" />
|
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="5.0.0" />
|
||||||
<PackageReference Include="Mono.Nat" Version="3.0.0" />
|
<PackageReference Include="Mono.Nat" Version="3.0.1" />
|
||||||
<PackageReference Include="prometheus-net.DotNetRuntime" Version="3.4.0" />
|
<PackageReference Include="prometheus-net.DotNetRuntime" Version="3.4.0" />
|
||||||
<PackageReference Include="ServiceStack.Text.Core" Version="5.9.2" />
|
<PackageReference Include="ServiceStack.Text.Core" Version="5.10.0" />
|
||||||
<PackageReference Include="sharpcompress" Version="0.26.0" />
|
<PackageReference Include="sharpcompress" Version="0.26.0" />
|
||||||
<PackageReference Include="SQLitePCL.pretty.netstandard" Version="2.1.0" />
|
<PackageReference Include="SQLitePCL.pretty.netstandard" Version="2.1.0" />
|
||||||
<PackageReference Include="DotNet.Glob" Version="3.1.0" />
|
<PackageReference Include="DotNet.Glob" Version="3.1.0" />
|
||||||
|
@ -49,10 +49,12 @@
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netstandard2.1</TargetFramework>
|
<TargetFramework>net5.0</TargetFramework>
|
||||||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
||||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||||
<TreatWarningsAsErrors Condition=" '$(Configuration)' == 'Release'">true</TreatWarningsAsErrors>
|
<TreatWarningsAsErrors Condition=" '$(Configuration)' == 'Release'">true</TreatWarningsAsErrors>
|
||||||
|
<!-- https://github.com/microsoft/ApplicationInsights-dotnet/issues/2047 -->
|
||||||
|
<NoWarn>AD0001</NoWarn>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<!-- Code Analyzers-->
|
<!-- Code Analyzers-->
|
||||||
|
|
|
@ -245,7 +245,7 @@ namespace Emby.Server.Implementations.HttpServer.Security
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
var parts = authorizationHeader.Split(new[] { ' ' }, 2);
|
var parts = authorizationHeader.Split(' ', 2);
|
||||||
|
|
||||||
// There should be at least to parts
|
// There should be at least to parts
|
||||||
if (parts.Length != 2)
|
if (parts.Length != 2)
|
||||||
|
@ -269,11 +269,11 @@ namespace Emby.Server.Implementations.HttpServer.Security
|
||||||
|
|
||||||
foreach (var item in parts)
|
foreach (var item in parts)
|
||||||
{
|
{
|
||||||
var param = item.Trim().Split(new[] { '=' }, 2);
|
var param = item.Trim().Split('=', 2);
|
||||||
|
|
||||||
if (param.Length == 2)
|
if (param.Length == 2)
|
||||||
{
|
{
|
||||||
var value = NormalizeValue(param[1].Trim(new[] { '"' }));
|
var value = NormalizeValue(param[1].Trim('"'));
|
||||||
result[param[0]] = value;
|
result[param[0]] = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ using System.Globalization;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
|
using System.Net.Http;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Emby.Naming.Audio;
|
using Emby.Naming.Audio;
|
||||||
|
@ -2485,9 +2486,10 @@ namespace Emby.Server.Implementations.Library
|
||||||
|
|
||||||
var isFolder = episode.VideoType == VideoType.BluRay || episode.VideoType == VideoType.Dvd;
|
var isFolder = episode.VideoType == VideoType.BluRay || episode.VideoType == VideoType.Dvd;
|
||||||
|
|
||||||
|
// TODO nullable - what are we trying to do there with empty episodeInfo?
|
||||||
var episodeInfo = episode.IsFileProtocol
|
var episodeInfo = episode.IsFileProtocol
|
||||||
? resolver.Resolve(episode.Path, isFolder, null, null, isAbsoluteNaming) ?? new Naming.TV.EpisodeInfo()
|
? resolver.Resolve(episode.Path, isFolder, null, null, isAbsoluteNaming) ?? new Naming.TV.EpisodeInfo(episode.Path)
|
||||||
: new Naming.TV.EpisodeInfo();
|
: new Naming.TV.EpisodeInfo(episode.Path);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -2576,12 +2578,12 @@ namespace Emby.Server.Implementations.Library
|
||||||
|
|
||||||
if (!episode.IndexNumberEnd.HasValue || forceRefresh)
|
if (!episode.IndexNumberEnd.HasValue || forceRefresh)
|
||||||
{
|
{
|
||||||
if (episode.IndexNumberEnd != episodeInfo.EndingEpsiodeNumber)
|
if (episode.IndexNumberEnd != episodeInfo.EndingEpisodeNumber)
|
||||||
{
|
{
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
episode.IndexNumberEnd = episodeInfo.EndingEpsiodeNumber;
|
episode.IndexNumberEnd = episodeInfo.EndingEpisodeNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!episode.ParentIndexNumber.HasValue || forceRefresh)
|
if (!episode.ParentIndexNumber.HasValue || forceRefresh)
|
||||||
|
@ -2705,7 +2707,7 @@ namespace Emby.Server.Implementations.Library
|
||||||
|
|
||||||
var videos = videoListResolver.Resolve(fileSystemChildren);
|
var videos = videoListResolver.Resolve(fileSystemChildren);
|
||||||
|
|
||||||
var currentVideo = videos.FirstOrDefault(i => string.Equals(owner.Path, i.Files.First().Path, StringComparison.OrdinalIgnoreCase));
|
var currentVideo = videos.FirstOrDefault(i => string.Equals(owner.Path, i.Files[0].Path, StringComparison.OrdinalIgnoreCase));
|
||||||
|
|
||||||
if (currentVideo != null)
|
if (currentVideo != null)
|
||||||
{
|
{
|
||||||
|
@ -2907,7 +2909,7 @@ namespace Emby.Server.Implementations.Library
|
||||||
|
|
||||||
return item.GetImageInfo(image.Type, imageIndex);
|
return item.GetImageInfo(image.Type, imageIndex);
|
||||||
}
|
}
|
||||||
catch (HttpException ex)
|
catch (HttpRequestException ex)
|
||||||
{
|
{
|
||||||
if (ex.StatusCode.HasValue
|
if (ex.StatusCode.HasValue
|
||||||
&& (ex.StatusCode.Value == HttpStatusCode.NotFound || ex.StatusCode.Value == HttpStatusCode.Forbidden))
|
&& (ex.StatusCode.Value == HttpStatusCode.NotFound || ex.StatusCode.Value == HttpStatusCode.Forbidden))
|
||||||
|
|
|
@ -849,7 +849,7 @@ namespace Emby.Server.Implementations.Library
|
||||||
throw new ArgumentException("Key can't be empty.", nameof(key));
|
throw new ArgumentException("Key can't be empty.", nameof(key));
|
||||||
}
|
}
|
||||||
|
|
||||||
var keys = key.Split(new[] { LiveStreamIdDelimeter }, 2);
|
var keys = key.Split(LiveStreamIdDelimeter, 2);
|
||||||
|
|
||||||
var provider = _providers.FirstOrDefault(i => string.Equals(i.GetType().FullName.GetMD5().ToString("N", CultureInfo.InvariantCulture), keys[0], StringComparison.OrdinalIgnoreCase));
|
var provider = _providers.FirstOrDefault(i => string.Equals(i.GetType().FullName.GetMD5().ToString("N", CultureInfo.InvariantCulture), keys[0], StringComparison.OrdinalIgnoreCase));
|
||||||
|
|
||||||
|
|
|
@ -101,7 +101,7 @@ namespace Emby.Server.Implementations.Library
|
||||||
|
|
||||||
private static IEnumerable<MediaStream> GetSortedStreams(IEnumerable<MediaStream> streams, MediaStreamType type, string[] languagePreferences)
|
private static IEnumerable<MediaStream> GetSortedStreams(IEnumerable<MediaStream> streams, MediaStreamType type, string[] languagePreferences)
|
||||||
{
|
{
|
||||||
// Give some preferance to external text subs for better performance
|
// Give some preference to external text subs for better performance
|
||||||
return streams.Where(i => i.Type == type)
|
return streams.Where(i => i.Type == type)
|
||||||
.OrderBy(i =>
|
.OrderBy(i =>
|
||||||
{
|
{
|
||||||
|
|
|
@ -201,7 +201,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.Audio
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
var firstMedia = resolvedItem.Files.First();
|
var firstMedia = resolvedItem.Files[0];
|
||||||
|
|
||||||
var libraryItem = new T
|
var libraryItem = new T
|
||||||
{
|
{
|
||||||
|
|
|
@ -77,11 +77,12 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
|
||||||
_logger.LogInformation("Copying recording stream to file {0}", targetFile);
|
_logger.LogInformation("Copying recording stream to file {0}", targetFile);
|
||||||
|
|
||||||
// The media source if infinite so we need to handle stopping ourselves
|
// The media source if infinite so we need to handle stopping ourselves
|
||||||
var durationToken = new CancellationTokenSource(duration);
|
using var durationToken = new CancellationTokenSource(duration);
|
||||||
cancellationToken = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, durationToken.Token).Token;
|
using var linkedCancellationToken = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, durationToken.Token);
|
||||||
|
cancellationToken = linkedCancellationToken.Token;
|
||||||
|
|
||||||
await _streamHelper.CopyUntilCancelled(
|
await _streamHelper.CopyUntilCancelled(
|
||||||
await response.Content.ReadAsStreamAsync().ConfigureAwait(false),
|
await response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false),
|
||||||
output,
|
output,
|
||||||
IODefaults.CopyToBufferSize,
|
IODefaults.CopyToBufferSize,
|
||||||
cancellationToken).ConfigureAwait(false);
|
cancellationToken).ConfigureAwait(false);
|
||||||
|
|
|
@ -1635,7 +1635,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
|
||||||
{
|
{
|
||||||
if (mediaSource.RequiresLooping || !(mediaSource.Container ?? string.Empty).EndsWith("ts", StringComparison.OrdinalIgnoreCase) || (mediaSource.Protocol != MediaProtocol.File && mediaSource.Protocol != MediaProtocol.Http))
|
if (mediaSource.RequiresLooping || !(mediaSource.Container ?? string.Empty).EndsWith("ts", StringComparison.OrdinalIgnoreCase) || (mediaSource.Protocol != MediaProtocol.File && mediaSource.Protocol != MediaProtocol.Http))
|
||||||
{
|
{
|
||||||
return new EncodedRecorder(_logger, _mediaEncoder, _config.ApplicationPaths, _jsonSerializer);
|
return new EncodedRecorder(_logger, _mediaEncoder, _config.ApplicationPaths, _jsonSerializer, _config);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new DirectRecorder(_logger, _httpClientFactory, _streamHelper);
|
return new DirectRecorder(_logger, _httpClientFactory, _streamHelper);
|
||||||
|
|
|
@ -8,7 +8,9 @@ using System.IO;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using MediaBrowser.Common.Configuration;
|
||||||
using MediaBrowser.Controller;
|
using MediaBrowser.Controller;
|
||||||
|
using MediaBrowser.Controller.Configuration;
|
||||||
using MediaBrowser.Controller.Library;
|
using MediaBrowser.Controller.Library;
|
||||||
using MediaBrowser.Controller.MediaEncoding;
|
using MediaBrowser.Controller.MediaEncoding;
|
||||||
using MediaBrowser.Model.Dto;
|
using MediaBrowser.Model.Dto;
|
||||||
|
@ -25,6 +27,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
|
||||||
private readonly IServerApplicationPaths _appPaths;
|
private readonly IServerApplicationPaths _appPaths;
|
||||||
private readonly IJsonSerializer _json;
|
private readonly IJsonSerializer _json;
|
||||||
private readonly TaskCompletionSource<bool> _taskCompletionSource = new TaskCompletionSource<bool>();
|
private readonly TaskCompletionSource<bool> _taskCompletionSource = new TaskCompletionSource<bool>();
|
||||||
|
private readonly IServerConfigurationManager _serverConfigurationManager;
|
||||||
|
|
||||||
private bool _hasExited;
|
private bool _hasExited;
|
||||||
private Stream _logFileStream;
|
private Stream _logFileStream;
|
||||||
|
@ -35,12 +38,14 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
|
||||||
ILogger logger,
|
ILogger logger,
|
||||||
IMediaEncoder mediaEncoder,
|
IMediaEncoder mediaEncoder,
|
||||||
IServerApplicationPaths appPaths,
|
IServerApplicationPaths appPaths,
|
||||||
IJsonSerializer json)
|
IJsonSerializer json,
|
||||||
|
IServerConfigurationManager serverConfigurationManager)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_mediaEncoder = mediaEncoder;
|
_mediaEncoder = mediaEncoder;
|
||||||
_appPaths = appPaths;
|
_appPaths = appPaths;
|
||||||
_json = json;
|
_json = json;
|
||||||
|
_serverConfigurationManager = serverConfigurationManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static bool CopySubtitles => false;
|
private static bool CopySubtitles => false;
|
||||||
|
@ -179,15 +184,17 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
|
||||||
|
|
||||||
var outputParam = string.Empty;
|
var outputParam = string.Empty;
|
||||||
|
|
||||||
|
var threads = EncodingHelper.GetNumberOfThreads(null, _serverConfigurationManager.GetEncodingOptions(), null);
|
||||||
var commandLineArgs = string.Format(
|
var commandLineArgs = string.Format(
|
||||||
CultureInfo.InvariantCulture,
|
CultureInfo.InvariantCulture,
|
||||||
"-i \"{0}\" {2} -map_metadata -1 -threads 0 {3}{4}{5} -y \"{1}\"",
|
"-i \"{0}\" {2} -map_metadata -1 -threads {6} {3}{4}{5} -y \"{1}\"",
|
||||||
inputTempFile,
|
inputTempFile,
|
||||||
targetFile,
|
targetFile,
|
||||||
videoArgs,
|
videoArgs,
|
||||||
GetAudioArgs(mediaSource),
|
GetAudioArgs(mediaSource),
|
||||||
subtitleArgs,
|
subtitleArgs,
|
||||||
outputParam);
|
outputParam,
|
||||||
|
threads);
|
||||||
|
|
||||||
return inputModifier + " " + commandLineArgs;
|
return inputModifier + " " + commandLineArgs;
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@ using System.Threading.Tasks;
|
||||||
using MediaBrowser.Common;
|
using MediaBrowser.Common;
|
||||||
using MediaBrowser.Common.Net;
|
using MediaBrowser.Common.Net;
|
||||||
using MediaBrowser.Controller.LiveTv;
|
using MediaBrowser.Controller.LiveTv;
|
||||||
|
using MediaBrowser.Model.Cryptography;
|
||||||
using MediaBrowser.Model.Dto;
|
using MediaBrowser.Model.Dto;
|
||||||
using MediaBrowser.Model.Entities;
|
using MediaBrowser.Model.Entities;
|
||||||
using MediaBrowser.Model.LiveTv;
|
using MediaBrowser.Model.LiveTv;
|
||||||
|
@ -33,17 +34,20 @@ namespace Emby.Server.Implementations.LiveTv.Listings
|
||||||
private readonly IHttpClientFactory _httpClientFactory;
|
private readonly IHttpClientFactory _httpClientFactory;
|
||||||
private readonly SemaphoreSlim _tokenSemaphore = new SemaphoreSlim(1, 1);
|
private readonly SemaphoreSlim _tokenSemaphore = new SemaphoreSlim(1, 1);
|
||||||
private readonly IApplicationHost _appHost;
|
private readonly IApplicationHost _appHost;
|
||||||
|
private readonly ICryptoProvider _cryptoProvider;
|
||||||
|
|
||||||
public SchedulesDirect(
|
public SchedulesDirect(
|
||||||
ILogger<SchedulesDirect> logger,
|
ILogger<SchedulesDirect> logger,
|
||||||
IJsonSerializer jsonSerializer,
|
IJsonSerializer jsonSerializer,
|
||||||
IHttpClientFactory httpClientFactory,
|
IHttpClientFactory httpClientFactory,
|
||||||
IApplicationHost appHost)
|
IApplicationHost appHost,
|
||||||
|
ICryptoProvider cryptoProvider)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_jsonSerializer = jsonSerializer;
|
_jsonSerializer = jsonSerializer;
|
||||||
_httpClientFactory = httpClientFactory;
|
_httpClientFactory = httpClientFactory;
|
||||||
_appHost = appHost;
|
_appHost = appHost;
|
||||||
|
_cryptoProvider = cryptoProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
private string UserAgent => _appHost.ApplicationUserAgent;
|
private string UserAgent => _appHost.ApplicationUserAgent;
|
||||||
|
@ -108,7 +112,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
|
||||||
options.Content = new StringContent(requestString, Encoding.UTF8, MediaTypeNames.Application.Json);
|
options.Content = new StringContent(requestString, Encoding.UTF8, MediaTypeNames.Application.Json);
|
||||||
options.Headers.TryAddWithoutValidation("token", token);
|
options.Headers.TryAddWithoutValidation("token", token);
|
||||||
using var response = await Send(options, true, info, cancellationToken).ConfigureAwait(false);
|
using var response = await Send(options, true, info, cancellationToken).ConfigureAwait(false);
|
||||||
await using var responseStream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false);
|
await using var responseStream = await response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
|
||||||
var dailySchedules = await _jsonSerializer.DeserializeFromStreamAsync<List<ScheduleDirect.Day>>(responseStream).ConfigureAwait(false);
|
var dailySchedules = await _jsonSerializer.DeserializeFromStreamAsync<List<ScheduleDirect.Day>>(responseStream).ConfigureAwait(false);
|
||||||
_logger.LogDebug("Found {ScheduleCount} programs on {ChannelID} ScheduleDirect", dailySchedules.Count, channelId);
|
_logger.LogDebug("Found {ScheduleCount} programs on {ChannelID} ScheduleDirect", dailySchedules.Count, channelId);
|
||||||
|
|
||||||
|
@ -119,7 +123,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
|
||||||
programRequestOptions.Content = new StringContent("[\"" + string.Join("\", \"", programsID) + "\"]", Encoding.UTF8, MediaTypeNames.Application.Json);
|
programRequestOptions.Content = new StringContent("[\"" + string.Join("\", \"", programsID) + "\"]", Encoding.UTF8, MediaTypeNames.Application.Json);
|
||||||
|
|
||||||
using var innerResponse = await Send(programRequestOptions, true, info, cancellationToken).ConfigureAwait(false);
|
using var innerResponse = await Send(programRequestOptions, true, info, cancellationToken).ConfigureAwait(false);
|
||||||
await using var innerResponseStream = await innerResponse.Content.ReadAsStreamAsync().ConfigureAwait(false);
|
await using var innerResponseStream = await innerResponse.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
|
||||||
var programDetails = await _jsonSerializer.DeserializeFromStreamAsync<List<ScheduleDirect.ProgramDetails>>(innerResponseStream).ConfigureAwait(false);
|
var programDetails = await _jsonSerializer.DeserializeFromStreamAsync<List<ScheduleDirect.ProgramDetails>>(innerResponseStream).ConfigureAwait(false);
|
||||||
var programDict = programDetails.ToDictionary(p => p.programID, y => y);
|
var programDict = programDetails.ToDictionary(p => p.programID, y => y);
|
||||||
|
|
||||||
|
@ -257,7 +261,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
|
||||||
Id = newID,
|
Id = newID,
|
||||||
StartDate = startAt,
|
StartDate = startAt,
|
||||||
EndDate = endAt,
|
EndDate = endAt,
|
||||||
Name = details.titles[0].title120 ?? "Unkown",
|
Name = details.titles[0].title120 ?? "Unknown",
|
||||||
OfficialRating = null,
|
OfficialRating = null,
|
||||||
CommunityRating = null,
|
CommunityRating = null,
|
||||||
EpisodeTitle = episodeTitle,
|
EpisodeTitle = episodeTitle,
|
||||||
|
@ -476,9 +480,8 @@ namespace Emby.Server.Implementations.LiveTv.Listings
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using var innerResponse2 = await Send(message, true, info, cancellationToken).ConfigureAwait(false);
|
using var innerResponse2 = await Send(message, true, info, cancellationToken).ConfigureAwait(false);
|
||||||
await using var response = await innerResponse2.Content.ReadAsStreamAsync().ConfigureAwait(false);
|
await using var response = await innerResponse2.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
|
||||||
return await _jsonSerializer.DeserializeFromStreamAsync<List<ScheduleDirect.ShowImages>>(
|
return await _jsonSerializer.DeserializeFromStreamAsync<List<ScheduleDirect.ShowImages>>(response).ConfigureAwait(false);
|
||||||
response).ConfigureAwait(false);
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
@ -505,7 +508,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using var httpResponse = await Send(options, false, info, cancellationToken).ConfigureAwait(false);
|
using var httpResponse = await Send(options, false, info, cancellationToken).ConfigureAwait(false);
|
||||||
await using var response = await httpResponse.Content.ReadAsStreamAsync().ConfigureAwait(false);
|
await using var response = await httpResponse.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
var root = await _jsonSerializer.DeserializeFromStreamAsync<List<ScheduleDirect.Headends>>(response).ConfigureAwait(false);
|
var root = await _jsonSerializer.DeserializeFromStreamAsync<List<ScheduleDirect.Headends>>(response).ConfigureAwait(false);
|
||||||
|
|
||||||
|
@ -538,6 +541,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
|
||||||
|
|
||||||
private readonly ConcurrentDictionary<string, NameValuePair> _tokens = new ConcurrentDictionary<string, NameValuePair>();
|
private readonly ConcurrentDictionary<string, NameValuePair> _tokens = new ConcurrentDictionary<string, NameValuePair>();
|
||||||
private DateTime _lastErrorResponse;
|
private DateTime _lastErrorResponse;
|
||||||
|
|
||||||
private async Task<string> GetToken(ListingsProviderInfo info, CancellationToken cancellationToken)
|
private async Task<string> GetToken(ListingsProviderInfo info, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var username = info.Username;
|
var username = info.Username;
|
||||||
|
@ -587,7 +591,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
|
||||||
savedToken.Value = DateTime.UtcNow.Ticks.ToString(CultureInfo.InvariantCulture);
|
savedToken.Value = DateTime.UtcNow.Ticks.ToString(CultureInfo.InvariantCulture);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
catch (HttpException ex)
|
catch (HttpRequestException ex)
|
||||||
{
|
{
|
||||||
if (ex.StatusCode.HasValue)
|
if (ex.StatusCode.HasValue)
|
||||||
{
|
{
|
||||||
|
@ -617,7 +621,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
|
||||||
{
|
{
|
||||||
return await _httpClientFactory.CreateClient(NamedClient.Default).SendAsync(options, completionOption, cancellationToken).ConfigureAwait(false);
|
return await _httpClientFactory.CreateClient(NamedClient.Default).SendAsync(options, completionOption, cancellationToken).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch (HttpException ex)
|
catch (HttpRequestException ex)
|
||||||
{
|
{
|
||||||
_tokens.Clear();
|
_tokens.Clear();
|
||||||
|
|
||||||
|
@ -642,10 +646,12 @@ namespace Emby.Server.Implementations.LiveTv.Listings
|
||||||
CancellationToken cancellationToken)
|
CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
using var options = new HttpRequestMessage(HttpMethod.Post, ApiUrl + "/token");
|
using var options = new HttpRequestMessage(HttpMethod.Post, ApiUrl + "/token");
|
||||||
options.Content = new StringContent("{\"username\":\"" + username + "\",\"password\":\"" + password + "\"}", Encoding.UTF8, MediaTypeNames.Application.Json);
|
var hashedPasswordBytes = _cryptoProvider.ComputeHash("SHA1", Encoding.ASCII.GetBytes(password), Array.Empty<byte>());
|
||||||
|
string hashedPassword = Hex.Encode(hashedPasswordBytes);
|
||||||
|
options.Content = new StringContent("{\"username\":\"" + username + "\",\"password\":\"" + hashedPassword + "\"}", Encoding.UTF8, MediaTypeNames.Application.Json);
|
||||||
|
|
||||||
using var response = await Send(options, false, null, cancellationToken).ConfigureAwait(false);
|
using var response = await Send(options, false, null, cancellationToken).ConfigureAwait(false);
|
||||||
await using var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false);
|
await using var stream = await response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
|
||||||
var root = await _jsonSerializer.DeserializeFromStreamAsync<ScheduleDirect.Token>(stream).ConfigureAwait(false);
|
var root = await _jsonSerializer.DeserializeFromStreamAsync<ScheduleDirect.Token>(stream).ConfigureAwait(false);
|
||||||
if (root.message == "OK")
|
if (root.message == "OK")
|
||||||
{
|
{
|
||||||
|
@ -699,13 +705,13 @@ namespace Emby.Server.Implementations.LiveTv.Listings
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using var httpResponse = await Send(options, false, null, cancellationToken).ConfigureAwait(false);
|
using var httpResponse = await Send(options, false, null, cancellationToken).ConfigureAwait(false);
|
||||||
await using var stream = await httpResponse.Content.ReadAsStreamAsync().ConfigureAwait(false);
|
await using var stream = await httpResponse.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
|
||||||
using var response = httpResponse.Content;
|
using var response = httpResponse.Content;
|
||||||
var root = await _jsonSerializer.DeserializeFromStreamAsync<ScheduleDirect.Lineups>(stream).ConfigureAwait(false);
|
var root = await _jsonSerializer.DeserializeFromStreamAsync<ScheduleDirect.Lineups>(stream).ConfigureAwait(false);
|
||||||
|
|
||||||
return root.lineups.Any(i => string.Equals(info.ListingsId, i.lineup, StringComparison.OrdinalIgnoreCase));
|
return root.lineups.Any(i => string.Equals(info.ListingsId, i.lineup, StringComparison.OrdinalIgnoreCase));
|
||||||
}
|
}
|
||||||
catch (HttpException ex)
|
catch (HttpRequestException ex)
|
||||||
{
|
{
|
||||||
// Apparently we're supposed to swallow this
|
// Apparently we're supposed to swallow this
|
||||||
if (ex.StatusCode.HasValue && ex.StatusCode.Value == HttpStatusCode.BadRequest)
|
if (ex.StatusCode.HasValue && ex.StatusCode.Value == HttpStatusCode.BadRequest)
|
||||||
|
@ -774,7 +780,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
|
||||||
var list = new List<ChannelInfo>();
|
var list = new List<ChannelInfo>();
|
||||||
|
|
||||||
using var httpResponse = await Send(options, true, info, cancellationToken).ConfigureAwait(false);
|
using var httpResponse = await Send(options, true, info, cancellationToken).ConfigureAwait(false);
|
||||||
await using var stream = await httpResponse.Content.ReadAsStreamAsync().ConfigureAwait(false);
|
await using var stream = await httpResponse.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
|
||||||
var root = await _jsonSerializer.DeserializeFromStreamAsync<ScheduleDirect.Channel>(stream).ConfigureAwait(false);
|
var root = await _jsonSerializer.DeserializeFromStreamAsync<ScheduleDirect.Channel>(stream).ConfigureAwait(false);
|
||||||
_logger.LogInformation("Found {ChannelCount} channels on the lineup on ScheduleDirect", root.map.Count);
|
_logger.LogInformation("Found {ChannelCount} channels on the lineup on ScheduleDirect", root.map.Count);
|
||||||
_logger.LogInformation("Mapping Stations to Channel");
|
_logger.LogInformation("Mapping Stations to Channel");
|
||||||
|
|
|
@ -79,7 +79,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings
|
||||||
Directory.CreateDirectory(Path.GetDirectoryName(cacheFile));
|
Directory.CreateDirectory(Path.GetDirectoryName(cacheFile));
|
||||||
|
|
||||||
using var response = await _httpClientFactory.CreateClient(NamedClient.Default).GetAsync(path, cancellationToken).ConfigureAwait(false);
|
using var response = await _httpClientFactory.CreateClient(NamedClient.Default).GetAsync(path, cancellationToken).ConfigureAwait(false);
|
||||||
await using var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false);
|
await using var stream = await response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
|
||||||
await using (var fileStream = new FileStream(cacheFile, FileMode.CreateNew))
|
await using (var fileStream = new FileStream(cacheFile, FileMode.CreateNew))
|
||||||
{
|
{
|
||||||
await stream.CopyToAsync(fileStream, cancellationToken).ConfigureAwait(false);
|
await stream.CopyToAsync(fileStream, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user