2019-01-13 21:02:23 +01:00
|
|
|
using System.Collections.Generic;
|
2019-01-13 20:25:45 +01:00
|
|
|
using System.IO;
|
|
|
|
using MediaBrowser.Controller.Configuration;
|
2014-02-08 21:02:35 +01:00
|
|
|
using MediaBrowser.Controller.Entities;
|
2014-02-09 05:52:52 +01:00
|
|
|
using MediaBrowser.Controller.Entities.Audio;
|
2014-02-08 21:02:35 +01:00
|
|
|
using MediaBrowser.Controller.Providers;
|
2016-10-25 21:02:04 +02:00
|
|
|
using MediaBrowser.Model.IO;
|
2014-02-08 21:02:35 +01:00
|
|
|
|
2014-06-30 05:04:50 +02:00
|
|
|
namespace MediaBrowser.LocalMetadata.Images
|
2014-02-08 21:02:35 +01:00
|
|
|
{
|
|
|
|
public class InternalMetadataFolderImageProvider : ILocalImageFileProvider, IHasOrder
|
|
|
|
{
|
|
|
|
private readonly IServerConfigurationManager _config;
|
2014-07-26 19:30:15 +02:00
|
|
|
private readonly IFileSystem _fileSystem;
|
2014-02-08 21:02:35 +01:00
|
|
|
|
2014-07-26 19:30:15 +02:00
|
|
|
public InternalMetadataFolderImageProvider(IServerConfigurationManager config, IFileSystem fileSystem)
|
2014-02-08 21:02:35 +01:00
|
|
|
{
|
|
|
|
_config = config;
|
2014-07-26 19:30:15 +02:00
|
|
|
_fileSystem = fileSystem;
|
2014-02-08 21:02:35 +01:00
|
|
|
}
|
|
|
|
|
2019-01-13 21:31:14 +01:00
|
|
|
public string Name => "Internal Images";
|
2014-02-08 21:02:35 +01:00
|
|
|
|
2018-09-12 19:26:21 +02:00
|
|
|
public bool Supports(BaseItem item)
|
2014-02-08 21:02:35 +01:00
|
|
|
{
|
2015-04-11 03:42:37 +02:00
|
|
|
if (item is Photo)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-02-08 21:02:35 +01:00
|
|
|
if (!item.IsSaveLocalMetadataEnabled())
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-02-09 05:52:52 +01:00
|
|
|
// Extracted images will be saved in here
|
|
|
|
if (item is Audio)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-10-20 05:04:45 +02:00
|
|
|
if (item.SupportsLocalMetadata && !item.AlwaysScanInternalMetadataPath)
|
2014-02-08 21:02:35 +01:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2015-10-30 17:45:22 +01:00
|
|
|
|
2014-02-08 21:02:35 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-01-13 21:31:14 +01:00
|
|
|
public int Order => 1000;
|
2014-02-08 21:02:35 +01:00
|
|
|
|
2018-09-12 19:26:21 +02:00
|
|
|
public List<LocalImageInfo> GetImages(BaseItem item, IDirectoryService directoryService)
|
2014-02-08 21:02:35 +01:00
|
|
|
{
|
2014-09-28 17:27:26 +02:00
|
|
|
var path = item.GetInternalMetadataPath();
|
|
|
|
|
2014-02-08 21:02:35 +01:00
|
|
|
try
|
|
|
|
{
|
2017-03-29 08:26:48 +02:00
|
|
|
return new LocalImageProvider(_fileSystem).GetImages(item, path, false, 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>();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|