The Free Software Media System - Server Backend & API
Add ability to upload (and save) SDH subtitles (#10036)
MBR-00019564248b1082
diff --git a/Jellyfin.Api/Controllers/SubtitleController.cs b/Jellyfin.Api/Controllers/SubtitleController.csindex b3e9d62972..7d02550b68 100644--- a/Jellyfin.Api/Controllers/SubtitleController.cs+++ b/Jellyfin.Api/Controllers/SubtitleController.cs@@ -90,7 +90,7 @@ public class SubtitleController : BaseJellyfinApiController[Authorize(Policy = Policies.RequiresElevation)][ProducesResponseType(StatusCodes.Status204NoContent)][ProducesResponseType(StatusCodes.Status404NotFound)]- public ActionResult<Task> DeleteSubtitle(+ public async Task<ActionResult> DeleteSubtitle([FromRoute, Required] Guid itemId,[FromRoute, Required] int index){@@ -101,7 +101,7 @@ public class SubtitleController : BaseJellyfinApiControllerreturn NotFound();}- _subtitleManager.DeleteSubtitles(item, index);+ await _subtitleManager.DeleteSubtitles(item, index).ConfigureAwait(false);return NoContent();}@@ -416,6 +416,7 @@ public class SubtitleController : BaseJellyfinApiControllerFormat = body.Format,Language = body.Language,IsForced = body.IsForced,+ IsHearingImpaired = body.IsHearingImpaired,Stream = memoryStream}).ConfigureAwait(false);_providerManager.QueueRefresh(video.Id, new MetadataRefreshOptions(new DirectoryService(_fileSystem)), RefreshPriority.High);diff --git a/Jellyfin.Api/Models/SubtitleDtos/UploadSubtitleDto.cs b/Jellyfin.Api/Models/SubtitleDtos/UploadSubtitleDto.csindex 3c903ea6b5..2c45e704bc 100644--- a/Jellyfin.Api/Models/SubtitleDtos/UploadSubtitleDto.cs+++ b/Jellyfin.Api/Models/SubtitleDtos/UploadSubtitleDto.cs@@ -25,6 +25,12 @@ public class UploadSubtitleDto[Required]public bool IsForced { get; set; }+ /// <summary>+ /// Gets or sets a value indicating whether the subtitle is for hearing impaired.+ /// </summary>+ [Required]+ public bool IsHearingImpaired { get; set; }+/// <summary>/// Gets or sets the subtitle data./// </summary>diff --git a/MediaBrowser.Controller/Subtitles/SubtitleResponse.cs b/MediaBrowser.Controller/Subtitles/SubtitleResponse.csindex 85b3e6fbd7..51c29c7a24 100644--- a/MediaBrowser.Controller/Subtitles/SubtitleResponse.cs+++ b/MediaBrowser.Controller/Subtitles/SubtitleResponse.cs@@ -14,6 +14,8 @@ namespace MediaBrowser.Controller.Subtitlespublic bool IsForced { get; set; }+ public bool IsHearingImpaired { get; set; }+public Stream Stream { get; set; }}}diff --git a/MediaBrowser.Providers/Subtitles/SubtitleManager.cs b/MediaBrowser.Providers/Subtitles/SubtitleManager.csindex 0c01c50317..87fd2a3cda 100644--- a/MediaBrowser.Providers/Subtitles/SubtitleManager.cs+++ b/MediaBrowser.Providers/Subtitles/SubtitleManager.cs@@ -200,6 +200,11 @@ namespace MediaBrowser.Providers.SubtitlessaveFileName += ".forced";}+ if (response.IsHearingImpaired)+ {+ saveFileName += ".sdh";+ }+saveFileName += "." + response.Format.ToLowerInvariant();if (saveInMediaFolder)