diff --git a/MediaBrowser.Controller/Entities/TV/Series.cs b/MediaBrowser.Controller/Entities/TV/Series.cs index 6c499f6180..e79c465a11 100644 --- a/MediaBrowser.Controller/Entities/TV/Series.cs +++ b/MediaBrowser.Controller/Entities/TV/Series.cs @@ -446,9 +446,13 @@ namespace MediaBrowser.Controller.Entities.TV { return true; } + if (!i.ParentIndexNumber.HasValue) + { + var season = i.Season; + return season != null && string.Equals(season.PresentationUniqueKey, seasonPresentationKey, StringComparison.OrdinalIgnoreCase); + } - var season = i.Season; - return season != null && string.Equals(season.PresentationUniqueKey, seasonPresentationKey, StringComparison.OrdinalIgnoreCase); + return false; }); } else @@ -464,8 +468,13 @@ namespace MediaBrowser.Controller.Entities.TV return true; } - var season = episode.Season; - return season != null && string.Equals(season.PresentationUniqueKey, seasonPresentationKey, StringComparison.OrdinalIgnoreCase); + if (!episode.ParentIndexNumber.HasValue) + { + var season = episode.Season; + return season != null && string.Equals(season.PresentationUniqueKey, seasonPresentationKey, StringComparison.OrdinalIgnoreCase); + } + + return false; }); } } diff --git a/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj b/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj index ba4d1b59e8..f759ffeaee 100644 --- a/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj +++ b/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj @@ -230,12 +230,6 @@ Configuration\SubtitlePlaybackMode.cs - - Configuration\TheMovieDbOptions.cs - - - Configuration\TvdbOptions.cs - Configuration\UnratedItem.cs diff --git a/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj b/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj index f5d538cc47..05bbeb50ef 100644 --- a/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj +++ b/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj @@ -204,12 +204,6 @@ Configuration\SubtitlePlaybackMode.cs - - Configuration\TheMovieDbOptions.cs - - - Configuration\TvdbOptions.cs - Configuration\UnratedItem.cs diff --git a/MediaBrowser.Model/Configuration/FanartOptions.cs b/MediaBrowser.Model/Configuration/FanartOptions.cs index e992abe5de..6924b25d7d 100644 --- a/MediaBrowser.Model/Configuration/FanartOptions.cs +++ b/MediaBrowser.Model/Configuration/FanartOptions.cs @@ -3,11 +3,6 @@ namespace MediaBrowser.Model.Configuration { public class FanartOptions { - /// - /// Gets or sets a value indicating whether [enable automatic updates]. - /// - /// true if [enable automatic updates]; otherwise, false. - public bool EnableAutomaticUpdates { get; set; } /// /// Gets or sets the user API key. /// diff --git a/MediaBrowser.Model/Configuration/TheMovieDbOptions.cs b/MediaBrowser.Model/Configuration/TheMovieDbOptions.cs deleted file mode 100644 index 9a73e34764..0000000000 --- a/MediaBrowser.Model/Configuration/TheMovieDbOptions.cs +++ /dev/null @@ -1,12 +0,0 @@ - -namespace MediaBrowser.Model.Configuration -{ - public class TheMovieDbOptions - { - /// - /// Gets or sets a value indicating whether [enable automatic updates]. - /// - /// true if [enable automatic updates]; otherwise, false. - public bool EnableAutomaticUpdates { get; set; } - } -} diff --git a/MediaBrowser.Model/Configuration/TvdbOptions.cs b/MediaBrowser.Model/Configuration/TvdbOptions.cs deleted file mode 100644 index 034af609c4..0000000000 --- a/MediaBrowser.Model/Configuration/TvdbOptions.cs +++ /dev/null @@ -1,12 +0,0 @@ - -namespace MediaBrowser.Model.Configuration -{ - public class TvdbOptions - { - /// - /// Gets or sets a value indicating whether [enable automatic updates]. - /// - /// true if [enable automatic updates]; otherwise, false. - public bool EnableAutomaticUpdates { get; set; } - } -} diff --git a/MediaBrowser.Model/MediaBrowser.Model.csproj b/MediaBrowser.Model/MediaBrowser.Model.csproj index 7c469b9fb9..522b7d38d2 100644 --- a/MediaBrowser.Model/MediaBrowser.Model.csproj +++ b/MediaBrowser.Model/MediaBrowser.Model.csproj @@ -97,8 +97,6 @@ - - diff --git a/MediaBrowser.Providers/Folders/DefaultImageProvider.cs b/MediaBrowser.Providers/Folders/DefaultImageProvider.cs deleted file mode 100644 index 08b4f64610..0000000000 --- a/MediaBrowser.Providers/Folders/DefaultImageProvider.cs +++ /dev/null @@ -1,165 +0,0 @@ -using MediaBrowser.Common.Net; -using MediaBrowser.Controller.Entities; -using MediaBrowser.Controller.Providers; -using MediaBrowser.Model.Entities; -using MediaBrowser.Model.Providers; -using MediaBrowser.Providers.Genres; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; - -namespace MediaBrowser.Providers.Folders -{ - public class DefaultImageProvider : IRemoteImageProvider, IHasItemChangeMonitor - { - private readonly IHttpClient _httpClient; - - public DefaultImageProvider(IHttpClient httpClient) - { - _httpClient = httpClient; - } - - public IEnumerable GetSupportedImages(IHasImages item) - { - return new List - { - ImageType.Primary - }; - } - - public Task> GetImages(IHasImages item, CancellationToken cancellationToken) - { - var view = item as UserView; - - if (view != null) - { - return GetImages(view.ViewType, cancellationToken); - } - - var folder = (ICollectionFolder)item; - return GetImages(folder.CollectionType, cancellationToken); - } - - private Task> GetImages(string viewType, CancellationToken cancellationToken) - { - var url = GetImageUrl(viewType); - - var list = new List(); - - if (!string.IsNullOrWhiteSpace(url)) - { - list.AddRange(new List{ - new RemoteImageInfo - { - ProviderName = Name, - Url = url, - Type = ImageType.Primary - } - }); - } - - return Task.FromResult>(list); - } - - private string GetImageUrl(string viewType) - { - const string urlPrefix = "https://raw.githubusercontent.com/MediaBrowser/Emby.Resources/master/images/folders/"; - - if (string.Equals(viewType, CollectionType.Books, StringComparison.OrdinalIgnoreCase)) - { - return urlPrefix + "books.jpg"; - } - if (string.Equals(viewType, CollectionType.Games, StringComparison.OrdinalIgnoreCase)) - { - return urlPrefix + "games.jpg"; - } - if (string.Equals(viewType, CollectionType.Music, StringComparison.OrdinalIgnoreCase)) - { - //return urlPrefix + "music.jpg"; - } - if (string.Equals(viewType, CollectionType.Photos, StringComparison.OrdinalIgnoreCase)) - { - //return urlPrefix + "photos.png"; - } - if (string.Equals(viewType, CollectionType.TvShows, StringComparison.OrdinalIgnoreCase)) - { - //return urlPrefix + "tv.jpg"; - } - if (string.Equals(viewType, CollectionType.Channels, StringComparison.OrdinalIgnoreCase)) - { - return urlPrefix + "channels.jpg"; - } - if (string.Equals(viewType, CollectionType.LiveTv, StringComparison.OrdinalIgnoreCase)) - { - return urlPrefix + "livetv.png"; - } - if (string.Equals(viewType, CollectionType.Movies, StringComparison.OrdinalIgnoreCase)) - { - //return urlPrefix + "movies.jpg"; - } - if (string.Equals(viewType, CollectionType.Playlists, StringComparison.OrdinalIgnoreCase)) - { - return urlPrefix + "playlists.jpg"; - } - if (string.Equals(viewType, CollectionType.HomeVideos, StringComparison.OrdinalIgnoreCase)) - { - //return urlPrefix + "homevideos.jpg"; - } - if (string.Equals(viewType, CollectionType.MusicVideos, StringComparison.OrdinalIgnoreCase)) - { - return urlPrefix + "musicvideos.jpg"; - } - if (string.Equals(viewType, CollectionType.BoxSets, StringComparison.OrdinalIgnoreCase)) - { - //return urlPrefix + "collections.jpg"; - } - if (string.IsNullOrWhiteSpace(viewType)) - { - //return urlPrefix + "generic.jpg"; - } - - return null; - } - - public string Name - { - get { return "Default Image Provider"; } - } - - public bool Supports(IHasImages item) - { - var view = item as UserView; - - if (view != null) - { - return !string.IsNullOrWhiteSpace(GetImageUrl(view.ViewType)); - } - - var folder = item as ICollectionFolder; - - if (folder != null) - { - return !string.IsNullOrWhiteSpace(GetImageUrl(folder.CollectionType)); - } - - return false; - } - - public Task GetImageResponse(string url, CancellationToken cancellationToken) - { - return _httpClient.GetResponse(new HttpRequestOptions - { - CancellationToken = cancellationToken, - Url = url, - ResourcePool = GenreImageProvider.ImageDownloadResourcePool - }); - } - - public bool HasChanged(IHasMetadata item, IDirectoryService directoryService) - { - return GetSupportedImages(item).Any(i => !item.HasImage(i)); - } - } -} \ No newline at end of file diff --git a/MediaBrowser.Providers/MediaBrowser.Providers.csproj b/MediaBrowser.Providers/MediaBrowser.Providers.csproj index f07478f986..bbfa20738f 100644 --- a/MediaBrowser.Providers/MediaBrowser.Providers.csproj +++ b/MediaBrowser.Providers/MediaBrowser.Providers.csproj @@ -89,7 +89,6 @@ - @@ -145,10 +144,7 @@ - - - @@ -168,7 +164,6 @@ - diff --git a/MediaBrowser.Providers/Movies/FanArtMovieUpdatesPostScanTask.cs b/MediaBrowser.Providers/Movies/FanArtMovieUpdatesPostScanTask.cs deleted file mode 100644 index 5262f8e3b1..0000000000 --- a/MediaBrowser.Providers/Movies/FanArtMovieUpdatesPostScanTask.cs +++ /dev/null @@ -1,196 +0,0 @@ -using MediaBrowser.Common.Net; -using MediaBrowser.Controller.Configuration; -using MediaBrowser.Controller.Library; -using MediaBrowser.Model.Configuration; -using MediaBrowser.Model.Logging; -using MediaBrowser.Model.Serialization; -using MediaBrowser.Providers.Music; -using MediaBrowser.Providers.TV; -using System; -using System.Collections.Generic; -using System.Globalization; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -using CommonIO; - -namespace MediaBrowser.Providers.Movies -{ - class FanartMovieUpdatesPostScanTask : ILibraryPostScanTask - { - private const string UpdatesUrl = "https://webservice.fanart.tv/v3/movies/latest?api_key={0}&date={1}"; - - /// - /// The _HTTP client - /// - private readonly IHttpClient _httpClient; - /// - /// The _logger - /// - private readonly ILogger _logger; - /// - /// The _config - /// - private readonly IServerConfigurationManager _config; - private readonly IJsonSerializer _jsonSerializer; - private readonly IFileSystem _fileSystem; - - private static readonly CultureInfo UsCulture = new CultureInfo("en-US"); - - public FanartMovieUpdatesPostScanTask(IJsonSerializer jsonSerializer, IServerConfigurationManager config, ILogger logger, IHttpClient httpClient, IFileSystem fileSystem) - { - _jsonSerializer = jsonSerializer; - _config = config; - _logger = logger; - _httpClient = httpClient; - _fileSystem = fileSystem; - } - - /// - /// Runs the specified progress. - /// - /// The progress. - /// The cancellation token. - /// Task. - public async Task Run(IProgress progress, CancellationToken cancellationToken) - { - var options = FanartSeriesProvider.Current.GetFanartOptions(); - - if (!options.EnableAutomaticUpdates) - { - progress.Report(100); - return; - } - - var path = FanartMovieImageProvider.GetMoviesDataPath(_config.CommonApplicationPaths); - - _fileSystem.CreateDirectory(path); - - var timestampFile = Path.Combine(path, "time.txt"); - - var timestampFileInfo = _fileSystem.GetFileInfo(timestampFile); - - // Don't check for updates every single time - if (timestampFileInfo.Exists && (DateTime.UtcNow - _fileSystem.GetLastWriteTimeUtc(timestampFileInfo)).TotalDays < 3) - { - return; - } - - // Find out the last time we queried for updates - var lastUpdateTime = timestampFileInfo.Exists ? _fileSystem.ReadAllText(timestampFile, Encoding.UTF8) : string.Empty; - - var existingDirectories = Directory.EnumerateDirectories(path).Select(Path.GetFileName).ToList(); - - // If this is our first time, don't do any updates and just record the timestamp - if (!string.IsNullOrEmpty(lastUpdateTime)) - { - var moviesToUpdate = await GetMovieIdsToUpdate(existingDirectories, lastUpdateTime, options, cancellationToken).ConfigureAwait(false); - - progress.Report(5); - - await UpdateMovies(moviesToUpdate, progress, cancellationToken).ConfigureAwait(false); - } - - var newUpdateTime = Convert.ToInt64(DateTimeToUnixTimestamp(DateTime.UtcNow)).ToString(UsCulture); - - _fileSystem.WriteAllText(timestampFile, newUpdateTime, Encoding.UTF8); - - progress.Report(100); - } - - private async Task> GetMovieIdsToUpdate(IEnumerable existingIds, string lastUpdateTime, FanartOptions options, CancellationToken cancellationToken) - { - var url = string.Format(UpdatesUrl, FanartArtistProvider.ApiKey, lastUpdateTime); - - var clientKey = options.UserApiKey; - if (!string.IsNullOrWhiteSpace(clientKey)) - { - url += "&client_key=" + clientKey; - } - - // First get last time - using (var stream = await _httpClient.Get(new HttpRequestOptions - { - Url = url, - CancellationToken = cancellationToken, - EnableHttpCompression = true, - ResourcePool = FanartArtistProvider.Current.FanArtResourcePool - - }).ConfigureAwait(false)) - { - using (var reader = new StreamReader(stream)) - { - var json = await reader.ReadToEndAsync().ConfigureAwait(false); - - // If empty fanart will return a string of "null", rather than an empty list - if (string.Equals(json, "null", StringComparison.OrdinalIgnoreCase)) - { - return new List(); - } - - var updates = _jsonSerializer.DeserializeFromString>(json); - - var existingDictionary = existingIds.ToDictionary(i => i, StringComparer.OrdinalIgnoreCase); - - return updates.SelectMany(i => - { - var list = new List(); - - if (!string.IsNullOrWhiteSpace(i.imdb_id)) - { - list.Add(i.imdb_id); - } - if (!string.IsNullOrWhiteSpace(i.tmdb_id)) - { - list.Add(i.tmdb_id); - } - - return list; - - }).Where(existingDictionary.ContainsKey); - } - } - } - - private async Task UpdateMovies(IEnumerable idList, IProgress progress, CancellationToken cancellationToken) - { - var list = idList.ToList(); - var numComplete = 0; - - foreach (var id in list) - { - _logger.Info("Updating movie " + id); - - await FanartMovieImageProvider.Current.DownloadMovieJson(id, cancellationToken).ConfigureAwait(false); - - numComplete++; - double percent = numComplete; - percent /= list.Count; - percent *= 95; - - progress.Report(percent + 5); - } - } - - /// - /// Dates the time to unix timestamp. - /// - /// The date time. - /// System.Double. - private static double DateTimeToUnixTimestamp(DateTime dateTime) - { - return (dateTime - new DateTime(1970, 1, 1).ToUniversalTime()).TotalSeconds; - } - - public class RootObject - { - public string tmdb_id { get; set; } - public string imdb_id { get; set; } - public string name { get; set; } - public string new_images { get; set; } - public string total_images { get; set; } - } - } -} diff --git a/MediaBrowser.Providers/Movies/FanartMovieImageProvider.cs b/MediaBrowser.Providers/Movies/FanartMovieImageProvider.cs index 775e6dfb9c..18f1779325 100644 --- a/MediaBrowser.Providers/Movies/FanartMovieImageProvider.cs +++ b/MediaBrowser.Providers/Movies/FanartMovieImageProvider.cs @@ -24,7 +24,7 @@ using MediaBrowser.Providers.TV; namespace MediaBrowser.Providers.Movies { - public class FanartMovieImageProvider : IRemoteImageProvider, IHasItemChangeMonitor, IHasOrder + public class FanartMovieImageProvider : IRemoteImageProvider, IHasOrder { private readonly CultureInfo _usCulture = new CultureInfo("en-US"); private readonly IServerConfigurationManager _config; @@ -241,33 +241,6 @@ namespace MediaBrowser.Providers.Movies }); } - public bool HasChanged(IHasMetadata item, IDirectoryService directoryService) - { - var options = FanartSeriesProvider.Current.GetFanartOptions(); - if (!options.EnableAutomaticUpdates) - { - return false; - } - - var id = item.GetProviderId(MetadataProviders.Tmdb); - if (string.IsNullOrEmpty(id)) - { - id = item.GetProviderId(MetadataProviders.Imdb); - } - - if (!string.IsNullOrEmpty(id)) - { - // Process images - var path = GetFanartJsonPath(id); - - var fileInfo = _fileSystem.GetFileInfo(path); - - return !fileInfo.Exists || _fileSystem.GetLastWriteTimeUtc(fileInfo) > item.DateLastRefreshed; - } - - return false; - } - /// /// Gets the movie data path. /// diff --git a/MediaBrowser.Providers/Movies/MovieDbImageProvider.cs b/MediaBrowser.Providers/Movies/MovieDbImageProvider.cs index 5958c3a0ad..f9e9bc947f 100644 --- a/MediaBrowser.Providers/Movies/MovieDbImageProvider.cs +++ b/MediaBrowser.Providers/Movies/MovieDbImageProvider.cs @@ -17,7 +17,7 @@ using System.Threading.Tasks; namespace MediaBrowser.Providers.Movies { - class MovieDbImageProvider : IRemoteImageProvider, IHasOrder, IHasItemChangeMonitor + class MovieDbImageProvider : IRemoteImageProvider, IHasOrder { private readonly IJsonSerializer _jsonSerializer; private readonly IHttpClient _httpClient; @@ -221,10 +221,5 @@ namespace MediaBrowser.Providers.Movies ResourcePool = MovieDbProvider.Current.MovieDbResourcePool }); } - - public bool HasChanged(IHasMetadata item, IDirectoryService directoryService) - { - return MovieDbProvider.Current.HasChanged(item); - } } } diff --git a/MediaBrowser.Providers/Movies/MovieDbProvider.cs b/MediaBrowser.Providers/Movies/MovieDbProvider.cs index c588a9a690..6a2e727439 100644 --- a/MediaBrowser.Providers/Movies/MovieDbProvider.cs +++ b/MediaBrowser.Providers/Movies/MovieDbProvider.cs @@ -409,33 +409,6 @@ namespace MediaBrowser.Providers.Movies return await _httpClient.Get(options).ConfigureAwait(false); } - public TheMovieDbOptions GetTheMovieDbOptions() - { - return _configurationManager.GetConfiguration("themoviedb"); - } - - public bool HasChanged(IHasMetadata item) - { - if (!GetTheMovieDbOptions().EnableAutomaticUpdates) - { - return false; - } - - var tmdbId = item.GetProviderId(MetadataProviders.Tmdb); - - if (!String.IsNullOrEmpty(tmdbId)) - { - // Process images - var dataFilePath = GetDataFilePath(tmdbId, item.GetPreferredMetadataLanguage()); - - var fileInfo = _fileSystem.GetFileInfo(dataFilePath); - - return !fileInfo.Exists || _fileSystem.GetLastWriteTimeUtc(fileInfo) > item.DateLastRefreshed; - } - - return false; - } - public void Dispose() { Dispose(true); @@ -659,19 +632,4 @@ namespace MediaBrowser.Providers.Movies }); } } - - public class TmdbConfigStore : IConfigurationFactory - { - public IEnumerable GetConfigurations() - { - return new List - { - new ConfigurationStore - { - Key = "themoviedb", - ConfigurationType = typeof(TheMovieDbOptions) - } - }; - } - } } diff --git a/MediaBrowser.Providers/Movies/MovieDbTrailerProvider.cs b/MediaBrowser.Providers/Movies/MovieDbTrailerProvider.cs index 5fb3ea3696..1d8691ab8e 100644 --- a/MediaBrowser.Providers/Movies/MovieDbTrailerProvider.cs +++ b/MediaBrowser.Providers/Movies/MovieDbTrailerProvider.cs @@ -33,11 +33,6 @@ namespace MediaBrowser.Providers.Movies get { return MovieDbProvider.Current.Name; } } - public bool HasChanged(IHasMetadata item, IDirectoryService directoryService) - { - return MovieDbProvider.Current.HasChanged(item); - } - public int Order { get diff --git a/MediaBrowser.Providers/Movies/MovieUpdatesPrescanTask.cs b/MediaBrowser.Providers/Movies/MovieUpdatesPrescanTask.cs deleted file mode 100644 index 70c155ad5d..0000000000 --- a/MediaBrowser.Providers/Movies/MovieUpdatesPrescanTask.cs +++ /dev/null @@ -1,249 +0,0 @@ -using MediaBrowser.Common.Net; -using MediaBrowser.Controller.Configuration; -using MediaBrowser.Controller.Entities.Movies; -using MediaBrowser.Controller.Library; -using MediaBrowser.Model.Entities; -using MediaBrowser.Model.Logging; -using MediaBrowser.Model.Serialization; -using System; -using System.Collections.Generic; -using System.Globalization; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -using CommonIO; - -namespace MediaBrowser.Providers.Movies -{ - public class MovieUpdatesPreScanTask : ILibraryPostScanTask - { - /// - /// The updates URL - /// - private const string UpdatesUrl = "https://api.themoviedb.org/3/movie/changes?start_date={0}&api_key={1}&page={2}"; - - /// - /// The _HTTP client - /// - private readonly IHttpClient _httpClient; - /// - /// The _logger - /// - private readonly ILogger _logger; - /// - /// The _config - /// - private readonly IServerConfigurationManager _config; - private readonly IJsonSerializer _json; - private readonly IFileSystem _fileSystem; - private readonly ILibraryManager _libraryManager; - - /// - /// Initializes a new instance of the class. - /// - /// The logger. - /// The HTTP client. - /// The config. - /// The json. - public MovieUpdatesPreScanTask(ILogger logger, IHttpClient httpClient, IServerConfigurationManager config, IJsonSerializer json, IFileSystem fileSystem, ILibraryManager libraryManager) - { - _logger = logger; - _httpClient = httpClient; - _config = config; - _json = json; - _fileSystem = fileSystem; - _libraryManager = libraryManager; - } - - protected readonly CultureInfo UsCulture = new CultureInfo("en-US"); - - /// - /// Runs the specified progress. - /// - /// The progress. - /// The cancellation token. - /// Task. - public async Task Run(IProgress progress, CancellationToken cancellationToken) - { - if (!MovieDbProvider.Current.GetTheMovieDbOptions().EnableAutomaticUpdates) - { - progress.Report(100); - return; - } - - var path = MovieDbProvider.GetMoviesDataPath(_config.CommonApplicationPaths); - - _fileSystem.CreateDirectory(path); - - var timestampFile = Path.Combine(path, "time.txt"); - - var timestampFileInfo = _fileSystem.GetFileInfo(timestampFile); - - // Don't check for updates every single time - if (timestampFileInfo.Exists && (DateTime.UtcNow - _fileSystem.GetLastWriteTimeUtc(timestampFileInfo)).TotalDays < 7) - { - return; - } - - // Find out the last time we queried tvdb for updates - var lastUpdateTime = timestampFileInfo.Exists ? _fileSystem.ReadAllText(timestampFile, Encoding.UTF8) : string.Empty; - - var existingDirectories = Directory.EnumerateDirectories(path).Select(Path.GetFileName).ToList(); - - if (!string.IsNullOrEmpty(lastUpdateTime)) - { - long lastUpdateTicks; - - if (long.TryParse(lastUpdateTime, NumberStyles.Any, UsCulture, out lastUpdateTicks)) - { - var lastUpdateDate = new DateTime(lastUpdateTicks, DateTimeKind.Utc); - - // They only allow up to 14 days of updates - if ((DateTime.UtcNow - lastUpdateDate).TotalDays > 13) - { - lastUpdateDate = DateTime.UtcNow.AddDays(-13); - } - - var updatedIds = await GetIdsToUpdate(lastUpdateDate, 1, cancellationToken).ConfigureAwait(false); - - var existingDictionary = existingDirectories.ToDictionary(i => i, StringComparer.OrdinalIgnoreCase); - - var idsToUpdate = updatedIds.Where(i => !string.IsNullOrWhiteSpace(i) && existingDictionary.ContainsKey(i)); - - await UpdateMovies(idsToUpdate, progress, cancellationToken).ConfigureAwait(false); - } - } - - _fileSystem.WriteAllText(timestampFile, DateTime.UtcNow.Ticks.ToString(UsCulture), Encoding.UTF8); - progress.Report(100); - } - - - /// - /// Gets the ids to update. - /// - /// The last update time. - /// The page. - /// The cancellation token. - /// Task{IEnumerable{System.String}}. - private async Task> GetIdsToUpdate(DateTime lastUpdateTime, int page, CancellationToken cancellationToken) - { - bool hasMorePages; - var list = new List(); - - // First get last time - using (var stream = await _httpClient.Get(new HttpRequestOptions - { - Url = string.Format(UpdatesUrl, lastUpdateTime.ToString("yyyy-MM-dd"), MovieDbProvider.ApiKey, page), - CancellationToken = cancellationToken, - EnableHttpCompression = true, - ResourcePool = MovieDbProvider.Current.MovieDbResourcePool, - AcceptHeader = MovieDbProvider.AcceptHeader - - }).ConfigureAwait(false)) - { - var obj = _json.DeserializeFromStream(stream); - - var data = obj.results.Select(i => i.id.ToString(UsCulture)); - - list.AddRange(data); - - hasMorePages = page < obj.total_pages; - } - - if (hasMorePages) - { - var more = await GetIdsToUpdate(lastUpdateTime, page + 1, cancellationToken).ConfigureAwait(false); - - list.AddRange(more); - } - - return list; - } - - /// - /// Updates the movies. - /// - /// The ids. - /// The progress. - /// The cancellation token. - /// Task. - private async Task UpdateMovies(IEnumerable ids, IProgress progress, CancellationToken cancellationToken) - { - var list = ids.ToList(); - var numComplete = 0; - - // Gather all movies into a lookup by tmdb id - var allMovies = _libraryManager.GetItemList(new Controller.Entities.InternalItemsQuery - { - IncludeItemTypes = new[] {typeof (Movie).Name}, - Recursive = true - - }).Where(i => !string.IsNullOrEmpty(i.GetProviderId(MetadataProviders.Tmdb))) - .ToLookup(i => i.GetProviderId(MetadataProviders.Tmdb)); - - foreach (var id in list) - { - // Find the preferred language(s) for the movie in the library - var languages = allMovies[id] - .Select(i => i.GetPreferredMetadataLanguage()) - .Distinct(StringComparer.OrdinalIgnoreCase) - .ToList(); - - foreach (var language in languages) - { - try - { - await UpdateMovie(id, language, cancellationToken).ConfigureAwait(false); - } - catch (Exception ex) - { - _logger.ErrorException("Error updating tmdb movie id {0}, language {1}", ex, id, language); - } - } - - numComplete++; - double percent = numComplete; - percent /= list.Count; - percent *= 100; - - progress.Report(percent); - } - } - - /// - /// Updates the movie. - /// - /// The id. - /// The preferred metadata language. - /// The cancellation token. - /// Task. - private Task UpdateMovie(string id, string preferredMetadataLanguage, CancellationToken cancellationToken) - { - _logger.Info("Updating movie from tmdb " + id + ", language " + preferredMetadataLanguage); - - return MovieDbProvider.Current.DownloadMovieInfo(id, preferredMetadataLanguage, cancellationToken); - } - - class Result - { - public int id { get; set; } - public bool? adult { get; set; } - } - - class RootObject - { - public List results { get; set; } - public int page { get; set; } - public int total_pages { get; set; } - public int total_results { get; set; } - - public RootObject() - { - results = new List(); - } - } - } -} diff --git a/MediaBrowser.Providers/Music/FanArtAlbumProvider.cs b/MediaBrowser.Providers/Music/FanArtAlbumProvider.cs index 5b3bd87db0..b47e8df5ae 100644 --- a/MediaBrowser.Providers/Music/FanArtAlbumProvider.cs +++ b/MediaBrowser.Providers/Music/FanArtAlbumProvider.cs @@ -19,7 +19,7 @@ using MediaBrowser.Model.Serialization; namespace MediaBrowser.Providers.Music { - public class FanartAlbumProvider : IRemoteImageProvider, IHasItemChangeMonitor, IHasOrder + public class FanartAlbumProvider : IRemoteImageProvider, IHasOrder { private readonly CultureInfo _usCulture = new CultureInfo("en-US"); private readonly IServerConfigurationManager _config; @@ -212,34 +212,5 @@ namespace MediaBrowser.Providers.Music ResourcePool = FanartArtistProvider.Current.FanArtResourcePool }); } - - public bool HasChanged(IHasMetadata item, IDirectoryService directoryService) - { - var options = FanartSeriesProvider.Current.GetFanartOptions(); - if (!options.EnableAutomaticUpdates) - { - return false; - } - - var album = (MusicAlbum)item; - var artist = album.MusicArtist; - - if (artist != null) - { - var artistMusicBrainzId = artist.GetProviderId(MetadataProviders.MusicBrainzArtist); - - if (!String.IsNullOrEmpty(artistMusicBrainzId)) - { - // Process images - var artistJsonPath = FanartArtistProvider.GetArtistJsonPath(_config.CommonApplicationPaths, artistMusicBrainzId); - - var fileInfo = _fileSystem.GetFileInfo(artistJsonPath); - - return !fileInfo.Exists || _fileSystem.GetLastWriteTimeUtc(fileInfo) > item.DateLastRefreshed; - } - } - - return false; - } } } diff --git a/MediaBrowser.Providers/Music/FanArtArtistProvider.cs b/MediaBrowser.Providers/Music/FanArtArtistProvider.cs index 37b51da5a3..9b18ac5e92 100644 --- a/MediaBrowser.Providers/Music/FanArtArtistProvider.cs +++ b/MediaBrowser.Providers/Music/FanArtArtistProvider.cs @@ -22,7 +22,7 @@ using MediaBrowser.Model.Serialization; namespace MediaBrowser.Providers.Music { - public class FanartArtistProvider : IRemoteImageProvider, IHasItemChangeMonitor, IHasOrder + public class FanartArtistProvider : IRemoteImageProvider, IHasOrder { internal readonly SemaphoreSlim FanArtResourcePool = new SemaphoreSlim(3, 3); internal const string ApiKey = "5c6b04c68e904cfed1e6cbc9a9e683d4"; @@ -207,29 +207,6 @@ namespace MediaBrowser.Providers.Music }); } - public bool HasChanged(IHasMetadata item, IDirectoryService directoryService) - { - var options = FanartSeriesProvider.Current.GetFanartOptions(); - if (!options.EnableAutomaticUpdates) - { - return false; - } - - var id = item.GetProviderId(MetadataProviders.MusicBrainzArtist); - - if (!String.IsNullOrEmpty(id)) - { - // Process images - var artistJsonPath = GetArtistJsonPath(_config.CommonApplicationPaths, id); - - var fileInfo = _fileSystem.GetFileInfo(artistJsonPath); - - return !fileInfo.Exists || _fileSystem.GetLastWriteTimeUtc(fileInfo) > item.DateLastRefreshed; - } - - return false; - } - private readonly Task _cachedTask = Task.FromResult(true); internal Task EnsureArtistJson(string musicBrainzId, CancellationToken cancellationToken) { diff --git a/MediaBrowser.Providers/Music/FanArtUpdatesPostScanTask.cs b/MediaBrowser.Providers/Music/FanArtUpdatesPostScanTask.cs deleted file mode 100644 index 3b829af9eb..0000000000 --- a/MediaBrowser.Providers/Music/FanArtUpdatesPostScanTask.cs +++ /dev/null @@ -1,203 +0,0 @@ -using MediaBrowser.Common.Net; -using MediaBrowser.Controller.Configuration; -using MediaBrowser.Controller.Library; -using MediaBrowser.Model.Configuration; -using MediaBrowser.Model.Logging; -using MediaBrowser.Model.Serialization; -using System; -using System.Collections.Generic; -using System.Globalization; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -using CommonIO; -using MediaBrowser.Providers.TV; - -namespace MediaBrowser.Providers.Music -{ - class FanartUpdatesPostScanTask : ILibraryPostScanTask - { - private const string UpdatesUrl = "https://api.fanart.tv/webservice/newmusic/{0}/{1}/"; - - /// - /// The _HTTP client - /// - private readonly IHttpClient _httpClient; - /// - /// The _logger - /// - private readonly ILogger _logger; - /// - /// The _config - /// - private readonly IServerConfigurationManager _config; - private readonly IJsonSerializer _jsonSerializer; - private readonly IFileSystem _fileSystem; - - private static readonly CultureInfo UsCulture = new CultureInfo("en-US"); - - public FanartUpdatesPostScanTask(IJsonSerializer jsonSerializer, IServerConfigurationManager config, ILogger logger, IHttpClient httpClient, IFileSystem fileSystem) - { - _jsonSerializer = jsonSerializer; - _config = config; - _logger = logger; - _httpClient = httpClient; - _fileSystem = fileSystem; - } - - /// - /// Runs the specified progress. - /// - /// The progress. - /// The cancellation token. - /// Task. - public async Task Run(IProgress progress, CancellationToken cancellationToken) - { - var options = FanartSeriesProvider.Current.GetFanartOptions(); - - if (!options.EnableAutomaticUpdates) - { - progress.Report(100); - return; - } - - var path = FanartArtistProvider.GetArtistDataPath(_config.CommonApplicationPaths); - - _fileSystem.CreateDirectory(path); - - var timestampFile = Path.Combine(path, "time.txt"); - - var timestampFileInfo = _fileSystem.GetFileInfo(timestampFile); - - // Don't check for updates every single time - if (timestampFileInfo.Exists && (DateTime.UtcNow - _fileSystem.GetLastWriteTimeUtc(timestampFileInfo)).TotalDays < 3) - { - return; - } - - // Find out the last time we queried for updates - var lastUpdateTime = timestampFileInfo.Exists ? _fileSystem.ReadAllText(timestampFile, Encoding.UTF8) : string.Empty; - - var existingDirectories = Directory.EnumerateDirectories(path).Select(Path.GetFileName).ToList(); - - // If this is our first time, don't do any updates and just record the timestamp - if (!string.IsNullOrEmpty(lastUpdateTime)) - { - var artistsToUpdate = await GetArtistIdsToUpdate(existingDirectories, lastUpdateTime, options, cancellationToken).ConfigureAwait(false); - - progress.Report(5); - - await UpdateArtists(artistsToUpdate, progress, cancellationToken).ConfigureAwait(false); - } - - var newUpdateTime = Convert.ToInt64(DateTimeToUnixTimestamp(DateTime.UtcNow)).ToString(UsCulture); - - _fileSystem.WriteAllText(timestampFile, newUpdateTime, Encoding.UTF8); - - progress.Report(100); - } - - /// - /// Gets the artist ids to update. - /// - /// The existing series ids. - /// The last update time. - /// The cancellation token. - /// Task{IEnumerable{System.String}}. - private async Task> GetArtistIdsToUpdate(IEnumerable existingArtistIds, string lastUpdateTime, FanartOptions options, CancellationToken cancellationToken) - { - var url = string.Format(UpdatesUrl, FanartArtistProvider.ApiKey, lastUpdateTime); - - if (!string.IsNullOrWhiteSpace(options.UserApiKey)) - { - url += "&client_key=" + options.UserApiKey; - } - - // First get last time - using (var stream = await _httpClient.Get(new HttpRequestOptions - { - Url = url, - CancellationToken = cancellationToken, - EnableHttpCompression = true, - ResourcePool = FanartArtistProvider.Current.FanArtResourcePool - - }).ConfigureAwait(false)) - { - // If empty fanart will return a string of "null", rather than an empty list - using (var reader = new StreamReader(stream)) - { - var json = await reader.ReadToEndAsync().ConfigureAwait(false); - - if (string.Equals(json, "null", StringComparison.OrdinalIgnoreCase)) - { - return new List(); - } - - var existingDictionary = existingArtistIds.ToDictionary(i => i, StringComparer.OrdinalIgnoreCase); - - var updates = _jsonSerializer.DeserializeFromString>(json); - - return updates.Select(i => i.id).Where(existingDictionary.ContainsKey); - } - } - } - - /// - /// Updates the artists. - /// - /// The id list. - /// The progress. - /// The cancellation token. - /// Task. - private async Task UpdateArtists(IEnumerable idList, IProgress progress, CancellationToken cancellationToken) - { - var list = idList.ToList(); - var numComplete = 0; - - foreach (var id in list) - { - await UpdateArtist(id, cancellationToken).ConfigureAwait(false); - - numComplete++; - double percent = numComplete; - percent /= list.Count; - percent *= 95; - - progress.Report(percent + 5); - } - } - - /// - /// Updates the artist. - /// - /// The musicBrainzId. - /// The cancellation token. - /// Task. - private Task UpdateArtist(string musicBrainzId, CancellationToken cancellationToken) - { - _logger.Info("Updating artist " + musicBrainzId); - - return FanartArtistProvider.Current.DownloadArtistJson(musicBrainzId, cancellationToken); - } - - /// - /// Dates the time to unix timestamp. - /// - /// The date time. - /// System.Double. - private static double DateTimeToUnixTimestamp(DateTime dateTime) - { - return (dateTime - new DateTime(1970, 1, 1).ToUniversalTime()).TotalSeconds; - } - - public class FanArtUpdate - { - public string id { get; set; } - public string name { get; set; } - public string new_images { get; set; } - public string total_images { get; set; } - } - } -} diff --git a/MediaBrowser.Providers/Music/MovieDbMusicVideoProvider.cs b/MediaBrowser.Providers/Music/MovieDbMusicVideoProvider.cs index d031b3d6b2..88689dd5a3 100644 --- a/MediaBrowser.Providers/Music/MovieDbMusicVideoProvider.cs +++ b/MediaBrowser.Providers/Music/MovieDbMusicVideoProvider.cs @@ -27,11 +27,6 @@ namespace MediaBrowser.Providers.Music get { return MovieDbProvider.Current.Name; } } - public bool HasChanged(IHasMetadata item, IDirectoryService directoryService) - { - return MovieDbProvider.Current.HasChanged(item); - } - public Task GetImageResponse(string url, CancellationToken cancellationToken) { throw new NotImplementedException(); diff --git a/MediaBrowser.Providers/TV/FanArt/FanArtSeasonProvider.cs b/MediaBrowser.Providers/TV/FanArt/FanArtSeasonProvider.cs index 673663d7f1..b1930d8f0e 100644 --- a/MediaBrowser.Providers/TV/FanArt/FanArtSeasonProvider.cs +++ b/MediaBrowser.Providers/TV/FanArt/FanArtSeasonProvider.cs @@ -21,7 +21,7 @@ using CommonIO; namespace MediaBrowser.Providers.TV { - public class FanArtSeasonProvider : IRemoteImageProvider, IHasOrder, IHasItemChangeMonitor + public class FanArtSeasonProvider : IRemoteImageProvider, IHasOrder { private readonly CultureInfo _usCulture = new CultureInfo("en-US"); private readonly IServerConfigurationManager _config; @@ -224,36 +224,5 @@ namespace MediaBrowser.Providers.TV ResourcePool = FanartArtistProvider.Current.FanArtResourcePool }); } - - public bool HasChanged(IHasMetadata item, IDirectoryService directoryService) - { - var options = FanartSeriesProvider.Current.GetFanartOptions(); - if (!options.EnableAutomaticUpdates) - { - return false; - } - - var season = (Season)item; - var series = season.Series; - - if (series == null) - { - return false; - } - - var tvdbId = series.GetProviderId(MetadataProviders.Tvdb); - - if (!String.IsNullOrEmpty(tvdbId)) - { - // Process images - var imagesFilePath = FanartSeriesProvider.Current.GetFanartJsonPath(tvdbId); - - var fileInfo = _fileSystem.GetFileInfo(imagesFilePath); - - return !fileInfo.Exists || _fileSystem.GetLastWriteTimeUtc(fileInfo) > item.DateLastRefreshed; - } - - return false; - } } } diff --git a/MediaBrowser.Providers/TV/FanArt/FanArtTvUpdatesPostScanTask.cs b/MediaBrowser.Providers/TV/FanArt/FanArtTvUpdatesPostScanTask.cs deleted file mode 100644 index 37e76531b1..0000000000 --- a/MediaBrowser.Providers/TV/FanArt/FanArtTvUpdatesPostScanTask.cs +++ /dev/null @@ -1,192 +0,0 @@ -using MediaBrowser.Common.Net; -using MediaBrowser.Controller.Configuration; -using MediaBrowser.Controller.Library; -using MediaBrowser.Model.Configuration; -using MediaBrowser.Model.Logging; -using MediaBrowser.Model.Serialization; -using MediaBrowser.Providers.Music; -using System; -using System.Collections.Generic; -using System.Globalization; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -using CommonIO; - -namespace MediaBrowser.Providers.TV -{ - class FanArtTvUpdatesPostScanTask : ILibraryPostScanTask - { - private const string UpdatesUrl = "https://webservice.fanart.tv/v3/tv/latest?api_key={0}&date={1}"; - - /// - /// The _HTTP client - /// - private readonly IHttpClient _httpClient; - /// - /// The _logger - /// - private readonly ILogger _logger; - /// - /// The _config - /// - private readonly IServerConfigurationManager _config; - private readonly IJsonSerializer _jsonSerializer; - private readonly IFileSystem _fileSystem; - - private static readonly CultureInfo UsCulture = new CultureInfo("en-US"); - - public FanArtTvUpdatesPostScanTask(IJsonSerializer jsonSerializer, IServerConfigurationManager config, ILogger logger, IHttpClient httpClient, IFileSystem fileSystem) - { - _jsonSerializer = jsonSerializer; - _config = config; - _logger = logger; - _httpClient = httpClient; - _fileSystem = fileSystem; - } - - /// - /// Runs the specified progress. - /// - /// The progress. - /// The cancellation token. - /// Task. - public async Task Run(IProgress progress, CancellationToken cancellationToken) - { - var options = FanartSeriesProvider.Current.GetFanartOptions(); - - if (!options.EnableAutomaticUpdates) - { - progress.Report(100); - return; - } - - var path = FanartSeriesProvider.GetSeriesDataPath(_config.CommonApplicationPaths); - - _fileSystem.CreateDirectory(path); - - var timestampFile = Path.Combine(path, "time.txt"); - - var timestampFileInfo = _fileSystem.GetFileInfo(timestampFile); - - // Don't check for updates every single time - if (timestampFileInfo.Exists && (DateTime.UtcNow - _fileSystem.GetLastWriteTimeUtc(timestampFileInfo)).TotalDays < 3) - { - return; - } - - // Find out the last time we queried for updates - var lastUpdateTime = timestampFileInfo.Exists ? _fileSystem.ReadAllText(timestampFile, Encoding.UTF8) : string.Empty; - - var existingDirectories = Directory.EnumerateDirectories(path).Select(Path.GetFileName).ToList(); - - // If this is our first time, don't do any updates and just record the timestamp - if (!string.IsNullOrEmpty(lastUpdateTime)) - { - var seriesToUpdate = await GetSeriesIdsToUpdate(existingDirectories, lastUpdateTime, options, cancellationToken).ConfigureAwait(false); - - progress.Report(5); - - await UpdateSeries(seriesToUpdate, progress, cancellationToken).ConfigureAwait(false); - } - - var newUpdateTime = Convert.ToInt64(DateTimeToUnixTimestamp(DateTime.UtcNow)).ToString(UsCulture); - - _fileSystem.WriteAllText(timestampFile, newUpdateTime, Encoding.UTF8); - - progress.Report(100); - } - - /// - /// Gets the series ids to update. - /// - /// The existing series ids. - /// The last update time. - /// The cancellation token. - /// Task{IEnumerable{System.String}}. - private async Task> GetSeriesIdsToUpdate(IEnumerable existingSeriesIds, string lastUpdateTime, FanartOptions options, CancellationToken cancellationToken) - { - var url = string.Format(UpdatesUrl, FanartArtistProvider.ApiKey, lastUpdateTime); - - if (!string.IsNullOrWhiteSpace(options.UserApiKey)) - { - url += "&client_key=" + options.UserApiKey; - } - - // First get last time - using (var stream = await _httpClient.Get(new HttpRequestOptions - { - Url = url, - CancellationToken = cancellationToken, - EnableHttpCompression = true, - ResourcePool = FanartArtistProvider.Current.FanArtResourcePool - - }).ConfigureAwait(false)) - { - // If empty fanart will return a string of "null", rather than an empty list - using (var reader = new StreamReader(stream)) - { - var json = await reader.ReadToEndAsync().ConfigureAwait(false); - - if (string.Equals(json, "null", StringComparison.OrdinalIgnoreCase) || string.IsNullOrWhiteSpace(json)) - { - return new List(); - } - - var existingDictionary = existingSeriesIds.ToDictionary(i => i, StringComparer.OrdinalIgnoreCase); - - var updates = _jsonSerializer.DeserializeFromString>(json); - - return updates.Select(i => i.id).Where(existingDictionary.ContainsKey); - } - } - } - - /// - /// Updates the series. - /// - /// The id list. - /// The progress. - /// The cancellation token. - /// Task. - private async Task UpdateSeries(IEnumerable idList, IProgress progress, CancellationToken cancellationToken) - { - var list = idList.ToList(); - var numComplete = 0; - - foreach (var id in list) - { - _logger.Info("Updating series " + id); - - await FanartSeriesProvider.Current.DownloadSeriesJson(id, cancellationToken).ConfigureAwait(false); - - numComplete++; - double percent = numComplete; - percent /= list.Count; - percent *= 95; - - progress.Report(percent + 5); - } - } - - /// - /// Dates the time to unix timestamp. - /// - /// The date time. - /// System.Double. - private static double DateTimeToUnixTimestamp(DateTime dateTime) - { - return (dateTime - new DateTime(1970, 1, 1).ToUniversalTime()).TotalSeconds; - } - - public class FanArtUpdate - { - public string id { get; set; } - public string name { get; set; } - public string new_images { get; set; } - public string total_images { get; set; } - } - } -} diff --git a/MediaBrowser.Providers/TV/FanArt/FanartSeriesProvider.cs b/MediaBrowser.Providers/TV/FanArt/FanartSeriesProvider.cs index 3c831dbbca..5662082db2 100644 --- a/MediaBrowser.Providers/TV/FanArt/FanartSeriesProvider.cs +++ b/MediaBrowser.Providers/TV/FanArt/FanartSeriesProvider.cs @@ -23,7 +23,7 @@ using CommonIO; namespace MediaBrowser.Providers.TV { - public class FanartSeriesProvider : IRemoteImageProvider, IHasOrder, IHasItemChangeMonitor + public class FanartSeriesProvider : IRemoteImageProvider, IHasOrder { private readonly CultureInfo _usCulture = new CultureInfo("en-US"); private readonly IServerConfigurationManager _config; @@ -341,29 +341,6 @@ namespace MediaBrowser.Providers.TV } } - public bool HasChanged(IHasMetadata item, IDirectoryService directoryService) - { - var options = GetFanartOptions(); - if (!options.EnableAutomaticUpdates) - { - return false; - } - - var tvdbId = item.GetProviderId(MetadataProviders.Tvdb); - - if (!String.IsNullOrEmpty(tvdbId)) - { - // Process images - var imagesFilePath = GetFanartJsonPath(tvdbId); - - var fileInfo = _fileSystem.GetFileInfo(imagesFilePath); - - return !fileInfo.Exists || _fileSystem.GetLastWriteTimeUtc(fileInfo) > item.DateLastRefreshed; - } - - return false; - } - public class Image { public string id { get; set; } diff --git a/MediaBrowser.Providers/TV/TheMovieDb/MovieDbSeriesImageProvider.cs b/MediaBrowser.Providers/TV/TheMovieDb/MovieDbSeriesImageProvider.cs index 65ac12adf0..06481f8f2f 100644 --- a/MediaBrowser.Providers/TV/TheMovieDb/MovieDbSeriesImageProvider.cs +++ b/MediaBrowser.Providers/TV/TheMovieDb/MovieDbSeriesImageProvider.cs @@ -16,7 +16,7 @@ using System.Threading.Tasks; namespace MediaBrowser.Providers.TV { - public class MovieDbSeriesImageProvider : IRemoteImageProvider, IHasOrder, IHasItemChangeMonitor + public class MovieDbSeriesImageProvider : IRemoteImageProvider, IHasOrder { private readonly IJsonSerializer _jsonSerializer; private readonly IHttpClient _httpClient; @@ -195,10 +195,5 @@ namespace MediaBrowser.Providers.TV ResourcePool = MovieDbProvider.Current.MovieDbResourcePool }); } - - public bool HasChanged(IHasMetadata item, IDirectoryService directoryService) - { - return MovieDbSeriesProvider.Current.HasChanged(item); - } } } diff --git a/MediaBrowser.Providers/TV/TheMovieDb/MovieDbSeriesProvider.cs b/MediaBrowser.Providers/TV/TheMovieDb/MovieDbSeriesProvider.cs index 7d0f499550..4a20418bb1 100644 --- a/MediaBrowser.Providers/TV/TheMovieDb/MovieDbSeriesProvider.cs +++ b/MediaBrowser.Providers/TV/TheMovieDb/MovieDbSeriesProvider.cs @@ -414,28 +414,6 @@ namespace MediaBrowser.Providers.TV return Path.Combine(path, filename); } - public bool HasChanged(IHasMetadata item) - { - if (!MovieDbProvider.Current.GetTheMovieDbOptions().EnableAutomaticUpdates) - { - return false; - } - - var tmdbId = item.GetProviderId(MetadataProviders.Tmdb); - - if (!String.IsNullOrEmpty(tmdbId)) - { - // Process images - var dataFilePath = GetDataFilePath(tmdbId, item.GetPreferredMetadataLanguage()); - - var fileInfo = _fileSystem.GetFileInfo(dataFilePath); - - return !fileInfo.Exists || _fileSystem.GetLastWriteTimeUtc(fileInfo) > item.DateLastRefreshed; - } - - return false; - } - private async Task FindByExternalId(string id, string externalSource, CancellationToken cancellationToken) { var url = string.Format("https://api.themoviedb.org/3/tv/find/{0}?api_key={1}&external_source={2}", diff --git a/MediaBrowser.Providers/TV/TheTVDB/TvdbEpisodeImageProvider.cs b/MediaBrowser.Providers/TV/TheTVDB/TvdbEpisodeImageProvider.cs index 7a0b2c90c6..8815132864 100644 --- a/MediaBrowser.Providers/TV/TheTVDB/TvdbEpisodeImageProvider.cs +++ b/MediaBrowser.Providers/TV/TheTVDB/TvdbEpisodeImageProvider.cs @@ -17,7 +17,7 @@ using CommonIO; namespace MediaBrowser.Providers.TV { - public class TvdbEpisodeImageProvider : IRemoteImageProvider, IHasItemChangeMonitor + public class TvdbEpisodeImageProvider : IRemoteImageProvider { private readonly IServerConfigurationManager _config; private readonly CultureInfo _usCulture = new CultureInfo("en-US"); @@ -173,31 +173,5 @@ namespace MediaBrowser.Providers.TV ResourcePool = TvdbSeriesProvider.Current.TvDbResourcePool }); } - - public bool HasChanged(IHasMetadata item, IDirectoryService directoryService) - { - // For non-unaired items, only enable if configured - if (!TvdbSeriesProvider.Current.GetTvDbOptions().EnableAutomaticUpdates) - { - return false; - } - - if (!item.HasImage(ImageType.Primary)) - { - var episode = (Episode)item; - - var series = episode.Series; - - if (series != null && TvdbSeriesProvider.IsValidSeries(series.ProviderIds)) - { - // Process images - var seriesXmlPath = TvdbSeriesProvider.Current.GetSeriesXmlPath(series.ProviderIds, series.GetPreferredMetadataLanguage()); - - return _fileSystem.GetLastWriteTimeUtc(seriesXmlPath) > item.DateLastRefreshed; - } - } - - return false; - } } } diff --git a/MediaBrowser.Providers/TV/TheTVDB/TvdbEpisodeProvider.cs b/MediaBrowser.Providers/TV/TheTVDB/TvdbEpisodeProvider.cs index 509b22ee6b..7005ba8f58 100644 --- a/MediaBrowser.Providers/TV/TheTVDB/TvdbEpisodeProvider.cs +++ b/MediaBrowser.Providers/TV/TheTVDB/TvdbEpisodeProvider.cs @@ -24,7 +24,7 @@ namespace MediaBrowser.Providers.TV /// /// Class RemoteEpisodeProvider /// - class TvdbEpisodeProvider : IRemoteMetadataProvider, IItemIdentityProvider, IHasItemChangeMonitor + class TvdbEpisodeProvider : IRemoteMetadataProvider, IItemIdentityProvider { private static readonly string FullIdKey = MetadataProviders.Tvdb + "-Full"; @@ -144,27 +144,6 @@ namespace MediaBrowser.Providers.TV return result; } - public bool HasChanged(IHasMetadata item, IDirectoryService directoryService) - { - if (!TvdbSeriesProvider.Current.GetTvDbOptions().EnableAutomaticUpdates) - { - return false; - } - - var episode = (Episode)item; - var series = episode.Series; - - if (series != null && TvdbSeriesProvider.IsValidSeries(series.ProviderIds)) - { - // Process images - var seriesXmlPath = TvdbSeriesProvider.Current.GetSeriesXmlPath(series.ProviderIds, series.GetPreferredMetadataLanguage()); - - return _fileSystem.GetLastWriteTimeUtc(seriesXmlPath) > item.DateLastRefreshed; - } - - return false; - } - /// /// Gets the episode XML files. /// diff --git a/MediaBrowser.Providers/TV/TheTVDB/TvdbSeasonImageProvider.cs b/MediaBrowser.Providers/TV/TheTVDB/TvdbSeasonImageProvider.cs index 52d12e501b..71587db979 100644 --- a/MediaBrowser.Providers/TV/TheTVDB/TvdbSeasonImageProvider.cs +++ b/MediaBrowser.Providers/TV/TheTVDB/TvdbSeasonImageProvider.cs @@ -20,7 +20,7 @@ using CommonIO; namespace MediaBrowser.Providers.TV { - public class TvdbSeasonImageProvider : IRemoteImageProvider, IHasOrder, IHasItemChangeMonitor + public class TvdbSeasonImageProvider : IRemoteImageProvider, IHasOrder { private static readonly CultureInfo UsCulture = new CultureInfo("en-US"); @@ -362,28 +362,5 @@ namespace MediaBrowser.Providers.TV ResourcePool = TvdbSeriesProvider.Current.TvDbResourcePool }); } - - public bool HasChanged(IHasMetadata item, IDirectoryService directoryService) - { - if (!TvdbSeriesProvider.Current.GetTvDbOptions().EnableAutomaticUpdates) - { - return false; - } - - var season = (Season)item; - var series = season.Series; - - if (series != null && TvdbSeriesProvider.IsValidSeries(series.ProviderIds)) - { - // Process images - var imagesXmlPath = Path.Combine(TvdbSeriesProvider.GetSeriesDataPath(_config.ApplicationPaths, series.ProviderIds), "banners.xml"); - - var fileInfo = _fileSystem.GetFileInfo(imagesXmlPath); - - return fileInfo.Exists && _fileSystem.GetLastWriteTimeUtc(fileInfo) > item.DateLastRefreshed; - } - - return false; - } } } diff --git a/MediaBrowser.Providers/TV/TheTVDB/TvdbSeriesImageProvider.cs b/MediaBrowser.Providers/TV/TheTVDB/TvdbSeriesImageProvider.cs index d1cdc717e4..c8efbfb141 100644 --- a/MediaBrowser.Providers/TV/TheTVDB/TvdbSeriesImageProvider.cs +++ b/MediaBrowser.Providers/TV/TheTVDB/TvdbSeriesImageProvider.cs @@ -20,7 +20,7 @@ using CommonIO; namespace MediaBrowser.Providers.TV { - public class TvdbSeriesImageProvider : IRemoteImageProvider, IHasOrder, IHasItemChangeMonitor + public class TvdbSeriesImageProvider : IRemoteImageProvider, IHasOrder { private readonly IServerConfigurationManager _config; private readonly IHttpClient _httpClient; @@ -331,25 +331,5 @@ namespace MediaBrowser.Providers.TV ResourcePool = TvdbSeriesProvider.Current.TvDbResourcePool }); } - - public bool HasChanged(IHasMetadata item, IDirectoryService directoryService) - { - if (!TvdbSeriesProvider.Current.GetTvDbOptions().EnableAutomaticUpdates) - { - return false; - } - - if (TvdbSeriesProvider.IsValidSeries(item.ProviderIds)) - { - // Process images - var imagesXmlPath = Path.Combine(TvdbSeriesProvider.GetSeriesDataPath(_config.ApplicationPaths, item.ProviderIds), "banners.xml"); - - var fileInfo = _fileSystem.GetFileInfo(imagesXmlPath); - - return fileInfo.Exists && _fileSystem.GetLastWriteTimeUtc(fileInfo) > item.DateLastRefreshed; - } - - return false; - } } } diff --git a/MediaBrowser.Providers/TV/TheTVDB/TvdbSeriesProvider.cs b/MediaBrowser.Providers/TV/TheTVDB/TvdbSeriesProvider.cs index ee1505b46c..15b0c97aca 100644 --- a/MediaBrowser.Providers/TV/TheTVDB/TvdbSeriesProvider.cs +++ b/MediaBrowser.Providers/TV/TheTVDB/TvdbSeriesProvider.cs @@ -311,11 +311,6 @@ namespace MediaBrowser.Providers.TV return null; } - public TvdbOptions GetTvDbOptions() - { - return _config.GetConfiguration("tvdb"); - } - internal static bool IsValidSeries(Dictionary seriesProviderIds) { string id; @@ -392,27 +387,25 @@ namespace MediaBrowser.Providers.TV var seriesXmlFilename = preferredMetadataLanguage + ".xml"; - var automaticUpdatesEnabled = GetTvDbOptions().EnableAutomaticUpdates; - const int cacheDays = 1; var seriesFile = files.FirstOrDefault(i => string.Equals(seriesXmlFilename, i.Name, StringComparison.OrdinalIgnoreCase)); // No need to check age if automatic updates are enabled - if (seriesFile == null || !seriesFile.Exists || (!automaticUpdatesEnabled && (DateTime.UtcNow - _fileSystem.GetLastWriteTimeUtc(seriesFile)).TotalDays > cacheDays)) + if (seriesFile == null || !seriesFile.Exists || (DateTime.UtcNow - _fileSystem.GetLastWriteTimeUtc(seriesFile)).TotalDays > cacheDays) { return false; } var actorsXml = files.FirstOrDefault(i => string.Equals("actors.xml", i.Name, StringComparison.OrdinalIgnoreCase)); // No need to check age if automatic updates are enabled - if (actorsXml == null || !actorsXml.Exists || (!automaticUpdatesEnabled && (DateTime.UtcNow - _fileSystem.GetLastWriteTimeUtc(actorsXml)).TotalDays > cacheDays)) + if (actorsXml == null || !actorsXml.Exists || (DateTime.UtcNow - _fileSystem.GetLastWriteTimeUtc(actorsXml)).TotalDays > cacheDays) { return false; } var bannersXml = files.FirstOrDefault(i => string.Equals("banners.xml", i.Name, StringComparison.OrdinalIgnoreCase)); // No need to check age if automatic updates are enabled - if (bannersXml == null || !bannersXml.Exists || (!automaticUpdatesEnabled && (DateTime.UtcNow - _fileSystem.GetLastWriteTimeUtc(bannersXml)).TotalDays > cacheDays)) + if (bannersXml == null || !bannersXml.Exists || (DateTime.UtcNow - _fileSystem.GetLastWriteTimeUtc(bannersXml)).TotalDays > cacheDays) { return false; } @@ -1450,19 +1443,4 @@ namespace MediaBrowser.Providers.TV }); } } - - public class TvdbConfigStore : IConfigurationFactory - { - public IEnumerable GetConfigurations() - { - return new List - { - new ConfigurationStore - { - Key = "tvdb", - ConfigurationType = typeof(TvdbOptions) - } - }; - } - } }