tmdb的异步api包装(https://www.themoviedb.org/)。
atmdb的Python项目详细描述
TMDb的异步api包装器。
相容性
atmdb使用asyncio和async和await语法,因此 与Python3.5及以上版本兼容
测试
您可以使用python setup.py test运行测试。包含集成 套件,确保环境变量TMDB_API_TOKEN设置为有效的 api令牌,如果直接运行py.test,则使用--runslow。
用法
客户
核心TMDbClient必须用有效的api令牌实例化(请参见 API FAQ有关详细信息),请直接执行以下操作:
from atmdb import TMDbClient client = TMDbClient(api_token='<insert your token here>')
或者作为TMDB_API_TOKEN环境变量:
client = TMDbClient.from_env()
然后可以通过调用 client实例:
movie = await client.get_movie(550) assert movie.title == 'Fight Club'
任何当前未通过helper方法公开的api端点都可以访问 直接使用url_builder和get_data方法,例如:
url = client.url_builder('company/{company_id}', dict(company_id=508)) # ^ endpoint # ^ parameters to insert company = await client.get_data(url) assert company.get('name') == 'Regency Enterprises'
注意,如果不使用helper方法,结果只是一个普通的 字典。
公用事业
atmdb还公开了在更高级别使用api和模型的实用程序 抽象级别,例如:
from aTMDb import TMDbClient from aTMDb.utils import find_overlapping_actors actors = await find_overlapping_actors( ['monty python holy grail', 'meaning of life'], TMDbClient(api_token='<insert your token here>'), ) assert any(person.name == 'Eric Idle' for person in overlap)
文件
其他文档可在PythonHosted上找到。