Skip to content

Commit

Permalink
[sankaku] add support for book searches (closes #1204)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikf committed Dec 29, 2020
1 parent 6cdbab0 commit b0beed7
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion docs/supportedsites.rst
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ rule #34 https://rule34.paheal.net/ Posts, Tag Searches
Rule 34 https://rule34.xxx/ Pools, Posts, Tag Searches
Safebooru https://safebooru.org/ Pools, Posts, Tag Searches
Sakugabooru https://www.sakugabooru.com/ Pools, Popular Images, Posts, Tag Searches
Sankaku Channel https://sankaku.app/ Pools, Posts, Tag Searches Supported
Sankaku Channel https://sankaku.app/ Book Searches, Pools, Posts, Tag Searches Supported
Sankaku Complex https://www.sankakucomplex.com/ Articles, Tag Searches
Sen Manga https://raw.senmanga.com/ Chapters
Sense-Scans https://sensescans.com/reader/ Chapters, Manga
Expand Down
29 changes: 29 additions & 0 deletions gallery_dl/extractor/sankaku.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"""Extractors for https://sankaku.app/"""

from .booru import BooruExtractor
from .common import Message
from .. import text, exception
from ..cache import cache
import collections
Expand Down Expand Up @@ -163,6 +164,31 @@ def posts(self):
return SankakuAPI(self).posts(self.post_id)


class SankakuBooksExtractor(SankakuExtractor):
"""Extractor for books by tag search on sankaku.app"""
subcategory = "books"
pattern = BASE_PATTERN + r"/books/?\?([^#]*)"
test = (
("https://sankaku.app/books?tags=aiue_oka", {
"range": "1-20",
"count": 20,
}),
("https://beta.sankakucomplex.com/books?tags=aiue_oka"),
)

def __init__(self, match):
SankakuExtractor.__init__(self, match)
query = text.parse_query(match.group(1))
self.tags = text.unquote(query.get("tags", "").replace("+", " "))

def items(self):
params = {"tags": self.tags, "pool_type": "0"}
for pool in SankakuAPI(self).pools_keyset(params):
pool["_extractor"] = SankakuPoolExtractor
url = "https://sankaku.app/books/{}".format(pool["id"])
yield Message.Queue, url, pool


class SankakuAPI():
"""Interface for the sankaku.app API"""

Expand All @@ -178,6 +204,9 @@ def pools(self, pool_id):
params = {"lang": "en"}
return self._call("/pools/" + pool_id, params)

def pools_keyset(self, params):
return self._pagination("/pools/keyset", params)

def posts(self, post_id):
params = {
"lang" : "en",
Expand Down
3 changes: 3 additions & 0 deletions scripts/supportedsites.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,9 @@
"me" : "pixiv.me Links",
"work": "individual Images",
},
"sankaku": {
"books": "Book Searches",
},
"smugmug": {
"path": "Images from Users and Folders",
},
Expand Down

0 comments on commit b0beed7

Please sign in to comment.