support tv backdrops from fanart
This commit is contained in:
parent
c702fb2179
commit
2f796d611b
|
@ -428,17 +428,13 @@ namespace MediaBrowser.Api
|
|||
|
||||
try
|
||||
{
|
||||
await item.RefreshMetadata(CancellationToken.None, forceRefresh: request.Forced).ConfigureAwait(false);
|
||||
|
||||
if (folder != null)
|
||||
{
|
||||
await
|
||||
folder.ValidateChildren(new Progress<double>(), CancellationToken.None, request.Recursive,
|
||||
await folder.ValidateChildren(new Progress<double>(), CancellationToken.None, request.Recursive,
|
||||
request.Forced).ConfigureAwait(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
await
|
||||
item.RefreshMetadata(CancellationToken.None, forceRefresh: request.Forced).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
|
@ -1,25 +1,15 @@
|
|||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Model.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
|
||||
namespace MediaBrowser.Controller.Providers
|
||||
{
|
||||
class FanArtProviderException : ApplicationException
|
||||
{
|
||||
public FanArtProviderException(string msg)
|
||||
: base(msg)
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// Class FanartBaseProvider
|
||||
/// </summary>
|
||||
public abstract class FanartBaseProvider : BaseMetadataProvider
|
||||
{
|
||||
|
||||
protected static readonly SemaphoreSlim FanArtResourcePool = new SemaphoreSlim(3,3);
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -192,16 +192,10 @@ namespace MediaBrowser.Controller.Providers.Movies
|
|||
var saveLocal = ConfigurationManager.Configuration.SaveLocalMeta &&
|
||||
item.LocationType == LocationType.FileSystem;
|
||||
|
||||
if (doc.HasChildNodes)
|
||||
{
|
||||
string path;
|
||||
var hd = ConfigurationManager.Configuration.DownloadHDFanArt ? "hd" : "";
|
||||
|
||||
var hasLogo = item.LocationType == LocationType.FileSystem ?
|
||||
item.ResolveArgs.ContainsMetaFileByName(LogoFile)
|
||||
: item.HasImage(ImageType.Logo);
|
||||
|
||||
if (ConfigurationManager.Configuration.DownloadMovieImages.Logo && !hasLogo)
|
||||
if (ConfigurationManager.Configuration.DownloadMovieImages.Logo && !item.HasImage(ImageType.Logo))
|
||||
{
|
||||
var node =
|
||||
doc.SelectSingleNode("//fanart/movie/movielogos/" + hd + "movielogo[@lang = \"" + language + "\"]/@url") ??
|
||||
|
@ -219,11 +213,7 @@ namespace MediaBrowser.Controller.Providers.Movies
|
|||
}
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
var hasArt = item.LocationType == LocationType.FileSystem ?
|
||||
item.ResolveArgs.ContainsMetaFileByName(ArtFile)
|
||||
: item.HasImage(ImageType.Art);
|
||||
|
||||
if (ConfigurationManager.Configuration.DownloadMovieImages.Art && !hasArt)
|
||||
if (ConfigurationManager.Configuration.DownloadMovieImages.Art && !item.HasImage(ImageType.Art))
|
||||
{
|
||||
var node =
|
||||
doc.SelectSingleNode("//fanart/movie/moviearts/" + hd + "movieart[@lang = \"" + language + "\"]/@url") ??
|
||||
|
@ -238,11 +228,7 @@ namespace MediaBrowser.Controller.Providers.Movies
|
|||
}
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
var hasDisc = item.LocationType == LocationType.FileSystem ?
|
||||
item.ResolveArgs.ContainsMetaFileByName(DiscFile)
|
||||
: item.HasImage(ImageType.Disc);
|
||||
|
||||
if (ConfigurationManager.Configuration.DownloadMovieImages.Disc && !hasDisc)
|
||||
if (ConfigurationManager.Configuration.DownloadMovieImages.Disc && !item.HasImage(ImageType.Disc))
|
||||
{
|
||||
var node = doc.SelectSingleNode("//fanart/movie/moviediscs/moviedisc[@lang = \"" + language + "\"]/@url") ??
|
||||
doc.SelectSingleNode("//fanart/movie/moviediscs/moviedisc/@url");
|
||||
|
@ -255,11 +241,7 @@ namespace MediaBrowser.Controller.Providers.Movies
|
|||
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
var hasBanner = item.LocationType == LocationType.FileSystem ?
|
||||
item.ResolveArgs.ContainsMetaFileByName(BannerFile)
|
||||
: item.HasImage(ImageType.Banner);
|
||||
|
||||
if (ConfigurationManager.Configuration.DownloadMovieImages.Banner && !hasBanner)
|
||||
if (ConfigurationManager.Configuration.DownloadMovieImages.Banner && !item.HasImage(ImageType.Banner))
|
||||
{
|
||||
var node = doc.SelectSingleNode("//fanart/movie/moviebanners/moviebanner[@lang = \"" + language + "\"]/@url") ??
|
||||
doc.SelectSingleNode("//fanart/movie/moviebanners/moviebanner/@url");
|
||||
|
@ -272,11 +254,7 @@ namespace MediaBrowser.Controller.Providers.Movies
|
|||
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
var hasThumb = item.LocationType == LocationType.FileSystem ?
|
||||
item.ResolveArgs.ContainsMetaFileByName(ThumbFile)
|
||||
: item.HasImage(ImageType.Thumb);
|
||||
|
||||
if (ConfigurationManager.Configuration.DownloadMovieImages.Thumb && !hasThumb)
|
||||
if (ConfigurationManager.Configuration.DownloadMovieImages.Thumb && !item.HasImage(ImageType.Thumb))
|
||||
{
|
||||
var node = doc.SelectSingleNode("//fanart/movie/moviethumbs/moviethumb[@lang = \"" + language + "\"]/@url") ??
|
||||
doc.SelectSingleNode("//fanart/movie/moviethumbs/moviethumb/@url");
|
||||
|
@ -287,33 +265,29 @@ namespace MediaBrowser.Controller.Providers.Movies
|
|||
}
|
||||
}
|
||||
|
||||
var hasBackdrop = item.LocationType == LocationType.FileSystem ?
|
||||
item.ResolveArgs.ContainsMetaFileByName(BackdropFile)
|
||||
: item.BackdropImagePaths.Count > 0;
|
||||
|
||||
if (ConfigurationManager.Configuration.DownloadMovieImages.Backdrops && !hasBackdrop)
|
||||
if (ConfigurationManager.Configuration.DownloadMovieImages.Backdrops && item.BackdropImagePaths.Count < ConfigurationManager.Configuration.MaxBackdrops)
|
||||
{
|
||||
var nodes = doc.SelectNodes("//fanart/movie/moviebackgrounds//@url");
|
||||
|
||||
if (nodes != null)
|
||||
{
|
||||
var numBackdrops = 0;
|
||||
item.BackdropImagePaths = new List<string>();
|
||||
var numBackdrops = item.BackdropImagePaths.Count;
|
||||
|
||||
foreach (XmlNode node in nodes)
|
||||
{
|
||||
path = node.Value;
|
||||
|
||||
if (!string.IsNullOrEmpty(path))
|
||||
{
|
||||
Logger.Debug("FanArtProvider getting Backdrop for " + item.Name);
|
||||
item.BackdropImagePaths.Add(await _providerManager.DownloadAndSaveImage(item, path, ("backdrop" + (numBackdrops > 0 ? numBackdrops.ToString(UsCulture) : "") + ".jpg"), saveLocal, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
|
||||
|
||||
numBackdrops++;
|
||||
if (numBackdrops >= ConfigurationManager.Configuration.MaxBackdrops) break;
|
||||
|
||||
if (item.BackdropImagePaths.Count >= ConfigurationManager.Configuration.MaxBackdrops) break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
data.Data = GetComparisonData(item.GetProviderId(MetadataProviders.Tmdb));
|
||||
|
|
|
@ -265,7 +265,7 @@ namespace MediaBrowser.Controller.Providers.Movies
|
|||
//still nothing - just get first one
|
||||
profile = searchResult.profiles[0];
|
||||
}
|
||||
if (profile != null)
|
||||
if (profile != null && !person.HasImage(ImageType.Primary))
|
||||
{
|
||||
var tmdbSettings = await MovieDbProvider.Current.GetTmdbSettings(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
|
@ -299,8 +299,7 @@ namespace MediaBrowser.Controller.Providers.Movies
|
|||
|
||||
//download and save locally (if not already there)
|
||||
var localPath = Path.Combine(item.MetaLocation, targetName);
|
||||
if (!item.ResolveArgs.ContainsMetaFileByName(targetName))
|
||||
{
|
||||
|
||||
using (var sourceStream = await MovieDbProvider.Current.GetMovieDbResponse(new HttpRequestOptions
|
||||
{
|
||||
Url = source,
|
||||
|
@ -312,7 +311,7 @@ namespace MediaBrowser.Controller.Providers.Movies
|
|||
|
||||
Logger.Debug("TmdbPersonProvider downloaded and saved image for {0}", item.Name);
|
||||
}
|
||||
}
|
||||
|
||||
return localPath;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
using MediaBrowser.Common.Extensions;
|
||||
using System.Globalization;
|
||||
using MediaBrowser.Common.Extensions;
|
||||
using MediaBrowser.Common.Net;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Entities.TV;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Model.Logging;
|
||||
using MediaBrowser.Model.Net;
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
@ -80,6 +80,8 @@ namespace MediaBrowser.Controller.Providers.TV
|
|||
return string.IsNullOrEmpty(id) ? Guid.Empty : id.GetMD5();
|
||||
}
|
||||
|
||||
protected readonly CultureInfo UsCulture = new CultureInfo("en-US");
|
||||
|
||||
public override async Task<bool> FetchAsync(BaseItem item, bool force, CancellationToken cancellationToken)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
@ -113,11 +115,9 @@ namespace MediaBrowser.Controller.Providers.TV
|
|||
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
if (doc.HasChildNodes)
|
||||
{
|
||||
string path;
|
||||
var hd = ConfigurationManager.Configuration.DownloadHDFanArt ? "hdtv" : "clear";
|
||||
if (ConfigurationManager.Configuration.DownloadSeriesImages.Logo && !series.ResolveArgs.ContainsMetaFileByName(LogoFile))
|
||||
if (ConfigurationManager.Configuration.DownloadSeriesImages.Logo && !series.HasImage(ImageType.Logo))
|
||||
{
|
||||
var node = doc.SelectSingleNode("//fanart/series/" + hd + "logos/" + hd + "logo[@lang = \"" + language + "\"]/@url") ??
|
||||
doc.SelectSingleNode("//fanart/series/clearlogos/clearlogo[@lang = \"" + language + "\"]/@url") ??
|
||||
|
@ -134,7 +134,7 @@ namespace MediaBrowser.Controller.Providers.TV
|
|||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
hd = ConfigurationManager.Configuration.DownloadHDFanArt ? "hd" : "";
|
||||
if (ConfigurationManager.Configuration.DownloadSeriesImages.Art && !series.ResolveArgs.ContainsMetaFileByName(ArtFile))
|
||||
if (ConfigurationManager.Configuration.DownloadSeriesImages.Art && !series.HasImage(ImageType.Art))
|
||||
{
|
||||
var node = doc.SelectSingleNode("//fanart/series/" + hd + "cleararts/" + hd + "clearart[@lang = \"" + language + "\"]/@url") ??
|
||||
doc.SelectSingleNode("//fanart/series/cleararts/clearart[@lang = \"" + language + "\"]/@url") ??
|
||||
|
@ -150,7 +150,7 @@ namespace MediaBrowser.Controller.Providers.TV
|
|||
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
if (ConfigurationManager.Configuration.DownloadSeriesImages.Thumb && !series.ResolveArgs.ContainsMetaFileByName(ThumbFile))
|
||||
if (ConfigurationManager.Configuration.DownloadSeriesImages.Thumb && !series.HasImage(ImageType.Thumb))
|
||||
{
|
||||
var node = doc.SelectSingleNode("//fanart/series/tvthumbs/tvthumb[@lang = \"" + language + "\"]/@url") ??
|
||||
doc.SelectSingleNode("//fanart/series/tvthumbs/tvthumb/@url");
|
||||
|
@ -162,7 +162,7 @@ namespace MediaBrowser.Controller.Providers.TV
|
|||
}
|
||||
}
|
||||
|
||||
if (ConfigurationManager.Configuration.DownloadSeriesImages.Banner && !series.ResolveArgs.ContainsMetaFileByName(BannerFile))
|
||||
if (ConfigurationManager.Configuration.DownloadSeriesImages.Banner && !series.HasImage(ImageType.Banner))
|
||||
{
|
||||
var node = doc.SelectSingleNode("//fanart/series/tbbanners/tvbanner[@lang = \"" + language + "\"]/@url") ??
|
||||
doc.SelectSingleNode("//fanart/series/tbbanners/tvbanner/@url");
|
||||
|
@ -173,7 +173,32 @@ namespace MediaBrowser.Controller.Providers.TV
|
|||
series.SetImage(ImageType.Banner, await _providerManager.DownloadAndSaveImage(series, path, BannerFile, ConfigurationManager.Configuration.SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
|
||||
}
|
||||
}
|
||||
|
||||
if (ConfigurationManager.Configuration.DownloadMovieImages.Backdrops && item.BackdropImagePaths.Count < ConfigurationManager.Configuration.MaxBackdrops)
|
||||
{
|
||||
var nodes = doc.SelectNodes("//fanart/series/showbackgrounds//@url");
|
||||
|
||||
if (nodes != null)
|
||||
{
|
||||
var numBackdrops = item.BackdropImagePaths.Count;
|
||||
|
||||
foreach (XmlNode node in nodes)
|
||||
{
|
||||
path = node.Value;
|
||||
|
||||
if (!string.IsNullOrEmpty(path))
|
||||
{
|
||||
item.BackdropImagePaths.Add(await _providerManager.DownloadAndSaveImage(item, path, ("backdrop" + (numBackdrops > 0 ? numBackdrops.ToString(UsCulture) : "") + ".jpg"), ConfigurationManager.Configuration.SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
|
||||
|
||||
numBackdrops++;
|
||||
|
||||
if (item.BackdropImagePaths.Count >= ConfigurationManager.Configuration.MaxBackdrops) break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
data.Data = GetComparisonData(item.GetProviderId(MetadataProviders.Tvdb));
|
||||
SetLastRefreshed(series, DateTime.UtcNow, status);
|
||||
|
|
|
@ -7,7 +7,6 @@ using MediaBrowser.Controller.Library;
|
|||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Model.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
using System.Globalization;
|
||||
using MediaBrowser.Common.Extensions;
|
||||
using MediaBrowser.Common.Extensions;
|
||||
using MediaBrowser.Common.Net;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
|
@ -8,6 +7,7 @@ using MediaBrowser.Controller.Library;
|
|||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Model.Logging;
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
@ -257,6 +257,7 @@ namespace MediaBrowser.Controller.Providers.TV
|
|||
if (series.BackdropImagePaths.Count < ConfigurationManager.Configuration.MaxBackdrops)
|
||||
{
|
||||
var bdNo = series.BackdropImagePaths.Count;
|
||||
|
||||
var xmlNodeList = images.SelectNodes("//Banner[BannerType='fanart']");
|
||||
if (xmlNodeList != null)
|
||||
{
|
||||
|
|
|
@ -388,7 +388,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) {
|
|||
|
||||
var url = self.getUrl("Items/" + itemId + "/Refresh", {
|
||||
|
||||
force: force || false,
|
||||
forced: force || false,
|
||||
recursive: recursive || false
|
||||
|
||||
});
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="MediaBrowser.ApiClient.Javascript" version="3.0.117" targetFramework="net45" />
|
||||
<package id="MediaBrowser.ApiClient.Javascript" version="3.0.118" targetFramework="net45" />
|
||||
<package id="ServiceStack.Common" version="3.9.46" targetFramework="net45" />
|
||||
<package id="ServiceStack.Text" version="3.9.45" targetFramework="net45" />
|
||||
</packages>
|
Loading…
Reference in New Issue
Block a user