diff options
author | pukkandan <pukkandan.ytdlp@gmail.com> | 2021-12-06 23:30:33 +0530 |
---|---|---|
committer | pukkandan <pukkandan.ytdlp@gmail.com> | 2021-12-06 23:30:33 +0530 |
commit | 38d79fd16c741ae9e460bc5adbbdb9972347b6be (patch) | |
tree | 17ae89baf80a7bc475e47682f6415035b8b0a165 /yt_dlp/__init__.py | |
parent | acc0d6a411aba58f008e547eb81b4e9e3398d284 (diff) |
Use `parse_duration` for `--wait-for-video`
and some minor fix
Diffstat (limited to 'yt_dlp/__init__.py')
-rw-r--r-- | yt_dlp/__init__.py | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/yt_dlp/__init__.py b/yt_dlp/__init__.py index 5d20ad8c3..3dccdb186 100644 --- a/yt_dlp/__init__.py +++ b/yt_dlp/__init__.py @@ -197,12 +197,11 @@ def _real_main(argv=None): if opts.concurrent_fragment_downloads <= 0: parser.error('Concurrent fragments must be positive') if opts.wait_for_video is not None: - mobj = re.match(r'(?P<min>\d+)(?:-(?P<max>\d+))?$', opts.wait_for_video) - if not mobj: - parser.error('Invalid time range to wait') - min_wait, max_wait = map(int_or_none, mobj.group('min', 'max')) - if max_wait is not None and max_wait < min_wait: + min_wait, max_wait, *_ = map(parse_duration, opts.wait_for_video.split('-', 1) + [None]) + if min_wait is None or (max_wait is None and '-' in opts.wait_for_video): parser.error('Invalid time range to wait') + elif max_wait is not None and max_wait < min_wait: + parser.error('Minimum time range to wait must not be longer than the maximum') opts.wait_for_video = (min_wait, max_wait) def parse_retries(retries, name=''): |