Skip to content

Instantly share code, notes, and snippets.

@zergon321
Created May 26, 2021 16:38
Show Gist options
  • Save zergon321/3b07eef3bb5135e9aa5f9a7f37156fe4 to your computer and use it in GitHub Desktop.
Save zergon321/3b07eef3bb5135e9aa5f9a7f37156fe4 to your computer and use it in GitHub Desktop.
Download YouTube playlist videos as MP3 files
import pytube, sys, os
if __name__ == "__main__":
playlistURL = sys.argv[1]
playlist = pytube.Playlist(playlistURL)
for video in playlist.videos:
video.streams.get_audio_only().\
download(output_path="./out", filename=video._title)
filename = "./out/" + video._title + ".mp4"
os.rename(filename, filename[:-4] + ".mp3")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment