return null if itemid is empty (#327)
also use IReadOnlyList Co-authored-by: rlauu <46294892+rlauu@users.noreply.github.com>
This commit is contained in:
parent
0841f1ba40
commit
6fb7d05dd7
@ -34,7 +34,7 @@ public class AnalyzerHelper
|
||||
/// <param name="mode">Analysis mode.</param>
|
||||
/// <returns>Modified Intro Timestamps.</returns>
|
||||
public Dictionary<Guid, Segment> AdjustIntroTimes(
|
||||
IReadOnlyCollection<QueuedEpisode> episodes,
|
||||
IReadOnlyList<QueuedEpisode> episodes,
|
||||
IReadOnlyDictionary<Guid, Segment> originalIntros,
|
||||
AnalysisMode mode)
|
||||
{
|
||||
@ -76,9 +76,9 @@ public class AnalyzerHelper
|
||||
return adjustedIntro;
|
||||
}
|
||||
|
||||
private List<ChapterInfo> GetChaptersWithVirtualEnd(QueuedEpisode episode)
|
||||
private static List<ChapterInfo> GetChaptersWithVirtualEnd(QueuedEpisode episode)
|
||||
{
|
||||
var chapters = Plugin.Instance?.GetChapters(episode.EpisodeId) ?? new List<ChapterInfo>();
|
||||
var chapters = Plugin.Instance?.GetChapters(episode.EpisodeId) ?? [];
|
||||
chapters.Add(new ChapterInfo { StartPositionTicks = TimeSpan.FromSeconds(episode.Duration).Ticks });
|
||||
return chapters;
|
||||
}
|
||||
|
@ -39,8 +39,8 @@ public class BlackFrameAnalyzer : IMediaFileAnalyzer
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public IReadOnlyCollection<QueuedEpisode> AnalyzeMediaFiles(
|
||||
IReadOnlyCollection<QueuedEpisode> analysisQueue,
|
||||
public IReadOnlyList<QueuedEpisode> AnalyzeMediaFiles(
|
||||
IReadOnlyList<QueuedEpisode> analysisQueue,
|
||||
AnalysisMode mode,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
|
@ -24,8 +24,8 @@ public class ChapterAnalyzer(ILogger<ChapterAnalyzer> logger) : IMediaFileAnalyz
|
||||
private ILogger<ChapterAnalyzer> _logger = logger;
|
||||
|
||||
/// <inheritdoc />
|
||||
public IReadOnlyCollection<QueuedEpisode> AnalyzeMediaFiles(
|
||||
IReadOnlyCollection<QueuedEpisode> analysisQueue,
|
||||
public IReadOnlyList<QueuedEpisode> AnalyzeMediaFiles(
|
||||
IReadOnlyList<QueuedEpisode> analysisQueue,
|
||||
AnalysisMode mode,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
|
@ -49,8 +49,8 @@ public class ChromaprintAnalyzer : IMediaFileAnalyzer
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public IReadOnlyCollection<QueuedEpisode> AnalyzeMediaFiles(
|
||||
IReadOnlyCollection<QueuedEpisode> analysisQueue,
|
||||
public IReadOnlyList<QueuedEpisode> AnalyzeMediaFiles(
|
||||
IReadOnlyList<QueuedEpisode> analysisQueue,
|
||||
AnalysisMode mode,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
|
@ -16,8 +16,8 @@ public interface IMediaFileAnalyzer
|
||||
/// <param name="mode">Analysis mode.</param>
|
||||
/// <param name="cancellationToken">Cancellation token from scheduled task.</param>
|
||||
/// <returns>Collection of media files that were **unsuccessfully analyzed**.</returns>
|
||||
public IReadOnlyCollection<QueuedEpisode> AnalyzeMediaFiles(
|
||||
IReadOnlyCollection<QueuedEpisode> analysisQueue,
|
||||
public IReadOnlyList<QueuedEpisode> AnalyzeMediaFiles(
|
||||
IReadOnlyList<QueuedEpisode> analysisQueue,
|
||||
AnalysisMode mode,
|
||||
CancellationToken cancellationToken);
|
||||
}
|
||||
|
@ -22,8 +22,8 @@ public class SegmentAnalyzer : IMediaFileAnalyzer
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public IReadOnlyCollection<QueuedEpisode> AnalyzeMediaFiles(
|
||||
IReadOnlyCollection<QueuedEpisode> analysisQueue,
|
||||
public IReadOnlyList<QueuedEpisode> AnalyzeMediaFiles(
|
||||
IReadOnlyList<QueuedEpisode> analysisQueue,
|
||||
AnalysisMode mode,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
|
@ -48,7 +48,7 @@ public static class EdlManager
|
||||
/// If the EDL action is set to a value other than None, update EDL files for the provided episodes.
|
||||
/// </summary>
|
||||
/// <param name="episodes">Episodes to update EDL files for.</param>
|
||||
public static void UpdateEDLFiles(IReadOnlyCollection<QueuedEpisode> episodes)
|
||||
public static void UpdateEDLFiles(IReadOnlyList<QueuedEpisode> episodes)
|
||||
{
|
||||
var regenerate = Plugin.Instance!.Configuration.RegenerateEdlFiles;
|
||||
var action = Plugin.Instance.Configuration.EdlAction;
|
||||
|
@ -241,8 +241,8 @@ public class QueueManager(ILogger<QueueManager> logger, ILibraryManager libraryM
|
||||
/// <param name="candidates">Queued media items.</param>
|
||||
/// <param name="modes">Analysis mode.</param>
|
||||
/// <returns>Media items that have been verified to exist in Jellyfin and in storage.</returns>
|
||||
public (IReadOnlyCollection<QueuedEpisode> VerifiedItems, IReadOnlyCollection<AnalysisMode> RequiredModes)
|
||||
VerifyQueue(IReadOnlyCollection<QueuedEpisode> candidates, IReadOnlyCollection<AnalysisMode> modes)
|
||||
public (IReadOnlyList<QueuedEpisode> VerifiedItems, IReadOnlyCollection<AnalysisMode> RequiredModes)
|
||||
VerifyQueue(IReadOnlyList<QueuedEpisode> candidates, IReadOnlyCollection<AnalysisMode> modes)
|
||||
{
|
||||
var verified = new List<QueuedEpisode>();
|
||||
var reqModes = new HashSet<AnalysisMode>();
|
||||
|
@ -312,10 +312,10 @@ public class Plugin : BasePlugin<PluginConfiguration>, IHasWebPages
|
||||
|
||||
internal BaseItem? GetItem(Guid id)
|
||||
{
|
||||
return _libraryManager.GetItemById(id);
|
||||
return id != Guid.Empty ? _libraryManager.GetItemById(id) : null;
|
||||
}
|
||||
|
||||
internal List<Folder> GetCollectionFolders(Guid id)
|
||||
internal IReadOnlyList<Folder> GetCollectionFolders(Guid id)
|
||||
{
|
||||
var item = GetItem(id);
|
||||
return item is not null ? _libraryManager.GetCollectionFolders(item) : [];
|
||||
|
@ -112,7 +112,7 @@ public class BaseItemAnalyzerTask
|
||||
return;
|
||||
}
|
||||
|
||||
var first = episodes.First();
|
||||
var first = episodes[0];
|
||||
if (requiredModes.Count == 0)
|
||||
{
|
||||
_logger.LogDebug(
|
||||
@ -180,14 +180,14 @@ public class BaseItemAnalyzerTask
|
||||
/// <param name="cancellationToken">Cancellation token.</param>
|
||||
/// <returns>Number of items that were successfully analyzed.</returns>
|
||||
private int AnalyzeItems(
|
||||
IReadOnlyCollection<QueuedEpisode> items,
|
||||
IReadOnlyList<QueuedEpisode> items,
|
||||
AnalysisMode mode,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
var totalItems = items.Count;
|
||||
|
||||
// Only analyze specials (season 0) if the user has opted in.
|
||||
var first = items.First();
|
||||
var first = items[0];
|
||||
if (first.SeasonNumber == 0 && !Plugin.Instance!.Configuration.AnalyzeSeasonZero)
|
||||
{
|
||||
return 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user