Merge pull request #195 from ISkIN-AI/fixfolderpath

Added the ability to create a folder hierarchy
This commit is contained in:
Vitiko 2023-02-20 14:19:09 -04:00 committed by GitHub
commit 95380b6eb1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3,7 +3,7 @@ import os
from typing import Tuple from typing import Tuple
import requests import requests
from pathvalidate import sanitize_filename from pathvalidate import sanitize_filename, sanitize_filepath
from tqdm import tqdm from tqdm import tqdm
import qobuz_dl.metadata as metadata import qobuz_dl.metadata as metadata
@ -97,7 +97,7 @@ class Download:
folder_format, track_format = _clean_format_str( folder_format, track_format = _clean_format_str(
self.folder_format, self.track_format, file_format self.folder_format, self.track_format, file_format
) )
sanitized_title = sanitize_filename(folder_format.format(**album_attr)) sanitized_title = sanitize_filepath(folder_format.format(**album_attr))
dirn = os.path.join(self.path, sanitized_title) dirn = os.path.join(self.path, sanitized_title)
os.makedirs(dirn, exist_ok=True) os.makedirs(dirn, exist_ok=True)
@ -156,7 +156,7 @@ class Download:
track_attr = self._get_track_attr( track_attr = self._get_track_attr(
meta, track_title, bit_depth, sampling_rate meta, track_title, bit_depth, sampling_rate
) )
sanitized_title = sanitize_filename(folder_format.format(**track_attr)) sanitized_title = sanitize_filepath(folder_format.format(**track_attr))
dirn = os.path.join(self.path, sanitized_title) dirn = os.path.join(self.path, sanitized_title)
os.makedirs(dirn, exist_ok=True) os.makedirs(dirn, exist_ok=True)