diff options
| author | Luke <luke.pulverenti@gmail.com> | 2016-10-30 03:29:27 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-10-30 03:29:27 -0400 |
| commit | d31b0f7be4b14e4ada999c97e675b856ad68352b (patch) | |
| tree | a4619513efbb3be62a6204c996526df606cb62c5 /MediaBrowser.MediaEncoding | |
| parent | b19f75fcae017cb51f1e58eb2d54ca84620b6ee0 (diff) | |
| parent | 3094cd7ff3e51578808ce1b6f56b141930c18004 (diff) | |
Merge pull request #2258 from MediaBrowser/dev
Dev
Diffstat (limited to 'MediaBrowser.MediaEncoding')
8 files changed, 44 insertions, 43 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 8f8a7a819..89e0b61c1 100644 --- a/MediaBrowser.MediaEncoding/MediaBrowser.MediaEncoding.csproj +++ b/MediaBrowser.MediaEncoding/MediaBrowser.MediaEncoding.csproj @@ -44,8 +44,9 @@ <Reference Include="Microsoft.CSharp" /> <Reference Include="System.Data" /> <Reference Include="System.Xml" /> - <Reference Include="UniversalDetector"> - <HintPath>..\ThirdParty\UniversalDetector\UniversalDetector.dll</HintPath> + <Reference Include="UniversalDetector, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> + <HintPath>..\packages\UniversalDetector.1.0.1\lib\portable-net45+sl4+wp71+win8+wpa81\UniversalDetector.dll</HintPath> + <Private>True</Private> </Reference> </ItemGroup> <ItemGroup> @@ -83,7 +84,7 @@ <Compile Include="Subtitles\VttWriter.cs" /> </ItemGroup> <ItemGroup> - <ProjectReference Include="..\..\BdInfo\BDInfo\BDInfo.csproj"> + <ProjectReference Include="..\BDInfo\BDInfo.csproj"> <Project>{88ae38df-19d7-406f-a6a9-09527719a21e}</Project> <Name>BDInfo</Name> </ProjectReference> @@ -105,7 +106,7 @@ </ProjectReference> </ItemGroup> <ItemGroup> - <EmbeddedResource Include="Probing\whitelist.txt" /> + <None Include="packages.config" /> </ItemGroup> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <!-- To modify your build process, add your task inside one of the targets below and uncomment it. diff --git a/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs b/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs index 90ae203e7..96c3bf6a0 100644 --- a/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs +++ b/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs @@ -400,7 +400,11 @@ namespace MediaBrowser.MediaEncoding.Probing private string NormalizeSubtitleCodec(string codec) { - if ((codec ?? string.Empty).IndexOf("PGS", StringComparison.OrdinalIgnoreCase) != -1) + if (string.Equals(codec, "dvb_subtitle", StringComparison.OrdinalIgnoreCase)) + { + codec = "dvbsub"; + } + else if ((codec ?? string.Empty).IndexOf("PGS", StringComparison.OrdinalIgnoreCase) != -1) { codec = "PGSSUB"; } @@ -969,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 diff --git a/MediaBrowser.MediaEncoding/packages.config b/MediaBrowser.MediaEncoding/packages.config new file mode 100644 index 000000000..bac7840a5 --- /dev/null +++ b/MediaBrowser.MediaEncoding/packages.config @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="utf-8"?> +<packages> + <package id="UniversalDetector" version="1.0.1" targetFramework="net46" /> +</packages>
\ No newline at end of file |
