jellyfin/MediaBrowser.LocalMetadata/Images/InternalMetadataFolderImageProvider.cs

79 lines
2.0 KiB
C#
Raw Normal View History

2016-03-27 14:11:27 -07:00
using MediaBrowser.Controller.Configuration;
2014-02-08 13:02:35 -07:00
using MediaBrowser.Controller.Entities;
2014-02-08 21:52:52 -07:00
using MediaBrowser.Controller.Entities.Audio;
2014-02-08 13:02:35 -07:00
using MediaBrowser.Controller.Providers;
2014-07-26 10:30:15 -07:00
using System.Collections.Generic;
using System.IO;
2017-05-25 23:48:54 -07:00
2016-10-25 12:02:04 -07:00
using MediaBrowser.Controller.IO;
using MediaBrowser.Model.IO;
2014-02-08 13:02:35 -07:00
namespace MediaBrowser.LocalMetadata.Images
2014-02-08 13:02:35 -07:00
{
public class InternalMetadataFolderImageProvider : ILocalImageFileProvider, IHasOrder
{
private readonly IServerConfigurationManager _config;
2014-07-26 10:30:15 -07:00
private readonly IFileSystem _fileSystem;
2014-02-08 13:02:35 -07:00
2014-07-26 10:30:15 -07:00
public InternalMetadataFolderImageProvider(IServerConfigurationManager config, IFileSystem fileSystem)
2014-02-08 13:02:35 -07:00
{
_config = config;
2014-07-26 10:30:15 -07:00
_fileSystem = fileSystem;
2014-02-08 13:02:35 -07:00
}
public string Name
{
get { return "Internal Images"; }
}
2017-08-07 14:06:13 -07:00
public bool Supports(IHasMetadata item)
2014-02-08 13:02:35 -07:00
{
2015-04-10 18:42:37 -07:00
if (item is Photo)
{
return false;
}
2014-02-08 13:02:35 -07:00
if (!item.IsSaveLocalMetadataEnabled())
{
return true;
}
2014-02-08 21:52:52 -07:00
// Extracted images will be saved in here
if (item is Audio)
{
return true;
}
2014-10-19 20:04:45 -07:00
if (item.SupportsLocalMetadata && !item.AlwaysScanInternalMetadataPath)
2014-02-08 13:02:35 -07:00
{
return false;
}
2015-10-30 09:45:22 -07:00
2014-02-08 13:02:35 -07:00
return true;
}
public int Order
{
get
{
// Make sure this is last so that all other locations are scanned first
return 1000;
}
}
2017-08-07 14:06:13 -07:00
public List<LocalImageInfo> GetImages(IHasMetadata item, IDirectoryService directoryService)
2014-02-08 13:02:35 -07:00
{
2014-09-28 08:27:26 -07:00
var path = item.GetInternalMetadataPath();
2014-02-08 13:02:35 -07:00
try
{
2017-03-28 23:26:48 -07:00
return new LocalImageProvider(_fileSystem).GetImages(item, path, false, directoryService);
2014-02-08 13:02:35 -07:00
}
2016-10-30 00:02:23 -07:00
catch (IOException)
2014-02-08 13:02:35 -07:00
{
return new List<LocalImageInfo>();
}
}
}
}