parent
47aa07c342
commit
0da5255f12
@ -1,83 +1,123 @@
|
||||
#pragma warning disable CS1591
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using BDInfo.IO;
|
||||
using MediaBrowser.Model.IO;
|
||||
|
||||
namespace MediaBrowser.MediaEncoding.BdInfo
|
||||
namespace MediaBrowser.MediaEncoding.BdInfo;
|
||||
|
||||
/// <summary>
|
||||
/// Class BdInfoDirectoryInfo.
|
||||
/// </summary>
|
||||
public class BdInfoDirectoryInfo : IDirectoryInfo
|
||||
{
|
||||
public class BdInfoDirectoryInfo : IDirectoryInfo
|
||||
{
|
||||
private readonly IFileSystem _fileSystem;
|
||||
private readonly IFileSystem _fileSystem;
|
||||
|
||||
private readonly FileSystemMetadata _impl;
|
||||
private readonly FileSystemMetadata _impl;
|
||||
|
||||
public BdInfoDirectoryInfo(IFileSystem fileSystem, string path)
|
||||
{
|
||||
_fileSystem = fileSystem;
|
||||
_impl = _fileSystem.GetDirectoryInfo(path);
|
||||
}
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="BdInfoDirectoryInfo" /> class.
|
||||
/// </summary>
|
||||
/// <param name="fileSystem">The filesystem.</param>
|
||||
/// <param name="path">The path.</param>
|
||||
public BdInfoDirectoryInfo(IFileSystem fileSystem, string path)
|
||||
{
|
||||
_fileSystem = fileSystem;
|
||||
_impl = _fileSystem.GetDirectoryInfo(path);
|
||||
}
|
||||
|
||||
private BdInfoDirectoryInfo(IFileSystem fileSystem, FileSystemMetadata impl)
|
||||
{
|
||||
_fileSystem = fileSystem;
|
||||
_impl = impl;
|
||||
}
|
||||
private BdInfoDirectoryInfo(IFileSystem fileSystem, FileSystemMetadata impl)
|
||||
{
|
||||
_fileSystem = fileSystem;
|
||||
_impl = impl;
|
||||
}
|
||||
|
||||
public string Name => _impl.Name;
|
||||
/// <summary>
|
||||
/// Gets the name.
|
||||
/// </summary>
|
||||
public string Name => _impl.Name;
|
||||
|
||||
public string FullName => _impl.FullName;
|
||||
/// <summary>
|
||||
/// Gets the full name.
|
||||
/// </summary>
|
||||
public string FullName => _impl.FullName;
|
||||
|
||||
public IDirectoryInfo? Parent
|
||||
/// <summary>
|
||||
/// Gets the parent directory information.
|
||||
/// </summary>
|
||||
public IDirectoryInfo? Parent
|
||||
{
|
||||
get
|
||||
{
|
||||
get
|
||||
var parentFolder = Path.GetDirectoryName(_impl.FullName);
|
||||
if (parentFolder is not null)
|
||||
{
|
||||
var parentFolder = System.IO.Path.GetDirectoryName(_impl.FullName);
|
||||
if (parentFolder is not null)
|
||||
{
|
||||
return new BdInfoDirectoryInfo(_fileSystem, parentFolder);
|
||||
}
|
||||
|
||||
return null;
|
||||
return new BdInfoDirectoryInfo(_fileSystem, parentFolder);
|
||||
}
|
||||
}
|
||||
|
||||
public IDirectoryInfo[] GetDirectories()
|
||||
{
|
||||
return Array.ConvertAll(
|
||||
_fileSystem.GetDirectories(_impl.FullName).ToArray(),
|
||||
x => new BdInfoDirectoryInfo(_fileSystem, x));
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public IFileInfo[] GetFiles()
|
||||
{
|
||||
return Array.ConvertAll(
|
||||
_fileSystem.GetFiles(_impl.FullName).ToArray(),
|
||||
x => new BdInfoFileInfo(x));
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets the directories.
|
||||
/// </summary>
|
||||
/// <returns>An array with all directories.</returns>
|
||||
public IDirectoryInfo[] GetDirectories()
|
||||
{
|
||||
return _fileSystem.GetDirectories(_impl.FullName)
|
||||
.Select(x => new BdInfoDirectoryInfo(_fileSystem, x))
|
||||
.ToArray();
|
||||
}
|
||||
|
||||
public IFileInfo[] GetFiles(string searchPattern)
|
||||
{
|
||||
return Array.ConvertAll(
|
||||
_fileSystem.GetFiles(_impl.FullName, new[] { searchPattern }, false, false).ToArray(),
|
||||
x => new BdInfoFileInfo(x));
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets the files.
|
||||
/// </summary>
|
||||
/// <returns>All files of the directory.</returns>
|
||||
public IFileInfo[] GetFiles()
|
||||
{
|
||||
return _fileSystem.GetFiles(_impl.FullName)
|
||||
.Select(x => new BdInfoFileInfo(x))
|
||||
.ToArray();
|
||||
}
|
||||
|
||||
public IFileInfo[] GetFiles(string searchPattern, System.IO.SearchOption searchOption)
|
||||
{
|
||||
return Array.ConvertAll(
|
||||
_fileSystem.GetFiles(
|
||||
_impl.FullName,
|
||||
new[] { searchPattern },
|
||||
false,
|
||||
(searchOption & System.IO.SearchOption.AllDirectories) == System.IO.SearchOption.AllDirectories).ToArray(),
|
||||
x => new BdInfoFileInfo(x));
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets the files matching a pattern.
|
||||
/// </summary>
|
||||
/// <param name="searchPattern">The search pattern.</param>
|
||||
/// <returns>All files of the directory matchign the search pattern.</returns>
|
||||
public IFileInfo[] GetFiles(string searchPattern)
|
||||
{
|
||||
return _fileSystem.GetFiles(_impl.FullName, new[] { searchPattern }, false, false)
|
||||
.Select(x => new BdInfoFileInfo(x))
|
||||
.ToArray();
|
||||
}
|
||||
|
||||
public static IDirectoryInfo FromFileSystemPath(IFileSystem fs, string path)
|
||||
{
|
||||
return new BdInfoDirectoryInfo(fs, path);
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets the files matching a pattern and search options.
|
||||
/// </summary>
|
||||
/// <param name="searchPattern">The search pattern.</param>
|
||||
/// <param name="searchOption">The search optin.</param>
|
||||
/// <returns>All files of the directory matchign the search pattern and options.</returns>
|
||||
public IFileInfo[] GetFiles(string searchPattern, SearchOption searchOption)
|
||||
{
|
||||
return _fileSystem.GetFiles(
|
||||
_impl.FullName,
|
||||
new[] { searchPattern },
|
||||
false,
|
||||
(searchOption & SearchOption.AllDirectories) == SearchOption.AllDirectories)
|
||||
.Select(x => new BdInfoFileInfo(x))
|
||||
.ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the bdinfo of a file system path.
|
||||
/// </summary>
|
||||
/// <param name="fs">The file system.</param>
|
||||
/// <param name="path">The path.</param>
|
||||
/// <returns>The BD directory information of the path on the file system.</returns>
|
||||
public static IDirectoryInfo FromFileSystemPath(IFileSystem fs, string path)
|
||||
{
|
||||
return new BdInfoDirectoryInfo(fs, path);
|
||||
}
|
||||
}
|
||||
|
@ -1,41 +1,68 @@
|
||||
#pragma warning disable CS1591
|
||||
|
||||
using System.IO;
|
||||
using MediaBrowser.Model.IO;
|
||||
|
||||
namespace MediaBrowser.MediaEncoding.BdInfo
|
||||
namespace MediaBrowser.MediaEncoding.BdInfo;
|
||||
|
||||
/// <summary>
|
||||
/// Class BdInfoFileInfo.
|
||||
/// </summary>
|
||||
public class BdInfoFileInfo : BDInfo.IO.IFileInfo
|
||||
{
|
||||
public class BdInfoFileInfo : BDInfo.IO.IFileInfo
|
||||
{
|
||||
private FileSystemMetadata _impl;
|
||||
private FileSystemMetadata _impl;
|
||||
|
||||
public BdInfoFileInfo(FileSystemMetadata impl)
|
||||
{
|
||||
_impl = impl;
|
||||
}
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="BdInfoFileInfo" /> class.
|
||||
/// </summary>
|
||||
/// <param name="impl">The <see cref="FileSystemMetadata" />.</param>
|
||||
public BdInfoFileInfo(FileSystemMetadata impl)
|
||||
{
|
||||
_impl = impl;
|
||||
}
|
||||
|
||||
public string Name => _impl.Name;
|
||||
/// <summary>
|
||||
/// Gets the name.
|
||||
/// </summary>
|
||||
public string Name => _impl.Name;
|
||||
|
||||
public string FullName => _impl.FullName;
|
||||
/// <summary>
|
||||
/// Gets the full name.
|
||||
/// </summary>
|
||||
public string FullName => _impl.FullName;
|
||||
|
||||
public string Extension => _impl.Extension;
|
||||
/// <summary>
|
||||
/// Gets the extension.
|
||||
/// </summary>
|
||||
public string Extension => _impl.Extension;
|
||||
|
||||
public long Length => _impl.Length;
|
||||
/// <summary>
|
||||
/// Gets the length.
|
||||
/// </summary>
|
||||
public long Length => _impl.Length;
|
||||
|
||||
public bool IsDir => _impl.IsDirectory;
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether this is a directory.
|
||||
/// </summary>
|
||||
public bool IsDir => _impl.IsDirectory;
|
||||
|
||||
public Stream OpenRead()
|
||||
{
|
||||
return new FileStream(
|
||||
FullName,
|
||||
FileMode.Open,
|
||||
FileAccess.Read,
|
||||
FileShare.Read);
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets a file as file stream.
|
||||
/// </summary>
|
||||
/// <returns>A <see cref="FileStream" /> for the file.</returns>
|
||||
public Stream OpenRead()
|
||||
{
|
||||
return new FileStream(
|
||||
FullName,
|
||||
FileMode.Open,
|
||||
FileAccess.Read,
|
||||
FileShare.Read);
|
||||
}
|
||||
|
||||
public StreamReader OpenText()
|
||||
{
|
||||
return new StreamReader(OpenRead());
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets a files's content with a stream reader.
|
||||
/// </summary>
|
||||
/// <returns>A <see cref="StreamReader" /> for the file's content.</returns>
|
||||
public StreamReader OpenText()
|
||||
{
|
||||
return new StreamReader(OpenRead());
|
||||
}
|
||||
}
|
||||
|
@ -1,39 +1,41 @@
|
||||
#nullable disable
|
||||
#pragma warning disable CS1591
|
||||
|
||||
using MediaBrowser.Model.Entities;
|
||||
|
||||
namespace MediaBrowser.Model.MediaInfo
|
||||
namespace MediaBrowser.Model.MediaInfo;
|
||||
|
||||
/// <summary>
|
||||
/// Represents the result of BDInfo output.
|
||||
/// </summary>
|
||||
public class BlurayDiscInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the result of BDInfo output.
|
||||
/// Gets or sets the media streams.
|
||||
/// </summary>
|
||||
public class BlurayDiscInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the media streams.
|
||||
/// </summary>
|
||||
/// <value>The media streams.</value>
|
||||
public MediaStream[] MediaStreams { get; set; }
|
||||
/// <value>The media streams.</value>
|
||||
public MediaStream[] MediaStreams { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the run time ticks.
|
||||
/// </summary>
|
||||
/// <value>The run time ticks.</value>
|
||||
public long? RunTimeTicks { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the run time ticks.
|
||||
/// </summary>
|
||||
/// <value>The run time ticks.</value>
|
||||
public long? RunTimeTicks { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the files.
|
||||
/// </summary>
|
||||
/// <value>The files.</value>
|
||||
public string[] Files { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the files.
|
||||
/// </summary>
|
||||
/// <value>The files.</value>
|
||||
public string[] Files { get; set; }
|
||||
|
||||
public string PlaylistName { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the playlist name.
|
||||
/// </summary>
|
||||
/// <value>The playlist name.</value>
|
||||
public string PlaylistName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the chapters.
|
||||
/// </summary>
|
||||
/// <value>The chapters.</value>
|
||||
public double[] Chapters { get; set; }
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets or sets the chapters.
|
||||
/// </summary>
|
||||
/// <value>The chapters.</value>
|
||||
public double[] Chapters { get; set; }
|
||||
}
|
||||
|
@ -1,15 +1,14 @@
|
||||
namespace MediaBrowser.Model.MediaInfo
|
||||
namespace MediaBrowser.Model.MediaInfo;
|
||||
|
||||
/// <summary>
|
||||
/// Interface IBlurayExaminer.
|
||||
/// </summary>
|
||||
public interface IBlurayExaminer
|
||||
{
|
||||
/// <summary>
|
||||
/// Interface IBlurayExaminer.
|
||||
/// Gets the disc info.
|
||||
/// </summary>
|
||||
public interface IBlurayExaminer
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the disc info.
|
||||
/// </summary>
|
||||
/// <param name="path">The path.</param>
|
||||
/// <returns>BlurayDiscInfo.</returns>
|
||||
BlurayDiscInfo GetDiscInfo(string path);
|
||||
}
|
||||
/// <param name="path">The path.</param>
|
||||
/// <returns>BlurayDiscInfo.</returns>
|
||||
BlurayDiscInfo GetDiscInfo(string path);
|
||||
}
|
||||
|
Loading…
Reference in new issue