refactor(controllers): consolidate stream URL generation across controllers

Refactor episode link construction to use a common BuildStreamUrl method
in Makhno and UaTUT controllers, and add streamlink support to UAKino
controller. This change standardizes how streaming URLs are generated and
passed to the episode template, reducing code duplication and improving
maintainability.
This commit is contained in:
baliasnyifeliks 2026-02-03 21:16:50 +02:00
parent 6f20e217ee
commit e5e3b38122
3 changed files with 19 additions and 11 deletions

View File

@ -244,16 +244,13 @@ namespace Makhno
var episode = sortedEpisodes[i];
if (!string.IsNullOrEmpty(episode.File))
{
string episodeLink = $"{host}/makhno/play?imdb_id={imdb_id}&title={HttpUtility.UrlEncode(title)}&original_title={HttpUtility.UrlEncode(original_title)}&year={year}&season={season}&t={selectedVoice}&episodeId={episode.Id}";
string streamLink = $"{episodeLink}&play=true";
string streamUrl = BuildStreamUrl(init, episode.File);
episode_tpl.Append(
episode.Title,
title ?? original_title,
season.ToString(),
(i + 1).ToString("D2"),
accsArgs(episodeLink),
"call",
streamlink: accsArgs(streamLink)
streamUrl
);
}
}

View File

@ -90,7 +90,15 @@ namespace UAKino.Controllers
int episodeNumber = UAKinoInvoke.TryParseEpisodeNumber(ep.Title) ?? index;
string episodeName = string.IsNullOrEmpty(ep.Title) ? $"Епізод {episodeNumber}" : ep.Title;
string callUrl = $"{host}/uakino/play?url={HttpUtility.UrlEncode(ep.Url)}&title={HttpUtility.UrlEncode(title ?? original_title)}";
episode_tpl.Append(episodeName, title ?? original_title, "1", episodeNumber.ToString("D2"), accsArgs(callUrl), "call");
episode_tpl.Append(
episodeName,
title ?? original_title,
"1",
episodeNumber.ToString("D2"),
accsArgs(callUrl),
"call",
streamlink: accsArgs($"{callUrl}&play=true")
);
index++;
}

View File

@ -181,11 +181,14 @@ namespace UaTUT
if (!string.IsNullOrEmpty(episodeFile))
{
// Створюємо прямий лінк на епізод через play action
string episodeLink = $"{host}/uatut/play?imdb_id={imdb_id}&kinopoisk_id={kinopoisk_id}&title={HttpUtility.UrlEncode(title)}&original_title={HttpUtility.UrlEncode(original_title)}&year={year}&s={s}&season={season}&t={selectedVoice}&episodeId={episode.Id}";
// Використовуємо правильний синтаксис EpisodeTpl.Append без poster параметра
episode_tpl.Append(episodeName, title ?? original_title, season.ToString(), (i + 1).ToString("D2"), episodeLink, "call");
string streamUrl = BuildStreamUrl(init, episodeFile);
episode_tpl.Append(
episodeName,
title ?? original_title,
season.ToString(),
(i + 1).ToString("D2"),
streamUrl
);
}
}
}