From 62c75e6c972eed4aadaba3dd03e60d63c31eb995 Mon Sep 17 00:00:00 2001 From: Robert Honz Date: Wed, 17 Jan 2024 22:08:39 +0100 Subject: ✨ File extension stored in an enum. File exists check refactored to explicit extension check. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tidal_dl_ng/helper/path.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'tidal_dl_ng/helper/path.py') 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 -- cgit v1.3.1