mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-05-27 10:58:44 +01:00
Merge branch 'master' of https://github.com/MediaBrowser/MediaBrowser
Conflicts: SharedVersion.cs
This commit is contained in:
@@ -602,118 +602,6 @@ namespace MediaBrowser.Controller.Entities
|
||||
return PlayAccess.Full;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Loads local trailers from the file system
|
||||
/// </summary>
|
||||
/// <returns>List{Video}.</returns>
|
||||
private IEnumerable<Trailer> LoadLocalTrailers(List<FileSystemInfo> fileSystemChildren, IDirectoryService directoryService)
|
||||
{
|
||||
var files = fileSystemChildren.OfType<DirectoryInfo>()
|
||||
.Where(i => string.Equals(i.Name, TrailerFolderName, StringComparison.OrdinalIgnoreCase))
|
||||
.SelectMany(i => i.EnumerateFiles("*", SearchOption.TopDirectoryOnly))
|
||||
.ToList();
|
||||
|
||||
var extraTypes = new List<ExtraType> { ExtraType.Trailer };
|
||||
var suffixes = ExtraSuffixes.Where(i => extraTypes.Contains(i.Value))
|
||||
.Select(i => i.Key)
|
||||
.ToList();
|
||||
|
||||
files.AddRange(fileSystemChildren.OfType<FileInfo>()
|
||||
.Where(i =>
|
||||
{
|
||||
var nameEithoutExtension = FileSystem.GetFileNameWithoutExtension(i);
|
||||
|
||||
if (!suffixes.Any(s => nameEithoutExtension.EndsWith(s, StringComparison.OrdinalIgnoreCase)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return !string.Equals(Path, i.FullName, StringComparison.OrdinalIgnoreCase);
|
||||
}));
|
||||
|
||||
return LibraryManager.ResolvePaths<Trailer>(files, directoryService, null).Select(video =>
|
||||
{
|
||||
// Try to retrieve it from the db. If we don't find it, use the resolved version
|
||||
var dbItem = LibraryManager.GetItemById(video.Id) as Trailer;
|
||||
|
||||
if (dbItem != null)
|
||||
{
|
||||
video = dbItem;
|
||||
}
|
||||
|
||||
if (video != null)
|
||||
{
|
||||
video.ExtraType = ExtraType.Trailer;
|
||||
}
|
||||
|
||||
return video;
|
||||
|
||||
// Sort them so that the list can be easily compared for changes
|
||||
}).OrderBy(i => i.Path).ToList();
|
||||
}
|
||||
|
||||
protected IEnumerable<Video> LoadSpecialFeatures(List<FileSystemInfo> fileSystemChildren, IDirectoryService directoryService)
|
||||
{
|
||||
var files = fileSystemChildren.OfType<DirectoryInfo>()
|
||||
.Where(i => string.Equals(i.Name, "extras", StringComparison.OrdinalIgnoreCase) || string.Equals(i.Name, "specials", StringComparison.OrdinalIgnoreCase))
|
||||
.SelectMany(i => i.EnumerateFiles("*", SearchOption.TopDirectoryOnly))
|
||||
.ToList();
|
||||
|
||||
var extraTypes = new List<ExtraType> { ExtraType.BehindTheScenes, ExtraType.DeletedScene, ExtraType.Interview, ExtraType.Sample, ExtraType.Scene, ExtraType.Clip };
|
||||
var suffixes = ExtraSuffixes.Where(i => extraTypes.Contains(i.Value))
|
||||
.Select(i => i.Key)
|
||||
.ToList();
|
||||
|
||||
files.AddRange(fileSystemChildren.OfType<FileInfo>()
|
||||
.Where(i =>
|
||||
{
|
||||
var nameEithoutExtension = FileSystem.GetFileNameWithoutExtension(i);
|
||||
|
||||
if (!suffixes.Any(s => nameEithoutExtension.EndsWith(s, StringComparison.OrdinalIgnoreCase)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return !string.Equals(Path, i.FullName, StringComparison.OrdinalIgnoreCase);
|
||||
}));
|
||||
|
||||
return LibraryManager.ResolvePaths<Video>(files, directoryService, null).Select(video =>
|
||||
{
|
||||
// Try to retrieve it from the db. If we don't find it, use the resolved version
|
||||
var dbItem = LibraryManager.GetItemById(video.Id) as Video;
|
||||
|
||||
if (dbItem != null)
|
||||
{
|
||||
video = dbItem;
|
||||
}
|
||||
|
||||
if (video != null)
|
||||
{
|
||||
SetExtraTypeFromFilename(video);
|
||||
}
|
||||
|
||||
return video;
|
||||
|
||||
// Sort them so that the list can be easily compared for changes
|
||||
}).OrderBy(i => i.Path).ToList();
|
||||
}
|
||||
|
||||
private void SetExtraTypeFromFilename(Video item)
|
||||
{
|
||||
var name = System.IO.Path.GetFileNameWithoutExtension(item.Path) ?? string.Empty;
|
||||
|
||||
foreach (var suffix in ExtraSuffixes)
|
||||
{
|
||||
if (name.EndsWith(suffix.Key, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
item.ExtraType = suffix.Value;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
item.ExtraType = ExtraType.Clip;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Loads the theme songs.
|
||||
/// </summary>
|
||||
@@ -879,7 +767,8 @@ namespace MediaBrowser.Controller.Entities
|
||||
|
||||
private async Task<bool> RefreshLocalTrailers(IHasTrailers item, MetadataRefreshOptions options, List<FileSystemInfo> fileSystemChildren, CancellationToken cancellationToken)
|
||||
{
|
||||
var newItems = LoadLocalTrailers(fileSystemChildren, options.DirectoryService).ToList();
|
||||
var newItems = LibraryManager.FindTrailers(this, fileSystemChildren, options.DirectoryService).ToList();
|
||||
|
||||
var newItemIds = newItems.Select(i => i.Id).ToList();
|
||||
|
||||
var itemsChanged = !item.LocalTrailerIds.SequenceEqual(newItemIds);
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using MediaBrowser.Common.Extensions;
|
||||
using MediaBrowser.Common.Progress;
|
||||
using MediaBrowser.Common.Progress;
|
||||
using MediaBrowser.Controller.Entities.TV;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Controller.Localization;
|
||||
|
||||
@@ -119,7 +119,7 @@ namespace MediaBrowser.Controller.Entities.Movies
|
||||
|
||||
private async Task<bool> RefreshSpecialFeatures(MetadataRefreshOptions options, List<FileSystemInfo> fileSystemChildren, CancellationToken cancellationToken)
|
||||
{
|
||||
var newItems = LoadSpecialFeatures(fileSystemChildren, options.DirectoryService).ToList();
|
||||
var newItems = LibraryManager.FindExtras(this, fileSystemChildren, options.DirectoryService).ToList();
|
||||
var newItemIds = newItems.Select(i => i.Id).ToList();
|
||||
|
||||
var itemsChanged = !SpecialFeatureIds.SequenceEqual(newItemIds);
|
||||
|
||||
Reference in New Issue
Block a user