1
0
mirror of https://codeberg.org/polarisfm/youtube-dl synced 2024-11-26 02:14:32 +01:00

Refactor according to requests

This commit is contained in:
Lukas Anzinger 2020-05-11 16:33:39 +02:00
parent fbfd54d0b8
commit 2508a4b6aa
3 changed files with 27 additions and 24 deletions

View File

@ -831,7 +831,8 @@ jwplayer("mediaplayer").setup({"abouttext":"Visit Indie DB","aboutlink":"http:\/
'height': 1080,
}],
{},
), (
),
(
# https://github.com/ytdl-org/youtube-dl/pull/14844
'urls_only',
'http://unknown/manifest.mpd', # mpd_url
@ -915,7 +916,8 @@ jwplayer("mediaplayer").setup({"abouttext":"Visit Indie DB","aboutlink":"http:\/
'height': 1080,
}],
{},
), (
),
(
# https://github.com/ytdl-org/youtube-dl/issues/20346
# Media considered unfragmented even though it contains
# Initialization tag
@ -933,7 +935,6 @@ jwplayer("mediaplayer").setup({"abouttext":"Visit Indie DB","aboutlink":"http:\/
'vcodec': 'none',
'tbr': 129.87,
'asr': 48000,
}, {
'url': 'https://v.redd.it/hw1x7rcg7zl21/DASH_240',
'manifest_url': 'https://v.redd.it/hw1x7rcg7zl21/DASHPlaylist.mpd',
@ -962,7 +963,8 @@ jwplayer("mediaplayer").setup({"abouttext":"Visit Indie DB","aboutlink":"http:\/
'fps': 30,
}],
{},
), (
),
(
'subtitles',
'https://example.com/streams/1/playlist/playlist.mpd', # mpd_url
'https://example.com/streams/1/playlist', # mpd_base_url
@ -1064,12 +1066,12 @@ jwplayer("mediaplayer").setup({"abouttext":"Visit Indie DB","aboutlink":"http:\/
for mpd_file, mpd_url, mpd_base_url, expected_formats, expected_subtitles in _TEST_CASES:
with io.open('./test/testdata/mpd/%s.mpd' % mpd_file,
mode='r', encoding='utf-8') as f:
formats, subtitles = self.ie._parse_mpd_formats_subtitles(
info_dict = self.ie._parse_mpd_formats_subtitles(
compat_etree_fromstring(f.read().encode('utf-8')),
mpd_base_url=mpd_base_url, mpd_url=mpd_url)
self.ie._sort_formats(formats)
expect_value(self, formats, expected_formats, None)
expect_value(self, subtitles, expected_subtitles, None)
self.ie._sort_formats(info_dict['formats'])
expect_value(self, info_dict['formats'], expected_formats, None)
expect_value(self, info_dict['subtitles'], expected_subtitles, None)
def test_parse_f4m_formats(self):
_TEST_CASES = [

View File

@ -2023,8 +2023,10 @@ class InfoExtractor(object):
})
return entries
def _extract_mpd_formats(self, *args, **kwargs):
return self._extract_mpd_formats_subtitles(*args, **kwargs)[0]
def _extract_mpd_formats(self, mpd_url, video_id, mpd_id=None, note=None, errnote=None, fatal=True, formats_dict={}, data=None, headers={}, query={}):
return self._extract_mpd_formats_subtitles(
mpd_url, video_id, mpd_id=mpd_id, note=note, errnote=errnote, fatal=fatal,
formats_dict=formats_dict, data=data, headers=headers, query=query)['formats']
def _extract_mpd_formats_subtitles(self, mpd_url, video_id, mpd_id=None, note=None, errnote=None, fatal=True, formats_dict={}, data=None, headers={}, query={}):
res = self._download_xml_handle(
@ -2040,11 +2042,13 @@ class InfoExtractor(object):
mpd_base_url = base_url(urlh.geturl())
return self._parse_mpd_formats_subtitles(
mpd_doc, mpd_id=mpd_id, mpd_base_url=mpd_base_url,
formats_dict=formats_dict, mpd_url=mpd_url)
mpd_doc, mpd_id=mpd_id, mpd_base_url=mpd_base_url, formats_dict=formats_dict,
mpd_url=mpd_url)
def _parse_mpd_formats(self, *args, **kwargs):
return self._parse_mpd_formats_subtitles(*args, **kwargs)[0]
def _parse_mpd_formats(self, mpd_doc, mpd_id=None, mpd_base_url='', formats_dict={}, mpd_url=None):
return self._parse_mpd_formats_subtitles(
mpd_doc, mpd_id=mpd_id, mpd_base_url=mpd_base_url, formats_dict=formats_dict,
mpd_url=mpd_url)['formats']
def _parse_mpd_formats_subtitles(self, mpd_doc, mpd_id=None, mpd_base_url='', formats_dict={}, mpd_url=None):
"""
@ -2055,7 +2059,7 @@ class InfoExtractor(object):
2. https://en.wikipedia.org/wiki/Dynamic_Adaptive_Streaming_over_HTTP
"""
if mpd_doc.get('type') == 'dynamic':
return []
return {'formats': [], 'subtitles': {}}
namespace = self._search_regex(r'(?i)^{([^}]+)?}MPD$', mpd_doc.tag, 'namespace', default=None)
@ -2337,7 +2341,7 @@ class InfoExtractor(object):
formats.append(full_info)
else:
self.report_warning('Unknown MIME type %s in DASH manifest' % mime_type)
return formats, subtitles
return {'formats': formats, 'subtitles': subtitles}
def _extract_ism_formats(self, ism_url, video_id, ism_id=None, note=None, errnote=None, fatal=True, data=None, headers={}, query={}):
res = self._download_xml_handle(

View File

@ -2390,14 +2390,11 @@ class GenericIE(InfoExtractor):
xspf_base_url=full_response.geturl()),
video_id)
elif re.match(r'(?i)^(?:{[^}]+})?MPD$', doc.tag):
formats, subtitles = self._parse_mpd_formats_subtitles(
doc,
mpd_base_url=full_response.geturl().rpartition('/')[0],
mpd_url=url)
self._sort_formats(formats)
info_dict['formats'] = formats
if subtitles:
info_dict['subtitles'] = subtitles
info_dict.update(
self._parse_mpd_formats_subtitles(
doc, mpd_base_url=full_response.geturl().rpartition('/')[0],
mpd_url=url))
self._sort_formats(info_dict['formats'])
return info_dict
elif re.match(r'^{http://ns\.adobe\.com/f4m/[12]\.0}manifest$', doc.tag):
info_dict['formats'] = self._parse_f4m_formats(doc, url, video_id)