From 5c873d3ed17b9291ed437b80b8ef66d4a4f2f960 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 12 May 2013 11:27:56 -0400 Subject: fixes #232 - '/' in artist causes issues. --- .../Providers/MediaInfo/BaseFFProbeProvider.cs | 62 ++-------------------- .../MediaInfo/FFProbeAudioInfoProvider.cs | 12 ----- .../MediaInfo/FFProbeVideoInfoProvider.cs | 31 ++--------- 3 files changed, 6 insertions(+), 99 deletions(-) (limited to 'MediaBrowser.Controller') diff --git a/MediaBrowser.Controller/Providers/MediaInfo/BaseFFProbeProvider.cs b/MediaBrowser.Controller/Providers/MediaInfo/BaseFFProbeProvider.cs index 4c86e909ba..bcaf4d525b 100644 --- a/MediaBrowser.Controller/Providers/MediaInfo/BaseFFProbeProvider.cs +++ b/MediaBrowser.Controller/Providers/MediaInfo/BaseFFProbeProvider.cs @@ -8,7 +8,6 @@ using MediaBrowser.Model.Serialization; using System; using System.Collections.Generic; using System.Globalization; -using System.IO; using System.Threading; using System.Threading.Tasks; @@ -28,33 +27,6 @@ namespace MediaBrowser.Controller.Providers.MediaInfo } protected readonly IJsonSerializer JsonSerializer; - - /// - /// Gets or sets the FF probe cache. - /// - /// The FF probe cache. - protected FileSystemRepository FFProbeCache { get; set; } - - /// - /// Initializes this instance. - /// - protected override void Initialize() - { - base.Initialize(); - FFProbeCache = new FileSystemRepository(Path.Combine(ConfigurationManager.ApplicationPaths.CachePath, CacheDirectoryName)); - } - - /// - /// Gets the name of the cache directory. - /// - /// The name of the cache directory. - protected virtual string CacheDirectoryName - { - get - { - return "ffmpeg-video-info"; - } - } /// /// Gets the priority. @@ -86,7 +58,7 @@ namespace MediaBrowser.Controller.Providers.MediaInfo { OnPreFetch(myItem, isoMount); - var result = await GetMediaInfo(item, isoMount, item.DateModified, FFProbeCache, cancellationToken).ConfigureAwait(false); + var result = await GetMediaInfo(item, isoMount, cancellationToken).ConfigureAwait(false); cancellationToken.ThrowIfCancellationRequested(); @@ -123,39 +95,15 @@ namespace MediaBrowser.Controller.Providers.MediaInfo /// /// The item. /// The iso mount. - /// The last date modified. - /// The cache. /// The cancellation token. /// Task{MediaInfoResult}. /// inputPath /// or /// cache - private async Task GetMediaInfo(BaseItem item, IIsoMount isoMount, DateTime lastDateModified, FileSystemRepository cache, CancellationToken cancellationToken) + private async Task GetMediaInfo(BaseItem item, IIsoMount isoMount, CancellationToken cancellationToken) { - if (cache == null) - { - throw new ArgumentNullException("cache"); - } - - // Put the ffmpeg version into the cache name so that it's unique per-version - // We don't want to try and deserialize data based on an old version, which could potentially fail - var resourceName = item.Id + "_" + lastDateModified.Ticks + "_" + MediaEncoder.Version; - - // Forumulate the cache file path - var cacheFilePath = cache.GetResourcePath(resourceName, ".js"); - cancellationToken.ThrowIfCancellationRequested(); - // Avoid File.Exists by just trying to deserialize - try - { - return JsonSerializer.DeserializeFromFile(cacheFilePath); - } - catch (FileNotFoundException) - { - // Cache file doesn't exist - } - var type = InputType.AudioFile; var inputPath = isoMount == null ? new[] { item.Path } : new[] { isoMount.MountedPath }; @@ -166,11 +114,7 @@ namespace MediaBrowser.Controller.Providers.MediaInfo inputPath = MediaEncoderHelpers.GetInputArgument(video, isoMount, out type); } - var info = await MediaEncoder.GetMediaInfo(inputPath, type, cancellationToken).ConfigureAwait(false); - - JsonSerializer.SerializeToFile(info, cacheFilePath); - - return info; + return await MediaEncoder.GetMediaInfo(inputPath, type, cancellationToken).ConfigureAwait(false); } /// diff --git a/MediaBrowser.Controller/Providers/MediaInfo/FFProbeAudioInfoProvider.cs b/MediaBrowser.Controller/Providers/MediaInfo/FFProbeAudioInfoProvider.cs index 9bd1e2811a..45ee732dd2 100644 --- a/MediaBrowser.Controller/Providers/MediaInfo/FFProbeAudioInfoProvider.cs +++ b/MediaBrowser.Controller/Providers/MediaInfo/FFProbeAudioInfoProvider.cs @@ -23,18 +23,6 @@ namespace MediaBrowser.Controller.Providers.MediaInfo { } - /// - /// Gets the name of the cache directory. - /// - /// The name of the cache directory. - protected override string CacheDirectoryName - { - get - { - return "ffmpeg-audio-info"; - } - } - /// /// Fetches the specified audio. /// diff --git a/MediaBrowser.Controller/Providers/MediaInfo/FFProbeVideoInfoProvider.cs b/MediaBrowser.Controller/Providers/MediaInfo/FFProbeVideoInfoProvider.cs index 93533b4f06..15a9b08f05 100644 --- a/MediaBrowser.Controller/Providers/MediaInfo/FFProbeVideoInfoProvider.cs +++ b/MediaBrowser.Controller/Providers/MediaInfo/FFProbeVideoInfoProvider.cs @@ -35,16 +35,8 @@ namespace MediaBrowser.Controller.Providers.MediaInfo _blurayExaminer = blurayExaminer; _isoManager = isoManager; - - BdInfoCache = new FileSystemRepository(Path.Combine(ConfigurationManager.ApplicationPaths.CachePath, "bdinfo")); } - /// - /// Gets or sets the bd info cache. - /// - /// The bd info cache. - private FileSystemRepository BdInfoCache { get; set; } - /// /// Gets or sets the bluray examiner. /// @@ -231,7 +223,7 @@ namespace MediaBrowser.Controller.Providers.MediaInfo if (video.VideoType == VideoType.BluRay || (video.IsoType.HasValue && video.IsoType.Value == IsoType.BluRay)) { var inputPath = isoMount != null ? isoMount.MountedPath : video.Path; - FetchBdInfo(video, inputPath, BdInfoCache, cancellationToken); + FetchBdInfo(video, inputPath, cancellationToken); } AddExternalSubtitles(video); @@ -334,29 +326,12 @@ namespace MediaBrowser.Controller.Providers.MediaInfo /// /// The item. /// The input path. - /// The bd info cache. /// The cancellation token. - private void FetchBdInfo(BaseItem item, string inputPath, FileSystemRepository bdInfoCache, CancellationToken cancellationToken) + private void FetchBdInfo(BaseItem item, string inputPath, CancellationToken cancellationToken) { var video = (Video)item; - // Get the path to the cache file - var cacheName = item.Id + "_" + item.DateModified.Ticks; - - var cacheFile = bdInfoCache.GetResourcePath(cacheName, ".js"); - - BlurayDiscInfo result; - - try - { - result = JsonSerializer.DeserializeFromFile(cacheFile); - } - catch (FileNotFoundException) - { - result = GetBDInfo(inputPath); - - JsonSerializer.SerializeToFile(result, cacheFile); - } + var result = GetBDInfo(inputPath); cancellationToken.ThrowIfCancellationRequested(); -- cgit v1.2.3