Created
March 4, 2014 23:48
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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