|
|
|
|
@@ -505,6 +505,14 @@ def _strip_tags(value: str) -> str:
|
|
|
|
|
return re.sub(r"<[^>]+>", " ", value or "")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _clean_collection_title(title: str) -> str:
|
|
|
|
|
cleaned = "".join(
|
|
|
|
|
ch for ch in title
|
|
|
|
|
if unicodedata.category(ch) not in ("So", "Sm", "Sk", "Sc", "Cs", "Co", "Cn")
|
|
|
|
|
)
|
|
|
|
|
return re.sub(r"\s+", " ", cleaned).strip()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _search_series_api(query: str) -> list[SeriesResult]:
|
|
|
|
|
query = (query or "").strip()
|
|
|
|
|
if not query:
|
|
|
|
|
@@ -1028,6 +1036,7 @@ class SerienstreamPlugin(BasisPlugin):
|
|
|
|
|
self._series_metadata_cache: dict[str, tuple[dict[str, str], dict[str, str]]] = {}
|
|
|
|
|
self._series_metadata_full: set[str] = set()
|
|
|
|
|
self._collection_url_cache: dict[str, str] = {}
|
|
|
|
|
self._collection_has_more: bool = False
|
|
|
|
|
self.is_available = True
|
|
|
|
|
self.unavailable_reason: str | None = None
|
|
|
|
|
if not self._requests_available: # pragma: no cover - optional dependency
|
|
|
|
|
@@ -1255,34 +1264,35 @@ class SerienstreamPlugin(BasisPlugin):
|
|
|
|
|
return {"popular_series", "genres", "latest_episodes", "alpha", "collections"}
|
|
|
|
|
|
|
|
|
|
def collections(self) -> list[str]:
|
|
|
|
|
"""Liefert alle Sammlungs-Namen von /sammlungen (alle Seiten)."""
|
|
|
|
|
"""Liefert Sammlungs-Namen von /sammlungen (Seite 1, für Paginierung)."""
|
|
|
|
|
return self._collections_page(1)
|
|
|
|
|
|
|
|
|
|
def _collections_page(self, page: int = 1) -> list[str]:
|
|
|
|
|
"""Liefert eine Seite mit Sammlungs-Namen von /sammlungen (paginiert)."""
|
|
|
|
|
if not self._requests_available:
|
|
|
|
|
return []
|
|
|
|
|
base = _get_base_url()
|
|
|
|
|
names: list[str] = []
|
|
|
|
|
url_map: dict[str, str] = {}
|
|
|
|
|
page = 1
|
|
|
|
|
while True:
|
|
|
|
|
url = f"{base}/sammlungen" if page == 1 else f"{base}/sammlungen?page={page}"
|
|
|
|
|
soup = _get_soup_simple(url)
|
|
|
|
|
found = False
|
|
|
|
|
for a in soup.select('a[href*="/sammlung/"]'):
|
|
|
|
|
h2 = a.find("h2")
|
|
|
|
|
if not h2:
|
|
|
|
|
continue
|
|
|
|
|
title = h2.get_text(strip=True)
|
|
|
|
|
href = (a.get("href") or "").strip()
|
|
|
|
|
if title and href:
|
|
|
|
|
url_map[title] = _absolute_url(href)
|
|
|
|
|
names.append(title)
|
|
|
|
|
found = True
|
|
|
|
|
if not found:
|
|
|
|
|
break
|
|
|
|
|
if not soup.select(f'a[href*="/sammlungen?page={page + 1}"]'):
|
|
|
|
|
break
|
|
|
|
|
page += 1
|
|
|
|
|
url = f"{base}/sammlungen" if page == 1 else f"{base}/sammlungen?page={page}"
|
|
|
|
|
soup = _get_soup_simple(url)
|
|
|
|
|
for a in soup.select('a[href*="/sammlung/"]'):
|
|
|
|
|
h2 = a.find("h2")
|
|
|
|
|
if not h2:
|
|
|
|
|
continue
|
|
|
|
|
title = _clean_collection_title(h2.get_text(strip=True))
|
|
|
|
|
href = (a.get("href") or "").strip()
|
|
|
|
|
if title and href:
|
|
|
|
|
url_map[title] = _absolute_url(href)
|
|
|
|
|
names.append(title)
|
|
|
|
|
if url_map:
|
|
|
|
|
_session_cache_set("collection_urls", url_map)
|
|
|
|
|
existing = _session_cache_get("collection_urls")
|
|
|
|
|
if isinstance(existing, dict):
|
|
|
|
|
existing.update(url_map)
|
|
|
|
|
_session_cache_set("collection_urls", existing)
|
|
|
|
|
else:
|
|
|
|
|
_session_cache_set("collection_urls", url_map)
|
|
|
|
|
names.sort(key=lambda t: t.casefold())
|
|
|
|
|
return names
|
|
|
|
|
|
|
|
|
|
def titles_for_collection(self, collection: str, page: int = 1) -> list[str]:
|
|
|
|
|
@@ -1297,6 +1307,7 @@ class SerienstreamPlugin(BasisPlugin):
|
|
|
|
|
return []
|
|
|
|
|
if page > 1:
|
|
|
|
|
url = f"{url}?page={page}"
|
|
|
|
|
base_url = self._collection_url_cache[collection]
|
|
|
|
|
soup = _get_soup_simple(url)
|
|
|
|
|
titles: list[str] = []
|
|
|
|
|
for a in soup.select('h6 a[href*="/serie/"]'):
|
|
|
|
|
@@ -1305,6 +1316,7 @@ class SerienstreamPlugin(BasisPlugin):
|
|
|
|
|
if title and href:
|
|
|
|
|
self._remember_series_result(title, _absolute_url(href), "")
|
|
|
|
|
titles.append(title)
|
|
|
|
|
self._collection_has_more = bool(soup.select(f'a[href*="?page={page + 1}"]'))
|
|
|
|
|
return titles
|
|
|
|
|
|
|
|
|
|
def popular_series(self) -> list[str]:
|
|
|
|
|
|