Apply suggestions from code review

Co-authored-by: Claus Vium <cvium@users.noreply.github.com>
This commit is contained in:
Nyanmisaka 2020-11-19 15:02:36 +00:00 committed by GitHub
parent 51dab0958d
commit 5ff08338d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 25 deletions

View File

@ -578,7 +578,7 @@ namespace Jellyfin.Api.Controllers
args += _encodingHelper.GetOutputSizeParam(state, _encodingOptions, codec); args += _encodingHelper.GetOutputSizeParam(state, _encodingOptions, codec);
} }
if (!(state.SubtitleStream != null && state.SubtitleStream.IsExternal && !state.SubtitleStream.IsTextSubtitleStream)) if (state.SubtitleStream == null || !state.SubtitleStream.IsExternal || state.SubtitleStream.IsTextSubtitleStream)
{ {
args += " -start_at_zero"; args += " -start_at_zero";
} }

View File

@ -1025,14 +1025,12 @@ namespace MediaBrowser.MediaEncoding.Probing
if (streamInfo != null && streamInfo.Tags != null) if (streamInfo != null && streamInfo.Tags != null)
{ {
var bps = GetDictionaryValue(streamInfo.Tags, "BPS-eng") ?? GetDictionaryValue(streamInfo.Tags, "BPS"); var bps = GetDictionaryValue(streamInfo.Tags, "BPS-eng") ?? GetDictionaryValue(streamInfo.Tags, "BPS");
if (!string.IsNullOrEmpty(bps)) if (!string.IsNullOrEmpty(bps)
{ && int.TryParse(bps, NumberStyles.Integer, CultureInfo.InvariantCulture, out var parsedBps))
if (int.TryParse(bps, NumberStyles.Integer, CultureInfo.InvariantCulture, out var parsedBps))
{ {
return parsedBps; return parsedBps;
} }
} }
}
return null; return null;
} }
@ -1042,14 +1040,11 @@ namespace MediaBrowser.MediaEncoding.Probing
if (streamInfo != null && streamInfo.Tags != null) if (streamInfo != null && streamInfo.Tags != null)
{ {
var duration = GetDictionaryValue(streamInfo.Tags, "DURATION-eng") ?? GetDictionaryValue(streamInfo.Tags, "DURATION"); var duration = GetDictionaryValue(streamInfo.Tags, "DURATION-eng") ?? GetDictionaryValue(streamInfo.Tags, "DURATION");
if (!string.IsNullOrEmpty(duration)) if (!string.IsNullOrEmpty(duration) && TimeSpan.TryParse(duration, out var parsedDuration))
{
if (TimeSpan.TryParse(duration, out var parsedDuration))
{ {
return parsedDuration.TotalSeconds; return parsedDuration.TotalSeconds;
} }
} }
}
return null; return null;
} }
@ -1059,14 +1054,12 @@ namespace MediaBrowser.MediaEncoding.Probing
if (streamInfo != null && streamInfo.Tags != null) if (streamInfo != null && streamInfo.Tags != null)
{ {
var numberOfBytes = GetDictionaryValue(streamInfo.Tags, "NUMBER_OF_BYTES-eng") ?? GetDictionaryValue(streamInfo.Tags, "NUMBER_OF_BYTES"); var numberOfBytes = GetDictionaryValue(streamInfo.Tags, "NUMBER_OF_BYTES-eng") ?? GetDictionaryValue(streamInfo.Tags, "NUMBER_OF_BYTES");
if (!string.IsNullOrEmpty(numberOfBytes)) if (!string.IsNullOrEmpty(numberOfBytes)
{ && long.TryParse(numberOfBytes, NumberStyles.Integer, CultureInfo.InvariantCulture, out var parsedBytes))
if (long.TryParse(numberOfBytes, NumberStyles.Integer, CultureInfo.InvariantCulture, out var parsedBytes))
{ {
return parsedBytes; return parsedBytes;
} }
} }
}
return null; return null;
} }