2014-02-03 13:51:28 -07:00
|
|
|
|
using MediaBrowser.Common.Net;
|
2014-02-04 13:19:29 -07:00
|
|
|
|
using MediaBrowser.Controller.Entities;
|
|
|
|
|
using MediaBrowser.Controller.Entities.Movies;
|
2014-02-03 13:51:28 -07:00
|
|
|
|
using MediaBrowser.Controller.Entities.TV;
|
2014-02-04 13:19:29 -07:00
|
|
|
|
using MediaBrowser.Controller.Library;
|
2014-02-03 13:51:28 -07:00
|
|
|
|
using MediaBrowser.Controller.Providers;
|
|
|
|
|
using MediaBrowser.Model.Serialization;
|
|
|
|
|
using System.Threading;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace MediaBrowser.Providers.Omdb
|
|
|
|
|
{
|
2014-02-07 09:42:19 -07:00
|
|
|
|
public class OmdbItemProvider : ICustomMetadataProvider<Series>,
|
2014-02-04 13:19:29 -07:00
|
|
|
|
ICustomMetadataProvider<Movie>, ICustomMetadataProvider<Trailer>
|
2014-02-03 13:51:28 -07:00
|
|
|
|
{
|
|
|
|
|
private readonly IJsonSerializer _jsonSerializer;
|
|
|
|
|
private readonly IHttpClient _httpClient;
|
|
|
|
|
|
2014-02-07 09:42:19 -07:00
|
|
|
|
public OmdbItemProvider(IJsonSerializer jsonSerializer, IHttpClient httpClient)
|
2014-02-03 13:51:28 -07:00
|
|
|
|
{
|
|
|
|
|
_jsonSerializer = jsonSerializer;
|
|
|
|
|
_httpClient = httpClient;
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-04 13:19:29 -07:00
|
|
|
|
public string Name
|
|
|
|
|
{
|
2014-02-08 21:52:52 -07:00
|
|
|
|
get { return "IMDb via The Open Movie Database"; }
|
2014-02-04 13:19:29 -07:00
|
|
|
|
}
|
|
|
|
|
|
2014-02-10 11:39:41 -07:00
|
|
|
|
public Task<ItemUpdateType> FetchAsync(Series item, IDirectoryService directoryService, CancellationToken cancellationToken)
|
2014-02-03 13:51:28 -07:00
|
|
|
|
{
|
|
|
|
|
return new OmdbProvider(_jsonSerializer, _httpClient).Fetch(item, cancellationToken);
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-10 11:39:41 -07:00
|
|
|
|
public Task<ItemUpdateType> FetchAsync(Movie item, IDirectoryService directoryService, CancellationToken cancellationToken)
|
2014-02-03 13:51:28 -07:00
|
|
|
|
{
|
2014-02-04 13:19:29 -07:00
|
|
|
|
return new OmdbProvider(_jsonSerializer, _httpClient).Fetch(item, cancellationToken);
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-10 11:39:41 -07:00
|
|
|
|
private readonly Task<ItemUpdateType> _cachedTask = Task.FromResult(ItemUpdateType.None);
|
|
|
|
|
public Task<ItemUpdateType> FetchAsync(Trailer item, IDirectoryService directoryService, CancellationToken cancellationToken)
|
2014-02-04 13:19:29 -07:00
|
|
|
|
{
|
|
|
|
|
if (item.IsLocalTrailer)
|
|
|
|
|
{
|
|
|
|
|
return _cachedTask;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return new OmdbProvider(_jsonSerializer, _httpClient).Fetch(item, cancellationToken);
|
2014-02-03 13:51:28 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|