diff options
| author | 2021-03-13 16:26:30 -0500 | |
|---|---|---|
| committer | 2021-03-13 16:26:30 -0500 | |
| commit | 3201d77a148367d739862b4f07868a76eaeb7cb1 (patch) | |
| tree | 78b8d71633ec000672a84ad0bbbddd0513ae2d30 /gallery_dl/extractor/cyberdrop.py | |
| parent | fc83315c164afd74734adf27e0f7fec2011904aa (diff) | |
New upstream version 1.17.0.upstream/1.17.0
Diffstat (limited to 'gallery_dl/extractor/cyberdrop.py')
| -rw-r--r-- | gallery_dl/extractor/cyberdrop.py | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/gallery_dl/extractor/cyberdrop.py b/gallery_dl/extractor/cyberdrop.py new file mode 100644 index 0000000..a057b84 --- /dev/null +++ b/gallery_dl/extractor/cyberdrop.py @@ -0,0 +1,58 @@ +# -*- coding: utf-8 -*- + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 as +# published by the Free Software Foundation. + +"""Extractors for https://cyberdrop.me/""" + +from .common import Extractor, Message +from .. import text +import base64 + + +class CyberdropAlbumExtractor(Extractor): + category = "cyberdrop" + subcategory = "album" + root = "https://cyberdrop.me" + directory_fmt = ("{category}", "{album_id} {album_name}") + archive_fmt = "{album_id}_{id}" + pattern = r"(?:https?://)?(?:www\.)?cyberdrop\.me/a/([^/?#]+)" + test = ("https://cyberdrop.me/a/keKRjm4t", { + "pattern": r"https://f\.cyberdrop\.cc/.*\.[a-z]+$", + "keyword": { + "album_id": "keKRjm4t", + "album_name": "Fate (SFW)", + "album_size": 150069254, + "count": 62, + "date": "dt:2020-06-18 13:14:20", + "description": "", + "id": r"re:\w{8}", + }, + }) + + def __init__(self, match): + Extractor.__init__(self, match) + self.album_id = match.group(1) + + def items(self): + url = self.root + "/a/" + self.album_id + extr = text.extract_from(self.request(url).text) + extr("const albumData = {", "") + + data = { + "album_id" : self.album_id, + "album_name" : extr("name: '", "'"), + "date" : text.parse_timestamp(extr("timestamp: ", ",")), + "album_size" : text.parse_int(extr("totalSize: ", ",")), + "description": extr("description: `", "`"), + } + files = extr("fl: '", "'").split(",") + data["count"] = len(files) + + yield Message.Directory, data + for file_b64 in files: + file = base64.b64decode(file_b64.encode()).decode() + text.nameext_from_url(file, data) + data["filename"], _, data["id"] = data["filename"].rpartition("-") + yield Message.Url, "https://f.cyberdrop.cc/" + file, data |
