From 2bd2a7bc6820a06b3fc5662f474034b75f0249c5 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 19 May 2013 15:37:52 -0400 Subject: [PATCH] make sure providers are trying again when appropiate --- .../Providers/MediaInfo/BaseFFMpegProvider.cs | 18 +- .../MediaInfo/BaseFFProbeProvider.cs | 12 - .../Providers/Movies/FanArtMovieProvider.cs | 58 +--- .../Providers/Movies/MovieDbImagesProvider.cs | 4 +- .../Providers/Movies/MovieDbProvider.cs | 310 ++++++------------ .../Providers/Movies/MovieProviderFromJson.cs | 8 +- .../Providers/Movies/TmdbPersonProvider.cs | 40 +-- .../Providers/Music/FanArtAlbumProvider.cs | 23 +- .../Providers/Music/FanArtArtistProvider.cs | 49 +-- .../Providers/Music/LastfmArtistProvider.cs | 47 ++- .../Providers/TV/FanArtTVProvider.cs | 36 +- .../Providers/TV/RemoteSeasonProvider.cs | 71 ++-- .../Providers/TV/RemoteSeriesProvider.cs | 29 +- .../Library/Resolvers/Movies/MovieResolver.cs | 2 +- 14 files changed, 185 insertions(+), 522 deletions(-) diff --git a/MediaBrowser.Controller/Providers/MediaInfo/BaseFFMpegProvider.cs b/MediaBrowser.Controller/Providers/MediaInfo/BaseFFMpegProvider.cs index 9fa6363a83..919c2ae213 100644 --- a/MediaBrowser.Controller/Providers/MediaInfo/BaseFFMpegProvider.cs +++ b/MediaBrowser.Controller/Providers/MediaInfo/BaseFFMpegProvider.cs @@ -62,23 +62,15 @@ namespace MediaBrowser.Controller.Providers.MediaInfo } /// - /// Needses the refresh internal. + /// Gets a value indicating whether [refresh on version change]. /// - /// The item. - /// The provider info. - /// true if XXXX, false otherwise - protected override bool NeedsRefreshInternal(BaseItem item, BaseProviderInfo providerInfo) + /// true if [refresh on version change]; otherwise, false. + 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); } } } diff --git a/MediaBrowser.Controller/Providers/MediaInfo/BaseFFProbeProvider.cs b/MediaBrowser.Controller/Providers/MediaInfo/BaseFFProbeProvider.cs index bcaf4d525b..7ea819edaa 100644 --- a/MediaBrowser.Controller/Providers/MediaInfo/BaseFFProbeProvider.cs +++ b/MediaBrowser.Controller/Providers/MediaInfo/BaseFFProbeProvider.cs @@ -117,18 +117,6 @@ namespace MediaBrowser.Controller.Providers.MediaInfo return await MediaEncoder.GetMediaInfo(inputPath, type, cancellationToken).ConfigureAwait(false); } - /// - /// Gets a value indicating whether [refresh on version change]. - /// - /// true if [refresh on version change]; otherwise, false. - protected override bool RefreshOnVersionChange - { - get - { - return true; - } - } - /// /// Mounts the iso if needed. /// diff --git a/MediaBrowser.Controller/Providers/Movies/FanArtMovieProvider.cs b/MediaBrowser.Controller/Providers/Movies/FanArtMovieProvider.cs index f44cdea1fe..47a46760a2 100644 --- a/MediaBrowser.Controller/Providers/Movies/FanArtMovieProvider.cs +++ b/MediaBrowser.Controller/Providers/Movies/FanArtMovieProvider.cs @@ -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; } } diff --git a/MediaBrowser.Controller/Providers/Movies/MovieDbImagesProvider.cs b/MediaBrowser.Controller/Providers/Movies/MovieDbImagesProvider.cs index 8260a0568f..bd290fbea3 100644 --- a/MediaBrowser.Controller/Providers/Movies/MovieDbImagesProvider.cs +++ b/MediaBrowser.Controller/Providers/Movies/MovieDbImagesProvider.cs @@ -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(); - 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 diff --git a/MediaBrowser.Controller/Providers/Movies/MovieDbProvider.cs b/MediaBrowser.Controller/Providers/Movies/MovieDbProvider.cs index a222c87855..3abe6d4df8 100644 --- a/MediaBrowser.Controller/Providers/Movies/MovieDbProvider.cs +++ b/MediaBrowser.Controller/Providers/Movies/MovieDbProvider.cs @@ -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) - { - } - - } /// /// Class MovieDbProvider /// @@ -154,85 +145,42 @@ namespace MediaBrowser.Controller.Providers.Movies /// /// The _TMDB settings task /// - private Task _tmdbSettingsTask; - /// - /// The _TMDB settings task initialized - /// - private bool _tmdbSettingsTaskInitialized; - /// - /// The _TMDB settings task sync lock - /// - private object _tmdbSettingsTaskSyncLock = new object(); + private TmdbSettingsResult _tmdbSettings; + + private readonly SemaphoreSlim _tmdbSettingsSemaphore = new SemaphoreSlim(1, 1); /// /// Gets the TMDB settings. /// - /// The TMDB settings. - public Task TmdbSettings + /// Task{TmdbSettingsResult}. + internal async Task GetTmdbSettings(CancellationToken cancellationToken) { - get + if (_tmdbSettings != null) { - LazyInitializer.EnsureInitialized(ref _tmdbSettingsTask, ref _tmdbSettingsTaskInitialized, ref _tmdbSettingsTaskSyncLock, () => GetTmdbSettings(JsonSerializer)); - return _tmdbSettingsTask; + return _tmdbSettings; } - } - /// - /// Gets the TMDB settings. - /// - /// Task{TmdbSettingsResult}. - private async Task GetTmdbSettings(IJsonSerializer jsonSerializer) - { + 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(json); + _tmdbSettings = JsonSerializer.DeserializeFromStream(json); + + return _tmdbSettings; } } - catch (HttpException) + finally { - return new TmdbSettingsResult - { - images = new TmdbImageSettings - { - backdrop_sizes = - new List - { - "w380", - "w780", - "w1280", - "original" - }, - poster_sizes = - new List - { - "w92", - "w154", - "w185", - "w342", - "w500", - "original" - }, - profile_sizes = - new List - { - "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(@"(?.*)") // 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); } /// @@ -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); } /// @@ -389,7 +310,7 @@ namespace MediaBrowser.Controller.Providers.Movies /// true if [has alt meta] [the specified item]; otherwise, false. 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); } /// @@ -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(json); - } - } - catch (HttpException) + }).ConfigureAwait(false)) { + searchResult = JsonSerializer.DeserializeFromStream(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(json); - } - } - catch (HttpException) + }).ConfigureAwait(false)) { + searchResult = JsonSerializer.DeserializeFromStream(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(json); + }).ConfigureAwait(false)) + { + var response = JsonSerializer.DeserializeFromStream(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(json); + }).ConfigureAwait(false)) + { + var movieResult = JsonSerializer.DeserializeFromStream(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(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(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(json); - } - } - catch (HttpException) + }).ConfigureAwait(false)) { + mainResult = JsonSerializer.DeserializeFromStream(json); } if (String.IsNullOrEmpty(mainResult.overview)) diff --git a/MediaBrowser.Controller/Providers/Movies/MovieProviderFromJson.cs b/MediaBrowser.Controller/Providers/Movies/MovieProviderFromJson.cs index b3cf9334a8..1556658d63 100644 --- a/MediaBrowser.Controller/Providers/Movies/MovieProviderFromJson.cs +++ b/MediaBrowser.Controller/Providers/Movies/MovieProviderFromJson.cs @@ -52,7 +52,7 @@ namespace MediaBrowser.Controller.Providers.Movies /// DateTime. 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 /// true if XXXX, false otherwise 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 diff --git a/MediaBrowser.Controller/Providers/Movies/TmdbPersonProvider.cs b/MediaBrowser.Controller/Providers/Movies/TmdbPersonProvider.cs index 36ca5dc1a6..5cf5fcc18d 100644 --- a/MediaBrowser.Controller/Providers/Movies/TmdbPersonProvider.cs +++ b/MediaBrowser.Controller/Providers/Movies/TmdbPersonProvider.cs @@ -70,24 +70,6 @@ namespace MediaBrowser.Controller.Providers.Movies return "2"; } } - - /// - /// Needses the refresh internal. - /// - /// The item. - /// The provider info. - /// true if XXXX, false otherwise - 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; - } /// /// 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(json); - } - } - catch (HttpException) + }).ConfigureAwait(false)) { + searchResult = JsonSerializer.DeserializeFromStream(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); diff --git a/MediaBrowser.Controller/Providers/Music/FanArtAlbumProvider.cs b/MediaBrowser.Controller/Providers/Music/FanArtAlbumProvider.cs index 537015c3fa..73a71e7e47 100644 --- a/MediaBrowser.Controller/Providers/Music/FanArtAlbumProvider.cs +++ b/MediaBrowser.Controller/Providers/Music/FanArtAlbumProvider.cs @@ -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; } diff --git a/MediaBrowser.Controller/Providers/Music/FanArtArtistProvider.cs b/MediaBrowser.Controller/Providers/Music/FanArtArtistProvider.cs index 45c4eae7b8..7fdef81f10 100644 --- a/MediaBrowser.Controller/Providers/Music/FanArtArtistProvider.cs +++ b/MediaBrowser.Controller/Providers/Music/FanArtArtistProvider.cs @@ -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)); } } } diff --git a/MediaBrowser.Controller/Providers/Music/LastfmArtistProvider.cs b/MediaBrowser.Controller/Providers/Music/LastfmArtistProvider.cs index 63132ddfcb..4fe7f522cf 100644 --- a/MediaBrowser.Controller/Providers/Music/LastfmArtistProvider.cs +++ b/MediaBrowser.Controller/Providers/Music/LastfmArtistProvider.cs @@ -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); + var jsonString = await reader.ReadToEndAsync().ConfigureAwait(false); - // Sometimes they send back an empty response or just the text "null" - if (!jsonString.StartsWith("{", StringComparison.OrdinalIgnoreCase)) - { - 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(jsonString); + var searchResult = JsonSerializer.DeserializeFromString(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; } diff --git a/MediaBrowser.Controller/Providers/TV/FanArtTVProvider.cs b/MediaBrowser.Controller/Providers/TV/FanArtTVProvider.cs index 3bff6ca387..4b80956664 100644 --- a/MediaBrowser.Controller/Providers/TV/FanArtTVProvider.cs +++ b/MediaBrowser.Controller/Providers/TV/FanArtTVProvider.cs @@ -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)); } } } diff --git a/MediaBrowser.Controller/Providers/TV/RemoteSeasonProvider.cs b/MediaBrowser.Controller/Providers/TV/RemoteSeasonProvider.cs index 289554370f..8b7c5e6e4c 100644 --- a/MediaBrowser.Controller/Providers/TV/RemoteSeasonProvider.cs +++ b/MediaBrowser.Controller/Providers/TV/RemoteSeasonProvider.cs @@ -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(); - 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(); + 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(); - 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)); } } } diff --git a/MediaBrowser.Controller/Providers/TV/RemoteSeriesProvider.cs b/MediaBrowser.Controller/Providers/TV/RemoteSeriesProvider.cs index 2f77b1607f..e3eb06963e 100644 --- a/MediaBrowser.Controller/Providers/TV/RemoteSeriesProvider.cs +++ b/MediaBrowser.Controller/Providers/TV/RemoteSeriesProvider.cs @@ -75,24 +75,24 @@ namespace MediaBrowser.Controller.Providers.TV /// /// The root URL /// - private const string rootUrl = "http://www.thetvdb.com/api/"; + private const string RootUrl = "http://www.thetvdb.com/api/"; /// /// The series query /// - private const string seriesQuery = "GetSeries.php?seriesname={0}"; + private const string SeriesQuery = "GetSeries.php?seriesname={0}"; /// /// The series get /// - 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"; /// /// The get actors /// - 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"; /// /// The LOCA l_ MET a_ FIL e_ NAME /// - protected const string LOCAL_META_FILE_NAME = "Series.xml"; + protected const string LocalMetaFileName = "Series.xml"; /// /// Supportses the specified item. @@ -133,15 +133,6 @@ namespace MediaBrowser.Controller.Providers.TV /// true if XXXX, false otherwise 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 /// Task. 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 /// true if [has local meta] [the specified item]; otherwise, false. private bool HasLocalMeta(BaseItem item) { - return item.ResolveArgs.ContainsMetaFileByName(LOCAL_META_FILE_NAME); + return item.ResolveArgs.ContainsMetaFileByName(LocalMetaFileName); } /// @@ -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 diff --git a/MediaBrowser.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs b/MediaBrowser.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs index 7e077d4d70..961e5e500d 100644 --- a/MediaBrowser.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs +++ b/MediaBrowser.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs @@ -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)