Reputation: 1325
currently i am doing this
from youtube_dl import YoutubeDL
y=YoutubeDL()
url = 'youtube url'
r=y.extract_info(url, download=False)
r.get('formats') contain all video, audio link
I need only specified format video audio link.
But i dont know where to specify or which param to set for format
Upvotes: 0
Views: 2062
Reputation: 3009
Use the format
parameter, which accepts the same value as the --format
option:
from youtube_dl import YoutubeDL
y = YoutubeDL({
'format': 'bestaudio',
})
url = 'http://www.youtube.com/watch?v=BaW_jenozKcj'
r = y.extract_info(url, download=False)
print(r['ext'])
print(r['url'])
Prints:
m4a
https://r3---sn-h5q7dned.googlevideo.com/videoplayback?<...>
Upvotes: 2