访问redtube api的模块-更新为python 3

python3-redtube的Python项目详细描述


我们走!我想展示一个简单的模块来访问RedTube API。那个api有一些 方法使用外部客户端(如这段小代码)访问其视频库。只有读访问是 目前提供。

所以,我将向您展示一个小例子,如何使用这个酷库:

from redtube import RedClient

red = RedClient()
# Getting top of the top... I think so :)
collection = red.search()
# Search method provides list like object of type RedCollection with video entries of type RedVideo.
print type(collection)
# You can show you total videos for current search and current page
print collection.total, collection.page

# Let's search banana, it's good choice for this search engine
collection = red.search(query='banana', page=2)
# As you can see, we can access next page by page parameter
# Also you can access next page by calling next method from RedCollection instance
collection = red.next()

# You can access video entries by their internal ID
first = red.by_id('1')
# Or by some syntax sugar:
first = red[1]
print first # <RedVideo[1] "Heather taking it deep again">

# RedVideo entries has many useful information about video, ie:
print first.title, first.duration, first.url, first.player_url, first.embed
# As you can see, we can access video streaming url for this client or generate video embed code

# Also you can retrieve tag, category or star lists provided by RedTube
categories, tags, stars = red.categories, red.tags, red.stars
# This methods has internal cache, so you will do only one HTTP request for multi calls.

就这些,伙计们!祝您有个美好的一天!

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
两个日期之间的datetime Java HashMap筛选器   java会选择以下选项吗:django+smartGWT似乎是一个不错的选择?   java如何在jsp中显示Json对象   从Java代码调用装入点文件路径   接口中的java JPA Hibernate更新查询   java在从jsp调用时从类获取根目录   java JFileChooser在JTextField中显示多个选定文件   在Springbean基类中定义的方法中使用@Retryable的java不会被重试   java StackOverflower错误和等于疯狂数字的值   swing使Java打印的页边距更小   java使用Matisse GUI builder设置最大宽度   带MySQL的java注册表单JavaFX在intellij中失败   java监听音量按钮事件安卓   java正在寻找一个新的应用程序。NET 3.5/J2EE体系结构概念比较文章/图表   java如何使用SpringJDBC检索记录   java MULE ESB:带有regex()函数的表达式过滤器   java JFrame按钮逻辑错误   java Android SQLite在Date1和Date2之间选择   java求解丢番图方程