summaryrefslogtreecommitdiffstats
path: root/gallery_dl/extractor/2ch.py
diff options
context:
space:
mode:
authorLibravatarUnit 193 <unit193@unit193.net>2025-07-31 01:22:01 -0400
committerLibravatarUnit 193 <unit193@unit193.net>2025-07-31 01:22:01 -0400
commita6e995c093de8aae2e91a0787281bb34c0b871eb (patch)
tree2d79821b05300d34d8871eb6c9662b359a2de85d /gallery_dl/extractor/2ch.py
parent7672a750cb74bf31e21d76aad2776367fd476155 (diff)
New upstream version 1.30.2.upstream/1.30.2
Diffstat (limited to 'gallery_dl/extractor/2ch.py')
-rw-r--r--gallery_dl/extractor/2ch.py25
1 files changed, 12 insertions, 13 deletions
diff --git a/gallery_dl/extractor/2ch.py b/gallery_dl/extractor/2ch.py
index dbbf21b..f5bb7b7 100644
--- a/gallery_dl/extractor/2ch.py
+++ b/gallery_dl/extractor/2ch.py
@@ -26,8 +26,8 @@ class _2chThreadExtractor(Extractor):
self.board, self.thread = match.groups()
def items(self):
- url = "{}/{}/res/{}.json".format(self.root, self.board, self.thread)
- posts = self.request(url).json()["threads"][0]["posts"]
+ url = f"{self.root}/{self.board}/res/{self.thread}.json"
+ posts = self.request_json(url)["threads"][0]["posts"]
op = posts[0]
title = op.get("subject") or text.remove_html(op["comment"])
@@ -40,8 +40,7 @@ class _2chThreadExtractor(Extractor):
yield Message.Directory, thread
for post in posts:
- files = post.get("files")
- if files:
+ if files := post.get("files"):
post["post_name"] = post["name"]
post["date"] = text.parse_timestamp(post["timestamp"])
del post["files"]
@@ -68,24 +67,24 @@ class _2chBoardExtractor(Extractor):
def __init__(self, match):
Extractor.__init__(self, match)
- self.board = match.group(1)
+ self.board = match[1]
def items(self):
+ base = f"{self.root}/{self.board}"
+
# index page
- url = "{}/{}/index.json".format(self.root, self.board)
- index = self.request(url).json()
+ url = f"{base}/index.json"
+ index = self.request_json(url)
index["_extractor"] = _2chThreadExtractor
for thread in index["threads"]:
- url = "{}/{}/res/{}.html".format(
- self.root, self.board, thread["thread_num"])
+ url = f"{base}/res/{thread['thread_num']}.html"
yield Message.Queue, url, index
# pages 1..n
for n in util.advance(index["pages"], 1):
- url = "{}/{}/{}.json".format(self.root, self.board, n)
- page = self.request(url).json()
+ url = f"{base}/{n}.json"
+ page = self.request_json(url)
page["_extractor"] = _2chThreadExtractor
for thread in page["threads"]:
- url = "{}/{}/res/{}.html".format(
- self.root, self.board, thread["thread_num"])
+ url = f"{base}/res/{thread['thread_num']}.html"
yield Message.Queue, url, page