update home video library support

This commit is contained in:
Luke Pulverenti 2017-10-21 12:39:52 -04:00
parent 0cf4f01dc7
commit e7ecd418c4
14 changed files with 234 additions and 173 deletions

View File

@ -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]

View File

@ -435,7 +435,6 @@
<Compile Include="Data\BaseSqliteRepository.cs" />
<Compile Include="Data\CleanDatabaseScheduledTask.cs" />
<Compile Include="Data\SqliteExtensions.cs" />
<Compile Include="Photos\PhotoAlbumImageProvider.cs" />
<Compile Include="Playlists\ManualPlaylistsFolder.cs" />
<Compile Include="Playlists\PlaylistImageProvider.cs" />
<Compile Include="Playlists\PlaylistManager.cs" />
@ -573,6 +572,7 @@
<Compile Include="Updates\InstallationManager.cs" />
<Compile Include="UserViews\CollectionFolderImageProvider.cs" />
<Compile Include="UserViews\DynamicImageProvider.cs" />
<Compile Include="UserViews\FolderImageProvider.cs" />
<Compile Include="Xml\XmlReaderSettingsFactory.cs" />
</ItemGroup>
<ItemGroup>

View File

@ -42,23 +42,14 @@ namespace Emby.Server.Implementations.Images
return true;
}
public virtual IEnumerable<ImageType> GetSupportedImages(IHasMetadata item)
public virtual ImageType[] GetSupportedImages(IHasMetadata item)
{
return new List<ImageType>
return new ImageType[]
{
ImageType.Primary,
ImageType.Thumb
ImageType.Primary
};
}
private IEnumerable<ImageType> GetEnabledImages(IHasMetadata item)
{
//var options = ProviderManager.GetMetadataOptions(item);
return GetSupportedImages(item);
//return GetSupportedImages(item).Where(i => IsEnabled(options, i, item)).ToList();
}
public async Task<ItemUpdateType> 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<BaseItem> GetFinalItems(IEnumerable<BaseItem> items)
{
return GetFinalItems(items, 4);

View File

@ -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<MusicVideo>(args.Path, args.Parent, files, args.DirectoryService, collectionType, true, false);
return FindMovie<MusicVideo>(args, args.Path, args.Parent, files, args.DirectoryService, collectionType, false);
}
if (string.Equals(collectionType, CollectionType.HomeVideos, StringComparison.OrdinalIgnoreCase))
{
return FindMovie<Video>(args.Path, args.Parent, files, args.DirectoryService, collectionType, false, false);
return FindMovie<Video>(args, args.Path, args.Parent, files, args.DirectoryService, collectionType, false);
}
if (string.IsNullOrEmpty(collectionType))
@ -239,13 +239,13 @@ namespace Emby.Server.Implementations.Library.Resolvers.Movies
}
{
return FindMovie<Movie>(args.Path, args.Parent, files, args.DirectoryService, collectionType, true, true);
return FindMovie<Movie>(args, args.Path, args.Parent, files, args.DirectoryService, collectionType, true);
}
}
if (string.Equals(collectionType, CollectionType.Movies, StringComparison.OrdinalIgnoreCase))
{
return FindMovie<Movie>(args.Path, args.Parent, files, args.DirectoryService, collectionType, true, true);
return FindMovie<Movie>(args, args.Path, args.Parent, files, args.DirectoryService, collectionType, true);
}
return null;
@ -361,11 +361,15 @@ namespace Emby.Server.Implementations.Library.Resolvers.Movies
/// </summary>
/// <typeparam name="T"></typeparam>
/// <returns>Movie.</returns>
private T FindMovie<T>(string path, Folder parent, List<FileSystemMetadata> fileSystemEntries, IDirectoryService directoryService, string collectionType, bool allowFilesAsFolders, bool parseName)
private T FindMovie<T>(ItemResolveArgs args, string path, Folder parent, List<FileSystemMetadata> fileSystemEntries, IDirectoryService directoryService, string collectionType, bool parseName)
where T : Video, new()
{
var multiDiscFolders = new List<FileSystemMetadata>();
var libraryOptions = args.GetLibraryOptions();
var supportPhotos = string.Equals(collectionType, CollectionType.HomeVideos, StringComparison.OrdinalIgnoreCase) && libraryOptions.EnablePhotos;
var photos = new List<FileSystemMetadata>();
// Search for a folder rip
foreach (var child in fileSystemEntries)
{
@ -406,10 +410,12 @@ namespace Emby.Server.Implementations.Library.Resolvers.Movies
Set3DFormat(movie);
return movie;
}
else if (supportPhotos && !child.IsHidden && PhotoResolver.IsImageFile(child.FullName, _imageProcessor))
{
photos.Add(child);
}
}
if (allowFilesAsFolders)
{
// TODO: Allow GetMultiDiscMovie in here
var supportsMultiVersion = !string.Equals(collectionType, CollectionType.HomeVideos) &&
!string.Equals(collectionType, CollectionType.Photos) &&
@ -419,18 +425,23 @@ namespace Emby.Server.Implementations.Library.Resolvers.Movies
new MultiItemResolverResult();
if (result.Items.Count == 1)
{
var videoPath = result.Items[0].Path;
var hasPhotos = photos.Any(i => !PhotoResolver.IsOwnedByResolvedMedia(LibraryManager, libraryOptions, videoPath, i.Name));
if (!hasPhotos)
{
var movie = (T)result.Items[0];
movie.IsInMixedFolder = false;
movie.Name = Path.GetFileName(movie.ContainingFolderPath);
return movie;
}
}
if (result.Items.Count == 0 && multiDiscFolders.Count > 0)
{
return GetMultiDiscMovie<T>(multiDiscFolders, directoryService);
}
}
return null;
}
@ -544,8 +555,11 @@ namespace Emby.Server.Implementations.Library.Resolvers.Movies
return !validCollectionTypes.Contains(collectionType, StringComparer.OrdinalIgnoreCase);
}
public MovieResolver(ILibraryManager libraryManager, IFileSystem fileSystem) : base(libraryManager, fileSystem)
private IImageProcessor _imageProcessor;
public MovieResolver(ILibraryManager libraryManager, IFileSystem fileSystem, IImageProcessor imageProcessor) : base(libraryManager, fileSystem)
{
_imageProcessor = imageProcessor;
}
}
}

