[cyberdrop] fix extraction
This commit is contained in:
@@ -14,6 +14,7 @@ from .. import text
|
||||
class CyberdropAlbumExtractor(lolisafe.LolisafeAlbumExtractor):
|
||||
category = "cyberdrop"
|
||||
root = "https://cyberdrop.me"
|
||||
root_api = "https://api.cyberdrop.me"
|
||||
pattern = r"(?:https?://)?(?:www\.)?cyberdrop\.(?:me|to)/a/([^/?#]+)"
|
||||
example = "https://cyberdrop.me/a/ID"
|
||||
|
||||
@@ -55,5 +56,14 @@ class CyberdropAlbumExtractor(lolisafe.LolisafeAlbumExtractor):
|
||||
|
||||
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()
|
||||
try:
|
||||
url = "{}/api/file/info/{}".format(self.root_api, file_id)
|
||||
file = self.request(url).json()
|
||||
auth = self.request(file["auth_url"]).json()
|
||||
file["url"] = auth["url"]
|
||||
except Exception as exc:
|
||||
self.log.warning("%s (%s: %s)",
|
||||
file_id, exc.__class__.__name__, exc)
|
||||
continue
|
||||
|
||||
yield file
|
||||
|
||||
@@ -12,7 +12,7 @@ __tests__ = (
|
||||
"#url" : "https://cyberdrop.me/a/8uE0wQiK",
|
||||
"#category": ("lolisafe", "cyberdrop", "album"),
|
||||
"#class" : cyberdrop.CyberdropAlbumExtractor,
|
||||
"#pattern" : r"https://sun\.cyberdrop\.ch/api/fc/yyK9y8xpQK5dP\?.+",
|
||||
"#pattern" : r"https://\w+\.cyberdrop\.ch/api/file/d/yyK9y8xpQK5dP\?token=ey.+",
|
||||
"#sha1_content": "0c8768055e4e20e7c7259608b67799171b691140",
|
||||
|
||||
"album_id" : "8uE0wQiK",
|
||||
@@ -28,7 +28,7 @@ __tests__ = (
|
||||
"num" : 1,
|
||||
"size" : 182,
|
||||
"slug" : "yyK9y8xpQK5dP",
|
||||
"thumbnailUrl": str,
|
||||
"thumbnail_url": str,
|
||||
"type" : "image/png",
|
||||
"url" : str,
|
||||
},
|
||||
@@ -37,7 +37,7 @@ __tests__ = (
|
||||
"#url" : "https://cyberdrop.me/a/HriMgbuf",
|
||||
"#category": ("lolisafe", "cyberdrop", "album"),
|
||||
"#class" : cyberdrop.CyberdropAlbumExtractor,
|
||||
"#pattern" : r"https://sun\.cyberdrop\.ch/api/fc/\w+\?.+",
|
||||
"#pattern" : r"https://\w+\.cyberdrop\.ch/api/file/d/\w+\?token=ey.+",
|
||||
"#count" : 3,
|
||||
|
||||
"album_id" : "HriMgbuf",
|
||||
@@ -53,7 +53,7 @@ __tests__ = (
|
||||
"num" : range(1, 3),
|
||||
"size" : int,
|
||||
"slug" : str,
|
||||
"thumbnailUrl": str,
|
||||
"thumbnail_url": str,
|
||||
"type" : r"re:image/gif|video/webm",
|
||||
"url" : str,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user