python client for the last.fm api,所有方法都有pythonic接口,包括auth等。还包括一个基于tornado的异步客户端。
lastfmclient的Python项目详细描述
带有 pythonic接口。还包括 Tornado。
用法
常规
fromlastfmclientimportLastfmClientapi=LastfmClient(api_key=KEY,api_secret=SECRET,session_key=session_key)resp=api.track.update_now_playing(track='Paranoid Android',artist='Radiohead',album='OK Computer',)printresp
异步(使用tornado.httpclient.AsyncHTTPClient)
importtornado.webimporttornado.genfromlastfmclient.asyncimportAsyncLastfmClientclassScrobbler(tornado.web.RequestHandler):@tornado.gen.coroutinedefpost(self):api=AsyncLastfmClient(api_key=KEY,api_secret=SECRET,session_key=session_key)resp=yieldapi.track.update_now_playing(track='Paranoid Android',artist='Radiohead',album='OK Computer',)self.finish(resp)
另请参见examples。
客户端方法
last.fm api提供的所有方法都与 丰富的文档字符串和参数描述。此代码实际上是生成的 直接从在线api文档页面 (请参见./generate.py、./api.json和./lastfmclient/api.py)。
定义的方法将通过以下途径更新到文档的当前版本:
$ pip install -r requirements.txt lxml # 1. Generate fresh api.json from docs at http://www.last.fm/api: $ make spec # 2. Generate `lastfm/api.py` from `api.json`: $ make code # Or, all the above in one step: $ make
联系人
Jakub Rozto_il