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.
This commit is contained in:
baliasnyifeliks 2026-02-04 14:33:41 +02:00
parent fed0472514
commit ac8bbe0318
4 changed files with 32 additions and 12 deletions

View File

@ -326,7 +326,7 @@ namespace Makhno
playUrl = invoke.BuildAshdiUrl(ashdiPath); 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 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)) if (string.IsNullOrWhiteSpace(category))
return false; return false;
if (category.Equals("Аніме", StringComparison.OrdinalIgnoreCase)
|| category.Equals("Аниме", StringComparison.OrdinalIgnoreCase))
{
return serial == 1;
}
return category.Equals("Серіал", StringComparison.OrdinalIgnoreCase) return category.Equals("Серіал", StringComparison.OrdinalIgnoreCase)
|| category.Equals("Сериал", StringComparison.OrdinalIgnoreCase) || category.Equals("Сериал", StringComparison.OrdinalIgnoreCase)
|| category.Equals("Аніме", StringComparison.OrdinalIgnoreCase) || category.Equals("Аніме", StringComparison.OrdinalIgnoreCase)

View File

@ -23,7 +23,7 @@ namespace Makhno
{ {
public class ModInit public class ModInit
{ {
public static double Version => 1.0; public static double Version => 1.5;
public static OnlinesSettings Makhno; public static OnlinesSettings Makhno;
public static bool ApnHostProvided; public static bool ApnHostProvided;

View File

@ -53,20 +53,20 @@ namespace UaTUT
if (serial == 1) 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 else
{ {
return await HandleMovie(searchResults, rjson, invoke); return await HandleMovie(searchResults, rjson, invoke, preferSeries: false);
} }
} }
private async Task<ActionResult> HandleSeries(List<SearchResult> 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<ActionResult> HandleSeries(List<SearchResult> 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 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()) if (!seriesResults.Any())
{ {
@ -244,12 +244,12 @@ namespace UaTUT
return match.Success ? int.Parse(match.Groups[1].Value) : 0; return match.Success ? int.Parse(match.Groups[1].Value) : 0;
} }
private async Task<ActionResult> HandleMovie(List<SearchResult> searchResults, bool rjson, UaTUTInvoke invoke) private async Task<ActionResult> HandleMovie(List<SearchResult> searchResults, bool rjson, UaTUTInvoke invoke, bool preferSeries)
{ {
var init = ModInit.UaTUT; 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()) if (!movieResults.Any())
{ {
@ -456,27 +456,41 @@ namespace UaTUT
return cleaned; return cleaned;
} }
private static bool IsMovieCategory(string category) private static bool IsMovieCategory(string category, bool preferSeries)
{ {
if (string.IsNullOrWhiteSpace(category)) if (string.IsNullOrWhiteSpace(category))
return false; return false;
var value = category.Trim().ToLowerInvariant(); var value = category.Trim().ToLowerInvariant();
if (IsAnimeCategory(value))
return !preferSeries;
return value == "фільм" || value == "фильм" || value == "мультфільм" || value == "мультфильм" || value == "movie"; 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)) if (string.IsNullOrWhiteSpace(category))
return false; return false;
var value = category.Trim().ToLowerInvariant(); var value = category.Trim().ToLowerInvariant();
if (IsAnimeCategory(value))
return preferSeries;
return value == "серіал" || value == "сериал" return value == "серіал" || value == "сериал"
|| value == "аніме" || value == "аниме" || value == "аніме" || value == "аниме"
|| value == "мультсеріал" || value == "мультсериал" || value == "мультсеріал" || value == "мультсериал"
|| value == "tv"; || value == "tv";
} }
private static bool IsAnimeCategory(string value)
{
if (string.IsNullOrWhiteSpace(value))
return false;
return value == "аніме" || value == "аниме";
}
string BuildStreamUrl(OnlinesSettings init, string streamLink) string BuildStreamUrl(OnlinesSettings init, string streamLink)
{ {
string link = streamLink?.Trim(); string link = streamLink?.Trim();

View File

@ -24,7 +24,7 @@ namespace UaTUT
{ {
public class ModInit public class ModInit
{ {
public static double Version => 3.3; public static double Version => 3.4;
public static OnlinesSettings UaTUT; public static OnlinesSettings UaTUT;
public static bool ApnHostProvided; public static bool ApnHostProvided;