当前位置: 首页>>代码示例>>Python>>正文


Python Rdio.call方法代码示例

本文整理汇总了Python中rdio.Rdio.call方法的典型用法代码示例。如果您正苦于以下问题:Python Rdio.call方法的具体用法?Python Rdio.call怎么用?Python Rdio.call使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在rdio.Rdio的用法示例。


在下文中一共展示了Rdio.call方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: GET

# 需要导入模块: from rdio import Rdio [as 别名]
# 或者: from rdio.Rdio import call [as 别名]
  def GET(self):
    access_token = web.cookies().get('at')
    access_token_secret = web.cookies().get('ats')
    if access_token and access_token_secret:
      rdio = Rdio((RDIO_CONSUMER_KEY, RDIO_CONSUMER_SECRET),
        (access_token, access_token_secret))
      # make sure that we can make an authenticated call

      try:
        currentUser = rdio.call('currentUser')['result']
      except urllib2.HTTPError:
        # this almost certainly means that authentication has been revoked for the app. log out.
        raise web.seeother('/logout')

      myPlaylists = rdio.call('getPlaylists')['result']['owned']

      response = '''
      <html><head><title>Rdio-Simple Example</title></head><body>
      <p>%s's playlists:</p>
      <ul>
      ''' % currentUser['firstName']
      for playlist in myPlaylists:
        response += '''<li><a href="%(shortUrl)s">%(name)s</a></li>''' % playlist
      response += '''</ul><a href="/logout">Log out of Rdio</a></body></html>'''
      return response
    else:
      return '''
开发者ID:ColdSauce,项目名称:rdio-simple,代码行数:29,代码来源:web-based.py

示例2: auth

# 需要导入模块: from rdio import Rdio [as 别名]
# 或者: from rdio.Rdio import call [as 别名]
def auth():
    request_token = session.get('rt')
    request_token_secret = session.get('rts')
    verifier = request.args.get('oauth_verifier', '')
    if request_token and request_token_secret and verifier:
        rdio = Rdio((RDIO_CONSUMER_KEY, RDIO_CONSUMER_SECRET), (request_token, request_token_secret))
        rdio.complete_authentication(verifier)
        session['at'] = rdio.token[0]
        session['ats'] = rdio.token[1]
        session['rt'] = ''
        session['rts'] = ''
        rdio_data = rdio.call('currentUser', params={'extras': 'username,displayName'})['result']
        username = rdio_data['username']
        print 'Creating user model.'
        user = User.query.filter(User.username == username).first()
        if user is None:
            user = User(username=username, key=rdio_data['key'], icon=rdio_data['icon'], name=rdio_data['displayName'])
            db_session.add(user)
            db_session.commit()
            playlists = rdio.call('getPlaylists', params={'extras': 'tracks,description,isViewable'})['result']['owned']
            #print playlists
            import_new_user_playlists(playlists, user.id)
        print 'Committed.'
        session['user_id'] = user.id
        print session
        return redirect(url_for('main'))
    else:
        # Login failed, clear everything
        print 'Auth failed.'
        logout()
        return redirect(url_for('main'))
开发者ID:nickdirienzo,项目名称:playgit,代码行数:33,代码来源:main.py

示例3: login

# 需要导入模块: from rdio import Rdio [as 别名]
# 或者: from rdio.Rdio import call [as 别名]
def login():
    args = request.args
    if 'token' in session and 'oauth_verifier' in args:
        verifier = request.args.get('oauth_verifier')
        rdio = Rdio((RDIO_CONSUMER_KEY, RDIO_CONSUMER_SECRET), session['token'])
        rdio.complete_authentication(verifier)
        session['token'] = rdio.token
        user = rdio.call('currentUser')['result']
        session['user'] = user['key']
        users[user['key']] = user
        username = rdio.call('currentUser', {'extras': 'username'})['result']['username']
        return redirect(url_for('playlists', username=username))
    rdio = Rdio((RDIO_CONSUMER_KEY, RDIO_CONSUMER_SECRET))
    auth_url = rdio.begin_authentication(SITE_URL + '/login')
    session['token'] = rdio.token
    return redirect(auth_url)
开发者ID:cvan,项目名称:playlist_builder,代码行数:18,代码来源:app.py

示例4: __init__

# 需要导入模块: from rdio import Rdio [as 别名]
# 或者: from rdio.Rdio import call [as 别名]
class rdio_simple:

	def __init__(self, CK, CS):
		self.rdio_obj = Rdio((CK, CS))

	def get_user_key_from_name(self, user_name):
		name = self.rdio_obj.call("findUser", {"vanityName": user_name})
		return name['result']['key']

	def get_collection_from_key(self, key):
		collection = self.rdio_obj.call("getTracksInCollection", {"user":key})
		return collection
	
	def get_tracks_from_collection(self, collection):
		for item in collection['result']:
			print item['name']
开发者ID:josneville,项目名称:VTHacks-Personalidads,代码行数:18,代码来源:test.py

示例5: search

# 需要导入模块: from rdio import Rdio [as 别名]
# 或者: from rdio.Rdio import call [as 别名]
def search(song):
    song = song.replace(';', '')
    song = song.replace('&', '')
    song = song.replace('With Lyrics', '')
    song = song.replace('(Official Video)', '')
    song = song.replace('(Official Music Video)', '')
    song = song.replace('[Official Video]', '')
    song = song.replace('[Official Music Video]', '')
    song = song.replace('-', '')

    spotify_request = requests.get('http://ws.spotify.com/search/1/track?q=%s' % song)
    spotify_root = ET.fromstring(spotify_request.content) #parse the xml out so we can do things with it
    spotify_song = ''
    spotify_attrib =''
    if spotify_root[1].text != '0':
        spotify_attrib = spotify_root[4].attrib #this looks like {'href': 'spotify:track:5TdAgcKS5HlxMcclStHODW'}
        spotify_attrib = spotify_attrib["href"]
        spotify_song = spotify_root[4][0].text
        spotify_attrib = spotify_attrib.replace('spotify:track:', 'http://open.spotify.com/track/');
        #at this point, we have the spotify song
    
    #rdio is up next
    rdio_title = ''
    rdio_artist = ''
    rdio_url = ''
    rdio = Rdio(("ad6x8mefbh2b2kh3deezgfq2", "tdWYdpKBfH"))
    rdio_song = rdio.call("search", {"query": song, "types": "Track"})
    if (rdio_song["status"] == "ok" and rdio_song["result"]["track_count"] != 0):
        rdio_turl = rdio_song["result"]["results"][0]["url"]
        rdio_url = "http://rdio.com"
        rdio_url += rdio_turl
    
    return jsonify(spotify_url = spotify_attrib, rdio_url = rdio_url)
开发者ID:adnissen,项目名称:isiton,代码行数:35,代码来源:isiton.py

示例6: login

# 需要导入模块: from rdio import Rdio [as 别名]
# 或者: from rdio.Rdio import call [as 别名]
def login():
    access_token = session.get('at')
    access_token_secret = session.get('ats')
    if access_token and access_token_secret:
        rdio = Rdio((RDIO_CONSUMER_KEY, RDIO_CONSUMER_SECRET), (access_token, access_token_secret))
        try:
            rdio_data = rdio.call('currentUser', params={'extras': 'username,displayName'})['result']
            username = rdio_data['username']
            user = User.query.filter(User.username == username).first()
            session['user_id'] = user.id
            print current_user
            return redirect(url_for('main'))
        except urllib2.HTTPError:
            # Something went horribly wrong, like Rdio told us our app sucks.
            logout()
            return redirect(url_for('main'))
    else:
        session['at'] = ''
        session['ats'] = ''
        session['rt'] = ''
        session['rts'] = ''
        rdio = Rdio((RDIO_CONSUMER_KEY, RDIO_CONSUMER_SECRET))
        login_url = rdio.begin_authentication(callback_url='http://' + request.host + '/auth')
        session['rt'] = rdio.token[0]
        session['rts'] = rdio.token[1]
        return jsonify(login_url=login_url)
开发者ID:nickdirienzo,项目名称:playgit,代码行数:28,代码来源:main.py

示例7: tester

# 需要导入模块: from rdio import Rdio [as 别名]
# 或者: from rdio.Rdio import call [as 别名]
def tester():
    rdio = Rdio(("u35btmntr29vd3n9hnuy9m6n", "jb8DTyHpVf"))
    url = rdio.begin_authentication('oob')
    saved_token = rdio.token
    print saved_token
    rdio = Rdio(("u35btmntr29vd3n9hnuy9m6n", "jb8DTyHpVf"), saved_token)
    #print "Go to website to verify: " + url
    #verifier = input("Enter pin: ")
    #rdio.complete_authentication(saved_token)
    print saved_token 
    song = rdio.call("search",{"query": "Lose yourself","types":"Track"})
    if(song["status"] == "ok"):
        track =  song["result"]["results"][0]["key"]
        rdio.call("addToPlaylist",{"playlist":"p8696966","tracks":str(track)})
    else:
        print "failed"
    return "Song Added"
开发者ID:leagerl1,项目名称:StreamEngine,代码行数:19,代码来源:run.py

示例8: __init__

# 需要导入模块: from rdio import Rdio [as 别名]
# 或者: from rdio.Rdio import call [as 别名]
class rdio_simple:

	def __init__(self, CK, CS):
		self.rdio_obj = Rdio((CK, CS))

	def get_user_key_from_name(self, user_name):
		name = self.rdio_obj.call("findUser", {"vanityName": user_name})
		return name['result']['key']

	def get_collection_from_key(self, key, count="100"):
		collection = self.rdio_obj.call("getTracksInCollection", {"user":key, "extras":"playCount", "count":count})
		return collection
	
	def get_artists_from_collection(self, collection):
		my_list = []
		for item in collection['result']:
			my_list.append(item['artist'].encode('utf-8'))
		return my_list
开发者ID:josneville,项目名称:VTHacks-Personalidads,代码行数:20,代码来源:server.py

示例9: top_track

# 需要导入模块: from rdio import Rdio [as 别名]
# 或者: from rdio.Rdio import call [as 别名]
def top_track(sesh):
    access_token = sesh['at']
    access_token_secret = sesh['ats']
    if len(access_token) > 0 and len(access_token_secret) > 0 and access_token and access_token_secret:
        rdio = Rdio((RDIO_CONSUMER_KEY, RDIO_CONSUMER_SECRET), (access_token, access_token_secret))
        try:
            currentUser = rdio.call('currentUser')['result']
        except urllib2.HTTPError:
        # this almost certainly means that authentication has been revoked for the app. log out.
            return {"error" : "failure"}
        topcharts = rdio.call('getTopCharts', {'type': 'Track', 'count' : 100})
        playbackToken = rdio.call('getPlaybackToken', {'domain' : 'localhost'})
        import random
        randomint = random.randint(0,99)
        song = topcharts['result'][randomint]
        song['playbackToken'] = playbackToken['result']
        return song
    else:
        return {"error" : "failure"}
开发者ID:brettjurgens,项目名称:voicedio,代码行数:21,代码来源:voicedio.py

示例10: MainTest

# 需要导入模块: from rdio import Rdio [as 别名]
# 或者: from rdio.Rdio import call [as 别名]
class MainTest(unittest.TestCase):

    def setUp(self):
        self.consumer = ('test', 'test')
        self.rdio = Rdio(self.consumer)

    @patch('rdio.urlopen', mock_urlopen)
    def test_unicode_params(self):
        r = self.rdio.call('search', {
            'query': 'Röyksopp'
        })
开发者ID:AdamGaudet,项目名称:rdio-simple,代码行数:13,代码来源:test_main.py

示例11: get_obj_listing

# 需要导入模块: from rdio import Rdio [as 别名]
# 或者: from rdio.Rdio import call [as 别名]
def get_obj_listing(obj, view):
    rdio = Rdio((RDIO_CONSUMER_KEY, RDIO_CONSUMER_SECRET), session['token'])
    user = session['user']
    if obj:
        req = rdio.call('get', {'keys':obj})
        res = req['result'][obj]
        if res['type'] == 'al':
            req = rdio.call('get', {'keys':','.join(res['trackKeys'])})
            res = req['result']
            tracks = res.values()
            return tracks

    if view == 'albums':
        req = rdio.call('getAlbumsInCollection', {'user': user})
        return req['result']

    if view == 'tracks':
        req = rdio.call('getTracksInCollection', {'user': user})
        return req['result']

    req = rdio.call('getArtistsInCollection', {'user': user})
    return req['result']
开发者ID:cvan,项目名称:playlist_builder,代码行数:24,代码来源:app.py

示例12: home

# 需要导入模块: from rdio import Rdio [as 别名]
# 或者: from rdio.Rdio import call [as 别名]
def home():
    access_token = session['at']
    access_token_secret = session['ats']
    if len(access_token) > 0 and len(access_token_secret) > 0 and access_token and access_token_secret:
        rdio = Rdio((RDIO_CONSUMER_KEY, RDIO_CONSUMER_SECRET), (access_token, access_token_secret))
        try:
            currentUser = rdio.call('currentUser')['result']
        except urllib2.HTTPError:
        # this almost certainly means that authentication has been revoked for the app. log out.
            return redirect(url_for(logout))
        return render_template('search_form.html')
    else:
        return redirect(url_for('login'))
开发者ID:brettjurgens,项目名称:voicedio,代码行数:15,代码来源:voicedio.py

示例13: create_rdio_playlist

# 需要导入模块: from rdio import Rdio [as 别名]
# 或者: from rdio.Rdio import call [as 别名]
def create_rdio_playlist(token, request):
    '''Rdio call, create playlist.'''
    logger.debug('Creating playlist')
    rdio = Rdio((CONSUMER_KEY, CONSUMER_SECRET), token)
    artist_key = request.form['create playlist']
    search = rdio.call('get', {'keys': artist_key})
    artist = search['result'][artist_key]['name']
    artist_top_ten_tracks = rdio.call('getTracksForArtist',
                                      {'artist': artist_key})
    if len(artist_top_ten_tracks['result']) == 0:
        # Flash message instead.
        return 'Could not find any tracks. Click back to try another artist.'
    api_call_key_list = []
    for track in artist_top_ten_tracks['result']:
        api_call_key_list.append(track['key'])
    playlist = ','.join(api_call_key_list)
    created_playlist = rdio.call('createPlaylist', {
        'name': '{}\'s Top Ten'.format(artist),
        'description': 'Top ten tracks by play count',
        'tracks': playlist})
    playlist_url = created_playlist['result']['url']
    logger.debug('Playlist created successfully.\n') 
    return playlist_url
开发者ID:ecalifornica,项目名称:rdio_playlist,代码行数:25,代码来源:lib.py

示例14: rdio_search

# 需要导入模块: from rdio import Rdio [as 别名]
# 或者: from rdio.Rdio import call [as 别名]
def rdio_search(query, sesh):
    access_token = sesh['at']
    access_token_secret = sesh['ats']
    if len(access_token) > 0 and len(access_token_secret) > 0 and access_token and access_token_secret:
        rdio = Rdio((RDIO_CONSUMER_KEY, RDIO_CONSUMER_SECRET), (access_token, access_token_secret))
        try:
            currentUser = rdio.call('currentUser')['result']
        except urllib2.HTTPError:
        # this almost certainly means that authentication has been revoked for the app. log out.
            return {"error" : "failure"}

        result = rdio.call('search', {'query' : query, 'types' : "Artist,Track" })
        result = result['result']['results']

        pop = result[0]

        while pop['type'] != 't':
            pop = result.pop(0)
        
        return pop

    else:
        return {"error" : "failure"}
开发者ID:brettjurgens,项目名称:voicedio,代码行数:25,代码来源:voicedio.py

示例15: main

# 需要导入模块: from rdio import Rdio [as 别名]
# 或者: from rdio.Rdio import call [as 别名]
def main():
	CONSUMER_KEY, CONSUMER_SECRET = get_consumer_credentials()
	rdio = Rdio((CONSUMER_KEY, CONSUMER_SECRET))
	auth_url = rdio.begin_authentication('oob')

	# redirect user to rdio, will give pin back

	verifier = get_pin(auth_url)
	saved_token = rdio.token # a two element tuple
	rdio.complete_authentication(verifier)

	print "fetching last fm artists..."
	lastfm = LastfmQuery.LastfmQuery()
	lastfm_list_of_artists = lastfm.getAlbums("jaisrael")
	
	print "adding artists to collection..." 
	for artist in lastfm_list_of_artists:
		try:
			response = rdio.call('search', {'query':artist, 'types':'Artist'})		
		except UnicodeEncodeError:
			print "unicode issue. skipping this artist"
			continue
	
		artist_key = response['result']['results'][0]['key']
		if artist_key is not None:
			track_objs = rdio.call('getTracksForArtist', {'artist':artist_key})['result']
			track_keys_unicode_list = [ track['key'] for track in track_objs ]
			if track_keys_unicode_list is not None:
				# convert track keys to unicode
				track_keys_ascii_list = [ unicodedata.normalize('NFKD', u).encode('ascii','ignore') for u in track_keys_unicode_list ]
				track_keys_str = ""
				for u in track_keys_ascii_list:
					track_keys_str += u + ","
				if track_keys_str.endswith(','):
					track_keys_str = track_keys_str[:-1]
				atc = rdio.call('addToCollection', {'keys':track_keys_str})
开发者ID:lopatin,项目名称:rdio-sourcing,代码行数:38,代码来源:main.py


注:本文中的rdio.Rdio.call方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。