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.
Asked
Active
Viewed 154 times
-2
-
Seems related to [this question](https://stackoverflow.com/questions/71376165/how-to-watch-video-without-downloading-like-mpv-using-yt-dl-python). – Benjamin Loison Aug 20 '22 at 18:37
-
No. I want to play the video I have sent to program as podcast. There should not be video. Just its audio. – Deezwend Aug 20 '22 at 19:31
1 Answers
2
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.

Benjamin Loison
- 3,782
- 4
- 16
- 33
-
I installed the 'vlc' library. But I am getting an error: FileNotFoundError: Could not find module 'C:\Users\bugra\Documents\GitHub\x\libvlc.dll' (or one of its dependencies). Try using the full path with constructor syntax. – Deezwend Aug 20 '22 at 19:49
-
Please consider the answers to [this question](https://stackoverflow.com/q/59014318/7123660) then. – Benjamin Loison Aug 20 '22 at 19:56
-
Sir, really thank you a lot. I was searching for how to do this for 8 hours. I was about to go crazy. – Deezwend Aug 20 '22 at 20:13