mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-04-22 01:54:42 +01:00
update sync objects
This commit is contained in:
@@ -3,6 +3,7 @@ using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Controller.Resolvers;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
@@ -16,6 +17,21 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
private readonly IFileSystem _fileSystem;
|
||||
private readonly ILibraryManager _libraryManager;
|
||||
|
||||
/// <summary>
|
||||
/// Any folder named in this list will be ignored - can be added to at runtime for extensibility
|
||||
/// </summary>
|
||||
public static readonly List<string> IgnoreFolders = new List<string>
|
||||
{
|
||||
"metadata",
|
||||
"ps3_update",
|
||||
"ps3_vprm",
|
||||
"extrafanart",
|
||||
"extrathumbs",
|
||||
".actors",
|
||||
".wd_tv"
|
||||
|
||||
};
|
||||
|
||||
public CoreResolutionIgnoreRule(IFileSystem fileSystem, ILibraryManager libraryManager)
|
||||
{
|
||||
_fileSystem = fileSystem;
|
||||
@@ -64,7 +80,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
if (args.IsDirectory)
|
||||
{
|
||||
// Ignore any folders in our list
|
||||
if (EntityResolutionHelper.IgnoreFolders.Contains(filename, StringComparer.OrdinalIgnoreCase))
|
||||
if (IgnoreFolders.Contains(filename, StringComparer.OrdinalIgnoreCase))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -88,15 +104,6 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
}
|
||||
else
|
||||
{
|
||||
if (args.Parent != null)
|
||||
{
|
||||
// Don't resolve these into audio files
|
||||
if (string.Equals(_fileSystem.GetFileNameWithoutExtension(filename), BaseItem.ThemeSongFilename) && _libraryManager.IsAudioFile(filename))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Ignore samples
|
||||
if (filename.IndexOf(".sample.", StringComparison.OrdinalIgnoreCase) != -1)
|
||||
{
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
using MediaBrowser.Common.IO;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
namespace MediaBrowser.Server.Implementations.Library
|
||||
{
|
||||
/// <summary>
|
||||
/// Class EntityResolutionHelper
|
||||
/// </summary>
|
||||
public static class EntityResolutionHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// Any folder named in this list will be ignored - can be added to at runtime for extensibility
|
||||
/// </summary>
|
||||
public static readonly List<string> IgnoreFolders = new List<string>
|
||||
{
|
||||
"metadata",
|
||||
"ps3_update",
|
||||
"ps3_vprm",
|
||||
"extrafanart",
|
||||
"extrathumbs",
|
||||
".actors",
|
||||
".wd_tv"
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
using System.Collections.Generic;
|
||||
using MediaBrowser.Controller.Channels;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Model.Channels;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MediaBrowser.Server.Implementations.Library
|
||||
{
|
||||
public class LocalTrailerPostScanTask : ILibraryPostScanTask
|
||||
{
|
||||
private readonly ILibraryManager _libraryManager;
|
||||
private readonly IChannelManager _channelManager;
|
||||
|
||||
public LocalTrailerPostScanTask(ILibraryManager libraryManager, IChannelManager channelManager)
|
||||
{
|
||||
_libraryManager = libraryManager;
|
||||
_channelManager = channelManager;
|
||||
}
|
||||
|
||||
public async Task Run(IProgress<double> progress, CancellationToken cancellationToken)
|
||||
{
|
||||
var items = _libraryManager.RootFolder
|
||||
.RecursiveChildren
|
||||
.OfType<IHasTrailers>()
|
||||
.ToList();
|
||||
|
||||
var channelTrailerResult = await _channelManager.GetAllMediaInternal(new AllChannelMediaQuery
|
||||
{
|
||||
ExtraTypes = new[] { ExtraType.Trailer }
|
||||
|
||||
}, CancellationToken.None);
|
||||
var channelTrailers = channelTrailerResult.Items;
|
||||
|
||||
var numComplete = 0;
|
||||
|
||||
foreach (var item in items)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
await AssignTrailers(item, channelTrailers).ConfigureAwait(false);
|
||||
|
||||
numComplete++;
|
||||
double percent = numComplete;
|
||||
percent /= items.Count;
|
||||
progress.Report(percent * 100);
|
||||
}
|
||||
|
||||
progress.Report(100);
|
||||
}
|
||||
|
||||
private async Task AssignTrailers(IHasTrailers item, BaseItem[] channelTrailers)
|
||||
{
|
||||
if (item is Game)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var imdbId = item.GetProviderId(MetadataProviders.Imdb);
|
||||
var tmdbId = item.GetProviderId(MetadataProviders.Tmdb);
|
||||
|
||||
var trailers = channelTrailers.Where(i =>
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(imdbId) &&
|
||||
string.Equals(imdbId, i.GetProviderId(MetadataProviders.Imdb), StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (!string.IsNullOrWhiteSpace(tmdbId) &&
|
||||
string.Equals(tmdbId, i.GetProviderId(MetadataProviders.Tmdb), StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
var trailerIds = trailers.Select(i => i.Id)
|
||||
.ToList();
|
||||
|
||||
if (!trailerIds.SequenceEqual(item.RemoteTrailerIds))
|
||||
{
|
||||
item.RemoteTrailerIds = trailerIds;
|
||||
|
||||
var baseItem = (BaseItem)item;
|
||||
await baseItem.UpdateToRepository(ItemUpdateType.MetadataImport, CancellationToken.None)
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -41,10 +41,19 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Audio
|
||||
{
|
||||
var collectionType = args.GetCollectionType();
|
||||
|
||||
var isMixed = string.IsNullOrWhiteSpace(collectionType);
|
||||
|
||||
// For conflicting extensions, give priority to videos
|
||||
if (isMixed && _libraryManager.IsVideoFile(args.Path))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var isStandalone = args.Parent == null;
|
||||
|
||||
if (isStandalone ||
|
||||
string.Equals(collectionType, CollectionType.Music, StringComparison.OrdinalIgnoreCase))
|
||||
string.Equals(collectionType, CollectionType.Music, StringComparison.OrdinalIgnoreCase) ||
|
||||
isMixed)
|
||||
{
|
||||
return new Controller.Entities.Audio.Audio();
|
||||
}
|
||||
|
||||
@@ -141,12 +141,6 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Audio
|
||||
|
||||
if (libraryManager.IsAudioFile(fullName))
|
||||
{
|
||||
// Don't resolve these into audio files
|
||||
if (string.Equals(fileSystem.GetFileNameWithoutExtension(fullName), BaseItem.ThemeSongFilename))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,12 +99,11 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.TV
|
||||
/// <param name="fileSystemChildren">The file system children.</param>
|
||||
/// <param name="directoryService">The directory service.</param>
|
||||
/// <param name="fileSystem">The file system.</param>
|
||||
/// <param name="logger">The logger.</param>
|
||||
/// <param name="libraryManager">The library manager.</param>
|
||||
/// <returns><c>true</c> if [is series folder] [the specified path]; otherwise, <c>false</c>.</returns>
|
||||
public static bool IsSeriesFolder(string path, bool considerSeasonlessEntries, IEnumerable<FileSystemInfo> fileSystemChildren, IDirectoryService directoryService, IFileSystem fileSystem, ILogger logger, ILibraryManager libraryManager)
|
||||
{
|
||||
// A folder with more than 3 non-season folders in will not becounted as a series
|
||||
var nonSeriesFolders = 0;
|
||||
|
||||
foreach (var child in fileSystemChildren)
|
||||
{
|
||||
var attributes = child.Attributes;
|
||||
@@ -129,19 +128,6 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.TV
|
||||
//logger.Debug("{0} is a series because of season folder {1}.", path, child.FullName);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (IsBadFolder(child.Name))
|
||||
{
|
||||
logger.Debug("Invalid folder under series: {0}", child.FullName);
|
||||
|
||||
nonSeriesFolders++;
|
||||
}
|
||||
|
||||
if (nonSeriesFolders >= 3)
|
||||
{
|
||||
logger.Debug("{0} not a series due to 3 or more invalid folders.", path);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -179,24 +165,6 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.TV
|
||||
return string.Equals(extension, ".disc", StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
private static bool IsBadFolder(string name)
|
||||
{
|
||||
if (string.Equals(name, BaseItem.ThemeSongsFolderName, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (string.Equals(name, BaseItem.ThemeVideosFolderName, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (string.Equals(name, BaseItem.TrailerFolderName, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return !EntityResolutionHelper.IgnoreFolders.Contains(name, StringComparer.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether [is season folder] [the specified path].
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user