mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-23 19:33:59 +01:00
[generic] Add a test case for direct links with broken HEAD (#4032)
This commit is contained in:
parent
579657ad87
commit
70b7e3fbb6
|
@ -171,3 +171,13 @@ def assertGreaterEqual(self, got, expected, msg=None):
|
||||||
if msg is None:
|
if msg is None:
|
||||||
msg = '%r not greater than or equal to %r' % (got, expected)
|
msg = '%r not greater than or equal to %r' % (got, expected)
|
||||||
self.assertTrue(got >= expected, msg)
|
self.assertTrue(got >= expected, msg)
|
||||||
|
|
||||||
|
|
||||||
|
def expect_warnings(ydl, warnings_re):
|
||||||
|
real_warning = ydl.report_warning
|
||||||
|
|
||||||
|
def _report_warning(w):
|
||||||
|
if not any(re.search(w_re, w) for w_re in warnings_re):
|
||||||
|
real_warning(w)
|
||||||
|
|
||||||
|
ydl.report_warning = _report_warning
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
|
|
||||||
from test.helper import (
|
from test.helper import (
|
||||||
assertGreaterEqual,
|
assertGreaterEqual,
|
||||||
|
expect_warnings,
|
||||||
get_params,
|
get_params,
|
||||||
gettestcases,
|
gettestcases,
|
||||||
expect_info_dict,
|
expect_info_dict,
|
||||||
|
@ -100,6 +101,7 @@ def _hook(status):
|
||||||
if status['status'] == 'finished':
|
if status['status'] == 'finished':
|
||||||
finished_hook_called.add(status['filename'])
|
finished_hook_called.add(status['filename'])
|
||||||
ydl.add_progress_hook(_hook)
|
ydl.add_progress_hook(_hook)
|
||||||
|
expect_warnings(ydl, test_case.get('expected_warnings', []))
|
||||||
|
|
||||||
def get_tc_filename(tc):
|
def get_tc_filename(tc):
|
||||||
return tc.get('file') or ydl.prepare_filename(tc.get('info_dict', {}))
|
return tc.get('file') or ydl.prepare_filename(tc.get('info_dict', {}))
|
||||||
|
|
|
@ -391,6 +391,21 @@ class GenericIE(InfoExtractor):
|
||||||
'uploader': 'thoughtworks.wistia.com',
|
'uploader': 'thoughtworks.wistia.com',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
# Direct download with broken HEAD
|
||||||
|
{
|
||||||
|
'url': 'http://ai-radio.org:8000/radio.opus',
|
||||||
|
'info_dict': {
|
||||||
|
'id': 'radio',
|
||||||
|
'ext': 'opus',
|
||||||
|
'title': 'radio',
|
||||||
|
},
|
||||||
|
'params': {
|
||||||
|
'skip_download': True, # infinite live stream
|
||||||
|
},
|
||||||
|
'expected_warnings': [
|
||||||
|
r'501.*Not Implemented'
|
||||||
|
],
|
||||||
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
def report_following_redirect(self, new_url):
|
def report_following_redirect(self, new_url):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user