1
0
mirror of https://github.com/mikf/gallery-dl.git synced 2024-11-23 11:12:40 +01:00

[redgifs] update 'search' URL pattern (#4115)

This commit is contained in:
Mike Fährmann 2023-05-30 15:42:31 +02:00
parent 5a6fd8027d
commit bab13402df
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88

View File

@ -162,21 +162,36 @@ class RedgifsSearchExtractor(RedgifsExtractor):
"""Extractor for redgifs search results""" """Extractor for redgifs search results"""
subcategory = "search" subcategory = "search"
directory_fmt = ("{category}", "Search", "{search}") directory_fmt = ("{category}", "Search", "{search}")
pattern = r"(?:https?://)?(?:\w+\.)?redgifs\.com/browse/?\?([^#]+)" pattern = (r"(?:https?://)?(?:\w+\.)?redgifs\.com"
r"/(?:gifs/([^/?#]+)|browse)(?:/?\?([^#]+))?")
test = ( test = (
("https://www.redgifs.com/gifs/jav", {
"pattern": r"https://\w+\.redgifs\.com/[A-Za-z-]+\.(mp4|jpg)",
"range": "1-10",
"count": 10,
}),
("https://www.redgifs.com/browse?tags=JAV", { ("https://www.redgifs.com/browse?tags=JAV", {
"pattern": r"https://\w+\.redgifs\.com/[A-Za-z-]+\.(mp4|jpg)", "pattern": r"https://\w+\.redgifs\.com/[A-Za-z-]+\.(mp4|jpg)",
"range": "1-10", "range": "1-10",
"count": 10, "count": 10,
}), }),
("https://v3.redgifs.com/browse?tags=JAV"), ("https://www.redgifs.com/gifs/jav?order=best&verified=1"),
("https://www.redgifs.com/browse?type=i&verified=y&order=top7"), ("https://www.redgifs.com/browse?type=i&verified=y&order=top7"),
("https://v3.redgifs.com/browse?tags=JAV"),
) )
def __init__(self, match):
RedgifsExtractor.__init__(self, match)
self.search, self.query = match.groups()
def metadata(self): def metadata(self):
self.params = params = text.parse_query(self.key) self.params = text.parse_query(self.query)
search = params.get("tags") or params.get("order") or "trending" if self.search:
return {"search": search} self.params["tags"] = text.unquote(self.search)
return {"search": (self.params.get("tags") or
self.params.get("order") or
"trending")}
def gifs(self): def gifs(self):
return self.api.search(self.params) return self.api.search(self.params)
@ -259,7 +274,6 @@ class RedgifsAPI():
def search(self, params): def search(self, params):
endpoint = "/v2/gifs/search" endpoint = "/v2/gifs/search"
params["search_text"] = params.pop("tags", None) params["search_text"] = params.pop("tags", None)
params.pop("needSendGtm", None)
return self._pagination(endpoint, params) return self._pagination(endpoint, params)
def _call(self, endpoint, params=None): def _call(self, endpoint, params=None):