Pafy – Getting Meta Data of the Video
Last Updated :
20 Jul, 2020
In this article we will see how we can get meta data 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. Metadata is “data that provides information about other data”. In other words, it is “data about data.” Many distinct types of metadata exist, including descriptive metadata, structural metadata, administrative metadata, reference metadata and statistical metadata.
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 __repr__
method with the pafy object of video
Syntax : video.__repr__()
Argument : It takes no argument
Return : It returns string
Below is the implementation
import pafy
video = pafy.new(url)
value = video.__repr__()
print ( "Meta Data : " + value)
|
Output :
Meta Data : Title: DSA Self Paced Course | GeeksforGeeks
Author: GeeksforGeeks
ID: vG2PNdI8axo
Duration: 00:01:06
Rating: 4.6923075
Views: 75562
Thumbnail: http://i.ytimg.com/vi/vG2PNdI8axo/default.jpg
Another example
import pafy
video = pafy.new(url)
value = video.__repr__()
print ( "Meta Data : " + value)
|
Output :
Meta Data : Title: COVID CASE IN OUR BUILDING - VLOG 32
Author: Tanmay Bhat
ID: i6rhnSoK_gc
Duration: 00:11:42
Rating: 4.9447651
Views: 1128643
Thumbnail: http://i.ytimg.com/vi/i6rhnSoK_gc/default.jpg
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...