fixes #586 - Support extrafanart folder for backdrops
This commit is contained in:
parent
bef67412b1
commit
b5059152fe
|
@ -354,7 +354,7 @@ namespace MediaBrowser.Controller.Providers
|
||||||
}
|
}
|
||||||
|
|
||||||
private Dictionary<string, string> _fileStampExtensionsDictionary;
|
private Dictionary<string, string> _fileStampExtensionsDictionary;
|
||||||
private Dictionary<string, string> FileStampExtensionsDictionary
|
private Dictionary<string, string> FileStampExtensionsDictionary
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
|
@ -400,46 +400,50 @@ namespace MediaBrowser.Controller.Providers
|
||||||
|
|
||||||
// Record the name of each file
|
// Record the name of each file
|
||||||
// Need to sort these because accoring to msdn docs, our i/o methods are not guaranteed in any order
|
// Need to sort these because accoring to msdn docs, our i/o methods are not guaranteed in any order
|
||||||
foreach (var file in resolveArgs.FileSystemChildren
|
AddFiles(sb, resolveArgs.FileSystemChildren, extensions, numExtensions);
|
||||||
.Where(i => IncludeInFileStamp(i, extensions, numExtensions))
|
AddFiles(sb, resolveArgs.MetadataFiles, extensions, numExtensions);
|
||||||
.OrderBy(f => f.Name))
|
|
||||||
{
|
|
||||||
sb.Append(file.Name);
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var file in resolveArgs.MetadataFiles
|
|
||||||
.Where(i => IncludeInFileStamp(i, extensions, numExtensions))
|
|
||||||
.OrderBy(f => f.Name))
|
|
||||||
{
|
|
||||||
sb.Append(file.Name);
|
|
||||||
}
|
|
||||||
|
|
||||||
return sb.ToString().GetMD5();
|
return sb.ToString().GetMD5();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static readonly Dictionary<string, string> FoldersToMonitor = new[] { "extrafanart" }
|
||||||
|
.ToDictionary(i => i, StringComparer.OrdinalIgnoreCase);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Includes the in file stamp.
|
/// Adds the files.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="file">The file.</param>
|
/// <param name="sb">The sb.</param>
|
||||||
|
/// <param name="files">The files.</param>
|
||||||
/// <param name="extensions">The extensions.</param>
|
/// <param name="extensions">The extensions.</param>
|
||||||
/// <param name="numExtensions">The num extensions.</param>
|
/// <param name="numExtensions">The num extensions.</param>
|
||||||
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns>
|
private void AddFiles(StringBuilder sb, IEnumerable<FileSystemInfo> files, Dictionary<string, string> extensions, int numExtensions)
|
||||||
private bool IncludeInFileStamp(FileSystemInfo file, Dictionary<string,string> extensions, int numExtensions)
|
|
||||||
{
|
{
|
||||||
try
|
foreach (var file in files
|
||||||
|
.OrderBy(f => f.Name))
|
||||||
{
|
{
|
||||||
if ((file.Attributes & FileAttributes.Directory) == FileAttributes.Directory)
|
try
|
||||||
{
|
{
|
||||||
return false;
|
if ((file.Attributes & FileAttributes.Directory) == FileAttributes.Directory)
|
||||||
|
{
|
||||||
|
if (FoldersToMonitor.ContainsKey(file.Name))
|
||||||
|
{
|
||||||
|
sb.Append(file.Name);
|
||||||
|
|
||||||
|
var children = ((DirectoryInfo) file).EnumerateFiles("*", SearchOption.TopDirectoryOnly).ToList();
|
||||||
|
AddFiles(sb, children, extensions, numExtensions);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// It's a file
|
||||||
|
else if (numExtensions == 0 || extensions.ContainsKey(file.Extension))
|
||||||
|
{
|
||||||
|
sb.Append(file.Name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (IOException ex)
|
||||||
|
{
|
||||||
|
Logger.ErrorException("Error accessing file attributes for {0}", ex, file.FullName);
|
||||||
}
|
}
|
||||||
|
|
||||||
return numExtensions == 0 || extensions.ContainsKey(file.Extension);
|
|
||||||
}
|
|
||||||
catch (IOException ex)
|
|
||||||
{
|
|
||||||
Logger.ErrorException("Error accessing file attributes for {0}", ex, file.FullName);
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -165,7 +165,7 @@ namespace MediaBrowser.Providers
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly CultureInfo _usCulture = new CultureInfo("en-US");
|
private readonly CultureInfo _usCulture = new CultureInfo("en-US");
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Fills in image paths based on files win the folder
|
/// Fills in image paths based on files win the folder
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -192,13 +192,13 @@ namespace MediaBrowser.Providers
|
||||||
|
|
||||||
image = GetImage(item, args, string.Format("season-{0}", num));
|
image = GetImage(item, args, string.Format("season-{0}", num));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Support plex/xbmc convention
|
// Support plex/xbmc convention
|
||||||
if (image == null && (item is Movie || item is MusicVideo || item is AdultVideo))
|
if (image == null && (item is Movie || item is MusicVideo || item is AdultVideo))
|
||||||
{
|
{
|
||||||
image = GetImage(item, args, "movie");
|
image = GetImage(item, args, "movie");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Look for a file with the same name as the item
|
// Look for a file with the same name as the item
|
||||||
if (image == null)
|
if (image == null)
|
||||||
{
|
{
|
||||||
|
@ -233,7 +233,7 @@ namespace MediaBrowser.Providers
|
||||||
|
|
||||||
image = GetImage(item, args, string.Format("season-{0}-banner", num));
|
image = GetImage(item, args, string.Format("season-{0}-banner", num));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (image != null)
|
if (image != null)
|
||||||
{
|
{
|
||||||
item.SetImage(ImageType.Banner, image.FullName);
|
item.SetImage(ImageType.Banner, image.FullName);
|
||||||
|
@ -344,12 +344,48 @@ namespace MediaBrowser.Providers
|
||||||
PopulateBackdrops(item, args, backdropFiles, "background", "background-");
|
PopulateBackdrops(item, args, backdropFiles, "background", "background-");
|
||||||
PopulateBackdrops(item, args, backdropFiles, "art", "art-");
|
PopulateBackdrops(item, args, backdropFiles, "art", "art-");
|
||||||
|
|
||||||
|
PopulateBackdropsFromExtraFanart(args, backdropFiles);
|
||||||
|
|
||||||
if (backdropFiles.Count > 0)
|
if (backdropFiles.Count > 0)
|
||||||
{
|
{
|
||||||
item.BackdropImagePaths = backdropFiles;
|
item.BackdropImagePaths = backdropFiles;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Populates the backdrops from extra fanart.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="args">The args.</param>
|
||||||
|
/// <param name="backdrops">The backdrops.</param>
|
||||||
|
private void PopulateBackdropsFromExtraFanart(ItemResolveArgs args, List<string> backdrops)
|
||||||
|
{
|
||||||
|
if (!args.IsDirectory)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.ContainsFileSystemEntryByName("extrafanart"))
|
||||||
|
{
|
||||||
|
var path = Path.Combine(args.Path, "extrafanart");
|
||||||
|
|
||||||
|
var imageFiles = Directory.EnumerateFiles(path, "*", SearchOption.TopDirectoryOnly)
|
||||||
|
.Where(i =>
|
||||||
|
{
|
||||||
|
var extension = Path.GetExtension(i);
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(extension))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return BaseItem.SupportedImageExtensions.Contains(extension, StringComparer.OrdinalIgnoreCase);
|
||||||
|
})
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
backdrops.AddRange(imageFiles);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Populates the backdrops.
|
/// Populates the backdrops.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user