View File

@ -12,9 +12,12 @@ namespace Emby.Server.Implementations.Library.Resolvers
public class PhotoAlbumResolver : FolderResolver<PhotoAlbum>
{
private readonly IImageProcessor _imageProcessor;
public PhotoAlbumResolver(IImageProcessor imageProcessor)
private ILibraryManager _libraryManager;
public PhotoAlbumResolver(IImageProcessor imageProcessor, ILibraryManager libraryManager)
{
_imageProcessor = imageProcessor;
_libraryManager = libraryManager;
}
/// <summary>
@ -25,7 +28,10 @@ namespace Emby.Server.Implementations.Library.Resolvers
protected override PhotoAlbum Resolve(ItemResolveArgs args)
{
// Must be an image file within a photo collection
if (args.IsDirectory && string.Equals(args.GetCollectionType(), CollectionType.Photos, StringComparison.OrdinalIgnoreCase))
if (args.IsDirectory)
{
if (string.Equals(args.GetCollectionType(), CollectionType.HomeVideos, StringComparison.OrdinalIgnoreCase) ||
string.Equals(args.GetCollectionType(), CollectionType.Photos, StringComparison.OrdinalIgnoreCase))
{
if (HasPhotos(args))
{
@ -35,13 +41,39 @@ namespace Emby.Server.Implementations.Library.Resolvers
};
}
}
}
return null;
}
private bool HasPhotos(ItemResolveArgs args)
{
return args.FileSystemChildren.Any(i => (!i.IsDirectory) && PhotoResolver.IsImageFile(i.FullName, _imageProcessor));
var files = args.FileSystemChildren;
foreach (var file in files)
{
if (!file.IsDirectory && PhotoResolver.IsImageFile(file.FullName, _imageProcessor))
{
var libraryOptions = args.GetLibraryOptions();
var filename = file.Name;
var ownedByMedia = false;
foreach (var siblingFile in files)
{
if (PhotoResolver.IsOwnedByMedia(_libraryManager, libraryOptions, siblingFile.FullName, filename))
{
ownedByMedia = true;
break;
}
}
if (!ownedByMedia)
{
return true;
}
}
}
return false;
}
public override ResolverPriority Priority

View File

