mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-09-06 03:26:07 +02:00
support xbmc -trailer suffix
This commit is contained in:
parent
5355ac4021
commit
9430b09ae9
3 changed files with 34 additions and 14 deletions
|
@ -48,6 +48,7 @@ namespace MediaBrowser.Controller.Entities
|
|||
public const string TrailerFolderName = "trailers";
|
||||
public const string ThemeSongsFolderName = "theme-music";
|
||||
public const string ThemeVideosFolderName = "backdrops";
|
||||
public const string XbmcTrailerFileSuffix = "-trailer";
|
||||
|
||||
private string _name;
|
||||
/// <summary>
|
||||
|
@ -707,27 +708,38 @@ namespace MediaBrowser.Controller.Entities
|
|||
return new List<Trailer>();
|
||||
}
|
||||
|
||||
var files = new List<FileSystemInfo>();
|
||||
|
||||
var folder = resolveArgs.GetFileSystemEntryByName(TrailerFolderName);
|
||||
|
||||
// Path doesn't exist. No biggie
|
||||
if (folder == null)
|
||||
if (folder != null)
|
||||
{
|
||||
return new List<Trailer>();
|
||||
}
|
||||
|
||||
IEnumerable<FileSystemInfo> files;
|
||||
|
||||
try
|
||||
{
|
||||
files = new DirectoryInfo(folder.FullName).EnumerateFiles();
|
||||
files.AddRange(new DirectoryInfo(folder.FullName).EnumerateFiles());
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
Logger.ErrorException("Error loading trailers for {0}", ex, Name);
|
||||
return new List<Trailer>();
|
||||
}
|
||||
}
|
||||
|
||||
return LibraryManager.ResolvePaths<Trailer>(files, null).Select(video =>
|
||||
// Support xbmc trailers (-trailer suffix on video file names)
|
||||
files.AddRange(resolveArgs.FileSystemChildren.Where(i =>
|
||||
{
|
||||
if (!i.Attributes.HasFlag(FileAttributes.Directory))
|
||||
{
|
||||
if (System.IO.Path.GetFileNameWithoutExtension(i.Name).EndsWith(XbmcTrailerFileSuffix, StringComparison.OrdinalIgnoreCase) && !string.Equals(Path, i.FullName, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
var dbItem = LibraryManager.RetrieveItem(video.Id) as Trailer;
|
||||
|
@ -740,6 +752,8 @@ namespace MediaBrowser.Controller.Entities
|
|||
|
||||
return video;
|
||||
}).ToList();
|
||||
|
||||
return trailers;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -31,6 +31,12 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers
|
|||
{
|
||||
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;
|
||||
|
|
|
@ -158,7 +158,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies
|
|||
}
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue