diff options
| author | Bond_009 <bond.009@outlook.com> | 2023-10-11 13:43:43 +0200 |
|---|---|---|
| committer | Bond_009 <bond.009@outlook.com> | 2023-10-11 13:43:43 +0200 |
| commit | 35d63ec540ced98e9f1eebf9a786714abc9ec82e (patch) | |
| tree | 9a580d64b6bd135eeea1b8051b0c4aef85c92cd7 | |
| parent | 26571a8c51b9670f198e58175463e1d3db5441ee (diff) | |
Fix regression
| -rw-r--r-- | Jellyfin.Api/Helpers/StreamingHelpers.cs | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/Jellyfin.Api/Helpers/StreamingHelpers.cs b/Jellyfin.Api/Helpers/StreamingHelpers.cs index a653c5795..11f6bcf6b 100644 --- a/Jellyfin.Api/Helpers/StreamingHelpers.cs +++ b/Jellyfin.Api/Helpers/StreamingHelpers.cs @@ -421,13 +421,12 @@ public static class StreamingHelpers /// <param name="state">The state.</param> /// <param name="mediaSource">The mediaSource.</param> /// <returns>System.String.</returns> - private static string? GetOutputFileExtension(StreamState state, MediaSourceInfo? mediaSource) + private static string GetOutputFileExtension(StreamState state, MediaSourceInfo? mediaSource) { - var ext = Path.GetExtension(state.RequestedUrl.AsSpan()); - - if (ext.IsEmpty) + var ext = Path.GetExtension(state.RequestedUrl); + if (!string.IsNullOrEmpty(ext)) { - return null; + return ext; } // Try to infer based on the desired video codec @@ -463,10 +462,9 @@ public static class StreamingHelpers return ".asf"; } } - - // Try to infer based on the desired audio codec - if (!state.IsVideoRequest) + else { + // Try to infer based on the desired audio codec var audioCodec = state.Request.AudioCodec; if (string.Equals("aac", audioCodec, StringComparison.OrdinalIgnoreCase)) @@ -497,7 +495,7 @@ public static class StreamingHelpers return '.' + (idx == -1 ? mediaSource.Container : mediaSource.Container[..idx]).Trim(); } - return null; + throw new InvalidOperationException("Failed to find an appropriate file extension"); } /// <summary> @@ -509,12 +507,12 @@ public static class StreamingHelpers /// <param name="deviceId">The device id.</param> /// <param name="playSessionId">The play session id.</param> /// <returns>The complete file path, including the folder, for the transcoding file.</returns> - private static string GetOutputFilePath(StreamState state, string? outputFileExtension, IServerConfigurationManager serverConfigurationManager, string? deviceId, string? playSessionId) + private static string GetOutputFilePath(StreamState state, string outputFileExtension, IServerConfigurationManager serverConfigurationManager, string? deviceId, string? playSessionId) { var data = $"{state.MediaPath}-{state.UserAgent}-{deviceId!}-{playSessionId!}"; var filename = data.GetMD5().ToString("N", CultureInfo.InvariantCulture); - var ext = outputFileExtension?.ToLowerInvariant(); + var ext = outputFileExtension.ToLowerInvariant(); var folder = serverConfigurationManager.GetTranscodePath(); return Path.Combine(folder, filename + ext); |
