From 049361b66cefe7cb26364f9c39ac57abc7826752 Mon Sep 17 00:00:00 2001 From: Nick <20588554+nicknsy@users.noreply.github.com> Date: Wed, 24 May 2023 14:41:38 -0700 Subject: [PATCH] TrickplayController return 404 if playlist doesn't exist. Minor code style/format changes (crobibero) --- .../Controllers/TrickplayController.cs | 31 +++++++++---------- .../Trickplay/TrickplayProvider.cs | 1 - 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/Jellyfin.Api/Controllers/TrickplayController.cs b/Jellyfin.Api/Controllers/TrickplayController.cs index e9ec6a6f4..ac71eff19 100644 --- a/Jellyfin.Api/Controllers/TrickplayController.cs +++ b/Jellyfin.Api/Controllers/TrickplayController.cs @@ -1,9 +1,6 @@ using System; -using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Globalization; -using System.IO; -using System.Linq; using System.Net.Mime; using System.Text; using Jellyfin.Api.Attributes; @@ -50,6 +47,7 @@ public class TrickplayController : BaseJellyfinApiController /// A containing the trickplay tiles file. [HttpGet("Videos/{itemId}/Trickplay/{width}/tiles.m3u8")] [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status404NotFound)] [ProducesPlaylistFile] public ActionResult GetTrickplayHlsPlaylist( [FromRoute, Required] Guid itemId, @@ -109,7 +107,7 @@ public class TrickplayController : BaseJellyfinApiController var resolution = $"{tilesInfo.Width}x{tilesInfo.Height}"; var layout = $"{tilesInfo.TileWidth}x{tilesInfo.TileHeight}"; var tilesPerGrid = tilesInfo.TileWidth * tilesInfo.TileHeight; - var tileDuration = tilesInfo.Interval / 1000m; + var tileDuration = tilesInfo.Interval / 1000d; var infDuration = tileDuration * tilesPerGrid; var tileGridCount = (int)Math.Ceiling((decimal)tilesInfo.TileCount / tilesPerGrid); @@ -132,18 +130,10 @@ public class TrickplayController : BaseJellyfinApiController infDuration = tileDuration * tilesPerGrid; } - var url = string.Format( - CultureInfo.InvariantCulture, - urlFormat, - width.ToString(CultureInfo.InvariantCulture), - i.ToString(CultureInfo.InvariantCulture), - mediaSourceId.ToString("N"), - User.GetToken()); - // EXTINF builder .Append("#EXTINF:") - .Append(string.Format(CultureInfo.InvariantCulture, decimalFormat, infDuration)) + .AppendFormat(CultureInfo.InvariantCulture, decimalFormat, infDuration) .AppendLine(","); // EXT-X-TILES @@ -153,10 +143,19 @@ public class TrickplayController : BaseJellyfinApiController .Append(",LAYOUT=") .Append(layout) .Append(",DURATION=") - .AppendLine(string.Format(CultureInfo.InvariantCulture, decimalFormat, tileDuration)); + .AppendFormat(CultureInfo.InvariantCulture, decimalFormat, tileDuration) + .AppendLine(); // URL - builder.AppendLine(url); + builder + .AppendFormat( + CultureInfo.InvariantCulture, + urlFormat, + width.ToString(CultureInfo.InvariantCulture), + i.ToString(CultureInfo.InvariantCulture), + mediaSourceId.ToString("N"), + User.GetToken()) + .AppendLine(); } builder.AppendLine("#EXT-X-ENDLIST"); @@ -164,6 +163,6 @@ public class TrickplayController : BaseJellyfinApiController } } - return new FileContentResult(Array.Empty(), MimeTypes.GetMimeType("playlist.m3u8")); + return NotFound(); } } diff --git a/MediaBrowser.Providers/Trickplay/TrickplayProvider.cs b/MediaBrowser.Providers/Trickplay/TrickplayProvider.cs index 17e9efdde..f6dcde4f6 100644 --- a/MediaBrowser.Providers/Trickplay/TrickplayProvider.cs +++ b/MediaBrowser.Providers/Trickplay/TrickplayProvider.cs @@ -8,7 +8,6 @@ using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Providers; using MediaBrowser.Controller.Trickplay; using MediaBrowser.Model.Configuration; -using Microsoft.Extensions.Logging; namespace MediaBrowser.Providers.Trickplay;