mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-10 09:07:58 +01:00
[periscope] Extract width and height (closes #20015)
This commit is contained in:
parent
55b8588f0e
commit
db1c3a9d3f
1 changed files with 18 additions and 4 deletions
|
@ -5,6 +5,7 @@
|
||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
|
int_or_none,
|
||||||
parse_iso8601,
|
parse_iso8601,
|
||||||
unescapeHTML,
|
unescapeHTML,
|
||||||
)
|
)
|
||||||
|
@ -75,6 +76,14 @@ def _real_extract(self, url):
|
||||||
'url': broadcast[image],
|
'url': broadcast[image],
|
||||||
} for image in ('image_url', 'image_url_small') if broadcast.get(image)]
|
} for image in ('image_url', 'image_url_small') if broadcast.get(image)]
|
||||||
|
|
||||||
|
width = int_or_none(broadcast.get('width'))
|
||||||
|
height = int_or_none(broadcast.get('height'))
|
||||||
|
|
||||||
|
def add_width_and_height(f):
|
||||||
|
for key, val in (('width', width), ('height', height)):
|
||||||
|
if not f.get(key):
|
||||||
|
f[key] = val
|
||||||
|
|
||||||
video_urls = set()
|
video_urls = set()
|
||||||
formats = []
|
formats = []
|
||||||
for format_id in ('replay', 'rtmp', 'hls', 'https_hls', 'lhls', 'lhlsweb'):
|
for format_id in ('replay', 'rtmp', 'hls', 'https_hls', 'lhls', 'lhlsweb'):
|
||||||
|
@ -83,16 +92,21 @@ def _real_extract(self, url):
|
||||||
continue
|
continue
|
||||||
video_urls.add(video_url)
|
video_urls.add(video_url)
|
||||||
if format_id != 'rtmp':
|
if format_id != 'rtmp':
|
||||||
formats.extend(self._extract_m3u8_formats(
|
m3u8_formats = self._extract_m3u8_formats(
|
||||||
video_url, token, 'mp4',
|
video_url, token, 'mp4',
|
||||||
entry_protocol='m3u8_native'
|
entry_protocol='m3u8_native'
|
||||||
if state in ('ended', 'timed_out') else 'm3u8',
|
if state in ('ended', 'timed_out') else 'm3u8',
|
||||||
m3u8_id=format_id, fatal=False))
|
m3u8_id=format_id, fatal=False)
|
||||||
|
if len(m3u8_formats) == 1:
|
||||||
|
add_width_and_height(m3u8_formats[0])
|
||||||
|
formats.extend(m3u8_formats)
|
||||||
continue
|
continue
|
||||||
formats.append({
|
rtmp_format = {
|
||||||
'url': video_url,
|
'url': video_url,
|
||||||
'ext': 'flv' if format_id == 'rtmp' else 'mp4',
|
'ext': 'flv' if format_id == 'rtmp' else 'mp4',
|
||||||
})
|
}
|
||||||
|
add_width_and_height(rtmp_format)
|
||||||
|
formats.append(rtmp_format)
|
||||||
self._sort_formats(formats)
|
self._sort_formats(formats)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
Loading…
Reference in a new issue