Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jkbrzt/lastfmclient
Python client for the Last.fm API. Non-blocking client for Tornado included.
https://github.com/jkbrzt/lastfmclient
api-client async client jakubroztocil lastfm lastfm-api python tornado
Last synced: 6 days ago
JSON representation
Python client for the Last.fm API. Non-blocking client for Tornado included.
- Host: GitHub
- URL: https://github.com/jkbrzt/lastfmclient
- Owner: jkbrzt
- License: other
- Created: 2013-02-22T20:02:50.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2019-10-03T22:26:34.000Z (about 5 years ago)
- Last Synced: 2024-11-01T10:42:06.342Z (13 days ago)
- Topics: api-client, async, client, jakubroztocil, lastfm, lastfm-api, python, tornado
- Language: Python
- Homepage: https://twitter.com/jakubroztocil
- Size: 69.3 KB
- Stars: 23
- Watchers: 3
- Forks: 6
- Open Issues: 3
-
Metadata Files:
- Readme: README.rst
Awesome Lists containing this project
README
``lastfmclient``
################Python client for the `Last.fm API `_ with a
pythonic interface. Also includes an async variant of the client for
`Tornado `_.Usage
=====Regular
-------.. code-block:: python
from lastfmclient import LastfmClient
api = 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',
)print resp
Asynchronous (uses ``tornado.httpclient.AsyncHTTPClient``)
----------------------------------------------------------.. code-block:: python
import tornado.web
import tornado.gen
from lastfmclient.async import AsyncLastfmClientclass Scrobbler(tornado.web.RequestHandler):
@tornado.gen.coroutine
def post(self):
api = AsyncLastfmClient(
api_key=KEY,
api_secret=SECRET,
session_key=session_key
)resp = yield api.track.update_now_playing(
track='Paranoid Android',
artist='Radiohead',
album='OK Computer',
)
self.finish(resp)See also `examples `_.
Client methods
==============All the methods the Last.fm API provides are mirrored in the client with
rich docstrings and arguments description. This code is actually generated
directly from the online API documentation pages
(see ``./generate.py``, ``./api.json``, and ``./lastfmclient/api.py``).The defined methods be updated to the current version of the documentation via:
.. code-block:: bash
$ 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:
$ makeContact
=======Jakub Roztočil
* https://github.com/jakubroztocil
* https://twitter.com/jakubroztocil
* https://roztocil.co