[pixeldrain] add support for single file album download

pull/5641/head
HornyQT 4 months ago
parent ea434963ae
commit 24e70b956b

@ -652,7 +652,7 @@ Consider all listed sites to potentially be NSFW.
<tr>
<td>pixeldrain</td>
<td>https://pixeldrain.com/</td>
<td>Albums, Files</td>
<td>Albums, Files, Singlefilefromalbums</td>
<td></td>
</tr>
<tr>

@ -1,6 +1,6 @@
# -*- 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
# it under the terms of the GNU General Public License version 2 as
@ -53,13 +53,40 @@ class PixeldrainFileExtractor(PixeldrainExtractor):
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):
"""Extractor for pixeldrain albums"""
subcategory = "album"
directory_fmt = ("{category}",
"{album[date]:%Y-%m-%d} {album[title]} ({album[id]})")
filename_fmt = "{num:>03} {filename[:230]} ({id}).{extension}"
pattern = BASE_PATTERN + r"/(?:l|api/list)/(\w+)"
pattern = BASE_PATTERN + r"/(?:l|api/list)/(\w+)$"
example = "https://pixeldrain.com/l/abcdefgh"
def __init__(self, match):

@ -89,4 +89,43 @@ __tests__ = (
"mime_type" : str,
},
{
"#url" : "https://pixeldrain.com/l/zQ7XpWfM#item=0",
"#category": ("", "pixeldrain", "singlefilefromalbums"),
"#class" : pixeldrain.PixeldrainSinglefilefromalbumsExtractor,
"#urls" : "https://pixeldrain.com/api/file/jW9E6s4h?download",
"#sha1_content": "0c8768055e4e20e7c7259608b67799171b691140",
"file" : {
"abuse_reporter_name" : "",
"abuse_type" : "",
"allow_video_player" : True,
"availability" : "",
"availability_message": "",
"bandwidth_used" : int,
"bandwidth_used_paid" : 0,
"can_download" : True,
"can_edit" : False,
"date" : "dt:2023-11-22 16:33:27",
"date_last_view" : r"re:\d+-\d+-\d+T\d+:\d+:\d+\.\d+Z",
"date_upload" : "2023-11-22T16:33:27.744Z",
"delete_after_date" : "0001-01-01T00:00:00Z",
"delete_after_downloads": 0,
"download_speed_limit": 0,
"downloads" : int,
"extension" : "png",
"filename" : "test-テスト-\"&>",
"hash_sha256" : "eb359cd8f02a7d6762f9863798297ff6a22569c5c87a9d38c55bdb3a3e26003f",
"id" : "jW9E6s4h",
"mime_type" : "image/png",
"name" : "test-テスト-\"&>.png",
"show_ads" : True,
"size" : 182,
"success" : True,
"thumbnail_href" : "/file/jW9E6s4h/thumbnail",
"url" : "https://pixeldrain.com/api/file/jW9E6s4h?download",
"views" : int,
},
},
)

Loading…
Cancel
Save