1
0
mirror of https://github.com/mikf/gallery-dl.git synced 2024-11-22 02:32:33 +01:00

[sankaku] add warning for unauthenticated users

also improve URL pattern and add missing options to default config file
This commit is contained in:
Mike Fährmann 2017-10-16 20:45:14 +02:00
parent 6af921a952
commit 5fa42336a2
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88
3 changed files with 13 additions and 4 deletions

View File

@ -51,6 +51,8 @@
},
"sankaku":
{
"wait-min": 2,
"wait-max": 4,
"username": null,
"password": null
},

View File

@ -300,7 +300,7 @@ class DeviantartCollectionExtractor(DeviantartExtractor):
r"/favourites/(\d+)/([^/?&#]+)"]
test = [("http://rosuuri.deviantart.com/favourites/58951174/Useful", {
"url": "f43b202011483e06998db1891e4b62381fabd64a",
"keyword": "629eb627747b3f0ae35541d0725cc345b3ac5aca",
"keyword": "1cd7172d3542a365620b8f103e47e4ef864e5156",
"options": (("original", False),),
})]

View File

@ -21,7 +21,8 @@ class SankakuTagExtractor(Extractor):
subcategory = "tag"
directory_fmt = ["{category}", "{tags}"]
filename_fmt = "{category}_{id}_{md5}.{extension}"
pattern = [r"(?:https?://)?chan\.sankakucomplex\.com/\?tags=([^&]+)"]
pattern = [r"(?:https?://)?chan\.sankakucomplex\.com"
r"/\?(?:[^&#]*&)*tags=([^&#]+)"]
test = [("https://chan.sankakucomplex.com/?tags=bonocho", {
"count": 5,
"pattern": (r"https://cs\.sankakucomplex\.com/data/[^/]{2}/[^/]{2}"
@ -63,6 +64,7 @@ class SankakuTagExtractor(Extractor):
return {"tags": self.tags}
def get_images(self):
"""Yield all available images for the given tags"""
params = {
"tags": self.tags,
"page": self.pagestart,
@ -80,8 +82,13 @@ class SankakuTagExtractor(Extractor):
return
params["page"] += 1
params["next"] = image["id"] - 1
self.log.warning(
"Unauthenticated users may only access the first 500 images / 25 "
"pages. (Use '--range 501-' to continue downloading from this "
"point onwards after setting up an account.)")
def get_image_metadata(self, image_id):
"""Collect metadata for a single image"""
url = "https://chan.sankakucomplex.com/post/show/" + image_id
page = self.request(url, retries=10).text
image_url, pos = text.extract(page, '<li>Original: <a href="', '"')
@ -127,5 +134,5 @@ class SankakuTagExtractor(Extractor):
method="POST", params=params)
if not response.history or response.url != self.root + "/user/home":
raise exception.AuthenticationError()
response = response.history[0]
return {c: response.cookies[c] for c in self.cookienames}
cookies = response.history[0].cookies
return {c: cookies[c] for c in self.cookienames}