aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.MediaEncoding
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2016-10-30 03:11:37 -0400
committerLuke Pulverenti <luke.pulverenti@gmail.com>2016-10-30 03:11:37 -0400
commit3094cd7ff3e51578808ce1b6f56b141930c18004 (patch)
tree27984f41f725e83fa01c524b4a1a0a0595d9bf74 /MediaBrowser.MediaEncoding
parentf676ea63156f959d08eb4d324274ef2fef853933 (diff)
update project targets
Diffstat (limited to 'MediaBrowser.MediaEncoding')
-rw-r--r--MediaBrowser.MediaEncoding/BdInfo/BdInfoExaminer.cs13
-rw-r--r--MediaBrowser.MediaEncoding/Configuration/EncodingConfigurationFactory.cs2
-rw-r--r--MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs2
-rw-r--r--MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs27
-rw-r--r--MediaBrowser.MediaEncoding/MediaBrowser.MediaEncoding.csproj3
-rw-r--r--MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs23
-rw-r--r--MediaBrowser.MediaEncoding/Probing/whitelist.txt1
7 files changed, 30 insertions, 41 deletions
diff --git a/MediaBrowser.MediaEncoding/BdInfo/BdInfoExaminer.cs b/MediaBrowser.MediaEncoding/BdInfo/BdInfoExaminer.cs
index e435c00f2..ee7cb9dda 100644
--- a/MediaBrowser.MediaEncoding/BdInfo/BdInfoExaminer.cs
+++ b/MediaBrowser.MediaEncoding/BdInfo/BdInfoExaminer.cs
@@ -4,6 +4,8 @@ using MediaBrowser.Model.MediaInfo;
using System;
using System.Collections.Generic;
using System.Linq;
+using MediaBrowser.Model.IO;
+using MediaBrowser.Model.TextEncoding;
namespace MediaBrowser.MediaEncoding.BdInfo
{
@@ -12,6 +14,15 @@ namespace MediaBrowser.MediaEncoding.BdInfo
/// </summary>
public class BdInfoExaminer : IBlurayExaminer
{
+ private readonly IFileSystem _fileSystem;
+ private readonly IEncoding _textEncoding;
+
+ public BdInfoExaminer(IFileSystem fileSystem, IEncoding textEncoding)
+ {
+ _fileSystem = fileSystem;
+ _textEncoding = textEncoding;
+ }
+
/// <summary>
/// Gets the disc info.
/// </summary>
@@ -19,7 +30,7 @@ namespace MediaBrowser.MediaEncoding.BdInfo
/// <returns>BlurayDiscInfo.</returns>
public BlurayDiscInfo GetDiscInfo(string path)
{
- var bdrom = new BDROM(path);
+ var bdrom = new BDROM(path, _fileSystem, _textEncoding);
bdrom.Scan();
diff --git a/MediaBrowser.MediaEncoding/Configuration/EncodingConfigurationFactory.cs b/MediaBrowser.MediaEncoding/Configuration/EncodingConfigurationFactory.cs
index cf4d12fcb..5beab746d 100644
--- a/MediaBrowser.MediaEncoding/Configuration/EncodingConfigurationFactory.cs
+++ b/MediaBrowser.MediaEncoding/Configuration/EncodingConfigurationFactory.cs
@@ -50,7 +50,7 @@ namespace MediaBrowser.MediaEncoding.Configuration
// Validate
if (!_fileSystem.DirectoryExists(newPath))
{
- throw new DirectoryNotFoundException(string.Format("{0} does not exist.", newPath));
+ throw new FileNotFoundException(string.Format("{0} does not exist.", newPath));
}
}
}
diff --git a/MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs b/MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs
index 536e5837f..be64aecc5 100644
--- a/MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs
+++ b/MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs
@@ -217,7 +217,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
}
try
{
- job.TaskCompletionSource.TrySetException(new ApplicationException("Encoding failed"));
+ job.TaskCompletionSource.TrySetException(new Exception("Encoding failed"));
}
catch
{
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<string, string>(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
/// <param name="videoType">Type of the video.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task{MediaInfoResult}.</returns>
- /// <exception cref="System.ApplicationException">ffprobe failed - streams and format are both null.</exception>
private async Task<MediaInfo> 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);
}
}
}
diff --git a/MediaBrowser.MediaEncoding/MediaBrowser.MediaEncoding.csproj b/MediaBrowser.MediaEncoding/MediaBrowser.MediaEncoding.csproj
index 99cec0316..89e0b61c1 100644
--- a/MediaBrowser.MediaEncoding/MediaBrowser.MediaEncoding.csproj
+++ b/MediaBrowser.MediaEncoding/MediaBrowser.MediaEncoding.csproj
@@ -106,9 +106,6 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
- <EmbeddedResource Include="Probing\whitelist.txt" />
- </ItemGroup>
- <ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
diff --git a/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs b/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs
index 288d9708a..96c3bf6a0 100644
--- a/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs
+++ b/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs
@@ -973,27 +973,10 @@ namespace MediaBrowser.MediaEncoding.Probing
{
if (_splitWhiteList == null)
{
- var file = GetType().Namespace + ".whitelist.txt";
-
- using (var stream = GetType().Assembly.GetManifestResourceStream(file))
- {
- using (var reader = new StreamReader(stream))
- {
- var list = new List<string>();
-
- while (!reader.EndOfStream)
+ _splitWhiteList = new List<string>
{
- var val = reader.ReadLine();
-
- if (!string.IsNullOrWhiteSpace(val))
- {
- list.Add(val);
- }
- }
-
- _splitWhiteList = list;
- }
- }
+ "AC/DV"
+ };
}
return _splitWhiteList;
diff --git a/MediaBrowser.MediaEncoding/Probing/whitelist.txt b/MediaBrowser.MediaEncoding/Probing/whitelist.txt
deleted file mode 100644
index 1fd366551..000000000
--- a/MediaBrowser.MediaEncoding/Probing/whitelist.txt
+++ /dev/null
@@ -1 +0,0 @@
-AC/DC \ No newline at end of file