From c5685efbf789e6fb7749a04f6c84ca56e6b79d84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Sun, 1 Dec 2024 18:01:43 +0100 Subject: [PATCH] [pixiv:ranking] implement filtering results by 'content' (#6574) --- gallery_dl/extractor/pixiv.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/gallery_dl/extractor/pixiv.py b/gallery_dl/extractor/pixiv.py index 8ad061d4..0914977b 100644 --- a/gallery_dl/extractor/pixiv.py +++ b/gallery_dl/extractor/pixiv.py @@ -607,8 +607,12 @@ class PixivRankingExtractor(PixivExtractor): def works(self): ranking = self.ranking - for ranking["rank"], work in enumerate( - self.api.illust_ranking(self.mode, self.date), 1): + + works = self.api.illust_ranking(self.mode, self.date) + if self.type: + works = filter(lambda work, t=self.type: work["type"] == t, works) + + for ranking["rank"], work in enumerate(works, 1): yield work def metadata(self): @@ -648,10 +652,13 @@ class PixivRankingExtractor(PixivExtractor): date = (now - timedelta(days=1)).strftime("%Y-%m-%d") self.date = date + self.type = type = query.get("content") + self.ranking = ranking = { "mode": mode, "date": self.date, "rank": 0, + "type": type or "all", } return {"ranking": ranking}