mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-12-25 20:55:52 +01:00
[turner] Extract all formats
This commit is contained in:
parent
547993dcd0
commit
cd10b3ea63
@ -4,6 +4,7 @@
|
|||||||
import re
|
import re
|
||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
|
from ..compat import compat_str
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
xpath_text,
|
xpath_text,
|
||||||
int_or_none,
|
int_or_none,
|
||||||
@ -30,11 +31,11 @@ def _extract_cvp_info(self, data_src, video_id, path_data={}):
|
|||||||
tokens = {}
|
tokens = {}
|
||||||
urls = []
|
urls = []
|
||||||
formats = []
|
formats = []
|
||||||
rex = re.compile(r'''(?x)
|
rex = re.compile(
|
||||||
(?P<width>[0-9]+)x(?P<height>[0-9]+)
|
r'(?P<width>[0-9]+)x(?P<height>[0-9]+)(?:_(?P<bitrate>[0-9]+))?')
|
||||||
(?:_(?P<bitrate>[0-9]+))?
|
# Possible formats locations: files/file, files/groupFiles/files
|
||||||
''')
|
# and maybe others
|
||||||
for video_file in video_data.findall('files/file'):
|
for video_file in video_data.findall('.//file'):
|
||||||
video_url = video_file.text.strip()
|
video_url = video_file.text.strip()
|
||||||
if not video_url:
|
if not video_url:
|
||||||
continue
|
continue
|
||||||
@ -84,12 +85,14 @@ def _extract_cvp_info(self, data_src, video_id, path_data={}):
|
|||||||
if video_url in urls:
|
if video_url in urls:
|
||||||
continue
|
continue
|
||||||
urls.append(video_url)
|
urls.append(video_url)
|
||||||
format_id = video_file.attrib['bitrate']
|
format_id = video_file.get('bitrate')
|
||||||
if ext == 'smil':
|
if ext == 'smil':
|
||||||
formats.extend(self._extract_smil_formats(video_url, video_id, fatal=False))
|
formats.extend(self._extract_smil_formats(
|
||||||
|
video_url, video_id, fatal=False))
|
||||||
elif ext == 'm3u8':
|
elif ext == 'm3u8':
|
||||||
m3u8_formats = self._extract_m3u8_formats(
|
m3u8_formats = self._extract_m3u8_formats(
|
||||||
video_url, video_id, 'mp4', m3u8_id=format_id, fatal=False)
|
video_url, video_id, 'mp4', m3u8_id=format_id or 'hls',
|
||||||
|
fatal=False)
|
||||||
if m3u8_formats:
|
if m3u8_formats:
|
||||||
# Sometimes final URLs inside m3u8 are unsigned, let's fix this
|
# Sometimes final URLs inside m3u8 are unsigned, let's fix this
|
||||||
# ourselves
|
# ourselves
|
||||||
@ -103,7 +106,7 @@ def _extract_cvp_info(self, data_src, video_id, path_data={}):
|
|||||||
elif ext == 'f4m':
|
elif ext == 'f4m':
|
||||||
formats.extend(self._extract_f4m_formats(
|
formats.extend(self._extract_f4m_formats(
|
||||||
update_url_query(video_url, {'hdcore': '3.7.0'}),
|
update_url_query(video_url, {'hdcore': '3.7.0'}),
|
||||||
video_id, f4m_id=format_id, fatal=False))
|
video_id, f4m_id=format_id or 'hds', fatal=False))
|
||||||
else:
|
else:
|
||||||
f = {
|
f = {
|
||||||
'format_id': format_id,
|
'format_id': format_id,
|
||||||
@ -117,7 +120,8 @@ def _extract_cvp_info(self, data_src, video_id, path_data={}):
|
|||||||
'height': int(mobj.group('height')),
|
'height': int(mobj.group('height')),
|
||||||
'tbr': int_or_none(mobj.group('bitrate')),
|
'tbr': int_or_none(mobj.group('bitrate')),
|
||||||
})
|
})
|
||||||
elif format_id.isdigit():
|
elif isinstance(format_id, compat_str):
|
||||||
|
if format_id.isdigit():
|
||||||
f['tbr'] = int(format_id)
|
f['tbr'] = int(format_id)
|
||||||
else:
|
else:
|
||||||
mobj = re.match(r'ios_(audio|[0-9]+)$', format_id)
|
mobj = re.match(r'ios_(audio|[0-9]+)$', format_id)
|
||||||
|
Loading…
Reference in New Issue
Block a user