diff options
Diffstat (limited to 'gallery_dl/extractor/paheal.py')
| -rw-r--r-- | gallery_dl/extractor/paheal.py | 28 |
1 files changed, 10 insertions, 18 deletions
diff --git a/gallery_dl/extractor/paheal.py b/gallery_dl/extractor/paheal.py index 2330b08..5245f31 100644 --- a/gallery_dl/extractor/paheal.py +++ b/gallery_dl/extractor/paheal.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -# Copyright 2018-2023 Mike Fährmann +# Copyright 2018-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 @@ -42,7 +42,7 @@ class PahealExtractor(Extractor): """Return an iterable containing data of all relevant posts""" def _extract_post(self, post_id): - url = "{}/post/view/{}".format(self.root, post_id) + url = f"{self.root}/post/view/{post_id}" extr = text.extract_from(self.request(url).text) post = { @@ -64,7 +64,7 @@ class PahealExtractor(Extractor): post["width"], _, height = dimensions.partition("x") post["height"], _, duration = height.partition(", ") post["duration"] = text.parse_float(duration[:-1]) - post["filename"] = "{} - {}".format(post_id, post["tags"]) + post["filename"] = f"{post_id} - {post['tags']}" post["extension"] = ext return post @@ -80,10 +80,6 @@ class PahealTagExtractor(PahealExtractor): page_start = 1 per_page = 70 - def __init__(self, match): - PahealExtractor.__init__(self, match) - self.tags = text.unquote(match.group(1)) - def _init(self): if self.config("metadata"): self._extract_data = self._extract_data_ex @@ -94,13 +90,14 @@ class PahealTagExtractor(PahealExtractor): return pages * self.per_page def get_metadata(self): - return {"search_tags": self.tags} + return {"search_tags": text.unquote(self.groups[0])} def get_posts(self): pnum = self.page_start + base = f"{self.root}/post/list/{self.groups[0]}/" + while True: - url = "{}/post/list/{}/{}".format(self.root, self.tags, pnum) - page = self.request(url).text + page = self.request(base + str(pnum)).text pos = page.find("id='image-list'") for post in text.extract_iter( @@ -111,8 +108,7 @@ class PahealTagExtractor(PahealExtractor): return pnum += 1 - @staticmethod - def _extract_data(post): + def _extract_data(self, post): pid , pos = text.extract(post, "", "'") data, pos = text.extract(post, "title='", "'", pos) md5 , pos = text.extract(post, "/_thumbs/", "/", pos) @@ -133,7 +129,7 @@ class PahealTagExtractor(PahealExtractor): "tags" : text.unescape(tags), "size" : text.parse_bytes(size[:-1]), "date" : text.parse_datetime(date, "%B %d, %Y; %H:%M"), - "filename" : "{} - {}".format(pid, tags), + "filename" : f"{pid} - {tags}", "extension": ext, } @@ -149,9 +145,5 @@ class PahealPostExtractor(PahealExtractor): r"/post/view/(\d+)") example = "https://rule34.paheal.net/post/view/12345" - def __init__(self, match): - PahealExtractor.__init__(self, match) - self.post_id = match.group(1) - def get_posts(self): - return (self._extract_post(self.post_id),) + return (self._extract_post(self.groups[0]),) |
