[twitter] Fix metadata extraction and test_Twitter_1
This commit is contained in:
parent
132e3b74bd
commit
7efc1c2b49
1 changed files with 12 additions and 7 deletions
|
@ -165,6 +165,7 @@ class TwitterIE(InfoExtractor):
|
||||||
'uploader': 'Gifs',
|
'uploader': 'Gifs',
|
||||||
'uploader_id': 'giphz',
|
'uploader_id': 'giphz',
|
||||||
},
|
},
|
||||||
|
'expected_warnings': ['height', 'width'],
|
||||||
}, {
|
}, {
|
||||||
'url': 'https://twitter.com/starwars/status/665052190608723968',
|
'url': 'https://twitter.com/starwars/status/665052190608723968',
|
||||||
'md5': '39b7199856dee6cd4432e72c74bc69d4',
|
'md5': '39b7199856dee6cd4432e72c74bc69d4',
|
||||||
|
@ -212,20 +213,24 @@ class TwitterIE(InfoExtractor):
|
||||||
return info
|
return info
|
||||||
|
|
||||||
mobj = re.search(r'''(?x)
|
mobj = re.search(r'''(?x)
|
||||||
<video[^>]+class="animated-gif"[^>]+
|
<video[^>]+class="animated-gif"(?P<more_info>[^>]+)>\s*
|
||||||
(?:data-height="(?P<height>\d+)")?[^>]+
|
|
||||||
(?:data-width="(?P<width>\d+)")?[^>]+
|
|
||||||
(?:poster="(?P<poster>[^"]+)")?[^>]*>\s*
|
|
||||||
<source[^>]+video-src="(?P<url>[^"]+)"
|
<source[^>]+video-src="(?P<url>[^"]+)"
|
||||||
''', webpage)
|
''', webpage)
|
||||||
|
|
||||||
if mobj:
|
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({
|
info.update({
|
||||||
'id': twid,
|
'id': twid,
|
||||||
'url': mobj.group('url'),
|
'url': mobj.group('url'),
|
||||||
'height': int_or_none(mobj.group('height')),
|
'height': height,
|
||||||
'width': int_or_none(mobj.group('width')),
|
'width': width,
|
||||||
'thumbnail': mobj.group('poster'),
|
'thumbnail': thumbnail,
|
||||||
})
|
})
|
||||||
return info
|
return info
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue