From cd6724b4525694e097858762e1efbbbcb93cece4 Mon Sep 17 00:00:00 2001 From: Felix Date: Sat, 21 Feb 2026 13:37:58 +0200 Subject: [PATCH] refactor: strip year prefix from movie titles MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Extract StripMoviePrefix method across all movie providers to remove year prefixes (e.g., "2023 - Movie Title" → "Movie Title") from displayed titles. Simplify label construction in UaTUT controller by removing redundant movie name prefix from variant labels. --- AnimeON/AnimeONInvoke.cs | 23 ++++++++++++++++++++++- KlonFUN/KlonFUNInvoke.cs | 23 ++++++++++++++++++++++- Makhno/MakhnoInvoke.cs | 23 ++++++++++++++++++++++- Mikai/MikaiInvoke.cs | 23 ++++++++++++++++++++++- UaTUT/Controller.cs | 4 +--- UaTUT/UaTUTInvoke.cs | 23 ++++++++++++++++++++++- Uaflix/UaflixInvoke.cs | 23 ++++++++++++++++++++++- 7 files changed, 133 insertions(+), 9 deletions(-) diff --git a/AnimeON/AnimeONInvoke.cs b/AnimeON/AnimeONInvoke.cs index 1c16d60..9be9108 100644 --- a/AnimeON/AnimeONInvoke.cs +++ b/AnimeON/AnimeONInvoke.cs @@ -320,7 +320,7 @@ namespace AnimeON private static string BuildDisplayTitle(string rawTitle, string link, int index) { - string normalized = string.IsNullOrWhiteSpace(rawTitle) ? $"Варіант {index}" : WebUtility.HtmlDecode(rawTitle).Trim(); + string normalized = string.IsNullOrWhiteSpace(rawTitle) ? $"Варіант {index}" : StripMoviePrefix(WebUtility.HtmlDecode(rawTitle).Trim()); string qualityTag = DetectQualityTag($"{normalized} {link}"); if (string.IsNullOrWhiteSpace(qualityTag)) return normalized; @@ -345,6 +345,27 @@ namespace AnimeON return null; } + private static string StripMoviePrefix(string title) + { + if (string.IsNullOrWhiteSpace(title)) + return title; + + string normalized = Regex.Replace(title, @"\s+", " ").Trim(); + int sepIndex = normalized.LastIndexOf(" - ", StringComparison.Ordinal); + if (sepIndex <= 0 || sepIndex >= normalized.Length - 3) + return normalized; + + string prefix = normalized.Substring(0, sepIndex).Trim(); + string suffix = normalized.Substring(sepIndex + 3).Trim(); + if (string.IsNullOrWhiteSpace(suffix)) + return normalized; + + if (Regex.IsMatch(prefix, @"(19|20)\d{2}")) + return suffix; + + return normalized; + } + private static string ExtractPlayerFileArray(string html) { if (string.IsNullOrWhiteSpace(html)) diff --git a/KlonFUN/KlonFUNInvoke.cs b/KlonFUN/KlonFUNInvoke.cs index 798dbbf..2505eea 100644 --- a/KlonFUN/KlonFUNInvoke.cs +++ b/KlonFUN/KlonFUNInvoke.cs @@ -650,7 +650,7 @@ namespace KlonFUN private static string FormatMovieTitle(string rawTitle, string streamUrl, int index) { - string title = CleanText(rawTitle); + string title = StripMoviePrefix(CleanText(rawTitle)); if (string.IsNullOrWhiteSpace(title)) title = $"Варіант {index}"; @@ -664,6 +664,27 @@ namespace KlonFUN return $"{tag} {title}"; } + private static string StripMoviePrefix(string title) + { + if (string.IsNullOrWhiteSpace(title)) + return title; + + string normalized = Regex.Replace(title, @"\s+", " ").Trim(); + int sepIndex = normalized.LastIndexOf(" - ", StringComparison.Ordinal); + if (sepIndex <= 0 || sepIndex >= normalized.Length - 3) + return normalized; + + string prefix = normalized.Substring(0, sepIndex).Trim(); + string suffix = normalized.Substring(sepIndex + 3).Trim(); + if (string.IsNullOrWhiteSpace(suffix)) + return normalized; + + if (Regex.IsMatch(prefix, @"(19|20)\d{2}")) + return suffix; + + return normalized; + } + private static string DetectQualityTag(string source) { if (string.IsNullOrWhiteSpace(source)) diff --git a/Makhno/MakhnoInvoke.cs b/Makhno/MakhnoInvoke.cs index cb1839a..3dd3e89 100644 --- a/Makhno/MakhnoInvoke.cs +++ b/Makhno/MakhnoInvoke.cs @@ -615,7 +615,7 @@ namespace Makhno private static string BuildMovieTitle(string rawTitle, string file, int index) { - string title = string.IsNullOrWhiteSpace(rawTitle) ? $"Варіант {index}" : WebUtility.HtmlDecode(rawTitle).Trim(); + string title = string.IsNullOrWhiteSpace(rawTitle) ? $"Варіант {index}" : StripMoviePrefix(WebUtility.HtmlDecode(rawTitle).Trim()); string qualityTag = DetectQualityTag($"{title} {file}"); if (string.IsNullOrWhiteSpace(qualityTag)) @@ -641,6 +641,27 @@ namespace Makhno return null; } + private static string StripMoviePrefix(string title) + { + if (string.IsNullOrWhiteSpace(title)) + return title; + + string normalized = Regex.Replace(title, @"\s+", " ").Trim(); + int sepIndex = normalized.LastIndexOf(" - ", StringComparison.Ordinal); + if (sepIndex <= 0 || sepIndex >= normalized.Length - 3) + return normalized; + + string prefix = normalized.Substring(0, sepIndex).Trim(); + string suffix = normalized.Substring(sepIndex + 3).Trim(); + if (string.IsNullOrWhiteSpace(suffix)) + return normalized; + + if (Regex.IsMatch(prefix, @"(19|20)\d{2}")) + return suffix; + + return normalized; + } + public string ExtractAshdiPath(string value) { if (string.IsNullOrWhiteSpace(value)) diff --git a/Mikai/MikaiInvoke.cs b/Mikai/MikaiInvoke.cs index 22834cf..e8e4c60 100644 --- a/Mikai/MikaiInvoke.cs +++ b/Mikai/MikaiInvoke.cs @@ -266,7 +266,7 @@ namespace Mikai private static string BuildDisplayTitle(string rawTitle, string link, int index) { - string normalized = string.IsNullOrWhiteSpace(rawTitle) ? $"Варіант {index}" : WebUtility.HtmlDecode(rawTitle).Trim(); + string normalized = string.IsNullOrWhiteSpace(rawTitle) ? $"Варіант {index}" : StripMoviePrefix(WebUtility.HtmlDecode(rawTitle).Trim()); string qualityTag = DetectQualityTag($"{normalized} {link}"); if (string.IsNullOrWhiteSpace(qualityTag)) return normalized; @@ -291,6 +291,27 @@ namespace Mikai return null; } + private static string StripMoviePrefix(string title) + { + if (string.IsNullOrWhiteSpace(title)) + return title; + + string normalized = Regex.Replace(title, @"\s+", " ").Trim(); + int sepIndex = normalized.LastIndexOf(" - ", StringComparison.Ordinal); + if (sepIndex <= 0 || sepIndex >= normalized.Length - 3) + return normalized; + + string prefix = normalized.Substring(0, sepIndex).Trim(); + string suffix = normalized.Substring(sepIndex + 3).Trim(); + if (string.IsNullOrWhiteSpace(suffix)) + return normalized; + + if (Regex.IsMatch(prefix, @"(19|20)\d{2}")) + return suffix; + + return normalized; + } + private static string ExtractPlayerFileArray(string html) { if (string.IsNullOrWhiteSpace(html)) diff --git a/UaTUT/Controller.cs b/UaTUT/Controller.cs index bfd7bfa..303cd14 100644 --- a/UaTUT/Controller.cs +++ b/UaTUT/Controller.cs @@ -298,14 +298,12 @@ namespace UaTUT if (movieStreams.Count == 0) continue; - string movieName = $"{movie.Title} ({movie.Year})"; foreach (var variant in movieStreams) { - string variantName = !string.IsNullOrWhiteSpace(variant.Title) + string label = !string.IsNullOrWhiteSpace(variant.Title) ? variant.Title : "Варіант"; - string label = $"{movieName} - {variantName}"; movie_tpl.Append(label, BuildStreamUrl(init, variant.File)); } } diff --git a/UaTUT/UaTUTInvoke.cs b/UaTUT/UaTUTInvoke.cs index 783ba23..1c3c561 100644 --- a/UaTUT/UaTUTInvoke.cs +++ b/UaTUT/UaTUTInvoke.cs @@ -329,7 +329,7 @@ namespace UaTUT private static string BuildMovieTitle(string rawTitle, string file, int index) { - string title = string.IsNullOrWhiteSpace(rawTitle) ? $"Варіант {index}" : WebUtility.HtmlDecode(rawTitle).Trim(); + string title = string.IsNullOrWhiteSpace(rawTitle) ? $"Варіант {index}" : StripMoviePrefix(WebUtility.HtmlDecode(rawTitle).Trim()); string qualityTag = DetectQualityTag($"{title} {file}"); if (string.IsNullOrWhiteSpace(qualityTag)) return title; @@ -354,6 +354,27 @@ namespace UaTUT return null; } + private static string StripMoviePrefix(string title) + { + if (string.IsNullOrWhiteSpace(title)) + return title; + + string normalized = Regex.Replace(title, @"\s+", " ").Trim(); + int sepIndex = normalized.LastIndexOf(" - ", StringComparison.Ordinal); + if (sepIndex <= 0 || sepIndex >= normalized.Length - 3) + return normalized; + + string prefix = normalized.Substring(0, sepIndex).Trim(); + string suffix = normalized.Substring(sepIndex + 3).Trim(); + if (string.IsNullOrWhiteSpace(suffix)) + return normalized; + + if (Regex.IsMatch(prefix, @"(19|20)\d{2}")) + return suffix; + + return normalized; + } + private static string ExtractPlayerFileArray(string html) { if (string.IsNullOrWhiteSpace(html)) diff --git a/Uaflix/UaflixInvoke.cs b/Uaflix/UaflixInvoke.cs index 8db5dd3..c162c9e 100644 --- a/Uaflix/UaflixInvoke.cs +++ b/Uaflix/UaflixInvoke.cs @@ -1533,7 +1533,7 @@ namespace Uaflix private static string BuildDisplayTitle(string rawTitle, string link, int index) { - string normalized = string.IsNullOrWhiteSpace(rawTitle) ? $"Варіант {index}" : WebUtility.HtmlDecode(rawTitle).Trim(); + string normalized = string.IsNullOrWhiteSpace(rawTitle) ? $"Варіант {index}" : StripMoviePrefix(WebUtility.HtmlDecode(rawTitle).Trim()); string qualityTag = DetectQualityTag($"{normalized} {link}"); if (string.IsNullOrWhiteSpace(qualityTag)) return normalized; @@ -1558,6 +1558,27 @@ namespace Uaflix return null; } + private static string StripMoviePrefix(string title) + { + if (string.IsNullOrWhiteSpace(title)) + return title; + + string normalized = Regex.Replace(title, @"\s+", " ").Trim(); + int sepIndex = normalized.LastIndexOf(" - ", StringComparison.Ordinal); + if (sepIndex <= 0 || sepIndex >= normalized.Length - 3) + return normalized; + + string prefix = normalized.Substring(0, sepIndex).Trim(); + string suffix = normalized.Substring(sepIndex + 3).Trim(); + if (string.IsNullOrWhiteSpace(suffix)) + return normalized; + + if (Regex.IsMatch(prefix, @"(19|20)\d{2}")) + return suffix; + + return normalized; + } + private static string ExtractPlayerFileArray(string html) { if (string.IsNullOrWhiteSpace(html))