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]; var episode = sortedEpisodes[i];
if (!string.IsNullOrEmpty(episode.File)) 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 streamUrl = BuildStreamUrl(init, episode.File);
string streamLink = $"{episodeLink}&play=true";
episode_tpl.Append( episode_tpl.Append(
episode.Title, episode.Title,
title ?? original_title, title ?? original_title,
season.ToString(), season.ToString(),
(i + 1).ToString("D2"), (i + 1).ToString("D2"),
accsArgs(episodeLink), streamUrl
"call",
streamlink: accsArgs(streamLink)
); );
} }
} }

View File

@ -90,7 +90,15 @@ namespace UAKino.Controllers
int episodeNumber = UAKinoInvoke.TryParseEpisodeNumber(ep.Title) ?? index; int episodeNumber = UAKinoInvoke.TryParseEpisodeNumber(ep.Title) ?? index;
string episodeName = string.IsNullOrEmpty(ep.Title) ? $"Епізод {episodeNumber}" : ep.Title; 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)}"; 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++; index++;
} }

View File

@ -181,11 +181,14 @@ namespace UaTUT
if (!string.IsNullOrEmpty(episodeFile)) if (!string.IsNullOrEmpty(episodeFile))
{ {
// Створюємо прямий лінк на епізод через play action string streamUrl = BuildStreamUrl(init, episodeFile);
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}"; episode_tpl.Append(
episodeName,
// Використовуємо правильний синтаксис EpisodeTpl.Append без poster параметра title ?? original_title,
episode_tpl.Append(episodeName, title ?? original_title, season.ToString(), (i + 1).ToString("D2"), episodeLink, "call"); season.ToString(),
(i + 1).ToString("D2"),
streamUrl
);
} }
} }
} }