2014-02-03 20:51:28 +00:00
|
|
|
|
using MediaBrowser.Common.Net;
|
2014-02-04 20:19:29 +00:00
|
|
|
|
using MediaBrowser.Controller.Entities;
|
|
|
|
|
using MediaBrowser.Controller.Entities.Movies;
|
2014-02-03 20:51:28 +00:00
|
|
|
|
using MediaBrowser.Controller.Entities.TV;
|
2014-02-04 20:19:29 +00:00
|
|
|
|
using MediaBrowser.Controller.Library;
|
2014-02-03 20:51:28 +00:00
|
|
|
|
using MediaBrowser.Controller.Providers;
|
|
|
|
|
using MediaBrowser.Model.Serialization;
|
|
|
|
|
using System.Threading;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace MediaBrowser.Providers.Omdb
|
|
|
|
|
{
|
2014-02-04 20:19:29 +00:00
|
|
|
|
public class OmdbSeriesProvider : ICustomMetadataProvider<Series>,
|
|
|
|
|
ICustomMetadataProvider<Movie>, ICustomMetadataProvider<Trailer>
|
2014-02-03 20:51:28 +00:00
|
|
|
|
{
|
|
|
|
|
private readonly IJsonSerializer _jsonSerializer;
|
|
|
|
|
private readonly IHttpClient _httpClient;
|
|
|
|
|
|
|
|
|
|
public OmdbSeriesProvider(IJsonSerializer jsonSerializer, IHttpClient httpClient)
|
|
|
|
|
{
|
|
|
|
|
_jsonSerializer = jsonSerializer;
|
|
|
|
|
_httpClient = httpClient;
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-04 20:19:29 +00:00
|
|
|
|
public string Name
|
|
|
|
|
{
|
|
|
|
|
get { return "OMDb"; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Task<ItemUpdateType> FetchAsync(Series item, CancellationToken cancellationToken)
|
2014-02-03 20:51:28 +00:00
|
|
|
|
{
|
|
|
|
|
return new OmdbProvider(_jsonSerializer, _httpClient).Fetch(item, cancellationToken);
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-04 20:19:29 +00:00
|
|
|
|
public Task<ItemUpdateType> FetchAsync(Movie item, CancellationToken cancellationToken)
|
2014-02-03 20:51:28 +00:00
|
|
|
|
{
|
2014-02-04 20:19:29 +00:00
|
|
|
|
return new OmdbProvider(_jsonSerializer, _httpClient).Fetch(item, cancellationToken);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private readonly Task<ItemUpdateType> _cachedTask = Task.FromResult(ItemUpdateType.Unspecified);
|
|
|
|
|
public Task<ItemUpdateType> FetchAsync(Trailer item, CancellationToken cancellationToken)
|
|
|
|
|
{
|
|
|
|
|
if (item.IsLocalTrailer)
|
|
|
|
|
{
|
|
|
|
|
return _cachedTask;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return new OmdbProvider(_jsonSerializer, _httpClient).Fetch(item, cancellationToken);
|
2014-02-03 20:51:28 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|