From 12cd85658b9c7ba76ea07193c08ddefa559296f4 Mon Sep 17 00:00:00 2001 From: enduser420 <91022934+enduser420@users.noreply.github.com> Date: Sun, 16 Jul 2023 21:22:06 +0530 Subject: [PATCH] [redgifs] add 'niches' extractor --- docs/supportedsites.md | 2 +- gallery_dl/extractor/redgifs.py | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/docs/supportedsites.md b/docs/supportedsites.md index c1f25d06..ecf4b73f 100644 --- a/docs/supportedsites.md +++ b/docs/supportedsites.md @@ -730,7 +730,7 @@ Consider all sites to be NSFW unless otherwise known. RedGIFs https://redgifs.com/ - Collections, individual Images, Search Results, User Profiles + Collections, individual Images, Niches, Search Results, User Profiles diff --git a/gallery_dl/extractor/redgifs.py b/gallery_dl/extractor/redgifs.py index bfd18b5d..9109e8dc 100644 --- a/gallery_dl/extractor/redgifs.py +++ b/gallery_dl/extractor/redgifs.py @@ -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)