Ejemplo n.º 1
0
def rdio_callback():
    # Build the URL and get the request tokens
    rdio = Rdio((config['rdio']['key'], config['rdio']['secret']), (session['rt'], session['rts']))
    rdio.complete_authentication(request.args.get('oauth_verifier'))
    
    # Set the access tokens
    session['at'] = rdio.token[0]
    session['ats'] = rdio.token[1]
    
    # Clear out request token cookies
    del session['rt']
    del session['rts']
    
    return redirect(url_for('home'))
Ejemplo n.º 2
0
def rdio_login():
    # Clear out any existing values
    cookies = ['rt', 'rts', 'at', 'ats']
    for c in cookies:
        if c in session:
            del session[c]
    
    # Build the URL and get the request tokens
    rdio = Rdio((config['rdio']['key'], config['rdio']['secret']))
    login_url = rdio.begin_authentication(url_for('rdio_callback', _external=True))
    
    # Save the request tokens
    session['rt'] = rdio.token[0]
    session['rts'] = rdio.token[1]
    
    # And redirect them to the oauth login system.
    return redirect(login_url)
Ejemplo n.º 3
0
def rdio_update_synced():
    if not 'at' in session:
        raise HTTPError(403)
    
    rdio = Rdio((config['rdio']['key'], config['rdio']['secret']), (session['at'], session['ats']))
    
    newOffline = [k for k, sync in request.form.iteritems() if sync == 'on']
    allTracks = rdio.call('getTracksInCollection')['result']
    newOnlineOnly = [t['key'] for t in allTracks if not t['key'] in newOffline]
    
    rdio.call('setAvailableOffline', {'keys': ','.join(newOffline), 'offline': True})
    rdio.call('setAvailableOffline', {'keys': ','.join(newOnlineOnly), 'offline': False})
    
    return redirect(url_for('home'))