mirror of
https://github.com/ytdl-org/youtube-dl.git
synced 2024-11-22 18:22:21 +00:00
Fix gfycat, for links redirected to redgifs (#25555)
Fixes #25555, #26631, #27543, #28330
This commit is contained in:
parent
5014bd67c2
commit
1e9272f7ae
1 changed files with 12 additions and 3 deletions
|
@ -8,6 +8,9 @@ from ..utils import (
|
||||||
qualities,
|
qualities,
|
||||||
ExtractorError,
|
ExtractorError,
|
||||||
)
|
)
|
||||||
|
from ..compat import (
|
||||||
|
compat_urlparse,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class GfycatIE(InfoExtractor):
|
class GfycatIE(InfoExtractor):
|
||||||
|
@ -63,15 +66,21 @@ class GfycatIE(InfoExtractor):
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
video_id = self._match_id(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(
|
gfy = self._download_json(
|
||||||
'https://api.gfycat.com/v1/gfycats/%s' % video_id,
|
api_endpoint,
|
||||||
video_id, 'Downloading video info')
|
video_id, 'Downloading video info')
|
||||||
if 'error' in gfy:
|
if 'error' in gfy:
|
||||||
raise ExtractorError('Gfycat said: ' + gfy['error'], expected=True)
|
raise ExtractorError('Gfycat said: ' + gfy['error'], expected=True)
|
||||||
gfy = gfy['gfyItem']
|
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')
|
description = gfy.get('description')
|
||||||
timestamp = int_or_none(gfy.get('createDate'))
|
timestamp = int_or_none(gfy.get('createDate'))
|
||||||
uploader = gfy.get('userName')
|
uploader = gfy.get('userName')
|
||||||
|
|
Loading…
Reference in a new issue