Skip to content

Instantly share code, notes, and snippets.

@dasevilla
Created March 4, 2014 23:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dasevilla/9358262 to your computer and use it in GitHub Desktop.
Save dasevilla/9358262 to your computer and use it in GitHub Desktop.
Given an artist short URL, print the artist station iframe URL. To be used with https://github.com/rdio/rdio-simple
#!/usr/bin/env python
from __future__ import unicode_literals
import sys,os.path
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from rdio import Rdio
from rdio_consumer_credentials import RDIO_CREDENTIALS
try:
from urllib.error import HTTPError
except ImportError:
from urllib2 import HTTPError
def main():
# Artist short URL
# short_url = 'http://rd.io/x/QFtsLVckZQ/' # Childish Gambino
short_url = 'http://rd.io/x/QFtsLVzCDw/' # Work Drugs
rdio = Rdio(RDIO_CREDENTIALS)
payload = rdio.call('getObjectFromUrl', {
'url': short_url,
'extras': '-*,radioKey',
})
# Artist Station key
artist_radio_key = payload['result']['radioKey']
payload = rdio.call('get', {
'keys': artist_radio_key,
'extras': '-*,iframeUrl',
})
artist_station = payload['result'][artist_radio_key]
# Artist station embed URL
print artist_station['iframeUrl']
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment