diff options
| author | 2019-12-25 19:40:28 -0500 | |
|---|---|---|
| committer | 2019-12-25 19:40:28 -0500 | |
| commit | f9a1a9dcb7df977eeac9544786df9c0b93795815 (patch) | |
| tree | 8cb69cf7685da8d7e4deb7dc1d6b209098e1ddfb /gallery_dl/extractor/4chan.py | |
| parent | 0c73e982fa596da07f23b377621ab894a9e64884 (diff) | |
New upstream version 1.12.1upstream/1.12.1
Diffstat (limited to 'gallery_dl/extractor/4chan.py')
| -rw-r--r-- | gallery_dl/extractor/4chan.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/gallery_dl/extractor/4chan.py b/gallery_dl/extractor/4chan.py index 36a0573..980dc20 100644 --- a/gallery_dl/extractor/4chan.py +++ b/gallery_dl/extractor/4chan.py @@ -59,3 +59,30 @@ class _4chanThreadExtractor(Extractor): url = "https://i.4cdn.org/{}/{}{}".format( post["board"], post["tim"], post["ext"]) yield Message.Url, url, post + + +class _4chanBoardExtractor(Extractor): + """Extractor for 4chan boards""" + category = "4chan" + subcategory = "board" + pattern = r"(?:https?://)?boards\.4chan(?:nel)?\.org/([^/?&#]+)/\d*$" + test = ("https://boards.4channel.org/po/", { + "pattern": _4chanThreadExtractor.pattern, + "count": ">= 100", + }) + + def __init__(self, match): + Extractor.__init__(self, match) + self.board = match.group(1) + + def items(self): + url = "https://a.4cdn.org/{}/threads.json".format(self.board) + threads = self.request(url).json() + + for page in threads: + for thread in page["threads"]: + url = "https://boards.4chan.org/{}/thread/{}/".format( + self.board, thread["no"]) + thread["page"] = page["page"] + thread["_extractor"] = _4chanThreadExtractor + yield Message.Queue, url, thread |
