[redgifs][gfycat] remove webtoken code (fixes #1907)
This commit is contained in:
@@ -10,7 +10,6 @@
|
|||||||
|
|
||||||
from .common import Extractor, Message
|
from .common import Extractor, Message
|
||||||
from .. import text, exception
|
from .. import text, exception
|
||||||
from ..cache import cache
|
|
||||||
|
|
||||||
|
|
||||||
class GfycatExtractor(Extractor):
|
class GfycatExtractor(Extractor):
|
||||||
@@ -155,7 +154,6 @@ class GfycatImageExtractor(GfycatExtractor):
|
|||||||
|
|
||||||
class GfycatAPI():
|
class GfycatAPI():
|
||||||
API_ROOT = "https://api.gfycat.com"
|
API_ROOT = "https://api.gfycat.com"
|
||||||
ACCESS_KEY = "Anr96uuqt9EdamSCwK4txKPjMsf2M95Rfa5FLLhPFucu8H5HTzeutyAa"
|
|
||||||
|
|
||||||
def __init__(self, extractor):
|
def __init__(self, extractor):
|
||||||
self.extractor = extractor
|
self.extractor = extractor
|
||||||
@@ -175,23 +173,8 @@ class GfycatAPI():
|
|||||||
params = {"search_text": query, "count": 150}
|
params = {"search_text": query, "count": 150}
|
||||||
return self._pagination(endpoint, params)
|
return self._pagination(endpoint, params)
|
||||||
|
|
||||||
@cache(keyarg=1, maxage=3600)
|
|
||||||
def _authenticate_impl(self, category):
|
|
||||||
if category == "redgifs":
|
|
||||||
url = "https://api.redgifs.com/v1/oauth/webtoken"
|
|
||||||
else:
|
|
||||||
url = "https://weblogin." + category + ".com/oauth/webtoken"
|
|
||||||
data = {"access_key": self.ACCESS_KEY}
|
|
||||||
headers = {"Referer": self.extractor.root + "/",
|
|
||||||
"Origin" : self.extractor.root}
|
|
||||||
response = self.extractor.request(
|
|
||||||
url, method="POST", headers=headers, json=data)
|
|
||||||
return "Bearer " + response.json()["access_token"]
|
|
||||||
|
|
||||||
def _call(self, endpoint, params=None):
|
def _call(self, endpoint, params=None):
|
||||||
url = self.API_ROOT + endpoint
|
url = self.API_ROOT + endpoint
|
||||||
self.headers["Authorization"] = self._authenticate_impl(
|
|
||||||
self.extractor.category)
|
|
||||||
return self.extractor.request(
|
return self.extractor.request(
|
||||||
url, params=params, headers=self.headers).json()
|
url, params=params, headers=self.headers).json()
|
||||||
|
|
||||||
|
|||||||
@@ -72,5 +72,3 @@ class RedgifsImageExtractor(RedgifsExtractor):
|
|||||||
|
|
||||||
class RedgifsAPI(GfycatAPI):
|
class RedgifsAPI(GfycatAPI):
|
||||||
API_ROOT = "https://api.redgifs.com"
|
API_ROOT = "https://api.redgifs.com"
|
||||||
ACCESS_KEY = ("dBLwVuGn9eq4dtXLs8WSfpjcYFY7bPQe"
|
|
||||||
"AqGPSFgqeW5B9uzj2cMVhF63pTFF4Rg9")
|
|
||||||
|
|||||||
Reference in New Issue
Block a user