From e5bc67eef8a63858366a922b46f2a8bf9c7b8e2f Mon Sep 17 00:00:00 2001 From: "itdrui.de" Date: Tue, 24 Feb 2026 18:51:36 +0100 Subject: [PATCH] dev: clean up genre labels from filter keys --- addon/plugins/aniworld_plugin.py | 6 +++++- addon/plugins/serienstream_plugin.py | 25 ++++++++++++++++++++++++- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/addon/plugins/aniworld_plugin.py b/addon/plugins/aniworld_plugin.py index 03f85da..f105eb4 100644 --- a/addon/plugins/aniworld_plugin.py +++ b/addon/plugins/aniworld_plugin.py @@ -1257,7 +1257,11 @@ class AniworldPlugin(BasisPlugin): return list(self._genre_names_cache) cached = _session_cache_get("genres") if isinstance(cached, list): - names = [str(value).strip() for value in cached if str(value).strip()] + names: List[str] = [] + for value in cached: + normalized = _normalize_genre_label(value) + if normalized: + names.append(normalized) if names: self._genre_names_cache = sorted(set(names), key=str.casefold) return list(self._genre_names_cache) diff --git a/addon/plugins/serienstream_plugin.py b/addon/plugins/serienstream_plugin.py index 8600b30..e05e0d9 100644 --- a/addon/plugins/serienstream_plugin.py +++ b/addon/plugins/serienstream_plugin.py @@ -1335,9 +1335,32 @@ class SerienstreamPlugin(BasisPlugin): def _ensure_genre_names(self) -> List[str]: if self._genre_names_cache is not None: return list(self._genre_names_cache) + + def _normalize_cached_genre(raw: str) -> str: + text = re.sub(r"\s+", " ", str(raw or "")).strip() + key_prefix = "filter.genre_" + if text.casefold().startswith(key_prefix): + slug = text[len(key_prefix) :].strip().casefold() + slug = slug.replace("_", "-") + slug = re.sub(r"[^a-z0-9-]+", "-", slug).strip("-") + if not slug: + return "" + if slug == "doku-soap": + return "Doku-Soap" + if slug == "scifi": + return "SciFi" + if slug == "fighting-shounen": + return "Fighting-Shounen" + return " ".join(chunk.capitalize() for chunk in slug.split("-") if chunk) + return text + cached = _session_cache_get("genres") if isinstance(cached, list): - genres = [str(value).strip() for value in cached if str(value).strip()] + genres: List[str] = [] + for value in cached: + normalized = _normalize_cached_genre(value) + if normalized: + genres.append(normalized) if genres: self._genre_names_cache = sorted(set(genres), key=str.casefold) return list(self._genre_names_cache)