1
0
Fork 0
mirror of synced 2024-05-20 12:12:40 +12:00

Re-fix Redgifs

API seems to return incorrect signature value when sending header. Other fixes seems to have worked temporarily but have stopped working so they're removed.
This commit is contained in:
SoulSuck24 2022-09-12 22:26:02 -04:00
parent d60b4e7fdd
commit e0a36f4eab

View file

@ -28,12 +28,7 @@ class Redgifs(BaseDownloader):
except AttributeError:
raise SiteDownloaderError(f'Could not extract Redgifs ID from {url}')
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) '
'Chrome/90.0.4430.93 Safari/537.36',
}
content = Redgifs.retrieve_url(f'https://api.redgifs.com/v2/gifs/{redgif_id}', headers=headers)
content = Redgifs.retrieve_url(f'https://api.redgifs.com/v2/gifs/{redgif_id}')
if content is None:
raise SiteDownloaderError('Could not read the page source')
@ -62,14 +57,4 @@ class Redgifs(BaseDownloader):
except (KeyError, AttributeError):
raise SiteDownloaderError('Failed to find JSON data in page')
# returned domain seems to be being phased out
out = {re.sub('thumbs2', 'thumbs3', link) for link in out}
out = {Redgifs._clean_thumbs4_link(link) for link in out}
return out
@staticmethod
def _clean_thumbs4_link(url: str) -> str:
split_url = urllib.parse.urlsplit(url)
out = split_url.scheme + '://' + split_url.netloc + split_url.path
out = re.sub('thumbs4', 'thumbs3', out)
return out