From 3094cd7ff3e51578808ce1b6f56b141930c18004 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 30 Oct 2016 03:11:37 -0400 Subject: update project targets --- MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs | 27 +++++++++++----------- 1 file changed, 13 insertions(+), 14 deletions(-) (limited to 'MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs') diff --git a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs index 69c0cf15f..bf6ff7655 100644 --- a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs +++ b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs @@ -219,7 +219,7 @@ namespace MediaBrowser.MediaEncoding.Encoder throw new ArgumentNullException("path"); } - if (!File.Exists(path) && !Directory.Exists(path)) + if (!FileSystem.FileExists(path) && !FileSystem.DirectoryExists(path)) { throw new ResourceNotFoundException(); } @@ -288,12 +288,12 @@ namespace MediaBrowser.MediaEncoding.Encoder if (!string.IsNullOrWhiteSpace(appPath)) { - if (Directory.Exists(appPath)) + if (FileSystem.DirectoryExists(appPath)) { return GetPathsFromDirectory(appPath); } - if (File.Exists(appPath)) + if (FileSystem.FileExists(appPath)) { return new Tuple(appPath, GetProbePathFromEncoderPath(appPath)); } @@ -329,16 +329,16 @@ namespace MediaBrowser.MediaEncoding.Encoder { // Since we can't predict the file extension, first try directly within the folder // If that doesn't pan out, then do a recursive search - var files = Directory.GetFiles(path); + var files = FileSystem.GetFilePaths(path); var excludeExtensions = new[] { ".c" }; var ffmpegPath = files.FirstOrDefault(i => string.Equals(Path.GetFileNameWithoutExtension(i), "ffmpeg", StringComparison.OrdinalIgnoreCase) && !excludeExtensions.Contains(Path.GetExtension(i) ?? string.Empty)); var ffprobePath = files.FirstOrDefault(i => string.Equals(Path.GetFileNameWithoutExtension(i), "ffprobe", StringComparison.OrdinalIgnoreCase) && !excludeExtensions.Contains(Path.GetExtension(i) ?? string.Empty)); - if (string.IsNullOrWhiteSpace(ffmpegPath) || !File.Exists(ffmpegPath)) + if (string.IsNullOrWhiteSpace(ffmpegPath) || !FileSystem.FileExists(ffmpegPath)) { - files = Directory.GetFiles(path, "*", SearchOption.AllDirectories); + files = FileSystem.GetFilePaths(path, true); ffmpegPath = files.FirstOrDefault(i => string.Equals(Path.GetFileNameWithoutExtension(i), "ffmpeg", StringComparison.OrdinalIgnoreCase) && !excludeExtensions.Contains(Path.GetExtension(i) ?? string.Empty)); @@ -353,7 +353,7 @@ namespace MediaBrowser.MediaEncoding.Encoder private string GetProbePathFromEncoderPath(string appPath) { - return Directory.GetFiles(Path.GetDirectoryName(appPath)) + return FileSystem.GetFilePaths(Path.GetDirectoryName(appPath)) .FirstOrDefault(i => string.Equals(Path.GetFileNameWithoutExtension(i), "ffprobe", StringComparison.OrdinalIgnoreCase)); } @@ -496,7 +496,6 @@ namespace MediaBrowser.MediaEncoding.Encoder /// Type of the video. /// The cancellation token. /// Task{MediaInfoResult}. - /// ffprobe failed - streams and format are both null. private async Task GetMediaInfoInternal(string inputPath, string primaryPath, MediaProtocol protocol, @@ -559,7 +558,7 @@ namespace MediaBrowser.MediaEncoding.Encoder if (result.streams == null && result.format == null) { - throw new ApplicationException("ffprobe failed - streams and format are both null."); + throw new Exception("ffprobe failed - streams and format are both null."); } if (result.streams != null) @@ -865,7 +864,7 @@ namespace MediaBrowser.MediaEncoding.Encoder } var tempExtractPath = Path.Combine(ConfigurationManager.ApplicationPaths.TempDirectory, Guid.NewGuid() + ".jpg"); - Directory.CreateDirectory(Path.GetDirectoryName(tempExtractPath)); + FileSystem.CreateDirectory(Path.GetDirectoryName(tempExtractPath)); // apply some filters to thumbnail extracted below (below) crop any black lines that we made and get the correct ar then scale to width 600. // This filter chain may have adverse effects on recorded tv thumbnails if ar changes during presentation ex. commercials @ diff ar @@ -962,7 +961,7 @@ namespace MediaBrowser.MediaEncoding.Encoder } var exitCode = ranToCompletion ? processWrapper.ExitCode ?? 0 : -1; - var file = new FileInfo(tempExtractPath); + var file = FileSystem.GetFileInfo(tempExtractPath); if (exitCode == -1 || !file.Exists || file.Length == 0) { @@ -970,7 +969,7 @@ namespace MediaBrowser.MediaEncoding.Encoder _logger.Error(msg); - throw new ApplicationException(msg); + throw new Exception(msg); } return tempExtractPath; @@ -1066,7 +1065,7 @@ namespace MediaBrowser.MediaEncoding.Encoder cancellationToken.ThrowIfCancellationRequested(); - var jpegCount = Directory.GetFiles(targetDirectory) + var jpegCount = FileSystem.GetFilePaths(targetDirectory) .Count(i => string.Equals(Path.GetExtension(i), ".jpg", StringComparison.OrdinalIgnoreCase)); isResponsive = (jpegCount > lastCount); @@ -1091,7 +1090,7 @@ namespace MediaBrowser.MediaEncoding.Encoder _logger.Error(msg); - throw new ApplicationException(msg); + throw new Exception(msg); } } } -- cgit v1.2.3