diff options
| author | Robert Honz <exislow+github@gmail.com> | 2024-01-17 22:08:39 +0100 |
|---|---|---|
| committer | Robert Honz <exislow+github@gmail.com> | 2024-01-17 22:08:39 +0100 |
| commit | 62c75e6c972eed4aadaba3dd03e60d63c31eb995 (patch) | |
| tree | e71f22c5757a0e81cf157016d8f9de26234054f3 /tidal_dl_ng/helper/path.py | |
| parent | bdccb8be37fd941cd5c681950a7e25085efbabb0 (diff) | |
| download | tidal-dl-ng-62c75e6c972eed4aadaba3dd03e60d63c31eb995.tar.gz | |
✨ File extension stored in an enum. File exists check refactored to explicit extension check.
Diffstat (limited to 'tidal_dl_ng/helper/path.py')
| -rw-r--r-- | tidal_dl_ng/helper/path.py | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/tidal_dl_ng/helper/path.py b/tidal_dl_ng/helper/path.py index fc8602c..a2ce98c 100644 --- a/tidal_dl_ng/helper/path.py +++ b/tidal_dl_ng/helper/path.py @@ -9,7 +9,7 @@ from pathvalidate.error import ValidationError from tidalapi import Album, Mix, Playlist, Track, UserPlaylist, Video from tidal_dl_ng import __name_display__ -from tidal_dl_ng.constants import MediaType +from tidal_dl_ng.constants import AudioExtensions, MediaType def path_home() -> str: @@ -210,9 +210,14 @@ def path_file_sanitize(path_file: str, adapt: bool = False) -> (bool, str): def check_file_exists(path_file: str, extension_ignore: bool = False): if extension_ignore: - path_file = Path(path_file).stem + ".*" + path_file_stem: str = Path(path_file).stem + path_files: [str] = [] - # TODO: Check what happens is (no) files . - result = bool(glob.glob(path_file)) + for extension in AudioExtensions: + path_files.append(path_file_stem + extension.value) + else: + path_files: [str] = [path_file] + + result = bool(sum([glob.glob(_file) for _file in path_files], [])) return result |
