Rdio-Sock Documentation

Start with the following example:

rdio = RdioSock()

# Login to Rdio
rdio.user.login("<username>", "<password>")

# Song changed callback
def song_changed(track):
    print "%s - %s - %s" % (track.name, track.album, track.artist)

# PubSub connected callback
def pubsub_connected():
    # Subscribe services into pubsub updates
    rdio.pubsub.subscribe(rdio.services.fields)
    rdio.pubsub.subscribe(rdio.services.private)

    # Bind player events
    rdio.player.on_song_changed.bind(song_changed)

    # Force a player update to get the current state
    # (Updates after this are done via PubSub automatically)
    rdio.player.update()

rdio.pubsub.on_connected.bind(pubsub_connected)

# Connect the WebSocket-PubSub client to enable real-time updates
rdio.pubsub.connect()

When you have this working you should be able to dive into the documentation starting at the main client class rdiosock.RdioSock

Classes

Core:

RdioSock

class rdiosock.RdioSock(useragent=None)[source]

Rdio-Sock client

Parameters:useragent (str) – User-Agent to use for HTTP/HTTPS requests or None which defaults to Chrome 25.0

Fields

pubsub

rdiosock.pubsub.RdioPubSub

PubSub client

services

rdiosock.RdioSockServiceManager

Rdio service manager

metadata

rdiosock.metadata.RdioMetadata

player

rdiosock.player.RdioPlayer

user

rdiosock.user.RdioUser

server_info

rdiosock.server_info.RdioServerInfo

version

int

Rdio communication version

class rdiosock.RdioSockServiceManager(sock)[source]

Rdio service manager

Fields

fields

rdiosock.services.fields.RdioFieldService

Field service manager

private

rdiosock.services.private.RdioPrivateService

Private service manager

RdioMetadata

class rdiosock.metadata.RdioMetadata(sock)[source]
search(query, search_types=SEARCH_TYPES.ALL, search_extras=SEARCH_EXTRAS.ALL)[source]

Search for media item.

Parameters:
class rdiosock.metadata.SEARCH_TYPES[source]

Metadata search types

NONE
ALL
ARTIST
ALBUM
TRACK
PLAYLIST
USER
LABEL
class rdiosock.metadata.SEARCH_EXTRAS[source]

Metadata search extras

NONE
ALL
LOCATION
USERNAME
STATIONS
DESCRIPTION
FOLLOWER_COUNT
FOLLOWING_COUNT
SET_COUNT
ICON_250x375
ICON_500x750
ICON_250x333
ICON_500x667

RdioPlayer

class rdiosock.player.RdioPlayer(sock)[source]

Class Constants

REPEAT_ALL
REPEAT_ONE
REPEAT_NONE

Fields

Un-changeable fields updated via PubSub

last_song_played

rdiosock.objects.queue.RdioQueue

Last song played

last_song_play_time
last_source_played

rdiosock.objects.source.RdioSource

Last source played

on_song_changed

rdiosock.utils.EventHook

Song changed event

player_state

rdiosock.objects.player_state.RdioPlayerState

Current Rdio player state

queue

rdiosock.objects.queue.RdioQueue

Current Rdio player state

Properties

Changeable properties updated and changed via PubSub

volume

float

Player volume (0.0 - 1.0)

NOTE: This property sends pubsub messages

shuffle

bool

Player shuffle mode

NOTE: This property sends pubsub messages

repeat

RdioPlayer.REPEAT_ALL, RdioPlayer.REPEAT_ONE, RdioPlayer.REPEAT_NONE

Player repeat mode

NOTE: This property sends pubsub messages

position

int

Player position in seconds

NOTE: This property sends pubsub messages

Methods

update(callback=None)[source]

Force a player state and queue update

get_playback_info(key, manual_play=True)[source]

Get track playback info

Parameters:key (str) – Track Key
toggle_pause()[source]
toggle_shuffle()[source]
play()[source]
pause()[source]
previous()[source]
next()[source]
next_source()[source]

RdioPubSub

class rdiosock.pubsub.RdioPubSub(sock)[source]

PubSub client

connect(update=True)[source]

Connect to PubSub server

