diff options
author | Wolfgang Müller | 2024-11-15 14:16:52 +0100 |
---|---|---|
committer | Wolfgang Müller | 2024-11-15 14:16:52 +0100 |
commit | 33cff31a4927dc2f36b8e1327bf0786f0676d5c1 (patch) | |
tree | 47224adb07b74f9236cc59d77dc145d91950194d /src | |
parent | 9d27d52af9b852ac492f391fe69f5dd0a027c3cf (diff) | |
download | hircine-33cff31a4927dc2f36b8e1327bf0786f0676d5c1.tar.gz |
backend/plugins: Catch E-Hentai errors only for relevant lines
Diffstat (limited to '')
-rw-r--r-- | src/hircine/plugins/scrapers/ehentai_api.py | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/hircine/plugins/scrapers/ehentai_api.py b/src/hircine/plugins/scrapers/ehentai_api.py index d276c5b..86b6cfa 100644 --- a/src/hircine/plugins/scrapers/ehentai_api.py +++ b/src/hircine/plugins/scrapers/ehentai_api.py @@ -58,20 +58,20 @@ class EHentaiAPIScraper(Scraper): if request.status_code == requests.codes.ok: try: response = json.loads(request.text)["gmetadata"][0] - - title = response.get("title") - if title: - response["title"] = html.unescape(title) - - title_jpn = response.get("title_jpn") - if title_jpn: - response["title_jpn"] = html.unescape(title_jpn) - - handler = ExHentaiHandler() - yield from handler.scrape(response) except json.JSONDecodeError as err: raise ScrapeError("Could not parse JSON response") from err except (KeyError, IndexError) as err: raise ScrapeError("Response is missing 'gmetadata' field") from err + + title = response.get("title") + if title: + response["title"] = html.unescape(title) + + title_jpn = response.get("title_jpn") + if title_jpn: + response["title_jpn"] = html.unescape(title_jpn) + + handler = ExHentaiHandler() + yield from handler.scrape(response) else: raise ScrapeError(f"Request failed with status code {request.status_code}") |