Merge pull request #2830 from Bond-009/dvdlib
DvdLib: remove dependency on MediaBrowser.Model
This commit is contained in:
commit
e1fb24c9ee
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System.Buffers.Binary;
|
||||
using System.IO;
|
||||
|
||||
namespace DvdLib
|
||||
|
@ -12,19 +12,12 @@ namespace DvdLib
|
|||
|
||||
public override ushort ReadUInt16()
|
||||
{
|
||||
return BitConverter.ToUInt16(ReadAndReverseBytes(2), 0);
|
||||
return BinaryPrimitives.ReadUInt16BigEndian(base.ReadBytes(2));
|
||||
}
|
||||
|
||||
public override uint ReadUInt32()
|
||||
{
|
||||
return BitConverter.ToUInt32(ReadAndReverseBytes(4), 0);
|
||||
}
|
||||
|
||||
private byte[] ReadAndReverseBytes(int count)
|
||||
{
|
||||
byte[] val = base.ReadBytes(count);
|
||||
Array.Reverse(val, 0, count);
|
||||
return val;
|
||||
return BinaryPrimitives.ReadUInt32BigEndian(base.ReadBytes(4));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,10 +4,6 @@
|
|||
<Compile Include="..\SharedVersion.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\MediaBrowser.Model\MediaBrowser.Model.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.1</TargetFramework>
|
||||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
||||
|
|
|
@ -2,7 +2,6 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using MediaBrowser.Model.IO;
|
||||
|
||||
namespace DvdLib.Ifo
|
||||
{
|
||||
|
@ -13,13 +12,10 @@ namespace DvdLib.Ifo
|
|||
|
||||
private ushort _titleCount;
|
||||
public readonly Dictionary<ushort, string> VTSPaths = new Dictionary<ushort, string>();
|
||||
private readonly IFileSystem _fileSystem;
|
||||
|
||||
public Dvd(string path, IFileSystem fileSystem)
|
||||
public Dvd(string path)
|
||||
{
|
||||
_fileSystem = fileSystem;
|
||||
Titles = new List<Title>();
|
||||
var allFiles = _fileSystem.GetFiles(path, true).ToList();
|
||||
var allFiles = new DirectoryInfo(path).GetFiles(path, SearchOption.AllDirectories);
|
||||
|
||||
var vmgPath = allFiles.FirstOrDefault(i => string.Equals(i.Name, "VIDEO_TS.IFO", StringComparison.OrdinalIgnoreCase)) ??
|
||||
allFiles.FirstOrDefault(i => string.Equals(i.Name, "VIDEO_TS.BUP", StringComparison.OrdinalIgnoreCase));
|
||||
|
@ -76,7 +72,7 @@ namespace DvdLib.Ifo
|
|||
}
|
||||
}
|
||||
|
||||
private void ReadVTS(ushort vtsNum, IEnumerable<FileSystemMetadata> allFiles)
|
||||
private void ReadVTS(ushort vtsNum, IReadOnlyList<FileInfo> allFiles)
|
||||
{
|
||||
var filename = string.Format("VTS_{0:00}_0.IFO", vtsNum);
|
||||
|
||||
|
|
|
@ -2364,7 +2364,7 @@ namespace Emby.Server.Implementations.Library
|
|||
string videoPath,
|
||||
string[] files)
|
||||
{
|
||||
new SubtitleResolver(BaseItem.LocalizationManager, _fileSystem).AddExternalSubtitleStreams(streams, videoPath, streams.Count, files);
|
||||
new SubtitleResolver(BaseItem.LocalizationManager).AddExternalSubtitleStreams(streams, videoPath, streams.Count, files);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
|
|
@ -46,7 +46,6 @@ namespace MediaBrowser.Providers.MediaInfo
|
|||
private readonly IApplicationPaths _appPaths;
|
||||
private readonly IJsonSerializer _json;
|
||||
private readonly IEncodingManager _encodingManager;
|
||||
private readonly IFileSystem _fileSystem;
|
||||
private readonly IServerConfigurationManager _config;
|
||||
private readonly ISubtitleManager _subtitleManager;
|
||||
private readonly IChapterManager _chapterManager;
|
||||
|
@ -134,7 +133,6 @@ namespace MediaBrowser.Providers.MediaInfo
|
|||
IApplicationPaths appPaths,
|
||||
IJsonSerializer json,
|
||||
IEncodingManager encodingManager,
|
||||
IFileSystem fileSystem,
|
||||
IServerConfigurationManager config,
|
||||
ISubtitleManager subtitleManager,
|
||||
IChapterManager chapterManager,
|
||||
|
@ -149,7 +147,6 @@ namespace MediaBrowser.Providers.MediaInfo
|
|||
_appPaths = appPaths;
|
||||
_json = json;
|
||||
_encodingManager = encodingManager;
|
||||
_fileSystem = fileSystem;
|
||||
_config = config;
|
||||
_subtitleManager = subtitleManager;
|
||||
_chapterManager = chapterManager;
|
||||
|
@ -157,7 +154,7 @@ namespace MediaBrowser.Providers.MediaInfo
|
|||
_channelManager = channelManager;
|
||||
_mediaSourceManager = mediaSourceManager;
|
||||
|
||||
_subtitleResolver = new SubtitleResolver(BaseItem.LocalizationManager, fileSystem);
|
||||
_subtitleResolver = new SubtitleResolver(BaseItem.LocalizationManager);
|
||||
}
|
||||
|
||||
private readonly Task<ItemUpdateType> _cachedTask = Task.FromResult(ItemUpdateType.None);
|
||||
|
@ -202,7 +199,6 @@ namespace MediaBrowser.Providers.MediaInfo
|
|||
_blurayExaminer,
|
||||
_localization,
|
||||
_encodingManager,
|
||||
_fileSystem,
|
||||
_config,
|
||||
_subtitleManager,
|
||||
_chapterManager,
|
||||
|
|
|
@ -39,7 +39,6 @@ namespace MediaBrowser.Providers.MediaInfo
|
|||
private readonly IBlurayExaminer _blurayExaminer;
|
||||
private readonly ILocalizationManager _localization;
|
||||
private readonly IEncodingManager _encodingManager;
|
||||
private readonly IFileSystem _fileSystem;
|
||||
private readonly IServerConfigurationManager _config;
|
||||
private readonly ISubtitleManager _subtitleManager;
|
||||
private readonly IChapterManager _chapterManager;
|
||||
|
@ -56,7 +55,6 @@ namespace MediaBrowser.Providers.MediaInfo
|
|||
IBlurayExaminer blurayExaminer,
|
||||
ILocalizationManager localization,
|
||||
IEncodingManager encodingManager,
|
||||
IFileSystem fileSystem,
|
||||
IServerConfigurationManager config,
|
||||
ISubtitleManager subtitleManager,
|
||||
IChapterManager chapterManager,
|
||||
|
@ -68,7 +66,6 @@ namespace MediaBrowser.Providers.MediaInfo
|
|||
_blurayExaminer = blurayExaminer;
|
||||
_localization = localization;
|
||||
_encodingManager = encodingManager;
|
||||
_fileSystem = fileSystem;
|
||||
_config = config;
|
||||
_subtitleManager = subtitleManager;
|
||||
_chapterManager = chapterManager;
|
||||
|
@ -76,7 +73,8 @@ namespace MediaBrowser.Providers.MediaInfo
|
|||
_mediaSourceManager = mediaSourceManager;
|
||||
}
|
||||
|
||||
public async Task<ItemUpdateType> ProbeVideo<T>(T item,
|
||||
public async Task<ItemUpdateType> ProbeVideo<T>(
|
||||
T item,
|
||||
MetadataRefreshOptions options,
|
||||
CancellationToken cancellationToken)
|
||||
where T : Video
|
||||
|
@ -99,7 +97,6 @@ namespace MediaBrowser.Providers.MediaInfo
|
|||
return ItemUpdateType.MetadataImport;
|
||||
}
|
||||
}
|
||||
|
||||
else if (item.VideoType == VideoType.BluRay)
|
||||
{
|
||||
var inputPath = item.Path;
|
||||
|
@ -130,7 +127,8 @@ namespace MediaBrowser.Providers.MediaInfo
|
|||
return ItemUpdateType.MetadataImport;
|
||||
}
|
||||
|
||||
private Task<Model.MediaInfo.MediaInfo> GetMediaInfo(Video item,
|
||||
private Task<Model.MediaInfo.MediaInfo> GetMediaInfo(
|
||||
Video item,
|
||||
string[] streamFileNames,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
|
@ -145,22 +143,24 @@ namespace MediaBrowser.Providers.MediaInfo
|
|||
protocol = _mediaSourceManager.GetPathProtocol(path);
|
||||
}
|
||||
|
||||
return _mediaEncoder.GetMediaInfo(new MediaInfoRequest
|
||||
{
|
||||
PlayableStreamFileNames = streamFileNames,
|
||||
ExtractChapters = true,
|
||||
MediaType = DlnaProfileType.Video,
|
||||
MediaSource = new MediaSourceInfo
|
||||
return _mediaEncoder.GetMediaInfo(
|
||||
new MediaInfoRequest
|
||||
{
|
||||
Path = path,
|
||||
Protocol = protocol,
|
||||
VideoType = item.VideoType
|
||||
}
|
||||
|
||||
}, cancellationToken);
|
||||
PlayableStreamFileNames = streamFileNames,
|
||||
ExtractChapters = true,
|
||||
MediaType = DlnaProfileType.Video,
|
||||
MediaSource = new MediaSourceInfo
|
||||
{
|
||||
Path = path,
|
||||
Protocol = protocol,
|
||||
VideoType = item.VideoType
|
||||
}
|
||||
},
|
||||
cancellationToken);
|
||||
}
|
||||
|
||||
protected async Task Fetch(Video video,
|
||||
protected async Task Fetch(
|
||||
Video video,
|
||||
CancellationToken cancellationToken,
|
||||
Model.MediaInfo.MediaInfo mediaInfo,
|
||||
BlurayDiscInfo blurayInfo,
|
||||
|
@ -491,12 +491,13 @@ namespace MediaBrowser.Providers.MediaInfo
|
|||
/// <param name="options">The refreshOptions.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>Task.</returns>
|
||||
private async Task AddExternalSubtitles(Video video,
|
||||
private async Task AddExternalSubtitles(
|
||||
Video video,
|
||||
List<MediaStream> currentStreams,
|
||||
MetadataRefreshOptions options,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
var subtitleResolver = new SubtitleResolver(_localization, _fileSystem);
|
||||
var subtitleResolver = new SubtitleResolver(_localization);
|
||||
|
||||
var startIndex = currentStreams.Count == 0 ? 0 : (currentStreams.Select(i => i.Index).Max() + 1);
|
||||
var externalSubtitleStreams = subtitleResolver.GetExternalSubtitleStreams(video, startIndex, options.DirectoryService, false);
|
||||
|
@ -605,7 +606,7 @@ namespace MediaBrowser.Providers.MediaInfo
|
|||
private string[] FetchFromDvdLib(Video item)
|
||||
{
|
||||
var path = item.Path;
|
||||
var dvd = new Dvd(path, _fileSystem);
|
||||
var dvd = new Dvd(path);
|
||||
|
||||
var primaryTitle = dvd.Titles.OrderByDescending(GetRuntime).FirstOrDefault();
|
||||
|
||||
|
|
|
@ -13,7 +13,6 @@ namespace MediaBrowser.Providers.MediaInfo
|
|||
public class SubtitleResolver
|
||||
{
|
||||
private readonly ILocalizationManager _localization;
|
||||
private readonly IFileSystem _fileSystem;
|
||||
|
||||
private static readonly HashSet<string> SubtitleExtensions = new HashSet<string>(StringComparer.OrdinalIgnoreCase)
|
||||
{
|
||||
|
@ -26,16 +25,16 @@ namespace MediaBrowser.Providers.MediaInfo
|
|||
".vtt"
|
||||
};
|
||||
|
||||
public SubtitleResolver(ILocalizationManager localization, IFileSystem fileSystem)
|
||||
public SubtitleResolver(ILocalizationManager localization)
|
||||
{
|
||||
_localization = localization;
|
||||
_fileSystem = fileSystem;
|
||||
}
|
||||
|
||||
public List<MediaStream> GetExternalSubtitleStreams(Video video,
|
||||
int startIndex,
|
||||
IDirectoryService directoryService,
|
||||
bool clearCache)
|
||||
public List<MediaStream> GetExternalSubtitleStreams(
|
||||
Video video,
|
||||
int startIndex,
|
||||
IDirectoryService directoryService,
|
||||
bool clearCache)
|
||||
{
|
||||
var streams = new List<MediaStream>();
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user