1
0
mirror of https://github.com/mikf/gallery-dl.git synced 2025-01-31 19:51:34 +01:00

[cyberdrop] update to site layout changes

This commit is contained in:
Mike Fährmann 2023-11-26 18:03:13 +01:00
parent 8ac68ffba2
commit d9734ce008
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88

View File

@ -7,6 +7,7 @@
"""Extractors for https://cyberdrop.me/""" """Extractors for https://cyberdrop.me/"""
from . import lolisafe from . import lolisafe
from .common import Message
from .. import text from .. import text
@ -16,24 +17,43 @@ class CyberdropAlbumExtractor(lolisafe.LolisafeAlbumExtractor):
pattern = r"(?:https?://)?(?:www\.)?cyberdrop\.(?:me|to)/a/([^/?#]+)" pattern = r"(?:https?://)?(?:www\.)?cyberdrop\.(?:me|to)/a/([^/?#]+)"
example = "https://cyberdrop.me/a/ID" example = "https://cyberdrop.me/a/ID"
def items(self):
files, data = self.fetch_album(self.album_id)
yield Message.Directory, data
for data["num"], file in enumerate(files, 1):
file.update(data)
text.nameext_from_url(file["name"], file)
file["name"], sep, file["id"] = file["filename"].rpartition("-")
yield Message.Url, file["url"], file
def fetch_album(self, album_id): def fetch_album(self, album_id):
url = self.root + "/a/" + self.album_id url = "{}/a/{}".format(self.root, album_id)
extr = text.extract_from(self.request(url).text) page = self.request(url).text
extr = text.extract_from(page)
files = [] desc = extr('property="og:description" content="', '"')
append = files.append if desc.startswith("A privacy-focused censorship-resistant file "
while True: "sharing platform free for everyone."):
url = text.unescape(extr('id="file" href="', '"')) desc = ""
if not url: extr('id="title"', "")
break
append({"file": url,
"_fallback": (self.root + url[url.find("/", 8):],)})
return files, { album = {
"album_id" : self.album_id, "album_id" : self.album_id,
"album_name" : extr("name: '", "'"), "album_name" : text.unescape(extr('title="', '"')),
"date" : text.parse_timestamp(extr("timestamp: ", ",")), "album_size" : text.parse_bytes(extr(
"album_size" : text.parse_int(extr("totalSize: ", ",")), '<p class="title">', "B")),
"description": extr("description: `", "`"), "date" : text.parse_datetime(extr(
"count" : len(files), '<p class="title">', '<'), "%d.%m.%Y"),
"description": text.unescape(text.unescape( # double
desc.rpartition(" [R")[0])),
} }
file_ids = list(text.extract_iter(page, 'id="file" href="/f/', '"'))
album["count"] = len(file_ids)
return self._extract_files(file_ids), album
def _extract_files(self, file_ids):
for file_id in file_ids:
url = "{}/api/f/{}".format(self.root, file_id)
yield self.request(url).json()