2014-02-04 20:19:29 +00:00
|
|
|
|
using MediaBrowser.Controller.Entities;
|
|
|
|
|
using MediaBrowser.Controller.Entities.TV;
|
|
|
|
|
using MediaBrowser.Controller.Providers;
|
|
|
|
|
using MediaBrowser.Model.Entities;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.IO;
|
|
|
|
|
|
|
|
|
|
namespace MediaBrowser.Providers.TV
|
|
|
|
|
{
|
2014-02-08 20:02:35 +00:00
|
|
|
|
public class EpisodeLocalLocalImageProvider : ILocalImageFileProvider
|
2014-02-04 20:19:29 +00:00
|
|
|
|
{
|
|
|
|
|
public string Name
|
|
|
|
|
{
|
|
|
|
|
get { return "Local Images"; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool Supports(IHasImages item)
|
|
|
|
|
{
|
|
|
|
|
return item is Episode && item.LocationType == LocationType.FileSystem;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<LocalImageInfo> GetImages(IHasImages item)
|
2014-02-08 20:02:35 +00:00
|
|
|
|
{
|
|
|
|
|
var file = GetFile(item);
|
|
|
|
|
|
|
|
|
|
var list = new List<LocalImageInfo>();
|
|
|
|
|
|
|
|
|
|
if (file != null)
|
|
|
|
|
{
|
|
|
|
|
list.Add(new LocalImageInfo
|
|
|
|
|
{
|
|
|
|
|
FileInfo = file,
|
|
|
|
|
Type = ImageType.Primary
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private FileInfo GetFile(IHasImages item)
|
2014-02-04 20:19:29 +00:00
|
|
|
|
{
|
|
|
|
|
var parentPath = Path.GetDirectoryName(item.Path);
|
|
|
|
|
|
|
|
|
|
var nameWithoutExtension = Path.GetFileNameWithoutExtension(item.Path);
|
|
|
|
|
var thumbName = nameWithoutExtension + "-thumb";
|
|
|
|
|
|
2014-02-08 20:02:35 +00:00
|
|
|
|
var path = Path.Combine(parentPath, thumbName + ".jpg");
|
|
|
|
|
var fileInfo = new FileInfo(path);
|
|
|
|
|
|
|
|
|
|
if (fileInfo.Exists)
|
|
|
|
|
{
|
|
|
|
|
return fileInfo;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
path = Path.Combine(parentPath, "metadata", nameWithoutExtension + ".jpg");
|
|
|
|
|
fileInfo = new FileInfo(path);
|
|
|
|
|
|
|
|
|
|
if (fileInfo.Exists)
|
|
|
|
|
{
|
|
|
|
|
return fileInfo;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null;
|
2014-02-04 20:19:29 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|