skips downloading files which already exist

pull/1/head
Mike Lynch 2023-10-21 09:55:05 +11:00
parent 8375051085
commit 793b615278
1 changed files with 7 additions and 4 deletions

View File

@ -9,10 +9,13 @@ from pathlib import Path
def download_audio(link, destdir): def download_audio(link, destdir):
parts = link.split('/') parts = link.split('/')
ptarget = Path(destdir) / Path(parts[-1]) ptarget = Path(destdir) / Path(parts[-1])
target = str(ptarget.resolve()) target = ptarget.resolve()
args = [ "wget", link, "-o", target ] if target.exists():
print(f"downloading {link} to {target}") print("File already exists, skipping")
subprocess.run(args) else:
args = [ "wget", link, "-o", str(target) ]
print(f"downloading {link}")
subprocess.run(args)