Skip to content

Commit db509ea

Browse files
authored
bugfix: fallback to other file formats (spotDL#1426)
1 parent 5463024 commit db509ea

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

spotdl/download/downloader.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,9 @@ async def download_song(self, song_object: SongObject) -> None:
177177
return None
178178

179179
if self.arguments["output_format"] == "m4a":
180-
ytdl_format = "bestaudio[ext=m4a]"
180+
ytdl_format = "bestaudio[ext=m4a]/bestaudio/best"
181181
elif self.arguments["output_format"] == "opus":
182-
ytdl_format = "bestaudio[ext=webm]"
182+
ytdl_format = "bestaudio[ext=webm]/bestaudio/best"
183183
else:
184184
ytdl_format = "bestaudio"
185185

@@ -220,7 +220,7 @@ async def download_song(self, song_object: SongObject) -> None:
220220

221221
downloaded_file_path = Path(downloaded_file_path_string)
222222

223-
if self.arguments["output_format"] != "m4a":
223+
if downloaded_file_path.suffix == ".m4a" and self.arguments["output_format"] != "m4a":
224224
ffmpeg_success = await ffmpeg.convert(
225225
downloaded_file_path=downloaded_file_path,
226226
converted_file_path=converted_file_path,

spotdl/download/ffmpeg.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,11 @@ async def convert(
6868
"mp3": ["-codec:a", "libmp3lame"],
6969
"flac": ["-codec:a", "flac"],
7070
"ogg": ["-codec:a", "libvorbis"],
71-
"opus": ["-vn", "-c:a", "copy"],
71+
"opus": [
72+
"-vn", "-c:a", "copy"
73+
] if downloaded_file_path.endswith(".opus") else [
74+
"-c:a", "libopus"
75+
],
7276
"m4a": ["-codec:a", "aac", "-vn"],
7377
"wav": [],
7478
}

spotdl/providers/provider_utils.py

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

0 commit comments

Comments
 (0)