Parameters:update (bool) – Force pubsub info update (pubsubInfo)
publish(topic, data)[source]

Publish PubSub message

Parameters:
  • topic (str) – Topic Name
  • data (object) – json serializable object
subscribe(service, target=None)[source]

Subscribe RdioService into pubsub messages

Parameters:
  • service (rdiosock.services.RdioService) – RdioService instance
  • target (str or None) – Target (User, Playlist) or None to indicate current user
subscribe_topic(topic, callback, target=None)[source]

Subscribe to pubsub topic

Parameters:
  • topic (str) – Topic Name
  • callback (function) – callback(message) will be called when messages are received

RdioServerInfo

class rdiosock.server_info.RdioServerInfo(sock)[source]

Fields

country_code

str

country_name

str

locale

str

RdioUser

class rdiosock.user.RdioUser(sock)[source]

Fields

id

int

key

str

authorization_key

str

first_name

str

last_name

str

vanity_name

str

is_anonymous

bool

new_user

bool

Methods

login(username, password, remember=True)[source]

Login as an Rdio user

Parameters:
  • username (str) – Username in plaintext
  • password (str) – Password in plaintext
  • remember (bool) – Should we remember this login authorization?

Services:

RdioFieldService

class rdiosock.services.fields.RdioFieldService(sock)[source]

Field service manager

Fields

fields

dict

Dictionary of current field values

Events

on_changed

rdiosock.utils.EventHook

Field changed event

Callback Parameters: (field_name, field_value)

RdioPrivateService

class rdiosock.services.private.RdioPrivateService(sock)[source]

Private service manager

Events

on_player_state_changed

rdiosock.utils.EventHook

Player state changed event

Callback Parameters: ()

on_queue_changed

rdiosock.utils.EventHook

Queue changed event

Callback Parameters: ()

Objects:

RdioMediaItem

class rdiosock.objects.base.RdioMediaItem[source]

Rdio base media item

can_sample

bool

can_stream

bool

can_tether

bool

is_clean

bool

is_explicit

bool

duration

int

price

float

embed_url

str

iframe_url

str

RdioNamedItem

class rdiosock.objects.base.RdioNamedItem[source]
name

str

length

int

short_url

str

RdioIconItem

class rdiosock.objects.base.RdioIconItem[source]
base_icon

str

icon

str

RdioDataItem

class rdiosock.objects.base.RdioDataItem[source]
key

str

type

str

url

str

RdioBaseItem

class rdiosock.objects.base.RdioBaseItem[source]
classmethod parse(data)[source]

Parse data into object

Parameters:data (str or dict) – Data to parse
Return type:rdiosock.objects.base.RdioBaseItem

RdioAlbum

class rdiosock.objects.album.RdioAlbum[source]

Rdio Album

artist

str

artist_key

str

artist_url

str

big_icon

str

big_icon_1200

str

copyright

str

display_date

unknown

icon_400

str

labels

unknown

network_consumers

list of rdiosock.objects.person.RdioPerson

playlist_count

int

play_count

int

release_date

unknown

review

str

tracks

list of rdiosock.objects.track.RdioTrack

track_keys

list of str

parse_tracks(key, value)[source]

Parse tracks list

Parameters:value (dict) – tracks list dictionary

RdioMediaItem (Inherited)

can_sample

bool

can_stream

bool

can_tether

bool

is_clean

bool

is_explicit

bool

duration

int

price

float

embed_url

str

iframe_url

str

RdioNamedItem (Inherited)

name

str

length

int

short_url

str

RdioIconItem (Inherited)

base_icon

str

icon

str

RdioDataItem (Inherited)

key

str

type

str

url

str

RdioBaseItem (Inherited)

classmethod parse(data)[source]

Parse data dictionary into RdioAlbum object

Parameters:data (str or dict) – Data to parse
Return type:rdiosock.objects.album.RdioAlbum

RdioArtist

class rdiosock.objects.artist.RdioArtist[source]
album_count

int

band_members

unknown

banner_alignment

str

banner_background_color

str

cover_photo_url

str

has_icon

bool

has_influenced_artists

bool

has_influential_artists

bool

has_radio

bool

bool

has_review

