Skip to content

Commit

Permalink
Merge pull request #1449 from spotDL/dev
Browse files Browse the repository at this point in the history
  • Loading branch information
xnetcat authored Jan 3, 2022
2 parents fe580b8 + b9ad323 commit 6d4ae78
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 10 deletions.
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[metadata]
version = 3.9.1
version = 3.9.2

name = spotdl
url = https://github.com/spotDL/spotify-downloader
Expand Down
20 changes: 17 additions & 3 deletions spotdl/download/ffmpeg.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,31 @@ async def convert(
"flac": ["-codec:a", "flac"],
"ogg": ["-codec:a", "libvorbis"],
"opus": ["-vn", "-c:a", "copy"]
if downloaded_file_path.endswith(".opus")
if downloaded_file_path.endswith(".webm")
else ["-c:a", "libopus"],
"m4a": ["-codec:a", "aac", "-vn"],
"wav": [],
}

bitrates = {
"mp3": ["-q:a", "0"],
"flac": [],
"ogg": ["-q:a", "5"],
"opus": []
if downloaded_file_path.endswith(".webm")
else ["-b:a", "160K"],
"m4a": []
if downloaded_file_path.endswith(".m4a")
else ["-b:a", "160K"],
"wav": [],
}

if output_format is None:
output_format_command = formats["mp3"]
output_bitrate = bitrates["mp3"]
else:
output_format_command = formats[output_format]
output_bitrate = bitrates[output_format]

if ffmpeg_path is None:
ffmpeg_path = "ffmpeg"
Expand All @@ -89,8 +104,7 @@ async def convert(
*output_format_command,
"-abr",
"true",
"-q:a",
"0",
*output_bitrate,
"-v",
"debug",
converted_file_path,
Expand Down
24 changes: 18 additions & 6 deletions spotdl/search/song_gatherer.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,10 @@ def get_tracks(track):
)

if generate_m3u:
file_path = _parse_path_template(path_template, song, output_format)
if path_template:
file_path = _parse_path_template(path_template, song, output_format)
else:
file_path = _get_converted_file_path(song, output_format)

return song, f"{file_path}\n"

Expand All @@ -201,8 +204,11 @@ def get_tracks(track):
return None, None
except OSError:
if generate_m3u:
song_obj = SongObject({*track}, album_response, {}, None, "", None)
file_path = _parse_path_template(path_template, song_obj, output_format)
song_obj = SongObject(track, album_response, {}, None, "", None)
if path_template:
file_path = _parse_path_template(path_template, song_obj, output_format)
else:
file_path = _get_converted_file_path(song_obj, output_format)

return None, f"{file_path}\n"

Expand Down Expand Up @@ -302,7 +308,10 @@ def get_song(track):
)

if generate_m3u:
file_path = _parse_path_template(path_template, song, output_format)
if path_template:
file_path = _parse_path_template(path_template, song, output_format)
else:
file_path = _get_converted_file_path(song, output_format)

return song, f"{file_path}\n"

Expand All @@ -312,9 +321,12 @@ def get_song(track):
except OSError:
if generate_m3u:
song_obj = SongObject(
{*track["track"]}, {}, {}, None, "", playlist_response
track["track"], {}, {}, None, "", playlist_response
)
file_path = _parse_path_template(path_template, song_obj, output_format)
if path_template:
file_path = _parse_path_template(path_template, song_obj, output_format)
else:
file_path = _get_converted_file_path(song_obj, output_format)

return None, f"{file_path}\n"

Expand Down

0 comments on commit 6d4ae78

Please sign in to comment.