You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you want to save in .mp3 just pass the mp3=True parameter (MPEG-4 AAC audio codec):
frompytubefiximportYouTubefrompytubefix.cliimporton_progressurl="url"yt=YouTube(url, on_progress_callback=on_progress)
print(yt.title)
ys=yt.streams.get_audio_only()
ys.download(mp3=True) # pass the parameter mp3=True to save in .mp3
if you want to download complete playlists:
frompytubefiximportPlaylistfrompytubefix.cliimporton_progressurl="url"pl=Playlist(url)
forvideoinpl.videos:
ys=video.streams.get_audio_only()
ys.download(mp3=True) # pass the parameter mp3=True to save in .mp3
if you want to add authentication
frompytubefiximportYouTubefrompytubefix.cliimporton_progressurl="url"yt=YouTube(url, use_oauth=True, allow_oauth_cache=True, on_progress_callback=on_progress)
ys=yt.streams.get_audio_only()
ys.download(mp3=True) # you will only get the request to authenticate once you download