diff options
Diffstat (limited to 'gallery_dl/extractor/8chan.py')
| -rw-r--r-- | gallery_dl/extractor/8chan.py | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/gallery_dl/extractor/8chan.py b/gallery_dl/extractor/8chan.py index 3e30ddc..0385067 100644 --- a/gallery_dl/extractor/8chan.py +++ b/gallery_dl/extractor/8chan.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 @@ -23,7 +23,7 @@ class _8chanExtractor(Extractor): root = "https://8chan.moe" def __init__(self, match): - self.root = "https://8chan." + match.group(1) + self.root = "https://8chan." + match[1] Extractor.__init__(self, match) @memcache() @@ -78,9 +78,9 @@ class _8chanThreadExtractor(_8chanExtractor): self.cookies.set(self.cookies_tos_name(), "1", domain=self.root[8:]) # fetch thread data - url = "{}/{}/res/{}.".format(self.root, board, thread) + url = f"{self.root}/{board}/res/{thread}." self.session.headers["Referer"] = url + "html" - thread = self.request(url + "json").json() + thread = self.request_json(url + "json") thread["postId"] = thread["threadId"] thread["_http_headers"] = {"Referer": url + "html"} @@ -116,19 +116,18 @@ class _8chanBoardExtractor(_8chanExtractor): self.cookies.set(self.cookies_tos_name(), "1", domain=self.root[8:]) pnum = text.parse_int(pnum, 1) - url = "{}/{}/{}.json".format(self.root, board, pnum) - data = self.request(url).json() + url = f"{self.root}/{board}/{pnum}.json" + data = self.request_json(url) threads = data["threads"] while True: for thread in threads: thread["_extractor"] = _8chanThreadExtractor - url = "{}/{}/res/{}.html".format( - self.root, board, thread["threadId"]) + url = f"{self.root}/{board}/res/{thread['threadId']}.html" yield Message.Queue, url, thread pnum += 1 if pnum > data["pageCount"]: return - url = "{}/{}/{}.json".format(self.root, board, pnum) - threads = self.request(url).json()["threads"] + url = f"{self.root}/{board}/{pnum}.json" + threads = self.request_json(url)["threads"] |
