summaryrefslogtreecommitdiffstats
path: root/gallery_dl/extractor/2chan.py
diff options
context:
space:
mode:
Diffstat (limited to 'gallery_dl/extractor/2chan.py')
-rw-r--r--gallery_dl/extractor/2chan.py16
1 files changed, 7 insertions, 9 deletions
diff --git a/gallery_dl/extractor/2chan.py b/gallery_dl/extractor/2chan.py
index 337ba48..9927b5a 100644
--- a/gallery_dl/extractor/2chan.py
+++ b/gallery_dl/extractor/2chan.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2017-2023 Mike Fährmann
+# Copyright 2017-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
@@ -19,7 +19,6 @@ class _2chanThreadExtractor(Extractor):
directory_fmt = ("{category}", "{board_name}", "{thread}")
filename_fmt = "{tim}.{extension}"
archive_fmt = "{board}_{thread}_{tim}"
- url_fmt = "https://{server}.2chan.net/{board}/src/{filename}"
pattern = r"(?:https?://)?([\w-]+)\.2chan\.net/([^/?#]+)/res/(\d+)"
example = "https://dec.2chan.net/12/res/12345.htm"
@@ -28,8 +27,8 @@ class _2chanThreadExtractor(Extractor):
self.server, self.board, self.thread = match.groups()
def items(self):
- url = "https://{}.2chan.net/{}/res/{}.htm".format(
- self.server, self.board, self.thread)
+ url = (f"https://{self.server}.2chan.net"
+ f"/{self.board}/res/{self.thread}.htm")
page = self.request(url).text
data = self.metadata(page)
yield Message.Directory, data
@@ -37,7 +36,8 @@ class _2chanThreadExtractor(Extractor):
if "filename" not in post:
continue
post.update(data)
- url = self.url_fmt.format_map(post)
+ url = (f"https://{post['server']}.2chan.net"
+ f"/{post['board']}/src/{post['filename']}")
yield Message.Url, url, post
def metadata(self, page):
@@ -74,8 +74,7 @@ class _2chanThreadExtractor(Extractor):
data["ext"] = "." + data["extension"]
return data
- @staticmethod
- def _extract_post(post):
+ def _extract_post(self, post):
return text.extract_all(post, (
("post", 'class="csb">' , '<'),
("name", 'class="cnm">' , '<'),
@@ -85,8 +84,7 @@ class _2chanThreadExtractor(Extractor):
("com" , '>', '</blockquote>'),
))[0]
- @staticmethod
- def _extract_image(post, data):
+ def _extract_image(self, post, data):
text.extract_all(post, (
(None , '_blank', ''),
("filename", '>', '<'),