From 8bfb4cf2b2ae6c9a826e07c52f11ad3807e94cdf Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Mon, 23 Mar 2020 21:54:27 +0100 Subject: [PATCH] Solving a bug with the GetSubtitle method of the public api --- Kyoo/Views/API/SubtitleAPI.cs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/Kyoo/Views/API/SubtitleAPI.cs b/Kyoo/Views/API/SubtitleAPI.cs index 980a8f8a..9da62cce 100644 --- a/Kyoo/Views/API/SubtitleAPI.cs +++ b/Kyoo/Views/API/SubtitleAPI.cs @@ -23,17 +23,13 @@ namespace Kyoo.Api [HttpGet("{showSlug}-s{seasonNumber:int}e{episodeNumber:int}.{identifier}.{extension?}")] public IActionResult GetSubtitle(string showSlug, int seasonNumber, int episodeNumber, string identifier, string extension) { + string languageTag = identifier.Substring(0, 3); bool forced = identifier.Length > 3 && identifier.Substring(4) == "forced"; - Track subtitle; + Track subtitle = _libraryManager.GetSubtitle(showSlug, seasonNumber, episodeNumber, languageTag, forced); - if (identifier.Length >= 3 && identifier[3] == '-') + if (subtitle == null) { - string languageTag = identifier.Substring(0, 3); - subtitle = _libraryManager.GetSubtitle(showSlug, seasonNumber, episodeNumber, languageTag, forced); - } - else - { - long.TryParse(identifier.Substring(0, 3), out long id); + long.TryParse(identifier.Substring(0, identifier.IndexOf('-')), out long id); subtitle = _libraryManager.GetSubtitleById(id); }