From e5e3b381221674693e926e448f994495a26711c5 Mon Sep 17 00:00:00 2001 From: baliasnyifeliks Date: Tue, 3 Feb 2026 21:16:50 +0200 Subject: [PATCH] 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. --- Makhno/Controller.cs | 7 ++----- UAKino/Controller.cs | 10 +++++++++- UaTUT/Controller.cs | 13 ++++++++----- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/Makhno/Controller.cs b/Makhno/Controller.cs index 157b1f0..73d81e4 100644 --- a/Makhno/Controller.cs +++ b/Makhno/Controller.cs @@ -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 ); } } diff --git a/UAKino/Controller.cs b/UAKino/Controller.cs index 71d1b3e..7dc3909 100644 --- a/UAKino/Controller.cs +++ b/UAKino/Controller.cs @@ -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++; } diff --git a/UaTUT/Controller.cs b/UaTUT/Controller.cs index f2e35fd..f6b9825 100644 --- a/UaTUT/Controller.cs +++ b/UaTUT/Controller.cs @@ -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 + ); } } }