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