summaryrefslogtreecommitdiff
path: root/tidal_dl_ng/download.py
diff options
context:
space:
mode:
authorRobert Honz <exislow+github@gmail.com>2025-06-30 16:33:32 +0200
committerRobert Honz <exislow+github@gmail.com>2025-06-30 16:33:32 +0200
commit70e29771b930fe1a862fdacf58b244f227e017f2 (patch)
treef43cd0b021db36a71b53acd6247187fc6919b6fa /tidal_dl_ng/download.py
parent0eaeed533fbdc8790413f178cadb73b0ac6949aa (diff)
downloadtidal-dl-ng-70e29771b930fe1a862fdacf58b244f227e017f2.tar.gz
🛠️ Directory length limit is checked and adapted correctly now. Fixes #447 & #436
Diffstat (limited to 'tidal_dl_ng/download.py')
-rw-r--r--tidal_dl_ng/download.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/tidal_dl_ng/download.py b/tidal_dl_ng/download.py
index c7c4af7..9b13053 100644
--- a/tidal_dl_ng/download.py
+++ b/tidal_dl_ng/download.py
@@ -12,6 +12,7 @@ from uuid import uuid4
import m3u8
import requests
from ffmpeg import FFmpeg
+from pathvalidate import sanitize_filename
from requests.adapters import HTTPAdapter, Retry
from requests.exceptions import HTTPError
from rich.progress import Progress, TaskID
@@ -36,7 +37,6 @@ from tidal_dl_ng.helper.path import (
check_file_exists,
format_path_media,
path_file_sanitize,
- sanitize_filename,
url_to_filename,
)
from tidal_dl_ng.helper.tidal import (
@@ -437,9 +437,12 @@ class Download:
elif isinstance(media, Video):
file_extension = AudioExtensions.MP4 if self.settings.data.video_convert_mp4 else VideoExtensions.TS
- # Compute file name, sanitize once again and create destination directory
- path_media_dst = path_media_dst.with_suffix(file_extension)
- path_media_dst = pathlib.Path(path_file_sanitize(path_media_dst, adapt=True))
+ # If file extension was guessed wrong in the beginning
+ if path_media_dst.suffix != file_extension:
+ # Compute file name, sanitize once again, because file extension could have been replaced after guessing it first and create destination directory
+ path_media_dst = path_media_dst.with_suffix(file_extension)
+ path_media_dst = pathlib.Path(path_file_sanitize(path_media_dst, adapt=True))
+
os.makedirs(path_media_dst.parent, exist_ok=True)
if not skip_download: