1
0
mirror of https://codeberg.org/polarisfm/youtube-dl synced 2024-11-22 16:44:32 +01:00

rename _parse_mpd to _parse_mpd_formats and add default value for mpd namespace

This commit is contained in:
remitamine 2016-02-06 14:03:48 +01:00
parent 0826a0b555
commit 91cb6b5065
3 changed files with 5 additions and 5 deletions

View File

@ -249,7 +249,7 @@ class TestFormatSelection(unittest.TestCase):
def format_info(f_id): def format_info(f_id):
info = YoutubeIE._formats[f_id].copy() info = YoutubeIE._formats[f_id].copy()
# XXX: In real cases InfoExtractor._parse_mpd() fills up 'acodec' # XXX: In real cases InfoExtractor._parse_mpd_formats() fills up 'acodec'
# and 'vcodec', while in tests such information is incomplete since # and 'vcodec', while in tests such information is incomplete since
# commit a6c2c24479e5f4827ceb06f64d855329c0a6f593 # commit a6c2c24479e5f4827ceb06f64d855329c0a6f593
# test_YoutubeDL.test_youtube_format_selection is broken without # test_YoutubeDL.test_youtube_format_selection is broken without

View File

@ -1343,14 +1343,14 @@ class InfoExtractor(object):
mpd, urlh = res mpd, urlh = res
mpd_base_url = re.match(r'https?://.+/', urlh.geturl()).group() mpd_base_url = re.match(r'https?://.+/', urlh.geturl()).group()
return self._parse_mpd( return self._parse_mpd_formats(
compat_etree_fromstring(mpd.encode('utf-8')), mpd_id, mpd_base_url, formats_dict=formats_dict) compat_etree_fromstring(mpd.encode('utf-8')), mpd_id, mpd_base_url, formats_dict=formats_dict)
def _parse_mpd(self, mpd_doc, mpd_id=None, mpd_base_url='', formats_dict={}): def _parse_mpd_formats(self, mpd_doc, mpd_id=None, mpd_base_url='', formats_dict={}):
if mpd_doc.get('type') == 'dynamic': if mpd_doc.get('type') == 'dynamic':
return [] return []
namespace = self._search_regex(r'(?i)^{([^}]+)?}MPD$', mpd_doc.tag, 'namespace') namespace = self._search_regex(r'(?i)^{([^}]+)?}MPD$', mpd_doc.tag, 'namespace', default=None)
def _add_ns(path): def _add_ns(path):
return self._xpath_ns(path, namespace) return self._xpath_ns(path, namespace)

View File

@ -215,7 +215,7 @@ class FacebookIE(InfoExtractor):
}) })
dash_manifest = f[0].get('dash_manifest') dash_manifest = f[0].get('dash_manifest')
if dash_manifest: if dash_manifest:
formats.extend(self._parse_mpd( formats.extend(self._parse_mpd_formats(
compat_etree_fromstring(compat_urllib_parse_unquote_plus(dash_manifest)))) compat_etree_fromstring(compat_urllib_parse_unquote_plus(dash_manifest))))
if not formats: if not formats:
raise ExtractorError('Cannot find video formats') raise ExtractorError('Cannot find video formats')