[2ch] support 'org' TLD (#8629)
This commit is contained in:
@@ -15,7 +15,7 @@ Consider all listed sites to potentially be NSFW.
|
||||
<tbody valign="top">
|
||||
<tr id="2ch" title="2ch">
|
||||
<td>2ch</td>
|
||||
<td>https://2ch.su/</td>
|
||||
<td>https://2ch.org/</td>
|
||||
<td>Boards, Threads</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
|
||||
@@ -4,28 +4,28 @@
|
||||
# it under the terms of the GNU General Public License version 2 as
|
||||
# published by the Free Software Foundation.
|
||||
|
||||
"""Extractors for https://2ch.su/"""
|
||||
"""Extractors for https://2ch.org/"""
|
||||
|
||||
from .common import Extractor, Message
|
||||
from .. import text, util
|
||||
|
||||
BASE_PATTERN = r"(?:https?://)?2ch\.(su|life|hk)"
|
||||
BASE_PATTERN = r"(?:https?://)?2ch\.(org|su|life|hk)"
|
||||
|
||||
|
||||
class _2chThreadExtractor(Extractor):
|
||||
"""Extractor for 2ch threads"""
|
||||
category = "2ch"
|
||||
subcategory = "thread"
|
||||
root = "https://2ch.su"
|
||||
root = "https://2ch.org"
|
||||
directory_fmt = ("{category}", "{board}", "{thread} {title}")
|
||||
filename_fmt = "{tim}{filename:? //}.{extension}"
|
||||
archive_fmt = "{board}_{thread}_{tim}"
|
||||
pattern = rf"{BASE_PATTERN}/([^/?#]+)/res/(\d+)"
|
||||
example = "https://2ch.su/a/res/12345.html"
|
||||
example = "https://2ch.org/a/res/12345.html"
|
||||
|
||||
def __init__(self, match):
|
||||
tld = match[1]
|
||||
self.root = f"https://2ch.{'su' if tld == 'hk' else tld}"
|
||||
self.root = f"https://2ch.{'org' if tld == 'hk' else tld}"
|
||||
Extractor.__init__(self, match)
|
||||
|
||||
def items(self):
|
||||
@@ -65,9 +65,9 @@ class _2chBoardExtractor(Extractor):
|
||||
"""Extractor for 2ch boards"""
|
||||
category = "2ch"
|
||||
subcategory = "board"
|
||||
root = "https://2ch.su"
|
||||
root = "https://2ch.org"
|
||||
pattern = rf"{BASE_PATTERN}/([^/?#]+)/?$"
|
||||
example = "https://2ch.su/a/"
|
||||
example = "https://2ch.org/a/"
|
||||
|
||||
def __init__(self, match):
|
||||
tld = match[1]
|
||||
|
||||
@@ -13,7 +13,7 @@ __tests__ = (
|
||||
"#url" : "https://2ch.hk/a/res/6202876.html",
|
||||
"#category": ("", "2ch", "thread"),
|
||||
"#class" : _2ch._2chThreadExtractor,
|
||||
"#pattern" : r"https://2ch\.su/a/src/6202876/\d+\.\w+",
|
||||
"#pattern" : r"https://2ch\.org/a/src/6202876/\d+\.\w+",
|
||||
"#count" : range(450, 1000),
|
||||
|
||||
"banned" : 0,
|
||||
@@ -53,6 +53,16 @@ __tests__ = (
|
||||
"width" : int,
|
||||
},
|
||||
|
||||
{
|
||||
"#url" : "https://2ch.org/a/res/6202876.html",
|
||||
"#class" : _2ch._2chThreadExtractor,
|
||||
},
|
||||
|
||||
{
|
||||
"#url" : "https://2ch.su/a/res/6202876.html",
|
||||
"#class" : _2ch._2chThreadExtractor,
|
||||
},
|
||||
|
||||
{
|
||||
"#url" : "https://2ch.life/a/res/6202876.html",
|
||||
"#class" : _2ch._2chThreadExtractor,
|
||||
@@ -63,10 +73,17 @@ __tests__ = (
|
||||
{
|
||||
"#url" : "https://2ch.hk/a/res/6202876.html",
|
||||
"#class" : _2ch._2chThreadExtractor,
|
||||
"#pattern" : r"https://2ch\.su/a/src/6202876/\d+\.\w+",
|
||||
"#pattern" : r"https://2ch\.org/a/src/6202876/\d+\.\w+",
|
||||
"#count" : range(450, 1000),
|
||||
},
|
||||
|
||||
{
|
||||
"#url" : "https://2ch.org/a/",
|
||||
"#class" : _2ch._2chBoardExtractor,
|
||||
"#pattern" : _2ch._2chThreadExtractor.pattern,
|
||||
"#count" : range(200, 400),
|
||||
},
|
||||
|
||||
{
|
||||
"#url" : "https://2ch.su/a/",
|
||||
"#class" : _2ch._2chBoardExtractor,
|
||||
|
||||
Reference in New Issue
Block a user