aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.MediaEncoding
diff options
context:
space:
mode:
authorBond-009 <bond.009@outlook.com>2022-12-07 17:17:37 +0100
committerGitHub <noreply@github.com>2022-12-07 17:17:37 +0100
commit584c80e323ac2a1386d86ff9f59e50daf174418e (patch)
tree4dbb2861cb79cf418a76a4b8f364fdc5c62b56f7 /MediaBrowser.MediaEncoding
parentf3c57e6a0ae015dc51cf548a0380d1bed33959c2 (diff)
parent227aa0540bf0d6c00848b0efb8a5e0ece86c7412 (diff)
Merge pull request #8547 from Bond-009/net7
Diffstat (limited to 'MediaBrowser.MediaEncoding')
-rw-r--r--MediaBrowser.MediaEncoding/Attachments/AttachmentExtractor.cs21
-rw-r--r--MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs5
-rw-r--r--MediaBrowser.MediaEncoding/MediaBrowser.MediaEncoding.csproj6
-rw-r--r--MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs31
4 files changed, 16 insertions, 47 deletions
diff --git a/MediaBrowser.MediaEncoding/Attachments/AttachmentExtractor.cs b/MediaBrowser.MediaEncoding/Attachments/AttachmentExtractor.cs
index 0ee2bdd38..db177ff76 100644
--- a/MediaBrowser.MediaEncoding/Attachments/AttachmentExtractor.cs
+++ b/MediaBrowser.MediaEncoding/Attachments/AttachmentExtractor.cs
@@ -145,15 +145,8 @@ namespace MediaBrowser.MediaEncoding.Attachments
bool isExternal,
CancellationToken cancellationToken)
{
- if (string.IsNullOrEmpty(inputPath))
- {
- throw new ArgumentNullException(nameof(inputPath));
- }
-
- if (string.IsNullOrEmpty(outputPath))
- {
- throw new ArgumentNullException(nameof(outputPath));
- }
+ ArgumentException.ThrowIfNullOrEmpty(inputPath);
+ ArgumentException.ThrowIfNullOrEmpty(outputPath);
Directory.CreateDirectory(outputPath);
@@ -300,15 +293,9 @@ namespace MediaBrowser.MediaEncoding.Attachments
string outputPath,
CancellationToken cancellationToken)
{
- if (string.IsNullOrEmpty(inputPath))
- {
- throw new ArgumentNullException(nameof(inputPath));
- }
+ ArgumentException.ThrowIfNullOrEmpty(inputPath);
- if (string.IsNullOrEmpty(outputPath))
- {
- throw new ArgumentNullException(nameof(outputPath));
- }
+ ArgumentException.ThrowIfNullOrEmpty(outputPath);
Directory.CreateDirectory(Path.GetDirectoryName(outputPath));
diff --git a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs
index addaea33e..ffaf5246d 100644
--- a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs
+++ b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs
@@ -637,10 +637,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
private async Task<string> ExtractImageInternal(string inputPath, string container, MediaStream videoStream, int? imageStreamIndex, Video3DFormat? threedFormat, TimeSpan? offset, bool useIFrame, ImageFormat? targetFormat, CancellationToken cancellationToken)
{
- if (string.IsNullOrEmpty(inputPath))
- {
- throw new ArgumentNullException(nameof(inputPath));
- }
+ ArgumentException.ThrowIfNullOrEmpty(inputPath);
var outputExtension = targetFormat switch
{
diff --git a/MediaBrowser.MediaEncoding/MediaBrowser.MediaEncoding.csproj b/MediaBrowser.MediaEncoding/MediaBrowser.MediaEncoding.csproj
index 2ed654e1c..375041490 100644
--- a/MediaBrowser.MediaEncoding/MediaBrowser.MediaEncoding.csproj
+++ b/MediaBrowser.MediaEncoding/MediaBrowser.MediaEncoding.csproj
@@ -6,7 +6,7 @@
</PropertyGroup>
<PropertyGroup>
- <TargetFramework>net6.0</TargetFramework>
+ <TargetFramework>net7.0</TargetFramework>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>
@@ -28,8 +28,8 @@
<ItemGroup>
<PackageReference Include="BDInfo" Version="0.7.6.2" />
<PackageReference Include="libse" Version="3.6.5" />
- <PackageReference Include="Microsoft.Extensions.Http" Version="6.0.0" />
- <PackageReference Include="System.Text.Encoding.CodePages" Version="6.0.0" />
+ <PackageReference Include="Microsoft.Extensions.Http" Version="7.0.0" />
+ <PackageReference Include="System.Text.Encoding.CodePages" Version="7.0.0" />
<PackageReference Include="UTF.Unknown" Version="2.5.1" />
</ItemGroup>
diff --git a/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs b/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs
index 4bc329a8a..b7c2fd7b1 100644
--- a/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs
+++ b/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs
@@ -179,7 +179,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles
_logger.LogDebug("charset {CharSet} detected for {Path}", result.EncodingName, fileInfo.Path);
using var reader = new StreamReader(stream, result.Encoding);
- var text = await reader.ReadToEndAsync().ConfigureAwait(false);
+ var text = await reader.ReadToEndAsync(cancellationToken).ConfigureAwait(false);
return new MemoryStream(Encoding.UTF8.GetBytes(text));
}
@@ -249,17 +249,14 @@ namespace MediaBrowser.MediaEncoding.Subtitles
private bool TryGetWriter(string format, [NotNullWhen(true)] out ISubtitleWriter? value)
{
+ ArgumentException.ThrowIfNullOrEmpty(format);
+
if (string.Equals(format, SubtitleFormat.ASS, StringComparison.OrdinalIgnoreCase))
{
value = new AssWriter();
return true;
}
- if (string.IsNullOrEmpty(format))
- {
- throw new ArgumentNullException(nameof(format));
- }
-
if (string.Equals(format, "json", StringComparison.OrdinalIgnoreCase))
{
value = new JsonWriter();
@@ -355,15 +352,9 @@ namespace MediaBrowser.MediaEncoding.Subtitles
private async Task ConvertTextSubtitleToSrtInternal(MediaStream subtitleStream, MediaSourceInfo mediaSource, string outputPath, CancellationToken cancellationToken)
{
var inputPath = subtitleStream.Path;
- if (string.IsNullOrEmpty(inputPath))
- {
- throw new ArgumentNullException(nameof(inputPath));
- }
+ ArgumentException.ThrowIfNullOrEmpty(inputPath);
- if (string.IsNullOrEmpty(outputPath))
- {
- throw new ArgumentNullException(nameof(outputPath));
- }
+ ArgumentException.ThrowIfNullOrEmpty(outputPath);
Directory.CreateDirectory(Path.GetDirectoryName(outputPath) ?? throw new ArgumentException($"Provided path ({outputPath}) is not valid.", nameof(outputPath)));
@@ -522,15 +513,9 @@ namespace MediaBrowser.MediaEncoding.Subtitles
string outputPath,
CancellationToken cancellationToken)
{
- if (string.IsNullOrEmpty(inputPath))
- {
- throw new ArgumentNullException(nameof(inputPath));
- }
+ ArgumentException.ThrowIfNullOrEmpty(inputPath);
- if (string.IsNullOrEmpty(outputPath))
- {
- throw new ArgumentNullException(nameof(outputPath));
- }
+ ArgumentException.ThrowIfNullOrEmpty(outputPath);
Directory.CreateDirectory(Path.GetDirectoryName(outputPath) ?? throw new ArgumentException($"Provided path ({outputPath}) is not valid.", nameof(outputPath)));
@@ -650,7 +635,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles
{
encoding = reader.CurrentEncoding;
- text = await reader.ReadToEndAsync().ConfigureAwait(false);
+ text = await reader.ReadToEndAsync(cancellationToken).ConfigureAwait(false);
}
var newText = text.Replace(",Arial,", ",Arial Unicode MS,", StringComparison.Ordinal);