dev: bump to 0.1.66 and harden resolveurl + serienstream
This commit is contained in:
29
addon/genre_utils.py
Normal file
29
addon/genre_utils.py
Normal file
@@ -0,0 +1,29 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import re
|
||||
from html import unescape
|
||||
|
||||
|
||||
def normalize_genre_label(raw: str) -> str:
|
||||
"""Normalisiert Genre-Bezeichner aus HTML-Labels oder Datenattributen."""
|
||||
|
||||
text = unescape(re.sub(r"\s+", " ", str(raw or ""))).strip()
|
||||
if not text:
|
||||
return ""
|
||||
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 ""
|
||||
special = {
|
||||
"doku-soap": "Doku-Soap",
|
||||
"scifi": "SciFi",
|
||||
"fighting-shounen": "Fighting-Shounen",
|
||||
}
|
||||
if slug in special:
|
||||
return special[slug]
|
||||
return " ".join(chunk.capitalize() for chunk in slug.split("-") if chunk)
|
||||
return text
|
||||
|
||||
Reference in New Issue
Block a user