bool

in_program

bool

stations

list of unknown

top_album_icon

str

top_songs_key

str

radio_key

str

play_count

int

RdioNamedItem (Inherited)

name

str

length

int

short_url

str

RdioIconItem (Inherited)

base_icon

str

icon

str

RdioDataItem (Inherited)

key

str

type

str

url

str

RdioBaseItem (Inherited)

classmethod parse(data)[source]

Parse data dictionary into RdioArtist object

Parameters:data (str or dict) – Data to parse
Return type:rdiosock.objects.artist.RdioArtist

RdioList

class rdiosock.objects.collection.RdioList[source]
parse_items(key, value)[source]

RdioCollection (Inherited)

start

int

total

int

number_results

int

type

str

type_count

dict

items

list of rdiosock.objects.base.RdioBaseItem

parse_items(key, value)[source]
parse_count(key, value)

RdioBaseItem (Inherited)

classmethod parse(data)[source]

Parse data dictionary into RdioList object

Parameters:data (str or dict) – Data to parse
Return type:rdiosock.objects.collection.RdioList

RdioCollection

class rdiosock.objects.collection.RdioCollection[source]
start

int

total

int

number_results

int

type

str

type_count

dict

items

list of rdiosock.objects.base.RdioBaseItem

parse_items(key, value)[source]
parse_count(key, value)[source]

RdioBaseItem (Inherited)

classmethod parse(data)[source]

Parse data dictionary into RdioCollection object

Parameters:data (str or dict) – Data to parse
Return type:rdiosock.objects.collection.RdioCollection

RdioPerson

class rdiosock.objects.person.RdioPerson[source]
first_name

str

last_name

str

gender

str

location

str

can_unfollow

bool

is_protected

bool

follower_state

unknown

following_state

str

library_version

int

RdioIconItem (Inherited)

base_icon

str

icon

str

RdioDataItem (Inherited)

key

str

type

str

url

str

RdioBaseItem (Inherited)

classmethod parse(data)[source]

Parse data into object

Parameters:data (str or dict) – Data to parse
Return type:rdiosock.objects.person.RdioPerson

RdioPlaybackInfo

class rdiosock.objects.playback_info.RdioPlaybackInfo[source]

Rdio Playback Info

mp4

bool

shost

int

surl

str

stream_app

str

stream_host

str

user_has_unlimited

bool

RdioTrack (Inherited)

track_num

int

artist

str

artist_key

str

artist_url

str

album

str

album_artist

str

album_artist_key

str

album_key

str

album_url

str

radio_key

str

can_download

bool

can_download_album_only

bool

RdioMediaItem (Inherited)

can_sample

bool

can_stream

bool

can_tether

bool

is_clean

bool

is_explicit

bool

duration

int

price

float

embed_url

str

iframe_url

str

RdioNamedItem (Inherited)

name

str

length

int

short_url

str

RdioIconItem (Inherited)

base_icon

str

icon

str

RdioDataItem (Inherited)

key

str

type

str

url

str

RdioBaseItem (Inherited)

classmethod parse(data)[source]

Parse data into RdioPlaybackInfo object

Parameters:data (str or dict) – Data to parse
Return type:rdiosock.objects.playback_info.RdioPlaybackInfo

RdioPlayerState

class rdiosock.objects.player_state.RdioPlayerState[source]
current_source

rdiosock.objects.source.RdioSource

repeat

int

shuffle

bool

station

unknown

version

int

RdioBaseItem (Inherited)

classmethod parse(data)[source]

Parse data into object

Parameters:data (str or dict) – Data to parse
Return type:rdiosock.objects.player_state.RdioPlayerState

RdioQueue

class rdiosock.objects.queue.RdioQueue[source]
track_keys

list of str

version

int

RdioBaseItem (Inherited)

parse(data)

Parse data into object

Parameters:data (str or dict) – Data to parse
Return type:rdiosock.objects.base.RdioBaseItem

RdioTrackSource

class rdiosock.objects.source.RdioTrackSource[source]

RdioTrack (Inherited)

track_num

int

artist

str

artist_key

str

artist_url

str

album

str

album_artist

str

album_artist_key

str

album_key

