Better error message when no --live-from-start format
This commit is contained in:
parent
4c3f8c3fb6
commit
319b6059d2
1 changed files with 12 additions and 9 deletions
|
@ -954,13 +954,13 @@ class YoutubeDL(object):
|
||||||
except UnicodeEncodeError:
|
except UnicodeEncodeError:
|
||||||
self.to_screen('Deleting existing file')
|
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')
|
has_drm = info.get('__has_drm')
|
||||||
msg = 'This video is DRM protected' if has_drm else 'No video formats found!'
|
ignored, expected = self.params.get('ignore_no_formats_error'), bool(msg)
|
||||||
expected = self.params.get('ignore_no_formats_error')
|
msg = msg or has_drm and 'This video is DRM protected' or 'No video formats found!'
|
||||||
if forced or not expected:
|
if forced or not ignored:
|
||||||
raise ExtractorError(msg, video_id=info['id'], ie=info['extractor'],
|
raise ExtractorError(msg, video_id=info['id'], ie=info['extractor'],
|
||||||
expected=has_drm or expected)
|
expected=has_drm or ignored or expected)
|
||||||
else:
|
else:
|
||||||
self.report_warning(msg)
|
self.report_warning(msg)
|
||||||
|
|
||||||
|
@ -2440,11 +2440,14 @@ class YoutubeDL(object):
|
||||||
if not self.params.get('allow_unplayable_formats'):
|
if not self.params.get('allow_unplayable_formats'):
|
||||||
formats = [f for f in formats if not f.get('has_drm')]
|
formats = [f for f in formats if not f.get('has_drm')]
|
||||||
|
|
||||||
if info_dict.get('is_live'):
|
get_from_start = not info_dict.get('is_live') or bool(self.params.get('live_from_start'))
|
||||||
get_from_start = 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]
|
formats = [f for f in formats if bool(f.get('is_from_start')) == get_from_start]
|
||||||
if not get_from_start:
|
if get_from_start and not formats:
|
||||||
info_dict['title'] += ' ' + datetime.datetime.now().strftime('%Y-%m-%d %H:%M')
|
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:
|
if not formats:
|
||||||
self.raise_no_formats(info_dict)
|
self.raise_no_formats(info_dict)
|
||||||
|
|
Loading…
Reference in a new issue