Skip to content

Commit

Permalink
[pixiv:ranking] add 'rank' metadata field (#6531)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikf committed Nov 28, 2024
1 parent 9e7d7a3 commit 79fd344
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
11 changes: 8 additions & 3 deletions gallery_dl/extractor/pixiv.py
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,10 @@ def __init__(self, match):
self.mode = self.date = None

def works(self):
return self.api.illust_ranking(self.mode, self.date)
ranking = self.ranking
for ranking["rank"], work in enumerate(
self.api.illust_ranking(self.mode, self.date), 1):
yield work

def metadata(self):
query = text.parse_query(self.query)
Expand Down Expand Up @@ -645,10 +648,12 @@ def metadata(self):
date = (now - timedelta(days=1)).strftime("%Y-%m-%d")
self.date = date

return {"ranking": {
self.ranking = ranking = {
"mode": mode,
"date": self.date,
}}
"rank": 0,
}
return {"ranking": ranking}


class PixivSearchExtractor(PixivExtractor):
Expand Down
7 changes: 7 additions & 0 deletions test/results/pixiv.py
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,13 @@
"#url" : "https://www.pixiv.net/ranking.php",
"#category": ("", "pixiv", "ranking"),
"#class" : pixiv.PixivRankingExtractor,
"#options" : {"max-posts": 10},

"ranking": {
"date": r"re:\d\d\d\d-\d\d-\d\d",
"mode": "day",
"rank": range(1, 10),
},
},

{
Expand Down

0 comments on commit 79fd344

Please sign in to comment.