mirror of
https://codeberg.org/polarisfm/youtube-dl
synced 2025-01-10 07:07:55 +01:00
[picta] Fix KeyError when missing attributes in MPD
Get element attribute using element.get('key') instead of element.attrib['index'] manifests like: SegmentList/Initialization@sourceURL SegmentList/SegmentURL@media Example MPD manifest https://www.picta.cu/videos/3bf20311b6564d61a0fd519b3c7dcced/manifest.mpd
This commit is contained in:
parent
3fb09eecd5
commit
b5626f1979
@ -2054,8 +2054,8 @@ class InfoExtractor(object):
|
||||
|
||||
def extract_Initialization(source):
|
||||
initialization = source.find(_add_ns('Initialization'))
|
||||
if initialization is not None:
|
||||
ms_info['initialization_url'] = initialization.attrib['sourceURL']
|
||||
if initialization is not None and initialization.get('sourceURL') is not None:
|
||||
ms_info['initialization_url'] = initialization.get('sourceURL')
|
||||
|
||||
segment_list = element.find(_add_ns('SegmentList'))
|
||||
if segment_list is not None:
|
||||
@ -2063,7 +2063,9 @@ class InfoExtractor(object):
|
||||
extract_Initialization(segment_list)
|
||||
segment_urls_e = segment_list.findall(_add_ns('SegmentURL'))
|
||||
if segment_urls_e:
|
||||
ms_info['segment_urls'] = [segment.attrib['media'] for segment in segment_urls_e]
|
||||
segment_urls = [segment.get('media') for segment in segment_urls_e if segment.get('media') is not None]
|
||||
if len(segment_urls) > 0:
|
||||
ms_info['segment_urls'] = segment_urls
|
||||
else:
|
||||
segment_template = element.find(_add_ns('SegmentTemplate'))
|
||||
if segment_template is not None:
|
||||
|
Loading…
Reference in New Issue
Block a user