def cache(this, *args, **kw): if len(args) > 1: if not args[1]: # 不使用缓存 data = func(this, *args, **kw) if data['code'] == 200: cache_data[args[0]] = data else: if args[0] in cache_data: LOG.debug('playlist: ' + cache_data[args[0]]['name'] + ' has been cached') else: cache_data[args[0]] = func(this, *args, **kw) return cache_data[args[0]]
def get_playlist_detail(self, pid, cache=True): """貌似这个请求会比较慢 :param pid: :return: """ data = self.ne.playlist_detail(pid) # 当列表内容多的时候,耗时久 if not self.is_response_avaible(data): return data data = data['result'] data['uid'] = data['userId'] data['type'] = data['specialType'] for i, track in enumerate(data['tracks']): data['tracks'][i] = self.access_music(track) model = PlaylistModel(data).get_dict() LOG.debug('Update playlist cache finish: ' + model['name']) return model
def get_playlist_detail(self, pid, cache=True): """貌似这个请求会比较慢 :param pid: :return: """ data = self.ne.playlist_detail(pid) # 当列表内容多的时候,耗时久 if not self.is_data_avaible(data): return data data = data['result'] data['uid'] = data['userId'] data['type'] = data['specialType'] for i, track in enumerate(data['tracks']): data['tracks'][i] = access_music(track) model = PlaylistModel(data).get_dict() LOG.debug('Update playlist cache finish: ' + model['name']) return model
def search_album(self, aid): LOG.debug("search album info, the album id is: " + str(aid)) self.signal_search_album.emit(aid)
def search_artist(self, aid): LOG.debug("search artist info, the artist id is: " + str(aid)) self.signal_search_artist.emit(aid)
def play_songs(self, songs_str): LOG.debug("play songs") songs = json.loads(songs_str) tracks = songs['tracks'] self.signal_play_songs.emit(tracks)
def play_mv(self, mvid): LOG.debug("play mv: the mv_id is " + str(mvid)) self.signal_play_mv.emit(mvid)
def play(self, mid): """ """ LOG.debug("play music: the music_id is " + str(mid)) self.signal_play.emit(mid)
def wrapper(*args, **kwargs): LOG.debug("In func_coroutine: before call ") LOG.debug("function name is : " + func.__name__) app_event_loop = asyncio.get_event_loop() app_event_loop.call_soon(func, *args) LOG.debug("In func_coroutine: after call ")