forked from minhngoc25a/yt-dlc
[nba] fix extraction errors
This commit is contained in:
parent
55bec9b658
commit
b80d4bebf3
|
@ -44,6 +44,8 @@ class NBAIE(InfoExtractor):
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
path, video_id = re.match(self._VALID_URL, url).groups()
|
path, video_id = re.match(self._VALID_URL, url).groups()
|
||||||
|
if path.startswith('nba/'):
|
||||||
|
path = path[3:]
|
||||||
video_info = self._download_xml('http://www.nba.com/%s.xml' % path, video_id)
|
video_info = self._download_xml('http://www.nba.com/%s.xml' % path, video_id)
|
||||||
video_id = xpath_text(video_info, 'slug')
|
video_id = xpath_text(video_info, 'slug')
|
||||||
title = xpath_text(video_info, 'headline')
|
title = xpath_text(video_info, 'headline')
|
||||||
|
@ -61,23 +63,27 @@ class NBAIE(InfoExtractor):
|
||||||
})
|
})
|
||||||
|
|
||||||
formats = []
|
formats = []
|
||||||
for video_file in video_info.find('files').iter('file'):
|
for video_file in video_info.findall('.//file'):
|
||||||
video_url = video_file.text
|
video_url = video_file.text
|
||||||
if video_url.startswith('/'):
|
if video_url.startswith('/'):
|
||||||
continue
|
continue
|
||||||
if video_url.endswith('.m3u8'):
|
if video_url.endswith('.m3u8'):
|
||||||
formats.extend(self._extract_m3u8_formats(video_url, video_id, m3u8_id='hls'))
|
m3u8_formats = self._extract_m3u8_formats(video_url, video_id, m3u8_id='hls', fatal=False)
|
||||||
|
if m3u8_formats:
|
||||||
|
formats.extend(m3u8_formats)
|
||||||
elif video_url.endswith('.f4m'):
|
elif video_url.endswith('.f4m'):
|
||||||
formats.extend(self._extract_f4m_formats(video_url + '?hdcore=3.4.1.1', video_id, f4m_id='hds'))
|
f4m_formats = self._extract_f4m_formats(video_url + '?hdcore=3.4.1.1', video_id, f4m_id='hds', fatal=False)
|
||||||
|
if f4m_formats:
|
||||||
|
formats.extend(f4m_formats)
|
||||||
else:
|
else:
|
||||||
key = video_file.attrib.get('bitrate')
|
key = video_file.attrib.get('bitrate')
|
||||||
width, height, bitrate = re.search(r'(\d+)x(\d+)(?:_(\d+))?', key).groups()
|
mobj = re.search(r'(\d+)x(\d+)(?:_(\d+))?', key)
|
||||||
formats.append({
|
formats.append({
|
||||||
'format_id': key,
|
'format_id': key,
|
||||||
'url': video_url,
|
'url': video_url,
|
||||||
'width': int_or_none(width),
|
'width': int_or_none(mobj.group(1)),
|
||||||
'height': int_or_none(height),
|
'height': int_or_none(mobj.group(2)),
|
||||||
'tbr': int_or_none(bitrate),
|
'tbr': int_or_none(mobj.group(3)),
|
||||||
})
|
})
|
||||||
self._sort_formats(formats)
|
self._sort_formats(formats)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue