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:
rlauuzo 2024-10-05 19:30:30 +02:00 committed by GitHub
parent 0841f1ba40
commit 6fb7d05dd7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 21 additions and 21 deletions

View File

@ -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;
}

View File

@ -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)
{

View File

@ -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)
{

View File

@ -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)
{

View File

@ -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);
}

View File

@ -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)
{

View File

@ -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;

View File

@ -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>();

View File

@ -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) : [];

View File

@ -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;