summaryrefslogtreecommitdiffstats
path: root/gallery_dl/extractor/zerochan.py
diff options
context:
space:
mode:
Diffstat (limited to 'gallery_dl/extractor/zerochan.py')
-rw-r--r--gallery_dl/extractor/zerochan.py16
1 files changed, 7 insertions, 9 deletions
diff --git a/gallery_dl/extractor/zerochan.py b/gallery_dl/extractor/zerochan.py
index 0ad73c0..3341594 100644
--- a/gallery_dl/extractor/zerochan.py
+++ b/gallery_dl/extractor/zerochan.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2022-2023 Mike Fährmann
+# Copyright 2022-2025 Mike Fährmann
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
@@ -12,7 +12,6 @@ from .booru import BooruExtractor
from ..cache import cache
from .. import text, util, exception
import collections
-import re
BASE_PATTERN = r"(?:https?://)?(?:www\.)?zerochan\.net"
@@ -63,7 +62,7 @@ class ZerochanExtractor(BooruExtractor):
return response.cookies
def _parse_entry_html(self, entry_id):
- url = "{}/{}".format(self.root, entry_id)
+ url = f"{self.root}/{entry_id}"
page = self.request(url).text
try:
@@ -102,7 +101,7 @@ class ZerochanExtractor(BooruExtractor):
return data
def _parse_entry_api(self, entry_id):
- url = "{}/{}?json".format(self.root, entry_id)
+ url = f"{self.root}/{entry_id}?json"
txt = self.request(url).text
try:
item = util.json_loads(txt)
@@ -127,7 +126,7 @@ class ZerochanExtractor(BooruExtractor):
return data
def _parse_json(self, txt):
- txt = re.sub(r"[\x00-\x1f\x7f]", "", txt)
+ txt = util.re(r"[\x00-\x1f\x7f]").sub("", txt)
main, _, tags = txt.partition('tags": [')
item = {}
@@ -174,8 +173,7 @@ class ZerochanTagExtractor(ZerochanExtractor):
self.posts = self.posts_api
self.session.headers["User-Agent"] = util.USERAGENT
- exts = self.config("extensions")
- if exts:
+ if exts := self.config("extensions"):
if isinstance(exts, str):
exts = exts.split(",")
self.exts = exts
@@ -239,7 +237,7 @@ class ZerochanTagExtractor(ZerochanExtractor):
self.log.warning("HTTP redirect to %s", url)
if self.config("redirects"):
continue
- raise exception.StopExtraction()
+ raise exception.AbortExtraction()
data = response.json()
try:
@@ -278,7 +276,7 @@ class ZerochanImageExtractor(ZerochanExtractor):
def __init__(self, match):
ZerochanExtractor.__init__(self, match)
- self.image_id = match.group(1)
+ self.image_id = match[1]
def posts(self):
post = self._parse_entry_html(self.image_id)