using MediaBrowser.Common.IO;
using MediaBrowser.Common.MediaInfo;
using MediaBrowser.Common.ScheduledTasks;
using MediaBrowser.Controller;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Movies;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Providers.MediaInfo;
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 VideoImagesTask
///
public class VideoImagesTask : 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 _iso manager
///
private readonly IIsoManager _isoManager;
///
/// The _locks
///
private readonly ConcurrentDictionary _locks = new ConcurrentDictionary();
///
/// Initializes a new instance of the class.
///
/// The library manager.
/// The media encoder.
/// The iso manager.
public VideoImagesTask(ILibraryManager libraryManager, IMediaEncoder mediaEncoder, IIsoManager isoManager)
{
_libraryManager = libraryManager;
_mediaEncoder = mediaEncoder;
_isoManager = isoManager;
ImageCache = new FileSystemRepository(Kernel.Instance.FFMpegManager.VideoImagesDataPath);
}
///
/// Gets the name of the task
///
/// The name.
public string Name
{
get { return "Video 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 allItems = _libraryManager.RootFolder.RecursiveChildren.ToList();
var localTrailers = allItems.SelectMany(i => i.LocalTrailers);
var videos = allItems.OfType