def album_ava(mid): logging.debug('获取专辑封面') music = Music() with auto_logging(): res = music._album_pic(mid) album_pic = json_formatter(res) return jsonify(album_pic)
def singer_ava(mid): logging.debug('获取歌手头像') music = Music() with auto_logging(): res = music._singer_avatar(mid) singer_avatar = json_formatter(res) return jsonify(singer_avatar)
def hot_keys(): logging.debug('热门搜索') music = Music() with auto_logging(): res = music._hot_keys() if res['code'] != current_app.config['ERROR_OK']: raise APIException() keys = res['data'] music_hot_keys = json_formatter(keys) return jsonify(music_hot_keys)
def top_list(): logging.debug('排行榜') music = Music() with auto_logging(): res = music._top_list() if res['code'] != current_app.config['ERROR_OK']: raise APIException() top = res['data']['topList'] music_top = json_formatter(top) return jsonify(music_top)
def songs_url(): logging.debug('获取歌曲url') music = Music() with auto_logging(): mids = request.args.get('songsmid', None) if mids is None: return APIException() res = music._songs_urls(mids) songs_meta = json_formatter(res) return jsonify(songs_meta)
def song_lyric(id): logging.debug('获取歌词') music = Music() with auto_logging(): res = music._lyric(id) if res['code'] != current_app.config['ERROR_OK']: raise APIException() lyc = decode_bs64(res['lyric']) music_lyc = json_formatter(dict(songid=id, lyric=lyc)) return jsonify(music_lyc)
def search_song(keyword): logging.debug('搜索歌曲') music = Music() with auto_logging(): page = int(request.args.get('page', 1)) count = int(request.args.get('count', 20)) res = music._search(keyword, page, count) if res['code'] != current_app.config['ERROR_OK']: raise APIException() search = res['data']['song'] total = search['totalnum'] all_song = get_songlist(search['list']) music_search = json_formatter(dict(total=total, song=all_song)) return jsonify(music_search)
def top_list_songs(topid): logging.debug('排行榜歌曲') music = Music() with auto_logging(): top_res = music._top_list_songs(topid) if top_res['code'] != current_app.config['ERROR_OK']: raise APIException() total = top_res['total_song_num'] _top_info = top_res['topinfo'] top_info = dict( name=_top_info['ListName'], info=_top_info['info'], pic=_top_info['pic_album'], ) logging.debug(top_info) update_time = top_res['update_time'] all_song = get_songlist(top_res['songlist']) music_top_list_songs = json_formatter( dict(total=total, top_info=top_info, update_time=update_time, all_song=all_song)) return jsonify(music_top_list_songs)
def get_body(self, environ=None): from app.libs.utils import json_formatter body = json_formatter(data=self.data, code=self.code) text = json.dumps(body) return text
def hot_list(): logging.debug('热门歌单') with auto_logging(): hot = get_recommend()['data']['songList'] music_hot = json_formatter(hot) return jsonify(music_hot)
def slider(): logging.debug('首页轮播图') with auto_logging(): slider = get_recommend()['data']['slider'] music_slider = json_formatter(slider) return jsonify(music_slider)