replace old %-formatted and .format(…) strings with f-strings (#7671)
mostly using flynt https://github.com/ikamensh/flynt
This commit is contained in:
@@ -42,7 +42,7 @@ class PixeldrainFileExtractor(PixeldrainExtractor):
|
||||
self.file_id = match[1]
|
||||
|
||||
def items(self):
|
||||
url = "{}/api/file/{}".format(self.root, self.file_id)
|
||||
url = f"{self.root}/api/file/{self.file_id}"
|
||||
file = self.request(url + "/info").json()
|
||||
|
||||
file["url"] = url + "?download"
|
||||
@@ -68,7 +68,7 @@ class PixeldrainAlbumExtractor(PixeldrainExtractor):
|
||||
self.file_index = match[2]
|
||||
|
||||
def items(self):
|
||||
url = "{}/api/list/{}".format(self.root, self.album_id)
|
||||
url = f"{self.root}/api/list/{self.album_id}"
|
||||
album = self.request(url).json()
|
||||
|
||||
files = album["files"]
|
||||
@@ -91,8 +91,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,7 +119,7 @@ class PixeldrainFolderExtractor(PixeldrainExtractor):
|
||||
def items(self):
|
||||
recursive = self.config("recursive")
|
||||
|
||||
url = "{}/api/filesystem/{}".format(self.root, self.groups[0])
|
||||
url = f"{self.root}/api/filesystem/{self.groups[0]}"
|
||||
stat = self.request(url + "?stat").json()
|
||||
|
||||
paths = stat["path"]
|
||||
@@ -143,9 +142,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 +157,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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user