In this article we will see how we can get the all streams of the given youtube video in pafy. Pafy is a python library to download YouTube content and retrieve metadata. Pafy object is the object which contains all the information about the given video. All streams are basically all the available streams for video and audio combined.
We can get the pafy object with the help of new
method, below is the command to get the pafy object for given video
video = pafy.new(url)
The video url should exist on youtube as it get the information of those videos which are present on the youtube. YouTube is an American online video-sharing platform.
In order to do this we use allstreams
attribute with the pafy object of video
Syntax : video.allstreams
Argument : It takes no argument
Return : It returns list of streams
Below is the implementation
import pafy
video = pafy.new(url)
value = video.allstreams
print (value)
|
Output :
[audio:webm@50k, audio:webm@70k, audio:m4a@128k, audio:webm@160k, video:mp4@256x144, video:webm@256x144, video:mp4@426x240, video:webm@426x240, video:mp4@640x360, video:mp4@854x480, video:webm@640x360, video:webm@854x480, video:mp4@1280x720, video:webm@1280x720, normal:mp4@640x360, normal:mp4@1280x720]
Another example
import pafy
video = pafy.new(url)
value = video.allstreams
print (value)
|
Output :
[audio:webm@50k, audio:webm@70k, audio:m4a@128k, audio:webm@160k, video:mp4@256x144, video:webm@256x144, video:mp4@426x240, video:webm@426x240, video:mp4@640x360, video:webm@640x360, video:webm@854x480, video:mp4@854x480, video:mp4@1280x720, video:webm@1280x720, normal:mp4@640x360, normal:mp4@1280x720]