[redgifs] fix search results
The metadata for Redgifs search results got stripped down to a bare minimum, including download URLs. (Clicking on search results on the website itself is broken as well) As a workaround, we make an extra call to '/v1/gfycats/<ID>' for each search result entry to fetch the missing data.
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
# Copyright 2017-2020 Mike Fährmann
|
# Copyright 2017-2021 Mike Fährmann
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License version 2 as
|
# it under the terms of the GNU General Public License version 2 as
|
||||||
@@ -41,8 +41,11 @@ class GfycatExtractor(Extractor):
|
|||||||
key = fmt + "Url"
|
key = fmt + "Url"
|
||||||
if key in gfyitem:
|
if key in gfyitem:
|
||||||
url = gfyitem[key]
|
url = gfyitem[key]
|
||||||
|
if url.startswith("http:"):
|
||||||
|
url = "https" + url[4:]
|
||||||
gfyitem["extension"] = url.rpartition(".")[2]
|
gfyitem["extension"] = url.rpartition(".")[2]
|
||||||
return url
|
return url
|
||||||
|
gfyitem["extension"] = ""
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
def metadata(self):
|
def metadata(self):
|
||||||
@@ -190,7 +193,11 @@ class GfycatAPI():
|
|||||||
while True:
|
while True:
|
||||||
data = self._call(endpoint, params)
|
data = self._call(endpoint, params)
|
||||||
gfycats = data["gfycats"]
|
gfycats = data["gfycats"]
|
||||||
yield from gfycats
|
|
||||||
|
for gfycat in gfycats:
|
||||||
|
if "gfyName" not in gfycat:
|
||||||
|
gfycat.update(self.gfycat(gfycat["gfyId"]))
|
||||||
|
yield gfycat
|
||||||
|
|
||||||
if "found" not in data and len(gfycats) < params["count"] or \
|
if "found" not in data and len(gfycats) < params["count"] or \
|
||||||
not data["gfycats"]:
|
not data["gfycats"]:
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
# Copyright 2020 Mike Fährmann
|
# Copyright 2020-2021 Mike Fährmann
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License version 2 as
|
# it under the terms of the GNU General Public License version 2 as
|
||||||
@@ -15,7 +15,7 @@ from .. import text
|
|||||||
class RedgifsExtractor(GfycatExtractor):
|
class RedgifsExtractor(GfycatExtractor):
|
||||||
"""Base class for redgifs extractors"""
|
"""Base class for redgifs extractors"""
|
||||||
category = "redgifs"
|
category = "redgifs"
|
||||||
root = "https://www.redgifs.com/"
|
root = "https://www.redgifs.com"
|
||||||
|
|
||||||
|
|
||||||
class RedgifsUserExtractor(RedgifsExtractor):
|
class RedgifsUserExtractor(RedgifsExtractor):
|
||||||
@@ -39,8 +39,8 @@ class RedgifsSearchExtractor(RedgifsExtractor):
|
|||||||
pattern = r"(?:https?://)?(?:www\.)?redgifs\.com/gifs/browse/([^/?#]+)"
|
pattern = r"(?:https?://)?(?:www\.)?redgifs\.com/gifs/browse/([^/?#]+)"
|
||||||
test = ("https://www.redgifs.com/gifs/browse/jav", {
|
test = ("https://www.redgifs.com/gifs/browse/jav", {
|
||||||
"pattern": r"https://\w+\.(redgifs|gfycat)\.com/[A-Za-z]+\.mp4",
|
"pattern": r"https://\w+\.(redgifs|gfycat)\.com/[A-Za-z]+\.mp4",
|
||||||
"range": "100-300",
|
"range": "1-10",
|
||||||
"count": "> 200",
|
"count": 10,
|
||||||
})
|
})
|
||||||
|
|
||||||
def metadata(self):
|
def metadata(self):
|
||||||
@@ -70,6 +70,6 @@ class RedgifsImageExtractor(RedgifsExtractor):
|
|||||||
|
|
||||||
|
|
||||||
class RedgifsAPI(GfycatAPI):
|
class RedgifsAPI(GfycatAPI):
|
||||||
API_ROOT = "https://napi.redgifs.com/"
|
API_ROOT = "https://napi.redgifs.com"
|
||||||
ACCESS_KEY = ("dBLwVuGn9eq4dtXLs8WSfpjcYFY7bPQe"
|
ACCESS_KEY = ("dBLwVuGn9eq4dtXLs8WSfpjcYFY7bPQe"
|
||||||
"AqGPSFgqeW5B9uzj2cMVhF63pTFF4Rg9")
|
"AqGPSFgqeW5B9uzj2cMVhF63pTFF4Rg9")
|
||||||
|
|||||||
Reference in New Issue
Block a user