Ask overwrite confirmation early

Ask whether to overwrite before starting download, this way once
download starts, there will be no more prompts.
This commit is contained in:
Ivan Habunek 2022-01-25 08:08:17 +01:00
parent 8156b18b37
commit 4fd532f05d
No known key found for this signature in database
GPG Key ID: CDBD63C43A30BB95

View File

@ -224,6 +224,12 @@ def _download_clip(slug, args):
target = _clip_target_filename(clip, args) target = _clip_target_filename(clip, args)
print_out("Target: <blue>{}</blue>".format(target)) print_out("Target: <blue>{}</blue>".format(target))
if not args.overwrite and path.exists(target):
response = input("File exists. Overwrite? [Y/n]: ")
if response.lower().strip() not in ["", "y"]:
raise ConsoleError("Aborted")
args.overwrite = True
url = get_clip_authenticated_url(slug, args.quality) url = get_clip_authenticated_url(slug, args.quality)
print_out("<dim>Selected URL: {}</dim>".format(url)) print_out("<dim>Selected URL: {}</dim>".format(url))
@ -249,6 +255,12 @@ def _download_video(video_id, args):
target = _video_target_filename(video, args) target = _video_target_filename(video, args)
print_out("Output: <blue>{}</blue>".format(target)) print_out("Output: <blue>{}</blue>".format(target))
if not args.overwrite and path.exists(target):
response = input("File exists. Overwrite? [Y/n]: ")
if response.lower().strip() not in ["", "y"]:
raise ConsoleError("Aborted")
args.overwrite = True
print_out("<dim>Fetching access token...</dim>") print_out("<dim>Fetching access token...</dim>")
access_token = twitch.get_access_token(video_id) access_token = twitch.get_access_token(video_id)