aboutsummaryrefslogtreecommitdiffstats
path: root/gallery_dl/extractor/szurubooru.py
diff options
context:
space:
mode:
Diffstat (limited to 'gallery_dl/extractor/szurubooru.py')
-rw-r--r--gallery_dl/extractor/szurubooru.py17
1 files changed, 6 insertions, 11 deletions
diff --git a/gallery_dl/extractor/szurubooru.py b/gallery_dl/extractor/szurubooru.py
index 1713509..190ccbf 100644
--- a/gallery_dl/extractor/szurubooru.py
+++ b/gallery_dl/extractor/szurubooru.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2023 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
@@ -26,17 +26,15 @@ class SzurubooruExtractor(booru.BooruExtractor):
"Content-Type": "application/json",
}
- username = self.config("username")
- if username:
- token = self.config("token")
- if token:
+ if username := self.config("username"):
+ if token := self.config("token"):
value = username + ":" + token
self.headers["Authorization"] = "Token " + \
binascii.b2a_base64(value.encode())[:-1].decode()
def _api_request(self, endpoint, params=None):
url = self.root + "/api" + endpoint
- return self.request(url, headers=self.headers, params=params).json()
+ return self.request_json(url, headers=self.headers, params=params)
def _pagination(self, endpoint, params):
params["offset"] = 0
@@ -58,20 +56,17 @@ class SzurubooruExtractor(booru.BooruExtractor):
url = self.root + "/" + url
return url
- @staticmethod
- def _prepare(post):
+ def _prepare(self, post):
post["date"] = text.parse_datetime(
post["creationTime"], "%Y-%m-%dT%H:%M:%S.%fZ")
tags = []
- append = tags.append
tags_categories = collections.defaultdict(list)
-
for tag in post["tags"]:
tag_type = tag["category"].rpartition("_")[2]
tag_name = tag["names"][0]
tags_categories[tag_type].append(tag_name)
- append(tag_name)
+ tags.append(tag_name)
post["tags"] = tags
for category, tags in tags_categories.items():