support xbmc -trailer suffix
This commit is contained in:
parent
5355ac4021
commit
9430b09ae9
|
@ -48,6 +48,7 @@ namespace MediaBrowser.Controller.Entities
|
||||||
public const string TrailerFolderName = "trailers";
|
public const string TrailerFolderName = "trailers";
|
||||||
public const string ThemeSongsFolderName = "theme-music";
|
public const string ThemeSongsFolderName = "theme-music";
|
||||||
public const string ThemeVideosFolderName = "backdrops";
|
public const string ThemeVideosFolderName = "backdrops";
|
||||||
|
public const string XbmcTrailerFileSuffix = "-trailer";
|
||||||
|
|
||||||
private string _name;
|
private string _name;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -707,27 +708,38 @@ namespace MediaBrowser.Controller.Entities
|
||||||
return new List<Trailer>();
|
return new List<Trailer>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var files = new List<FileSystemInfo>();
|
||||||
|
|
||||||
var folder = resolveArgs.GetFileSystemEntryByName(TrailerFolderName);
|
var folder = resolveArgs.GetFileSystemEntryByName(TrailerFolderName);
|
||||||
|
|
||||||
// Path doesn't exist. No biggie
|
// Path doesn't exist. No biggie
|
||||||
if (folder == null)
|
if (folder != null)
|
||||||
{
|
{
|
||||||
return new List<Trailer>();
|
try
|
||||||
|
{
|
||||||
|
files.AddRange(new DirectoryInfo(folder.FullName).EnumerateFiles());
|
||||||
|
}
|
||||||
|
catch (IOException ex)
|
||||||
|
{
|
||||||
|
Logger.ErrorException("Error loading trailers for {0}", ex, Name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IEnumerable<FileSystemInfo> files;
|
// Support xbmc trailers (-trailer suffix on video file names)
|
||||||
|
files.AddRange(resolveArgs.FileSystemChildren.Where(i =>
|
||||||
try
|
|
||||||
{
|
{
|
||||||
files = new DirectoryInfo(folder.FullName).EnumerateFiles();
|
if (!i.Attributes.HasFlag(FileAttributes.Directory))
|
||||||
}
|
{
|
||||||
catch (IOException ex)
|
if (System.IO.Path.GetFileNameWithoutExtension(i.Name).EndsWith(XbmcTrailerFileSuffix, StringComparison.OrdinalIgnoreCase) && !string.Equals(Path, i.FullName, StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
Logger.ErrorException("Error loading trailers for {0}", ex, Name);
|
return true;
|
||||||
return new List<Trailer>();
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return LibraryManager.ResolvePaths<Trailer>(files, null).Select(video =>
|
return false;
|
||||||
|
}));
|
||||||
|
|
||||||
|
var trailers= LibraryManager.ResolvePaths<Trailer>(files, null).Select(video =>
|
||||||
{
|
{
|
||||||
// Try to retrieve it from the db. If we don't find it, use the resolved version
|
// Try to retrieve it from the db. If we don't find it, use the resolved version
|
||||||
var dbItem = LibraryManager.RetrieveItem(video.Id) as Trailer;
|
var dbItem = LibraryManager.RetrieveItem(video.Id) as Trailer;
|
||||||
|
@ -740,6 +752,8 @@ namespace MediaBrowser.Controller.Entities
|
||||||
|
|
||||||
return video;
|
return video;
|
||||||
}).ToList();
|
}).ToList();
|
||||||
|
|
||||||
|
return trailers;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -31,6 +31,12 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers
|
||||||
{
|
{
|
||||||
return base.Resolve(args);
|
return base.Resolve(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Support xbmc local trailer convention, but only when looking for local trailers (hence the parent == null check)
|
||||||
|
if (args.Parent == null && Path.GetFileNameWithoutExtension(args.Path).EndsWith(BaseItem.XbmcTrailerFileSuffix, StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
return base.Resolve(args);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -158,7 +158,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies
|
||||||
}
|
}
|
||||||
|
|
||||||
// Don't misidentify xbmc trailers as a movie
|
// Don't misidentify xbmc trailers as a movie
|
||||||
if (child.Name.IndexOf("-trailer", StringComparison.OrdinalIgnoreCase) != -1)
|
if (child.Name.IndexOf(BaseItem.XbmcTrailerFileSuffix, StringComparison.OrdinalIgnoreCase) != -1)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user