本文整理汇总了Python中accounts.models.UserProfile.get_google_music_api方法的典型用法代码示例。如果您正苦于以下问题:Python UserProfile.get_google_music_api方法的具体用法?Python UserProfile.get_google_music_api怎么用?Python UserProfile.get_google_music_api使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类accounts.models.UserProfile
的用法示例。
在下文中一共展示了UserProfile.get_google_music_api方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: sync
# 需要导入模块: from accounts.models import UserProfile [as 别名]
# 或者: from accounts.models.UserProfile import get_google_music_api [as 别名]
def sync(request, user_id):
api, result = UserProfile.get_google_music_api(user_id)
if(result):
songs = api.get_all_songs()
song_dicts = [Song.create_from_google_music(song, user_id).to_dict() for song in songs]
return HttpResponse(json.dumps({'songs':song_dicts, 'id': user_id}), mimetype="application/json")
else:
logger.warn("Failed to log in!")
return HttpResponse(json.dumps({'message':'Could not log in to Google Music'}), mimetype="application/json")
示例2: stream_url
# 需要导入模块: from accounts.models import UserProfile [as 别名]
# 或者: from accounts.models.UserProfile import get_google_music_api [as 别名]
def stream_url(request, user_id, song_id):
api, result = UserProfile.get_google_music_api(user_id)
if(result):
song = {
'id': song_id,
'stream_url': api.get_stream_url(song_id)
}
return HttpResponse(json.dumps(song), mimetype="application/json")
else:
logger.warn("Failed to log in!")
return HttpResponse(json.dumps({'message':'Could not log in to Google Music'}), mimetype="application/json")
示例3: pop_song
# 需要导入模块: from accounts.models import UserProfile [as 别名]
# 或者: from accounts.models.UserProfile import get_google_music_api [as 别名]
def pop_song(request, user_id, queue_id):
queue = Queue.objects.get(id=queue_id)
response = {}
song = queue.pop()
if(song != None):
api, result = UserProfile.get_google_music_api(user_id)
stream_url = api.get_stream_url(song.id)
song_dict = song.to_dict()
song_dict['stream_url'] = stream_url
response['popped_song'] = song_dict
response['queue'] = queue.to_dict()
return HttpResponse(json.dumps(response), mimetype="application/json")