2014-06-30 03:04:50 +00:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using MediaBrowser.Common.IO;
|
2014-02-08 20:02:35 +00:00
|
|
|
|
using MediaBrowser.Controller.Configuration;
|
|
|
|
|
using MediaBrowser.Controller.Entities;
|
|
|
|
|
using MediaBrowser.Controller.Providers;
|
|
|
|
|
|
2014-06-30 03:04:50 +00:00
|
|
|
|
namespace MediaBrowser.LocalMetadata.Images
|
2014-02-08 20:02:35 +00: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 00:39:02 +00:00
|
|
|
|
return item is CollectionFolder;
|
2014-02-08 20:02:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int Order
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
// Run after LocalImageProvider, and after CollectionFolderImageProvider
|
|
|
|
|
return 2;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-10 18:39:41 +00:00
|
|
|
|
public List<LocalImageInfo> GetImages(IHasImages item, IDirectoryService directoryService)
|
2014-02-08 20:02:35 +00:00
|
|
|
|
{
|
|
|
|
|
var name = _fileSystem.GetValidFilename(item.Name);
|
|
|
|
|
|
|
|
|
|
var path = Path.Combine(_config.ApplicationPaths.GeneralPath, name);
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
2014-07-26 17:30:15 +00:00
|
|
|
|
return new LocalImageProvider(_fileSystem).GetImages(item, path, directoryService);
|
2014-02-08 20:02:35 +00:00
|
|
|
|
}
|
|
|
|
|
catch (DirectoryNotFoundException)
|
|
|
|
|
{
|
|
|
|
|
return new List<LocalImageInfo>();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|