Skip to content

Commit 9af62eb

Browse files
authored
1 parent b994d80 commit 9af62eb

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

spotdl/download/downloader.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,6 @@ async def download_song(self, song_object: SongObject) -> None:
163163
song_object, self.arguments["output_format"]
164164
)
165165

166-
converted_file_path.parent.mkdir(parents=True, exist_ok=True)
167-
168166
# if a song is already downloaded skip it
169167
if converted_file_path.is_file():
170168
if self.display_manager:
@@ -176,6 +174,8 @@ async def download_song(self, song_object: SongObject) -> None:
176174
# ! it here as a continent way to avoid executing the rest of the function.
177175
return None
178176

177+
converted_file_path.parent.mkdir(parents=True, exist_ok=True)
178+
179179
if self.arguments["output_format"] == "m4a":
180180
ytdl_format = "bestaudio[ext=m4a]/bestaudio/best"
181181
elif self.arguments["output_format"] == "opus":
@@ -199,7 +199,7 @@ async def download_song(self, song_object: SongObject) -> None:
199199

200200
try:
201201
downloaded_file_path_string = await self._perform_audio_download_async(
202-
converted_file_path.name.split(".")[0],
202+
converted_file_path.name.rsplit(".", 1)[0],
203203
temp_folder,
204204
audio_handler,
205205
song_object.youtube_link,

spotdl/providers/provider_utils.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import re
2+
13
from pathlib import Path
24
from typing import List
35

@@ -146,4 +148,15 @@ def _parse_path_template(path_template, song_object, output_format, short=False)
146148

147149
converted_file_path = Path(converted_file_name)
148150

151+
santitized_parts = []
152+
for part in converted_file_path.parts:
153+
match = re.search(r"[^\.*](.*)[^\.*$]", part)
154+
if match:
155+
santitized_parts.append(match.group(0))
156+
else:
157+
santitized_parts.append(part)
158+
159+
# Join the parts of the path
160+
converted_file_path = Path(*santitized_parts)
161+
149162
return converted_file_path

0 commit comments

Comments
 (0)