2014-06-30 05:04:50 +02:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.IO;
|
2016-10-25 21:02:04 +02:00
|
|
|
|
using MediaBrowser.Common.IO;
|
|
|
|
|
using MediaBrowser.Model.IO;
|
2014-02-08 21:02:35 +01:00
|
|
|
|
using MediaBrowser.Controller.Configuration;
|
|
|
|
|
using MediaBrowser.Controller.Entities;
|
2016-10-25 21:02:04 +02:00
|
|
|
|
using MediaBrowser.Controller.IO;
|
2014-02-08 21:02:35 +01:00
|
|
|
|
using MediaBrowser.Controller.Providers;
|
|
|
|
|
|
2014-06-30 05:04:50 +02:00
|
|
|
|
namespace MediaBrowser.LocalMetadata.Images
|
2014-02-08 21:02:35 +01:00
|
|
|
|
{
|
|
|
|
|
public class ImagesByNameImageProvider : ILocalImageFileProvider, IHasOrder
|
|
|
|
|
{
|
|
|
|
|
private readonly IFileSystem _fileSystem;
|
|
|
|
|
private readonly IServerConfigurationManager _config;
|
|
|
|
|
|
|
|
|
|
public ImagesByNameImageProvider(IFileSystem fileSystem, IServerConfigurationManager config)
|
|
|
|
|
{
|
|
|
|
|
_fileSystem = fileSystem;
|
|
|
|
|
_config = config;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string Name
|
|
|
|
|
{
|
|
|
|
|
get { return "Images By Name"; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool Supports(IHasImages item)
|
|
|
|
|
{
|
2014-06-06 02:39:02 +02:00
|
|
|
|
return item is CollectionFolder;
|
2014-02-08 21:02:35 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int Order
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
// Run after LocalImageProvider, and after CollectionFolderImageProvider
|
|
|
|
|
return 2;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-10 19:39:41 +01:00
|
|
|
|
public List<LocalImageInfo> GetImages(IHasImages item, IDirectoryService directoryService)
|
2014-02-08 21:02:35 +01:00
|
|
|
|
{
|
|
|
|
|
var name = _fileSystem.GetValidFilename(item.Name);
|
|
|
|
|
|
|
|
|
|
var path = Path.Combine(_config.ApplicationPaths.GeneralPath, name);
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
2015-10-30 17:45:22 +01:00
|
|
|
|
return new LocalImageProvider(_fileSystem).GetImages(item, path, directoryService);
|
2014-02-08 21:02:35 +01:00
|
|
|
|
}
|
2016-10-30 08:02:23 +01:00
|
|
|
|
catch (IOException)
|
2014-02-08 21:02:35 +01:00
|
|
|
|
{
|
|
|
|
|
return new List<LocalImageInfo>();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|