aboutsummaryrefslogtreecommitdiffstats
path: root/gallery_dl/extractor/2ch.py
diff options
context:
space:
mode:
authorLibravatarUnit 193 <unit193@unit193.net>2025-09-23 07:44:44 -0400
committerLibravatarUnit 193 <unit193@unit193.net>2025-09-23 07:44:44 -0400
commit291c04af647559317fc9f9f392ad43841ec509ad (patch)
tree13a72906223927180001b362d086c82401cb7843 /gallery_dl/extractor/2ch.py
parent065386e00c7a6c8bbe4bb23a545a7fc7b2c09a4a (diff)
parent42b62671fabfdcf983a9575221420d85f7fbcac1 (diff)
Update upstream source from tag 'upstream/1.30.8'
Update to upstream version '1.30.8' with Debian dir 51367313d3355f7d0d16a754c5c63135fb3c72e2
Diffstat (limited to 'gallery_dl/extractor/2ch.py')
-rw-r--r--gallery_dl/extractor/2ch.py31
1 files changed, 18 insertions, 13 deletions
diff --git a/gallery_dl/extractor/2ch.py b/gallery_dl/extractor/2ch.py
index f5bb7b7..912a251 100644
--- a/gallery_dl/extractor/2ch.py
+++ b/gallery_dl/extractor/2ch.py
@@ -4,37 +4,41 @@
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
-"""Extractors for https://2ch.hk/"""
+"""Extractors for https://2ch.su/"""
from .common import Extractor, Message
from .. import text, util
+BASE_PATTERN = r"(?:https?://)?2ch\.(su|life|hk)"
+
class _2chThreadExtractor(Extractor):
"""Extractor for 2ch threads"""
category = "2ch"
subcategory = "thread"
- root = "https://2ch.hk"
+ root = "https://2ch.su"
directory_fmt = ("{category}", "{board}", "{thread} {title}")
filename_fmt = "{tim}{filename:? //}.{extension}"
archive_fmt = "{board}_{thread}_{tim}"
- pattern = r"(?:https?://)?2ch\.hk/([^/?#]+)/res/(\d+)"
- example = "https://2ch.hk/a/res/12345.html"
+ pattern = rf"{BASE_PATTERN}/([^/?#]+)/res/(\d+)"
+ example = "https://2ch.su/a/res/12345.html"
def __init__(self, match):
+ tld = match[1]
+ self.root = f"https://2ch.{'su' if tld == 'hk' else tld}"
Extractor.__init__(self, match)
- self.board, self.thread = match.groups()
def items(self):
- url = f"{self.root}/{self.board}/res/{self.thread}.json"
+ _, board, thread = self.groups
+ url = f"{self.root}/{board}/res/{thread}.json"
posts = self.request_json(url)["threads"][0]["posts"]
op = posts[0]
title = op.get("subject") or text.remove_html(op["comment"])
thread = {
- "board" : self.board,
- "thread": self.thread,
+ "board" : board,
+ "thread": thread,
"title" : text.unescape(title)[:50],
}
@@ -61,16 +65,17 @@ class _2chBoardExtractor(Extractor):
"""Extractor for 2ch boards"""
category = "2ch"
subcategory = "board"
- root = "https://2ch.hk"
- pattern = r"(?:https?://)?2ch\.hk/([^/?#]+)/?$"
- example = "https://2ch.hk/a/"
+ root = "https://2ch.su"
+ pattern = rf"{BASE_PATTERN}/([^/?#]+)/?$"
+ example = "https://2ch.su/a/"
def __init__(self, match):
+ tld = match[1]
+ self.root = f"https://2ch.{'su' if tld == 'hk' else tld}"
Extractor.__init__(self, match)
- self.board = match[1]
def items(self):
- base = f"{self.root}/{self.board}"
+ base = f"{self.root}/{self.groups[1]}"
# index page
url = f"{base}/index.json"