using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Threading; using System.Threading.Tasks; using Jellyfin.Data.Enums; using Jellyfin.Extensions; using MediaBrowser.Common.Configuration; using MediaBrowser.Controller.Chapters; using MediaBrowser.Controller.Dto; using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Providers; using MediaBrowser.Model.Globalization; using MediaBrowser.Model.IO; using MediaBrowser.Model.Tasks; using Microsoft.Extensions.Logging; namespace Emby.Server.Implementations.ScheduledTasks.Tasks; /// /// Class ChapterImagesTask. /// public class ChapterImagesTask : IScheduledTask { private readonly ILogger _logger; private readonly ILibraryManager _libraryManager; private readonly IApplicationPaths _appPaths; private readonly IChapterManager _chapterManager; private readonly IFileSystem _fileSystem; private readonly ILocalizationManager _localization; /// /// Initializes a new instance of the class. /// /// Instance of the interface. /// Instance of the interface. /// Instance of the interface. /// Instance of the interface. /// Instance of the interface. /// Instance of the interface. public ChapterImagesTask( ILogger logger, ILibraryManager libraryManager, IApplicationPaths appPaths, IChapterManager chapterManager, IFileSystem fileSystem, ILocalizationManager localization) { _logger = logger; _libraryManager = libraryManager; _appPaths = appPaths; _chapterManager = chapterManager; _fileSystem = fileSystem; _localization = localization; } /// public string Name => _localization.GetLocalizedString("TaskRefreshChapterImages"); /// public string Description => _localization.GetLocalizedString("TaskRefreshChapterImagesDescription"); /// public string Category => _localization.GetLocalizedString("TasksLibraryCategory"); /// public string Key => "RefreshChapterImages"; /// public IEnumerable GetDefaultTriggers() { yield return new TaskTriggerInfo { Type = TaskTriggerInfoType.DailyTrigger, TimeOfDayTicks = TimeSpan.FromHours(2).Ticks, MaxRuntimeTicks = TimeSpan.FromHours(4).Ticks }; } /// public async Task ExecuteAsync(IProgress progress, CancellationToken cancellationToken) { var videos = _libraryManager.GetItemList(new InternalItemsQuery { MediaTypes = [MediaType.Video], IsFolder = false, Recursive = true, DtoOptions = new DtoOptions(false) { EnableImages = false }, SourceTypes = [SourceType.Library], IsVirtualItem = false }) .OfType