mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-04-21 09:34:44 +01:00
reduce requests against tvdb by getting entire series metadata at once
This commit is contained in:
@@ -31,6 +31,8 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
/// </summary>
|
||||
public class LibraryManager : ILibraryManager
|
||||
{
|
||||
private IEnumerable<ILibraryPrescanTask> PrescanTasks { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the intro providers.
|
||||
/// </summary>
|
||||
@@ -161,13 +163,15 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
IEnumerable<IVirtualFolderCreator> pluginFolders,
|
||||
IEnumerable<IItemResolver> resolvers,
|
||||
IEnumerable<IIntroProvider> introProviders,
|
||||
IEnumerable<IBaseItemComparer> itemComparers)
|
||||
IEnumerable<IBaseItemComparer> itemComparers,
|
||||
IEnumerable<ILibraryPrescanTask> prescanTasks)
|
||||
{
|
||||
EntityResolutionIgnoreRules = rules;
|
||||
PluginFolderCreators = pluginFolders;
|
||||
EntityResolvers = resolvers.OrderBy(i => i.Priority).ToArray();
|
||||
IntroProviders = introProviders;
|
||||
Comparers = itemComparers;
|
||||
PrescanTasks = prescanTasks;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -841,6 +845,19 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
await ValidateCollectionFolders(folder, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
// Run prescan tasks
|
||||
foreach (var task in PrescanTasks)
|
||||
{
|
||||
try
|
||||
{
|
||||
await task.Run(new Progress<double>(), cancellationToken);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.ErrorException("Error running prescan task", ex);
|
||||
}
|
||||
}
|
||||
|
||||
var innerProgress = new ActionableProgress<double>();
|
||||
|
||||
innerProgress.RegisterAction(pct => progress.Report(pct * .8));
|
||||
|
||||
@@ -18,41 +18,54 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.TV
|
||||
/// <returns>Episode.</returns>
|
||||
protected override Episode Resolve(ItemResolveArgs args)
|
||||
{
|
||||
var isInSeason = args.Parent is Season;
|
||||
var season = args.Parent as Season;
|
||||
|
||||
// If the parent is a Season or Series, then this is an Episode if the VideoResolver returns something
|
||||
if (isInSeason || args.Parent is Series)
|
||||
if (season != null || args.Parent is Series)
|
||||
{
|
||||
Episode episode = null;
|
||||
|
||||
if (args.IsDirectory)
|
||||
{
|
||||
if (args.ContainsFileSystemEntryByName("video_ts"))
|
||||
{
|
||||
return new Episode
|
||||
episode = new Episode
|
||||
{
|
||||
IndexNumber = TVUtils.GetEpisodeNumberFromFile(args.Path, isInSeason),
|
||||
Path = args.Path,
|
||||
VideoType = VideoType.Dvd
|
||||
};
|
||||
}
|
||||
if (args.ContainsFileSystemEntryByName("bdmv"))
|
||||
{
|
||||
return new Episode
|
||||
episode = new Episode
|
||||
{
|
||||
IndexNumber = TVUtils.GetEpisodeNumberFromFile(args.Path, isInSeason),
|
||||
Path = args.Path,
|
||||
VideoType = VideoType.BluRay
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
var episide = base.Resolve(args);
|
||||
|
||||
if (episide != null)
|
||||
if (episode == null)
|
||||
{
|
||||
episide.IndexNumber = TVUtils.GetEpisodeNumberFromFile(args.Path, isInSeason);
|
||||
episode = base.Resolve(args);
|
||||
}
|
||||
|
||||
return episide;
|
||||
if (episode != null)
|
||||
{
|
||||
episode.IndexNumber = TVUtils.GetEpisodeNumberFromFile(args.Path, season != null);
|
||||
|
||||
if (season != null)
|
||||
{
|
||||
episode.ParentIndexNumber = season.IndexNumber;
|
||||
}
|
||||
|
||||
if (episode.ParentIndexNumber == null)
|
||||
{
|
||||
episode.ParentIndexNumber = TVUtils.GetSeasonNumberFromEpisodeFile(args.Path);
|
||||
}
|
||||
}
|
||||
|
||||
return episode;
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user