mirror of
https://github.com/ytdl-org/youtube-dl.git
synced 2024-11-25 11:41:52 +00:00
[youtube] Improve stretch extraction and fix stretched ratio calculation (closes #28769)
This commit is contained in:
parent
7c52395479
commit
54558e0baa
1 changed files with 15 additions and 7 deletions
|
@ -812,6 +812,11 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
|
||||||
},
|
},
|
||||||
'skip': 'This video does not exist.',
|
'skip': 'This video does not exist.',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
# Video with incomplete 'yt:stretch=16:'
|
||||||
|
'url': 'https://www.youtube.com/watch?v=FRhJzUSJbGI',
|
||||||
|
'only_matching': True,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
# Video licensed under Creative Commons
|
# Video licensed under Creative Commons
|
||||||
'url': 'https://www.youtube.com/watch?v=M4gD1WSo5mA',
|
'url': 'https://www.youtube.com/watch?v=M4gD1WSo5mA',
|
||||||
|
@ -1717,13 +1722,16 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
|
||||||
for m in re.finditer(self._meta_regex('og:video:tag'), webpage)]
|
for m in re.finditer(self._meta_regex('og:video:tag'), webpage)]
|
||||||
for keyword in keywords:
|
for keyword in keywords:
|
||||||
if keyword.startswith('yt:stretch='):
|
if keyword.startswith('yt:stretch='):
|
||||||
w, h = keyword.split('=')[1].split(':')
|
mobj = re.search(r'(\d+)\s*:\s*(\d+)', keyword)
|
||||||
w, h = int(w), int(h)
|
if mobj:
|
||||||
if w > 0 and h > 0:
|
# NB: float is intentional for forcing float division
|
||||||
ratio = w / h
|
w, h = (float(v) for v in mobj.groups())
|
||||||
for f in formats:
|
if w > 0 and h > 0:
|
||||||
if f.get('vcodec') != 'none':
|
ratio = w / h
|
||||||
f['stretched_ratio'] = ratio
|
for f in formats:
|
||||||
|
if f.get('vcodec') != 'none':
|
||||||
|
f['stretched_ratio'] = ratio
|
||||||
|
break
|
||||||
|
|
||||||
thumbnails = []
|
thumbnails = []
|
||||||
for container in (video_details, microformat):
|
for container in (video_details, microformat):
|
||||||
|
|
Loading…
Reference in a new issue