Compare commits

...

3 Commits

Author SHA1 Message Date
xXmeme-machineXx
c4e967cd05
Merge 1e9272f7aede164c9b9a2a2416762956be833bb1 into 3eb8d22ddb8982ca4fb56bb7a8d6517538bf14c6 2025-04-01 09:13:36 +02:00
dirkf
3eb8d22ddb
[JSInterp] Temporary fix for #33102 2025-03-31 04:21:09 +01:00
xXmeme-machineXx
1e9272f7ae Fix gfycat, for links redirected to redgifs (#25555)
Fixes #25555, #26631, #27543, #28330
2021-12-22 08:30:57 +00:00
2 changed files with 14 additions and 3 deletions

View File

@ -8,6 +8,9 @@ from ..utils import (
qualities,
ExtractorError,
)
from ..compat import (
compat_urlparse,
)
class GfycatIE(InfoExtractor):
@ -63,15 +66,21 @@ class GfycatIE(InfoExtractor):
def _real_extract(self, url):
video_id = self._match_id(url)
response = self._request_webpage(url, video_id)
final_url = response.geturl() # follow redirects
hostname = compat_urlparse.urlparse(final_url).netloc
if hostname == 'www.redgifs.com':
api_endpoint = 'https://api.redgifs.com/v1/gifs/%s' % video_id.lower()
else:
api_endpoint = 'https://api.gfycat.com/v1/gfycats/%s' % video_id
gfy = self._download_json(
'https://api.gfycat.com/v1/gfycats/%s' % video_id,
api_endpoint,
video_id, 'Downloading video info')
if 'error' in gfy:
raise ExtractorError('Gfycat said: ' + gfy['error'], expected=True)
gfy = gfy['gfyItem']
title = gfy.get('title') or gfy['gfyName']
title = gfy.get('title') or gfy.get('gifName') or gfy['gfyName']
description = gfy.get('description')
timestamp = int_or_none(gfy.get('createDate'))
uploader = gfy.get('userName')

View File

@ -686,6 +686,8 @@ class JSInterpreter(object):
raise self.Exception('Cannot get index {idx!r:.100}'.format(**locals()), expr=repr(obj), cause=e)
def _dump(self, obj, namespace):
if obj is JS_Undefined:
return 'undefined'
try:
return json.dumps(obj)
except TypeError: