Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #995 #1065

Merged
merged 3 commits into from
Jan 5, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 12 additions & 2 deletions spotdl/download/downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,13 @@ async def download_song(self, songObj: SongObj) -> None:
else:
youtubeHandler = YouTube(songObj.get_youtube_link())

trackAudioStream = youtubeHandler.streams.get_audio_only()
trackAudioStream = youtubeHandler.streams.filter(only_audio=True).order_by('bitrate').last()

if not trackAudioStream:
print(f"Unable to get audio stream for \"{songObj.get_song_name()}\" "
f"by \"{songObj.get_contributing_artists()[0]}\" "
f"from video \"{songObj.get_youtube_link()}\"")
return None

downloadedFilePath = await self._download_from_youtube(convertedFileName, tempFolder,
trackAudioStream)
Expand Down Expand Up @@ -210,8 +216,12 @@ async def download_song(self, songObj: SongObj) -> None:
# ! as 47 seconds long in your music player, yeah that was an issue earlier.)

command = 'ffmpeg -v quiet -y -i "%s" -acodec libmp3lame -abr true ' \
f'-b:a {trackAudioStream.bitrate} ' \
'-af "apad=pad_dur=2, dynaudnorm, loudnorm=I=-17" "%s"'
formattedCommand = command % (downloadedFilePath, convertedFilePath)
formattedCommand = command % (
downloadedFilePath.replace('$', '\$'),
convertedFilePath.replace('$', '\$')
)

process = await asyncio.subprocess.create_subprocess_shell(formattedCommand)
_ = await process.communicate()
Expand Down