Skip to content

Commit

Permalink
Use the highest bitrate stream regardless of codec
Browse files Browse the repository at this point in the history
The get_audio_only function defaults to filtering for mp4 streams.
This seems arbitrary as ffmpeg has the capabilities for other codecs
too and higher quality may be achieved this way.
  • Loading branch information
pithuene committed Jan 2, 2021
1 parent ff40b1f commit 172209e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion 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

0 comments on commit 172209e

Please sign in to comment.