2016-06-04 00:23:44 +00:00
|
|
|
|
using CommonIO;
|
|
|
|
|
using MediaBrowser.Common.Configuration;
|
|
|
|
|
using MediaBrowser.Common.Net;
|
|
|
|
|
using MediaBrowser.Controller.Configuration;
|
2014-02-03 20:51:28 +00:00
|
|
|
|
using MediaBrowser.Controller.Entities;
|
2015-05-30 14:32:18 +00:00
|
|
|
|
using MediaBrowser.Model.Entities;
|
2014-02-03 20:51:28 +00:00
|
|
|
|
using MediaBrowser.Model.Serialization;
|
|
|
|
|
using System;
|
2016-06-23 01:27:25 +00:00
|
|
|
|
using System.Collections.Generic;
|
2014-02-03 20:51:28 +00:00
|
|
|
|
using System.Globalization;
|
2016-06-03 21:46:39 +00:00
|
|
|
|
using System.IO;
|
2014-02-03 20:51:28 +00:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Net;
|
2016-06-03 21:46:39 +00:00
|
|
|
|
using System.Text;
|
2014-02-03 20:51:28 +00:00
|
|
|
|
using System.Threading;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace MediaBrowser.Providers.Omdb
|
|
|
|
|
{
|
|
|
|
|
public class OmdbProvider
|
|
|
|
|
{
|
2014-10-06 23:58:46 +00:00
|
|
|
|
internal static readonly SemaphoreSlim ResourcePool = new SemaphoreSlim(1, 1);
|
2014-02-03 20:51:28 +00:00
|
|
|
|
private readonly IJsonSerializer _jsonSerializer;
|
2016-06-04 00:23:44 +00:00
|
|
|
|
private readonly IFileSystem _fileSystem;
|
|
|
|
|
private readonly IServerConfigurationManager _configurationManager;
|
2014-02-03 20:51:28 +00:00
|
|
|
|
private readonly IHttpClient _httpClient;
|
|
|
|
|
private readonly CultureInfo _usCulture = new CultureInfo("en-US");
|
|
|
|
|
|
2016-06-04 00:23:44 +00:00
|
|
|
|
public OmdbProvider(IJsonSerializer jsonSerializer, IHttpClient httpClient, IFileSystem fileSystem, IServerConfigurationManager configurationManager)
|
2014-02-03 20:51:28 +00:00
|
|
|
|
{
|
|
|
|
|
_jsonSerializer = jsonSerializer;
|
|
|
|
|
_httpClient = httpClient;
|
2016-06-04 00:23:44 +00:00
|
|
|
|
_fileSystem = fileSystem;
|
|
|
|
|
_configurationManager = configurationManager;
|
2014-02-03 20:51:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2015-08-19 16:43:23 +00:00
|
|
|
|
public async Task Fetch(BaseItem item, string imdbId, string language, string country, CancellationToken cancellationToken)
|
2014-02-03 20:51:28 +00:00
|
|
|
|
{
|
2015-05-28 23:37:43 +00:00
|
|
|
|
if (string.IsNullOrWhiteSpace(imdbId))
|
|
|
|
|
{
|
|
|
|
|
throw new ArgumentNullException("imdbId");
|
|
|
|
|
}
|
|
|
|
|
|
2016-06-04 01:08:27 +00:00
|
|
|
|
var result = await GetRootObject(imdbId, cancellationToken);
|
2014-02-03 20:51:28 +00:00
|
|
|
|
|
2015-08-16 16:46:50 +00:00
|
|
|
|
// Only take the name and rating if the user's language is set to english, since Omdb has no localization
|
2015-07-06 14:20:23 +00:00
|
|
|
|
if (string.Equals(language, "en", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
{
|
|
|
|
|
item.Name = result.Title;
|
2015-08-19 16:43:23 +00:00
|
|
|
|
|
|
|
|
|
if (string.Equals(country, "us", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
{
|
|
|
|
|
item.OfficialRating = result.Rated;
|
|
|
|
|
}
|
2015-07-06 14:20:23 +00:00
|
|
|
|
}
|
2015-05-30 14:32:18 +00:00
|
|
|
|
|
|
|
|
|
int year;
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(result.Year)
|
|
|
|
|
&& int.TryParse(result.Year, NumberStyles.Number, _usCulture, out year)
|
|
|
|
|
&& year >= 0)
|
|
|
|
|
{
|
|
|
|
|
item.ProductionYear = year;
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-03 20:51:28 +00:00
|
|
|
|
var hasCriticRating = item as IHasCriticRating;
|
|
|
|
|
if (hasCriticRating != null)
|
|
|
|
|
{
|
|
|
|
|
// Seeing some bogus RT data on omdb for series, so filter it out here
|
|
|
|
|
// RT doesn't even have tv series
|
|
|
|
|
int tomatoMeter;
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(result.tomatoMeter)
|
|
|
|
|
&& int.TryParse(result.tomatoMeter, NumberStyles.Integer, _usCulture, out tomatoMeter)
|
|
|
|
|
&& tomatoMeter >= 0)
|
|
|
|
|
{
|
|
|
|
|
hasCriticRating.CriticRating = tomatoMeter;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(result.tomatoConsensus)
|
|
|
|
|
&& !string.Equals(result.tomatoConsensus, "No consensus yet.", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
{
|
|
|
|
|
hasCriticRating.CriticRatingSummary = WebUtility.HtmlDecode(result.tomatoConsensus);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int voteCount;
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(result.imdbVotes)
|
|
|
|
|
&& int.TryParse(result.imdbVotes, NumberStyles.Number, _usCulture, out voteCount)
|
|
|
|
|
&& voteCount >= 0)
|
|
|
|
|
{
|
|
|
|
|
item.VoteCount = voteCount;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
float imdbRating;
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(result.imdbRating)
|
|
|
|
|
&& float.TryParse(result.imdbRating, NumberStyles.Any, _usCulture, out imdbRating)
|
|
|
|
|
&& imdbRating >= 0)
|
|
|
|
|
{
|
|
|
|
|
item.CommunityRating = imdbRating;
|
|
|
|
|
}
|
|
|
|
|
|
2016-06-03 21:46:39 +00:00
|
|
|
|
if (!string.IsNullOrEmpty(result.Website))
|
2014-02-03 20:51:28 +00:00
|
|
|
|
{
|
|
|
|
|
item.HomePageUrl = result.Website;
|
|
|
|
|
}
|
|
|
|
|
|
2016-06-03 21:46:39 +00:00
|
|
|
|
if (!string.IsNullOrWhiteSpace(result.imdbID))
|
2015-05-30 14:32:18 +00:00
|
|
|
|
{
|
|
|
|
|
item.SetProviderId(MetadataProviders.Imdb, result.imdbID);
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-03 20:51:28 +00:00
|
|
|
|
ParseAdditionalMetadata(item, result);
|
2016-06-04 00:23:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-06-23 01:27:25 +00:00
|
|
|
|
public async Task<bool> FetchEpisodeData(BaseItem item, int episodeNumber, int seasonNumber, string imdbId, string language, string country, CancellationToken cancellationToken)
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrWhiteSpace(imdbId))
|
|
|
|
|
{
|
|
|
|
|
throw new ArgumentNullException("imdbId");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var seasonResult = await GetSeasonRootObject(imdbId, seasonNumber, cancellationToken);
|
|
|
|
|
|
|
|
|
|
RootObject result = null;
|
|
|
|
|
|
|
|
|
|
foreach (var episode in seasonResult.Episodes)
|
|
|
|
|
{
|
|
|
|
|
if (episode.Episode == episodeNumber)
|
|
|
|
|
{
|
|
|
|
|
result = episode;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (result == null)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Only take the name and rating if the user's language is set to english, since Omdb has no localization
|
|
|
|
|
if (string.Equals(language, "en", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
{
|
|
|
|
|
item.Name = result.Title;
|
|
|
|
|
|
|
|
|
|
if (string.Equals(country, "us", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
{
|
|
|
|
|
item.OfficialRating = result.Rated;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int year;
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(result.Year)
|
|
|
|
|
&& int.TryParse(result.Year, NumberStyles.Number, _usCulture, out year)
|
|
|
|
|
&& year >= 0)
|
|
|
|
|
{
|
|
|
|
|
item.ProductionYear = year;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var hasCriticRating = item as IHasCriticRating;
|
|
|
|
|
if (hasCriticRating != null)
|
|
|
|
|
{
|
|
|
|
|
// Seeing some bogus RT data on omdb for series, so filter it out here
|
|
|
|
|
// RT doesn't even have tv series
|
|
|
|
|
int tomatoMeter;
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(result.tomatoMeter)
|
|
|
|
|
&& int.TryParse(result.tomatoMeter, NumberStyles.Integer, _usCulture, out tomatoMeter)
|
|
|
|
|
&& tomatoMeter >= 0)
|
|
|
|
|
{
|
|
|
|
|
hasCriticRating.CriticRating = tomatoMeter;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(result.tomatoConsensus)
|
|
|
|
|
&& !string.Equals(result.tomatoConsensus, "No consensus yet.", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
{
|
|
|
|
|
hasCriticRating.CriticRatingSummary = WebUtility.HtmlDecode(result.tomatoConsensus);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int voteCount;
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(result.imdbVotes)
|
|
|
|
|
&& int.TryParse(result.imdbVotes, NumberStyles.Number, _usCulture, out voteCount)
|
|
|
|
|
&& voteCount >= 0)
|
|
|
|
|
{
|
|
|
|
|
item.VoteCount = voteCount;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
float imdbRating;
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(result.imdbRating)
|
|
|
|
|
&& float.TryParse(result.imdbRating, NumberStyles.Any, _usCulture, out imdbRating)
|
|
|
|
|
&& imdbRating >= 0)
|
|
|
|
|
{
|
|
|
|
|
item.CommunityRating = imdbRating;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(result.Website))
|
|
|
|
|
{
|
|
|
|
|
item.HomePageUrl = result.Website;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(result.imdbID))
|
|
|
|
|
{
|
|
|
|
|
item.SetProviderId(MetadataProviders.Imdb, result.imdbID);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ParseAdditionalMetadata(item, result);
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2016-06-04 01:08:27 +00:00
|
|
|
|
internal async Task<RootObject> GetRootObject(string imdbId, CancellationToken cancellationToken)
|
|
|
|
|
{
|
|
|
|
|
var path = await EnsureItemInfo(imdbId, cancellationToken);
|
|
|
|
|
|
|
|
|
|
string resultString;
|
|
|
|
|
|
|
|
|
|
using (Stream stream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read, 131072))
|
|
|
|
|
{
|
|
|
|
|
using (var reader = new StreamReader(stream, new UTF8Encoding(false)))
|
|
|
|
|
{
|
|
|
|
|
resultString = reader.ReadToEnd();
|
|
|
|
|
resultString = resultString.Replace("\"N/A\"", "\"\"");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var result = _jsonSerializer.DeserializeFromString<RootObject>(resultString);
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2016-06-23 01:27:25 +00:00
|
|
|
|
internal async Task<SeasonRootObject> GetSeasonRootObject(string imdbId, int seasonId, CancellationToken cancellationToken)
|
|
|
|
|
{
|
|
|
|
|
var path = await EnsureSeasonInfo(imdbId, seasonId, cancellationToken);
|
|
|
|
|
|
|
|
|
|
string resultString;
|
|
|
|
|
|
|
|
|
|
using (Stream stream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read, 131072))
|
|
|
|
|
{
|
|
|
|
|
using (var reader = new StreamReader(stream, new UTF8Encoding(false)))
|
|
|
|
|
{
|
|
|
|
|
resultString = reader.ReadToEnd();
|
|
|
|
|
resultString = resultString.Replace("\"N/A\"", "\"\"");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var result = _jsonSerializer.DeserializeFromString<SeasonRootObject>(resultString);
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal static bool IsValidSeries(Dictionary<string, string> seriesProviderIds)
|
|
|
|
|
{
|
|
|
|
|
string id;
|
|
|
|
|
if (seriesProviderIds.TryGetValue(MetadataProviders.Imdb.ToString(), out id) && !string.IsNullOrEmpty(id))
|
|
|
|
|
{
|
|
|
|
|
// This check should ideally never be necessary but we're seeing some cases of this and haven't tracked them down yet.
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(id))
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2016-06-04 01:08:27 +00:00
|
|
|
|
private async Task<string> EnsureItemInfo(string imdbId, CancellationToken cancellationToken)
|
2016-06-04 00:23:44 +00:00
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrWhiteSpace(imdbId))
|
|
|
|
|
{
|
|
|
|
|
throw new ArgumentNullException("imdbId");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var imdbParam = imdbId.StartsWith("tt", StringComparison.OrdinalIgnoreCase) ? imdbId : "tt" + imdbId;
|
|
|
|
|
|
|
|
|
|
var path = GetDataFilePath(imdbParam);
|
|
|
|
|
|
|
|
|
|
var fileInfo = _fileSystem.GetFileSystemInfo(path);
|
|
|
|
|
|
|
|
|
|
if (fileInfo.Exists)
|
|
|
|
|
{
|
|
|
|
|
// If it's recent or automatic updates are enabled, don't re-download
|
|
|
|
|
if ((DateTime.UtcNow - _fileSystem.GetLastWriteTimeUtc(fileInfo)).TotalDays <= 3)
|
|
|
|
|
{
|
|
|
|
|
return path;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var url = string.Format("https://www.omdbapi.com/?i={0}&tomatoes=true", imdbParam);
|
|
|
|
|
|
|
|
|
|
using (var stream = await _httpClient.Get(new HttpRequestOptions
|
|
|
|
|
{
|
|
|
|
|
Url = url,
|
|
|
|
|
ResourcePool = ResourcePool,
|
|
|
|
|
CancellationToken = cancellationToken
|
|
|
|
|
|
|
|
|
|
}).ConfigureAwait(false))
|
|
|
|
|
{
|
|
|
|
|
var rootObject = _jsonSerializer.DeserializeFromStream<RootObject>(stream);
|
|
|
|
|
_fileSystem.CreateDirectory(Path.GetDirectoryName(path));
|
|
|
|
|
_jsonSerializer.SerializeToFile(rootObject, path);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return path;
|
|
|
|
|
}
|
|
|
|
|
|
2016-06-23 01:27:25 +00:00
|
|
|
|
private async Task<string> EnsureSeasonInfo(string seriesImdbId, int seasonId, CancellationToken cancellationToken)
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrWhiteSpace(seriesImdbId))
|
|
|
|
|
{
|
|
|
|
|
throw new ArgumentNullException("imdbId");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var imdbParam = seriesImdbId.StartsWith("tt", StringComparison.OrdinalIgnoreCase) ? seriesImdbId : "tt" + seriesImdbId;
|
|
|
|
|
|
|
|
|
|
var path = GetSeasonFilePath(imdbParam, seasonId);
|
|
|
|
|
|
|
|
|
|
var fileInfo = _fileSystem.GetFileSystemInfo(path);
|
|
|
|
|
|
|
|
|
|
if (fileInfo.Exists)
|
|
|
|
|
{
|
|
|
|
|
// If it's recent or automatic updates are enabled, don't re-download
|
|
|
|
|
if ((DateTime.UtcNow - _fileSystem.GetLastWriteTimeUtc(fileInfo)).TotalDays <= 3)
|
|
|
|
|
{
|
|
|
|
|
return path;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var url = string.Format("https://www.omdbapi.com/?i={0}&season={1}&detail=full", imdbParam, seasonId);
|
|
|
|
|
|
|
|
|
|
using (var stream = await _httpClient.Get(new HttpRequestOptions
|
|
|
|
|
{
|
|
|
|
|
Url = url,
|
|
|
|
|
ResourcePool = ResourcePool,
|
|
|
|
|
CancellationToken = cancellationToken
|
|
|
|
|
|
|
|
|
|
}).ConfigureAwait(false))
|
|
|
|
|
{
|
|
|
|
|
var rootObject = _jsonSerializer.DeserializeFromStream<SeasonRootObject>(stream);
|
|
|
|
|
_fileSystem.CreateDirectory(Path.GetDirectoryName(path));
|
|
|
|
|
_jsonSerializer.SerializeToFile(rootObject, path);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return path;
|
|
|
|
|
}
|
|
|
|
|
|
2016-06-04 00:23:44 +00:00
|
|
|
|
internal string GetDataFilePath(string imdbId)
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrEmpty(imdbId))
|
|
|
|
|
{
|
|
|
|
|
throw new ArgumentNullException("imdbId");
|
2014-02-03 20:51:28 +00:00
|
|
|
|
}
|
2016-06-04 00:23:44 +00:00
|
|
|
|
|
|
|
|
|
var dataPath = Path.Combine(_configurationManager.ApplicationPaths.CachePath, "omdb");
|
|
|
|
|
|
|
|
|
|
var filename = string.Format("{0}.json", imdbId);
|
|
|
|
|
|
|
|
|
|
return Path.Combine(dataPath, filename);
|
2014-02-03 20:51:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-06-23 01:27:25 +00:00
|
|
|
|
internal string GetSeasonFilePath(string imdbId, int seasonId)
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrEmpty(imdbId))
|
|
|
|
|
{
|
|
|
|
|
throw new ArgumentNullException("imdbId");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var dataPath = Path.Combine(_configurationManager.ApplicationPaths.CachePath, "omdb");
|
|
|
|
|
|
|
|
|
|
var filename = string.Format("{0}_season_{1}.json", imdbId, seasonId);
|
|
|
|
|
|
|
|
|
|
return Path.Combine(dataPath, filename);
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-03 20:51:28 +00:00
|
|
|
|
private void ParseAdditionalMetadata(BaseItem item, RootObject result)
|
|
|
|
|
{
|
|
|
|
|
// Grab series genres because imdb data is better than tvdb. Leave movies alone
|
|
|
|
|
// But only do it if english is the preferred language because this data will not be localized
|
2014-02-15 16:36:09 +00:00
|
|
|
|
if (ShouldFetchGenres(item) &&
|
2016-06-03 21:46:39 +00:00
|
|
|
|
!string.IsNullOrWhiteSpace(result.Genre))
|
2014-02-03 20:51:28 +00:00
|
|
|
|
{
|
|
|
|
|
item.Genres.Clear();
|
|
|
|
|
|
|
|
|
|
foreach (var genre in result.Genre
|
|
|
|
|
.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)
|
|
|
|
|
.Select(i => i.Trim())
|
|
|
|
|
.Where(i => !string.IsNullOrWhiteSpace(i)))
|
|
|
|
|
{
|
|
|
|
|
item.AddGenre(genre);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var hasMetascore = item as IHasMetascore;
|
|
|
|
|
if (hasMetascore != null)
|
|
|
|
|
{
|
|
|
|
|
float metascore;
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(result.Metascore) && float.TryParse(result.Metascore, NumberStyles.Any, _usCulture, out metascore) && metascore >= 0)
|
|
|
|
|
{
|
|
|
|
|
hasMetascore.Metascore = metascore;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var hasAwards = item as IHasAwards;
|
2016-06-03 21:46:39 +00:00
|
|
|
|
if (hasAwards != null && !string.IsNullOrEmpty(result.Awards))
|
2014-02-03 20:51:28 +00:00
|
|
|
|
{
|
|
|
|
|
hasAwards.AwardSummary = WebUtility.HtmlDecode(result.Awards);
|
|
|
|
|
}
|
2014-06-24 04:18:02 +00:00
|
|
|
|
|
|
|
|
|
var hasShortOverview = item as IHasShortOverview;
|
|
|
|
|
if (hasShortOverview != null)
|
|
|
|
|
{
|
|
|
|
|
// Imdb plots are usually pretty short
|
|
|
|
|
hasShortOverview.ShortOverview = result.Plot;
|
|
|
|
|
}
|
2014-02-03 20:51:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private bool ShouldFetchGenres(BaseItem item)
|
|
|
|
|
{
|
|
|
|
|
var lang = item.GetPreferredMetadataLanguage();
|
|
|
|
|
|
|
|
|
|
// The data isn't localized and so can only be used for english users
|
2014-02-15 16:36:09 +00:00
|
|
|
|
return string.Equals(lang, "en", StringComparison.OrdinalIgnoreCase);
|
2014-02-03 20:51:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-06-23 01:27:25 +00:00
|
|
|
|
internal class SeasonRootObject
|
|
|
|
|
{
|
|
|
|
|
public string Title { get; set; }
|
|
|
|
|
public string seriesID { get; set; }
|
|
|
|
|
public int Season { get; set; }
|
|
|
|
|
public int? totalSeasons { get; set; }
|
|
|
|
|
public RootObject[] Episodes { get; set; }
|
|
|
|
|
public string Response { get; set; }
|
|
|
|
|
}
|
|
|
|
|
|
2016-06-04 01:08:27 +00:00
|
|
|
|
internal class RootObject
|
2014-02-03 20:51:28 +00:00
|
|
|
|
{
|
|
|
|
|
public string Title { get; set; }
|
|
|
|
|
public string Year { get; set; }
|
|
|
|
|
public string Rated { get; set; }
|
|
|
|
|
public string Released { get; set; }
|
2016-06-23 01:27:25 +00:00
|
|
|
|
public int Episode { get; set; }
|
2014-02-03 20:51:28 +00:00
|
|
|
|
public string Runtime { get; set; }
|
|
|
|
|
public string Genre { get; set; }
|
|
|
|
|
public string Director { get; set; }
|
|
|
|
|
public string Writer { get; set; }
|
|
|
|
|
public string Actors { get; set; }
|
|
|
|
|
public string Plot { get; set; }
|
|
|
|
|
public string Poster { get; set; }
|
|
|
|
|
public string imdbRating { get; set; }
|
|
|
|
|
public string imdbVotes { get; set; }
|
|
|
|
|
public string imdbID { get; set; }
|
|
|
|
|
public string Type { get; set; }
|
|
|
|
|
public string tomatoMeter { get; set; }
|
|
|
|
|
public string tomatoImage { get; set; }
|
|
|
|
|
public string tomatoRating { get; set; }
|
|
|
|
|
public string tomatoReviews { get; set; }
|
|
|
|
|
public string tomatoFresh { get; set; }
|
|
|
|
|
public string tomatoRotten { get; set; }
|
|
|
|
|
public string tomatoConsensus { get; set; }
|
|
|
|
|
public string tomatoUserMeter { get; set; }
|
|
|
|
|
public string tomatoUserRating { get; set; }
|
|
|
|
|
public string tomatoUserReviews { get; set; }
|
|
|
|
|
public string DVD { get; set; }
|
|
|
|
|
public string BoxOffice { get; set; }
|
|
|
|
|
public string Production { get; set; }
|
|
|
|
|
public string Website { get; set; }
|
|
|
|
|
public string Response { get; set; }
|
|
|
|
|
|
|
|
|
|
public string Language { get; set; }
|
|
|
|
|
public string Country { get; set; }
|
|
|
|
|
public string Awards { get; set; }
|
|
|
|
|
public string Metascore { get; set; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|