[pixiv] allow setting a date range for search results (#2133)

with the 'scd' and 'ecd' query parameters
This commit is contained in:
Mike Fährmann 2021-12-23 23:03:39 +01:00
parent 882c614281
commit 4bec34fc94
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88

View File

@ -456,7 +456,9 @@ class PixivSearchExtractor(PixivExtractor):
self.sort = self.target = None
def works(self):
return self.api.search_illust(self.word, self.sort, self.target)
return self.api.search_illust(
self.word, self.sort, self.target,
date_start=self.date_start, date_end=self.date_end)
def metadata(self):
query = text.parse_query(self.query)
@ -489,10 +491,15 @@ class PixivSearchExtractor(PixivExtractor):
target = "s_tag"
self.target = target_map[target]
self.date_start = query.get("scd")
self.date_end = query.get("ecd")
return {"search": {
"word": self.word,
"sort": self.sort,
"target": self.target,
"date_start": self.date_start,
"date_end": self.date_end,
}}
@ -710,9 +717,11 @@ class PixivAppAPI():
params = {"illust_id": illust_id}
return self._pagination("v2/illust/related", params)
def search_illust(self, word, sort=None, target=None, duration=None):
def search_illust(self, word, sort=None, target=None, duration=None,
date_start=None, date_end=None):
params = {"word": word, "search_target": target,
"sort": sort, "duration": duration}
"sort": sort, "duration": duration,
"start_date": date_start, "end_date": date_end}
return self._pagination("v1/search/illust", params)
def user_bookmarks_illust(self, user_id, tag=None, restrict="public"):