Skip to content

Commit

Permalink
[paheal] add 'metadata' option (#2641)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikf committed Jun 4, 2022
1 parent 535cbcb commit 4b78bd4
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
12 changes: 12 additions & 0 deletions docs/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1761,6 +1761,18 @@ Description
port than the default.


extractor.paheal.metadata
-------------------------
Type
``bool``
Default
``false``
Description
Extract additional metadata (``source``, ``uploader``)

Note: This requires 1 additional HTTP request per post.


extractor.patreon.files
-----------------------
Type
Expand Down
4 changes: 4 additions & 0 deletions docs/gallery-dl.conf
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,10 @@
"cache": true,
"port": 6414
},
"paheal":
{
"metadata": false
},
"pillowfort":
{
"external": false,
Expand Down
12 changes: 10 additions & 2 deletions gallery_dl/extractor/paheal.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def _extract_post(self, post_id):
post["width"], _, post["height"] = dimensions.partition("x")
post["size"] = text.parse_bytes(size[:-1])

return (post,)
return post


class PahealTagExtractor(PahealExtractor):
Expand All @@ -81,6 +81,9 @@ def __init__(self, match):
PahealExtractor.__init__(self, match)
self.tags = text.unquote(match.group(1))

if self.config("metadata"):
self._extract_data = self._extract_data_ex

def get_metadata(self):
return {"search_tags": self.tags}

Expand Down Expand Up @@ -114,8 +117,13 @@ def _extract_data(post):
"width": width, "height": height,
"tags": text.unescape(tags),
"size": text.parse_bytes(size[:-1]),
"date": text.parse_datetime(date, "%B %d, %Y; %H:%M"),
}

def _extract_data_ex(self, post):
pid = post[:post.index('"')]
return self._extract_post(pid)


class PahealPostExtractor(PahealExtractor):
"""Extractor for single images from rule34.paheal.net"""
Expand Down Expand Up @@ -162,4 +170,4 @@ def __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.post_id),)

0 comments on commit 4b78bd4

Please sign in to comment.