diff --git a/c3dbdl b/c3dbdl index b4901ff..9e03703 100755 --- a/c3dbdl +++ b/c3dbdl @@ -109,9 +109,6 @@ def downloadSong(destination, filename, entry): download_filename = f"{destination}/{download_filename}" download_path = '/'.join(f"{download_filename}".split('/')[0:-1]) - if not os.path.exists(download_path): - os.makedirs(download_path) - if os.path.exists(download_filename): click.echo(f"File exists at {download_filename}") return None @@ -135,6 +132,10 @@ def downloadSong(destination, filename, entry): else: code = "-1" raise HTTPError(download_url, code, "", None, None) + + if not os.path.exists(download_path): + os.makedirs(download_path) + with open(download_filename, 'wb') as f: for chunk in r.iter_content(chunk_size=8192): f.write(chunk)