这是youtube数据api v3的一个简单客户端
pyytdata的Python项目详细描述
这是一个youtube数据api v3包装器,可以集成到任何python应用程序中,基本上是在推荐youtube视频的web应用程序中。在
先决条件
- 从https://console.developers.google.com/apis/获取youtube data v3 api密钥
- Set环境变量API_KEY='YoutubeDatav3 API KEY'
安装
- for stable version
- pip install pyytdata
- for developement
- git clone https://github.com/Agent-Hellboy/YouTubeDataApi_Wrapper/
- cd YouTubeDataApi_Wrapper
- virtualenv venv
- source venv/bin/activate
- pip install -r requirements.txt
使用
>>>frompyytdataimportPyYtData>>>obj=PyYtData('flask',1)>>>vid=obj.get_videoinfo()>>>vid[<util.vidinfo.VidInfoobjectat0x7ff971539e10>]#You can fire dir on this object to get the attribute and method of the object.>>>dir(vid[0])['_Info__API_KEY','__class__','__delattr__','__dict__','__dir__','__doc__','__eq__','__format__','__ge__','__getattribute__','__gt__','__hash__','__init__','__init_subclass__','__le__','__lt__','__module__','__ne__','__new__','__reduce__','__reduce_ex__','__repr__','__setattr__','__sizeof__','__str__','__subclasshook__','__weakref__','_id','channel_info','get_description','get_image_url','get_link','get_publishedtime','get_title','keyword','maxlen','open_id','order','result','type','youtube']# To get the description of the video>>>vid[0].get_description()'Flask is a micro web framework written in Python. It is classified as a microframework because it does not require particular tools or libraries. Learn how to use it ...'# To get the title of the video.>>>vid[0].get_title()'Learn Flask for Python - Full Tutorial'# To get the link for the video which can we used in web app to open the link for the video.>>>vid[0].get_link()'https://www.youtube.com/watch?v=Z1RJmh_OqeA'# To get the title img of the video which can be rendered through HTML tag.>>>vid[0].get_image_url()'https://i.ytimg.com/vi/Z1RJmh_OqeA/mqdefault.jpg'# To get the date at which the video is published>>>vid[0].get_publisheddate()# To get the chnlInfo object having methods which describes a channel.>>>chnl=vid[0].channel_info()>>>dir(chnl)['__class__','__delattr__','__dict__','__dir__','__doc__','__eq__','__format__','__ge__','__getattribute__','__gt__','__hash__','__init__','__init_subclass__','__le__','__lt__','__module__','__ne__','__new__','__reduce__','__reduce_ex__','__repr__','__setattr__','__sizeof__','__str__','__subclasshook__','__weakref__','id','result','total_subscriber','total_video','total_viewcnt','youtube']# To get the total view count of the channel.>>>chnl.total_viewcnt()'95246354'# To get the number of subscribers of the channel.>>>chnl.total_subscriber()'2170000'# To get number of video uploaded by this particular channel.>>>chnl.total_video()'1133'# To get the obejct having stat of the video>>>vidinf=vid[0].video_stat()# To get total number of like to the video>>>vidinf.total_like()'7203'# To get total number of dislike to the video>>>vidinf.total_dislike()'166'# To get total number of views>>>vidinf.total_view()'436803'# To get total number of comment on the video>>>vidinf.total_comment()'621'
一般信息
开发中
- 我认为这个包实现了facade模式,因为像videoinfo和chnlinfo这样的底层包是独立于pyytdata的,不向客户端公开,而且通过提供接口/模块pyytdata,queryer和videoinfo之间的交互对客户端是隐藏的
- vidoinfo类和Chnlinfo有合成关系,因为视频没有通道就不存在
包体系结构
贡献
欢迎拉取请求。对于重大更改,请先打开问题 讨论你想改变什么。在
- 项目
标签: