[cyberdrop] update
- add test and archive_fmt - extract more metadata
This commit is contained in:
@@ -6,37 +6,53 @@
|
||||
|
||||
"""Extractors for https://cyberdrop.me/"""
|
||||
|
||||
import base64
|
||||
|
||||
from .common import Extractor, Message
|
||||
from .. import text
|
||||
import base64
|
||||
|
||||
|
||||
class CyberdropAlbumExtractor(Extractor):
|
||||
pattern = r"(?:https?://)?(?:www\.)?cyberdrop\.me/a/([^/]+)/?"
|
||||
category = "cyberdrop"
|
||||
subcategory = "album"
|
||||
directory_fmt = ("{category}", "{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)
|
||||
self.album_url = self.root + "/a/" + self.album_id
|
||||
|
||||
def items(self):
|
||||
initial_page = self.request(self.album_url).text
|
||||
url = self.root + "/a/" + self.album_id
|
||||
extr = text.extract_from(self.request(url).text)
|
||||
extr("const albumData = {", "")
|
||||
|
||||
albumName, _ = text.extract(initial_page, "name: '", "'")
|
||||
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)
|
||||
|
||||
encodedFileList, _ = text.extract(initial_page, "fl: '", "'")
|
||||
|
||||
fileList = [base64.b64decode(s.encode()).decode()
|
||||
for s in encodedFileList.split(",")]
|
||||
|
||||
for f in fileList:
|
||||
data = text.nameext_from_url(f)
|
||||
yield Message.Directory, {
|
||||
"album": self.album_id + ": " + albumName
|
||||
}
|
||||
yield Message.Url, "https://f.cyberdrop.cc/" + f, data
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user