mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-09-06 13:57:14 -04:00
make sure providers are trying again when appropiate
This commit is contained in:
parent
25314e1fc9
commit
2bd2a7bc68
@ -62,23 +62,15 @@ namespace MediaBrowser.Controller.Providers.MediaInfo
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Needses the refresh internal.
|
||||
/// Gets a value indicating whether [refresh on version change].
|
||||
/// </summary>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <param name="providerInfo">The provider info.</param>
|
||||
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns>
|
||||
protected override bool NeedsRefreshInternal(BaseItem item, BaseProviderInfo providerInfo)
|
||||
/// <value><c>true</c> if [refresh on version change]; otherwise, <c>false</c>.</value>
|
||||
protected override bool RefreshOnVersionChange
|
||||
{
|
||||
// If the last run wasn't successful, try again when there's a new version of ffmpeg
|
||||
if (providerInfo.LastRefreshStatus != ProviderRefreshStatus.Success)
|
||||
get
|
||||
{
|
||||
if (!string.Equals(ProviderVersion, providerInfo.ProviderVersion))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return base.NeedsRefreshInternal(item, providerInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -117,18 +117,6 @@ namespace MediaBrowser.Controller.Providers.MediaInfo
|
||||
return await MediaEncoder.GetMediaInfo(inputPath, type, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether [refresh on version change].
|
||||
/// </summary>
|
||||
/// <value><c>true</c> if [refresh on version change]; otherwise, <c>false</c>.</value>
|
||||
protected override bool RefreshOnVersionChange
|
||||
{
|
||||
get
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Mounts the iso if needed.
|
||||
/// </summary>
|
||||
|
@ -214,14 +214,7 @@ namespace MediaBrowser.Controller.Providers.Movies
|
||||
path = node != null ? node.Value : null;
|
||||
if (!string.IsNullOrEmpty(path))
|
||||
{
|
||||
try
|
||||
{
|
||||
movie.SetImage(ImageType.Logo, await _providerManager.DownloadAndSaveImage(movie, path, LOGO_FILE, saveLocal, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
|
||||
}
|
||||
catch (HttpException)
|
||||
{
|
||||
status = ProviderRefreshStatus.CompletedWithErrors;
|
||||
}
|
||||
movie.SetImage(ImageType.Logo, await _providerManager.DownloadAndSaveImage(movie, path, LOGO_FILE, saveLocal, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
|
||||
}
|
||||
}
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
@ -240,14 +233,7 @@ namespace MediaBrowser.Controller.Providers.Movies
|
||||
path = node != null ? node.Value : null;
|
||||
if (!string.IsNullOrEmpty(path))
|
||||
{
|
||||
try
|
||||
{
|
||||
movie.SetImage(ImageType.Art, await _providerManager.DownloadAndSaveImage(movie, path, ART_FILE, saveLocal, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
|
||||
}
|
||||
catch (HttpException)
|
||||
{
|
||||
status = ProviderRefreshStatus.CompletedWithErrors;
|
||||
}
|
||||
movie.SetImage(ImageType.Art, await _providerManager.DownloadAndSaveImage(movie, path, ART_FILE, saveLocal, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
|
||||
}
|
||||
}
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
@ -263,14 +249,7 @@ namespace MediaBrowser.Controller.Providers.Movies
|
||||
path = node != null ? node.Value : null;
|
||||
if (!string.IsNullOrEmpty(path))
|
||||
{
|
||||
try
|
||||
{
|
||||
movie.SetImage(ImageType.Disc, await _providerManager.DownloadAndSaveImage(movie, path, DISC_FILE, saveLocal, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
|
||||
}
|
||||
catch (HttpException)
|
||||
{
|
||||
status = ProviderRefreshStatus.CompletedWithErrors;
|
||||
}
|
||||
movie.SetImage(ImageType.Disc, await _providerManager.DownloadAndSaveImage(movie, path, DISC_FILE, saveLocal, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
|
||||
}
|
||||
}
|
||||
|
||||
@ -287,14 +266,7 @@ namespace MediaBrowser.Controller.Providers.Movies
|
||||
path = node != null ? node.Value : null;
|
||||
if (!string.IsNullOrEmpty(path))
|
||||
{
|
||||
try
|
||||
{
|
||||
movie.SetImage(ImageType.Banner, await _providerManager.DownloadAndSaveImage(movie, path, BANNER_FILE, saveLocal, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
|
||||
}
|
||||
catch (HttpException)
|
||||
{
|
||||
status = ProviderRefreshStatus.CompletedWithErrors;
|
||||
}
|
||||
movie.SetImage(ImageType.Banner, await _providerManager.DownloadAndSaveImage(movie, path, BANNER_FILE, saveLocal, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
|
||||
}
|
||||
}
|
||||
|
||||
@ -311,14 +283,7 @@ namespace MediaBrowser.Controller.Providers.Movies
|
||||
path = node != null ? node.Value : null;
|
||||
if (!string.IsNullOrEmpty(path))
|
||||
{
|
||||
try
|
||||
{
|
||||
movie.SetImage(ImageType.Thumb, await _providerManager.DownloadAndSaveImage(movie, path, THUMB_FILE, saveLocal, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
|
||||
}
|
||||
catch (HttpException)
|
||||
{
|
||||
status = ProviderRefreshStatus.CompletedWithErrors;
|
||||
}
|
||||
movie.SetImage(ImageType.Thumb, await _providerManager.DownloadAndSaveImage(movie, path, THUMB_FILE, saveLocal, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
|
||||
}
|
||||
}
|
||||
|
||||
@ -339,16 +304,9 @@ namespace MediaBrowser.Controller.Providers.Movies
|
||||
if (!string.IsNullOrEmpty(path))
|
||||
{
|
||||
Logger.Debug("FanArtProvider getting Backdrop for " + item.Name);
|
||||
try
|
||||
{
|
||||
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;
|
||||
}
|
||||
catch (HttpException)
|
||||
{
|
||||
status = ProviderRefreshStatus.CompletedWithErrors;
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -238,7 +238,7 @@ namespace MediaBrowser.Controller.Providers.Movies
|
||||
// poster
|
||||
if (images.posters != null && images.posters.Count > 0 && (ConfigurationManager.Configuration.RefreshItemImages || !hasLocalPoster))
|
||||
{
|
||||
var tmdbSettings = await MovieDbProvider.Current.TmdbSettings.ConfigureAwait(false);
|
||||
var tmdbSettings = await MovieDbProvider.Current.GetTmdbSettings(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
var tmdbImageUrl = tmdbSettings.images.base_url + ConfigurationManager.Configuration.TmdbFetchedPosterSize;
|
||||
// get highest rated poster for our language
|
||||
@ -281,7 +281,7 @@ namespace MediaBrowser.Controller.Providers.Movies
|
||||
{
|
||||
item.BackdropImagePaths = new List<string>();
|
||||
|
||||
var tmdbSettings = await MovieDbProvider.Current.TmdbSettings.ConfigureAwait(false);
|
||||
var tmdbSettings = await MovieDbProvider.Current.GetTmdbSettings(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
var tmdbImageUrl = tmdbSettings.images.base_url + ConfigurationManager.Configuration.TmdbFetchedBackdropSize;
|
||||
//backdrops should be in order of rating. get first n ones
|
||||
|
@ -5,7 +5,6 @@ using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Entities.Movies;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Model.Logging;
|
||||
using MediaBrowser.Model.Net;
|
||||
using MediaBrowser.Model.Serialization;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@ -20,14 +19,6 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace MediaBrowser.Controller.Providers.Movies
|
||||
{
|
||||
class MovieDbProviderException : ApplicationException
|
||||
{
|
||||
public MovieDbProviderException(string msg)
|
||||
: base(msg)
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// Class MovieDbProvider
|
||||
/// </summary>
|
||||
@ -154,85 +145,42 @@ namespace MediaBrowser.Controller.Providers.Movies
|
||||
/// <summary>
|
||||
/// The _TMDB settings task
|
||||
/// </summary>
|
||||
private Task<TmdbSettingsResult> _tmdbSettingsTask;
|
||||
/// <summary>
|
||||
/// The _TMDB settings task initialized
|
||||
/// </summary>
|
||||
private bool _tmdbSettingsTaskInitialized;
|
||||
/// <summary>
|
||||
/// The _TMDB settings task sync lock
|
||||
/// </summary>
|
||||
private object _tmdbSettingsTaskSyncLock = new object();
|
||||
private TmdbSettingsResult _tmdbSettings;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the TMDB settings.
|
||||
/// </summary>
|
||||
/// <value>The TMDB settings.</value>
|
||||
public Task<TmdbSettingsResult> TmdbSettings
|
||||
{
|
||||
get
|
||||
{
|
||||
LazyInitializer.EnsureInitialized(ref _tmdbSettingsTask, ref _tmdbSettingsTaskInitialized, ref _tmdbSettingsTaskSyncLock, () => GetTmdbSettings(JsonSerializer));
|
||||
return _tmdbSettingsTask;
|
||||
}
|
||||
}
|
||||
private readonly SemaphoreSlim _tmdbSettingsSemaphore = new SemaphoreSlim(1, 1);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the TMDB settings.
|
||||
/// </summary>
|
||||
/// <returns>Task{TmdbSettingsResult}.</returns>
|
||||
private async Task<TmdbSettingsResult> GetTmdbSettings(IJsonSerializer jsonSerializer)
|
||||
internal async Task<TmdbSettingsResult> GetTmdbSettings(CancellationToken cancellationToken)
|
||||
{
|
||||
if (_tmdbSettings != null)
|
||||
{
|
||||
return _tmdbSettings;
|
||||
}
|
||||
|
||||
await _tmdbSettingsSemaphore.WaitAsync(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
try
|
||||
{
|
||||
using (var json = await GetMovieDbResponse(new HttpRequestOptions
|
||||
{
|
||||
Url = string.Format(TmdbConfigUrl, ApiKey),
|
||||
CancellationToken = CancellationToken.None,
|
||||
CancellationToken = cancellationToken,
|
||||
AcceptHeader = AcceptHeader,
|
||||
EnableResponseCache = true
|
||||
|
||||
}).ConfigureAwait(false))
|
||||
{
|
||||
return jsonSerializer.DeserializeFromStream<TmdbSettingsResult>(json);
|
||||
_tmdbSettings = JsonSerializer.DeserializeFromStream<TmdbSettingsResult>(json);
|
||||
|
||||
return _tmdbSettings;
|
||||
}
|
||||
}
|
||||
catch (HttpException)
|
||||
finally
|
||||
{
|
||||
return new TmdbSettingsResult
|
||||
{
|
||||
images = new TmdbImageSettings
|
||||
{
|
||||
backdrop_sizes =
|
||||
new List<string>
|
||||
{
|
||||
"w380",
|
||||
"w780",
|
||||
"w1280",
|
||||
"original"
|
||||
},
|
||||
poster_sizes =
|
||||
new List<string>
|
||||
{
|
||||
"w92",
|
||||
"w154",
|
||||
"w185",
|
||||
"w342",
|
||||
"w500",
|
||||
"original"
|
||||
},
|
||||
profile_sizes =
|
||||
new List<string>
|
||||
{
|
||||
"w45",
|
||||
"w185",
|
||||
"h632",
|
||||
"original"
|
||||
},
|
||||
base_url = "http://cf2.imgobject.com/t/p/"
|
||||
|
||||
}
|
||||
};
|
||||
_tmdbSettingsSemaphore.Release();
|
||||
}
|
||||
}
|
||||
|
||||
@ -284,13 +232,16 @@ namespace MediaBrowser.Controller.Providers.Movies
|
||||
new Regex(@"(?<name>.*)") // last resort matches the whole string as the name
|
||||
};
|
||||
|
||||
public const string LOCAL_META_FILE_NAME = "tmdb3.json";
|
||||
public const string ALT_META_FILE_NAME = "movie.xml";
|
||||
public const string LocalMetaFileName = "tmdb3.json";
|
||||
public const string AltMetaFileName = "movie.xml";
|
||||
|
||||
protected override bool NeedsRefreshInternal(BaseItem item, BaseProviderInfo providerInfo)
|
||||
{
|
||||
if (item.DontFetchMeta) return false;
|
||||
|
||||
if (HasAltMeta(item))
|
||||
return false; //never refresh if has meta from other source
|
||||
|
||||
if (item.LocationType == LocationType.FileSystem &&
|
||||
ConfigurationManager.Configuration.SaveLocalMeta &&
|
||||
HasFileSystemStampChanged(item, providerInfo))
|
||||
@ -302,31 +253,7 @@ namespace MediaBrowser.Controller.Providers.Movies
|
||||
|
||||
}
|
||||
|
||||
if (providerInfo.LastRefreshStatus != ProviderRefreshStatus.Success)
|
||||
{
|
||||
Logger.Debug("MovieProvider for {0} - last attempt had errors. Will try again.", item.Path);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (RefreshOnVersionChange && !String.Equals(ProviderVersion, providerInfo.ProviderVersion))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
var downloadDate = providerInfo.LastRefreshed;
|
||||
|
||||
if (ConfigurationManager.Configuration.MetadataRefreshDays == -1 && downloadDate != DateTime.MinValue)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (DateTime.Today.Subtract(downloadDate).TotalDays < ConfigurationManager.Configuration.MetadataRefreshDays) // only refresh every n days
|
||||
return false;
|
||||
|
||||
if (HasAltMeta(item))
|
||||
return false; //never refresh if has meta from other source
|
||||
|
||||
return true;
|
||||
return base.NeedsRefreshInternal(item, providerInfo);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -354,19 +281,13 @@ namespace MediaBrowser.Controller.Providers.Movies
|
||||
|
||||
if (!ConfigurationManager.Configuration.SaveLocalMeta || !HasLocalMeta(item) || (force && !HasLocalMeta(item)))
|
||||
{
|
||||
try
|
||||
{
|
||||
await FetchMovieData(item, cancellationToken).ConfigureAwait(false);
|
||||
SetLastRefreshed(item, DateTime.UtcNow);
|
||||
}
|
||||
catch (MovieDbProviderException)
|
||||
{
|
||||
SetLastRefreshed(item, DateTime.UtcNow, ProviderRefreshStatus.CompletedWithErrors);
|
||||
}
|
||||
|
||||
return true;
|
||||
await FetchMovieData(item, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
Logger.Debug("MovieDBProvider not fetching because local meta exists for " + item.Name);
|
||||
else
|
||||
{
|
||||
Logger.Debug("MovieDBProvider not fetching because local meta exists for " + item.Name);
|
||||
}
|
||||
|
||||
SetLastRefreshed(item, DateTime.UtcNow);
|
||||
return true;
|
||||
}
|
||||
@ -379,7 +300,7 @@ namespace MediaBrowser.Controller.Providers.Movies
|
||||
private bool HasLocalMeta(BaseItem item)
|
||||
{
|
||||
//need at least the xml and folder.jpg/png or a movie.xml put in by someone else
|
||||
return item.LocationType == LocationType.FileSystem && item.ResolveArgs.ContainsMetaFileByName(LOCAL_META_FILE_NAME);
|
||||
return item.LocationType == LocationType.FileSystem && item.ResolveArgs.ContainsMetaFileByName(LocalMetaFileName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -389,7 +310,7 @@ namespace MediaBrowser.Controller.Providers.Movies
|
||||
/// <returns><c>true</c> if [has alt meta] [the specified item]; otherwise, <c>false</c>.</returns>
|
||||
private bool HasAltMeta(BaseItem item)
|
||||
{
|
||||
return item.LocationType == LocationType.FileSystem && item.ResolveArgs.ContainsMetaFileByName(ALT_META_FILE_NAME);
|
||||
return item.LocationType == LocationType.FileSystem && item.ResolveArgs.ContainsMetaFileByName(AltMetaFileName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -557,23 +478,18 @@ namespace MediaBrowser.Controller.Providers.Movies
|
||||
string url3 = string.Format(Search3, UrlEncode(name), ApiKey, language);
|
||||
TmdbMovieSearchResults searchResult = null;
|
||||
|
||||
try
|
||||
using (Stream json = await GetMovieDbResponse(new HttpRequestOptions
|
||||
{
|
||||
using (Stream json = await GetMovieDbResponse(new HttpRequestOptions
|
||||
{
|
||||
Url = url3,
|
||||
CancellationToken = cancellationToken,
|
||||
AcceptHeader = AcceptHeader,
|
||||
EnableResponseCache = true
|
||||
Url = url3,
|
||||
CancellationToken = cancellationToken,
|
||||
AcceptHeader = AcceptHeader,
|
||||
EnableResponseCache = true
|
||||
|
||||
}).ConfigureAwait(false))
|
||||
{
|
||||
searchResult = JsonSerializer.DeserializeFromStream<TmdbMovieSearchResults>(json);
|
||||
}
|
||||
}
|
||||
catch (HttpException)
|
||||
}).ConfigureAwait(false))
|
||||
{
|
||||
searchResult = JsonSerializer.DeserializeFromStream<TmdbMovieSearchResults>(json);
|
||||
}
|
||||
|
||||
if (searchResult == null || searchResult.results.Count == 0)
|
||||
{
|
||||
//try replacing numbers
|
||||
@ -596,22 +512,16 @@ namespace MediaBrowser.Controller.Providers.Movies
|
||||
Logger.Info("MovieDBProvider - No results. Trying replacement numbers: " + name);
|
||||
url3 = string.Format(Search3, UrlEncode(name), ApiKey, language);
|
||||
|
||||
try
|
||||
using (var json = await GetMovieDbResponse(new HttpRequestOptions
|
||||
{
|
||||
using (var json = await GetMovieDbResponse(new HttpRequestOptions
|
||||
{
|
||||
Url = url3,
|
||||
CancellationToken = cancellationToken,
|
||||
AcceptHeader = AcceptHeader,
|
||||
EnableResponseCache = true
|
||||
Url = url3,
|
||||
CancellationToken = cancellationToken,
|
||||
AcceptHeader = AcceptHeader,
|
||||
EnableResponseCache = true
|
||||
|
||||
}).ConfigureAwait(false))
|
||||
{
|
||||
searchResult = JsonSerializer.DeserializeFromStream<TmdbMovieSearchResults>(json);
|
||||
}
|
||||
}
|
||||
catch (HttpException)
|
||||
}).ConfigureAwait(false))
|
||||
{
|
||||
searchResult = JsonSerializer.DeserializeFromStream<TmdbMovieSearchResults>(json);
|
||||
}
|
||||
}
|
||||
if (searchResult != null)
|
||||
@ -642,40 +552,34 @@ namespace MediaBrowser.Controller.Providers.Movies
|
||||
//that title didn't match - look for alternatives
|
||||
url3 = string.Format(AltTitleSearch, id, ApiKey, ConfigurationManager.Configuration.MetadataCountryCode);
|
||||
|
||||
try
|
||||
using (var json = await GetMovieDbResponse(new HttpRequestOptions
|
||||
{
|
||||
using (var json = await GetMovieDbResponse(new HttpRequestOptions
|
||||
{
|
||||
Url = url3,
|
||||
CancellationToken = cancellationToken,
|
||||
AcceptHeader = AcceptHeader,
|
||||
EnableResponseCache = true
|
||||
Url = url3,
|
||||
CancellationToken = cancellationToken,
|
||||
AcceptHeader = AcceptHeader,
|
||||
EnableResponseCache = true
|
||||
|
||||
}).ConfigureAwait(false))
|
||||
{
|
||||
var response = JsonSerializer.DeserializeFromStream<TmdbAltTitleResults>(json);
|
||||
}).ConfigureAwait(false))
|
||||
{
|
||||
var response = JsonSerializer.DeserializeFromStream<TmdbAltTitleResults>(json);
|
||||
|
||||
if (response != null && response.titles != null)
|
||||
if (response != null && response.titles != null)
|
||||
{
|
||||
foreach (var title in response.titles)
|
||||
{
|
||||
foreach (var title in response.titles)
|
||||
var t = GetComparableName(title.title, Logger);
|
||||
if (t == compName)
|
||||
{
|
||||
var t = GetComparableName(title.title, Logger);
|
||||
if (t == compName)
|
||||
{
|
||||
Logger.Debug("MovieDbProvider - " + compName +
|
||||
" matched " + t);
|
||||
matchedName = t;
|
||||
break;
|
||||
}
|
||||
Logger.Debug("MovieDbProvider - " + compName +
|
||||
" did not match " + t);
|
||||
" matched " + t);
|
||||
matchedName = t;
|
||||
break;
|
||||
}
|
||||
Logger.Debug("MovieDbProvider - " + compName +
|
||||
" did not match " + t);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (HttpException)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
if (matchedName != null)
|
||||
@ -731,31 +635,25 @@ namespace MediaBrowser.Controller.Providers.Movies
|
||||
{
|
||||
string url = string.Format(GetMovieInfo3, childId, ApiKey, language);
|
||||
|
||||
try
|
||||
using (Stream json = await GetMovieDbResponse(new HttpRequestOptions
|
||||
{
|
||||
using (Stream json = await GetMovieDbResponse(new HttpRequestOptions
|
||||
{
|
||||
Url = url,
|
||||
CancellationToken = cancellationToken,
|
||||
AcceptHeader = AcceptHeader,
|
||||
EnableResponseCache = true
|
||||
Url = url,
|
||||
CancellationToken = cancellationToken,
|
||||
AcceptHeader = AcceptHeader,
|
||||
EnableResponseCache = true
|
||||
|
||||
}).ConfigureAwait(false))
|
||||
{
|
||||
var movieResult = JsonSerializer.DeserializeFromStream<CompleteMovieData>(json);
|
||||
}).ConfigureAwait(false))
|
||||
{
|
||||
var movieResult = JsonSerializer.DeserializeFromStream<CompleteMovieData>(json);
|
||||
|
||||
if (movieResult != null && movieResult.belongs_to_collection != null)
|
||||
{
|
||||
id = movieResult.belongs_to_collection.id.ToString(CultureInfo.InvariantCulture);
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.Error("Unable to obtain boxset id.");
|
||||
}
|
||||
if (movieResult != null && movieResult.belongs_to_collection != null)
|
||||
{
|
||||
id = movieResult.belongs_to_collection.id.ToString(CultureInfo.InvariantCulture);
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.Error("Unable to obtain boxset id.");
|
||||
}
|
||||
}
|
||||
catch (HttpException)
|
||||
{
|
||||
}
|
||||
}
|
||||
return id;
|
||||
@ -795,7 +693,7 @@ namespace MediaBrowser.Controller.Providers.Movies
|
||||
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
await ProviderManager.SaveToLibraryFilesystem(item, Path.Combine(item.MetaLocation, LOCAL_META_FILE_NAME), ms, cancellationToken).ConfigureAwait(false);
|
||||
await ProviderManager.SaveToLibraryFilesystem(item, Path.Combine(item.MetaLocation, LocalMetaFileName), ms, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
@ -815,34 +713,16 @@ namespace MediaBrowser.Controller.Providers.Movies
|
||||
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
try
|
||||
using (var json = await GetMovieDbResponse(new HttpRequestOptions
|
||||
{
|
||||
using (var json = await GetMovieDbResponse(new HttpRequestOptions
|
||||
{
|
||||
Url = url,
|
||||
CancellationToken = cancellationToken,
|
||||
AcceptHeader = AcceptHeader,
|
||||
EnableResponseCache = true
|
||||
Url = url,
|
||||
CancellationToken = cancellationToken,
|
||||
AcceptHeader = AcceptHeader,
|
||||
EnableResponseCache = true
|
||||
|
||||
}).ConfigureAwait(false))
|
||||
{
|
||||
mainResult = JsonSerializer.DeserializeFromStream<CompleteMovieData>(json);
|
||||
}
|
||||
}
|
||||
catch (HttpException e)
|
||||
}).ConfigureAwait(false))
|
||||
{
|
||||
if (e.IsTimedOut)
|
||||
{
|
||||
Logger.ErrorException("MovieDbProvider timed out attempting to retrieve main info for {0}", e, item.Path);
|
||||
throw new MovieDbProviderException("Timed out on main info");
|
||||
}
|
||||
if (e.StatusCode == HttpStatusCode.NotFound)
|
||||
{
|
||||
Logger.ErrorException("MovieDbProvider not found error attempting to retrieve main info for {0}", e, item.Path);
|
||||
throw new MovieDbProviderException("Not Found");
|
||||
}
|
||||
|
||||
throw;
|
||||
mainResult = JsonSerializer.DeserializeFromStream<CompleteMovieData>(json);
|
||||
}
|
||||
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
@ -855,22 +735,16 @@ namespace MediaBrowser.Controller.Providers.Movies
|
||||
|
||||
url = string.Format(baseUrl, id, ApiKey, "en");
|
||||
|
||||
try
|
||||
using (Stream json = await GetMovieDbResponse(new HttpRequestOptions
|
||||
{
|
||||
using (Stream json = await GetMovieDbResponse(new HttpRequestOptions
|
||||
{
|
||||
Url = url,
|
||||
CancellationToken = cancellationToken,
|
||||
AcceptHeader = AcceptHeader,
|
||||
EnableResponseCache = true
|
||||
Url = url,
|
||||
CancellationToken = cancellationToken,
|
||||
AcceptHeader = AcceptHeader,
|
||||
EnableResponseCache = true
|
||||
|
||||
}).ConfigureAwait(false))
|
||||
{
|
||||
mainResult = JsonSerializer.DeserializeFromStream<CompleteMovieData>(json);
|
||||
}
|
||||
}
|
||||
catch (HttpException)
|
||||
}).ConfigureAwait(false))
|
||||
{
|
||||
mainResult = JsonSerializer.DeserializeFromStream<CompleteMovieData>(json);
|
||||
}
|
||||
|
||||
if (String.IsNullOrEmpty(mainResult.overview))
|
||||
|
@ -52,7 +52,7 @@ namespace MediaBrowser.Controller.Providers.Movies
|
||||
/// <returns>DateTime.</returns>
|
||||
protected override DateTime CompareDate(BaseItem item)
|
||||
{
|
||||
var entry = item.ResolveArgs.GetMetaFileByPath(Path.Combine(item.MetaLocation, LOCAL_META_FILE_NAME));
|
||||
var entry = item.ResolveArgs.GetMetaFileByPath(Path.Combine(item.MetaLocation, LocalMetaFileName));
|
||||
return entry != null ? entry.LastWriteTimeUtc : DateTime.MinValue;
|
||||
}
|
||||
|
||||
@ -64,12 +64,12 @@ namespace MediaBrowser.Controller.Providers.Movies
|
||||
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns>
|
||||
protected override bool NeedsRefreshInternal(BaseItem item, BaseProviderInfo providerInfo)
|
||||
{
|
||||
if (item.ResolveArgs.ContainsMetaFileByName(ALT_META_FILE_NAME))
|
||||
if (item.ResolveArgs.ContainsMetaFileByName(AltMetaFileName))
|
||||
{
|
||||
return false; // don't read our file if 3rd party data exists
|
||||
}
|
||||
|
||||
if (!item.ResolveArgs.ContainsMetaFileByName(LOCAL_META_FILE_NAME))
|
||||
if (!item.ResolveArgs.ContainsMetaFileByName(LocalMetaFileName))
|
||||
{
|
||||
return false; // nothing to read
|
||||
}
|
||||
@ -89,7 +89,7 @@ namespace MediaBrowser.Controller.Providers.Movies
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
var entry = item.ResolveArgs.GetMetaFileByPath(Path.Combine(item.MetaLocation, LOCAL_META_FILE_NAME));
|
||||
var entry = item.ResolveArgs.GetMetaFileByPath(Path.Combine(item.MetaLocation, LocalMetaFileName));
|
||||
if (entry != null)
|
||||
{
|
||||
// read in our saved meta and pass to processing function
|
||||
|
@ -70,24 +70,6 @@ namespace MediaBrowser.Controller.Providers.Movies
|
||||
return "2";
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Needses the refresh internal.
|
||||
/// </summary>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <param name="providerInfo">The provider info.</param>
|
||||
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns>
|
||||
protected override bool NeedsRefreshInternal(BaseItem item, BaseProviderInfo providerInfo)
|
||||
{
|
||||
if (RefreshOnVersionChange && !String.Equals(ProviderVersion, providerInfo.ProviderVersion))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
//we fetch if either info or image needed and haven't already tried recently
|
||||
return (string.IsNullOrEmpty(item.PrimaryImagePath) || !item.ResolveArgs.ContainsMetaFileByName(MetaFileName))
|
||||
&& DateTime.Today.Subtract(providerInfo.LastRefreshed).TotalDays > ConfigurationManager.Configuration.MetadataRefreshDays;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fetches metadata and returns true or false indicating if any work that requires persistence was done
|
||||
@ -159,22 +141,16 @@ namespace MediaBrowser.Controller.Providers.Movies
|
||||
string url = string.Format(@"http://api.themoviedb.org/3/search/person?api_key={1}&query={0}", WebUtility.UrlEncode(person.Name), MovieDbProvider.ApiKey);
|
||||
PersonSearchResults searchResult = null;
|
||||
|
||||
try
|
||||
using (Stream json = await MovieDbProvider.Current.GetMovieDbResponse(new HttpRequestOptions
|
||||
{
|
||||
using (Stream json = await MovieDbProvider.Current.GetMovieDbResponse(new HttpRequestOptions
|
||||
{
|
||||
Url = url,
|
||||
CancellationToken = cancellationToken,
|
||||
AcceptHeader = MovieDbProvider.AcceptHeader,
|
||||
EnableResponseCache = true
|
||||
Url = url,
|
||||
CancellationToken = cancellationToken,
|
||||
AcceptHeader = MovieDbProvider.AcceptHeader,
|
||||
EnableResponseCache = true
|
||||
|
||||
}).ConfigureAwait(false))
|
||||
{
|
||||
searchResult = JsonSerializer.DeserializeFromStream<PersonSearchResults>(json);
|
||||
}
|
||||
}
|
||||
catch (HttpException)
|
||||
}).ConfigureAwait(false))
|
||||
{
|
||||
searchResult = JsonSerializer.DeserializeFromStream<PersonSearchResults>(json);
|
||||
}
|
||||
|
||||
return searchResult != null && searchResult.Total_Results > 0 ? searchResult.Results[0].Id.ToString(UsCulture) : null;
|
||||
@ -293,7 +269,7 @@ namespace MediaBrowser.Controller.Providers.Movies
|
||||
}
|
||||
if (profile != null)
|
||||
{
|
||||
var tmdbSettings = await MovieDbProvider.Current.TmdbSettings.ConfigureAwait(false);
|
||||
var tmdbSettings = await MovieDbProvider.Current.GetTmdbSettings(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
var img = await DownloadAndSaveImage(person, tmdbSettings.images.base_url + ConfigurationManager.Configuration.TmdbFetchedProfileSize + profile.file_path,
|
||||
"folder" + Path.GetExtension(profile.file_path), cancellationToken).ConfigureAwait(false);
|
||||
|
@ -4,7 +4,6 @@ using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Entities.Audio;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Model.Logging;
|
||||
using MediaBrowser.Model.Net;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
@ -139,8 +138,6 @@ namespace MediaBrowser.Controller.Providers.Music
|
||||
|
||||
var doc = new XmlDocument();
|
||||
|
||||
var status = ProviderRefreshStatus.Success;
|
||||
|
||||
using (var xml = await HttpClient.Get(new HttpRequestOptions
|
||||
{
|
||||
Url = url,
|
||||
@ -166,14 +163,7 @@ namespace MediaBrowser.Controller.Providers.Music
|
||||
if (!string.IsNullOrEmpty(path))
|
||||
{
|
||||
Logger.Debug("FanArtProvider getting Disc for " + item.Name);
|
||||
try
|
||||
{
|
||||
item.SetImage(ImageType.Disc, await _providerManager.DownloadAndSaveImage(item, path, DISC_FILE, ConfigurationManager.Configuration.SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
|
||||
}
|
||||
catch (HttpException)
|
||||
{
|
||||
status = ProviderRefreshStatus.CompletedWithErrors;
|
||||
}
|
||||
item.SetImage(ImageType.Disc, await _providerManager.DownloadAndSaveImage(item, path, DISC_FILE, ConfigurationManager.Configuration.SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
|
||||
}
|
||||
}
|
||||
|
||||
@ -186,19 +176,12 @@ namespace MediaBrowser.Controller.Providers.Music
|
||||
if (!string.IsNullOrEmpty(path))
|
||||
{
|
||||
Logger.Debug("FanArtProvider getting albumcover for " + item.Name);
|
||||
try
|
||||
{
|
||||
item.SetImage(ImageType.Primary, await _providerManager.DownloadAndSaveImage(item, path, PRIMARY_FILE, ConfigurationManager.Configuration.SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
|
||||
}
|
||||
catch (HttpException)
|
||||
{
|
||||
status = ProviderRefreshStatus.CompletedWithErrors;
|
||||
}
|
||||
item.SetImage(ImageType.Primary, await _providerManager.DownloadAndSaveImage(item, path, PRIMARY_FILE, ConfigurationManager.Configuration.SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SetLastRefreshed(item, DateTime.UtcNow, status);
|
||||
SetLastRefreshed(item, DateTime.UtcNow);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -146,14 +146,7 @@ namespace MediaBrowser.Controller.Providers.Music
|
||||
if (!string.IsNullOrEmpty(path))
|
||||
{
|
||||
Logger.Debug("FanArtProvider getting ClearLogo for " + item.Name);
|
||||
try
|
||||
{
|
||||
item.SetImage(ImageType.Logo, await _providerManager.DownloadAndSaveImage(item, path, LOGO_FILE, SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
|
||||
}
|
||||
catch (HttpException)
|
||||
{
|
||||
status = ProviderRefreshStatus.CompletedWithErrors;
|
||||
}
|
||||
item.SetImage(ImageType.Logo, await _providerManager.DownloadAndSaveImage(item, path, LOGO_FILE, SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
|
||||
}
|
||||
}
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
@ -171,16 +164,9 @@ namespace MediaBrowser.Controller.Providers.Music
|
||||
if (!string.IsNullOrEmpty(path))
|
||||
{
|
||||
Logger.Debug("FanArtProvider getting Backdrop for " + item.Name);
|
||||
try
|
||||
{
|
||||
item.BackdropImagePaths.Add(await _providerManager.DownloadAndSaveImage(item, path, ("Backdrop" + (numBackdrops > 0 ? numBackdrops.ToString(UsCulture) : "") + ".jpg"), SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
|
||||
numBackdrops++;
|
||||
if (numBackdrops >= ConfigurationManager.Configuration.MaxBackdrops) break;
|
||||
}
|
||||
catch (HttpException)
|
||||
{
|
||||
status = ProviderRefreshStatus.CompletedWithErrors;
|
||||
}
|
||||
item.BackdropImagePaths.Add(await _providerManager.DownloadAndSaveImage(item, path, ("Backdrop" + (numBackdrops > 0 ? numBackdrops.ToString(UsCulture) : "") + ".jpg"), SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
|
||||
numBackdrops++;
|
||||
if (numBackdrops >= ConfigurationManager.Configuration.MaxBackdrops) break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -199,14 +185,7 @@ namespace MediaBrowser.Controller.Providers.Music
|
||||
if (!string.IsNullOrEmpty(path))
|
||||
{
|
||||
Logger.Debug("FanArtProvider getting ClearArt for " + item.Name);
|
||||
try
|
||||
{
|
||||
item.SetImage(ImageType.Art, await _providerManager.DownloadAndSaveImage(item, path, ART_FILE, SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
|
||||
}
|
||||
catch (HttpException)
|
||||
{
|
||||
status = ProviderRefreshStatus.CompletedWithErrors;
|
||||
}
|
||||
item.SetImage(ImageType.Art, await _providerManager.DownloadAndSaveImage(item, path, ART_FILE, SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
|
||||
}
|
||||
}
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
@ -219,14 +198,7 @@ namespace MediaBrowser.Controller.Providers.Music
|
||||
if (!string.IsNullOrEmpty(path))
|
||||
{
|
||||
Logger.Debug("FanArtProvider getting Banner for " + item.Name);
|
||||
try
|
||||
{
|
||||
item.SetImage(ImageType.Banner, await _providerManager.DownloadAndSaveImage(item, path, BANNER_FILE, SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
|
||||
}
|
||||
catch (HttpException)
|
||||
{
|
||||
status = ProviderRefreshStatus.CompletedWithErrors;
|
||||
}
|
||||
item.SetImage(ImageType.Banner, await _providerManager.DownloadAndSaveImage(item, path, BANNER_FILE, SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
|
||||
}
|
||||
}
|
||||
|
||||
@ -240,14 +212,7 @@ namespace MediaBrowser.Controller.Providers.Music
|
||||
if (!string.IsNullOrEmpty(path))
|
||||
{
|
||||
Logger.Debug("FanArtProvider getting Primary image for " + item.Name);
|
||||
try
|
||||
{
|
||||
item.SetImage(ImageType.Primary, await _providerManager.DownloadAndSaveImage(item, path, PRIMARY_FILE, SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
|
||||
}
|
||||
catch (HttpException)
|
||||
{
|
||||
status = ProviderRefreshStatus.CompletedWithErrors;
|
||||
}
|
||||
item.SetImage(ImageType.Primary, await _providerManager.DownloadAndSaveImage(item, path, PRIMARY_FILE, SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -93,43 +93,36 @@ namespace MediaBrowser.Controller.Providers.Music
|
||||
//Execute the Artist search against our name and assume first one is the one we want
|
||||
var url = RootUrl + string.Format("method=artist.search&artist={0}&api_key={1}&format=json", UrlEncode(item.Name), ApiKey);
|
||||
|
||||
try
|
||||
using (var json = await HttpClient.Get(new HttpRequestOptions
|
||||
{
|
||||
using (var json = await HttpClient.Get(new HttpRequestOptions
|
||||
{
|
||||
Url = url,
|
||||
ResourcePool = LastfmResourcePool,
|
||||
CancellationToken = cancellationToken,
|
||||
EnableResponseCache = true
|
||||
Url = url,
|
||||
ResourcePool = LastfmResourcePool,
|
||||
CancellationToken = cancellationToken,
|
||||
EnableResponseCache = true
|
||||
|
||||
}).ConfigureAwait(false))
|
||||
}).ConfigureAwait(false))
|
||||
{
|
||||
using (var reader = new StreamReader(json, true))
|
||||
{
|
||||
using (var reader = new StreamReader(json, true))
|
||||
var jsonString = await reader.ReadToEndAsync().ConfigureAwait(false);
|
||||
|
||||
// Sometimes they send back an empty response or just the text "null"
|
||||
if (!jsonString.StartsWith("{", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
var jsonString = await reader.ReadToEndAsync().ConfigureAwait(false);
|
||||
return null;
|
||||
}
|
||||
|
||||
// Sometimes they send back an empty response or just the text "null"
|
||||
if (!jsonString.StartsWith("{", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
var searchResult = JsonSerializer.DeserializeFromString<LastfmArtistSearchResults>(jsonString);
|
||||
|
||||
var searchResult = JsonSerializer.DeserializeFromString<LastfmArtistSearchResults>(jsonString);
|
||||
if (searchResult != null && searchResult.results != null && searchResult.results.artistmatches != null && searchResult.results.artistmatches.artist.Count > 0)
|
||||
{
|
||||
var artist = searchResult.results.artistmatches.artist.FirstOrDefault(i => i.name != null && string.Compare(i.name, item.Name, CultureInfo.CurrentCulture, CompareOptions.IgnoreNonSpace) == 0) ??
|
||||
searchResult.results.artistmatches.artist.First();
|
||||
|
||||
if (searchResult != null && searchResult.results != null && searchResult.results.artistmatches != null && searchResult.results.artistmatches.artist.Count > 0)
|
||||
{
|
||||
var artist = searchResult.results.artistmatches.artist.FirstOrDefault(i => i.name != null && string.Compare(i.name, item.Name, CultureInfo.CurrentCulture, CompareOptions.IgnoreNonSpace) == 0) ??
|
||||
searchResult.results.artistmatches.artist.First();
|
||||
|
||||
return artist.mbid;
|
||||
}
|
||||
return artist.mbid;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (HttpException)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
@ -127,14 +127,7 @@ namespace MediaBrowser.Controller.Providers.TV
|
||||
if (!string.IsNullOrEmpty(path))
|
||||
{
|
||||
Logger.Debug("FanArtProvider getting ClearLogo for " + series.Name);
|
||||
try
|
||||
{
|
||||
series.SetImage(ImageType.Logo, await _providerManager.DownloadAndSaveImage(series, path, LOGO_FILE, ConfigurationManager.Configuration.SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
|
||||
}
|
||||
catch (HttpException)
|
||||
{
|
||||
status = ProviderRefreshStatus.CompletedWithErrors;
|
||||
}
|
||||
series.SetImage(ImageType.Logo, await _providerManager.DownloadAndSaveImage(series, path, LOGO_FILE, ConfigurationManager.Configuration.SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
|
||||
}
|
||||
}
|
||||
|
||||
@ -151,14 +144,7 @@ namespace MediaBrowser.Controller.Providers.TV
|
||||
if (!string.IsNullOrEmpty(path))
|
||||
{
|
||||
Logger.Debug("FanArtProvider getting ClearArt for " + series.Name);
|
||||
try
|
||||
{
|
||||
series.SetImage(ImageType.Art, await _providerManager.DownloadAndSaveImage(series, path, ART_FILE, ConfigurationManager.Configuration.SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
|
||||
}
|
||||
catch (HttpException)
|
||||
{
|
||||
status = ProviderRefreshStatus.CompletedWithErrors;
|
||||
}
|
||||
series.SetImage(ImageType.Art, await _providerManager.DownloadAndSaveImage(series, path, ART_FILE, ConfigurationManager.Configuration.SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
|
||||
}
|
||||
}
|
||||
|
||||
@ -172,14 +158,7 @@ namespace MediaBrowser.Controller.Providers.TV
|
||||
if (!string.IsNullOrEmpty(path))
|
||||
{
|
||||
Logger.Debug("FanArtProvider getting ThumbArt for " + series.Name);
|
||||
try
|
||||
{
|
||||
series.SetImage(ImageType.Thumb, await _providerManager.DownloadAndSaveImage(series, path, THUMB_FILE, ConfigurationManager.Configuration.SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
|
||||
}
|
||||
catch (HttpException)
|
||||
{
|
||||
status = ProviderRefreshStatus.CompletedWithErrors;
|
||||
}
|
||||
series.SetImage(ImageType.Thumb, await _providerManager.DownloadAndSaveImage(series, path, THUMB_FILE, ConfigurationManager.Configuration.SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
|
||||
}
|
||||
}
|
||||
|
||||
@ -191,14 +170,7 @@ namespace MediaBrowser.Controller.Providers.TV
|
||||
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;
|
||||
}
|
||||
series.SetImage(ImageType.Banner, await _providerManager.DownloadAndSaveImage(series, path, BANNER_FILE, ConfigurationManager.Configuration.SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,6 @@ using MediaBrowser.Controller.Entities.TV;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Model.Logging;
|
||||
using MediaBrowser.Model.Net;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
@ -182,15 +181,8 @@ namespace MediaBrowser.Controller.Providers.TV
|
||||
{
|
||||
n = n.SelectSingleNode("./BannerPath");
|
||||
|
||||
try
|
||||
{
|
||||
if (n != null)
|
||||
season.PrimaryImagePath = await _providerManager.DownloadAndSaveImage(season, TVUtils.BannerUrl + n.InnerText, "folder" + Path.GetExtension(n.InnerText), ConfigurationManager.Configuration.SaveLocalMeta, RemoteSeriesProvider.Current.TvDbResourcePool, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
catch (HttpException)
|
||||
{
|
||||
status = ProviderRefreshStatus.CompletedWithErrors;
|
||||
}
|
||||
if (n != null)
|
||||
season.PrimaryImagePath = await _providerManager.DownloadAndSaveImage(season, TVUtils.BannerUrl + n.InnerText, "folder" + Path.GetExtension(n.InnerText), ConfigurationManager.Configuration.SaveLocalMeta, RemoteSeriesProvider.Current.TvDbResourcePool, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
@ -203,22 +195,15 @@ namespace MediaBrowser.Controller.Providers.TV
|
||||
n = n.SelectSingleNode("./BannerPath");
|
||||
if (n != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
var bannerImagePath =
|
||||
await _providerManager.DownloadAndSaveImage(season,
|
||||
TVUtils.BannerUrl + n.InnerText,
|
||||
"banner" +
|
||||
Path.GetExtension(n.InnerText),
|
||||
ConfigurationManager.Configuration.SaveLocalMeta, RemoteSeriesProvider.Current.TvDbResourcePool, cancellationToken).
|
||||
ConfigureAwait(false);
|
||||
var bannerImagePath =
|
||||
await _providerManager.DownloadAndSaveImage(season,
|
||||
TVUtils.BannerUrl + n.InnerText,
|
||||
"banner" +
|
||||
Path.GetExtension(n.InnerText),
|
||||
ConfigurationManager.Configuration.SaveLocalMeta, RemoteSeriesProvider.Current.TvDbResourcePool, cancellationToken).
|
||||
ConfigureAwait(false);
|
||||
|
||||
season.SetImage(ImageType.Banner, bannerImagePath);
|
||||
}
|
||||
catch (HttpException)
|
||||
{
|
||||
status = ProviderRefreshStatus.CompletedWithErrors;
|
||||
}
|
||||
season.SetImage(ImageType.Banner, bannerImagePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -231,15 +216,8 @@ namespace MediaBrowser.Controller.Providers.TV
|
||||
n = n.SelectSingleNode("./BannerPath");
|
||||
if (n != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (season.BackdropImagePaths == null) season.BackdropImagePaths = new List<string>();
|
||||
season.BackdropImagePaths.Add(await _providerManager.DownloadAndSaveImage(season, TVUtils.BannerUrl + n.InnerText, "backdrop" + Path.GetExtension(n.InnerText), ConfigurationManager.Configuration.SaveLocalMeta, RemoteSeriesProvider.Current.TvDbResourcePool, cancellationToken).ConfigureAwait(false));
|
||||
}
|
||||
catch (HttpException)
|
||||
{
|
||||
status = ProviderRefreshStatus.CompletedWithErrors;
|
||||
}
|
||||
if (season.BackdropImagePaths == null) season.BackdropImagePaths = new List<string>();
|
||||
season.BackdropImagePaths.Add(await _providerManager.DownloadAndSaveImage(season, TVUtils.BannerUrl + n.InnerText, "backdrop" + Path.GetExtension(n.InnerText), ConfigurationManager.Configuration.SaveLocalMeta, RemoteSeriesProvider.Current.TvDbResourcePool, cancellationToken).ConfigureAwait(false));
|
||||
}
|
||||
}
|
||||
else if (!ConfigurationManager.Configuration.SaveLocalMeta) //if saving local - season will inherit from series
|
||||
@ -256,22 +234,15 @@ namespace MediaBrowser.Controller.Providers.TV
|
||||
if (season.BackdropImagePaths == null)
|
||||
season.BackdropImagePaths = new List<string>();
|
||||
|
||||
try
|
||||
{
|
||||
season.BackdropImagePaths.Add(
|
||||
await _providerManager.DownloadAndSaveImage(season,
|
||||
TVUtils.BannerUrl +
|
||||
n.InnerText,
|
||||
"backdrop" +
|
||||
Path.GetExtension(
|
||||
n.InnerText),
|
||||
ConfigurationManager.Configuration.SaveLocalMeta, RemoteSeriesProvider.Current.TvDbResourcePool, cancellationToken)
|
||||
.ConfigureAwait(false));
|
||||
}
|
||||
catch (HttpException)
|
||||
{
|
||||
status = ProviderRefreshStatus.CompletedWithErrors;
|
||||
}
|
||||
season.BackdropImagePaths.Add(
|
||||
await _providerManager.DownloadAndSaveImage(season,
|
||||
TVUtils.BannerUrl +
|
||||
n.InnerText,
|
||||
"backdrop" +
|
||||
Path.GetExtension(
|
||||
n.InnerText),
|
||||
ConfigurationManager.Configuration.SaveLocalMeta, RemoteSeriesProvider.Current.TvDbResourcePool, cancellationToken)
|
||||
.ConfigureAwait(false));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -75,24 +75,24 @@ namespace MediaBrowser.Controller.Providers.TV
|
||||
/// <summary>
|
||||
/// The root URL
|
||||
/// </summary>
|
||||
private const string rootUrl = "http://www.thetvdb.com/api/";
|
||||
private const string RootUrl = "http://www.thetvdb.com/api/";
|
||||
/// <summary>
|
||||
/// The series query
|
||||
/// </summary>
|
||||
private const string seriesQuery = "GetSeries.php?seriesname={0}";
|
||||
private const string SeriesQuery = "GetSeries.php?seriesname={0}";
|
||||
/// <summary>
|
||||
/// The series get
|
||||
/// </summary>
|
||||
private const string seriesGet = "http://www.thetvdb.com/api/{0}/series/{1}/{2}.xml";
|
||||
private const string SeriesGet = "http://www.thetvdb.com/api/{0}/series/{1}/{2}.xml";
|
||||
/// <summary>
|
||||
/// The get actors
|
||||
/// </summary>
|
||||
private const string getActors = "http://www.thetvdb.com/api/{0}/series/{1}/actors.xml";
|
||||
private const string GetActors = "http://www.thetvdb.com/api/{0}/series/{1}/actors.xml";
|
||||
|
||||
/// <summary>
|
||||
/// The LOCA l_ MET a_ FIL e_ NAME
|
||||
/// </summary>
|
||||
protected const string LOCAL_META_FILE_NAME = "Series.xml";
|
||||
protected const string LocalMetaFileName = "Series.xml";
|
||||
|
||||
/// <summary>
|
||||
/// Supportses the specified item.
|
||||
@ -133,15 +133,6 @@ namespace MediaBrowser.Controller.Providers.TV
|
||||
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns>
|
||||
protected override bool NeedsRefreshInternal(BaseItem item, BaseProviderInfo providerInfo)
|
||||
{
|
||||
var downloadDate = providerInfo.LastRefreshed;
|
||||
|
||||
if (ConfigurationManager.Configuration.MetadataRefreshDays == -1 && downloadDate != DateTime.MinValue)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (item.DontFetchMeta) return false;
|
||||
|
||||
return !HasLocalMeta(item) && base.NeedsRefreshInternal(item, providerInfo);
|
||||
}
|
||||
|
||||
@ -195,7 +186,7 @@ namespace MediaBrowser.Controller.Providers.TV
|
||||
if (!string.IsNullOrEmpty(seriesId))
|
||||
{
|
||||
|
||||
string url = string.Format(seriesGet, TVUtils.TvdbApiKey, seriesId, ConfigurationManager.Configuration.PreferredMetadataLanguage);
|
||||
string url = string.Format(SeriesGet, TVUtils.TvdbApiKey, seriesId, ConfigurationManager.Configuration.PreferredMetadataLanguage);
|
||||
var doc = new XmlDocument();
|
||||
|
||||
using (var xml = await HttpClient.Get(new HttpRequestOptions
|
||||
@ -273,7 +264,7 @@ namespace MediaBrowser.Controller.Providers.TV
|
||||
var ms = new MemoryStream();
|
||||
doc.Save(ms);
|
||||
|
||||
await _providerManager.SaveToLibraryFilesystem(series, Path.Combine(series.MetaLocation, LOCAL_META_FILE_NAME), ms, cancellationToken).ConfigureAwait(false);
|
||||
await _providerManager.SaveToLibraryFilesystem(series, Path.Combine(series.MetaLocation, LocalMetaFileName), ms, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -291,7 +282,7 @@ namespace MediaBrowser.Controller.Providers.TV
|
||||
/// <returns>Task.</returns>
|
||||
private async Task FetchActors(Series series, string seriesId, XmlDocument doc, CancellationToken cancellationToken)
|
||||
{
|
||||
string urlActors = string.Format(getActors, TVUtils.TvdbApiKey, seriesId);
|
||||
string urlActors = string.Format(GetActors, TVUtils.TvdbApiKey, seriesId);
|
||||
var docActors = new XmlDocument();
|
||||
|
||||
using (var actors = await HttpClient.Get(new HttpRequestOptions
|
||||
@ -440,7 +431,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)
|
||||
{
|
||||
return item.ResolveArgs.ContainsMetaFileByName(LOCAL_META_FILE_NAME);
|
||||
return item.ResolveArgs.ContainsMetaFileByName(LocalMetaFileName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -470,7 +461,7 @@ namespace MediaBrowser.Controller.Providers.TV
|
||||
{
|
||||
|
||||
//nope - search for it
|
||||
string url = string.Format(rootUrl + seriesQuery, WebUtility.UrlEncode(name));
|
||||
string url = string.Format(RootUrl + SeriesQuery, WebUtility.UrlEncode(name));
|
||||
var doc = new XmlDocument();
|
||||
|
||||
using (var results = await HttpClient.Get(new HttpRequestOptions
|
||||
|
@ -170,7 +170,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies
|
||||
// If we already know it's a movie, we can stop looping
|
||||
if (!isKnownMovie.HasValue)
|
||||
{
|
||||
isKnownMovie = args.ContainsMetaFileByName("movie.xml") || args.ContainsMetaFileByName(MovieDbProvider.LOCAL_META_FILE_NAME) || args.Path.IndexOf("[tmdbid", StringComparison.OrdinalIgnoreCase) != -1;
|
||||
isKnownMovie = args.ContainsMetaFileByName("movie.xml") || args.ContainsMetaFileByName(MovieDbProvider.LocalMetaFileName) || args.Path.IndexOf("[tmdbid", StringComparison.OrdinalIgnoreCase) != -1;
|
||||
}
|
||||
|
||||
if (isKnownMovie.Value)
|
||||
|
Loading…
Reference in New Issue
Block a user