Giter Club home page Giter Club logo

lastfmclient's Introduction

lastfmclient

Python client for the Last.fm API with a pythonic interface. Also includes an async variant of the client for Tornado.

Usage

Regular

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)

import tornado.web
import tornado.gen
from lastfmclient.async import AsyncLastfmClient

class 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:

$ 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

Contact

Jakub Roztočil

lastfmclient's People

Contributors

jkbrzt avatar perlence avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

lastfmclient's Issues

Support http proxy

lastfmclient does not currently works behind proxy mainly due to tornado.

Indeed as you may know tornado only support proxy settings when using tornado.curl_httpclient.CurlAsyncHTTPClient (see tornadoweb/tornado#754). But using tornado.curl_httpclient.CurlAsyncHTTPClient will force user to install pycurl (which depends on libcurl).

You might not want to support http proxy because it depends on curl. But it will good to officially claim no support for http proxy.

I personally need http proxy support for https://github.com/jakubroztocil/cloudtunes behind http proxy. Currently I'm stuck here: https://github.com/jakubroztocil/lastfmclient/blob/master/lastfmclient/async.py#L39

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.