[redgifs] add 'niches' extractor

This commit is contained in:
enduser420
2023-07-16 21:22:06 +05:30
parent 248e8bc699
commit 12cd85658b
2 changed files with 26 additions and 1 deletions

View File

@@ -730,7 +730,7 @@ Consider all sites to be NSFW unless otherwise known.
<tr>
<td>RedGIFs</td>
<td>https://redgifs.com/</td>
<td>Collections, individual Images, Search Results, User Profiles</td>
<td>Collections, individual Images, Niches, Search Results, User Profiles</td>
<td></td>
</tr>
<tr>

View File

@@ -158,6 +158,27 @@ class RedgifsCollectionsExtractor(RedgifsExtractor):
yield Message.Queue, url, collection
class RedgifsNichesExtractor(RedgifsExtractor):
"""Extractor for redgifs niches"""
subcategory = "niches"
pattern = r"(?:https?://)?(?:www\.)?redgifs\.com/niches/([^/?#]+)"
test = (
("https://www.redgifs.com/niches/boobs", {
"pattern": r"https://\w+\.redgifs\.com/[\w-]+\.mp4",
"range": "1-20",
"count": 20,
}),
("https://www.redgifs.com/niches/ass", {
"pattern": r"https://\w+\.redgifs\.com/[\w-]+\.mp4",
"range": "1-20",
"count": 20,
}),
)
def gifs(self):
return self.api.niches(self.key)
class RedgifsSearchExtractor(RedgifsExtractor):
"""Extractor for redgifs search results"""
subcategory = "search"
@@ -271,6 +292,10 @@ class RedgifsAPI():
endpoint = "/v2/users/{}/collections".format(user)
return self._pagination(endpoint, key="collections")
def niches(self, niche):
endpoint = "/v2/niches/{}/gifs".format(niche)
return self._pagination(endpoint)
def search(self, params):
endpoint = "/v2/gifs/search"
params["search_text"] = params.pop("tags", None)