访问redtube api的python模块

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第三方库


热门话题
java Vaadin编译小部件(插件)   java Apache Camel库是否会长期保存内存?   java什么是`。伊娃的档案?如何处理它来生成类?   如何通过反射确定Java类是否是抽象的   来自JDK 1.8.0_161的macos Java任务控制在Mac OS X上启动时冻结   java在httpSession中存储扩展对象   SpringBootApplication没有获取java@Service注释bean   java我想从具有innermap和outermap关系的hashmap创建一个hashmap?   java如何强制Eclipse链接创建完全相同类名的表?   java在pojo对象中使用映射未映射请求   java DOM W3c XML元素解析空属性   java我们可以将文本区域中的数据保存到文本文件中吗?   java如何链接首选项。xml到我的表格布局中的settingsTabFragment?   java我想设置一个私有字段来测试函数   接口中的java继承   macos我有一台mac,而java博士根本不运行我的程序   java解析时差   spring应用程序文件上传的java Jar可执行文件失败?   java向Git推送什么?