diff options
| author | 2025-07-31 01:22:01 -0400 | |
|---|---|---|
| committer | 2025-07-31 01:22:01 -0400 | |
| commit | a6e995c093de8aae2e91a0787281bb34c0b871eb (patch) | |
| tree | 2d79821b05300d34d8871eb6c9662b359a2de85d /gallery_dl/extractor/pixeldrain.py | |
| parent | 7672a750cb74bf31e21d76aad2776367fd476155 (diff) | |
New upstream version 1.30.2.upstream/1.30.2
Diffstat (limited to 'gallery_dl/extractor/pixeldrain.py')
| -rw-r--r-- | gallery_dl/extractor/pixeldrain.py | 33 |
1 files changed, 15 insertions, 18 deletions
diff --git a/gallery_dl/extractor/pixeldrain.py b/gallery_dl/extractor/pixeldrain.py index 7a4d1a5..73f4b1f 100644 --- a/gallery_dl/extractor/pixeldrain.py +++ b/gallery_dl/extractor/pixeldrain.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -# Copyright 2023-2024 Mike Fährmann +# Copyright 2023-2025 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 @@ -21,8 +21,7 @@ class PixeldrainExtractor(Extractor): archive_fmt = "{id}" def _init(self): - api_key = self.config("api-key") - if api_key: + if api_key := self.config("api-key"): self.session.auth = util.HTTPBasicAuth("", api_key) def parse_datetime(self, date_string): @@ -39,11 +38,11 @@ class PixeldrainFileExtractor(PixeldrainExtractor): def __init__(self, match): Extractor.__init__(self, match) - self.file_id = match.group(1) + self.file_id = match[1] def items(self): - url = "{}/api/file/{}".format(self.root, self.file_id) - file = self.request(url + "/info").json() + url = f"{self.root}/api/file/{self.file_id}" + file = self.request_json(url + "/info") file["url"] = url + "?download" file["date"] = self.parse_datetime(file["date_upload"]) @@ -64,12 +63,12 @@ class PixeldrainAlbumExtractor(PixeldrainExtractor): def __init__(self, match): Extractor.__init__(self, match) - self.album_id = match.group(1) - self.file_index = match.group(2) + self.album_id = match[1] + self.file_index = match[2] def items(self): - url = "{}/api/list/{}".format(self.root, self.album_id) - album = self.request(url).json() + url = f"{self.root}/api/list/{self.album_id}" + album = self.request_json(url) files = album["files"] album["count"] = album["file_count"] @@ -91,8 +90,7 @@ class PixeldrainAlbumExtractor(PixeldrainExtractor): for num, file in enumerate(files, idx+1): file["album"] = album file["num"] = num - file["url"] = url = "{}/api/file/{}?download".format( - self.root, file["id"]) + file["url"] = url = f"{self.root}/api/file/{file['id']}?download" file["date"] = self.parse_datetime(file["date_upload"]) text.nameext_from_url(file["name"], file) yield Message.Url, url, file @@ -120,8 +118,8 @@ class PixeldrainFolderExtractor(PixeldrainExtractor): def items(self): recursive = self.config("recursive") - url = "{}/api/filesystem/{}".format(self.root, self.groups[0]) - stat = self.request(url + "?stat").json() + url = f"{self.root}/api/filesystem/{self.groups[0]}" + stat = self.request_json(url + "?stat") paths = stat["path"] path = paths[stat["base_index"]] @@ -143,9 +141,8 @@ class PixeldrainFolderExtractor(PixeldrainExtractor): for child in children: if child["type"] == "file": num += 1 - url = "{}/api/filesystem{}?attach".format( - self.root, child["path"]) - share_url = "{}/d{}".format(self.root, child["path"]) + url = f"{self.root}/api/filesystem{child['path']}?attach" + share_url = f"{self.root}/d{child['path']}" data = self.metadata(child) data.update({ "id" : folder["id"], @@ -159,7 +156,7 @@ class PixeldrainFolderExtractor(PixeldrainExtractor): elif child["type"] == "dir": if recursive: - url = "{}/d{}".format(self.root, child["path"]) + url = f"{self.root}/d{child['path']}" child["_extractor"] = PixeldrainFolderExtractor yield Message.Queue, url, child |
