From e7ecd418c43b966bac3c34d09e6f97c1176a749c Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sat, 21 Oct 2017 12:39:52 -0400 Subject: [PATCH 1/2] update home video library support --- .../Devices/CameraUploadsFolder.cs | 2 +- .../Emby.Server.Implementations.csproj | 2 +- .../Images/BaseDynamicImageProvider.cs | 32 +++--- .../Library/Resolvers/Movies/MovieResolver.cs | 54 ++++++---- .../Library/Resolvers/PhotoAlbumResolver.cs | 46 ++++++-- .../Library/Resolvers/PhotoResolver.cs | 33 ++++-- .../Localization/Core/ru.json | 6 +- .../Localization/LocalizationManager.cs | 18 +++- .../Photos/PhotoAlbumImageProvider.cs | 34 ------ .../CollectionFolderImageProvider.cs | 16 --- .../UserViews/DynamicImageProvider.cs | 17 --- .../UserViews/FolderImageProvider.cs | 100 ++++++++++++++++++ .../MediaBrowser.Providers.csproj | 1 - .../Music/AlbumImageFromSongProvider.cs | 46 -------- 14 files changed, 234 insertions(+), 173 deletions(-) delete mode 100644 Emby.Server.Implementations/Photos/PhotoAlbumImageProvider.cs create mode 100644 Emby.Server.Implementations/UserViews/FolderImageProvider.cs delete mode 100644 MediaBrowser.Providers/Music/AlbumImageFromSongProvider.cs diff --git a/Emby.Server.Implementations/Devices/CameraUploadsFolder.cs b/Emby.Server.Implementations/Devices/CameraUploadsFolder.cs index 55063872c..5c205dd19 100644 --- a/Emby.Server.Implementations/Devices/CameraUploadsFolder.cs +++ b/Emby.Server.Implementations/Devices/CameraUploadsFolder.cs @@ -28,7 +28,7 @@ namespace Emby.Server.Implementations.Devices [IgnoreDataMember] public override string CollectionType { - get { return MediaBrowser.Model.Entities.CollectionType.Photos; } + get { return MediaBrowser.Model.Entities.CollectionType.HomeVideos; } } [IgnoreDataMember] diff --git a/Emby.Server.Implementations/Emby.Server.Implementations.csproj b/Emby.Server.Implementations/Emby.Server.Implementations.csproj index 083a14788..1ecbabf2f 100644 --- a/Emby.Server.Implementations/Emby.Server.Implementations.csproj +++ b/Emby.Server.Implementations/Emby.Server.Implementations.csproj @@ -435,7 +435,6 @@ - @@ -573,6 +572,7 @@ + diff --git a/Emby.Server.Implementations/Images/BaseDynamicImageProvider.cs b/Emby.Server.Implementations/Images/BaseDynamicImageProvider.cs index 3f9ea79c6..5cd7e4262 100644 --- a/Emby.Server.Implementations/Images/BaseDynamicImageProvider.cs +++ b/Emby.Server.Implementations/Images/BaseDynamicImageProvider.cs @@ -42,23 +42,14 @@ namespace Emby.Server.Implementations.Images return true; } - public virtual IEnumerable GetSupportedImages(IHasMetadata item) + public virtual ImageType[] GetSupportedImages(IHasMetadata item) { - return new List + return new ImageType[] { - ImageType.Primary, - ImageType.Thumb + ImageType.Primary }; } - private IEnumerable GetEnabledImages(IHasMetadata item) - { - //var options = ProviderManager.GetMetadataOptions(item); - - return GetSupportedImages(item); - //return GetSupportedImages(item).Where(i => IsEnabled(options, i, item)).ToList(); - } - public async Task FetchAsync(T item, MetadataRefreshOptions options, CancellationToken cancellationToken) { if (!Supports(item)) @@ -67,7 +58,7 @@ namespace Emby.Server.Implementations.Images } var updateType = ItemUpdateType.None; - var supportedImages = GetEnabledImages(item).ToList(); + var supportedImages = GetSupportedImages(item); if (supportedImages.Contains(ImageType.Primary)) { @@ -253,7 +244,7 @@ namespace Emby.Server.Implementations.Images return false; } - var supportedImages = GetEnabledImages(item).ToList(); + var supportedImages = GetSupportedImages(item); if (supportedImages.Contains(ImageType.Primary) && HasChanged(item, ImageType.Primary)) { @@ -283,8 +274,7 @@ namespace Emby.Server.Implementations.Images return false; } - var age = DateTime.UtcNow - image.DateModified; - if (age.TotalDays <= MaxImageAgeDays) + if (!HasChangedByDate(item, image)) { return false; } @@ -293,6 +283,16 @@ namespace Emby.Server.Implementations.Images return true; } + protected virtual bool HasChangedByDate(IHasMetadata item, ItemImageInfo image) + { + var age = DateTime.UtcNow - image.DateModified; + if (age.TotalDays <= MaxImageAgeDays) + { + return false; + } + return true; + } + protected List GetFinalItems(IEnumerable items) { return GetFinalItems(items, 4); diff --git a/Emby.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs b/Emby.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs index fc5cab0a0..94cafa3e2 100644 --- a/Emby.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs +++ b/Emby.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs @@ -11,7 +11,7 @@ using System; using System.Collections.Generic; using System.IO; using System.Linq; - +using MediaBrowser.Controller.Drawing; using MediaBrowser.Controller.IO; using MediaBrowser.Model.IO; using MediaBrowser.Model.Logging; @@ -216,12 +216,12 @@ namespace Emby.Server.Implementations.Library.Resolvers.Movies if (string.Equals(collectionType, CollectionType.MusicVideos, StringComparison.OrdinalIgnoreCase)) { - return FindMovie(args.Path, args.Parent, files, args.DirectoryService, collectionType, true, false); + return FindMovie(args, args.Path, args.Parent, files, args.DirectoryService, collectionType, false); } if (string.Equals(collectionType, CollectionType.HomeVideos, StringComparison.OrdinalIgnoreCase)) { - return FindMovie