|
|
@ -53,45 +53,19 @@ class PixeldrainFileExtractor(PixeldrainExtractor):
|
|
|
|
yield Message.Url, file["url"], file
|
|
|
|
yield Message.Url, file["url"], file
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class PixeldrainSinglefilefromalbumsExtractor(PixeldrainExtractor):
|
|
|
|
|
|
|
|
"""Extractor for pixeldrain file from albums"""
|
|
|
|
|
|
|
|
subcategory = "singlefilefromalbums"
|
|
|
|
|
|
|
|
filename_fmt = "{filename[:230]} ({id}).{extension}"
|
|
|
|
|
|
|
|
pattern = BASE_PATTERN + r"/(?:l)/(\w+)#item=(\d+)"
|
|
|
|
|
|
|
|
example = "https://pixeldrain.com/l/abcdefgh#item=0"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def __init__(self, match):
|
|
|
|
|
|
|
|
Extractor.__init__(self, match)
|
|
|
|
|
|
|
|
self.album_id = match.group(1)
|
|
|
|
|
|
|
|
self.file_number = int(match.group(2))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def items(self):
|
|
|
|
|
|
|
|
url = "{}/api/list/{}".format(self.root, self.album_id)
|
|
|
|
|
|
|
|
album = self.request(url).json()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
file = album["files"][self.file_number]
|
|
|
|
|
|
|
|
file["url"] = "{}/api/file/{}?download".format(self.root, file["id"])
|
|
|
|
|
|
|
|
file["date"] = self.parse_datetime(file["date_upload"])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
del album
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
text.nameext_from_url(file["name"], file)
|
|
|
|
|
|
|
|
yield Message.Directory, file
|
|
|
|
|
|
|
|
yield Message.Url, file["url"], file
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class PixeldrainAlbumExtractor(PixeldrainExtractor):
|
|
|
|
class PixeldrainAlbumExtractor(PixeldrainExtractor):
|
|
|
|
"""Extractor for pixeldrain albums"""
|
|
|
|
"""Extractor for pixeldrain albums"""
|
|
|
|
subcategory = "album"
|
|
|
|
subcategory = "album"
|
|
|
|
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)
|
|
|
@ -101,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(
|
|
|
|