mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-12-11 14:18:18 +01:00
Better error message when no --live-from-start format
This commit is contained in:
parent
4c3f8c3fb6
commit
319b6059d2
@ -954,13 +954,13 @@ def report_file_delete(self, file_name):
|
||||
except UnicodeEncodeError:
|
||||
self.to_screen('Deleting existing file')
|
||||
|
||||
def raise_no_formats(self, info, forced=False):
|
||||
def raise_no_formats(self, info, forced=False, *, msg=None):
|
||||
has_drm = info.get('__has_drm')
|
||||
msg = 'This video is DRM protected' if has_drm else 'No video formats found!'
|
||||
expected = self.params.get('ignore_no_formats_error')
|
||||
if forced or not expected:
|
||||
ignored, expected = self.params.get('ignore_no_formats_error'), bool(msg)
|
||||
msg = msg or has_drm and 'This video is DRM protected' or 'No video formats found!'
|
||||
if forced or not ignored:
|
||||
raise ExtractorError(msg, video_id=info['id'], ie=info['extractor'],
|
||||
expected=has_drm or expected)
|
||||
expected=has_drm or ignored or expected)
|
||||
else:
|
||||
self.report_warning(msg)
|
||||
|
||||
@ -2440,11 +2440,14 @@ def sanitize_numeric_fields(info):
|
||||
if not self.params.get('allow_unplayable_formats'):
|
||||
formats = [f for f in formats if not f.get('has_drm')]
|
||||
|
||||
if info_dict.get('is_live'):
|
||||
get_from_start = bool(self.params.get('live_from_start'))
|
||||
get_from_start = not info_dict.get('is_live') or bool(self.params.get('live_from_start'))
|
||||
if not get_from_start:
|
||||
info_dict['title'] += ' ' + datetime.datetime.now().strftime('%Y-%m-%d %H:%M')
|
||||
if info_dict.get('is_live') and formats:
|
||||
formats = [f for f in formats if bool(f.get('is_from_start')) == get_from_start]
|
||||
if not get_from_start:
|
||||
info_dict['title'] += ' ' + datetime.datetime.now().strftime('%Y-%m-%d %H:%M')
|
||||
if get_from_start and not formats:
|
||||
self.raise_no_formats(info_dict, msg='--live-from-start is passed, but there are no formats that can be downloaded from the start. '
|
||||
'If you want to download from the current time, pass --no-live-from-start')
|
||||
|
||||
if not formats:
|
||||
self.raise_no_formats(info_dict)
|
||||
|
Loading…
Reference in New Issue
Block a user