mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-04-19 00:33:08 +01:00
Remove global subtitle configuration (#14957)
This commit is contained in:
@@ -1,21 +0,0 @@
|
||||
#pragma warning disable CS1591
|
||||
|
||||
using System.Collections.Generic;
|
||||
using MediaBrowser.Common.Configuration;
|
||||
using MediaBrowser.Model.Providers;
|
||||
|
||||
namespace MediaBrowser.Common.Providers
|
||||
{
|
||||
public class SubtitleConfigurationFactory : IConfigurationFactory
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public IEnumerable<ConfigurationStore> GetConfigurations()
|
||||
{
|
||||
yield return new ConfigurationStore()
|
||||
{
|
||||
Key = "subtitles",
|
||||
ConfigurationType = typeof(SubtitleOptions)
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
#nullable disable
|
||||
#pragma warning disable CS1591
|
||||
|
||||
using System;
|
||||
|
||||
namespace MediaBrowser.Model.Providers
|
||||
{
|
||||
public class SubtitleOptions
|
||||
{
|
||||
public SubtitleOptions()
|
||||
{
|
||||
DownloadLanguages = Array.Empty<string>();
|
||||
|
||||
SkipIfAudioTrackMatches = true;
|
||||
RequirePerfectMatch = true;
|
||||
}
|
||||
|
||||
public bool SkipIfEmbeddedSubtitlesPresent { get; set; }
|
||||
|
||||
public bool SkipIfAudioTrackMatches { get; set; }
|
||||
|
||||
public string[] DownloadLanguages { get; set; }
|
||||
|
||||
public bool DownloadMovieSubtitles { get; set; }
|
||||
|
||||
public bool DownloadEpisodeSubtitles { get; set; }
|
||||
|
||||
public string OpenSubtitlesUsername { get; set; }
|
||||
|
||||
public string OpenSubtitlesPasswordHash { get; set; }
|
||||
|
||||
public bool IsOpenSubtitleVipAccount { get; set; }
|
||||
|
||||
public bool RequirePerfectMatch { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,6 @@ using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Jellyfin.Data.Enums;
|
||||
using Jellyfin.Extensions;
|
||||
using MediaBrowser.Common.Configuration;
|
||||
using MediaBrowser.Controller.Chapters;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
@@ -25,7 +24,6 @@ using MediaBrowser.Model.Dto;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Model.Globalization;
|
||||
using MediaBrowser.Model.MediaInfo;
|
||||
using MediaBrowser.Model.Providers;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace MediaBrowser.Providers.MediaInfo
|
||||
@@ -74,7 +72,6 @@ namespace MediaBrowser.Providers.MediaInfo
|
||||
_subtitleResolver = subtitleResolver;
|
||||
_mediaAttachmentRepository = mediaAttachmentRepository;
|
||||
_mediaStreamRepository = mediaStreamRepository;
|
||||
_mediaStreamRepository = mediaStreamRepository;
|
||||
}
|
||||
|
||||
public async Task<ItemUpdateType> ProbeVideo<T>(
|
||||
@@ -551,47 +548,19 @@ namespace MediaBrowser.Providers.MediaInfo
|
||||
var enableSubtitleDownloading = options.MetadataRefreshMode == MetadataRefreshMode.Default ||
|
||||
options.MetadataRefreshMode == MetadataRefreshMode.FullRefresh;
|
||||
|
||||
var subtitleOptions = _config.GetConfiguration<SubtitleOptions>("subtitles");
|
||||
|
||||
var libraryOptions = _libraryManager.GetLibraryOptions(video);
|
||||
|
||||
string[] subtitleDownloadLanguages;
|
||||
bool skipIfEmbeddedSubtitlesPresent;
|
||||
bool skipIfAudioTrackMatches;
|
||||
bool requirePerfectMatch;
|
||||
bool enabled;
|
||||
|
||||
if (libraryOptions.SubtitleDownloadLanguages is null)
|
||||
{
|
||||
subtitleDownloadLanguages = subtitleOptions.DownloadLanguages;
|
||||
skipIfEmbeddedSubtitlesPresent = subtitleOptions.SkipIfEmbeddedSubtitlesPresent;
|
||||
skipIfAudioTrackMatches = subtitleOptions.SkipIfAudioTrackMatches;
|
||||
requirePerfectMatch = subtitleOptions.RequirePerfectMatch;
|
||||
enabled = (subtitleOptions.DownloadEpisodeSubtitles &&
|
||||
video is Episode) ||
|
||||
(subtitleOptions.DownloadMovieSubtitles &&
|
||||
video is Movie);
|
||||
}
|
||||
else
|
||||
{
|
||||
subtitleDownloadLanguages = libraryOptions.SubtitleDownloadLanguages;
|
||||
skipIfEmbeddedSubtitlesPresent = libraryOptions.SkipSubtitlesIfEmbeddedSubtitlesPresent;
|
||||
skipIfAudioTrackMatches = libraryOptions.SkipSubtitlesIfAudioTrackMatches;
|
||||
requirePerfectMatch = libraryOptions.RequirePerfectSubtitleMatch;
|
||||
enabled = true;
|
||||
}
|
||||
|
||||
if (enableSubtitleDownloading && enabled)
|
||||
if (enableSubtitleDownloading && libraryOptions.SubtitleDownloadLanguages is not null)
|
||||
{
|
||||
var downloadedLanguages = await new SubtitleDownloader(
|
||||
_logger,
|
||||
_subtitleManager).DownloadSubtitles(
|
||||
video,
|
||||
currentStreams.Concat(externalSubtitleStreams).ToList(),
|
||||
skipIfEmbeddedSubtitlesPresent,
|
||||
skipIfAudioTrackMatches,
|
||||
requirePerfectMatch,
|
||||
subtitleDownloadLanguages,
|
||||
libraryOptions.SkipSubtitlesIfEmbeddedSubtitlesPresent,
|
||||
libraryOptions.SkipSubtitlesIfAudioTrackMatches,
|
||||
libraryOptions.RequirePerfectSubtitleMatch,
|
||||
libraryOptions.SubtitleDownloadLanguages,
|
||||
libraryOptions.DisabledSubtitleFetchers,
|
||||
libraryOptions.SubtitleFetcherOrder,
|
||||
true,
|
||||
|
||||
@@ -8,14 +8,12 @@ using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Jellyfin.Data.Enums;
|
||||
using MediaBrowser.Common.Configuration;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Controller.Dto;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Controller.Subtitles;
|
||||
using MediaBrowser.Model.Globalization;
|
||||
using MediaBrowser.Model.Providers;
|
||||
using MediaBrowser.Model.Tasks;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
@@ -57,16 +55,9 @@ namespace MediaBrowser.Providers.MediaInfo
|
||||
|
||||
public bool IsLogged => true;
|
||||
|
||||
private SubtitleOptions GetOptions()
|
||||
{
|
||||
return _config.GetConfiguration<SubtitleOptions>("subtitles");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task ExecuteAsync(IProgress<double> progress, CancellationToken cancellationToken)
|
||||
{
|
||||
var options = GetOptions();
|
||||
|
||||
var types = new[] { BaseItemKind.Episode, BaseItemKind.Movie };
|
||||
|
||||
var dict = new Dictionary<Guid, BaseItem>();
|
||||
@@ -81,17 +72,14 @@ namespace MediaBrowser.Providers.MediaInfo
|
||||
|
||||
if (libraryOptions.SubtitleDownloadLanguages is null)
|
||||
{
|
||||
subtitleDownloadLanguages = options.DownloadLanguages;
|
||||
skipIfEmbeddedSubtitlesPresent = options.SkipIfEmbeddedSubtitlesPresent;
|
||||
skipIfAudioTrackMatches = options.SkipIfAudioTrackMatches;
|
||||
}
|
||||
else
|
||||
{
|
||||
subtitleDownloadLanguages = libraryOptions.SubtitleDownloadLanguages;
|
||||
skipIfEmbeddedSubtitlesPresent = libraryOptions.SkipSubtitlesIfEmbeddedSubtitlesPresent;
|
||||
skipIfAudioTrackMatches = libraryOptions.SkipSubtitlesIfAudioTrackMatches;
|
||||
// Skip this library if subtitle download languages are not configured
|
||||
continue;
|
||||
}
|
||||
|
||||
subtitleDownloadLanguages = libraryOptions.SubtitleDownloadLanguages;
|
||||
skipIfEmbeddedSubtitlesPresent = libraryOptions.SkipSubtitlesIfEmbeddedSubtitlesPresent;
|
||||
skipIfAudioTrackMatches = libraryOptions.SkipSubtitlesIfAudioTrackMatches;
|
||||
|
||||
foreach (var lang in subtitleDownloadLanguages)
|
||||
{
|
||||
var query = new InternalItemsQuery
|
||||
@@ -144,7 +132,7 @@ namespace MediaBrowser.Providers.MediaInfo
|
||||
|
||||
try
|
||||
{
|
||||
await DownloadSubtitles(video as Video, options, cancellationToken).ConfigureAwait(false);
|
||||
await DownloadSubtitles(video as Video, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -160,7 +148,7 @@ namespace MediaBrowser.Providers.MediaInfo
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<bool> DownloadSubtitles(Video video, SubtitleOptions options, CancellationToken cancellationToken)
|
||||
private async Task<bool> DownloadSubtitles(Video video, CancellationToken cancellationToken)
|
||||
{
|
||||
var mediaStreams = video.GetMediaStreams();
|
||||
|
||||
@@ -173,19 +161,15 @@ namespace MediaBrowser.Providers.MediaInfo
|
||||
|
||||
if (libraryOptions.SubtitleDownloadLanguages is null)
|
||||
{
|
||||
subtitleDownloadLanguages = options.DownloadLanguages;
|
||||
skipIfEmbeddedSubtitlesPresent = options.SkipIfEmbeddedSubtitlesPresent;
|
||||
skipIfAudioTrackMatches = options.SkipIfAudioTrackMatches;
|
||||
requirePerfectMatch = options.RequirePerfectMatch;
|
||||
}
|
||||
else
|
||||
{
|
||||
subtitleDownloadLanguages = libraryOptions.SubtitleDownloadLanguages;
|
||||
skipIfEmbeddedSubtitlesPresent = libraryOptions.SkipSubtitlesIfEmbeddedSubtitlesPresent;
|
||||
skipIfAudioTrackMatches = libraryOptions.SkipSubtitlesIfAudioTrackMatches;
|
||||
requirePerfectMatch = libraryOptions.RequirePerfectSubtitleMatch;
|
||||
// Subtitle downloading is not configured for this library
|
||||
return true;
|
||||
}
|
||||
|
||||
subtitleDownloadLanguages = libraryOptions.SubtitleDownloadLanguages;
|
||||
skipIfEmbeddedSubtitlesPresent = libraryOptions.SkipSubtitlesIfEmbeddedSubtitlesPresent;
|
||||
skipIfAudioTrackMatches = libraryOptions.SkipSubtitlesIfAudioTrackMatches;
|
||||
requirePerfectMatch = libraryOptions.RequirePerfectSubtitleMatch;
|
||||
|
||||
var downloadedLanguages = await new SubtitleDownloader(
|
||||
_logger,
|
||||
_subtitleManager).DownloadSubtitles(
|
||||
|
||||
Reference in New Issue
Block a user