support tv banner from fanart
This commit is contained in:
parent
1f898cef2d
commit
9d24362695
|
@ -270,8 +270,8 @@ namespace MediaBrowser.Controller.Providers.Movies
|
|||
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
// backdrops
|
||||
if (images.backdrops != null && images.backdrops.Count > 0 && ConfigurationManager.Configuration.DownloadMovieImages.Backdrops)
|
||||
// backdrops - only download if earlier providers didn't find any (fanart)
|
||||
if (images.backdrops != null && images.backdrops.Count > 0 && ConfigurationManager.Configuration.DownloadMovieImages.Backdrops && item.BackdropImagePaths.Count == 0)
|
||||
{
|
||||
item.BackdropImagePaths = new List<string>();
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using MediaBrowser.Common.Net;
|
||||
using MediaBrowser.Common.Extensions;
|
||||
using MediaBrowser.Common.Net;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Entities.TV;
|
||||
|
@ -6,7 +7,6 @@ using MediaBrowser.Model.Entities;
|
|||
using MediaBrowser.Model.Logging;
|
||||
using MediaBrowser.Model.Net;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml;
|
||||
|
@ -56,26 +56,49 @@ namespace MediaBrowser.Controller.Providers.TV
|
|||
|
||||
if (!ConfigurationManager.Configuration.DownloadSeriesImages.Art &&
|
||||
!ConfigurationManager.Configuration.DownloadSeriesImages.Logo &&
|
||||
!ConfigurationManager.Configuration.DownloadSeriesImages.Thumb)
|
||||
!ConfigurationManager.Configuration.DownloadSeriesImages.Thumb &&
|
||||
!ConfigurationManager.Configuration.DownloadSeriesImages.Backdrops &&
|
||||
!ConfigurationManager.Configuration.DownloadSeriesImages.Banner)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (providerInfo.Data != GetComparisonData(item.GetProviderId(MetadataProviders.Tvdb)))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return base.NeedsRefreshInternal(item, providerInfo);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the comparison data.
|
||||
/// </summary>
|
||||
/// <returns>Guid.</returns>
|
||||
private Guid GetComparisonData(string id)
|
||||
{
|
||||
return string.IsNullOrEmpty(id) ? Guid.Empty : id.GetMD5();
|
||||
}
|
||||
|
||||
public override async Task<bool> FetchAsync(BaseItem item, bool force, CancellationToken cancellationToken)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
var status = ProviderRefreshStatus.Success;
|
||||
BaseProviderInfo data;
|
||||
|
||||
if (!item.ProviderData.TryGetValue(Id, out data))
|
||||
{
|
||||
data = new BaseProviderInfo();
|
||||
item.ProviderData[Id] = data;
|
||||
}
|
||||
|
||||
var series = (Series)item;
|
||||
|
||||
string language = ConfigurationManager.Configuration.PreferredMetadataLanguage.ToLower();
|
||||
string url = string.Format(FanArtBaseUrl, APIKey, series.GetProviderId(MetadataProviders.Tvdb));
|
||||
var doc = new XmlDocument();
|
||||
|
||||
try
|
||||
{
|
||||
using (var xml = await HttpClient.Get(new HttpRequestOptions
|
||||
{
|
||||
Url = url,
|
||||
|
@ -87,10 +110,6 @@ namespace MediaBrowser.Controller.Providers.TV
|
|||
{
|
||||
doc.Load(xml);
|
||||
}
|
||||
}
|
||||
catch (HttpException)
|
||||
{
|
||||
}
|
||||
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
|
@ -114,10 +133,7 @@ namespace MediaBrowser.Controller.Providers.TV
|
|||
}
|
||||
catch (HttpException)
|
||||
{
|
||||
}
|
||||
catch (IOException)
|
||||
{
|
||||
|
||||
status = ProviderRefreshStatus.CompletedWithErrors;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -141,10 +157,7 @@ namespace MediaBrowser.Controller.Providers.TV
|
|||
}
|
||||
catch (HttpException)
|
||||
{
|
||||
}
|
||||
catch (IOException)
|
||||
{
|
||||
|
||||
status = ProviderRefreshStatus.CompletedWithErrors;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -161,20 +174,37 @@ namespace MediaBrowser.Controller.Providers.TV
|
|||
Logger.Debug("FanArtProvider getting ThumbArt for " + series.Name);
|
||||
try
|
||||
{
|
||||
series.SetImage(ImageType.Disc, await _providerManager.DownloadAndSaveImage(series, path, THUMB_FILE, ConfigurationManager.Configuration.SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
|
||||
series.SetImage(ImageType.Thumb, await _providerManager.DownloadAndSaveImage(series, path, THUMB_FILE, ConfigurationManager.Configuration.SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
|
||||
}
|
||||
catch (HttpException)
|
||||
{
|
||||
status = ProviderRefreshStatus.CompletedWithErrors;
|
||||
}
|
||||
catch (IOException)
|
||||
}
|
||||
}
|
||||
|
||||
if (ConfigurationManager.Configuration.DownloadSeriesImages.Banner && !series.ResolveArgs.ContainsMetaFileByName(BANNER_FILE))
|
||||
{
|
||||
|
||||
var node = doc.SelectSingleNode("//fanart/series/tbbanners/tvbanner[@lang = \"" + language + "\"]/@url") ??
|
||||
doc.SelectSingleNode("//fanart/series/tbbanners/tvbanner/@url");
|
||||
path = node != null ? node.Value : null;
|
||||
if (!string.IsNullOrEmpty(path))
|
||||
{
|
||||
Logger.Debug("FanArtProvider getting banner for " + series.Name);
|
||||
try
|
||||
{
|
||||
series.SetImage(ImageType.Banner, await _providerManager.DownloadAndSaveImage(series, path, BANNER_FILE, ConfigurationManager.Configuration.SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
|
||||
}
|
||||
catch (HttpException)
|
||||
{
|
||||
status = ProviderRefreshStatus.CompletedWithErrors;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SetLastRefreshed(series, DateTime.UtcNow);
|
||||
data.Data = GetComparisonData(item.GetProviderId(MetadataProviders.Tvcom));
|
||||
SetLastRefreshed(series, DateTime.UtcNow, status);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -105,8 +105,10 @@ namespace MediaBrowser.Controller.Providers.TV
|
|||
|
||||
if (seriesId != null)
|
||||
{
|
||||
await FetchSeasonData(season, seriesId, cancellationToken).ConfigureAwait(false);
|
||||
SetLastRefreshed(item, DateTime.UtcNow);
|
||||
var status = await FetchSeasonData(season, seriesId, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
SetLastRefreshed(item, DateTime.UtcNow, status);
|
||||
|
||||
return true;
|
||||
}
|
||||
Logger.Info("Season provider unable to obtain series id for {0}", item.Path);
|
||||
|
@ -126,10 +128,8 @@ namespace MediaBrowser.Controller.Providers.TV
|
|||
/// <param name="seriesId">The series id.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>Task{System.Boolean}.</returns>
|
||||
private async Task<bool> FetchSeasonData(Season season, string seriesId, CancellationToken cancellationToken)
|
||||
private async Task<ProviderRefreshStatus> FetchSeasonData(Season season, string seriesId, CancellationToken cancellationToken)
|
||||
{
|
||||
string name = season.Name;
|
||||
|
||||
var seasonNumber = TVUtils.GetSeasonNumberFromPath(season.Path) ?? -1;
|
||||
|
||||
season.IndexNumber = seasonNumber;
|
||||
|
@ -139,15 +139,18 @@ namespace MediaBrowser.Controller.Providers.TV
|
|||
season.Name = "Specials";
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(seriesId))
|
||||
var status = ProviderRefreshStatus.Success;
|
||||
|
||||
if (string.IsNullOrEmpty(seriesId))
|
||||
{
|
||||
return status;
|
||||
}
|
||||
|
||||
if ((season.PrimaryImagePath == null) || (!season.HasImage(ImageType.Banner)) || (season.BackdropImagePaths == null))
|
||||
{
|
||||
var images = new XmlDocument();
|
||||
var url = string.Format("http://www.thetvdb.com/api/" + TVUtils.TVDBApiKey + "/series/{0}/banners.xml", seriesId);
|
||||
|
||||
try
|
||||
{
|
||||
using (var imgs = await HttpClient.Get(new HttpRequestOptions
|
||||
{
|
||||
Url = url,
|
||||
|
@ -159,10 +162,6 @@ namespace MediaBrowser.Controller.Providers.TV
|
|||
{
|
||||
images.Load(imgs);
|
||||
}
|
||||
}
|
||||
catch (HttpException)
|
||||
{
|
||||
}
|
||||
|
||||
if (images.HasChildNodes)
|
||||
{
|
||||
|
@ -180,10 +179,7 @@ namespace MediaBrowser.Controller.Providers.TV
|
|||
}
|
||||
catch (HttpException)
|
||||
{
|
||||
}
|
||||
catch (IOException)
|
||||
{
|
||||
|
||||
status = ProviderRefreshStatus.CompletedWithErrors;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -210,10 +206,7 @@ namespace MediaBrowser.Controller.Providers.TV
|
|||
}
|
||||
catch (HttpException)
|
||||
{
|
||||
}
|
||||
catch (IOException)
|
||||
{
|
||||
|
||||
status = ProviderRefreshStatus.CompletedWithErrors;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -234,10 +227,7 @@ namespace MediaBrowser.Controller.Providers.TV
|
|||
}
|
||||
catch (HttpException)
|
||||
{
|
||||
}
|
||||
catch (IOException)
|
||||
{
|
||||
|
||||
status = ProviderRefreshStatus.CompletedWithErrors;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -269,10 +259,7 @@ namespace MediaBrowser.Controller.Providers.TV
|
|||
}
|
||||
catch (HttpException)
|
||||
{
|
||||
}
|
||||
catch (IOException)
|
||||
{
|
||||
|
||||
status = ProviderRefreshStatus.CompletedWithErrors;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -280,10 +267,7 @@ namespace MediaBrowser.Controller.Providers.TV
|
|||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return status;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
Loading…
Reference in New Issue
Block a user