Add --overwrite option

issue #37
This commit is contained in:
Ivan Habunek 2020-09-29 10:57:09 +02:00
parent 2abc56213e
commit c510d5aae4
No known key found for this signature in database
GPG Key ID: CDBD63C43A30BB95
3 changed files with 12 additions and 2 deletions

View File

@ -6,6 +6,8 @@ Twitch Downloader change log
* Added `source` as alias for best available quality (#33) * Added `source` as alias for best available quality (#33)
* Added `--no-join` option to `download` to skip ffmpeg join (#36) * Added `--no-join` option to `download` to skip ffmpeg join (#36)
* Added `--overwrite` option to `download` to overwrite target without prompting
for confirmation (#37)
1.11.0 (2020-09-03) 1.11.0 (2020-09-03)
------------------- -------------------

View File

@ -106,7 +106,7 @@ def _select_playlist_interactive(playlists):
return uri return uri
def _join_vods(playlist_path, target): def _join_vods(playlist_path, target, overwrite, no_overwrite):
command = [ command = [
"ffmpeg", "ffmpeg",
"-i", playlist_path, "-i", playlist_path,
@ -116,6 +116,9 @@ def _join_vods(playlist_path, target):
"-loglevel", "warning", "-loglevel", "warning",
] ]
if overwrite:
command.append("-y")
print_out("<dim>{}</dim>".format(" ".join(command))) print_out("<dim>{}</dim>".format(" ".join(command)))
result = subprocess.run(command) result = subprocess.run(command)
if result.returncode != 0: if result.returncode != 0:
@ -308,7 +311,7 @@ def _download_video(video_id, args):
print_out("\n\nJoining files...") print_out("\n\nJoining files...")
target = _video_target_filename(video, args.format) target = _video_target_filename(video, args.format)
_join_vods(playlist_path, target) _join_vods(playlist_path, target, args.overwrite)
if args.keep: if args.keep:
print_out("\n<dim>Temporary files not deleted: {}</dim>".format(target_dir)) print_out("\n<dim>Temporary files not deleted: {}</dim>".format(target_dir))

View File

@ -123,6 +123,11 @@ COMMANDS = [
"action": "store_true", "action": "store_true",
"default": False, "default": False,
}), }),
(["--overwrite"], {
"help": "Overwrite the target file if it already exists without prompting.",
"action": "store_true",
"default": False,
})
], ],
), ),
] ]