From ac8bbe03183f6560b05bd2822c96738e5bff894d Mon Sep 17 00:00:00 2001 From: baliasnyifeliks Date: Wed, 4 Feb 2026 14:33:41 +0200 Subject: [PATCH] feat(controllers): add conditional handling for anime categories Anime content classification now respects the serial/preferSeries parameter to determine whether to treat anime as a series or movie, improving content type detection accuracy across both Makhno and UaTUT controllers. --- Makhno/Controller.cs | 10 ++++++++-- Makhno/ModInit.cs | 2 +- UaTUT/Controller.cs | 30 ++++++++++++++++++++++-------- UaTUT/ModInit.cs | 2 +- 4 files changed, 32 insertions(+), 12 deletions(-) diff --git a/Makhno/Controller.cs b/Makhno/Controller.cs index a7ff918..eb23aff 100644 --- a/Makhno/Controller.cs +++ b/Makhno/Controller.cs @@ -326,7 +326,7 @@ namespace Makhno playUrl = invoke.BuildAshdiUrl(ashdiPath); - bool isSerial = serial == 1 || IsSerialByCategory(selected.Category) || IsSerialByUrl(playUrl, serial); + bool isSerial = serial == 1 || IsSerialByCategory(selected.Category, serial) || IsSerialByUrl(playUrl, serial); return new ResolveResult { @@ -338,11 +338,17 @@ namespace Makhno }; } - private bool IsSerialByCategory(string category) + private bool IsSerialByCategory(string category, int serial) { if (string.IsNullOrWhiteSpace(category)) return false; + if (category.Equals("Аніме", StringComparison.OrdinalIgnoreCase) + || category.Equals("Аниме", StringComparison.OrdinalIgnoreCase)) + { + return serial == 1; + } + return category.Equals("Серіал", StringComparison.OrdinalIgnoreCase) || category.Equals("Сериал", StringComparison.OrdinalIgnoreCase) || category.Equals("Аніме", StringComparison.OrdinalIgnoreCase) diff --git a/Makhno/ModInit.cs b/Makhno/ModInit.cs index f6f95a5..7417059 100644 --- a/Makhno/ModInit.cs +++ b/Makhno/ModInit.cs @@ -23,7 +23,7 @@ namespace Makhno { public class ModInit { - public static double Version => 1.0; + public static double Version => 1.5; public static OnlinesSettings Makhno; public static bool ApnHostProvided; diff --git a/UaTUT/Controller.cs b/UaTUT/Controller.cs index 19f6a11..13dac3a 100644 --- a/UaTUT/Controller.cs +++ b/UaTUT/Controller.cs @@ -53,20 +53,20 @@ namespace UaTUT if (serial == 1) { - return await HandleSeries(searchResults, imdb_id, kinopoisk_id, title, original_title, year, s, season, t, rjson, invoke); + return await HandleSeries(searchResults, imdb_id, kinopoisk_id, title, original_title, year, s, season, t, rjson, invoke, preferSeries: true); } else { - return await HandleMovie(searchResults, rjson, invoke); + return await HandleMovie(searchResults, rjson, invoke, preferSeries: false); } } - private async Task HandleSeries(List searchResults, string imdb_id, long kinopoisk_id, string title, string original_title, int year, int s, int season, string t, bool rjson, UaTUTInvoke invoke) + private async Task HandleSeries(List searchResults, string imdb_id, long kinopoisk_id, string title, string original_title, int year, int s, int season, string t, bool rjson, UaTUTInvoke invoke, bool preferSeries) { var init = ModInit.UaTUT; // Фільтруємо тільки серіали та аніме - var seriesResults = searchResults.Where(r => IsSeriesCategory(r.Category)).ToList(); + var seriesResults = searchResults.Where(r => IsSeriesCategory(r.Category, preferSeries)).ToList(); if (!seriesResults.Any()) { @@ -244,12 +244,12 @@ namespace UaTUT return match.Success ? int.Parse(match.Groups[1].Value) : 0; } - private async Task HandleMovie(List searchResults, bool rjson, UaTUTInvoke invoke) + private async Task HandleMovie(List searchResults, bool rjson, UaTUTInvoke invoke, bool preferSeries) { var init = ModInit.UaTUT; // Фільтруємо тільки фільми - var movieResults = searchResults.Where(r => IsMovieCategory(r.Category)).ToList(); + var movieResults = searchResults.Where(r => IsMovieCategory(r.Category, preferSeries)).ToList(); if (!movieResults.Any()) { @@ -456,27 +456,41 @@ namespace UaTUT return cleaned; } - private static bool IsMovieCategory(string category) + private static bool IsMovieCategory(string category, bool preferSeries) { if (string.IsNullOrWhiteSpace(category)) return false; var value = category.Trim().ToLowerInvariant(); + if (IsAnimeCategory(value)) + return !preferSeries; + return value == "фільм" || value == "фильм" || value == "мультфільм" || value == "мультфильм" || value == "movie"; } - private static bool IsSeriesCategory(string category) + private static bool IsSeriesCategory(string category, bool preferSeries) { if (string.IsNullOrWhiteSpace(category)) return false; var value = category.Trim().ToLowerInvariant(); + if (IsAnimeCategory(value)) + return preferSeries; + return value == "серіал" || value == "сериал" || value == "аніме" || value == "аниме" || value == "мультсеріал" || value == "мультсериал" || value == "tv"; } + private static bool IsAnimeCategory(string value) + { + if (string.IsNullOrWhiteSpace(value)) + return false; + + return value == "аніме" || value == "аниме"; + } + string BuildStreamUrl(OnlinesSettings init, string streamLink) { string link = streamLink?.Trim(); diff --git a/UaTUT/ModInit.cs b/UaTUT/ModInit.cs index f2a12ed..8813e0b 100644 --- a/UaTUT/ModInit.cs +++ b/UaTUT/ModInit.cs @@ -24,7 +24,7 @@ namespace UaTUT { public class ModInit { - public static double Version => 3.3; + public static double Version => 3.4; public static OnlinesSettings UaTUT; public static bool ApnHostProvided;