2014-02-09 14:11:11 -07:00
|
|
|
|
using MediaBrowser.Common.Configuration;
|
|
|
|
|
using MediaBrowser.Controller.Entities;
|
2014-02-05 21:39:16 -07:00
|
|
|
|
using MediaBrowser.Controller.Entities.Audio;
|
2014-02-04 13:19:29 -07:00
|
|
|
|
using MediaBrowser.Controller.Entities.Movies;
|
|
|
|
|
using MediaBrowser.Controller.Entities.TV;
|
|
|
|
|
using MediaBrowser.Controller.Library;
|
|
|
|
|
using MediaBrowser.Controller.LiveTv;
|
|
|
|
|
using MediaBrowser.Controller.Localization;
|
2014-02-20 09:37:41 -07:00
|
|
|
|
using MediaBrowser.Controller.MediaEncoding;
|
2014-02-04 13:19:29 -07:00
|
|
|
|
using MediaBrowser.Controller.Persistence;
|
|
|
|
|
using MediaBrowser.Controller.Providers;
|
|
|
|
|
using MediaBrowser.Model.Entities;
|
|
|
|
|
using MediaBrowser.Model.IO;
|
|
|
|
|
using MediaBrowser.Model.Logging;
|
|
|
|
|
using MediaBrowser.Model.MediaInfo;
|
2014-02-10 11:39:41 -07:00
|
|
|
|
using MediaBrowser.Model.Serialization;
|
2014-02-04 13:19:29 -07:00
|
|
|
|
using System;
|
|
|
|
|
using System.Threading;
|
|
|
|
|
using System.Threading.Tasks;
|
2014-02-10 11:39:41 -07:00
|
|
|
|
using System.Linq;
|
2014-02-04 13:19:29 -07:00
|
|
|
|
|
|
|
|
|
namespace MediaBrowser.Providers.MediaInfo
|
|
|
|
|
{
|
|
|
|
|
public class FFProbeProvider : ICustomMetadataProvider<Episode>,
|
2014-02-05 21:39:16 -07:00
|
|
|
|
ICustomMetadataProvider<MusicVideo>,
|
|
|
|
|
ICustomMetadataProvider<Movie>,
|
|
|
|
|
ICustomMetadataProvider<AdultVideo>,
|
|
|
|
|
ICustomMetadataProvider<LiveTvVideoRecording>,
|
|
|
|
|
ICustomMetadataProvider<LiveTvAudioRecording>,
|
|
|
|
|
ICustomMetadataProvider<Trailer>,
|
|
|
|
|
ICustomMetadataProvider<Video>,
|
|
|
|
|
ICustomMetadataProvider<Audio>,
|
2014-02-08 16:44:49 -07:00
|
|
|
|
IHasChangeMonitor,
|
2014-02-18 22:21:03 -07:00
|
|
|
|
IHasOrder,
|
|
|
|
|
IForcedProvider
|
2014-02-04 13:19:29 -07:00
|
|
|
|
{
|
|
|
|
|
private readonly ILogger _logger;
|
|
|
|
|
private readonly IIsoManager _isoManager;
|
|
|
|
|
private readonly IMediaEncoder _mediaEncoder;
|
|
|
|
|
private readonly IItemRepository _itemRepo;
|
|
|
|
|
private readonly IBlurayExaminer _blurayExaminer;
|
|
|
|
|
private readonly ILocalizationManager _localization;
|
2014-02-09 14:11:11 -07:00
|
|
|
|
private readonly IApplicationPaths _appPaths;
|
|
|
|
|
private readonly IJsonSerializer _json;
|
2014-02-20 09:37:41 -07:00
|
|
|
|
private readonly IEncodingManager _encodingManager;
|
2014-02-05 21:39:16 -07:00
|
|
|
|
|
2014-02-04 13:19:29 -07:00
|
|
|
|
public string Name
|
|
|
|
|
{
|
|
|
|
|
get { return "ffprobe"; }
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-10 11:39:41 -07:00
|
|
|
|
public Task<ItemUpdateType> FetchAsync(Episode item, IDirectoryService directoryService, CancellationToken cancellationToken)
|
2014-02-04 13:19:29 -07:00
|
|
|
|
{
|
2014-02-10 11:39:41 -07:00
|
|
|
|
return FetchVideoInfo(item, directoryService, cancellationToken);
|
2014-02-04 13:19:29 -07:00
|
|
|
|
}
|
|
|
|
|
|
2014-02-10 11:39:41 -07:00
|
|
|
|
public Task<ItemUpdateType> FetchAsync(MusicVideo item, IDirectoryService directoryService, CancellationToken cancellationToken)
|
2014-02-04 13:19:29 -07:00
|
|
|
|
{
|
2014-02-10 11:39:41 -07:00
|
|
|
|
return FetchVideoInfo(item, directoryService, cancellationToken);
|
2014-02-04 13:19:29 -07:00
|
|
|
|
}
|
|
|
|
|
|
2014-02-10 11:39:41 -07:00
|
|
|
|
public Task<ItemUpdateType> FetchAsync(Movie item, IDirectoryService directoryService, CancellationToken cancellationToken)
|
2014-02-04 13:19:29 -07:00
|
|
|
|
{
|
2014-02-10 11:39:41 -07:00
|
|
|
|
return FetchVideoInfo(item, directoryService, cancellationToken);
|
2014-02-04 13:19:29 -07:00
|
|
|
|
}
|
|
|
|
|
|
2014-02-10 11:39:41 -07:00
|
|
|
|
public Task<ItemUpdateType> FetchAsync(AdultVideo item, IDirectoryService directoryService, CancellationToken cancellationToken)
|
2014-02-04 13:19:29 -07:00
|
|
|
|
{
|
2014-02-10 11:39:41 -07:00
|
|
|
|
return FetchVideoInfo(item, directoryService, cancellationToken);
|
2014-02-04 13:19:29 -07:00
|
|
|
|
}
|
|
|
|
|
|
2014-02-10 11:39:41 -07:00
|
|
|
|
public Task<ItemUpdateType> FetchAsync(LiveTvVideoRecording item, IDirectoryService directoryService, CancellationToken cancellationToken)
|
2014-02-04 13:19:29 -07:00
|
|
|
|
{
|
2014-02-10 11:39:41 -07:00
|
|
|
|
return FetchVideoInfo(item, directoryService, cancellationToken);
|
2014-02-04 13:19:29 -07:00
|
|
|
|
}
|
|
|
|
|
|
2014-02-10 11:39:41 -07:00
|
|
|
|
public Task<ItemUpdateType> FetchAsync(Trailer item, IDirectoryService directoryService, CancellationToken cancellationToken)
|
2014-02-05 21:39:16 -07:00
|
|
|
|
{
|
2014-02-10 11:39:41 -07:00
|
|
|
|
return FetchVideoInfo(item, directoryService, cancellationToken);
|
2014-02-05 21:39:16 -07:00
|
|
|
|
}
|
|
|
|
|
|
2014-02-10 11:39:41 -07:00
|
|
|
|
public Task<ItemUpdateType> FetchAsync(Video item, IDirectoryService directoryService, CancellationToken cancellationToken)
|
2014-02-05 21:39:16 -07:00
|
|
|
|
{
|
2014-02-10 11:39:41 -07:00
|
|
|
|
return FetchVideoInfo(item, directoryService, cancellationToken);
|
2014-02-05 21:39:16 -07:00
|
|
|
|
}
|
|
|
|
|
|
2014-02-10 11:39:41 -07:00
|
|
|
|
public Task<ItemUpdateType> FetchAsync(Audio item, IDirectoryService directoryService, CancellationToken cancellationToken)
|
2014-02-05 21:39:16 -07:00
|
|
|
|
{
|
|
|
|
|
return FetchAudioInfo(item, cancellationToken);
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-10 11:39:41 -07:00
|
|
|
|
public Task<ItemUpdateType> FetchAsync(LiveTvAudioRecording item, IDirectoryService directoryService, CancellationToken cancellationToken)
|
2014-02-05 21:39:16 -07:00
|
|
|
|
{
|
|
|
|
|
return FetchAudioInfo(item, cancellationToken);
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-22 23:14:48 -07:00
|
|
|
|
public FFProbeProvider(ILogger logger, IIsoManager isoManager, IMediaEncoder mediaEncoder, IItemRepository itemRepo, IBlurayExaminer blurayExaminer, ILocalizationManager localization, IApplicationPaths appPaths, IJsonSerializer json, IEncodingManager encodingManager)
|
2014-02-04 13:19:29 -07:00
|
|
|
|
{
|
|
|
|
|
_logger = logger;
|
|
|
|
|
_isoManager = isoManager;
|
|
|
|
|
_mediaEncoder = mediaEncoder;
|
|
|
|
|
_itemRepo = itemRepo;
|
|
|
|
|
_blurayExaminer = blurayExaminer;
|
|
|
|
|
_localization = localization;
|
2014-02-09 14:11:11 -07:00
|
|
|
|
_appPaths = appPaths;
|
|
|
|
|
_json = json;
|
2014-02-22 23:14:48 -07:00
|
|
|
|
_encodingManager = encodingManager;
|
2014-02-04 13:19:29 -07:00
|
|
|
|
}
|
|
|
|
|
|
2014-02-10 11:39:41 -07:00
|
|
|
|
private readonly Task<ItemUpdateType> _cachedTask = Task.FromResult(ItemUpdateType.None);
|
|
|
|
|
public Task<ItemUpdateType> FetchVideoInfo<T>(T item, IDirectoryService directoryService, CancellationToken cancellationToken)
|
2014-02-04 13:19:29 -07:00
|
|
|
|
where T : Video
|
|
|
|
|
{
|
|
|
|
|
if (item.LocationType != LocationType.FileSystem)
|
|
|
|
|
{
|
|
|
|
|
return _cachedTask;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (item.VideoType == VideoType.Iso && !_isoManager.CanMount(item.Path))
|
|
|
|
|
{
|
|
|
|
|
return _cachedTask;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (item.VideoType == VideoType.HdDvd)
|
|
|
|
|
{
|
|
|
|
|
return _cachedTask;
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-20 09:37:41 -07:00
|
|
|
|
var prober = new FFProbeVideoInfo(_logger, _isoManager, _mediaEncoder, _itemRepo, _blurayExaminer, _localization, _appPaths, _json, _encodingManager);
|
2014-02-04 13:19:29 -07:00
|
|
|
|
|
2014-02-10 11:39:41 -07:00
|
|
|
|
return prober.ProbeVideo(item, directoryService, cancellationToken);
|
2014-02-04 13:19:29 -07:00
|
|
|
|
}
|
|
|
|
|
|
2014-02-05 21:39:16 -07:00
|
|
|
|
public Task<ItemUpdateType> FetchAudioInfo<T>(T item, CancellationToken cancellationToken)
|
|
|
|
|
where T : Audio
|
|
|
|
|
{
|
|
|
|
|
if (item.LocationType != LocationType.FileSystem)
|
|
|
|
|
{
|
|
|
|
|
return _cachedTask;
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-09 14:11:11 -07:00
|
|
|
|
var prober = new FFProbeAudioInfo(_mediaEncoder, _itemRepo, _appPaths, _json);
|
2014-02-05 21:39:16 -07:00
|
|
|
|
|
|
|
|
|
return prober.Probe(item, cancellationToken);
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-10 11:39:41 -07:00
|
|
|
|
public bool HasChanged(IHasMetadata item, IDirectoryService directoryService, DateTime date)
|
2014-02-04 13:19:29 -07:00
|
|
|
|
{
|
2014-02-10 11:39:41 -07:00
|
|
|
|
if (item.DateModified > date)
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-10 13:11:46 -07:00
|
|
|
|
if (item.SupportsLocalMetadata)
|
2014-02-10 11:39:41 -07:00
|
|
|
|
{
|
|
|
|
|
var video = item as Video;
|
|
|
|
|
|
|
|
|
|
if (video != null)
|
|
|
|
|
{
|
2014-02-20 09:37:41 -07:00
|
|
|
|
var prober = new FFProbeVideoInfo(_logger, _isoManager, _mediaEncoder, _itemRepo, _blurayExaminer, _localization, _appPaths, _json, _encodingManager);
|
2014-02-10 11:39:41 -07:00
|
|
|
|
|
|
|
|
|
return !video.SubtitleFiles.SequenceEqual(prober.GetSubtitleFiles(video, directoryService).Select(i => i.FullName).OrderBy(i => i), StringComparer.OrdinalIgnoreCase);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
2014-02-04 13:19:29 -07:00
|
|
|
|
}
|
2014-02-08 16:44:49 -07:00
|
|
|
|
|
|
|
|
|
public int Order
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
// Run last
|
|
|
|
|
return 100;
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-02-04 13:19:29 -07:00
|
|
|
|
}
|
|
|
|
|
}
|