📜  Pafy – 获取视频描述

📅  最后修改于: 2022-05-13 01:55:02.309000             🧑  作者: Mango

Pafy – 获取视频描述

在本文中,我们将看到如何在 pafy 中获取给定 youtube 视频的描述。 Pafy 是一个Python库,用于下载 YouTube 内容和检索元数据。 Pafy 对象是包含有关给定视频的所有信息的对象。 YouTube 视频说明是每个视频下方的文字。它可以帮助观众找到内容并决定是否观看。

我们可以借助new方法获取 pafy 对象,下面是获取给定视频的 pafy 对象的命令

video = pafy.new(url)

视频 url 应该存在于 youtube 上,因为它会获取 youtube 上存在的那些视频的信息。 YouTube 是美国的在线视频分享平台。

为了做到这一点,我们将description属性与视频的 pafy 对象一起使用

下面是实现

# importing pafy
import pafy 
    
# url of video 
url = "https://www.youtube.com / watch?v = vG2PNdI8axo"
    
# getting video
video = pafy.new(url) 
  
# getting description of the video
value = video.description
  
# printing the value
print(value)

输出 :

Still having doubts about this course? Well, don't worry, that's how we humans are coded. But clear all your doubts by heading to the course page of the DSA Self Paced Course: https://practice.geeksforgeeks.org/co...
The course is a bestseller and one of the most promising courses for Data Structures and Algorithms by GeeksforGeeks till date. Register Now: https://practice.geeksforgeeks.org/co...

Please Like, Comment and Share the Video among your friends.

Install our Android App:
https://play.google.com/store/apps/de...

If you wish, translate into the local language and help us reach millions of other geeks:
http://www.youtube.com/timedtext_cs_p...

Follow us on Facebook:
https://www.facebook.com/GfGVideos/

And Twitter:
ht=tps://twitter.com/gfgvideos

Also, Subscribe if you haven't already! :)

另一个例子

# importing pafy
import pafy 
    
# url of video 
url = "https://www.youtube.com / watch?v = 3QKiK4rJIB0"
    
# getting video
video = pafy.new(url) 
  
# getting description of the video
value = video.description
  
  
# printing the value
print("Video description : " + str(value))

输出 :

Video description : None