@ -35,7 +35,6 @@ namespace Emby.Server.Implementations.Library.Resolvers
// Must be an image file within a photo collection
var collectionType = args.GetCollectionType();
if (string.Equals(collectionType, CollectionType.Photos, StringComparison.OrdinalIgnoreCase) ||
(string.Equals(collectionType, CollectionType.HomeVideos, StringComparison.OrdinalIgnoreCase) && args.GetLibraryOptions().EnablePhotos))
{
@ -44,10 +43,16 @@ namespace Emby.Server.Implementations.Library.Resolvers
var filename = Path.GetFileNameWithoutExtension(args.Path);
// Make sure the image doesn't belong to a video file
if (_fileSystem.GetFilePaths(_fileSystem.GetDirectoryName(args.Path)).Any(i => IsOwnedByMedia(args.GetLibraryOptions(), i, filename)))
var files = args.DirectoryService.GetFiles(_fileSystem.GetDirectoryName(args.Path));
var libraryOptions = args.GetLibraryOptions();
foreach (var file in files)
{
if (IsOwnedByMedia(_libraryManager, libraryOptions, file.FullName, filename))
{
return null;
}
}
return new Photo
{
@ -60,15 +65,22 @@ namespace Emby.Server.Implementations.Library.Resolvers
return null;
}
private bool IsOwnedByMedia(LibraryOptions libraryOptions, string file, string imageFilename)
internal static bool IsOwnedByMedia(ILibraryManager libraryManager, LibraryOptions libraryOptions, string file, string imageFilename)
{
if (_libraryManager.IsVideoFile(file, libraryOptions))
if (libraryManager.IsVideoFile(file, libraryOptions))
{
return IsOwnedByResolvedMedia(libraryManager, libraryOptions, file, imageFilename);
}
return false;
}
internal static bool IsOwnedByResolvedMedia(ILibraryManager libraryManager, LibraryOptions libraryOptions, string file, string imageFilename)
{
if (imageFilename.StartsWith(Path.GetFileNameWithoutExtension(file), StringComparison.OrdinalIgnoreCase))
{
return true;
}
}
return false;
}
@ -81,7 +93,8 @@ namespace Emby.Server.Implementations.Library.Resolvers
"fanart",
"backdrop",
"poster",
"cover"
"cover",
"logo"
};
internal static bool IsImageFile(string path, IImageProcessor imageProcessor)

View File

@ -53,9 +53,9 @@
"UserCreatedWithName": "\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c {0} \u0431\u044b\u043b \u0441\u043e\u0437\u0434\u0430\u043d",
"UserPasswordChangedWithName": "\u041f\u0430\u0440\u043e\u043b\u044c \u043f\u043e\u043b\u044c\u0437-\u043b\u044f {0} \u0431\u044b\u043b \u0438\u0437\u043c\u0435\u043d\u0451\u043d",
"UserDeletedWithName": "\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c {0} \u0431\u044b\u043b \u0443\u0434\u0430\u043b\u0451\u043d",
"UserConfigurationUpdatedWithName": "\u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f \u043f\u043e\u043b\u044c\u0437-\u043b\u044f {0} \u0431\u044b\u043b\u0430 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0430",
"MessageServerConfigurationUpdated": "\u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0431\u044b\u043b\u0430 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0430",
"MessageNamedServerConfigurationUpdatedWithValue": "\u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f \u0441\u0435\u0440\u0432\u0435\u0440\u0430 (\u0440\u0430\u0437\u0434\u0435\u043b {0}) \u0431\u044b\u043b\u0430 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0430",
"UserConfigurationUpdatedWithName": "\u041a\u043e\u043d\u0444\u0438\u0433-\u0438\u044f \u043f\u043e\u043b\u044c\u0437-\u043b\u044f {0} \u0431\u044b\u043b\u0430 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0430",
"MessageServerConfigurationUpdated": "\u041a\u043e\u043d\u0444\u0438\u0433-\u0438\u044f \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0431\u044b\u043b\u0430 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0430",
"MessageNamedServerConfigurationUpdatedWithValue": "\u041a\u043e\u043d\u0444\u0438\u0433-\u0438\u044f \u0441\u0435\u0440\u0432\u0435\u0440\u0430 (\u0440\u0430\u0437\u0434\u0435\u043b {0}) \u0431\u044b\u043b\u0430 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0430",
"MessageApplicationUpdated": "Emby Server \u0431\u044b\u043b \u043e\u0431\u043d\u043e\u0432\u043b\u0451\u043d",
"FailedLoginAttemptWithUserName": "{0} - \u043f\u043e\u043f\u044b\u0442\u043a\u0430 \u0432\u0445\u043e\u0434\u0430 \u043d\u0435\u0443\u0434\u0430\u0447\u043d\u0430",
"AuthenticationSucceededWithUserName": "{0} - \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f \u0443\u0441\u043f\u0435\u0448\u043d\u0430",

