summaryrefslogtreecommitdiffstats
path: root/gallery_dl/extractor/philomena.py
diff options
context:
space:
mode:
authorLibravatarUnit 193 <unit193@unit193.net>2025-07-31 01:22:01 -0400
committerLibravatarUnit 193 <unit193@unit193.net>2025-07-31 01:22:01 -0400
commita6e995c093de8aae2e91a0787281bb34c0b871eb (patch)
tree2d79821b05300d34d8871eb6c9662b359a2de85d /gallery_dl/extractor/philomena.py
parent7672a750cb74bf31e21d76aad2776367fd476155 (diff)
New upstream version 1.30.2.upstream/1.30.2
Diffstat (limited to 'gallery_dl/extractor/philomena.py')
-rw-r--r--gallery_dl/extractor/philomena.py36
1 files changed, 12 insertions, 24 deletions
diff --git a/gallery_dl/extractor/philomena.py b/gallery_dl/extractor/philomena.py
index 201d4d6..8891dc0 100644
--- a/gallery_dl/extractor/philomena.py
+++ b/gallery_dl/extractor/philomena.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2021-2023 Mike Fährmann
+# Copyright 2021-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
@@ -35,8 +35,7 @@ class PhilomenaExtractor(BooruExtractor):
return url.rpartition(".")[0] + ".svg"
return url
- @staticmethod
- def _prepare(post):
+ def _prepare(self, post):
post["date"] = text.parse_datetime(
post["created_at"][:19], "%Y-%m-%dT%H:%M:%S")
@@ -66,12 +65,8 @@ class PhilomenaPostExtractor(PhilomenaExtractor):
pattern = BASE_PATTERN + r"/(?:images/)?(\d+)"
example = "https://derpibooru.org/images/12345"
- def __init__(self, match):
- PhilomenaExtractor.__init__(self, match)
- self.image_id = match.group(match.lastindex)
-
def posts(self):
- return (self.api.image(self.image_id),)
+ return (self.api.image(self.groups[-1]),)
class PhilomenaSearchExtractor(PhilomenaExtractor):
@@ -83,9 +78,9 @@ class PhilomenaSearchExtractor(PhilomenaExtractor):
def __init__(self, match):
PhilomenaExtractor.__init__(self, match)
- groups = match.groups()
- if groups[-1]:
- q = groups[-1].replace("+", " ")
+
+ if q := self.groups[-1]:
+ q = q.replace("+", " ")
for old, new in (
("-colon-" , ":"),
("-dash-" , "-"),
@@ -98,7 +93,7 @@ class PhilomenaSearchExtractor(PhilomenaExtractor):
q = q.replace(old, new)
self.params = {"q": text.unquote(text.unquote(q))}
else:
- self.params = text.parse_query(groups[-2])
+ self.params = text.parse_query(self.groups[-2])
def metadata(self):
return {"search_tags": self.params.get("q", "")}
@@ -115,18 +110,14 @@ class PhilomenaGalleryExtractor(PhilomenaExtractor):
pattern = BASE_PATTERN + r"/galleries/(\d+)"
example = "https://derpibooru.org/galleries/12345"
- def __init__(self, match):
- PhilomenaExtractor.__init__(self, match)
- self.gallery_id = match.group(match.lastindex)
-
def metadata(self):
try:
- return {"gallery": self.api.gallery(self.gallery_id)}
+ return {"gallery": self.api.gallery(self.groups[-1])}
except IndexError:
raise exception.NotFoundError("gallery")
def posts(self):
- gallery_id = "gallery_id:" + self.gallery_id
+ gallery_id = f"gallery_id:{self.groups[-1]}"
params = {"sd": "desc", "sf": gallery_id, "q": gallery_id}
return self.api.search(params)
@@ -169,18 +160,15 @@ class PhilomenaAPI():
# error
self.extractor.log.debug(response.content)
- raise exception.StopExtraction(
- "%s %s", response.status_code, response.reason)
+ raise exception.HttpError("", response)
def _pagination(self, endpoint, params):
extr = self.extractor
- api_key = extr.config("api-key")
- if api_key:
+ if api_key := extr.config("api-key"):
params["key"] = api_key
- filter_id = extr.config("filter")
- if filter_id:
+ if filter_id := extr.config("filter"):
params["filter_id"] = filter_id
elif not api_key:
params["filter_id"] = extr.config_instance("filter_id") or "2"