using System; using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; using MediaBrowser.Controller.Library; using MediaBrowser.Model.Tasks; using Microsoft.Extensions.Logging; namespace ConfusedPolarBear.Plugin.IntroSkipper; /// /// Analyze all television episodes for credits. /// TODO: analyze all media files. /// public class DetectCreditsTask : IScheduledTask { private readonly ILoggerFactory _loggerFactory; private readonly ILibraryManager _libraryManager; /// /// Initializes a new instance of the class. /// /// Logger factory. /// Library manager. public DetectCreditsTask( ILoggerFactory loggerFactory, ILibraryManager libraryManager) { _loggerFactory = loggerFactory; _libraryManager = libraryManager; } /// /// Gets the task name. /// public string Name => "Detect Credits"; /// /// Gets the task category. /// public string Category => "Intro Skipper"; /// /// Gets the task description. /// public string Description => "Analyzes the audio and video of all television episodes to find credits."; /// /// Gets the task key. /// public string Key => "CPBIntroSkipperDetectCredits"; /// /// Analyze all episodes in the queue. Only one instance of this task should be run at a time. /// /// Task progress. /// Cancellation token. /// Task. public Task ExecuteAsync(IProgress progress, CancellationToken cancellationToken) { if (_libraryManager is null) { throw new InvalidOperationException("Library manager was null"); } var baseAnalyzer = new BaseItemAnalyzerTask( AnalysisMode.Credits, _loggerFactory.CreateLogger(), _loggerFactory, _libraryManager); baseAnalyzer.AnalyzeItems(progress, cancellationToken); return Task.CompletedTask; } /// /// Get task triggers. /// /// Task triggers. public IEnumerable GetDefaultTriggers() { return Array.Empty(); } }