View File

@ -319,6 +319,10 @@ namespace Emby.Server.Implementations.Localization
{
culture = _configurationManager.Configuration.UICulture;
}
if (string.IsNullOrWhiteSpace(culture))
{
culture = DefaultCulture;
}
var dictionary = GetLocalizationDictionary(culture);
@ -332,19 +336,31 @@ namespace Emby.Server.Implementations.Localization
return phrase;
}
const string DefaultCulture = "en-US";
private readonly ConcurrentDictionary<string, Dictionary<string, string>> _dictionaries =
new ConcurrentDictionary<string, Dictionary<string, string>>(StringComparer.OrdinalIgnoreCase);
public Dictionary<string, string> GetLocalizationDictionary(string culture)
{
if (string.IsNullOrWhiteSpace(culture))
{
throw new ArgumentNullException("culture");
}
const string prefix = "Core";
var key = prefix + culture;
return _dictionaries.GetOrAdd(key, k => GetDictionary(prefix, culture, "en-US.json"));
return _dictionaries.GetOrAdd(key, k => GetDictionary(prefix, culture, DefaultCulture + ".json"));
}
private Dictionary<string, string> GetDictionary(string prefix, string culture, string baseFilename)
{
if (string.IsNullOrWhiteSpace(culture))
{
throw new ArgumentNullException("culture");
}
var dictionary = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
var namespaceName = GetType().Namespace + "." + prefix;

View File

@ -1,34 +0,0 @@
using MediaBrowser.Common.Configuration;
using MediaBrowser.Controller.Drawing;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Providers;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Emby.Server.Implementations.Images;
using MediaBrowser.Model.IO;
using MediaBrowser.Model.Entities;
namespace Emby.Server.Implementations.Photos
{
public class PhotoAlbumImageProvider : BaseDynamicImageProvider<PhotoAlbum>
{
public PhotoAlbumImageProvider(IFileSystem fileSystem, IProviderManager providerManager, IApplicationPaths applicationPaths, IImageProcessor imageProcessor)
: base(fileSystem, providerManager, applicationPaths, imageProcessor)
{
}
protected override List<BaseItem> GetItemsWithImages(IHasMetadata item)
{
var photoAlbum = (PhotoAlbum)item;
var items = GetFinalItems(photoAlbum.Children);
return items;
}
protected override string CreateImage(IHasMetadata item, List<BaseItem> itemsWithImages, string outputPathWithoutExtension, ImageType imageType, int imageIndex)
{
return CreateSingleImage(itemsWithImages, outputPathWithoutExtension, ImageType.Primary);
}
}
}

View File

@ -28,14 +28,6 @@ namespace Emby.Server.Implementations.UserViews
{
}
public override IEnumerable<ImageType> GetSupportedImages(IHasMetadata item)
{
return new List<ImageType>
{
ImageType.Primary
};
}
protected override List<BaseItem> GetItemsWithImages(IHasMetadata item)
{
var view = (CollectionFolder)item;
@ -126,14 +118,6 @@ namespace Emby.Server.Implementations.UserViews
_libraryManager = libraryManager;
}
public override IEnumerable<ImageType> GetSupportedImages(IHasMetadata item)
{
return new List<ImageType>
{
ImageType.Primary
};
}
protected override List<BaseItem> GetItemsWithImages(IHasMetadata item)
{
var view = (ManualCollectionsFolder)item;

View File

@ -31,23 +31,6 @@ namespace Emby.Server.Implementations.UserViews
_libraryManager = libraryManager;
}
public override IEnumerable<ImageType> GetSupportedImages(IHasMetadata item)
{
var view = (UserView)item;
if (IsUsingCollectionStrip(view))
{
return new List<ImageType>
{
ImageType.Primary
};
}
return new List<ImageType>
{
ImageType.Primary
};
}
protected override List<BaseItem> GetItemsWithImages(IHasMetadata item)
{
var view = (UserView)item;

View File

@ -0,0 +1,100 @@
using MediaBrowser.Common.Configuration;
using MediaBrowser.Controller.Drawing;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Providers;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Emby.Server.Implementations.Images;
using MediaBrowser.Model.IO;
using MediaBrowser.Model.Entities;
using MediaBrowser.Controller.Entities.Audio;
using MediaBrowser.Model.Dto;
using MediaBrowser.Model.Querying;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Dto;
namespace Emby.Server.Implementations.Photos
{
public abstract class BaseFolderImageProvider<T> : BaseDynamicImageProvider<T>
where T : Folder, new ()
{
protected ILibraryManager _libraryManager;
public BaseFolderImageProvider(IFileSystem fileSystem, IProviderManager providerManager, IApplicationPaths applicationPaths, IImageProcessor imageProcessor, ILibraryManager libraryManager)
: base(fileSystem, providerManager, applicationPaths, imageProcessor)
{
_libraryManager = libraryManager;
}
protected override List<BaseItem> GetItemsWithImages(IHasMetadata item)
{
return _libraryManager.GetItemList(new InternalItemsQuery
{
Parent = item as BaseItem,
GroupByPresentationUniqueKey = false,
DtoOptions = new DtoOptions(true),
ImageTypes = new ImageType[] { ImageType.Primary }
});
}
protected override string CreateImage(IHasMetadata item, List<BaseItem> itemsWithImages, string outputPathWithoutExtension, ImageType imageType, int imageIndex)
{
return CreateSingleImage(itemsWithImages, outputPathWithoutExtension, ImageType.Primary);
}
protected override bool Supports(IHasMetadata item)
{
if (item is PhotoAlbum || item is MusicAlbum)
{
return true;
}
if (item.GetType() == typeof(Folder))
{
var folder = item as Folder;
if (folder.IsTopParent)
{
return false;
}
return true;
}
return false;
}
protected override bool HasChangedByDate(IHasMetadata item, ItemImageInfo image)
{
if (item is MusicAlbum)
{
return false;
}
return base.HasChangedByDate(item, image);
}
}
public class FolderImageProvider : BaseFolderImageProvider<Folder>
{
public FolderImageProvider(IFileSystem fileSystem, IProviderManager providerManager, IApplicationPaths applicationPaths, IImageProcessor imageProcessor, ILibraryManager libraryManager)
: base(fileSystem, providerManager, applicationPaths, imageProcessor, libraryManager)
{
}
}
public class MusicAlbumImageProvider : BaseFolderImageProvider<MusicAlbum>
{
public MusicAlbumImageProvider(IFileSystem fileSystem, IProviderManager providerManager, IApplicationPaths applicationPaths, IImageProcessor imageProcessor, ILibraryManager libraryManager)
: base(fileSystem, providerManager, applicationPaths, imageProcessor, libraryManager)
{
}
}
public class PhotoAlbumImageProvider : BaseFolderImageProvider<PhotoAlbum>
{
public PhotoAlbumImageProvider(IFileSystem fileSystem, IProviderManager providerManager, IApplicationPaths applicationPaths, IImageProcessor imageProcessor, ILibraryManager libraryManager)
: base(fileSystem, providerManager, applicationPaths, imageProcessor, libraryManager)
{
}
}
}

View File

@ -85,7 +85,6 @@
<Compile Include="Movies\MovieDbImageProvider.cs" />
<Compile Include="Movies\FanartMovieImageProvider.cs" />
<Compile Include="MusicGenres\MusicGenreMetadataService.cs" />
<Compile Include="Music\AlbumImageFromSongProvider.cs" />
<Compile Include="Music\AlbumMetadataService.cs" />
<Compile Include="Music\ArtistMetadataService.cs" />
<Compile Include="Music\AudioDbAlbumImageProvider.cs" />

View File

@ -1,46 +0,0 @@
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Audio;
using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.Entities;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
namespace MediaBrowser.Providers.Music
{
public class AlbumImageFromSongProvider : IDynamicImageProvider
{
public IEnumerable<ImageType> GetSupportedImages(IHasMetadata item)
{
return new List<ImageType> { ImageType.Primary };
}
public Task<DynamicImageResponse> GetImage(IHasMetadata item, ImageType type, CancellationToken cancellationToken)
{
var album = (MusicAlbum)item;
var image = album.GetRecursiveChildren(i => !i.IsFolder)
.Select(i => i.GetImageInfo(type, 0))
.FirstOrDefault(i => i != null && i.IsLocalFile);
var imagePath = image == null ? null : image.Path;
return Task.FromResult(new DynamicImageResponse
{
Path = imagePath,
HasImage = !string.IsNullOrEmpty(imagePath)
});
}
public string Name
{
get { return "Image Extractor"; }
}
public bool Supports(IHasMetadata item)
{
return item is MusicAlbum;
}
}
}