Solving a bug with the GetSubtitle method of the public api

This commit is contained in:
Zoe Roux 2020-03-23 21:54:27 +01:00
parent 2cfb285c22
commit 8bfb4cf2b2

View File

@ -22,18 +22,14 @@ namespace Kyoo.Api
[HttpGet("{showSlug}-s{seasonNumber:int}e{episodeNumber:int}.{identifier}.{extension?}")] [HttpGet("{showSlug}-s{seasonNumber:int}e{episodeNumber:int}.{identifier}.{extension?}")]
public IActionResult GetSubtitle(string showSlug, int seasonNumber, int episodeNumber, string identifier, string extension) public IActionResult GetSubtitle(string showSlug, int seasonNumber, int episodeNumber, string identifier, string extension)
{
bool forced = identifier.Length > 3 && identifier.Substring(4) == "forced";
Track subtitle;
if (identifier.Length >= 3 && identifier[3] == '-')
{ {
string languageTag = identifier.Substring(0, 3); string languageTag = identifier.Substring(0, 3);
subtitle = _libraryManager.GetSubtitle(showSlug, seasonNumber, episodeNumber, languageTag, forced); bool forced = identifier.Length > 3 && identifier.Substring(4) == "forced";
} Track subtitle = _libraryManager.GetSubtitle(showSlug, seasonNumber, episodeNumber, languageTag, forced);
else
if (subtitle == null)
{ {
long.TryParse(identifier.Substring(0, 3), out long id); long.TryParse(identifier.Substring(0, identifier.IndexOf('-')), out long id);
subtitle = _libraryManager.GetSubtitleById(id); subtitle = _libraryManager.GetSubtitleById(id);
} }