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/szurubooru.py | |
| parent | 7672a750cb74bf31e21d76aad2776367fd476155 (diff) | |
New upstream version 1.30.2.upstream/1.30.2
Diffstat (limited to 'gallery_dl/extractor/szurubooru.py')
| -rw-r--r-- | gallery_dl/extractor/szurubooru.py | 17 |
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(): |
