merge #3447: [jschan] add generic extractors for jschan imageboards
This commit is contained in:
@@ -1122,6 +1122,16 @@ Consider all sites to be NSFW unless otherwise known.
|
|||||||
<td></td>
|
<td></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td colspan="4"><strong>jschan Imageboards</strong></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>94chan</td>
|
||||||
|
<td>https://94chan.org/</td>
|
||||||
|
<td>Boards, Threads</td>
|
||||||
|
<td></td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="4"><strong>LynxChan Imageboards</strong></td>
|
<td colspan="4"><strong>LynxChan Imageboards</strong></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
@@ -76,6 +76,7 @@ modules = [
|
|||||||
"itaku",
|
"itaku",
|
||||||
"itchio",
|
"itchio",
|
||||||
"jpgfish",
|
"jpgfish",
|
||||||
|
"jschan",
|
||||||
"kabeuchi",
|
"kabeuchi",
|
||||||
"keenspot",
|
"keenspot",
|
||||||
"kemonoparty",
|
"kemonoparty",
|
||||||
|
|||||||
94
gallery_dl/extractor/jschan.py
Normal file
94
gallery_dl/extractor/jschan.py
Normal file
@@ -0,0 +1,94 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
# 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
|
||||||
|
# published by the Free Software Foundation.
|
||||||
|
|
||||||
|
"""Extractors for jschan Imageboards"""
|
||||||
|
|
||||||
|
from .common import BaseExtractor, Message
|
||||||
|
from .. import text
|
||||||
|
import itertools
|
||||||
|
|
||||||
|
|
||||||
|
class JschanExtractor(BaseExtractor):
|
||||||
|
basecategory = "jschan"
|
||||||
|
|
||||||
|
|
||||||
|
BASE_PATTERN = JschanExtractor.update({
|
||||||
|
"94chan": {
|
||||||
|
"root": "https://94chan.org",
|
||||||
|
"pattern": r"94chan\.org"
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
class JschanThreadExtractor(JschanExtractor):
|
||||||
|
"""Extractor for jschan threads"""
|
||||||
|
subcategory = "thread"
|
||||||
|
directory_fmt = ("{category}", "{board}",
|
||||||
|
"{threadId} {subject|nomarkup[:50]}")
|
||||||
|
filename_fmt = "{postId}{num:?-//} {filename}.{extension}"
|
||||||
|
archive_fmt = "{board}_{postId}_{num}"
|
||||||
|
pattern = BASE_PATTERN + r"/([^/?#]+)/thread/(\d+)\.html"
|
||||||
|
test = (
|
||||||
|
("https://94chan.org/art/thread/25.html", {
|
||||||
|
"pattern": r"https://94chan.org/file/[0-9a-f]{64}(\.\w+)?",
|
||||||
|
"count": ">= 15"
|
||||||
|
})
|
||||||
|
)
|
||||||
|
|
||||||
|
def __init__(self, match):
|
||||||
|
JschanExtractor.__init__(self, match)
|
||||||
|
index = match.lastindex
|
||||||
|
self.board = match.group(index-1)
|
||||||
|
self.thread = match.group(index)
|
||||||
|
|
||||||
|
def items(self):
|
||||||
|
url = "{}/{}/thread/{}.json".format(
|
||||||
|
self.root, self.board, self.thread)
|
||||||
|
thread = self.request(url).json()
|
||||||
|
thread["threadId"] = thread["postId"]
|
||||||
|
posts = thread.pop("replies", ())
|
||||||
|
|
||||||
|
yield Message.Directory, thread
|
||||||
|
for post in itertools.chain((thread,), posts):
|
||||||
|
files = post.pop("files", ())
|
||||||
|
if files:
|
||||||
|
thread.update(post)
|
||||||
|
thread["count"] = len(files)
|
||||||
|
for num, file in enumerate(files):
|
||||||
|
url = self.root + "/file/" + file["filename"]
|
||||||
|
file.update(thread)
|
||||||
|
file["num"] = num
|
||||||
|
file["siteFilename"] = file["filename"]
|
||||||
|
text.nameext_from_url(file["originalFilename"], file)
|
||||||
|
yield Message.Url, url, file
|
||||||
|
|
||||||
|
|
||||||
|
class JschanBoardExtractor(JschanExtractor):
|
||||||
|
"""Extractor for jschan boards"""
|
||||||
|
subcategory = "board"
|
||||||
|
pattern = (BASE_PATTERN + r"/([^/?#]+)"
|
||||||
|
r"(?:/index\.html|/catalog\.html|/\d+\.html|/?$)")
|
||||||
|
test = (
|
||||||
|
("https://94chan.org/art/", {
|
||||||
|
"pattern": JschanThreadExtractor.pattern,
|
||||||
|
"count": ">= 30"
|
||||||
|
}),
|
||||||
|
("https://94chan.org/art/2.html"),
|
||||||
|
("https://94chan.org/art/catalog.html"),
|
||||||
|
("https://94chan.org/art/index.html"),
|
||||||
|
)
|
||||||
|
|
||||||
|
def __init__(self, match):
|
||||||
|
JschanExtractor.__init__(self, match)
|
||||||
|
self.board = match.group(match.lastindex)
|
||||||
|
|
||||||
|
def items(self):
|
||||||
|
url = "{}/{}/catalog.json".format(self.root, self.board)
|
||||||
|
for thread in self.request(url).json():
|
||||||
|
url = "{}/{}/thread/{}.html".format(
|
||||||
|
self.root, self.board, thread["postId"])
|
||||||
|
thread["_extractor"] = JschanThreadExtractor
|
||||||
|
yield Message.Queue, url, thread
|
||||||
@@ -278,6 +278,7 @@ BASE_MAP = {
|
|||||||
"foolslide" : "FoOlSlide Instances",
|
"foolslide" : "FoOlSlide Instances",
|
||||||
"gelbooru_v01": "Gelbooru Beta 0.1.11",
|
"gelbooru_v01": "Gelbooru Beta 0.1.11",
|
||||||
"gelbooru_v02": "Gelbooru Beta 0.2",
|
"gelbooru_v02": "Gelbooru Beta 0.2",
|
||||||
|
"jschan" : "jschan Imageboards",
|
||||||
"lolisafe" : "lolisafe and chibisafe",
|
"lolisafe" : "lolisafe and chibisafe",
|
||||||
"lynxchan" : "LynxChan Imageboards",
|
"lynxchan" : "LynxChan Imageboards",
|
||||||
"moebooru" : "Moebooru and MyImouto",
|
"moebooru" : "Moebooru and MyImouto",
|
||||||
|
|||||||
Reference in New Issue
Block a user