diff options
| author | crobibero <cody@robibe.ro> | 2021-03-25 18:06:25 -0600 |
|---|---|---|
| committer | crobibero <cody@robibe.ro> | 2021-03-25 18:06:25 -0600 |
| commit | 73fe9d3f696e5d144047e173553b1d1dba03c5d1 (patch) | |
| tree | aaa2b258375d588ca93abba413f69808bdd69b12 /Jellyfin.Api/Controllers/SubtitleController.cs | |
| parent | 6946e58ca4ee904615146b3a702663cc630f5ad6 (diff) | |
Allow subtitle format to be set from query parameter.
Diffstat (limited to 'Jellyfin.Api/Controllers/SubtitleController.cs')
| -rw-r--r-- | Jellyfin.Api/Controllers/SubtitleController.cs | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/Jellyfin.Api/Controllers/SubtitleController.cs b/Jellyfin.Api/Controllers/SubtitleController.cs index 16a47f2d8..e260efc9a 100644 --- a/Jellyfin.Api/Controllers/SubtitleController.cs +++ b/Jellyfin.Api/Controllers/SubtitleController.cs @@ -185,6 +185,7 @@ namespace Jellyfin.Api.Controllers /// <param name="itemId">The item id.</param> /// <param name="mediaSourceId">The media source id.</param> /// <param name="index">The subtitle stream index.</param> + /// <param name="routeFormat">The (route) format of the returned subtitle.</param> /// <param name="format">The format of the returned subtitle.</param> /// <param name="endPositionTicks">Optional. The end position of the subtitle in ticks.</param> /// <param name="copyTimestamps">Optional. Whether to copy the timestamps.</param> @@ -192,19 +193,25 @@ namespace Jellyfin.Api.Controllers /// <param name="startPositionTicks">Optional. The start position of the subtitle in ticks.</param> /// <response code="200">File returned.</response> /// <returns>A <see cref="FileContentResult"/> with the subtitle file.</returns> - [HttpGet("Videos/{itemId}/{mediaSourceId}/Subtitles/{index}/Stream.{format}")] + [HttpGet("Videos/{itemId}/{mediaSourceId}/Subtitles/{index}/Stream.{routeFormat}")] [ProducesResponseType(StatusCodes.Status200OK)] [ProducesFile("text/*")] public async Task<ActionResult> GetSubtitle( [FromRoute, Required] Guid itemId, [FromRoute, Required] string mediaSourceId, [FromRoute, Required] int index, - [FromRoute, Required] string format, + [FromRoute, Required] string routeFormat, + [FromQuery] string? format, [FromQuery] long? endPositionTicks, [FromQuery] bool copyTimestamps = false, [FromQuery] bool addVttTimeMap = false, [FromQuery] long startPositionTicks = 0) { + if (string.IsNullOrEmpty(format)) + { + format = routeFormat; + } + if (string.Equals(format, "js", StringComparison.OrdinalIgnoreCase)) { format = "json"; @@ -255,13 +262,14 @@ namespace Jellyfin.Api.Controllers /// <param name="mediaSourceId">The media source id.</param> /// <param name="index">The subtitle stream index.</param> /// <param name="startPositionTicks">Optional. The start position of the subtitle in ticks.</param> + /// <param name="routeFormat">The (route) format of the returned subtitle.</param> /// <param name="format">The format of the returned subtitle.</param> /// <param name="endPositionTicks">Optional. The end position of the subtitle in ticks.</param> /// <param name="copyTimestamps">Optional. Whether to copy the timestamps.</param> /// <param name="addVttTimeMap">Optional. Whether to add a VTT time map.</param> /// <response code="200">File returned.</response> /// <returns>A <see cref="FileContentResult"/> with the subtitle file.</returns> - [HttpGet("Videos/{itemId}/{mediaSourceId}/Subtitles/{index}/{startPositionTicks}/Stream.{format}")] + [HttpGet("Videos/{itemId}/{mediaSourceId}/Subtitles/{index}/{startPositionTicks}/Stream.{routeFormat}")] [ProducesResponseType(StatusCodes.Status200OK)] [ProducesFile("text/*")] public Task<ActionResult> GetSubtitleWithTicks( @@ -269,7 +277,8 @@ namespace Jellyfin.Api.Controllers [FromRoute, Required] string mediaSourceId, [FromRoute, Required] int index, [FromRoute, Required] long startPositionTicks, - [FromRoute, Required] string format, + [FromRoute, Required] string routeFormat, + [FromQuery] string? format, [FromQuery] long? endPositionTicks, [FromQuery] bool copyTimestamps = false, [FromQuery] bool addVttTimeMap = false) @@ -278,6 +287,7 @@ namespace Jellyfin.Api.Controllers itemId, mediaSourceId, index, + routeFormat, format, endPositionTicks, copyTimestamps, |
