merge #5641: [pixeldrain] add support for single file album download
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
# Copyright 2023 Mike Fährmann
|
# Copyright 2023-2024 Mike Fährmann
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License version 2 as
|
||||||
@@ -59,12 +59,13 @@ class PixeldrainAlbumExtractor(PixeldrainExtractor):
|
|||||||
directory_fmt = ("{category}",
|
directory_fmt = ("{category}",
|
||||||
"{album[date]:%Y-%m-%d} {album[title]} ({album[id]})")
|
"{album[date]:%Y-%m-%d} {album[title]} ({album[id]})")
|
||||||
filename_fmt = "{num:>03} {filename[:230]} ({id}).{extension}"
|
filename_fmt = "{num:>03} {filename[:230]} ({id}).{extension}"
|
||||||
pattern = BASE_PATTERN + r"/(?:l|api/list)/(\w+)"
|
pattern = BASE_PATTERN + r"/(?:l|api/list)/(\w+)(?:#item=(\d+))?"
|
||||||
example = "https://pixeldrain.com/l/abcdefgh"
|
example = "https://pixeldrain.com/l/abcdefgh"
|
||||||
|
|
||||||
def __init__(self, match):
|
def __init__(self, match):
|
||||||
Extractor.__init__(self, match)
|
Extractor.__init__(self, match)
|
||||||
self.album_id = match.group(1)
|
self.album_id = match.group(1)
|
||||||
|
self.file_index = match.group(2)
|
||||||
|
|
||||||
def items(self):
|
def items(self):
|
||||||
url = "{}/api/list/{}".format(self.root, self.album_id)
|
url = "{}/api/list/{}".format(self.root, self.album_id)
|
||||||
@@ -74,11 +75,20 @@ class PixeldrainAlbumExtractor(PixeldrainExtractor):
|
|||||||
album["count"] = album["file_count"]
|
album["count"] = album["file_count"]
|
||||||
album["date"] = self.parse_datetime(album["date_created"])
|
album["date"] = self.parse_datetime(album["date_created"])
|
||||||
|
|
||||||
|
if self.file_index:
|
||||||
|
idx = text.parse_int(self.file_index)
|
||||||
|
try:
|
||||||
|
files = (files[idx],)
|
||||||
|
except LookupError:
|
||||||
|
files = ()
|
||||||
|
else:
|
||||||
|
idx = 0
|
||||||
|
|
||||||
del album["files"]
|
del album["files"]
|
||||||
del album["file_count"]
|
del album["file_count"]
|
||||||
|
|
||||||
yield Message.Directory, {"album": album}
|
yield Message.Directory, {"album": album}
|
||||||
for num, file in enumerate(files, 1):
|
for num, file in enumerate(files, idx+1):
|
||||||
file["album"] = album
|
file["album"] = album
|
||||||
file["num"] = num
|
file["num"] = num
|
||||||
file["url"] = url = "{}/api/file/{}?download".format(
|
file["url"] = url = "{}/api/file/{}?download".format(
|
||||||
|
|||||||
@@ -89,4 +89,12 @@ __tests__ = (
|
|||||||
"mime_type" : str,
|
"mime_type" : str,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
"#url" : "https://pixeldrain.com/l/zQ7XpWfM#item=0",
|
||||||
|
"#category": ("", "pixeldrain", "album"),
|
||||||
|
"#class" : pixeldrain.PixeldrainAlbumExtractor,
|
||||||
|
"#urls" : "https://pixeldrain.com/api/file/jW9E6s4h?download",
|
||||||
|
"#sha1_content": "0c8768055e4e20e7c7259608b67799171b691140",
|
||||||
|
},
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user