Git Product home page Git Product logo

python-rdio's Introduction

python-rdio

About

Another Python library for accessing the Rdio API, using OAuth. Inspired by Rdio's own 'rdio-python' library and python-twitter. This is more or less a test of my own abilities, as I've been writing Django for a while, and I'd like to get into more Python-oriented development.

Function names and objects will follow Rdio's API specs for methods and object types as closely as possible, accounting for Python-ish function and property names (underscores and all that, instead of camelCase).

Installation

Don't sweat it. You can geek out and look at the source by cloning this git repo. But I doubt that's why you're here. Just do this!

pip install python-rdio

What's that? You're not using pip? Shame, shame. I guess you can do this, too.

easy_install python-rdio

Then, follow the usage example below. Please code responsibly. Everything is fully documented. That means you can use __doc__ on each method.

Requirements

Usage

# Setup the API manager. If you have an ACCESS_KEY and ACCESS_SECRET for a
# particular user, you can pass that in as the third and forth arguments
# to Api().
import rdio
rdio_manager = rdio.Api(CONSUMER_KEY, CONSUMER_SECRET)
user = rdio_manager.find_user('[email protected]')
print '%s %s's key is: %s.' % (user.first_name, user.last_name, user.key)

# Set authorization: get authorization URL, then pass back the PIN.
token_dict = rdio_manager.get_token_and_login_url()
print 'Authorize this application at: %s?oauth_token=%s' % (
    token_dict['login_url'], token_dict['oauth_token'])

token_secret = token_dict['oauth_token_secret']
oauth_verifier = raw_input('Enter the PIN / oAuth verifier: ').strip()
token = raw_input('Enter oauth_token parameter from URL: ').strip()
request_token = {"oauth_token":token, oauth_token_secret":token_secret}
authorization_dict = rdio_manager.authorize_with_verifier(oauth_verifier, request_token)

# Get back key and secret. rdio_manager is now authorized
# on the user's behalf.
print 'Access token key: %s' % authorization_dict['oauth_token']
print 'Access token secret: %s' % authorization_dict['oauth_token_secret']

# Make an authorized call.
current_user = rdio_manager.current_user()
print 'The full name of the current user is %s.' % (
    current_user.name,)

# Have some fun.
search_object = rdio_manager.search(
        query='Big Echo',
        types=['Albums',],
        extras=['trackKeys',])
album = search_object.results[0]
print "Found album %s by %s." % (album.name, album.artist_name,)
new_playlist = rdio_manager.create_playlist(
    name='Whoopie!',
    description='A test playlist for the Rdio API.',
    tracks=album.track_keys,
    extras=['trackKeys',])
print "Just made playlist %s with %i tracks at %s! Has tracks: " % (
        new_playlist.name,
        new_playlist.track_count,
        new_playlist.short_url)
tracks = rdio_manager.get(new_playlist.track_keys)
for t in tracks: print "%s (Duration: %i seconds)" % (t.name, t.duration.seconds,)

Version history

Because you all care.

  • Version 0.6: Corrected a regular expression that refused four-character TLDs in emails.
  • Version 0.5: Fixed some bugs around the 0.4 release, including making user.last_song_played an actual RdioTrack. Also made duration a timedelta.
  • Version 0.4: Added object types for Rdio stations as documented here. Also added user lists for heavy rotation results.
  • Version 0.3: All calls implemented; most of them are working properly. Some minor tweaking may need to be done here and there, but a majority of the work is done. Also, setuptools!
  • Version 0.2: Supports PIN authorization through Rdio's oAuth implementation. Added current_user call.
  • Version 0.1: Initial release. Includes data models, unauthenticated API call logic, and one call.

Disclaimer

I don't work for Rdio. I'm just a nerd who loves Rdio. If someone from Rdio has any sort of objections to this package, be it naming or whatever, please contact me at benjaminkreeger [at] gmail [dot] com and we can totally work it out.

python-rdio's People

Contributors

kreeger avatar the3rdhbtaylor avatar

Stargazers

 avatar

Watchers

 avatar  avatar

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.