diff --git a/youtube_dl/extractor/twitter.py b/youtube_dl/extractor/twitter.py index 8acd09f6a..5d2b5ec35 100644 --- a/youtube_dl/extractor/twitter.py +++ b/youtube_dl/extractor/twitter.py @@ -165,6 +165,7 @@ class TwitterIE(InfoExtractor): 'uploader': 'Gifs', 'uploader_id': 'giphz', }, + 'expected_warnings': ['height', 'width'], }, { 'url': 'https://twitter.com/starwars/status/665052190608723968', 'md5': '39b7199856dee6cd4432e72c74bc69d4', @@ -212,20 +213,24 @@ def _real_extract(self, url): return info mobj = re.search(r'''(?x) - ]+class="animated-gif"[^>]+ - (?:data-height="(?P\d+)")?[^>]+ - (?:data-width="(?P\d+)")?[^>]+ - (?:poster="(?P[^"]+)")?[^>]*>\s* + ]+class="animated-gif"(?P[^>]+)>\s* ]+video-src="(?P[^"]+)" ''', webpage) if mobj: + more_info = mobj.group('more_info') + height = int_or_none(self._search_regex( + r'data-height="(\d+)"', more_info, 'height', fatal=False)) + width = int_or_none(self._search_regex( + r'data-width="(\d+)"', more_info, 'width', fatal=False)) + thumbnail = self._search_regex( + r'poster="([^"]+)"', more_info, 'poster', fatal=False) info.update({ 'id': twid, 'url': mobj.group('url'), - 'height': int_or_none(mobj.group('height')), - 'width': int_or_none(mobj.group('width')), - 'thumbnail': mobj.group('poster'), + 'height': height, + 'width': width, + 'thumbnail': thumbnail, }) return info