str

album_url

str

radio_key

str

can_download

bool

can_download_album_only

bool

RdioSource (Inherited)

parse_source(value)

Parse the source into RdioTrackSource or RdioAlbumSource

Parameters:value (dict) – Data to parse
Return type:rdiosock.objects.source.RdioSource

RdioMediaItem (Inherited)

can_sample

bool

can_stream

bool

can_tether

bool

is_clean

bool

is_explicit

bool

duration

int

price

float

embed_url

str

iframe_url

str

RdioNamedItem (Inherited)

name

str

length

int

short_url

str

RdioIconItem (Inherited)

base_icon

str

icon

str

RdioDataItem (Inherited)

key

str

type

str

url

str

RdioBaseItem (Inherited)

classmethod parse(data)[source]

Parse data into object

Parameters:data (str or dict) – Data to parse
Return type:rdiosock.objects.source.RdioTrackSource

RdioAlbumSource

class rdiosock.objects.source.RdioAlbumSource[source]
album_key

str

album_url

str

current_position

int

raw_artist_key

str

user_key

str

user_name

str

RdioAlbum (Inherited)

artist

str

artist_key

str

artist_url

str

big_icon

str

big_icon_1200

str

copyright

str

display_date

unknown

icon_400

str

labels

unknown

network_consumers

list of rdiosock.objects.person.RdioPerson

playlist_count

int

play_count

int

release_date

unknown

review

str

tracks

list of rdiosock.objects.track.RdioTrack

track_keys

list of str

parse_tracks(key, value)

Parse tracks list

Parameters:value (dict) – tracks list dictionary

RdioSource (Inherited)

parse_source(value)

Parse the source into RdioTrackSource or RdioAlbumSource

Parameters:value (dict) – Data to parse
Return type:rdiosock.objects.source.RdioSource

RdioMediaItem (Inherited)

can_sample

bool

can_stream

bool

can_tether

bool

is_clean

bool

is_explicit

bool

duration

int

price

float

embed_url

str

iframe_url

str

RdioNamedItem (Inherited)

name

str

length

int

short_url

str

RdioIconItem (Inherited)

base_icon

str

icon

str

RdioDataItem (Inherited)

key

str

type

str

url

str

RdioBaseItem (Inherited)

classmethod parse(data)[source]

Parse data into object

Parameters:data (str or dict) – Data to parse
Return type:rdiosock.objects.source.RdioAlbumSource

RdioSource

class rdiosock.objects.source.RdioSource[source]
static parse_source(value)[source]

Parse the source into RdioTrackSource or RdioAlbumSource

Parameters:value (dict) – Data to parse
Return type:rdiosock.objects.source.RdioSource

RdioMediaItem (Inherited)

can_sample

bool

can_stream

bool

can_tether

bool

is_clean

bool

is_explicit

bool

duration

int

price

float

embed_url

str

iframe_url

str

RdioNamedItem (Inherited)

name

str

length

int

short_url

str

RdioIconItem (Inherited)

base_icon

str

icon

str

RdioDataItem (Inherited)

key

str

type

str

url

str

RdioBaseItem (Inherited)

classmethod parse(data)[source]

Parse data into object

Parameters:data (str or dict) – Data to parse
Return type:rdiosock.objects.source.RdioSource

RdioTrack

class rdiosock.objects.track.RdioTrack[source]
track_num

int

artist

str

artist_key

str

artist_url

str

album

str

album_artist

str

album_artist_key

str

album_key

str

album_url

str

radio_key

str

can_download

bool

can_download_album_only

bool

RdioMediaItem (Inherited)

can_sample

bool

can_stream

bool

can_tether

bool

is_clean

bool

is_explicit

bool

duration

int

price

float

embed_url

str

iframe_url

str

RdioNamedItem (Inherited)

name

str

length

int

short_url

str

RdioIconItem (Inherited)

base_icon

str

icon

str

RdioDataItem (Inherited)

key

str

type

str

url

str

RdioBaseItem (Inherited)

classmethod parse(data)[source]

Parse data into object

Parameters:data (str or dict) – Data to parse
Return type:rdiosock.objects.track.RdioTrack

Indices and tables