fixes #281 - Metadata images incomplete
This commit is contained in:
parent
4cd7030248
commit
4c971ed161
|
@ -91,12 +91,13 @@ namespace MediaBrowser.Controller.Providers
|
|||
}
|
||||
|
||||
// Only validate paths from the same directory - need to copy to a list because we are going to potentially modify the collection below
|
||||
var deletedKeys = item.Images.Keys.Where(image =>
|
||||
var deletedKeys = item.Images.ToList().Where(image =>
|
||||
{
|
||||
var path = item.Images[image];
|
||||
var path = image.Value;
|
||||
|
||||
return IsInMetaLocation(item, path) && item.ResolveArgs.GetMetaFileByPath(path) == null;
|
||||
}).ToList();
|
||||
|
||||
}).Select(i => i.Key).ToList();
|
||||
|
||||
// Now remove them from the dictionary
|
||||
foreach (var key in deletedKeys)
|
||||
|
|
|
@ -46,11 +46,11 @@ namespace MediaBrowser.Controller.Providers.TV
|
|||
/// <summary>
|
||||
/// The episode query
|
||||
/// </summary>
|
||||
private const string episodeQuery = "http://www.thetvdb.com/api/{0}/series/{1}/default/{2}/{3}/{4}.xml";
|
||||
private const string EpisodeQuery = "http://www.thetvdb.com/api/{0}/series/{1}/default/{2}/{3}/{4}.xml";
|
||||
/// <summary>
|
||||
/// The abs episode query
|
||||
/// </summary>
|
||||
private const string absEpisodeQuery = "http://www.thetvdb.com/api/{0}/series/{1}/absolute/{2}/{3}.xml";
|
||||
private const string AbsEpisodeQuery = "http://www.thetvdb.com/api/{0}/series/{1}/absolute/{2}/{3}.xml";
|
||||
|
||||
/// <summary>
|
||||
/// Supportses the specified item.
|
||||
|
@ -179,11 +179,9 @@ namespace MediaBrowser.Controller.Providers.TV
|
|||
seasonNumber = "0"; // Specials
|
||||
}
|
||||
|
||||
var url = string.Format(episodeQuery, TVUtils.TvdbApiKey, seriesId, seasonNumber, episodeNumber, ConfigurationManager.Configuration.PreferredMetadataLanguage);
|
||||
var url = string.Format(EpisodeQuery, TVUtils.TvdbApiKey, seriesId, seasonNumber, episodeNumber, ConfigurationManager.Configuration.PreferredMetadataLanguage);
|
||||
var doc = new XmlDocument();
|
||||
|
||||
try
|
||||
{
|
||||
using (var result = await HttpClient.Get(new HttpRequestOptions
|
||||
{
|
||||
Url = url,
|
||||
|
@ -195,20 +193,14 @@ namespace MediaBrowser.Controller.Providers.TV
|
|||
{
|
||||
doc.Load(result);
|
||||
}
|
||||
}
|
||||
catch (HttpException)
|
||||
{
|
||||
}
|
||||
|
||||
//episode does not exist under this season, try absolute numbering.
|
||||
//still assuming it's numbered as 1x01
|
||||
//this is basicly just for anime.
|
||||
if (!doc.HasChildNodes && Int32.Parse(seasonNumber) == 1)
|
||||
{
|
||||
url = string.Format(absEpisodeQuery, TVUtils.TvdbApiKey, seriesId, episodeNumber, ConfigurationManager.Configuration.PreferredMetadataLanguage);
|
||||
url = string.Format(AbsEpisodeQuery, TVUtils.TvdbApiKey, seriesId, episodeNumber, ConfigurationManager.Configuration.PreferredMetadataLanguage);
|
||||
|
||||
try
|
||||
{
|
||||
using (var result = await HttpClient.Get(new HttpRequestOptions
|
||||
{
|
||||
Url = url,
|
||||
|
@ -222,10 +214,6 @@ namespace MediaBrowser.Controller.Providers.TV
|
|||
usingAbsoluteData = true;
|
||||
}
|
||||
}
|
||||
catch (HttpException)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
if (doc.HasChildNodes)
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
|
@ -11,6 +10,7 @@ using MediaBrowser.Model.Logging;
|
|||
using MediaBrowser.Model.Net;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
|
@ -142,8 +142,7 @@ namespace MediaBrowser.Controller.Providers.TV
|
|||
|
||||
if (item.DontFetchMeta) return false;
|
||||
|
||||
return !HasLocalMeta(item) && (ConfigurationManager.Configuration.MetadataRefreshDays != -1 &&
|
||||
DateTime.UtcNow.Subtract(downloadDate).TotalDays > ConfigurationManager.Configuration.MetadataRefreshDays);
|
||||
return !HasLocalMeta(item) && base.NeedsRefreshInternal(item, providerInfo);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -165,15 +164,16 @@ namespace MediaBrowser.Controller.Providers.TV
|
|||
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
var status = ProviderRefreshStatus.Success;
|
||||
|
||||
if (!string.IsNullOrEmpty(seriesId))
|
||||
{
|
||||
series.SetProviderId(MetadataProviders.Tvdb, seriesId);
|
||||
if (!HasCompleteMetadata(series))
|
||||
{
|
||||
await FetchSeriesData(series, seriesId, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
status = await FetchSeriesData(series, seriesId, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
SetLastRefreshed(item, DateTime.UtcNow);
|
||||
|
||||
SetLastRefreshed(item, DateTime.UtcNow, status);
|
||||
return true;
|
||||
}
|
||||
Logger.Info("Series provider not fetching because local meta exists or requested to ignore: " + item.Name);
|
||||
|
@ -188,11 +188,9 @@ 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> FetchSeriesData(Series series, string seriesId, CancellationToken cancellationToken)
|
||||
private async Task<ProviderRefreshStatus> FetchSeriesData(Series series, string seriesId, CancellationToken cancellationToken)
|
||||
{
|
||||
var success = false;
|
||||
|
||||
var name = series.Name;
|
||||
var status = ProviderRefreshStatus.Success;
|
||||
|
||||
if (!string.IsNullOrEmpty(seriesId))
|
||||
{
|
||||
|
@ -200,8 +198,6 @@ namespace MediaBrowser.Controller.Providers.TV
|
|||
string url = string.Format(seriesGet, TVUtils.TvdbApiKey, seriesId, ConfigurationManager.Configuration.PreferredMetadataLanguage);
|
||||
var doc = new XmlDocument();
|
||||
|
||||
try
|
||||
{
|
||||
using (var xml = await HttpClient.Get(new HttpRequestOptions
|
||||
{
|
||||
Url = url,
|
||||
|
@ -213,10 +209,6 @@ namespace MediaBrowser.Controller.Providers.TV
|
|||
{
|
||||
doc.Load(xml);
|
||||
}
|
||||
}
|
||||
catch (HttpException)
|
||||
{
|
||||
}
|
||||
|
||||
if (doc.HasChildNodes)
|
||||
{
|
||||
|
@ -224,8 +216,6 @@ namespace MediaBrowser.Controller.Providers.TV
|
|||
var actorTask = FetchActors(series, seriesId, doc, cancellationToken);
|
||||
var imageTask = FetchImages(series, seriesId, cancellationToken);
|
||||
|
||||
success = true;
|
||||
|
||||
series.Name = doc.SafeGetString("//SeriesName");
|
||||
series.Overview = doc.SafeGetString("//Overview");
|
||||
series.CommunityRating = doc.SafeGetSingle("//Rating", 0, 10);
|
||||
|
@ -268,8 +258,15 @@ namespace MediaBrowser.Controller.Providers.TV
|
|||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
//wait for other tasks
|
||||
await Task.WhenAll(actorTask, imageTask).ConfigureAwait(false);
|
||||
}
|
||||
catch (HttpException)
|
||||
{
|
||||
status = ProviderRefreshStatus.CompletedWithErrors;
|
||||
}
|
||||
|
||||
if (ConfigurationManager.Configuration.SaveLocalMeta)
|
||||
{
|
||||
|
@ -281,9 +278,7 @@ namespace MediaBrowser.Controller.Providers.TV
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
return success;
|
||||
return status;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -299,8 +294,6 @@ namespace MediaBrowser.Controller.Providers.TV
|
|||
string urlActors = string.Format(getActors, TVUtils.TvdbApiKey, seriesId);
|
||||
var docActors = new XmlDocument();
|
||||
|
||||
try
|
||||
{
|
||||
using (var actors = await HttpClient.Get(new HttpRequestOptions
|
||||
{
|
||||
Url = urlActors,
|
||||
|
@ -312,10 +305,6 @@ namespace MediaBrowser.Controller.Providers.TV
|
|||
{
|
||||
docActors.Load(actors);
|
||||
}
|
||||
}
|
||||
catch (HttpException)
|
||||
{
|
||||
}
|
||||
|
||||
if (docActors.HasChildNodes)
|
||||
{
|
||||
|
@ -380,8 +369,6 @@ namespace MediaBrowser.Controller.Providers.TV
|
|||
string url = string.Format("http://www.thetvdb.com/api/" + TVUtils.TvdbApiKey + "/series/{0}/banners.xml", seriesId);
|
||||
var images = new XmlDocument();
|
||||
|
||||
try
|
||||
{
|
||||
using (var imgs = await HttpClient.Get(new HttpRequestOptions
|
||||
{
|
||||
Url = url,
|
||||
|
@ -393,10 +380,6 @@ namespace MediaBrowser.Controller.Providers.TV
|
|||
{
|
||||
images.Load(imgs);
|
||||
}
|
||||
}
|
||||
catch (HttpException)
|
||||
{
|
||||
}
|
||||
|
||||
if (images.HasChildNodes)
|
||||
{
|
||||
|
@ -407,19 +390,9 @@ namespace MediaBrowser.Controller.Providers.TV
|
|||
{
|
||||
n = n.SelectSingleNode("./BannerPath");
|
||||
if (n != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
series.PrimaryImagePath = await _providerManager.DownloadAndSaveImage(series, TVUtils.BannerUrl + n.InnerText, "folder" + Path.GetExtension(n.InnerText), ConfigurationManager.Configuration.SaveLocalMeta, TvDbResourcePool, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
catch (HttpException)
|
||||
{
|
||||
}
|
||||
catch (IOException)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -430,21 +403,11 @@ namespace MediaBrowser.Controller.Providers.TV
|
|||
{
|
||||
n = n.SelectSingleNode("./BannerPath");
|
||||
if (n != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
var bannerImagePath = await _providerManager.DownloadAndSaveImage(series, TVUtils.BannerUrl + n.InnerText, "banner" + Path.GetExtension(n.InnerText), ConfigurationManager.Configuration.SaveLocalMeta, TvDbResourcePool, cancellationToken);
|
||||
|
||||
series.SetImage(ImageType.Banner, bannerImagePath);
|
||||
}
|
||||
catch (HttpException)
|
||||
{
|
||||
}
|
||||
catch (IOException)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -459,19 +422,9 @@ namespace MediaBrowser.Controller.Providers.TV
|
|||
{
|
||||
var bdName = "backdrop" + (bdNo > 0 ? bdNo.ToString(UsCulture) : "");
|
||||
if (ConfigurationManager.Configuration.RefreshItemImages || !series.HasLocalImage(bdName))
|
||||
{
|
||||
try
|
||||
{
|
||||
series.BackdropImagePaths.Add(await _providerManager.DownloadAndSaveImage(series, TVUtils.BannerUrl + p.InnerText, bdName + Path.GetExtension(p.InnerText), ConfigurationManager.Configuration.SaveLocalMeta, TvDbResourcePool, cancellationToken).ConfigureAwait(false));
|
||||
}
|
||||
catch (HttpException)
|
||||
{
|
||||
}
|
||||
catch (IOException)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
bdNo++;
|
||||
if (bdNo >= ConfigurationManager.Configuration.MaxBackdrops) break;
|
||||
}
|
||||
|
@ -480,18 +433,6 @@ namespace MediaBrowser.Controller.Providers.TV
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether [has complete metadata] [the specified series].
|
||||
/// </summary>
|
||||
/// <param name="series">The series.</param>
|
||||
/// <returns><c>true</c> if [has complete metadata] [the specified series]; otherwise, <c>false</c>.</returns>
|
||||
private bool HasCompleteMetadata(Series series)
|
||||
{
|
||||
return (series.HasImage(ImageType.Banner)) && (series.CommunityRating != null)
|
||||
&& (series.Overview != null) && (series.Name != null) && (series.People != null)
|
||||
&& (series.Genres != null) && (series.OfficialRating != null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether [has local meta] [the specified item].
|
||||
/// </summary>
|
||||
|
@ -499,9 +440,7 @@ namespace MediaBrowser.Controller.Providers.TV
|
|||
/// <returns><c>true</c> if [has local meta] [the specified item]; otherwise, <c>false</c>.</returns>
|
||||
private bool HasLocalMeta(BaseItem item)
|
||||
{
|
||||
//need at least the xml and folder.jpg/png
|
||||
return item.ResolveArgs.ContainsMetaFileByName(LOCAL_META_FILE_NAME) && (item.ResolveArgs.ContainsMetaFileByName("folder.jpg") ||
|
||||
item.ResolveArgs.ContainsMetaFileByName("folder.png"));
|
||||
return item.ResolveArgs.ContainsMetaFileByName(LOCAL_META_FILE_NAME);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
Loading…
Reference in New Issue
Block a user