using MediaBrowser.Common.IO; using MediaBrowser.Common.MediaInfo; using MediaBrowser.Common.ScheduledTasks; using MediaBrowser.Controller; using MediaBrowser.Controller.Entities.Audio; using MediaBrowser.Controller.Library; using MediaBrowser.Model.Entities; using System; using System.Collections.Concurrent; using System.Collections.Generic; using System.Linq; using System.Threading; using System.Threading.Tasks; namespace MediaBrowser.Server.Implementations.ScheduledTasks { /// /// Class AudioImagesTask /// public class AudioImagesTask : IScheduledTask { /// /// Gets or sets the image cache. /// /// The image cache. public FileSystemRepository ImageCache { get; set; } /// /// The _library manager /// private readonly ILibraryManager _libraryManager; /// /// The _media encoder /// private readonly IMediaEncoder _mediaEncoder; /// /// The _locks /// private readonly ConcurrentDictionary _locks = new ConcurrentDictionary(); /// /// Initializes a new instance of the class. /// /// The library manager. /// The media encoder. public AudioImagesTask(ILibraryManager libraryManager, IMediaEncoder mediaEncoder) { _libraryManager = libraryManager; _mediaEncoder = mediaEncoder; ImageCache = new FileSystemRepository(Kernel.Instance.FFMpegManager.AudioImagesDataPath); } /// /// Gets the name of the task /// /// The name. public string Name { get { return "Audio image extraction"; } } /// /// Gets the description. /// /// The description. public string Description { get { return "Extracts images from audio files that do not have external images."; } } /// /// Gets the category. /// /// The category. public string Category { get { return "Library"; } } /// /// Executes the task /// /// The cancellation token. /// The progress. /// Task. public async Task Execute(CancellationToken cancellationToken, IProgress progress) { var items = _libraryManager.RootFolder.RecursiveChildren .OfType