2014-01-28 18:37:01 +00:00
|
|
|
|
using MediaBrowser.Common.IO;
|
2013-11-07 15:56:35 +00:00
|
|
|
|
using MediaBrowser.Controller.Configuration;
|
|
|
|
|
using MediaBrowser.Controller.Entities;
|
|
|
|
|
using MediaBrowser.Controller.Library;
|
|
|
|
|
using MediaBrowser.Controller.Providers;
|
|
|
|
|
using MediaBrowser.Model.Entities;
|
|
|
|
|
using MediaBrowser.Model.Logging;
|
|
|
|
|
using System;
|
2014-01-28 18:37:01 +00:00
|
|
|
|
using System.Collections.Generic;
|
2013-11-07 15:56:35 +00:00
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
|
|
|
|
namespace MediaBrowser.Providers
|
|
|
|
|
{
|
|
|
|
|
public class CollectionFolderImageProvider : ImageFromMediaLocationProvider
|
|
|
|
|
{
|
|
|
|
|
public CollectionFolderImageProvider(ILogManager logManager, IServerConfigurationManager configurationManager, IFileSystem fileSystem)
|
|
|
|
|
: base(logManager, configurationManager, fileSystem)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override bool Supports(BaseItem item)
|
|
|
|
|
{
|
|
|
|
|
return item is CollectionFolder && item.LocationType == LocationType.FileSystem;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override MetadataProviderPriority Priority
|
|
|
|
|
{
|
|
|
|
|
get { return MetadataProviderPriority.Second; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override FileSystemInfo GetImage(BaseItem item, ItemResolveArgs args, string filenameWithoutExtension)
|
|
|
|
|
{
|
|
|
|
|
return item.ResolveArgs.PhysicalLocations
|
|
|
|
|
.Select(i => GetImageFromLocation(i, filenameWithoutExtension))
|
|
|
|
|
.FirstOrDefault(i => i != null);
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-10 02:36:24 +00:00
|
|
|
|
protected override Guid GetFileSystemStamp(IEnumerable<BaseItem> items)
|
2013-11-07 15:56:35 +00:00
|
|
|
|
{
|
2013-12-10 02:36:24 +00:00
|
|
|
|
var files = items.SelectMany(i => i.ResolveArgs.PhysicalLocations)
|
2013-11-07 15:56:35 +00:00
|
|
|
|
.Select(i => new DirectoryInfo(i))
|
|
|
|
|
.SelectMany(i => i.EnumerateFiles("*", SearchOption.TopDirectoryOnly))
|
|
|
|
|
.Where(i =>
|
|
|
|
|
{
|
|
|
|
|
var ext = i.Extension;
|
|
|
|
|
|
|
|
|
|
return !string.IsNullOrEmpty(ext) &&
|
|
|
|
|
BaseItem.SupportedImageExtensions.Contains(ext, StringComparer.OrdinalIgnoreCase);
|
|
|
|
|
})
|
|
|
|
|
.ToList();
|
|
|
|
|
|
|
|
|
|
return GetFileSystemStamp(files);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|