0
我需要一個mp3網址。這樣我就可以使用該URL直接在vlc中打開它,這樣vlc就可以作爲流媒體播放。我在stackoverflow上找到了下面的代碼。是否有任何改變,我可以讓它獲得MP3網址。如何使用YouTube-dl python api獲取YouTube鏈接的mp3網址?
我正在pyMusicFs
import youtube_dl
ydl = youtube_dl.YoutubeDL({'outtmpl': '%(id)s%(ext)s'})
# Add all the available extractors
ydl.add_default_info_extractors()
result = ydl.extract_info('http://www.youtube.com/watch?v=BaW_jenozKc'
, download=False # We just want to extract the info
)
if 'entries' in result:
# Can be a playlist or a list of videos
Video = result ['entries'] [0]
else:
# Just a video
video = result
print(video)
video_url = video['url']
print(video_url)
你能舉個例子嗎? – heisenberg
我更新了答案 –