You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
gallery-dl/gallery_dl/extractor/sankaku.py

36 lines
1.2 KiB

10 years ago
from .common import AsyncExtractor
from ..util import filename_from_url
class Extractor(AsyncExtractor):
url = "https://chan.sankakucomplex.com/"
def __init__(self, match, config):
AsyncExtractor.__init__(self, config)
self.tags = match.group(1)
self.category = "sankaku"
self.directory = self.tags.replace("/", "_")
self.enable_useragent()
def images(self):
needle = ' src="//c.sankakucomplex.com/data/preview/'
params = {"tags": self.tags, "page":1}
while True:
text = self.request(self.url, params=params).text
print(text)
return
pos = 0
found = 0
while True:
try:
url, pos = self.extract(text, needle, '"', pos)
found += 1
print("https://cs.sankakucomplex.com/data/" + url)
yield ("https://cs.sankakucomplex.com/data/" + url,
"%s_%s" % (self.category, filename_from_url(url)))
except:
break
if found == 0:
break
params["page"] += 1