summaryrefslogtreecommitdiffstats
path: root/gallery_dl/extractor/zerochan.py
diff options
context:
space:
mode:
Diffstat (limited to 'gallery_dl/extractor/zerochan.py')
-rw-r--r--gallery_dl/extractor/zerochan.py74
1 files changed, 14 insertions, 60 deletions
diff --git a/gallery_dl/extractor/zerochan.py b/gallery_dl/extractor/zerochan.py
index 03fd909..5fe1943 100644
--- a/gallery_dl/extractor/zerochan.py
+++ b/gallery_dl/extractor/zerochan.py
@@ -21,17 +21,19 @@ class ZerochanExtractor(BooruExtractor):
root = "https://www.zerochan.net"
filename_fmt = "{id}.{extension}"
archive_fmt = "{id}"
- cookiedomain = ".zerochan.net"
- cookienames = ("z_id", "z_hash")
+ cookies_domain = ".zerochan.net"
+ cookies_names = ("z_id", "z_hash")
def login(self):
self._logged_in = True
- if not self._check_cookies(self.cookienames):
- username, password = self._get_auth_info()
- if username:
- self._update_cookies(self._login_impl(username, password))
- else:
- self._logged_in = False
+ if self.cookies_check(self.cookies_names):
+ return
+
+ username, password = self._get_auth_info()
+ if username:
+ return self.cookies_update(self._login_impl(username, password))
+
+ self._logged_in = False
@cache(maxage=90*86400, keyarg=1)
def _login_impl(self, username, password):
@@ -78,7 +80,8 @@ class ZerochanExtractor(BooruExtractor):
html = data["tags"]
tags = data["tags"] = []
for tag in html.split("<li class=")[1:]:
- category, _, name = text.extr(tag, 'alt="', '<').partition('">')
+ category = text.extr(tag, 'alt="', '"')
+ name = text.extr(tag, ">-->", "</a>")
tags.append(category + ":" + name.strip())
return data
@@ -108,23 +111,7 @@ class ZerochanTagExtractor(ZerochanExtractor):
subcategory = "tag"
directory_fmt = ("{category}", "{search_tags}")
pattern = BASE_PATTERN + r"/(?!\d+$)([^/?#]+)/?(?:\?([^#]+))?"
- test = ("https://www.zerochan.net/Perth+%28Kantai+Collection%29", {
- "pattern": r"https://static\.zerochan\.net/.+\.full\.\d+\.(jpg|png)",
- "count": "> 24",
- "keyword": {
- "extension": r"re:jpg|png",
- "file_url": r"re:https://static\.zerochan\.net"
- r"/.+\.full\.\d+\.(jpg|png)",
- "filename": r"re:(Perth\.\(Kantai\.Collection\)"
- r"|Kantai\.Collection)\.full\.\d+",
- "height": r"re:^\d+$",
- "id": r"re:^\d+$",
- "name": r"re:(Perth \(Kantai Collection\)|Kantai Collection)",
- "search_tags": "Perth (Kantai Collection)",
- "size": r"re:^\d+k$",
- "width": r"re:^\d+$",
- },
- })
+ example = "https://www.zerochan.net/TAG"
def __init__(self, match):
ZerochanExtractor.__init__(self, match)
@@ -174,40 +161,7 @@ class ZerochanTagExtractor(ZerochanExtractor):
class ZerochanImageExtractor(ZerochanExtractor):
subcategory = "image"
pattern = BASE_PATTERN + r"/(\d+)"
- test = ("https://www.zerochan.net/2920445", {
- "pattern": r"https://static\.zerochan\.net/"
- r"Perth\.%28Kantai\.Collection%29\.full.2920445\.jpg",
- "keyword": {
- "author": "YeFan 葉凡",
- "date": "dt:2020-04-24 21:33:44",
- "file_url": "https://static.zerochan.net"
- "/Perth.%28Kantai.Collection%29.full.2920445.jpg",
- "filename": "Perth.(Kantai.Collection).full.2920445",
- "height": 1366,
- "id": 2920445,
- "path": ["Kantai Collection", "Perth (Kantai Collection)"],
- "size": 1975296,
- "tags": [
- "Mangaka:YeFan 葉凡",
- "Game:Kantai Collection",
- "Character:Perth (Kantai Collection)",
- "Theme:Blonde Hair",
- "Theme:Braids",
- "Theme:Coat",
- "Theme:Female",
- "Theme:Firefighter Outfit",
- "Theme:Group",
- "Theme:Long Sleeves",
- "Theme:Personification",
- "Theme:Pins",
- "Theme:Ribbon",
- "Theme:Shirt",
- "Theme:Short Hair",
- ],
- "uploader": "YukinoTokisaki",
- "width": 1920,
- },
- })
+ example = "https://www.zerochan.net/12345"
def __init__(self, match):
ZerochanExtractor.__init__(self, match)