Derive download directory from filename itself

In some cases when using `-f` to create sub-directories from metadata,
where the full slugified download filename and the non-slugified
download directory happen to differ, the download would fail. This
happens because the directory the track needs to be downloaded doesn't
get created.

With this, the download directory will now be derived from filename
itself so that the sub-directory name always overlaps.

Fixes #727.
This commit is contained in:
Ritiek Malhotra
2020-05-20 12:19:13 +05:30
parent b13f12f1fe
commit 2aa7dce4a4

View File

@@ -261,16 +261,7 @@ class Spotdl:
if not self.arguments["no_metadata"]: if not self.arguments["no_metadata"]:
metadata["lyrics"].start() metadata["lyrics"].start()
filter_space_chars = self.output_filename_filter(not self.arguments["no_spaces"]) os.makedirs(os.path.dirname(filename) or ".", exist_ok=True)
directory = os.path.dirname(
spotdl.metadata.format_string(
self.arguments["output_file"],
metadata,
output_extension=output_extension,
sanitizer=filter_space_chars
)
)
os.makedirs(directory or ".", exist_ok=True)
logger.info('Downloading to "{filename}"'.format(filename=filename)) logger.info('Downloading to "{filename}"'.format(filename=filename))
if self.arguments["no_encode"]: if self.arguments["no_encode"]: