From 96d090f908b82123ffe99dca82770b5cde2fc347 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Tue, 24 May 2016 15:48:53 -0400 Subject: [PATCH 1/5] update episode filters --- MediaBrowser.Api/TvShowsService.cs | 11 +++- MediaBrowser.Controller/Entities/TV/Season.cs | 2 +- MediaBrowser.Controller/Entities/TV/Series.cs | 54 +++++++++++++++---- 3 files changed, 56 insertions(+), 11 deletions(-) diff --git a/MediaBrowser.Api/TvShowsService.cs b/MediaBrowser.Api/TvShowsService.cs index c4c603f91..aa0485d57 100644 --- a/MediaBrowser.Api/TvShowsService.cs +++ b/MediaBrowser.Api/TvShowsService.cs @@ -456,7 +456,16 @@ namespace MediaBrowser.Api throw new ResourceNotFoundException("No series exists with Id " + request.Id); } - episodes = series.GetEpisodes(user, request.Season.Value); + var season = series.GetSeasons(user).FirstOrDefault(i => i.IndexNumber == request.Season.Value); + + if (season == null) + { + episodes = new List(); + } + else + { + episodes = series.GetEpisodes(user, season); + } } else { diff --git a/MediaBrowser.Controller/Entities/TV/Season.cs b/MediaBrowser.Controller/Entities/TV/Season.cs index 68170884c..7fa1b55de 100644 --- a/MediaBrowser.Controller/Entities/TV/Season.cs +++ b/MediaBrowser.Controller/Entities/TV/Season.cs @@ -205,7 +205,7 @@ namespace MediaBrowser.Controller.Entities.TV if (IndexNumber.HasValue && series != null) { - return series.GetEpisodes(user, IndexNumber.Value, includeMissingEpisodes, includeVirtualUnairedEpisodes); + return series.GetEpisodes(user, this, includeMissingEpisodes, includeVirtualUnairedEpisodes); } var episodes = GetRecursiveChildren(user) diff --git a/MediaBrowser.Controller/Entities/TV/Series.cs b/MediaBrowser.Controller/Entities/TV/Series.cs index 17fc0c0d2..6c499f618 100644 --- a/MediaBrowser.Controller/Entities/TV/Series.cs +++ b/MediaBrowser.Controller/Entities/TV/Series.cs @@ -338,11 +338,11 @@ namespace MediaBrowser.Controller.Entities.TV progress.Report(100); } - public IEnumerable GetEpisodes(User user, int seasonNumber) + public IEnumerable GetEpisodes(User user, Season season) { var config = user.Configuration; - return GetEpisodes(user, seasonNumber, config.DisplayMissingEpisodes, config.DisplayUnairedEpisodes); + return GetEpisodes(user, season, config.DisplayMissingEpisodes, config.DisplayUnairedEpisodes); } private bool EnablePooling() @@ -350,7 +350,7 @@ namespace MediaBrowser.Controller.Entities.TV return false; } - public IEnumerable GetEpisodes(User user, int seasonNumber, bool includeMissingEpisodes, bool includeVirtualUnairedEpisodes) + public IEnumerable GetEpisodes(User user, Season parentSeason, bool includeMissingEpisodes, bool includeVirtualUnairedEpisodes) { IEnumerable episodes; @@ -388,7 +388,7 @@ namespace MediaBrowser.Controller.Entities.TV }).Cast(); } - episodes = FilterEpisodesBySeason(episodes, seasonNumber, DisplaySpecialsWithSeasons); + episodes = FilterEpisodesBySeason(episodes, parentSeason, DisplaySpecialsWithSeasons); if (!includeMissingEpisodes) { @@ -399,7 +399,7 @@ namespace MediaBrowser.Controller.Entities.TV episodes = episodes.Where(i => !i.IsVirtualUnaired); } - var sortBy = seasonNumber == 0 ? ItemSortBy.SortName : ItemSortBy.AiredEpisodeOrder; + var sortBy = (parentSeason.IndexNumber ?? -1) == 0 ? ItemSortBy.SortName : ItemSortBy.AiredEpisodeOrder; return LibraryManager.Sort(episodes, user, new[] { sortBy }, SortOrder.Ascending) .Cast(); @@ -408,10 +408,6 @@ namespace MediaBrowser.Controller.Entities.TV /// /// Filters the episodes by season. /// - /// The episodes. - /// The season number. - /// if set to true [include specials]. - /// IEnumerable{Episode}. public static IEnumerable FilterEpisodesBySeason(IEnumerable episodes, int seasonNumber, bool includeSpecials) { if (!includeSpecials || seasonNumber < 1) @@ -434,6 +430,46 @@ namespace MediaBrowser.Controller.Entities.TV }); } + /// + /// Filters the episodes by season. + /// + public static IEnumerable FilterEpisodesBySeason(IEnumerable episodes, Season parentSeason, bool includeSpecials) + { + var seasonNumber = parentSeason.IndexNumber; + if (!includeSpecials || (seasonNumber.HasValue && seasonNumber.Value == 0)) + { + var seasonPresentationKey = parentSeason.PresentationUniqueKey; + + return episodes.Where(i => + { + if ((i.ParentIndexNumber ?? -1) == seasonNumber) + { + return true; + } + + var season = i.Season; + return season != null && string.Equals(season.PresentationUniqueKey, seasonPresentationKey, StringComparison.OrdinalIgnoreCase); + }); + } + else + { + var seasonPresentationKey = parentSeason.PresentationUniqueKey; + + return episodes.Where(episode => + { + var currentSeasonNumber = episode.AiredSeasonNumber; + + if (currentSeasonNumber.HasValue && seasonNumber.HasValue && currentSeasonNumber.Value == seasonNumber.Value) + { + return true; + } + + var season = episode.Season; + return season != null && string.Equals(season.PresentationUniqueKey, seasonPresentationKey, StringComparison.OrdinalIgnoreCase); + }); + } + } + protected override bool GetBlockUnratedValue(UserPolicy config) { return config.BlockUnratedItems.Contains(UnratedItem.Series); From 6bb6e0ff849e09fa39281adf6001599c0a73f979 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Tue, 24 May 2016 20:22:41 -0400 Subject: [PATCH 2/5] update logging --- .../Persistence/SqliteItemRepository.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs b/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs index 9978e9781..ec10fdaf6 100644 --- a/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs +++ b/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs @@ -1670,7 +1670,13 @@ namespace MediaBrowser.Server.Implementations.Persistence { var elapsed = (DateTime.UtcNow - startDate).TotalMilliseconds; - if (elapsed >= 400) + var slowThreshold = 1000; + +#if DEBUG + slowThreshold = 200; +#endif + + if (elapsed >= slowThreshold) { Logger.Debug("{2} query time (slow): {0}ms. Query: {1}", Convert.ToInt32(elapsed), From 77dc47df0c2b7e3f81ebd2c48c4cf84afb518612 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Tue, 24 May 2016 20:42:12 -0400 Subject: [PATCH 3/5] deprecate provider options --- MediaBrowser.Controller/Entities/TV/Series.cs | 17 +- .../MediaBrowser.Model.Portable.csproj | 6 - .../MediaBrowser.Model.net35.csproj | 6 - .../Configuration/FanartOptions.cs | 5 - .../Configuration/TheMovieDbOptions.cs | 12 - .../Configuration/TvdbOptions.cs | 12 - MediaBrowser.Model/MediaBrowser.Model.csproj | 2 - .../Folders/DefaultImageProvider.cs | 165 ------------ .../MediaBrowser.Providers.csproj | 5 - .../Movies/FanArtMovieUpdatesPostScanTask.cs | 196 -------------- .../Movies/FanartMovieImageProvider.cs | 29 +- .../Movies/MovieDbImageProvider.cs | 7 +- .../Movies/MovieDbProvider.cs | 42 --- .../Movies/MovieDbTrailerProvider.cs | 5 - .../Movies/MovieUpdatesPrescanTask.cs | 249 ------------------ .../Music/FanArtAlbumProvider.cs | 31 +-- .../Music/FanArtArtistProvider.cs | 25 +- .../Music/FanArtUpdatesPostScanTask.cs | 203 -------------- .../Music/MovieDbMusicVideoProvider.cs | 5 - .../TV/FanArt/FanArtSeasonProvider.cs | 33 +-- .../TV/FanArt/FanArtTvUpdatesPostScanTask.cs | 192 -------------- .../TV/FanArt/FanartSeriesProvider.cs | 25 +- .../TheMovieDb/MovieDbSeriesImageProvider.cs | 7 +- .../TV/TheMovieDb/MovieDbSeriesProvider.cs | 22 -- .../TV/TheTVDB/TvdbEpisodeImageProvider.cs | 28 +- .../TV/TheTVDB/TvdbEpisodeProvider.cs | 23 +- .../TV/TheTVDB/TvdbSeasonImageProvider.cs | 25 +- .../TV/TheTVDB/TvdbSeriesImageProvider.cs | 22 +- .../TV/TheTVDB/TvdbSeriesProvider.cs | 28 +- 29 files changed, 27 insertions(+), 1400 deletions(-) delete mode 100644 MediaBrowser.Model/Configuration/TheMovieDbOptions.cs delete mode 100644 MediaBrowser.Model/Configuration/TvdbOptions.cs delete mode 100644 MediaBrowser.Providers/Folders/DefaultImageProvider.cs delete mode 100644 MediaBrowser.Providers/Movies/FanArtMovieUpdatesPostScanTask.cs delete mode 100644 MediaBrowser.Providers/Movies/MovieUpdatesPrescanTask.cs delete mode 100644 MediaBrowser.Providers/Music/FanArtUpdatesPostScanTask.cs delete mode 100644 MediaBrowser.Providers/TV/FanArt/FanArtTvUpdatesPostScanTask.cs diff --git a/MediaBrowser.Controller/Entities/TV/Series.cs b/MediaBrowser.Controller/Entities/TV/Series.cs index 6c499f618..e79c465a1 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 ba4d1b59e..f759ffeae 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 f5d538cc4..05bbeb50e 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 e992abe5d..6924b25d7 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 9a73e3476..000000000 --- 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 034af609c..000000000 --- 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 7c469b9fb..522b7d38d 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 08b4f6461..000000000 --- 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 f07478f98..bbfa20738 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 5262f8e3b..000000000 --- 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 775e6dfb9..18f177932 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 5958c3a0a..f9e9bc947 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 c588a9a69..6a2e72743 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 5fb3ea369..1d8691ab8 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 70c155ad5..000000000 --- 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 5b3bd87db..b47e8df5a 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 37b51da5a..9b18ac5e9 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 3b829af9e..000000000 --- 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 d031b3d6b..88689dd5a 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 673663d7f..b1930d8f0 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 37e76531b..000000000 --- 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 3c831dbbc..5662082db 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 65ac12adf..06481f8f2 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 7d0f49955..4a20418bb 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 7a0b2c90c..881513286 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 509b22ee6..7005ba8f5 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 52d12e501..71587db97 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 d1cdc717e..c8efbfb14 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 ee1505b46..15b0c97ac 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) - } - }; - } - } } From e2c4c0f1deb4096c882c3c016f8b4359963a5bbb Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Tue, 24 May 2016 22:06:11 -0400 Subject: [PATCH 4/5] hls subtitle fixes --- MediaBrowser.Api/Subtitles/SubtitleService.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/MediaBrowser.Api/Subtitles/SubtitleService.cs b/MediaBrowser.Api/Subtitles/SubtitleService.cs index c3f31e75a..c2183ad7b 100644 --- a/MediaBrowser.Api/Subtitles/SubtitleService.cs +++ b/MediaBrowser.Api/Subtitles/SubtitleService.cs @@ -159,6 +159,7 @@ namespace MediaBrowser.Api.Subtitles builder.AppendLine("#EXT-X-TARGETDURATION:" + request.SegmentLength.ToString(CultureInfo.InvariantCulture)); builder.AppendLine("#EXT-X-VERSION:3"); builder.AppendLine("#EXT-X-MEDIA-SEQUENCE:0"); + builder.AppendLine("#EXT-X-PLAYLIST-TYPE:VOD"); long positionTicks = 0; var segmentLengthTicks = TimeSpan.FromSeconds(request.SegmentLength).Ticks; @@ -170,7 +171,7 @@ namespace MediaBrowser.Api.Subtitles var remaining = runtime - positionTicks; var lengthTicks = Math.Min(remaining, segmentLengthTicks); - builder.AppendLine("#EXTINF:" + TimeSpan.FromTicks(lengthTicks).TotalSeconds.ToString(CultureInfo.InvariantCulture)); + builder.AppendLine("#EXTINF:" + TimeSpan.FromTicks(lengthTicks).TotalSeconds.ToString(CultureInfo.InvariantCulture) + ","); var endPositionTicks = Math.Min(runtime, positionTicks + segmentLengthTicks); From cc19c762b419fe427abb8d03a2625e2be796e443 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Tue, 24 May 2016 22:06:56 -0400 Subject: [PATCH 5/5] update refresh --- MediaBrowser.Controller/Entities/BaseItem.cs | 4 +--- MediaBrowser.Controller/Entities/Folder.cs | 8 +++----- MediaBrowser.Providers/Manager/MetadataService.cs | 6 ------ .../Devices/CameraUploadsFolder.cs | 1 + 4 files changed, 5 insertions(+), 14 deletions(-) diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs index 61060766f..1a9bd618d 100644 --- a/MediaBrowser.Controller/Entities/BaseItem.cs +++ b/MediaBrowser.Controller/Entities/BaseItem.cs @@ -1031,9 +1031,7 @@ namespace MediaBrowser.Controller.Entities } : options; - var result = await ProviderManager.RefreshSingleItem(this, refreshOptions, cancellationToken).ConfigureAwait(false); - - return result; + return await ProviderManager.RefreshSingleItem(this, refreshOptions, cancellationToken).ConfigureAwait(false); } [IgnoreDataMember] diff --git a/MediaBrowser.Controller/Entities/Folder.cs b/MediaBrowser.Controller/Entities/Folder.cs index ac49dc3b2..cbbd0ad68 100644 --- a/MediaBrowser.Controller/Entities/Folder.cs +++ b/MediaBrowser.Controller/Entities/Folder.cs @@ -461,17 +461,15 @@ namespace MediaBrowser.Controller.Entities foreach (var item in itemsRemoved) { - if (item.LocationType == LocationType.Virtual || - item.LocationType == LocationType.Remote) + var itemLocationType = item.LocationType; + if (itemLocationType == LocationType.Virtual || + itemLocationType == LocationType.Remote) { - // Don't remove these because there's no way to accurately validate them. - validChildren.Add(item); } else if (!string.IsNullOrEmpty(item.Path) && IsPathOffline(item.Path)) { await UpdateIsOffline(item, true).ConfigureAwait(false); - validChildren.Add(item); } else { diff --git a/MediaBrowser.Providers/Manager/MetadataService.cs b/MediaBrowser.Providers/Manager/MetadataService.cs index 0c2954424..b84d1b0ff 100644 --- a/MediaBrowser.Providers/Manager/MetadataService.cs +++ b/MediaBrowser.Providers/Manager/MetadataService.cs @@ -422,12 +422,6 @@ namespace MediaBrowser.Providers.Manager providers = providers .Where(i => { - var hasChangeMonitor = i as IHasChangeMonitor; - if (hasChangeMonitor != null) - { - return HasChanged(item, hasChangeMonitor, dateLastImageRefresh, options.DirectoryService); - } - var hasFileChangeMonitor = i as IHasItemChangeMonitor; if (hasFileChangeMonitor != null) { diff --git a/MediaBrowser.Server.Implementations/Devices/CameraUploadsFolder.cs b/MediaBrowser.Server.Implementations/Devices/CameraUploadsFolder.cs index 947933561..3dfc04c26 100644 --- a/MediaBrowser.Server.Implementations/Devices/CameraUploadsFolder.cs +++ b/MediaBrowser.Server.Implementations/Devices/CameraUploadsFolder.cs @@ -28,6 +28,7 @@ namespace MediaBrowser.Server.Implementations.Devices return base.IsVisible(user) && HasChildren(); } + [IgnoreDataMember] public override string CollectionType { get { return Model.Entities.CollectionType.Photos; }