The Free Software Media System - Server Backend & API
Fix some warnings
Bond_009384ab39f5b3d
diff --git a/Emby.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs b/Emby.Server.Implementations/LiveTv/Listings/SchedulesDirect.csindex f9ae55af85..655ff58537 100644--- a/Emby.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs+++ b/Emby.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs@@ -468,13 +468,15 @@ namespace Emby.Server.Implementations.LiveTv.ListingsimageIdString = imageIdString.TrimEnd(',') + "]";- using var message = new HttpRequestMessage(HttpMethod.Post, ApiUrl + "/metadata/programs");- message.Content = new StringContent(imageIdString, Encoding.UTF8, MediaTypeNames.Application.Json);+ using var message = new HttpRequestMessage(HttpMethod.Post, ApiUrl + "/metadata/programs")+ {+ Content = new StringContent(imageIdString, Encoding.UTF8, MediaTypeNames.Application.Json)+ };try{using var innerResponse2 = await Send(message, true, info, cancellationToken).ConfigureAwait(false);- await using var response = await innerResponse2.Content.ReadAsStreamAsync();+ await using var response = await innerResponse2.Content.ReadAsStreamAsync().ConfigureAwait(false);return await _jsonSerializer.DeserializeFromStreamAsync<List<ScheduleDirect.ShowImages>>(response).ConfigureAwait(false);}diff --git a/MediaBrowser.Providers/Folders/CollectionFolderMetadataService.cs b/MediaBrowser.Providers/Folders/CollectionFolderMetadataService.csindex 46f368f72b..e0f3131fdb 100644--- a/MediaBrowser.Providers/Folders/CollectionFolderMetadataService.cs+++ b/MediaBrowser.Providers/Folders/CollectionFolderMetadataService.cs@@ -1,6 +1,5 @@#pragma warning disable CS1591-using MediaBrowser.Controller.Configuration;using MediaBrowser.Controller.Entities;using MediaBrowser.Controller.Library;diff --git a/MediaBrowser.Providers/LiveTv/ProgramMetadataService.cs b/MediaBrowser.Providers/LiveTv/LiveTvMetadataService.cssimilarity index 100%rename from MediaBrowser.Providers/LiveTv/ProgramMetadataService.csrename to MediaBrowser.Providers/LiveTv/LiveTvMetadataService.csdiff --git a/MediaBrowser.Providers/Manager/ImageSaver.cs b/MediaBrowser.Providers/Manager/ImageSaver.csindex 413d297cb5..19a42d506c 100644--- a/MediaBrowser.Providers/Manager/ImageSaver.cs+++ b/MediaBrowser.Providers/Manager/ImageSaver.cs@@ -7,7 +7,6 @@ using System.IO;using System.Linq;using System.Threading;using System.Threading.Tasks;-using Jellyfin.Data.Entities;using MediaBrowser.Common.Configuration;using MediaBrowser.Controller.Configuration;using MediaBrowser.Controller.Entities;@@ -59,6 +58,16 @@ namespace MediaBrowser.Providers.Manager_logger = logger;}+ private bool EnableExtraThumbsDuplication+ {+ get+ {+ var config = _config.GetConfiguration<XbmcMetadataOptions>("xbmcmetadata");++ return config.EnableExtraThumbsDuplication;+ }+ }+/// <summary>/// Saves the image./// </summary>@@ -69,7 +78,7 @@ namespace MediaBrowser.Providers.Manager/// <param name="imageIndex">Index of the image.</param>/// <param name="cancellationToken">The cancellation token.</param>/// <returns>Task.</returns>- /// <exception cref="ArgumentNullException">mimeType</exception>+ /// <exception cref="ArgumentNullException">mimeType.</exception>public Task SaveImage(BaseItem item, Stream source, string mimeType, ImageType type, int? imageIndex, CancellationToken cancellationToken){return SaveImage(item, source, mimeType, type, imageIndex, null, cancellationToken);@@ -312,7 +321,7 @@ namespace MediaBrowser.Providers.Manager/// <exception cref="ArgumentNullException">/// imageIndex/// or- /// imageIndex+ /// imageIndex./// </exception>private ItemImageInfo GetCurrentImage(BaseItem item, ImageType type, int imageIndex){@@ -328,7 +337,8 @@ namespace MediaBrowser.Providers.Manager/// <param name="path">The path.</param>/// <exception cref="ArgumentNullException">imageIndex/// or- /// imageIndex</exception>+ /// imageIndex.+ /// </exception>private void SetImagePath(BaseItem item, ImageType type, int? imageIndex, string path){item.SetImagePath(type, imageIndex ?? 0, _fileSystem.GetFileInfo(path));@@ -346,7 +356,7 @@ namespace MediaBrowser.Providers.Manager/// <exception cref="ArgumentNullException">/// imageIndex/// or- /// imageIndex+ /// imageIndex./// </exception>private string GetStandardSavePath(BaseItem item, ImageType type, int? imageIndex, string mimeType, bool saveLocally){@@ -500,7 +510,7 @@ namespace MediaBrowser.Providers.Manager/// <param name="imageIndex">Index of the image.</param>/// <param name="mimeType">Type of the MIME.</param>/// <returns>IEnumerable{System.String}.</returns>- /// <exception cref="ArgumentNullException">imageIndex</exception>+ /// <exception cref="ArgumentNullException">imageIndex.</exception>private string[] GetCompatibleSavePaths(BaseItem item, ImageType type, int? imageIndex, string mimeType){var season = item as Season;@@ -604,16 +614,6 @@ namespace MediaBrowser.Providers.Managerreturn new[] { GetStandardSavePath(item, type, imageIndex, mimeType, true) };}- private bool EnableExtraThumbsDuplication- {- get- {- var config = _config.GetConfiguration<XbmcMetadataOptions>("xbmcmetadata");-- return config.EnableExtraThumbsDuplication;- }- }-/// <summary>/// Gets the save path for item in mixed folder./// </summary>diff --git a/MediaBrowser.Providers/Manager/ItemImageProvider.cs b/MediaBrowser.Providers/Manager/ItemImageProvider.csindex 9227b6d937..d0bdbd7c95 100644--- a/MediaBrowser.Providers/Manager/ItemImageProvider.cs+++ b/MediaBrowser.Providers/Manager/ItemImageProvider.cs@@ -28,6 +28,22 @@ namespace MediaBrowser.Providers.Managerprivate readonly IProviderManager _providerManager;private readonly IFileSystem _fileSystem;+ /// <summary>+ /// Image types that are only one per item.+ /// </summary>+ private readonly ImageType[] _singularImages =+ {+ ImageType.Primary,+ ImageType.Art,+ ImageType.Banner,+ ImageType.Box,+ ImageType.BoxRear,+ ImageType.Disc,+ ImageType.Logo,+ ImageType.Menu,+ ImageType.Thumb+ };+public ItemImageProvider(ILogger logger, IProviderManager providerManager, IFileSystem fileSystem){_logger = logger;@@ -175,22 +191,6 @@ namespace MediaBrowser.Providers.Manager}}- /// <summary>- /// Image types that are only one per item.- /// </summary>- private readonly ImageType[] _singularImages =- {- ImageType.Primary,- ImageType.Art,- ImageType.Banner,- ImageType.Box,- ImageType.BoxRear,- ImageType.Disc,- ImageType.Logo,- ImageType.Menu,- ImageType.Thumb- };-private bool HasImage(BaseItem item, ImageType type){return item.HasImage(type);@@ -378,7 +378,6 @@ namespace MediaBrowser.Providers.Manager}else{-var newDateModified = _fileSystem.GetLastWriteTimeUtc(image.FileInfo);// If date changed then we need to reset saved image dimensions@@ -441,7 +440,9 @@ namespace MediaBrowser.Providers.Managerreturn changed;}- private async Task<bool> DownloadImage(BaseItem item, LibraryOptions libraryOptions,+ private async Task<bool> DownloadImage(+ BaseItem item,+ LibraryOptions libraryOptions,IRemoteImageProvider provider,RefreshResult result,IEnumerable<RemoteImageInfo> images,@@ -522,11 +523,6 @@ namespace MediaBrowser.Providers.Managerreturn false;}- // if (!item.IsSaveLocalMetadataEnabled())- //{- // return true;- //}-return true;}@@ -539,13 +535,15 @@ namespace MediaBrowser.Providers.Managerprivate void SaveImageStub(BaseItem item, ImageType imageType, IEnumerable<string> urls, int newIndex){- var path = string.Join("|", urls.Take(1).ToArray());+ var path = string.Join('|', urls.Take(1));- item.SetImage(new ItemImageInfo- {- Path = path,- Type = imageType- }, newIndex);+ item.SetImage(+ new ItemImageInfo+ {+ Path = path,+ Type = imageType+ },+ newIndex);}private async Task DownloadBackdrops(BaseItem item, LibraryOptions libraryOptions, ImageType imageType, int limit, IRemoteImageProvider provider, RefreshResult result, IEnumerable<RemoteImageInfo> images, int minWidth, CancellationToken cancellationToken)diff --git a/MediaBrowser.Providers/Manager/MetadataService.cs b/MediaBrowser.Providers/Manager/MetadataService.csindex d0de584276..42785b0574 100644--- a/MediaBrowser.Providers/Manager/MetadataService.cs+++ b/MediaBrowser.Providers/Manager/MetadataService.cs@@ -21,12 +21,6 @@ namespace MediaBrowser.Providers.Managerwhere TItemType : BaseItem, IHasLookupInfo<TIdType>, new()where TIdType : ItemLookupInfo, new(){- protected readonly IServerConfigurationManager ServerConfigurationManager;- protected readonly ILogger<MetadataService<TItemType, TIdType>> Logger;- protected readonly IProviderManager ProviderManager;- protected readonly IFileSystem FileSystem;- protected readonly ILibraryManager LibraryManager;-protected MetadataService(IServerConfigurationManager serverConfigurationManager, ILogger<MetadataService<TItemType, TIdType>> logger, IProviderManager providerManager, IFileSystem fileSystem, ILibraryManager libraryManager){ServerConfigurationManager = serverConfigurationManager;@@ -36,6 +30,26 @@ namespace MediaBrowser.Providers.ManagerLibraryManager = libraryManager;}+ protected IServerConfigurationManager ServerConfigurationManager { get; }++ protected ILogger<MetadataService<TItemType, TIdType>> Logger { get; }++ protected IProviderManager ProviderManager { get; }++ protected IFileSystem FileSystem { get; }++ protected ILibraryManager LibraryManager { get; }++ protected virtual bool EnableUpdatingPremiereDateFromChildren => false;++ protected virtual bool EnableUpdatingGenresFromChildren => false;++ protected virtual bool EnableUpdatingStudiosFromChildren => false;++ protected virtual bool EnableUpdatingOfficialRatingFromChildren => false;++ public virtual int Order => 0;+private FileSystemMetadata TryGetFile(string path, IDirectoryService directoryService){try@@ -442,14 +456,6 @@ namespace MediaBrowser.Providers.Managerreturn updateType;}- protected virtual bool EnableUpdatingPremiereDateFromChildren => false;-- protected virtual bool EnableUpdatingGenresFromChildren => false;-- protected virtual bool EnableUpdatingStudiosFromChildren => false;-- protected virtual bool EnableUpdatingOfficialRatingFromChildren => false;-private ItemUpdateType UpdatePremiereDate(TItemType item, IList<BaseItem> children){var updateType = ItemUpdateType.None;@@ -658,7 +664,8 @@ namespace MediaBrowser.Providers.Managerreturn type == typeof(TItemType);}- protected virtual async Task<RefreshResult> RefreshWithProviders(MetadataResult<TItemType> metadata,+ protected virtual async Task<RefreshResult> RefreshWithProviders(+ MetadataResult<TItemType> metadata,TIdType id,MetadataRefreshOptions options,List<IMetadataProvider> providers,@@ -773,7 +780,7 @@ namespace MediaBrowser.Providers.Managerelse{// TODO: If the new metadata from above has some blank data, this can cause old data to get filled into those empty fields- MergeData(metadata, temp, new MetadataField[] { }, false, false);+ MergeData(metadata, temp, Array.Empty<MetadataField>(), false, false);MergeData(temp, metadata, item.LockedFields, true, false);}}@@ -900,24 +907,23 @@ namespace MediaBrowser.Providers.Manager}}- protected abstract void MergeData(MetadataResult<TItemType> source,+ protected abstract void MergeData(+ MetadataResult<TItemType> source,MetadataResult<TItemType> target,MetadataField[] lockedFields,bool replaceData,bool mergeMetadataSettings);- public virtual int Order => 0;-private bool HasChanged(BaseItem item, IHasItemChangeMonitor changeMonitor, IDirectoryService directoryService){try{var hasChanged = changeMonitor.HasChanged(item, directoryService);- // if (hasChanged)- //{- // logger.LogDebug("{0} reports change to {1}", changeMonitor.GetType().Name, item.Path ?? item.Name);- //}+ if (hasChanged)+ {+ Logger.LogDebug("{0} reports change to {1}", changeMonitor.GetType().Name, item.Path ?? item.Name);+ }return hasChanged;}@@ -928,13 +934,4 @@ namespace MediaBrowser.Providers.Manager}}}-- public class RefreshResult- {- public ItemUpdateType UpdateType { get; set; }-- public string ErrorMessage { get; set; }-- public int Failures { get; set; }- }}diff --git a/MediaBrowser.Providers/Manager/ProviderManager.cs b/MediaBrowser.Providers/Manager/ProviderManager.csindex 171b824ca6..b6fb4267f4 100644--- a/MediaBrowser.Providers/Manager/ProviderManager.cs+++ b/MediaBrowser.Providers/Manager/ProviderManager.cs@@ -9,7 +9,6 @@ using System.Net.Http;using System.Net.Mime;using System.Threading;using System.Threading.Tasks;-using Jellyfin.Data.Entities;using Jellyfin.Data.Events;using MediaBrowser.Common.Net;using MediaBrowser.Common.Progress;@@ -905,8 +904,7 @@ namespace MediaBrowser.Providers.Managerreturn provider.GetImageResponse(url, cancellationToken);}- /// <inheritdoc/>- public IEnumerable<IExternalId> GetExternalIds(IHasProviderIds item)+ private IEnumerable<IExternalId> GetExternalIds(IHasProviderIds item){return _externalIds.Where(i =>{diff --git a/MediaBrowser.Providers/Manager/ProviderUtils.cs b/MediaBrowser.Providers/Manager/ProviderUtils.csindex a4fd6ca84e..70a5a6ac13 100644--- a/MediaBrowser.Providers/Manager/ProviderUtils.cs+++ b/MediaBrowser.Providers/Manager/ProviderUtils.cs@@ -26,12 +26,12 @@ namespace MediaBrowser.Providers.Managerif (source == null){- throw new ArgumentNullException(nameof(source));+ throw new ArgumentException("Item cannot be null.", nameof(sourceResult));}if (target == null){- throw new ArgumentNullException(nameof(target));+ throw new ArgumentException("Item cannot be null.", nameof(targetResult));}if (!lockedFields.Contains(MetadataField.Name))diff --git a/MediaBrowser.Providers/Manager/RefreshResult.cs b/MediaBrowser.Providers/Manager/RefreshResult.csnew file mode 100644index 0000000000..72fc61e424--- /dev/null+++ b/MediaBrowser.Providers/Manager/RefreshResult.cs@@ -0,0 +1,15 @@+#pragma warning disable CS1591++using MediaBrowser.Controller.Library;++namespace MediaBrowser.Providers.Manager+{+ public class RefreshResult+ {+ public ItemUpdateType UpdateType { get; set; }++ public string ErrorMessage { get; set; }++ public int Failures { get; set; }+ }+}diff --git a/MediaBrowser.Providers/MediaInfo/AudioImageProvider.cs b/MediaBrowser.Providers/MediaInfo/AudioImageProvider.csindex f69ec9744a..64ad1bddfe 100644--- a/MediaBrowser.Providers/MediaInfo/AudioImageProvider.cs+++ b/MediaBrowser.Providers/MediaInfo/AudioImageProvider.cs@@ -34,6 +34,10 @@ namespace MediaBrowser.Providers.MediaInfo_fileSystem = fileSystem;}+ public string AudioImagesPath => Path.Combine(_config.ApplicationPaths.CachePath, "extracted-audio-images");++ public string Name => "Image Extractor";+public IEnumerable<ImageType> GetSupportedImages(BaseItem item){return new List<ImageType> { ImageType.Primary };@@ -97,11 +101,11 @@ namespace MediaBrowser.Providers.MediaInfoif (item.GetType() == typeof(Audio)){- var albumArtist = item.AlbumArtists.FirstOrDefault();-- if (!string.IsNullOrWhiteSpace(item.Album) && !string.IsNullOrWhiteSpace(albumArtist))+ if (item.AlbumArtists.Count > 0+ && !string.IsNullOrWhiteSpace(item.Album)+ && !string.IsNullOrWhiteSpace(item.AlbumArtists[0])){- filename = (item.Album + "-" + albumArtist).GetMD5().ToString("N", CultureInfo.InvariantCulture);+ filename = (item.Album + "-" + item.AlbumArtists[0]).GetMD5().ToString("N", CultureInfo.InvariantCulture);}else{@@ -121,10 +125,6 @@ namespace MediaBrowser.Providers.MediaInforeturn Path.Join(AudioImagesPath, prefix, filename);}- public string AudioImagesPath => Path.Combine(_config.ApplicationPaths.CachePath, "extracted-audio-images");-- public string Name => "Image Extractor";-public bool Supports(BaseItem item){if (item.IsShortcut)diff --git a/MediaBrowser.Providers/MediaInfo/FFProbeAudioInfo.cs b/MediaBrowser.Providers/MediaInfo/FFProbeAudioInfo.csindex 77f03580ab..9454636669 100644--- a/MediaBrowser.Providers/MediaInfo/FFProbeAudioInfo.cs+++ b/MediaBrowser.Providers/MediaInfo/FFProbeAudioInfo.cs@@ -37,7 +37,9 @@ namespace MediaBrowser.Providers.MediaInfo_mediaSourceManager = mediaSourceManager;}- public async Task<ItemUpdateType> Probe<T>(T item, MetadataRefreshOptions options,+ public async Task<ItemUpdateType> Probe<T>(+ T item,+ MetadataRefreshOptions options,CancellationToken cancellationToken)where T : Audio{@@ -52,19 +54,21 @@ namespace MediaBrowser.Providers.MediaInfoprotocol = _mediaSourceManager.GetPathProtocol(path);}- var result = await _mediaEncoder.GetMediaInfo(new MediaInfoRequest- {- MediaType = DlnaProfileType.Audio,- MediaSource = new MediaSourceInfo+ var result = await _mediaEncoder.GetMediaInfo(+ new MediaInfoRequest{- Path = path,- Protocol = protocol- }- }, cancellationToken).ConfigureAwait(false);+ MediaType = DlnaProfileType.Audio,+ MediaSource = new MediaSourceInfo+ {+ Path = path,+ Protocol = protocol+ }+ },+ cancellationToken).ConfigureAwait(false);cancellationToken.ThrowIfCancellationRequested();- Fetch(item, cancellationToken, result);+ Fetch(item, result, cancellationToken);}return ItemUpdateType.MetadataImport;@@ -74,10 +78,9 @@ namespace MediaBrowser.Providers.MediaInfo/// Fetches the specified audio./// </summary>/// <param name="audio">The audio.</param>- /// <param name="cancellationToken">The cancellation token.</param>/// <param name="mediaInfo">The media information.</param>- /// <returns>Task.</returns>- protected void Fetch(Audio audio, CancellationToken cancellationToken, Model.MediaInfo.MediaInfo mediaInfo)+ /// <param name="cancellationToken">The cancellation token.</param>+ protected void Fetch(Audio audio, Model.MediaInfo.MediaInfo mediaInfo, CancellationToken cancellationToken){var mediaStreams = mediaInfo.MediaStreams;diff --git a/MediaBrowser.Providers/MediaInfo/FFProbeProvider.cs b/MediaBrowser.Providers/MediaInfo/FFProbeProvider.csindex 9926275ae7..c61187fdf6 100644--- a/MediaBrowser.Providers/MediaInfo/FFProbeProvider.cs+++ b/MediaBrowser.Providers/MediaInfo/FFProbeProvider.cs@@ -5,8 +5,6 @@ using System.IO;using System.Linq;using System.Threading;using System.Threading.Tasks;-using MediaBrowser.Common.Configuration;-using MediaBrowser.Controller.Channels;using MediaBrowser.Controller.Chapters;using MediaBrowser.Controller.Configuration;using MediaBrowser.Controller.Entities;@@ -20,9 +18,7 @@ using MediaBrowser.Controller.Providers;using MediaBrowser.Controller.Subtitles;using MediaBrowser.Model.Entities;using MediaBrowser.Model.Globalization;-using MediaBrowser.Model.IO;using MediaBrowser.Model.MediaInfo;-using MediaBrowser.Model.Serialization;using Microsoft.Extensions.Logging;namespace MediaBrowser.Providers.MediaInfo@@ -50,9 +46,43 @@ namespace MediaBrowser.Providers.MediaInfoprivate readonly IChapterManager _chapterManager;private readonly ILibraryManager _libraryManager;private readonly IMediaSourceManager _mediaSourceManager;+ private readonly SubtitleResolver _subtitleResolver;++ private readonly Task<ItemUpdateType> _cachedTask = Task.FromResult(ItemUpdateType.None);++ public FFProbeProvider(+ ILogger<FFProbeProvider> logger,+ IMediaSourceManager mediaSourceManager,+ IMediaEncoder mediaEncoder,+ IItemRepository itemRepo,+ IBlurayExaminer blurayExaminer,+ ILocalizationManager localization,+ IEncodingManager encodingManager,+ IServerConfigurationManager config,+ ISubtitleManager subtitleManager,+ IChapterManager chapterManager,+ ILibraryManager libraryManager)+ {+ _logger = logger;+ _mediaEncoder = mediaEncoder;+ _itemRepo = itemRepo;+ _blurayExaminer = blurayExaminer;+ _localization = localization;+ _encodingManager = encodingManager;+ _config = config;+ _subtitleManager = subtitleManager;+ _chapterManager = chapterManager;+ _libraryManager = libraryManager;+ _mediaSourceManager = mediaSourceManager;++ _subtitleResolver = new SubtitleResolver(BaseItem.LocalizationManager);+ }public string Name => "ffprobe";+ // Run last+ public int Order => 100;+public bool HasChanged(BaseItem item, IDirectoryService directoryService){var video = item as Video;@@ -117,37 +147,6 @@ namespace MediaBrowser.Providers.MediaInforeturn FetchAudioInfo(item, options, cancellationToken);}- private SubtitleResolver _subtitleResolver;-- public FFProbeProvider(- ILogger<FFProbeProvider> logger,- IMediaSourceManager mediaSourceManager,- IMediaEncoder mediaEncoder,- IItemRepository itemRepo,- IBlurayExaminer blurayExaminer,- ILocalizationManager localization,- IEncodingManager encodingManager,- IServerConfigurationManager config,- ISubtitleManager subtitleManager,- IChapterManager chapterManager,- ILibraryManager libraryManager)- {- _logger = logger;- _mediaEncoder = mediaEncoder;- _itemRepo = itemRepo;- _blurayExaminer = blurayExaminer;- _localization = localization;- _encodingManager = encodingManager;- _config = config;- _subtitleManager = subtitleManager;- _chapterManager = chapterManager;- _libraryManager = libraryManager;- _mediaSourceManager = mediaSourceManager;-- _subtitleResolver = new SubtitleResolver(BaseItem.LocalizationManager);- }-- private readonly Task<ItemUpdateType> _cachedTask = Task.FromResult(ItemUpdateType.None);public Task<ItemUpdateType> FetchVideoInfo<T>(T item, MetadataRefreshOptions options, CancellationToken cancellationToken)where T : Video{@@ -234,8 +233,5 @@ namespace MediaBrowser.Providers.MediaInforeturn prober.Probe(item, options, cancellationToken);}-- // Run last- public int Order => 100;}}diff --git a/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs b/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.csindex 53a6bb6195..776dee7802 100644--- a/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs+++ b/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs@@ -539,17 +539,18 @@ namespace MediaBrowser.Providers.MediaInfoif (enableSubtitleDownloading && enabled){- var downloadedLanguages = await new SubtitleDownloader(_logger,- _subtitleManager)- .DownloadSubtitles(video,- currentStreams.Concat(externalSubtitleStreams).ToList(),- skipIfEmbeddedSubtitlesPresent,- skipIfAudioTrackMatches,- requirePerfectMatch,- subtitleDownloadLanguages,- libraryOptions.DisabledSubtitleFetchers,- libraryOptions.SubtitleFetcherOrder,- cancellationToken).ConfigureAwait(false);+ var downloadedLanguages = await new SubtitleDownloader(+ _logger,+ _subtitleManager).DownloadSubtitles(+ video,+ currentStreams.Concat(externalSubtitleStreams).ToList(),+ skipIfEmbeddedSubtitlesPresent,+ skipIfAudioTrackMatches,+ requirePerfectMatch,+ subtitleDownloadLanguages,+ libraryOptions.DisabledSubtitleFetchers,+ libraryOptions.SubtitleFetcherOrder,+ cancellationToken).ConfigureAwait(false);// Rescanif (downloadedLanguages.Count > 0)diff --git a/MediaBrowser.Providers/MediaInfo/SubtitleDownloader.cs b/MediaBrowser.Providers/MediaInfo/SubtitleDownloader.csindex acddb73d0b..912aedb0db 100644--- a/MediaBrowser.Providers/MediaInfo/SubtitleDownloader.cs+++ b/MediaBrowser.Providers/MediaInfo/SubtitleDownloader.cs@@ -42,8 +42,16 @@ namespace MediaBrowser.Providers.MediaInfoforeach (var lang in languages){- var downloaded = await DownloadSubtitles(video, mediaStreams, skipIfEmbeddedSubtitlesPresent,- skipIfAudioTrackMatches, requirePerfectMatch, lang, disabledSubtitleFetchers, subtitleFetcherOrder, cancellationToken).ConfigureAwait(false);+ var downloaded = await DownloadSubtitles(+ video,+ mediaStreams,+ skipIfEmbeddedSubtitlesPresent,+ skipIfAudioTrackMatches,+ requirePerfectMatch,+ lang,+ disabledSubtitleFetchers,+ subtitleFetcherOrder,+ cancellationToken).ConfigureAwait(false);if (downloaded){@@ -54,7 +62,8 @@ namespace MediaBrowser.Providers.MediaInforeturn downloadedLanguages;}- public Task<bool> DownloadSubtitles(Video video,+ public Task<bool> DownloadSubtitles(+ Video video,List<MediaStream> mediaStreams,bool skipIfEmbeddedSubtitlesPresent,bool skipIfAudioTrackMatches,@@ -90,11 +99,21 @@ namespace MediaBrowser.Providers.MediaInforeturn Task.FromResult(false);}- return DownloadSubtitles(video, mediaStreams, skipIfEmbeddedSubtitlesPresent, skipIfAudioTrackMatches,- requirePerfectMatch, lang, disabledSubtitleFetchers, subtitleFetcherOrder, mediaType, cancellationToken);+ return DownloadSubtitles(+ video,+ mediaStreams,+ skipIfEmbeddedSubtitlesPresent,+ skipIfAudioTrackMatches,+ requirePerfectMatch,+ lang,+ disabledSubtitleFetchers,+ subtitleFetcherOrder,+ mediaType,+ cancellationToken);}- private async Task<bool> DownloadSubtitles(Video video,+ private async Task<bool> DownloadSubtitles(+ Video video,List<MediaStream> mediaStreams,bool skipIfEmbeddedSubtitlesPresent,bool skipIfAudioTrackMatches,diff --git a/MediaBrowser.Providers/MediaInfo/SubtitleResolver.cs b/MediaBrowser.Providers/MediaInfo/SubtitleResolver.csindex 43659b68cc..e9f999c6d0 100644--- a/MediaBrowser.Providers/MediaInfo/SubtitleResolver.cs+++ b/MediaBrowser.Providers/MediaInfo/SubtitleResolver.cs@@ -66,9 +66,10 @@ namespace MediaBrowser.Providers.MediaInforeturn streams;}- public List<string> GetExternalSubtitleFiles(Video video,- IDirectoryService directoryService,- bool clearCache)+ public List<string> GetExternalSubtitleFiles(+ Video video,+ IDirectoryService directoryService,+ bool clearCache){var list = new List<string>();@@ -87,7 +88,9 @@ namespace MediaBrowser.Providers.MediaInforeturn list;}- private void AddExternalSubtitleStreams(List<MediaStream> streams, string folder,+ private void AddExternalSubtitleStreams(+ List<MediaStream> streams,+ string folder,string videoPath,int startIndex,IDirectoryService directoryService,@@ -98,7 +101,8 @@ namespace MediaBrowser.Providers.MediaInfoAddExternalSubtitleStreams(streams, videoPath, startIndex, files);}- public void AddExternalSubtitleStreams(List<MediaStream> streams,+ public void AddExternalSubtitleStreams(+ List<MediaStream> streams,string videoPath,int startIndex,string[] files)@@ -185,8 +189,8 @@ namespace MediaBrowser.Providers.MediaInfoprivate string NormalizeFilenameForSubtitleComparison(string filename){// Try to account for sloppy file naming- filename = filename.Replace("_", string.Empty);- filename = filename.Replace(" ", string.Empty);+ filename = filename.Replace("_", string.Empty, StringComparison.Ordinal);+ filename = filename.Replace(" ", string.Empty, StringComparison.Ordinal);// can't normalize this due to languages such as pt-br// filename = filename.Replace("-", string.Empty);diff --git a/MediaBrowser.Providers/MediaInfo/SubtitleScheduledTask.cs b/MediaBrowser.Providers/MediaInfo/SubtitleScheduledTask.csindex 91ab7b4acb..d231bfa2fc 100644--- a/MediaBrowser.Providers/MediaInfo/SubtitleScheduledTask.cs+++ b/MediaBrowser.Providers/MediaInfo/SubtitleScheduledTask.cs@@ -12,11 +12,10 @@ using MediaBrowser.Controller.Entities;using MediaBrowser.Controller.Library;using MediaBrowser.Controller.Subtitles;using MediaBrowser.Model.Entities;+using MediaBrowser.Model.Globalization;using MediaBrowser.Model.Providers;-using MediaBrowser.Model.Serialization;using MediaBrowser.Model.Tasks;using Microsoft.Extensions.Logging;-using MediaBrowser.Model.Globalization;namespace MediaBrowser.Providers.MediaInfo{@@ -25,29 +24,37 @@ namespace MediaBrowser.Providers.MediaInfoprivate readonly ILibraryManager _libraryManager;private readonly IServerConfigurationManager _config;private readonly ISubtitleManager _subtitleManager;- private readonly IMediaSourceManager _mediaSourceManager;private readonly ILogger<SubtitleScheduledTask> _logger;- private readonly IJsonSerializer _json;private readonly ILocalizationManager _localization;public SubtitleScheduledTask(ILibraryManager libraryManager,- IJsonSerializer json,IServerConfigurationManager config,ISubtitleManager subtitleManager,ILogger<SubtitleScheduledTask> logger,- IMediaSourceManager mediaSourceManager,ILocalizationManager localization){_libraryManager = libraryManager;_config = config;_subtitleManager = subtitleManager;_logger = logger;- _mediaSourceManager = mediaSourceManager;- _json = json;_localization = localization;}+ public string Name => _localization.GetLocalizedString("TaskDownloadMissingSubtitles");++ public string Description => _localization.GetLocalizedString("TaskDownloadMissingSubtitlesDescription");++ public string Category => _localization.GetLocalizedString("TasksLibraryCategory");++ public string Key => "DownloadSubtitles";++ public bool IsHidden => false;++ public bool IsEnabled => true;++ public bool IsLogged => true;+private SubtitleOptions GetOptions(){return _config.GetConfiguration<SubtitleOptions>("subtitles");@@ -66,23 +73,23 @@ namespace MediaBrowser.Providers.MediaInfovar libraryOptions = _libraryManager.GetLibraryOptions(library);string[] subtitleDownloadLanguages;- bool SkipIfEmbeddedSubtitlesPresent;- bool SkipIfAudioTrackMatches;- bool RequirePerfectMatch;+ bool skipIfEmbeddedSubtitlesPresent;+ bool skipIfAudioTrackMatches;+ bool requirePerfectMatch;if (libraryOptions.SubtitleDownloadLanguages == null){subtitleDownloadLanguages = options.DownloadLanguages;- SkipIfEmbeddedSubtitlesPresent = options.SkipIfEmbeddedSubtitlesPresent;- SkipIfAudioTrackMatches = options.SkipIfAudioTrackMatches;- RequirePerfectMatch = options.RequirePerfectMatch;+ skipIfEmbeddedSubtitlesPresent = options.SkipIfEmbeddedSubtitlesPresent;+ skipIfAudioTrackMatches = options.SkipIfAudioTrackMatches;+ requirePerfectMatch = options.RequirePerfectMatch;}else{subtitleDownloadLanguages = libraryOptions.SubtitleDownloadLanguages;- SkipIfEmbeddedSubtitlesPresent = libraryOptions.SkipSubtitlesIfEmbeddedSubtitlesPresent;- SkipIfAudioTrackMatches = libraryOptions.SkipSubtitlesIfAudioTrackMatches;- RequirePerfectMatch = libraryOptions.RequirePerfectSubtitleMatch;+ skipIfEmbeddedSubtitlesPresent = libraryOptions.SkipSubtitlesIfEmbeddedSubtitlesPresent;+ skipIfAudioTrackMatches = libraryOptions.SkipSubtitlesIfAudioTrackMatches;+ requirePerfectMatch = libraryOptions.RequirePerfectSubtitleMatch;}foreach (var lang in subtitleDownloadLanguages)@@ -98,12 +105,12 @@ namespace MediaBrowser.Providers.MediaInfoRecursive = true};- if (SkipIfAudioTrackMatches)+ if (skipIfAudioTrackMatches){query.HasNoAudioTrackWithLanguage = lang;}- if (SkipIfEmbeddedSubtitlesPresent)+ if (skipIfEmbeddedSubtitlesPresent){// Exclude if it already has any subtitles of the same languagequery.HasNoSubtitleTrackWithLanguage = lang;@@ -160,36 +167,37 @@ namespace MediaBrowser.Providers.MediaInfovar libraryOptions = _libraryManager.GetLibraryOptions(video);string[] subtitleDownloadLanguages;- bool SkipIfEmbeddedSubtitlesPresent;- bool SkipIfAudioTrackMatches;- bool RequirePerfectMatch;+ bool skipIfEmbeddedSubtitlesPresent;+ bool skipIfAudioTrackMatches;+ bool requirePerfectMatch;if (libraryOptions.SubtitleDownloadLanguages == null){subtitleDownloadLanguages = options.DownloadLanguages;- SkipIfEmbeddedSubtitlesPresent = options.SkipIfEmbeddedSubtitlesPresent;- SkipIfAudioTrackMatches = options.SkipIfAudioTrackMatches;- RequirePerfectMatch = options.RequirePerfectMatch;+ skipIfEmbeddedSubtitlesPresent = options.SkipIfEmbeddedSubtitlesPresent;+ skipIfAudioTrackMatches = options.SkipIfAudioTrackMatches;+ requirePerfectMatch = options.RequirePerfectMatch;}else{subtitleDownloadLanguages = libraryOptions.SubtitleDownloadLanguages;- SkipIfEmbeddedSubtitlesPresent = libraryOptions.SkipSubtitlesIfEmbeddedSubtitlesPresent;- SkipIfAudioTrackMatches = libraryOptions.SkipSubtitlesIfAudioTrackMatches;- RequirePerfectMatch = libraryOptions.RequirePerfectSubtitleMatch;+ skipIfEmbeddedSubtitlesPresent = libraryOptions.SkipSubtitlesIfEmbeddedSubtitlesPresent;+ skipIfAudioTrackMatches = libraryOptions.SkipSubtitlesIfAudioTrackMatches;+ requirePerfectMatch = libraryOptions.RequirePerfectSubtitleMatch;}- var downloadedLanguages = await new SubtitleDownloader(_logger,- _subtitleManager)- .DownloadSubtitles(video,- mediaStreams,- SkipIfEmbeddedSubtitlesPresent,- SkipIfAudioTrackMatches,- RequirePerfectMatch,- subtitleDownloadLanguages,- libraryOptions.DisabledSubtitleFetchers,- libraryOptions.SubtitleFetcherOrder,- cancellationToken).ConfigureAwait(false);+ var downloadedLanguages = await new SubtitleDownloader(+ _logger,+ _subtitleManager).DownloadSubtitles(+ video,+ mediaStreams,+ skipIfEmbeddedSubtitlesPresent,+ skipIfAudioTrackMatches,+ requirePerfectMatch,+ subtitleDownloadLanguages,+ libraryOptions.DisabledSubtitleFetchers,+ libraryOptions.SubtitleFetcherOrder,+ cancellationToken).ConfigureAwait(false);// Rescanif (downloadedLanguages.Count > 0)@@ -203,25 +211,11 @@ namespace MediaBrowser.Providers.MediaInfopublic IEnumerable<TaskTriggerInfo> GetDefaultTriggers(){- return new[] {-+ return new[]+ {// Every so oftennew TaskTriggerInfo { Type = TaskTriggerInfo.TriggerInterval, IntervalTicks = TimeSpan.FromHours(24).Ticks}};}-- public string Name => _localization.GetLocalizedString("TaskDownloadMissingSubtitles");-- public string Description => _localization.GetLocalizedString("TaskDownloadMissingSubtitlesDescription");-- public string Category => _localization.GetLocalizedString("TasksLibraryCategory");-- public string Key => "DownloadSubtitles";-- public bool IsHidden => false;-- public bool IsEnabled => true;-- public bool IsLogged => true;}}diff --git a/MediaBrowser.Providers/MediaInfo/VideoImageProvider.cs b/MediaBrowser.Providers/MediaInfo/VideoImageProvider.csindex e23854d900..fc38d3832a 100644--- a/MediaBrowser.Providers/MediaInfo/VideoImageProvider.cs+++ b/MediaBrowser.Providers/MediaInfo/VideoImageProvider.cs@@ -29,6 +29,11 @@ namespace MediaBrowser.Providers.MediaInfo_fileSystem = fileSystem;}+ public string Name => "Screen Grabber";++ // Make sure this comes after internet image providers+ public int Order => 100;+public IEnumerable<ImageType> GetSupportedImages(BaseItem item){return new List<ImageType> { ImageType.Primary };@@ -127,8 +132,6 @@ namespace MediaBrowser.Providers.MediaInfo};}- public string Name => "Screen Grabber";-public bool Supports(BaseItem item){if (item.IsShortcut)@@ -150,7 +153,5 @@ namespace MediaBrowser.Providers.MediaInforeturn false;}- // Make sure this comes after internet image providers- public int Order => 100;}}diff --git a/MediaBrowser.Providers/Movies/MovieExternalIds.cs b/MediaBrowser.Providers/Movies/ImdbExternalId.cssimilarity index 68%rename from MediaBrowser.Providers/Movies/MovieExternalIds.csrename to MediaBrowser.Providers/Movies/ImdbExternalId.csindex 14080841c2..a8d74aa0b5 100644--- a/MediaBrowser.Providers/Movies/MovieExternalIds.cs+++ b/MediaBrowser.Providers/Movies/ImdbExternalId.cs@@ -36,22 +36,4 @@ namespace MediaBrowser.Providers.Moviesreturn item is Movie || item is MusicVideo || item is Series || item is Episode || item is Trailer;}}-- public class ImdbPersonExternalId : IExternalId- {- /// <inheritdoc />- public string ProviderName => "IMDb";-- /// <inheritdoc />- public string Key => MetadataProvider.Imdb.ToString();-- /// <inheritdoc />- public ExternalIdMediaType? Type => ExternalIdMediaType.Person;-- /// <inheritdoc />- public string UrlFormatString => "https://www.imdb.com/name/{0}";-- /// <inheritdoc />- public bool Supports(IHasProviderIds item) => item is Person;- }}diff --git a/MediaBrowser.Providers/Movies/ImdbPersonExternalId.cs b/MediaBrowser.Providers/Movies/ImdbPersonExternalId.csnew file mode 100644index 0000000000..8151ab4715--- /dev/null+++ b/MediaBrowser.Providers/Movies/ImdbPersonExternalId.cs@@ -0,0 +1,27 @@+#pragma warning disable CS1591++using MediaBrowser.Controller.Entities;+using MediaBrowser.Controller.Providers;+using MediaBrowser.Model.Entities;+using MediaBrowser.Model.Providers;++namespace MediaBrowser.Providers.Movies+{+ public class ImdbPersonExternalId : IExternalId+ {+ /// <inheritdoc />+ public string ProviderName => "IMDb";++ /// <inheritdoc />+ public string Key => MetadataProvider.Imdb.ToString();++ /// <inheritdoc />+ public ExternalIdMediaType? Type => ExternalIdMediaType.Person;++ /// <inheritdoc />+ public string UrlFormatString => "https://www.imdb.com/name/{0}";++ /// <inheritdoc />+ public bool Supports(IHasProviderIds item) => item is Person;+ }+}diff --git a/MediaBrowser.Providers/Music/Extensions.cs b/MediaBrowser.Providers/Music/AlbumInfoExtensions.cssimilarity index 100%rename from MediaBrowser.Providers/Music/Extensions.csrename to MediaBrowser.Providers/Music/AlbumInfoExtensions.csdiff --git a/MediaBrowser.Providers/Music/MusicExternalIds.cs b/MediaBrowser.Providers/Music/ImvdbId.cssimilarity index 100%rename from MediaBrowser.Providers/Music/MusicExternalIds.csrename to MediaBrowser.Providers/Music/ImvdbId.csdiff --git a/MediaBrowser.Providers/Playlists/PlaylistItemsProvider.cs b/MediaBrowser.Providers/Playlists/PlaylistItemsProvider.csindex 5cc0a527ea..067d585cba 100644--- a/MediaBrowser.Providers/Playlists/PlaylistItemsProvider.cs+++ b/MediaBrowser.Providers/Playlists/PlaylistItemsProvider.cs@@ -10,7 +10,6 @@ using MediaBrowser.Controller.Entities;using MediaBrowser.Controller.Library;using MediaBrowser.Controller.Playlists;using MediaBrowser.Controller.Providers;-using MediaBrowser.Model.IO;using Microsoft.Extensions.Logging;using PlaylistsNET.Content;@@ -23,16 +22,17 @@ namespace MediaBrowser.Providers.PlaylistsIHasItemChangeMonitor{private readonly ILogger<PlaylistItemsProvider> _logger;- private IFileSystem _fileSystem;- public PlaylistItemsProvider(IFileSystem fileSystem, ILogger<PlaylistItemsProvider> logger)+ public PlaylistItemsProvider(ILogger<PlaylistItemsProvider> logger){- _fileSystem = fileSystem;_logger = logger;}public string Name => "Playlist Reader";+ // Run last+ public int Order => 100;+public Task<ItemUpdateType> FetchAsync(Playlist item, MetadataRefreshOptions options, CancellationToken cancellationToken){var path = item.Path;@@ -163,7 +163,5 @@ namespace MediaBrowser.Providers.Playlistsreturn false;}- // Run last- public int Order => 100;}}diff --git a/MediaBrowser.Providers/Plugins/AudioDb/ArtistProvider.cs b/MediaBrowser.Providers/Plugins/AudioDb/ArtistProvider.csindex 670c0cd05a..72dad8a25a 100644--- a/MediaBrowser.Providers/Plugins/AudioDb/ArtistProvider.cs+++ b/MediaBrowser.Providers/Plugins/AudioDb/ArtistProvider.cs@@ -23,16 +23,14 @@ namespace MediaBrowser.Providers.Plugins.AudioDb{public class AudioDbArtistProvider : IRemoteMetadataProvider<MusicArtist, ArtistInfo>, IHasOrder{+ private const string ApiKey = "195003";+ public const string BaseUrl = "https://www.theaudiodb.com/api/v1/json/" + ApiKey;+private readonly IServerConfigurationManager _config;private readonly IFileSystem _fileSystem;private readonly IHttpClientFactory _httpClientFactory;private readonly IJsonSerializer _json;- public static AudioDbArtistProvider Current;-- private const string ApiKey = "195003";- public const string BaseUrl = "https://www.theaudiodb.com/api/v1/json/" + ApiKey;-public AudioDbArtistProvider(IServerConfigurationManager config, IFileSystem fileSystem, IHttpClientFactory httpClientFactory, IJsonSerializer json){_config = config;@@ -42,6 +40,8 @@ namespace MediaBrowser.Providers.Plugins.AudioDbCurrent = this;}+ public static AudioDbArtistProvider Current { get; private set; }+/// <inheritdoc />public string Name => "TheAudioDB";diff --git a/MediaBrowser.Providers/Plugins/AudioDb/AudioDbAlbumExternalId.cs b/MediaBrowser.Providers/Plugins/AudioDb/AudioDbAlbumExternalId.csnew file mode 100644index 0000000000..138cfef19a--- /dev/null+++ b/MediaBrowser.Providers/Plugins/AudioDb/AudioDbAlbumExternalId.cs@@ -0,0 +1,27 @@+#pragma warning disable CS1591++using MediaBrowser.Controller.Entities.Audio;+using MediaBrowser.Controller.Providers;+using MediaBrowser.Model.Entities;+using MediaBrowser.Model.Providers;++namespace MediaBrowser.Providers.Plugins.AudioDb+{+ public class AudioDbAlbumExternalId : IExternalId+ {+ /// <inheritdoc />+ public string ProviderName => "TheAudioDb";++ /// <inheritdoc />+ public string Key => MetadataProvider.AudioDbAlbum.ToString();++ /// <inheritdoc />+ public ExternalIdMediaType? Type => null;++ /// <inheritdoc />+ public string UrlFormatString => "https://www.theaudiodb.com/album/{0}";++ /// <inheritdoc />+ public bool Supports(IHasProviderIds item) => item is MusicAlbum;+ }+}diff --git a/MediaBrowser.Providers/Plugins/AudioDb/AudioDbArtistExternalId.cs b/MediaBrowser.Providers/Plugins/AudioDb/AudioDbArtistExternalId.csnew file mode 100644index 0000000000..8aceb48c0c--- /dev/null+++ b/MediaBrowser.Providers/Plugins/AudioDb/AudioDbArtistExternalId.cs@@ -0,0 +1,27 @@+#pragma warning disable CS1591++using MediaBrowser.Controller.Entities.Audio;+using MediaBrowser.Controller.Providers;+using MediaBrowser.Model.Entities;+using MediaBrowser.Model.Providers;++namespace MediaBrowser.Providers.Plugins.AudioDb+{+ public class AudioDbArtistExternalId : IExternalId+ {+ /// <inheritdoc />+ public string ProviderName => "TheAudioDb";++ /// <inheritdoc />+ public string Key => MetadataProvider.AudioDbArtist.ToString();++ /// <inheritdoc />+ public ExternalIdMediaType? Type => ExternalIdMediaType.Artist;++ /// <inheritdoc />+ public string UrlFormatString => "https://www.theaudiodb.com/artist/{0}";++ /// <inheritdoc />+ public bool Supports(IHasProviderIds item) => item is MusicArtist;+ }+}diff --git a/MediaBrowser.Providers/Plugins/AudioDb/AudioDbOtherAlbumExternalId.cs b/MediaBrowser.Providers/Plugins/AudioDb/AudioDbOtherAlbumExternalId.csnew file mode 100644index 0000000000..014481da24--- /dev/null+++ b/MediaBrowser.Providers/Plugins/AudioDb/AudioDbOtherAlbumExternalId.cs@@ -0,0 +1,27 @@+#pragma warning disable CS1591++using MediaBrowser.Controller.Entities.Audio;+using MediaBrowser.Controller.Providers;+using MediaBrowser.Model.Entities;+using MediaBrowser.Model.Providers;++namespace MediaBrowser.Providers.Plugins.AudioDb+{+ public class AudioDbOtherAlbumExternalId : IExternalId+ {+ /// <inheritdoc />+ public string ProviderName => "TheAudioDb";++ /// <inheritdoc />+ public string Key => MetadataProvider.AudioDbAlbum.ToString();++ /// <inheritdoc />+ public ExternalIdMediaType? Type => ExternalIdMediaType.Album;++ /// <inheritdoc />+ public string UrlFormatString => "https://www.theaudiodb.com/album/{0}";++ /// <inheritdoc />+ public bool Supports(IHasProviderIds item) => item is Audio;+ }+}diff --git a/MediaBrowser.Providers/Plugins/AudioDb/AudioDbOtherArtistExternalId.cs b/MediaBrowser.Providers/Plugins/AudioDb/AudioDbOtherArtistExternalId.csnew file mode 100644index 0000000000..7875391043--- /dev/null+++ b/MediaBrowser.Providers/Plugins/AudioDb/AudioDbOtherArtistExternalId.cs@@ -0,0 +1,27 @@+#pragma warning disable CS1591++using MediaBrowser.Controller.Entities.Audio;+using MediaBrowser.Controller.Providers;+using MediaBrowser.Model.Entities;+using MediaBrowser.Model.Providers;++namespace MediaBrowser.Providers.Plugins.AudioDb+{+ public class AudioDbOtherArtistExternalId : IExternalId+ {+ /// <inheritdoc />+ public string ProviderName => "TheAudioDb";++ /// <inheritdoc />+ public string Key => MetadataProvider.AudioDbArtist.ToString();++ /// <inheritdoc />+ public ExternalIdMediaType? Type => ExternalIdMediaType.OtherArtist;++ /// <inheritdoc />+ public string UrlFormatString => "https://www.theaudiodb.com/artist/{0}";++ /// <inheritdoc />+ public bool Supports(IHasProviderIds item) => item is Audio || item is MusicAlbum;+ }+}diff --git a/MediaBrowser.Providers/Plugins/AudioDb/ExternalIds.cs b/MediaBrowser.Providers/Plugins/AudioDb/ExternalIds.csdeleted file mode 100644index 1cc1f0fa18..0000000000--- a/MediaBrowser.Providers/Plugins/AudioDb/ExternalIds.cs+++ /dev/null@@ -1,81 +0,0 @@-#pragma warning disable CS1591--using MediaBrowser.Controller.Entities.Audio;-using MediaBrowser.Controller.Providers;-using MediaBrowser.Model.Entities;-using MediaBrowser.Model.Providers;--namespace MediaBrowser.Providers.Plugins.AudioDb-{- public class AudioDbAlbumExternalId : IExternalId- {- /// <inheritdoc />- public string ProviderName => "TheAudioDb";-- /// <inheritdoc />- public string Key => MetadataProvider.AudioDbAlbum.ToString();-- /// <inheritdoc />- public ExternalIdMediaType? Type => null;-- /// <inheritdoc />- public string UrlFormatString => "https://www.theaudiodb.com/album/{0}";-- /// <inheritdoc />- public bool Supports(IHasProviderIds item) => item is MusicAlbum;- }-- public class AudioDbOtherAlbumExternalId : IExternalId- {- /// <inheritdoc />- public string ProviderName => "TheAudioDb";-- /// <inheritdoc />- public string Key => MetadataProvider.AudioDbAlbum.ToString();-- /// <inheritdoc />- public ExternalIdMediaType? Type => ExternalIdMediaType.Album;-- /// <inheritdoc />- public string UrlFormatString => "https://www.theaudiodb.com/album/{0}";-- /// <inheritdoc />- public bool Supports(IHasProviderIds item) => item is Audio;- }-- public class AudioDbArtistExternalId : IExternalId- {- /// <inheritdoc />- public string ProviderName => "TheAudioDb";-- /// <inheritdoc />- public string Key => MetadataProvider.AudioDbArtist.ToString();-- /// <inheritdoc />- public ExternalIdMediaType? Type => ExternalIdMediaType.Artist;-- /// <inheritdoc />- public string UrlFormatString => "https://www.theaudiodb.com/artist/{0}";-- /// <inheritdoc />- public bool Supports(IHasProviderIds item) => item is MusicArtist;- }-- public class AudioDbOtherArtistExternalId : IExternalId- {- /// <inheritdoc />- public string ProviderName => "TheAudioDb";-- /// <inheritdoc />- public string Key => MetadataProvider.AudioDbArtist.ToString();-- /// <inheritdoc />- public ExternalIdMediaType? Type => ExternalIdMediaType.OtherArtist;-- /// <inheritdoc />- public string UrlFormatString => "https://www.theaudiodb.com/artist/{0}";-- /// <inheritdoc />- public bool Supports(IHasProviderIds item) => item is Audio || item is MusicAlbum;- }-}diff --git a/MediaBrowser.Providers/Plugins/AudioDb/Plugin.cs b/MediaBrowser.Providers/Plugins/AudioDb/Plugin.csindex 54054d0153..b5bd72ff0d 100644--- a/MediaBrowser.Providers/Plugins/AudioDb/Plugin.cs+++ b/MediaBrowser.Providers/Plugins/AudioDb/Plugin.cs@@ -11,6 +11,12 @@ namespace MediaBrowser.Providers.Plugins.AudioDb{public class Plugin : BasePlugin<PluginConfiguration>, IHasWebPages{+ public Plugin(IApplicationPaths applicationPaths, IXmlSerializer xmlSerializer)+ : base(applicationPaths, xmlSerializer)+ {+ Instance = this;+ }+public static Plugin Instance { get; private set; }public override Guid Id => new Guid("a629c0da-fac5-4c7e-931a-7174223f14c8");@@ -22,12 +28,6 @@ namespace MediaBrowser.Providers.Plugins.AudioDb// TODO remove when plugin removed from server.public override string ConfigurationFileName => "Jellyfin.Plugin.AudioDb.xml";- public Plugin(IApplicationPaths applicationPaths, IXmlSerializer xmlSerializer)- : base(applicationPaths, xmlSerializer)- {- Instance = this;- }-public IEnumerable<PluginPageInfo> GetPages(){yield return new PluginPageInfodiff --git a/MediaBrowser.Providers/Plugins/MusicBrainz/AlbumProvider.cs b/MediaBrowser.Providers/Plugins/MusicBrainz/MusicBrainzAlbumProvider.cssimilarity index 98%rename from MediaBrowser.Providers/Plugins/MusicBrainz/AlbumProvider.csrename to MediaBrowser.Providers/Plugins/MusicBrainz/MusicBrainzAlbumProvider.csindex 8414c93281..46f8988f27 100644--- a/MediaBrowser.Providers/Plugins/MusicBrainz/AlbumProvider.cs+++ b/MediaBrowser.Providers/Plugins/MusicBrainz/MusicBrainzAlbumProvider.cs@@ -8,7 +8,6 @@ using System.IO;using System.Linq;using System.Net;using System.Net.Http;-using System.Net.Http.Headers;using System.Text;using System.Threading;using System.Threading.Tasks;@@ -26,14 +25,6 @@ namespace MediaBrowser.Providers.Music{public class MusicBrainzAlbumProvider : IRemoteMetadataProvider<MusicAlbum, AlbumInfo>, IHasOrder{- /// <summary>- /// The Jellyfin user-agent is unrestricted but source IP must not exceed- /// one request per second, therefore we rate limit to avoid throttling.- /// Be prudent, use a value slightly above the minimun required.- /// https://musicbrainz.org/doc/XML_Web_Service/Rate_Limiting- /// </summary>- private readonly long _musicBrainzQueryIntervalMs;-/// <summary>/// For each single MB lookup/search, this is the maximum number of/// attempts that shall be made whilst receiving a 503 Server@@ -41,7 +32,13 @@ namespace MediaBrowser.Providers.Music/// </summary>private const uint MusicBrainzQueryAttempts = 5u;- internal static MusicBrainzAlbumProvider Current;+ /// <summary>+ /// The Jellyfin user-agent is unrestricted but source IP must not exceed+ /// one request per second, therefore we rate limit to avoid throttling.+ /// Be prudent, use a value slightly above the minimun required.+ /// https://musicbrainz.org/doc/XML_Web_Service/Rate_Limiting+ /// </summary>+ private readonly long _musicBrainzQueryIntervalMs;private readonly IHttpClientFactory _httpClientFactory;private readonly IApplicationHost _appHost;@@ -69,6 +66,8 @@ namespace MediaBrowser.Providers.MusicCurrent = this;}+ internal static MusicBrainzAlbumProvider Current { get; private set; }+/// <inheritdoc />public string Name => "MusicBrainz";@@ -112,7 +111,7 @@ namespace MediaBrowser.Providers.Musicelse{// I'm sure there is a better way but for now it resolves search for 12" Mixes- var queryName = searchInfo.Name.Replace("\"", string.Empty);+ var queryName = searchInfo.Name.Replace("\"", string.Empty, StringComparison.Ordinal);url = string.Format(CultureInfo.InvariantCulture,@@ -277,7 +276,9 @@ namespace MediaBrowser.Providers.Musicprivate async Task<ReleaseResult> GetReleaseResult(string albumName, string artistId, CancellationToken cancellationToken){- var url = string.Format(CultureInfo.InvariantCulture, "/ws/2/release/?query=\"{0}\" AND arid:{1}",+ var url = string.Format(+ CultureInfo.InvariantCulture,+ "/ws/2/release/?query=\"{0}\" AND arid:{1}",WebUtility.UrlEncode(albumName),artistId);@@ -496,7 +497,7 @@ namespace MediaBrowser.Providers.Music}}- private static ValueTuple<string, string> ParseArtistCredit(XmlReader reader)+ private static (string, string) ParseArtistCredit(XmlReader reader){reader.MoveToContent();reader.Read();@@ -531,7 +532,7 @@ namespace MediaBrowser.Providers.Music}}- return new ValueTuple<string, string>();+ return default;}private static (string, string) ParseArtistNameCredit(XmlReader reader)diff --git a/MediaBrowser.Providers/Plugins/Omdb/OmdbImageProvider.cs b/MediaBrowser.Providers/Plugins/Omdb/OmdbImageProvider.csindex 8b8fea09e8..8f4240dc11 100644--- a/MediaBrowser.Providers/Plugins/Omdb/OmdbImageProvider.cs+++ b/MediaBrowser.Providers/Plugins/Omdb/OmdbImageProvider.cs@@ -36,6 +36,12 @@ namespace MediaBrowser.Providers.Plugins.Omdb_appHost = appHost;}+ public string Name => "The Open Movie Database";++ // After other internet providers, because they're better+ // But before fallback providers like screengrab+ public int Order => 90;+public IEnumerable<ImageType> GetSupportedImages(BaseItem item){return new List<ImageType>@@ -86,15 +92,9 @@ namespace MediaBrowser.Providers.Plugins.Omdbreturn _httpClientFactory.CreateClient(NamedClient.Default).GetAsync(url, cancellationToken);}- public string Name => "The Open Movie Database";-public bool Supports(BaseItem item){return item is Movie || item is Trailer || item is Episode;}-- // After other internet providers, because they're better- // But before fallback providers like screengrab- public int Order => 90;}}diff --git a/MediaBrowser.Providers/Plugins/Omdb/OmdbItemProvider.cs b/MediaBrowser.Providers/Plugins/Omdb/OmdbItemProvider.csindex d53eba7e94..705359d2c7 100644--- a/MediaBrowser.Providers/Plugins/Omdb/OmdbItemProvider.cs+++ b/MediaBrowser.Providers/Plugins/Omdb/OmdbItemProvider.cs@@ -49,6 +49,8 @@ namespace MediaBrowser.Providers.Plugins.Omdb_appHost = appHost;}+ public string Name => "The Open Movie Database";+// After primary optionpublic int Order => 2;@@ -199,8 +201,6 @@ namespace MediaBrowser.Providers.Plugins.Omdbreturn GetSearchResults(searchInfo, "movie", cancellationToken);}- public string Name => "The Open Movie Database";-public async Task<MetadataResult<Series>> GetMetadata(SeriesInfo info, CancellationToken cancellationToken){var result = new MetadataResult<Series>@@ -263,14 +263,14 @@ namespace MediaBrowser.Providers.Plugins.Omdb{var results = await GetSearchResultsInternal(info, "movie", false, cancellationToken).ConfigureAwait(false);var first = results.FirstOrDefault();- return first == null ? null : first.GetProviderId(MetadataProvider.Imdb);+ return first?.GetProviderId(MetadataProvider.Imdb);}private async Task<string> GetSeriesImdbId(SeriesInfo info, CancellationToken cancellationToken){var results = await GetSearchResultsInternal(info, "series", false, cancellationToken).ConfigureAwait(false);var first = results.FirstOrDefault();- return first == null ? null : first.GetProviderId(MetadataProvider.Imdb);+ return first?.GetProviderId(MetadataProvider.Imdb);}public Task<HttpResponseMessage> GetImageResponse(string url, CancellationToken cancellationToken)@@ -278,7 +278,7 @@ namespace MediaBrowser.Providers.Plugins.Omdbreturn _httpClientFactory.CreateClient(NamedClient.Default).GetAsync(url, cancellationToken);}- class SearchResult+ private class SearchResult{public string Title { get; set; }diff --git a/MediaBrowser.Providers/TV/DummySeasonProvider.cs b/MediaBrowser.Providers/TV/DummySeasonProvider.csindex 0c09cdef6c..a0f7f6cfd7 100644--- a/MediaBrowser.Providers/TV/DummySeasonProvider.cs+++ b/MediaBrowser.Providers/TV/DummySeasonProvider.cs@@ -124,7 +124,8 @@ namespace MediaBrowser.Providers.TV/// <summary>/// Adds the season./// </summary>- public async Task<Season> AddSeason(Series series,+ public async Task<Season> AddSeason(+ Series series,int? seasonNumber,bool isVirtualItem,CancellationToken cancellationToken)@@ -211,11 +212,14 @@ namespace MediaBrowser.Providers.TV{_logger.LogInformation("Removing virtual season {0} {1}", series.Name, seasonToRemove.IndexNumber);- _libraryManager.DeleteItem(seasonToRemove, new DeleteOptions- {- DeleteFileLocation = true+ _libraryManager.DeleteItem(+ seasonToRemove,+ new DeleteOptions+ {+ DeleteFileLocation = true- }, false);+ },+ false);hasChanges = true;}diff --git a/MediaBrowser.Providers/TV/MissingEpisodeProvider.cs b/MediaBrowser.Providers/TV/MissingEpisodeProvider.csindex 09850beb0d..616c61ec0a 100644--- a/MediaBrowser.Providers/TV/MissingEpisodeProvider.cs+++ b/MediaBrowser.Providers/TV/MissingEpisodeProvider.cs@@ -159,7 +159,7 @@ namespace MediaBrowser.Providers.TVvar now = DateTime.UtcNow.AddDays(-UnairedEpisodeThresholdDays);- if (airDate < now && addMissingEpisodes || airDate > now)+ if ((airDate < now && addMissingEpisodes) || airDate > now){// tvdb has a lot of nearly blank episodes_logger.LogInformation("Creating virtual missing/unaired episode {0} {1}x{2}", series.Name, tuple.seasonNumber, tuple.episodenumber);@@ -232,10 +232,13 @@ namespace MediaBrowser.Providers.TVforeach (var episodeToRemove in episodesToRemove){- _libraryManager.DeleteItem(episodeToRemove, new DeleteOptions- {- DeleteFileLocation = true- }, false);+ _libraryManager.DeleteItem(+ episodeToRemove,+ new DeleteOptions+ {+ DeleteFileLocation = true+ },+ false);hasChanges = true;}@@ -246,7 +249,7 @@ namespace MediaBrowser.Providers.TV/// <summary>/// Removes the obsolete or missing seasons./// </summary>- /// <param name="allRecursiveChildren"></param>+ /// <param name="allRecursiveChildren">All recursive children.</param>/// <param name="episodeLookup">The episode lookup.</param>/// <returns><see cref="bool" />.</returns>private bool RemoveObsoleteOrMissingSeasons(@@ -297,10 +300,13 @@ namespace MediaBrowser.Providers.TVforeach (var seasonToRemove in seasonsToRemove){- _libraryManager.DeleteItem(seasonToRemove, new DeleteOptions- {- DeleteFileLocation = true- }, false);+ _libraryManager.DeleteItem(+ seasonToRemove,+ new DeleteOptions+ {+ DeleteFileLocation = true+ },+ false);hasChanges = true;}@@ -354,7 +360,10 @@ namespace MediaBrowser.Providers.TV/// <param name="seasonCounts"></param>/// <param name="episodeTuple"></param>/// <returns>Episode.</returns>- private Episode GetExistingEpisode(IEnumerable<Episode> existingEpisodes, IReadOnlyDictionary<int, int> seasonCounts, (int seasonNumber, int episodeNumber, DateTime firstAired) episodeTuple)+ private Episode GetExistingEpisode(+ IEnumerable<Episode> existingEpisodes,+ IReadOnlyDictionary<int, int> seasonCounts,+ (int seasonNumber, int episodeNumber, DateTime firstAired) episodeTuple){var seasonNumber = episodeTuple.seasonNumber;var episodeNumber = episodeTuple.episodeNumber;diff --git a/MediaBrowser.Providers/TV/TvExternalIds.cs b/MediaBrowser.Providers/TV/TvExternalIds.csdeleted file mode 100644index a6040edd15..0000000000--- a/MediaBrowser.Providers/TV/TvExternalIds.cs+++ /dev/null@@ -1,82 +0,0 @@-#pragma warning disable CS1591--using MediaBrowser.Controller.Entities.TV;-using MediaBrowser.Controller.Providers;-using MediaBrowser.Model.Entities;-using MediaBrowser.Model.Providers;-using MediaBrowser.Providers.Plugins.TheTvdb;--namespace MediaBrowser.Providers.TV-{- public class Zap2ItExternalId : IExternalId- {- /// <inheritdoc />- public string ProviderName => "Zap2It";-- /// <inheritdoc />- public string Key => MetadataProvider.Zap2It.ToString();-- /// <inheritdoc />- public ExternalIdMediaType? Type => null;-- /// <inheritdoc />- public string UrlFormatString => "http://tvlistings.zap2it.com/overview.html?programSeriesId={0}";-- /// <inheritdoc />- public bool Supports(IHasProviderIds item) => item is Series;- }-- public class TvdbExternalId : IExternalId- {- /// <inheritdoc />- public string ProviderName => "TheTVDB";-- /// <inheritdoc />- public string Key => MetadataProvider.Tvdb.ToString();-- /// <inheritdoc />- public ExternalIdMediaType? Type => null;-- /// <inheritdoc />- public string UrlFormatString => TvdbUtils.TvdbBaseUrl + "?tab=series&id={0}";-- /// <inheritdoc />- public bool Supports(IHasProviderIds item) => item is Series;- }-- public class TvdbSeasonExternalId : IExternalId- {- /// <inheritdoc />- public string ProviderName => "TheTVDB";-- /// <inheritdoc />- public string Key => MetadataProvider.Tvdb.ToString();-- /// <inheritdoc />- public ExternalIdMediaType? Type => ExternalIdMediaType.Season;-- /// <inheritdoc />- public string UrlFormatString => null;-- /// <inheritdoc />- public bool Supports(IHasProviderIds item) => item is Season;- }-- public class TvdbEpisodeExternalId : IExternalId- {- /// <inheritdoc />- public string ProviderName => "TheTVDB";-- /// <inheritdoc />- public string Key => MetadataProvider.Tvdb.ToString();-- /// <inheritdoc />- public ExternalIdMediaType? Type => ExternalIdMediaType.Episode;-- /// <inheritdoc />- public string UrlFormatString => TvdbUtils.TvdbBaseUrl + "?tab=episode&id={0}";-- /// <inheritdoc />- public bool Supports(IHasProviderIds item) => item is Episode;- }-}diff --git a/MediaBrowser.Providers/TV/TvdbEpisodeExternalId.cs b/MediaBrowser.Providers/TV/TvdbEpisodeExternalId.csnew file mode 100644index 0000000000..40c5f2d785--- /dev/null+++ b/MediaBrowser.Providers/TV/TvdbEpisodeExternalId.cs@@ -0,0 +1,28 @@+#pragma warning disable CS1591++using MediaBrowser.Controller.Entities.TV;+using MediaBrowser.Controller.Providers;+using MediaBrowser.Model.Entities;+using MediaBrowser.Model.Providers;+using MediaBrowser.Providers.Plugins.TheTvdb;++namespace MediaBrowser.Providers.TV+{+ public class TvdbEpisodeExternalId : IExternalId+ {+ /// <inheritdoc />+ public string ProviderName => "TheTVDB";++ /// <inheritdoc />+ public string Key => MetadataProvider.Tvdb.ToString();++ /// <inheritdoc />+ public ExternalIdMediaType? Type => ExternalIdMediaType.Episode;++ /// <inheritdoc />+ public string UrlFormatString => TvdbUtils.TvdbBaseUrl + "?tab=episode&id={0}";++ /// <inheritdoc />+ public bool Supports(IHasProviderIds item) => item is Episode;+ }+}diff --git a/MediaBrowser.Providers/TV/TvdbExternalId.cs b/MediaBrowser.Providers/TV/TvdbExternalId.csnew file mode 100644index 0000000000..4c54de9f82--- /dev/null+++ b/MediaBrowser.Providers/TV/TvdbExternalId.cs@@ -0,0 +1,28 @@+#pragma warning disable CS1591++using MediaBrowser.Controller.Entities.TV;+using MediaBrowser.Controller.Providers;+using MediaBrowser.Model.Entities;+using MediaBrowser.Model.Providers;+using MediaBrowser.Providers.Plugins.TheTvdb;++namespace MediaBrowser.Providers.TV+{+ public class TvdbExternalId : IExternalId+ {+ /// <inheritdoc />+ public string ProviderName => "TheTVDB";++ /// <inheritdoc />+ public string Key => MetadataProvider.Tvdb.ToString();++ /// <inheritdoc />+ public ExternalIdMediaType? Type => null;++ /// <inheritdoc />+ public string UrlFormatString => TvdbUtils.TvdbBaseUrl + "?tab=series&id={0}";++ /// <inheritdoc />+ public bool Supports(IHasProviderIds item) => item is Series;+ }+}diff --git a/MediaBrowser.Providers/TV/TvdbSeasonExternalId.cs b/MediaBrowser.Providers/TV/TvdbSeasonExternalId.csnew file mode 100644index 0000000000..807ebb3eee--- /dev/null+++ b/MediaBrowser.Providers/TV/TvdbSeasonExternalId.cs@@ -0,0 +1,28 @@+#pragma warning disable CS1591++using MediaBrowser.Controller.Entities.TV;+using MediaBrowser.Controller.Providers;+using MediaBrowser.Model.Entities;+using MediaBrowser.Model.Providers;+using MediaBrowser.Providers.Plugins.TheTvdb;++namespace MediaBrowser.Providers.TV+{+ public class TvdbSeasonExternalId : IExternalId+ {+ /// <inheritdoc />+ public string ProviderName => "TheTVDB";++ /// <inheritdoc />+ public string Key => MetadataProvider.Tvdb.ToString();++ /// <inheritdoc />+ public ExternalIdMediaType? Type => ExternalIdMediaType.Season;++ /// <inheritdoc />+ public string UrlFormatString => null;++ /// <inheritdoc />+ public bool Supports(IHasProviderIds item) => item is Season;+ }+}diff --git a/MediaBrowser.Providers/TV/Zap2ItExternalId.cs b/MediaBrowser.Providers/TV/Zap2ItExternalId.csnew file mode 100644index 0000000000..c9f314af94--- /dev/null+++ b/MediaBrowser.Providers/TV/Zap2ItExternalId.cs@@ -0,0 +1,28 @@+#pragma warning disable CS1591++using MediaBrowser.Controller.Entities.TV;+using MediaBrowser.Controller.Providers;+using MediaBrowser.Model.Entities;+using MediaBrowser.Model.Providers;+using MediaBrowser.Providers.Plugins.TheTvdb;++namespace MediaBrowser.Providers.TV+{+ public class Zap2ItExternalId : IExternalId+ {+ /// <inheritdoc />+ public string ProviderName => "Zap2It";++ /// <inheritdoc />+ public string Key => MetadataProvider.Zap2It.ToString();++ /// <inheritdoc />+ public ExternalIdMediaType? Type => null;++ /// <inheritdoc />+ public string UrlFormatString => "http://tvlistings.zap2it.com/overview.html?programSeriesId={0}";++ /// <inheritdoc />+ public bool Supports(IHasProviderIds item) => item is Series;+ }+}