Revert "Backfill watchlist alternative titles lazily"
This reverts commit 8aa490adf8.
This commit is contained in:
@@ -1875,54 +1875,6 @@ class WatchlistStore:
|
||||
continue
|
||||
return {"items": updated}
|
||||
|
||||
def ensure_alt_titles(self, show_id, force=False):
|
||||
item = self.get(show_id)
|
||||
if not force and (item.get("alt_titles") or item.get("english_title")):
|
||||
return item
|
||||
parsed = fetch_allmanga_alternative_titles(item["show_id"], item.get("title"), timeout=self._refresh_request_timeout())
|
||||
updated_at = now_iso()
|
||||
alt_titles_json = json.dumps(unique_title_values(parsed.get("alt_titles") or [], item.get("title")))
|
||||
with self.lock, self._connect() as conn:
|
||||
conn.execute(
|
||||
"""
|
||||
UPDATE watchlist
|
||||
SET english_title = ?, alt_titles_json = ?, updated_at = ?
|
||||
WHERE show_id = ?
|
||||
""",
|
||||
(
|
||||
parsed.get("english_title") or None,
|
||||
alt_titles_json,
|
||||
updated_at,
|
||||
item["show_id"],
|
||||
),
|
||||
)
|
||||
return self.get(show_id)
|
||||
|
||||
def ensure_alt_titles_many(self, show_ids, limit=6, force=False):
|
||||
normalized = []
|
||||
for show_id in show_ids:
|
||||
text = str(show_id or "").strip()
|
||||
if text and text not in normalized:
|
||||
normalized.append(text)
|
||||
updated = []
|
||||
for show_id in normalized[: max(1, min(int(limit or 6), 10))]:
|
||||
try:
|
||||
item = self.get(show_id)
|
||||
except KeyError:
|
||||
continue
|
||||
if not force and (item.get("alt_titles") or item.get("english_title")):
|
||||
updated.append(item)
|
||||
continue
|
||||
try:
|
||||
updated.append(self.ensure_alt_titles(show_id, force=force))
|
||||
except Exception as exc:
|
||||
debug_log("watchlist.alt_titles.ensure_failed", show_id=show_id, error=exc)
|
||||
try:
|
||||
updated.append(self.get(show_id))
|
||||
except KeyError:
|
||||
continue
|
||||
return {"items": updated}
|
||||
|
||||
|
||||
def add_to_watchlist(payload):
|
||||
ensure_runtime()
|
||||
|
||||
Reference in New Issue
Block a user