From 6813bb51b4fc9fe9e6a01f671d21571a113fdacf Mon Sep 17 00:00:00 2001 From: Ivan Habunek Date: Fri, 23 Aug 2019 10:16:49 +0200 Subject: [PATCH] Add option not to delete downloaded VODs --- twitchdl/commands.py | 13 ++++++++----- twitchdl/console.py | 5 +++++ 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/twitchdl/commands.py b/twitchdl/commands.py index 91f5c97..8e016b7 100644 --- a/twitchdl/commands.py +++ b/twitchdl/commands.py @@ -184,7 +184,7 @@ def parse_video_id(video_id): raise ConsoleError("Invalid video ID given, expected integer ID or Twitch URL") -def download(video_id, max_workers, format='mkv', start=None, end=None, **kwargs): +def download(video_id, max_workers, format='mkv', start=None, end=None, keep=False, **kwargs): video_id = parse_video_id(video_id) if start and end and end <= start: @@ -221,8 +221,11 @@ def download(video_id, max_workers, format='mkv', start=None, end=None, **kwargs target = _video_target_filename(video, format) _join_vods(directory, paths, target) - print_out("\nDeleting vods...") - for path in paths: - os.unlink(path) + if keep: + print_out("\nTemporary files not deleted: {}".format(directory)) + else: + print_out("\nDeleting vods...") + for path in paths: + os.unlink(path) - print_out("\nDownloaded: {}".format(target)) + print_out("Downloaded: {}".format(target)) diff --git a/twitchdl/console.py b/twitchdl/console.py index 78fc163..2f69867 100644 --- a/twitchdl/console.py +++ b/twitchdl/console.py @@ -89,6 +89,11 @@ COMMANDS = [ "type": str, "default": "mkv", }), + (["-k", "--keep"], { + "help": "Don't delete downloaded VODs and playlists after merging.", + "action": "store_true", + "default": False, + }), ], ), ]