As I said on the title, I want to play a video as podcast from YouTube in program without downloading the video from YouTube in Python. I did a detailed search on the internet on how to do it but I could find nothing about it.
CodePudding user response:
Thanks to YouTube-DL we can retrieve the YouTube video audio link then we can provide it to the VLC media player to play it without downloading as a file the audio.
import youtube_dl, vlc
youtube_dl_options = {
'quiet': True,
'format': 'bestaudio',
}
with youtube_dl.YoutubeDL() as yt_dl:
info = yt_dl.extract_info(YOUR_VIDEO_ID, download=False)
audio_url = info['formats'][0]['url']
player = vlc.MediaPlayer(audio_url)
player.play()
BaW_jenozKc
is an example of video id.