[twitter] Provide more metadata
This commit is contained in:
parent
3233a68fbb
commit
845817aadf
|
@ -102,6 +102,14 @@ class TwitterCardIE(TwitterBaseIE):
|
||||||
r'data-(?:player-)?config="([^"]+)"', webpage, 'data player config'),
|
r'data-(?:player-)?config="([^"]+)"', webpage, 'data player config'),
|
||||||
video_id)
|
video_id)
|
||||||
|
|
||||||
|
def _search_dimensions_in_video_url(a_format, video_url):
|
||||||
|
m = re.search(r'/(?P<width>\d+)x(?P<height>\d+)/', video_url)
|
||||||
|
if m:
|
||||||
|
a_format.update({
|
||||||
|
'width': int(m.group('width')),
|
||||||
|
'height': int(m.group('height')),
|
||||||
|
})
|
||||||
|
|
||||||
playlist = config.get('playlist')
|
playlist = config.get('playlist')
|
||||||
if playlist:
|
if playlist:
|
||||||
video_url = playlist[0]['source']
|
video_url = playlist[0]['source']
|
||||||
|
@ -110,12 +118,8 @@ class TwitterCardIE(TwitterBaseIE):
|
||||||
'url': video_url,
|
'url': video_url,
|
||||||
}
|
}
|
||||||
|
|
||||||
m = re.search(r'/(?P<width>\d+)x(?P<height>\d+)/', video_url)
|
_search_dimensions_in_video_url(f, video_url)
|
||||||
if m:
|
|
||||||
f.update({
|
|
||||||
'width': int(m.group('width')),
|
|
||||||
'height': int(m.group('height')),
|
|
||||||
})
|
|
||||||
formats.append(f)
|
formats.append(f)
|
||||||
|
|
||||||
vmap_url = config.get('vmapUrl') or config.get('vmap_url')
|
vmap_url = config.get('vmapUrl') or config.get('vmap_url')
|
||||||
|
@ -148,6 +152,8 @@ class TwitterCardIE(TwitterBaseIE):
|
||||||
if not a_format['vbr']:
|
if not a_format['vbr']:
|
||||||
del a_format['vbr']
|
del a_format['vbr']
|
||||||
|
|
||||||
|
_search_dimensions_in_video_url(a_format, media_url)
|
||||||
|
|
||||||
formats.append(a_format)
|
formats.append(a_format)
|
||||||
|
|
||||||
duration = float_or_none(media_info.get('duration', {}).get('nanos'), scale=1e9)
|
duration = float_or_none(media_info.get('duration', {}).get('nanos'), scale=1e9)
|
||||||
|
|
Loading…
Reference in New Issue