You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
80 lines
3.3 KiB
80 lines
3.3 KiB
6 years ago
|
using System.Collections.Generic;
|
||
6 years ago
|
using System.Threading;
|
||
|
using System.Threading.Tasks;
|
||
|
using MediaBrowser.Common;
|
||
9 years ago
|
using MediaBrowser.Common.Net;
|
||
|
using MediaBrowser.Controller.Configuration;
|
||
9 years ago
|
using MediaBrowser.Controller.Entities.TV;
|
||
|
using MediaBrowser.Controller.Library;
|
||
|
using MediaBrowser.Controller.Providers;
|
||
|
using MediaBrowser.Model.Entities;
|
||
6 years ago
|
using MediaBrowser.Model.IO;
|
||
9 years ago
|
using MediaBrowser.Model.Providers;
|
||
|
using MediaBrowser.Model.Serialization;
|
||
6 years ago
|
using Microsoft.Extensions.Logging;
|
||
9 years ago
|
|
||
5 years ago
|
namespace MediaBrowser.Providers.Plugins.Omdb
|
||
9 years ago
|
{
|
||
6 years ago
|
public class OmdbEpisodeProvider :
|
||
9 years ago
|
IRemoteMetadataProvider<Episode, EpisodeInfo>,
|
||
|
IHasOrder
|
||
|
{
|
||
|
private readonly IJsonSerializer _jsonSerializer;
|
||
|
private readonly IHttpClient _httpClient;
|
||
9 years ago
|
private readonly OmdbItemProvider _itemProvider;
|
||
9 years ago
|
private readonly IFileSystem _fileSystem;
|
||
|
private readonly IServerConfigurationManager _configurationManager;
|
||
6 years ago
|
private readonly IApplicationHost _appHost;
|
||
9 years ago
|
|
||
6 years ago
|
public OmdbEpisodeProvider(IJsonSerializer jsonSerializer, IApplicationHost appHost, IHttpClient httpClient, ILogger logger, ILibraryManager libraryManager, IFileSystem fileSystem, IServerConfigurationManager configurationManager)
|
||
9 years ago
|
{
|
||
|
_jsonSerializer = jsonSerializer;
|
||
|
_httpClient = httpClient;
|
||
9 years ago
|
_fileSystem = fileSystem;
|
||
|
_configurationManager = configurationManager;
|
||
6 years ago
|
_appHost = appHost;
|
||
|
_itemProvider = new OmdbItemProvider(jsonSerializer, _appHost, httpClient, logger, libraryManager, fileSystem, configurationManager);
|
||
9 years ago
|
}
|
||
|
|
||
|
public Task<IEnumerable<RemoteSearchResult>> GetSearchResults(EpisodeInfo searchInfo, CancellationToken cancellationToken)
|
||
|
{
|
||
|
return _itemProvider.GetSearchResults(searchInfo, "episode", cancellationToken);
|
||
|
}
|
||
|
|
||
|
public async Task<MetadataResult<Episode>> GetMetadata(EpisodeInfo info, CancellationToken cancellationToken)
|
||
|
{
|
||
9 years ago
|
var result = new MetadataResult<Episode>()
|
||
9 years ago
|
{
|
||
8 years ago
|
Item = new Episode(),
|
||
|
QueriedById = true
|
||
9 years ago
|
};
|
||
|
|
||
9 years ago
|
// Allowing this will dramatically increase scan times
|
||
7 years ago
|
if (info.IsMissingEpisode)
|
||
9 years ago
|
{
|
||
|
return result;
|
||
|
}
|
||
|
|
||
6 years ago
|
if (info.SeriesProviderIds.TryGetValue(MetadataProviders.Imdb.ToString(), out string seriesImdbId) && !string.IsNullOrEmpty(seriesImdbId))
|
||
9 years ago
|
{
|
||
8 years ago
|
if (info.IndexNumber.HasValue && info.ParentIndexNumber.HasValue)
|
||
8 years ago
|
{
|
||
6 years ago
|
result.HasMetadata = await new OmdbProvider(_jsonSerializer, _httpClient, _fileSystem, _appHost, _configurationManager)
|
||
8 years ago
|
.FetchEpisodeData(result, info.IndexNumber.Value, info.ParentIndexNumber.Value, info.GetProviderId(MetadataProviders.Imdb), seriesImdbId, info.MetadataLanguage, info.MetadataCountryCode, cancellationToken).ConfigureAwait(false);
|
||
8 years ago
|
}
|
||
9 years ago
|
}
|
||
|
|
||
|
return result;
|
||
|
}
|
||
6 years ago
|
// After TheTvDb
|
||
6 years ago
|
public int Order => 1;
|
||
9 years ago
|
|
||
6 years ago
|
public string Name => "The Open Movie Database";
|
||
9 years ago
|
|
||
|
public Task<HttpResponseInfo> GetImageResponse(string url, CancellationToken cancellationToken)
|
||
|
{
|
||
|
return _itemProvider.GetImageResponse(url, cancellationToken);
|
||
|
}
|
||
|
}
|
||
|
}
|