2015-10-30 12:45:22 -04:00
|
|
|
|
using MediaBrowser.Controller.Entities;
|
2014-01-31 14:55:21 -05:00
|
|
|
|
using MediaBrowser.Controller.Entities.Audio;
|
2014-01-28 13:37:01 -05:00
|
|
|
|
using MediaBrowser.Controller.Entities.TV;
|
|
|
|
|
using MediaBrowser.Controller.Providers;
|
|
|
|
|
using MediaBrowser.Model.Entities;
|
2014-07-26 13:30:15 -04:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Globalization;
|
|
|
|
|
using System.Linq;
|
2017-05-26 02:48:54 -04:00
|
|
|
|
|
2016-10-25 15:02:04 -04:00
|
|
|
|
using MediaBrowser.Controller.IO;
|
|
|
|
|
using MediaBrowser.Model.IO;
|
2014-01-28 13:37:01 -05:00
|
|
|
|
|
2014-06-29 23:04:50 -04:00
|
|
|
|
namespace MediaBrowser.LocalMetadata.Images
|
2014-01-28 13:37:01 -05:00
|
|
|
|
{
|
2015-04-10 21:42:37 -04:00
|
|
|
|
public class LocalImageProvider : ILocalImageFileProvider, IHasOrder
|
2014-01-28 13:37:01 -05:00
|
|
|
|
{
|
2014-07-26 13:30:15 -04:00
|
|
|
|
private readonly IFileSystem _fileSystem;
|
|
|
|
|
|
|
|
|
|
public LocalImageProvider(IFileSystem fileSystem)
|
|
|
|
|
{
|
|
|
|
|
_fileSystem = fileSystem;
|
|
|
|
|
}
|
2014-10-19 23:04:45 -04:00
|
|
|
|
|
2014-01-28 13:37:01 -05:00
|
|
|
|
public string Name
|
|
|
|
|
{
|
|
|
|
|
get { return "Local Images"; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int Order
|
|
|
|
|
{
|
|
|
|
|
get { return 0; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool Supports(IHasImages item)
|
|
|
|
|
{
|
2014-02-10 15:11:46 -05:00
|
|
|
|
if (item.SupportsLocalMetadata)
|
2014-01-28 13:37:01 -05:00
|
|
|
|
{
|
|
|
|
|
// Episode has it's own provider
|
2014-07-21 21:29:06 -04:00
|
|
|
|
if (item.IsOwnedItem || item is Episode || item is Audio || item is Photo)
|
2014-01-28 13:37:01 -05:00
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2014-01-31 14:55:21 -05:00
|
|
|
|
|
2014-02-10 15:11:46 -05:00
|
|
|
|
if (item.LocationType == LocationType.Virtual)
|
2014-01-28 13:37:01 -05:00
|
|
|
|
{
|
|
|
|
|
var season = item as Season;
|
|
|
|
|
|
|
|
|
|
if (season != null)
|
|
|
|
|
{
|
|
|
|
|
var series = season.Series;
|
|
|
|
|
|
|
|
|
|
if (series != null && series.LocationType == LocationType.FileSystem)
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2015-10-03 23:38:46 -04:00
|
|
|
|
private IEnumerable<FileSystemMetadata> GetFiles(IHasImages item, bool includeDirectories, IDirectoryService directoryService)
|
2014-01-28 13:37:01 -05:00
|
|
|
|
{
|
|
|
|
|
if (item.LocationType != LocationType.FileSystem)
|
|
|
|
|
{
|
2015-10-03 23:38:46 -04:00
|
|
|
|
return new List<FileSystemMetadata>();
|
2014-01-28 13:37:01 -05:00
|
|
|
|
}
|
|
|
|
|
|
2014-02-06 00:17:00 -05:00
|
|
|
|
var path = item.ContainingFolderPath;
|
2014-01-28 13:37:01 -05:00
|
|
|
|
|
|
|
|
|
if (includeDirectories)
|
|
|
|
|
{
|
2014-02-08 17:38:02 -05:00
|
|
|
|
return directoryService.GetFileSystemEntries(path)
|
2015-11-12 15:51:39 -05:00
|
|
|
|
.Where(i => BaseItem.SupportedImageExtensions.Contains(i.Extension, StringComparer.OrdinalIgnoreCase) || i.IsDirectory)
|
2014-12-18 23:20:07 -05:00
|
|
|
|
|
|
|
|
|
.OrderBy(i => BaseItem.SupportedImageExtensionsList.IndexOf(i.Extension ?? string.Empty));
|
2014-01-28 13:37:01 -05:00
|
|
|
|
}
|
2014-02-07 17:40:03 -05:00
|
|
|
|
|
2014-02-08 17:38:02 -05:00
|
|
|
|
return directoryService.GetFiles(path)
|
2014-12-18 23:20:07 -05:00
|
|
|
|
.Where(i => BaseItem.SupportedImageExtensions.Contains(i.Extension, StringComparer.OrdinalIgnoreCase))
|
|
|
|
|
.OrderBy(i => BaseItem.SupportedImageExtensionsList.IndexOf(i.Extension ?? string.Empty));
|
2014-01-28 13:37:01 -05:00
|
|
|
|
}
|
|
|
|
|
|
2014-02-10 13:39:41 -05:00
|
|
|
|
public List<LocalImageInfo> GetImages(IHasImages item, IDirectoryService directoryService)
|
2014-01-28 13:37:01 -05:00
|
|
|
|
{
|
2014-02-08 17:38:02 -05:00
|
|
|
|
var files = GetFiles(item, true, directoryService).ToList();
|
2014-01-28 13:37:01 -05:00
|
|
|
|
|
|
|
|
|
var list = new List<LocalImageInfo>();
|
|
|
|
|
|
2014-02-08 17:38:02 -05:00
|
|
|
|
PopulateImages(item, list, files, true, directoryService);
|
2014-02-08 15:02:35 -05:00
|
|
|
|
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-29 02:26:48 -04:00
|
|
|
|
public List<LocalImageInfo> GetImages(IHasImages item, string path, bool isPathInMediaFolder, IDirectoryService directoryService)
|
2014-02-08 15:02:35 -05:00
|
|
|
|
{
|
2017-03-29 02:26:48 -04:00
|
|
|
|
return GetImages(item, new[] { path }, isPathInMediaFolder, directoryService);
|
2014-02-08 15:02:35 -05:00
|
|
|
|
}
|
|
|
|
|
|
2017-03-29 02:26:48 -04:00
|
|
|
|
public List<LocalImageInfo> GetImages(IHasImages item, IEnumerable<string> paths, bool arePathsInMediaFolders, IDirectoryService directoryService)
|
2014-02-08 15:02:35 -05:00
|
|
|
|
{
|
2017-03-29 02:26:48 -04:00
|
|
|
|
IEnumerable<FileSystemMetadata> files;
|
2014-03-16 00:23:58 -04:00
|
|
|
|
|
2017-03-29 02:26:48 -04:00
|
|
|
|
if (arePathsInMediaFolders)
|
|
|
|
|
{
|
|
|
|
|
files = paths.SelectMany(i => _fileSystem.GetFiles(i, BaseItem.SupportedImageExtensions, true, false));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
files = paths.SelectMany(directoryService.GetFiles)
|
|
|
|
|
.Where(i =>
|
|
|
|
|
{
|
|
|
|
|
var ext = i.Extension;
|
|
|
|
|
|
|
|
|
|
return !string.IsNullOrEmpty(ext) &&
|
|
|
|
|
BaseItem.SupportedImageExtensions.Contains(ext, StringComparer.OrdinalIgnoreCase);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
files = files
|
|
|
|
|
.OrderBy(i => BaseItem.SupportedImageExtensionsList.IndexOf(i.Extension ?? string.Empty));
|
2014-02-08 15:02:35 -05:00
|
|
|
|
|
|
|
|
|
var list = new List<LocalImageInfo>();
|
|
|
|
|
|
2017-03-29 02:26:48 -04:00
|
|
|
|
PopulateImages(item, list, files.ToList(), false, directoryService);
|
2014-01-28 13:37:01 -05:00
|
|
|
|
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
|
2015-10-03 23:38:46 -04:00
|
|
|
|
private void PopulateImages(IHasImages item, List<LocalImageInfo> images, List<FileSystemMetadata> files, bool supportParentSeriesFiles, IDirectoryService directoryService)
|
2014-01-28 13:37:01 -05:00
|
|
|
|
{
|
2016-01-21 21:59:07 -05:00
|
|
|
|
if (supportParentSeriesFiles)
|
|
|
|
|
{
|
|
|
|
|
var season = item as Season;
|
|
|
|
|
|
|
|
|
|
if (season != null)
|
|
|
|
|
{
|
|
|
|
|
PopulateSeasonImagesFromSeriesFolder(season, images, directoryService);
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-03-29 02:26:48 -04:00
|
|
|
|
|
2014-12-08 23:57:18 -05:00
|
|
|
|
var imagePrefix = item.FileNameWithoutExtension + "-";
|
2016-10-07 11:08:13 -04:00
|
|
|
|
var isInMixedFolder = item.DetectIsInMixedFolder();
|
2014-01-28 13:37:01 -05:00
|
|
|
|
|
2014-12-08 23:57:18 -05:00
|
|
|
|
PopulatePrimaryImages(item, images, files, imagePrefix, isInMixedFolder);
|
2014-01-28 13:37:01 -05:00
|
|
|
|
|
2014-12-08 23:57:18 -05:00
|
|
|
|
AddImage(files, images, "logo", imagePrefix, isInMixedFolder, ImageType.Logo);
|
|
|
|
|
AddImage(files, images, "clearart", imagePrefix, isInMixedFolder, ImageType.Art);
|
2016-01-21 21:29:00 -05:00
|
|
|
|
|
|
|
|
|
// For music albums, prefer cdart before disc
|
|
|
|
|
if (item is MusicAlbum)
|
|
|
|
|
{
|
|
|
|
|
AddImage(files, images, "cdart", imagePrefix, isInMixedFolder, ImageType.Disc);
|
|
|
|
|
AddImage(files, images, "disc", imagePrefix, isInMixedFolder, ImageType.Disc);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
AddImage(files, images, "disc", imagePrefix, isInMixedFolder, ImageType.Disc);
|
|
|
|
|
AddImage(files, images, "cdart", imagePrefix, isInMixedFolder, ImageType.Disc);
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-08 23:57:18 -05:00
|
|
|
|
AddImage(files, images, "box", imagePrefix, isInMixedFolder, ImageType.Box);
|
|
|
|
|
AddImage(files, images, "back", imagePrefix, isInMixedFolder, ImageType.BoxRear);
|
|
|
|
|
AddImage(files, images, "boxrear", imagePrefix, isInMixedFolder, ImageType.BoxRear);
|
|
|
|
|
AddImage(files, images, "menu", imagePrefix, isInMixedFolder, ImageType.Menu);
|
2014-01-28 13:37:01 -05:00
|
|
|
|
|
|
|
|
|
// Banner
|
2014-12-08 23:57:18 -05:00
|
|
|
|
AddImage(files, images, "banner", imagePrefix, isInMixedFolder, ImageType.Banner);
|
2014-01-28 13:37:01 -05:00
|
|
|
|
|
|
|
|
|
// Thumb
|
2014-12-08 23:57:18 -05:00
|
|
|
|
AddImage(files, images, "landscape", imagePrefix, isInMixedFolder, ImageType.Thumb);
|
2016-01-21 21:59:07 -05:00
|
|
|
|
AddImage(files, images, "thumb", imagePrefix, isInMixedFolder, ImageType.Thumb);
|
2014-12-08 23:57:18 -05:00
|
|
|
|
|
|
|
|
|
PopulateBackdrops(item, images, files, imagePrefix, isInMixedFolder, directoryService);
|
|
|
|
|
PopulateScreenshots(images, files, imagePrefix, isInMixedFolder);
|
2014-01-28 13:37:01 -05:00
|
|
|
|
}
|
|
|
|
|
|
2015-10-03 23:38:46 -04:00
|
|
|
|
private void PopulatePrimaryImages(IHasImages item, List<LocalImageInfo> images, List<FileSystemMetadata> files, string imagePrefix, bool isInMixedFolder)
|
2014-01-28 13:37:01 -05:00
|
|
|
|
{
|
2014-12-08 23:57:18 -05:00
|
|
|
|
var names = new List<string>
|
|
|
|
|
{
|
2014-12-26 12:45:06 -05:00
|
|
|
|
"cover",
|
2014-12-08 23:57:18 -05:00
|
|
|
|
"default"
|
|
|
|
|
};
|
2014-01-28 13:37:01 -05:00
|
|
|
|
|
2017-03-05 10:38:17 -05:00
|
|
|
|
if (item is MusicAlbum || item is MusicArtist || item is PhotoAlbum || item is Person)
|
2016-01-21 21:59:07 -05:00
|
|
|
|
{
|
|
|
|
|
// these prefer folder
|
|
|
|
|
names.Insert(0, "poster");
|
|
|
|
|
names.Insert(0, "folder");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
names.Insert(0, "folder");
|
|
|
|
|
names.Insert(0, "poster");
|
|
|
|
|
}
|
2017-03-29 02:26:48 -04:00
|
|
|
|
|
2014-12-08 23:57:18 -05:00
|
|
|
|
// Support plex/kodi convention
|
2014-01-28 13:37:01 -05:00
|
|
|
|
if (item is Series)
|
|
|
|
|
{
|
2014-12-08 23:57:18 -05:00
|
|
|
|
names.Add("show");
|
2014-01-28 13:37:01 -05:00
|
|
|
|
}
|
|
|
|
|
|
2014-12-08 23:57:18 -05:00
|
|
|
|
// Support plex/kodi convention
|
2014-10-01 20:28:16 -04:00
|
|
|
|
if (item is Video && !(item is Episode))
|
2014-01-28 13:37:01 -05:00
|
|
|
|
{
|
2014-12-08 23:57:18 -05:00
|
|
|
|
names.Add("movie");
|
2014-01-28 13:37:01 -05:00
|
|
|
|
}
|
|
|
|
|
|
2014-12-08 23:57:18 -05:00
|
|
|
|
var fileNameWithoutExtension = item.FileNameWithoutExtension;
|
|
|
|
|
if (!string.IsNullOrEmpty(fileNameWithoutExtension))
|
|
|
|
|
{
|
|
|
|
|
AddImage(files, images, fileNameWithoutExtension, ImageType.Primary);
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-27 00:17:04 -04:00
|
|
|
|
foreach (var name in names)
|
|
|
|
|
{
|
|
|
|
|
AddImage(files, images, imagePrefix + name, ImageType.Primary);
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-08 23:57:18 -05:00
|
|
|
|
if (!isInMixedFolder)
|
|
|
|
|
{
|
|
|
|
|
foreach (var name in names)
|
2014-01-28 13:37:01 -05:00
|
|
|
|
{
|
|
|
|
|
AddImage(files, images, name, ImageType.Primary);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-10-03 23:38:46 -04:00
|
|
|
|
private void PopulateBackdrops(IHasImages item, List<LocalImageInfo> images, List<FileSystemMetadata> files, string imagePrefix, bool isInMixedFolder, IDirectoryService directoryService)
|
2014-01-28 13:37:01 -05:00
|
|
|
|
{
|
2014-02-27 11:25:04 -05:00
|
|
|
|
if (!string.IsNullOrEmpty(item.Path))
|
2014-01-28 13:37:01 -05:00
|
|
|
|
{
|
2014-12-08 23:57:18 -05:00
|
|
|
|
var name = item.FileNameWithoutExtension;
|
2014-01-28 13:37:01 -05:00
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(name))
|
|
|
|
|
{
|
|
|
|
|
AddImage(files, images, imagePrefix + name + "-fanart", ImageType.Backdrop);
|
2014-12-08 23:57:18 -05:00
|
|
|
|
|
|
|
|
|
// Support without the prefix if it's in it's own folder
|
|
|
|
|
if (!isInMixedFolder)
|
|
|
|
|
{
|
|
|
|
|
AddImage(files, images, name + "-fanart", ImageType.Backdrop);
|
|
|
|
|
}
|
2014-01-28 13:37:01 -05:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-08 23:57:18 -05:00
|
|
|
|
PopulateBackdrops(images, files, imagePrefix, "fanart", "fanart-", isInMixedFolder, ImageType.Backdrop);
|
|
|
|
|
PopulateBackdrops(images, files, imagePrefix, "background", "background-", isInMixedFolder, ImageType.Backdrop);
|
|
|
|
|
PopulateBackdrops(images, files, imagePrefix, "art", "art-", isInMixedFolder, ImageType.Backdrop);
|
2014-01-28 13:37:01 -05:00
|
|
|
|
|
2014-03-12 15:56:12 -04:00
|
|
|
|
var extraFanartFolder = files
|
2014-02-07 17:40:03 -05:00
|
|
|
|
.FirstOrDefault(i => string.Equals(i.Name, "extrafanart", StringComparison.OrdinalIgnoreCase));
|
|
|
|
|
|
|
|
|
|
if (extraFanartFolder != null)
|
2014-01-28 13:37:01 -05:00
|
|
|
|
{
|
2014-02-08 17:38:02 -05:00
|
|
|
|
PopulateBackdropsFromExtraFanart(extraFanartFolder.FullName, images, directoryService);
|
2014-01-28 13:37:01 -05:00
|
|
|
|
}
|
2016-01-21 21:59:07 -05:00
|
|
|
|
|
|
|
|
|
PopulateBackdrops(images, files, imagePrefix, "backdrop", "backdrop", isInMixedFolder, ImageType.Backdrop);
|
2014-01-28 13:37:01 -05:00
|
|
|
|
}
|
|
|
|
|
|
2014-02-10 13:39:41 -05:00
|
|
|
|
private void PopulateBackdropsFromExtraFanart(string path, List<LocalImageInfo> images, IDirectoryService directoryService)
|
2014-01-28 13:37:01 -05:00
|
|
|
|
{
|
2017-03-29 02:26:48 -04:00
|
|
|
|
var imageFiles = _fileSystem.GetFiles(path, BaseItem.SupportedImageExtensions, false, false);
|
2014-01-28 13:37:01 -05:00
|
|
|
|
|
2017-03-29 15:16:18 -04:00
|
|
|
|
images.AddRange(imageFiles.Where(i => i.Length > 0).Select(i => new LocalImageInfo
|
2014-01-28 13:37:01 -05:00
|
|
|
|
{
|
2014-02-07 17:40:03 -05:00
|
|
|
|
FileInfo = i,
|
2014-01-28 13:37:01 -05:00
|
|
|
|
Type = ImageType.Backdrop
|
|
|
|
|
}));
|
|
|
|
|
}
|
|
|
|
|
|
2015-10-03 23:38:46 -04:00
|
|
|
|
private void PopulateScreenshots(List<LocalImageInfo> images, List<FileSystemMetadata> files, string imagePrefix, bool isInMixedFolder)
|
2014-01-28 13:37:01 -05:00
|
|
|
|
{
|
2014-12-08 23:57:18 -05:00
|
|
|
|
PopulateBackdrops(images, files, imagePrefix, "screenshot", "screenshot", isInMixedFolder, ImageType.Screenshot);
|
2014-01-28 13:37:01 -05:00
|
|
|
|
}
|
|
|
|
|
|
2015-10-03 23:38:46 -04:00
|
|
|
|
private void PopulateBackdrops(List<LocalImageInfo> images, List<FileSystemMetadata> files, string imagePrefix, string firstFileName, string subsequentFileNamePrefix, bool isInMixedFolder, ImageType type)
|
2014-01-28 13:37:01 -05:00
|
|
|
|
{
|
|
|
|
|
AddImage(files, images, imagePrefix + firstFileName, type);
|
|
|
|
|
|
|
|
|
|
var unfound = 0;
|
|
|
|
|
for (var i = 1; i <= 20; i++)
|
|
|
|
|
{
|
|
|
|
|
// Screenshot Image
|
|
|
|
|
var found = AddImage(files, images, imagePrefix + subsequentFileNamePrefix + i, type);
|
|
|
|
|
|
|
|
|
|
if (!found)
|
|
|
|
|
{
|
|
|
|
|
unfound++;
|
|
|
|
|
|
|
|
|
|
if (unfound >= 3)
|
|
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-12-08 23:57:18 -05:00
|
|
|
|
|
|
|
|
|
// Support without the prefix
|
|
|
|
|
if (!isInMixedFolder)
|
|
|
|
|
{
|
|
|
|
|
AddImage(files, images, firstFileName, type);
|
|
|
|
|
|
|
|
|
|
unfound = 0;
|
|
|
|
|
for (var i = 1; i <= 20; i++)
|
|
|
|
|
{
|
|
|
|
|
// Screenshot Image
|
|
|
|
|
var found = AddImage(files, images, subsequentFileNamePrefix + i, type);
|
|
|
|
|
|
|
|
|
|
if (!found)
|
|
|
|
|
{
|
|
|
|
|
unfound++;
|
|
|
|
|
|
|
|
|
|
if (unfound >= 3)
|
|
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-01-28 13:37:01 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private readonly CultureInfo _usCulture = new CultureInfo("en-US");
|
2014-07-26 13:30:15 -04:00
|
|
|
|
|
2014-02-10 13:39:41 -05:00
|
|
|
|
private void PopulateSeasonImagesFromSeriesFolder(Season season, List<LocalImageInfo> images, IDirectoryService directoryService)
|
2014-01-28 13:37:01 -05:00
|
|
|
|
{
|
|
|
|
|
var seasonNumber = season.IndexNumber;
|
|
|
|
|
|
|
|
|
|
var series = season.Series;
|
|
|
|
|
if (!seasonNumber.HasValue || series.LocationType != LocationType.FileSystem)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-08 17:38:02 -05:00
|
|
|
|
var seriesFiles = GetFiles(series, false, directoryService).ToList();
|
2014-01-28 13:37:01 -05:00
|
|
|
|
|
|
|
|
|
// Try using the season name
|
|
|
|
|
var prefix = season.Name.ToLower().Replace(" ", string.Empty);
|
|
|
|
|
|
|
|
|
|
var filenamePrefixes = new List<string> { prefix };
|
|
|
|
|
|
|
|
|
|
var seasonMarker = seasonNumber.Value == 0
|
|
|
|
|
? "-specials"
|
|
|
|
|
: seasonNumber.Value.ToString("00", _usCulture);
|
|
|
|
|
|
|
|
|
|
// Get this one directly from the file system since we have to go up a level
|
|
|
|
|
if (!string.Equals(prefix, seasonMarker, StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
{
|
|
|
|
|
filenamePrefixes.Add("season" + seasonMarker);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach (var filename in filenamePrefixes)
|
|
|
|
|
{
|
2014-02-07 17:40:03 -05:00
|
|
|
|
AddImage(seriesFiles, images, filename + "-poster", ImageType.Primary);
|
|
|
|
|
AddImage(seriesFiles, images, filename + "-fanart", ImageType.Backdrop);
|
|
|
|
|
AddImage(seriesFiles, images, filename + "-banner", ImageType.Banner);
|
|
|
|
|
AddImage(seriesFiles, images, filename + "-landscape", ImageType.Thumb);
|
2014-01-28 13:37:01 -05:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-10-03 23:38:46 -04:00
|
|
|
|
private bool AddImage(List<FileSystemMetadata> files, List<LocalImageInfo> images, string name, string imagePrefix, bool isInMixedFolder, ImageType type)
|
2014-12-08 23:57:18 -05:00
|
|
|
|
{
|
|
|
|
|
var added = AddImage(files, images, imagePrefix + name, type);
|
|
|
|
|
|
|
|
|
|
if (!isInMixedFolder)
|
|
|
|
|
{
|
|
|
|
|
if (AddImage(files, images, name, type))
|
|
|
|
|
{
|
|
|
|
|
added = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return added;
|
|
|
|
|
}
|
|
|
|
|
|
2015-10-03 23:38:46 -04:00
|
|
|
|
private bool AddImage(IEnumerable<FileSystemMetadata> files, List<LocalImageInfo> images, string name, ImageType type)
|
2014-01-28 13:37:01 -05:00
|
|
|
|
{
|
2015-10-03 23:38:46 -04:00
|
|
|
|
var image = GetImage(files, name);
|
2014-01-28 13:37:01 -05:00
|
|
|
|
|
|
|
|
|
if (image != null)
|
|
|
|
|
{
|
|
|
|
|
images.Add(new LocalImageInfo
|
|
|
|
|
{
|
2014-02-07 17:40:03 -05:00
|
|
|
|
FileInfo = image,
|
2014-01-28 13:37:01 -05:00
|
|
|
|
Type = type
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2015-10-03 23:38:46 -04:00
|
|
|
|
private FileSystemMetadata GetImage(IEnumerable<FileSystemMetadata> files, string name)
|
2014-01-28 13:37:01 -05:00
|
|
|
|
{
|
2017-03-29 15:16:18 -04:00
|
|
|
|
return files.FirstOrDefault(i => !i.IsDirectory && string.Equals(name, _fileSystem.GetFileNameWithoutExtension(i), StringComparison.OrdinalIgnoreCase) && i.Length > 0);
|
2014-01-28 13:37:01 -05:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|