Skip to content

Commit

Permalink
merge #6115: [inkbunny:favorite] update default directory
Browse files Browse the repository at this point in the history
- extract 'favs_username' metadata
- store files in 'favs_username' directory
  • Loading branch information
mikf committed Sep 25, 2024
2 parents 050d87d + ac3ff25 commit e8c5b57
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
13 changes: 12 additions & 1 deletion gallery_dl/extractor/inkbunny.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ def posts(self):
class InkbunnyFavoriteExtractor(InkbunnyExtractor):
"""Extractor for inkbunny user favorites"""
subcategory = "favorite"
directory_fmt = ("{category}", "{favs_username!l}", "Favorites")
pattern = (BASE_PATTERN + r"/(?:"
r"userfavorites_process\.php\?favs_user_id=(\d+)|"
r"submissionsviewall\.php"
Expand All @@ -151,7 +152,17 @@ def __init__(self, match):
self.orderby = params.get("orderby", "fav_datetime")

def metadata(self):
return {"favs_user_id": self.user_id}
# Lookup fav user ID as username
url = "{}/userfavorites_process.php?favs_user_id={}".format(
self.root, self.user_id)
page = self.request(url).text
user_link = text.extr(page, '<a rel="author"', '</a>')
favs_username = text.extr(user_link, 'href="/', '"')

return {
"favs_user_id": self.user_id,
"favs_username": favs_username,
}

def posts(self):
params = {
Expand Down
3 changes: 2 additions & 1 deletion test/results/inkbunny.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@
"#pattern" : r"https://[\w.]+\.metapix\.net/files/full/\d+/\d+_\w+_.+",
"#range" : "20-50",

"favs_user_id": "20969",
"favs_user_id" : "20969",
"favs_username": "soina",
},

{
Expand Down

0 comments on commit e8c5b57

Please sign in to comment.