Merge pull request #2549 from dkanada/refactor

Refactor some provider classes
This commit is contained in:
dkanada 2020-03-18 17:43:15 +09:00 committed by GitHub
commit a96c0a72b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
55 changed files with 146 additions and 205 deletions

View File

@ -99,8 +99,8 @@ using MediaBrowser.Model.Tasks;
using MediaBrowser.Model.Updates;
using MediaBrowser.Providers.Chapters;
using MediaBrowser.Providers.Manager;
using MediaBrowser.Providers.Plugins.TheTvdb;
using MediaBrowser.Providers.Subtitles;
using MediaBrowser.Providers.TV.TheTVDB;
using MediaBrowser.WebDashboard.Api;
using MediaBrowser.XbmcMetadata.Providers;
using Microsoft.AspNetCore.Http;
@ -666,7 +666,7 @@ namespace Emby.Server.Implementations
serviceCollection.AddSingleton<ILogger>(Logger);
serviceCollection.AddSingleton(FileSystemManager);
serviceCollection.AddSingleton<TvDbClientManager>();
serviceCollection.AddSingleton<TvdbClientManager>();
HttpClient = new HttpClientManager.HttpClientManager(
ApplicationPaths,

View File

@ -64,7 +64,7 @@ namespace MediaBrowser.Controller.Channels
/// </summary>
/// <param name="type">The type.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task{DynamicImageInfo}.</returns>
/// <returns>Task{DynamicImageResponse}.</returns>
Task<DynamicImageResponse> GetChannelImage(ImageType type, CancellationToken cancellationToken);
/// <summary>

View File

@ -2190,13 +2190,9 @@ namespace MediaBrowser.Controller.Entities
/// <summary>
/// Do whatever refreshing is necessary when the filesystem pertaining to this item has changed.
/// </summary>
/// <returns>Task.</returns>
public virtual void ChangedExternally()
{
ProviderManager.QueueRefresh(Id, new MetadataRefreshOptions(new DirectoryService(FileSystem))
{
}, RefreshPriority.High);
ProviderManager.QueueRefresh(Id, new MetadataRefreshOptions(new DirectoryService(FileSystem)), RefreshPriority.High);
}
/// <summary>
@ -2227,7 +2223,6 @@ namespace MediaBrowser.Controller.Entities
existingImage.Width = image.Width;
existingImage.Height = image.Height;
}
else
{
var current = ImageInfos;
@ -2270,7 +2265,6 @@ namespace MediaBrowser.Controller.Entities
/// </summary>
/// <param name="type">The type.</param>
/// <param name="index">The index.</param>
/// <returns>Task.</returns>
public void DeleteImage(ImageType type, int index)
{
var info = GetImageInfo(type, index);
@ -2308,7 +2302,7 @@ namespace MediaBrowser.Controller.Entities
}
/// <summary>
/// Validates that images within the item are still on the file system
/// Validates that images within the item are still on the filesystem.
/// </summary>
public bool ValidateImages(IDirectoryService directoryService)
{
@ -2602,7 +2596,7 @@ namespace MediaBrowser.Controller.Entities
}
/// <summary>
/// This is called before any metadata refresh and returns true or false indicating if changes were made
/// This is called before any metadata refresh and returns true if changes were made.
/// </summary>
public virtual bool BeforeMetadataRefresh(bool replaceAllMetdata)
{
@ -2662,36 +2656,43 @@ namespace MediaBrowser.Controller.Entities
newOptions.ForceSave = true;
ownedItem.Genres = item.Genres;
}
if (!item.Studios.SequenceEqual(ownedItem.Studios, StringComparer.Ordinal))
{
newOptions.ForceSave = true;
ownedItem.Studios = item.Studios;
}
if (!item.ProductionLocations.SequenceEqual(ownedItem.ProductionLocations, StringComparer.Ordinal))
{
newOptions.ForceSave = true;
ownedItem.ProductionLocations = item.ProductionLocations;
}
if (item.CommunityRating != ownedItem.CommunityRating)
{
ownedItem.CommunityRating = item.CommunityRating;
newOptions.ForceSave = true;
}
if (item.CriticRating != ownedItem.CriticRating)
{
ownedItem.CriticRating = item.CriticRating;
newOptions.ForceSave = true;
}
if (!string.Equals(item.Overview, ownedItem.Overview, StringComparison.Ordinal))
{
ownedItem.Overview = item.Overview;
newOptions.ForceSave = true;
}
if (!string.Equals(item.OfficialRating, ownedItem.OfficialRating, StringComparison.Ordinal))
{
ownedItem.OfficialRating = item.OfficialRating;
newOptions.ForceSave = true;
}
if (!string.Equals(item.CustomRating, ownedItem.CustomRating, StringComparison.Ordinal))
{
ownedItem.CustomRating = item.CustomRating;
@ -2900,11 +2901,17 @@ namespace MediaBrowser.Controller.Entities
}
public virtual bool IsHD => Height >= 720;
public bool IsShortcut { get; set; }
public string ShortcutPath { get; set; }
public int Width { get; set; }
public int Height { get; set; }
public Guid[] ExtraIds { get; set; }
public virtual long GetRunTimeTicksForPlayState()
{
return RunTimeTicks ?? 0;

View File

@ -13,8 +13,10 @@ namespace MediaBrowser.Controller.Entities
[JsonIgnore]
public string SeriesPresentationUniqueKey { get; set; }
[JsonIgnore]
public string SeriesName { get; set; }
[JsonIgnore]
public Guid SeriesId { get; set; }
@ -22,10 +24,12 @@ namespace MediaBrowser.Controller.Entities
{
return SeriesName;
}
public string FindSeriesName()
{
return SeriesName;
}
public string FindSeriesPresentationUniqueKey()
{
return SeriesPresentationUniqueKey;

View File

@ -16,6 +16,7 @@ namespace MediaBrowser.Controller.Providers
/// </summary>
/// <value>The artist provider ids.</value>
public Dictionary<string, string> ArtistProviderIds { get; set; }
public List<SongInfo> SongInfos { get; set; }
public AlbumInfo()

View File

@ -2,6 +2,5 @@ namespace MediaBrowser.Controller.Providers
{
public class BoxSetInfo : ItemLookupInfo
{
}
}

View File

@ -26,7 +26,6 @@ namespace MediaBrowser.Controller.Providers
{
entries = _fileSystem.GetFileSystemEntries(path).ToArray();
//_cache.TryAdd(path, entries);
_cache[path] = entries;
}
@ -56,7 +55,6 @@ namespace MediaBrowser.Controller.Providers
if (file != null && file.Exists)
{
//_fileCache.TryAdd(path, file);
_fileCache[path] = file;
}
else
@ -66,7 +64,6 @@ namespace MediaBrowser.Controller.Providers
}
return file;
//return _fileSystem.GetFileInfo(path);
}
public List<string> GetFilePaths(string path)

View File

@ -1,10 +0,0 @@
using MediaBrowser.Model.Entities;
namespace MediaBrowser.Controller.Providers
{
public class DynamicImageInfo
{
public string ImageId { get; set; }
public ImageType Type { get; set; }
}
}

View File

@ -8,9 +8,13 @@ namespace MediaBrowser.Controller.Providers
public class DynamicImageResponse
{
public string Path { get; set; }
public MediaProtocol Protocol { get; set; }
public Stream Stream { get; set; }
public ImageFormat Format { get; set; }
public bool HasImage { get; set; }
public void SetFormatFromMimeType(string mimeType)

View File

@ -10,6 +10,7 @@ namespace MediaBrowser.Controller.Providers
public int? IndexNumberEnd { get; set; }
public bool IsMissingEpisode { get; set; }
public string SeriesDisplayOrder { get; set; }
public EpisodeInfo()

View File

@ -1,15 +0,0 @@
using MediaBrowser.Model.Entities;
namespace MediaBrowser.Controller.Providers
{
public class ExtraInfo
{
public string Path { get; set; }
public LocationType LocationType { get; set; }
public bool IsDownloadable { get; set; }
public ExtraType ExtraType { get; set; }
}
}

View File

@ -1,9 +0,0 @@
namespace MediaBrowser.Controller.Providers
{
public enum ExtraSource
{
Local = 1,
Metadata = 2,
Remote = 3
}
}

View File

@ -13,7 +13,7 @@ namespace MediaBrowser.Controller.Providers
where TItemType : BaseItem
{
/// <summary>
/// Fetches the asynchronous.
/// Fetches the metadata asynchronously.
/// </summary>
/// <param name="item">The item.</param>
/// <param name="options">The options.</param>

View File

@ -6,10 +6,13 @@ namespace MediaBrowser.Controller.Providers
public interface IDirectoryService
{
FileSystemMetadata[] GetFileSystemEntries(string path);
List<FileSystemMetadata> GetFiles(string path);
FileSystemMetadata GetFile(string path);
List<string> GetFilePaths(string path);
List<string> GetFilePaths(string path, bool clearCache);
}
}

View File

@ -1,20 +0,0 @@
using MediaBrowser.Controller.Entities;
namespace MediaBrowser.Controller.Providers
{
public interface IExtrasProvider
{
/// <summary>
/// Gets the name.
/// </summary>
/// <value>The name.</value>
string Name { get; }
/// <summary>
/// Supportses the specified item.
/// </summary>
/// <param name="item">The item.</param>
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
bool Supports(BaseItem item);
}
}

View File

@ -1,7 +1,7 @@
namespace MediaBrowser.Controller.Providers
{
/// <summary>
/// This is a marker interface that will cause a provider to run even if IsLocked=true
/// This is a marker interface that will cause a provider to run even if an item is locked from changes.
/// </summary>
public interface IForcedProvider
{

View File

@ -3,7 +3,7 @@ using MediaBrowser.Controller.Entities;
namespace MediaBrowser.Controller.Providers
{
/// <summary>
/// Interface IImageProvider
/// Interface IImageProvider.
/// </summary>
public interface IImageProvider
{
@ -14,10 +14,10 @@ namespace MediaBrowser.Controller.Providers
string Name { get; }
/// <summary>
/// Supportses the specified item.
/// Supports the specified item.
/// </summary>
/// <param name="item">The item.</param>
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns>
/// <returns><c>true</c> if the provider supports the item.</returns>
bool Supports(BaseItem item);
}
}

View File

@ -1,10 +0,0 @@
using System.Collections.Generic;
using MediaBrowser.Controller.Entities;
namespace MediaBrowser.Controller.Providers
{
public interface ILocalImageFileProvider : ILocalImageProvider
{
List<LocalImageInfo> GetImages(BaseItem item, IDirectoryService directoryService);
}
}

View File

@ -1,9 +1,13 @@
using System.Collections.Generic;
using MediaBrowser.Controller.Entities;
namespace MediaBrowser.Controller.Providers
{
/// <summary>
/// This is just a marker interface
/// This is just a marker interface.
/// </summary>
public interface ILocalImageProvider : IImageProvider
{
List<LocalImageInfo> GetImages(BaseItem item, IDirectoryService directoryService);
}
}

View File

@ -17,8 +17,9 @@ namespace MediaBrowser.Controller.Providers
/// <param name="info">The information.</param>
/// <param name="directoryService">The directory service.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task{MetadataResult{`0}}.</returns>
Task<MetadataResult<TItemType>> GetMetadata(ItemInfo info,
/// <returns>Task{MetadataResult{0}}.</returns>
Task<MetadataResult<TItemType>> GetMetadata(
ItemInfo info,
IDirectoryService directoryService,
CancellationToken cancellationToken);
}

View File

@ -12,8 +12,9 @@ namespace MediaBrowser.Controller.Providers
/// Determines whether this instance can refresh the specified item.
/// </summary>
/// <param name="item">The item.</param>
/// <returns><c>true</c> if this instance can refresh the specified item; otherwise, <c>false</c>.</returns>
/// <returns><c>true</c> if this instance can refresh the specified item.</returns>
bool CanRefresh(BaseItem item);
bool CanRefreshPrimary(Type type);
/// <summary>

View File

@ -2,6 +2,5 @@ namespace MediaBrowser.Controller.Providers
{
public interface IPreRefreshProvider : ICustomMetadataProvider
{
}
}

View File

@ -14,7 +14,7 @@ using MediaBrowser.Model.Providers;
namespace MediaBrowser.Controller.Providers
{
/// <summary>
/// Interface IProviderManager
/// Interface IProviderManager.
/// </summary>
public interface IProviderManager
{
@ -159,13 +159,17 @@ namespace MediaBrowser.Controller.Providers
Dictionary<Guid, Guid> GetRefreshQueue();
void OnRefreshStart(BaseItem item);
void OnRefreshProgress(BaseItem item, double progress);
void OnRefreshComplete(BaseItem item);
double? GetRefreshProgress(Guid id);
event EventHandler<GenericEventArgs<BaseItem>> RefreshStarted;
event EventHandler<GenericEventArgs<BaseItem>> RefreshCompleted;
event EventHandler<GenericEventArgs<Tuple<BaseItem, double>>> RefreshProgress;
}

View File

@ -9,7 +9,7 @@ using MediaBrowser.Model.Providers;
namespace MediaBrowser.Controller.Providers
{
/// <summary>
/// Interface IImageProvider
/// Interface IImageProvider.
/// </summary>
public interface IRemoteImageProvider : IImageProvider
{

View File

@ -23,10 +23,15 @@ namespace MediaBrowser.Controller.Providers
}
public Type ItemType { get; set; }
public string Path { get; set; }
public string ContainingFolderPath { get; set; }
public VideoType VideoType { get; set; }
public bool IsInMixedFolder { get; set; }
public bool IsPlaceHolder { get; set; }
}
}

View File

@ -11,29 +11,37 @@ namespace MediaBrowser.Controller.Providers
/// </summary>
/// <value>The name.</value>
public string Name { get; set; }
/// <summary>
/// Gets or sets the metadata language.
/// </summary>
/// <value>The metadata language.</value>
public string MetadataLanguage { get; set; }
/// <summary>
/// Gets or sets the metadata country code.
/// </summary>
/// <value>The metadata country code.</value>
public string MetadataCountryCode { get; set; }
/// <summary>
/// Gets or sets the provider ids.
/// </summary>
/// <value>The provider ids.</value>
public Dictionary<string, string> ProviderIds { get; set; }
/// <summary>
/// Gets or sets the year.
/// </summary>
/// <value>The year.</value>
public int? Year { get; set; }
public int? IndexNumber { get; set; }
public int? ParentIndexNumber { get; set; }
public DateTime? PremiereDate { get; set; }
public bool IsAutomated { get; set; }
public ItemLookupInfo()

View File

@ -6,6 +6,7 @@ namespace MediaBrowser.Controller.Providers
public class LocalImageInfo
{
public FileSystemMetadata FileInfo { get; set; }
public ImageType Type { get; set; }
}
}

View File

@ -1,39 +0,0 @@
namespace MediaBrowser.Controller.Providers
{
/// <summary>
/// Determines when a provider should execute, relative to others
/// </summary>
public enum MetadataProviderPriority
{
// Run this provider at the beginning
/// <summary>
/// The first
/// </summary>
First = 1,
// Run this provider after all first priority providers
/// <summary>
/// The second
/// </summary>
Second = 2,
// Run this provider after all second priority providers
/// <summary>
/// The third
/// </summary>
Third = 3,
/// <summary>
/// The fourth
/// </summary>
Fourth = 4,
Fifth = 5,
// Run this provider last
/// <summary>
/// The last
/// </summary>
Last = 999
}
}

View File

@ -13,11 +13,13 @@ namespace MediaBrowser.Controller.Providers
public bool ReplaceAllMetadata { get; set; }
public MetadataRefreshMode MetadataRefreshMode { get; set; }
public RemoteSearchResult SearchResult { get; set; }
public string[] RefreshPaths { get; set; }
public bool ForceSave { get; set; }
public bool EnableRemoteContentProbe { get; set; }
public MetadataRefreshOptions(IDirectoryService directoryService)

View File

@ -8,6 +8,7 @@ namespace MediaBrowser.Controller.Providers
public class MetadataResult<T>
{
public List<LocalImageInfo> Images { get; set; }
public List<UserItemData> UserDataList { get; set; }
public MetadataResult()
@ -19,10 +20,15 @@ namespace MediaBrowser.Controller.Providers
public List<PersonInfo> People { get; set; }
public bool HasMetadata { get; set; }
public T Item { get; set; }
public string ResultLanguage { get; set; }
public string Provider { get; set; }
public bool QueriedById { get; set; }
public void AddPerson(PersonInfo p)
{
if (People == null)

View File

@ -2,6 +2,5 @@ namespace MediaBrowser.Controller.Providers
{
public class MovieInfo : ItemLookupInfo
{
}
}

View File

@ -2,6 +2,5 @@ namespace MediaBrowser.Controller.Providers
{
public class PersonLookupInfo : ItemLookupInfo
{
}
}

View File

@ -10,14 +10,14 @@ namespace MediaBrowser.Controller.Providers
public Guid ItemId { get; set; }
/// <summary>
/// If set will only search within the given provider
/// Will only search within the given provider when set.
/// </summary>
public string SearchProviderName { get; set; }
/// <summary>
/// Gets or sets a value indicating whether [include disabled providers].
/// Gets or sets a value indicating whether disabled providers should be included.
/// </summary>
/// <value><c>true</c> if [include disabled providers]; otherwise, <c>false</c>.</value>
/// <value><c>true</c> if disabled providers should be included.</value>
public bool IncludeDisabledProviders { get; set; }
}
}

View File

@ -5,7 +5,7 @@ using MediaBrowser.Model.IO;
namespace MediaBrowser.LocalMetadata.Images
{
public class CollectionFolderLocalImageProvider : ILocalImageFileProvider, IHasOrder
public class CollectionFolderLocalImageProvider : ILocalImageProvider, IHasOrder
{
private readonly IFileSystem _fileSystem;

View File

@ -10,7 +10,7 @@ using MediaBrowser.Model.IO;
namespace MediaBrowser.LocalMetadata.Images
{
public class EpisodeLocalLocalImageProvider : ILocalImageFileProvider, IHasOrder
public class EpisodeLocalLocalImageProvider : ILocalImageProvider, IHasOrder
{
private readonly IFileSystem _fileSystem;

View File

@ -9,7 +9,7 @@ using Microsoft.Extensions.Logging;
namespace MediaBrowser.LocalMetadata.Images
{
public class InternalMetadataFolderImageProvider : ILocalImageFileProvider, IHasOrder
public class InternalMetadataFolderImageProvider : ILocalImageProvider, IHasOrder
{
private readonly IServerConfigurationManager _config;
private readonly IFileSystem _fileSystem;

View File

@ -13,7 +13,7 @@ using MediaBrowser.Model.IO;
namespace MediaBrowser.LocalMetadata.Images
{
public class LocalImageProvider : ILocalImageFileProvider, IHasOrder
public class LocalImageProvider : ILocalImageProvider, IHasOrder
{
private readonly IFileSystem _fileSystem;
@ -30,7 +30,7 @@ namespace MediaBrowser.LocalMetadata.Images
{
if (item.SupportsLocalMetadata)
{
// Episode has it's own provider
// Episode has its own provider
if (item is Episode || item is Audio || item is Photo)
{
return false;

View File

@ -44,6 +44,7 @@ namespace MediaBrowser.Model.Entities
/// The box.
/// </summary>
Box = 7,
/// <summary>
/// The screenshot.
/// </summary>

View File

@ -39,7 +39,7 @@ namespace MediaBrowser.Providers.Manager
if (!(item is Photo))
{
var images = providers.OfType<ILocalImageFileProvider>()
var images = providers.OfType<ILocalImageProvider>()
.SelectMany(i => i.GetImages(item, directoryService))
.ToList();

View File

@ -606,7 +606,6 @@ namespace MediaBrowser.Providers.Manager
// Run custom refresh providers if they report a change or any remote providers change
return anyRemoteProvidersChanged || providersWithChanges.Contains(i);
}).ToList();
}
}

View File

@ -11,10 +11,9 @@ using MediaBrowser.Model.Entities;
using MediaBrowser.Model.IO;
using MediaBrowser.Model.Providers;
using MediaBrowser.Model.Serialization;
using MediaBrowser.Providers.Omdb;
using Microsoft.Extensions.Logging;
namespace MediaBrowser.Providers.TV.Omdb
namespace MediaBrowser.Providers.Plugins.Omdb
{
public class OmdbEpisodeProvider :
IRemoteMetadataProvider<Episode, EpisodeInfo>,

View File

@ -13,7 +13,7 @@ using MediaBrowser.Model.IO;
using MediaBrowser.Model.Providers;
using MediaBrowser.Model.Serialization;
namespace MediaBrowser.Providers.Omdb
namespace MediaBrowser.Providers.Plugins.Omdb
{
public class OmdbImageProvider : IRemoteImageProvider, IHasOrder
{

View File

@ -19,7 +19,7 @@ using MediaBrowser.Model.Providers;
using MediaBrowser.Model.Serialization;
using Microsoft.Extensions.Logging;
namespace MediaBrowser.Providers.Omdb
namespace MediaBrowser.Providers.Plugins.Omdb
{
public class OmdbItemProvider : IRemoteMetadataProvider<Series, SeriesInfo>,
IRemoteMetadataProvider<Movie, MovieInfo>, IRemoteMetadataProvider<Trailer, TrailerInfo>, IHasOrder

View File

@ -16,7 +16,7 @@ using MediaBrowser.Model.Entities;
using MediaBrowser.Model.IO;
using MediaBrowser.Model.Serialization;
namespace MediaBrowser.Providers.Omdb
namespace MediaBrowser.Providers.Plugins.Omdb
{
public class OmdbProvider
{

View File

@ -10,9 +10,9 @@ using Microsoft.Extensions.Caching.Memory;
using TvDbSharper;
using TvDbSharper.Dto;
namespace MediaBrowser.Providers.TV.TheTVDB
namespace MediaBrowser.Providers.Plugins.TheTvdb
{
public class TvDbClientManager
public class TvdbClientManager
{
private const string DefaultLanguage = "en";
@ -21,7 +21,7 @@ namespace MediaBrowser.Providers.TV.TheTVDB
private readonly TvDbClient _tvDbClient;
private DateTime _tokenCreatedAt;
public TvDbClientManager(IMemoryCache memoryCache)
public TvdbClientManager(IMemoryCache memoryCache)
{
_cache = memoryCache;
_tvDbClient = new TvDbClient();

View File

@ -12,19 +12,19 @@ using Microsoft.Extensions.Logging;
using TvDbSharper;
using TvDbSharper.Dto;
namespace MediaBrowser.Providers.TV.TheTVDB
namespace MediaBrowser.Providers.Plugins.TheTvdb
{
public class TvdbEpisodeImageProvider : IRemoteImageProvider
{
private readonly IHttpClient _httpClient;
private readonly ILogger _logger;
private readonly TvDbClientManager _tvDbClientManager;
private readonly TvdbClientManager _tvdbClientManager;
public TvdbEpisodeImageProvider(IHttpClient httpClient, ILogger<TvdbEpisodeImageProvider> logger, TvDbClientManager tvDbClientManager)
public TvdbEpisodeImageProvider(IHttpClient httpClient, ILogger<TvdbEpisodeImageProvider> logger, TvdbClientManager tvdbClientManager)
{
_httpClient = httpClient;
_logger = logger;
_tvDbClientManager = tvDbClientManager;
_tvdbClientManager = tvdbClientManager;
}
public string Name => "TheTVDB";
@ -60,7 +60,7 @@ namespace MediaBrowser.Providers.TV.TheTVDB
SeriesProviderIds = series.ProviderIds,
SeriesDisplayOrder = series.DisplayOrder
};
string episodeTvdbId = await _tvDbClientManager
string episodeTvdbId = await _tvdbClientManager
.GetEpisodeTvdbId(episodeInfo, language, cancellationToken).ConfigureAwait(false);
if (string.IsNullOrEmpty(episodeTvdbId))
{
@ -73,7 +73,7 @@ namespace MediaBrowser.Providers.TV.TheTVDB
}
var episodeResult =
await _tvDbClientManager
await _tvdbClientManager
.GetEpisodesAsync(Convert.ToInt32(episodeTvdbId), language, cancellationToken)
.ConfigureAwait(false);

View File

@ -12,7 +12,7 @@ using Microsoft.Extensions.Logging;
using TvDbSharper;
using TvDbSharper.Dto;
namespace MediaBrowser.Providers.TV.TheTVDB
namespace MediaBrowser.Providers.Plugins.TheTvdb
{
/// <summary>
@ -22,13 +22,13 @@ namespace MediaBrowser.Providers.TV.TheTVDB
{
private readonly IHttpClient _httpClient;
private readonly ILogger _logger;
private readonly TvDbClientManager _tvDbClientManager;
private readonly TvdbClientManager _tvdbClientManager;
public TvdbEpisodeProvider(IHttpClient httpClient, ILogger<TvdbEpisodeProvider> logger, TvDbClientManager tvDbClientManager)
public TvdbEpisodeProvider(IHttpClient httpClient, ILogger<TvdbEpisodeProvider> logger, TvdbClientManager tvdbClientManager)
{
_httpClient = httpClient;
_logger = logger;
_tvDbClientManager = tvDbClientManager;
_tvdbClientManager = tvdbClientManager;
}
public async Task<IEnumerable<RemoteSearchResult>> GetSearchResults(EpisodeInfo searchInfo, CancellationToken cancellationToken)
@ -99,7 +99,7 @@ namespace MediaBrowser.Providers.TV.TheTVDB
string episodeTvdbId = null;
try
{
episodeTvdbId = await _tvDbClientManager
episodeTvdbId = await _tvdbClientManager
.GetEpisodeTvdbId(searchInfo, searchInfo.MetadataLanguage, cancellationToken)
.ConfigureAwait(false);
if (string.IsNullOrEmpty(episodeTvdbId))
@ -109,7 +109,7 @@ namespace MediaBrowser.Providers.TV.TheTVDB
return result;
}
var episodeResult = await _tvDbClientManager.GetEpisodesAsync(
var episodeResult = await _tvdbClientManager.GetEpisodesAsync(
Convert.ToInt32(episodeTvdbId), searchInfo.MetadataLanguage,
cancellationToken).ConfigureAwait(false);

View File

@ -11,25 +11,24 @@ using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Providers;
using MediaBrowser.Providers.TV.TheTVDB;
using Microsoft.Extensions.Logging;
using TvDbSharper;
namespace MediaBrowser.Providers.People
namespace MediaBrowser.Providers.Plugins.TheTvdb
{
public class TvdbPersonImageProvider : IRemoteImageProvider, IHasOrder
{
private readonly IHttpClient _httpClient;
private readonly ILogger _logger;
private readonly ILibraryManager _libraryManager;
private readonly TvDbClientManager _tvDbClientManager;
private readonly TvdbClientManager _tvdbClientManager;
public TvdbPersonImageProvider(ILibraryManager libraryManager, IHttpClient httpClient, ILogger<TvdbPersonImageProvider> logger, TvDbClientManager tvDbClientManager)
public TvdbPersonImageProvider(ILibraryManager libraryManager, IHttpClient httpClient, ILogger<TvdbPersonImageProvider> logger, TvdbClientManager tvdbClientManager)
{
_libraryManager = libraryManager;
_httpClient = httpClient;
_logger = logger;
_tvDbClientManager = tvDbClientManager;
_tvdbClientManager = tvdbClientManager;
}
/// <inheritdoc />
@ -78,7 +77,7 @@ namespace MediaBrowser.Providers.People
try
{
var actorsResult = await _tvDbClientManager
var actorsResult = await _tvdbClientManager
.GetActorsAsync(tvdbId, series.GetPreferredMetadataLanguage(), cancellationToken)
.ConfigureAwait(false);
var actor = actorsResult.Data.FirstOrDefault(a =>

View File

@ -14,19 +14,19 @@ using TvDbSharper;
using TvDbSharper.Dto;
using RatingType = MediaBrowser.Model.Dto.RatingType;
namespace MediaBrowser.Providers.TV.TheTVDB
namespace MediaBrowser.Providers.Plugins.TheTvdb
{
public class TvdbSeasonImageProvider : IRemoteImageProvider, IHasOrder
{
private readonly IHttpClient _httpClient;
private readonly ILogger _logger;
private readonly TvDbClientManager _tvDbClientManager;
private readonly TvdbClientManager _tvdbClientManager;
public TvdbSeasonImageProvider(IHttpClient httpClient, ILogger<TvdbSeasonImageProvider> logger, TvDbClientManager tvDbClientManager)
public TvdbSeasonImageProvider(IHttpClient httpClient, ILogger<TvdbSeasonImageProvider> logger, TvdbClientManager tvdbClientManager)
{
_httpClient = httpClient;
_logger = logger;
_tvDbClientManager = tvDbClientManager;
_tvdbClientManager = tvdbClientManager;
}
public string Name => ProviderName;
@ -73,7 +73,7 @@ namespace MediaBrowser.Providers.TV.TheTVDB
};
try
{
var imageResults = await _tvDbClientManager
var imageResults = await _tvdbClientManager
.GetImagesAsync(tvdbId, imageQuery, language, cancellationToken).ConfigureAwait(false);
remoteImages.AddRange(GetImages(imageResults.Data, language));
}
@ -89,7 +89,7 @@ namespace MediaBrowser.Providers.TV.TheTVDB
private IEnumerable<RemoteImageInfo> GetImages(Image[] images, string preferredLanguage)
{
var list = new List<RemoteImageInfo>();
var languages = _tvDbClientManager.GetLanguagesAsync(CancellationToken.None).Result.Data;
var languages = _tvdbClientManager.GetLanguagesAsync(CancellationToken.None).Result.Data;
foreach (Image image in images)
{
var imageInfo = new RemoteImageInfo

View File

@ -14,19 +14,19 @@ using TvDbSharper.Dto;
using RatingType = MediaBrowser.Model.Dto.RatingType;
using Series = MediaBrowser.Controller.Entities.TV.Series;
namespace MediaBrowser.Providers.TV.TheTVDB
namespace MediaBrowser.Providers.Plugins.TheTvdb
{
public class TvdbSeriesImageProvider : IRemoteImageProvider, IHasOrder
{
private readonly IHttpClient _httpClient;
private readonly ILogger _logger;
private readonly TvDbClientManager _tvDbClientManager;
private readonly TvdbClientManager _tvdbClientManager;
public TvdbSeriesImageProvider(IHttpClient httpClient, ILogger<TvdbSeriesImageProvider> logger, TvDbClientManager tvDbClientManager)
public TvdbSeriesImageProvider(IHttpClient httpClient, ILogger<TvdbSeriesImageProvider> logger, TvdbClientManager tvdbClientManager)
{
_httpClient = httpClient;
_logger = logger;
_tvDbClientManager = tvDbClientManager;
_tvdbClientManager = tvdbClientManager;
}
public string Name => ProviderName;
@ -68,7 +68,7 @@ namespace MediaBrowser.Providers.TV.TheTVDB
try
{
var imageResults =
await _tvDbClientManager.GetImagesAsync(tvdbId, imageQuery, language, cancellationToken)
await _tvdbClientManager.GetImagesAsync(tvdbId, imageQuery, language, cancellationToken)
.ConfigureAwait(false);
remoteImages.AddRange(GetImages(imageResults.Data, language));
@ -85,7 +85,7 @@ namespace MediaBrowser.Providers.TV.TheTVDB
private IEnumerable<RemoteImageInfo> GetImages(Image[] images, string preferredLanguage)
{
var list = new List<RemoteImageInfo>();
var languages = _tvDbClientManager.GetLanguagesAsync(CancellationToken.None).Result.Data;
var languages = _tvdbClientManager.GetLanguagesAsync(CancellationToken.None).Result.Data;
foreach (Image image in images)
{

View File

@ -17,7 +17,7 @@ using TvDbSharper;
using TvDbSharper.Dto;
using Series = MediaBrowser.Controller.Entities.TV.Series;
namespace MediaBrowser.Providers.TV.TheTVDB
namespace MediaBrowser.Providers.Plugins.TheTvdb
{
public class TvdbSeriesProvider : IRemoteMetadataProvider<Series, SeriesInfo>, IHasOrder
{
@ -26,16 +26,16 @@ namespace MediaBrowser.Providers.TV.TheTVDB
private readonly ILogger _logger;
private readonly ILibraryManager _libraryManager;
private readonly ILocalizationManager _localizationManager;
private readonly TvDbClientManager _tvDbClientManager;
private readonly TvdbClientManager _tvdbClientManager;
public TvdbSeriesProvider(IHttpClient httpClient, ILogger<TvdbSeriesProvider> logger, ILibraryManager libraryManager, ILocalizationManager localizationManager, TvDbClientManager tvDbClientManager)
public TvdbSeriesProvider(IHttpClient httpClient, ILogger<TvdbSeriesProvider> logger, ILibraryManager libraryManager, ILocalizationManager localizationManager, TvdbClientManager tvdbClientManager)
{
_httpClient = httpClient;
_logger = logger;
_libraryManager = libraryManager;
_localizationManager = localizationManager;
Current = this;
_tvDbClientManager = tvDbClientManager;
_tvdbClientManager = tvdbClientManager;
}
public async Task<IEnumerable<RemoteSearchResult>> GetSearchResults(SeriesInfo searchInfo, CancellationToken cancellationToken)
@ -116,7 +116,7 @@ namespace MediaBrowser.Providers.TV.TheTVDB
try
{
var seriesResult =
await _tvDbClientManager
await _tvdbClientManager
.GetSeriesByIdAsync(Convert.ToInt32(tvdbId), metadataLanguage, cancellationToken)
.ConfigureAwait(false);
MapSeriesToResult(result, seriesResult.Data, metadataLanguage);
@ -133,7 +133,7 @@ namespace MediaBrowser.Providers.TV.TheTVDB
try
{
var actorsResult = await _tvDbClientManager
var actorsResult = await _tvdbClientManager
.GetActorsAsync(Convert.ToInt32(tvdbId), metadataLanguage, cancellationToken).ConfigureAwait(false);
MapActorsToResult(result, actorsResult.Data);
}
@ -152,12 +152,12 @@ namespace MediaBrowser.Providers.TV.TheTVDB
{
if (string.Equals(idType, MetadataProviders.Zap2It.ToString(), StringComparison.OrdinalIgnoreCase))
{
result = await _tvDbClientManager.GetSeriesByZap2ItIdAsync(id, language, cancellationToken)
result = await _tvdbClientManager.GetSeriesByZap2ItIdAsync(id, language, cancellationToken)
.ConfigureAwait(false);
}
else
{
result = await _tvDbClientManager.GetSeriesByImdbIdAsync(id, language, cancellationToken)
result = await _tvdbClientManager.GetSeriesByImdbIdAsync(id, language, cancellationToken)
.ConfigureAwait(false);
}
}
@ -223,7 +223,7 @@ namespace MediaBrowser.Providers.TV.TheTVDB
TvDbResponse<SeriesSearchResult[]> result;
try
{
result = await _tvDbClientManager.GetSeriesByNameAsync(comparableName, language, cancellationToken)
result = await _tvdbClientManager.GetSeriesByNameAsync(comparableName, language, cancellationToken)
.ConfigureAwait(false);
}
catch (TvDbServerException e)
@ -252,7 +252,7 @@ namespace MediaBrowser.Providers.TV.TheTVDB
try
{
var seriesSesult =
await _tvDbClientManager.GetSeriesByIdAsync(seriesSearchResult.Id, language, cancellationToken)
await _tvdbClientManager.GetSeriesByIdAsync(seriesSearchResult.Id, language, cancellationToken)
.ConfigureAwait(false);
remoteSearchResult.SetProviderId(MetadataProviders.Imdb, seriesSesult.Data.ImdbId);
remoteSearchResult.SetProviderId(MetadataProviders.Zap2It, seriesSesult.Data.Zap2itId);
@ -359,7 +359,7 @@ namespace MediaBrowser.Providers.TV.TheTVDB
{
try
{
var episodeSummary = _tvDbClientManager
var episodeSummary = _tvdbClientManager
.GetSeriesEpisodeSummaryAsync(tvdbSeries.Id, metadataLanguage, CancellationToken.None).Result.Data;
var maxSeasonNumber = episodeSummary.AiredSeasons.Select(s => Convert.ToInt32(s)).Max();
var episodeQuery = new EpisodeQuery
@ -367,7 +367,7 @@ namespace MediaBrowser.Providers.TV.TheTVDB
AiredSeason = maxSeasonNumber
};
var episodesPage =
_tvDbClientManager.GetEpisodesPageAsync(tvdbSeries.Id, episodeQuery, metadataLanguage, CancellationToken.None).Result.Data;
_tvdbClientManager.GetEpisodesPageAsync(tvdbSeries.Id, episodeQuery, metadataLanguage, CancellationToken.None).Result.Data;
result.Item.EndDate = episodesPage.Select(e =>
{
DateTime.TryParse(e.FirstAired, out var firstAired);

View File

@ -1,6 +1,7 @@
using System;
using MediaBrowser.Model.Entities;
namespace MediaBrowser.Providers.TV.TheTVDB
namespace MediaBrowser.Providers.Plugins.TheTvdb
{
public static class TvdbUtils
{

View File

@ -12,7 +12,7 @@ using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Globalization;
using MediaBrowser.Model.IO;
using MediaBrowser.Providers.TV.TheTVDB;
using MediaBrowser.Providers.Plugins.TheTvdb;
using Microsoft.Extensions.Logging;
namespace MediaBrowser.Providers.TV
@ -26,7 +26,7 @@ namespace MediaBrowser.Providers.TV
private readonly ILibraryManager _libraryManager;
private readonly ILocalizationManager _localization;
private readonly IFileSystem _fileSystem;
private readonly TvDbClientManager _tvDbClientManager;
private readonly TvdbClientManager _tvdbClientManager;
public MissingEpisodeProvider(
ILogger logger,
@ -34,14 +34,14 @@ namespace MediaBrowser.Providers.TV
ILibraryManager libraryManager,
ILocalizationManager localization,
IFileSystem fileSystem,
TvDbClientManager tvDbClientManager)
TvdbClientManager tvdbClientManager)
{
_logger = logger;
_config = config;
_libraryManager = libraryManager;
_localization = localization;
_fileSystem = fileSystem;
_tvDbClientManager = tvDbClientManager;
_tvdbClientManager = tvdbClientManager;
}
public async Task<bool> Run(Series series, bool addNewItems, CancellationToken cancellationToken)
@ -52,7 +52,7 @@ namespace MediaBrowser.Providers.TV
return false;
}
var episodes = await _tvDbClientManager.GetAllEpisodesAsync(Convert.ToInt32(tvdbId), series.GetPreferredMetadataLanguage(), cancellationToken);
var episodes = await _tvdbClientManager.GetAllEpisodesAsync(Convert.ToInt32(tvdbId), series.GetPreferredMetadataLanguage(), cancellationToken);
var episodeLookup = episodes
.Select(i =>

View File

@ -9,7 +9,7 @@ using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Globalization;
using MediaBrowser.Model.IO;
using MediaBrowser.Providers.Manager;
using MediaBrowser.Providers.TV.TheTVDB;
using MediaBrowser.Providers.Plugins.TheTvdb;
using Microsoft.Extensions.Logging;
namespace MediaBrowser.Providers.TV
@ -17,7 +17,7 @@ namespace MediaBrowser.Providers.TV
public class SeriesMetadataService : MetadataService<Series, SeriesInfo>
{
private readonly ILocalizationManager _localization;
private readonly TvDbClientManager _tvDbClientManager;
private readonly TvdbClientManager _tvdbClientManager;
public SeriesMetadataService(
IServerConfigurationManager serverConfigurationManager,
@ -26,11 +26,11 @@ namespace MediaBrowser.Providers.TV
IFileSystem fileSystem,
ILibraryManager libraryManager,
ILocalizationManager localization,
TvDbClientManager tvDbClientManager)
TvdbClientManager tvdbClientManager)
: base(serverConfigurationManager, logger, providerManager, fileSystem, libraryManager)
{
_localization = localization;
_tvDbClientManager = tvDbClientManager;
_tvdbClientManager = tvdbClientManager;
}
/// <inheritdoc />
@ -47,7 +47,7 @@ namespace MediaBrowser.Providers.TV
LibraryManager,
_localization,
FileSystem,
_tvDbClientManager);
_tvdbClientManager);
try
{

View File

@ -1,7 +1,7 @@
using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.Entities;
using MediaBrowser.Providers.TV.TheTVDB;
using MediaBrowser.Providers.Plugins.TheTvdb;
namespace MediaBrowser.Providers.TV
{