Exemplo n.º 1
0
    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]]
Exemplo n.º 2
0
    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]]
Exemplo n.º 3
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
Exemplo n.º 4
0
    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
Exemplo n.º 5
0
 def search_album(self, aid):
     LOG.debug("search album info, the album id is: " + str(aid))
     self.signal_search_album.emit(aid)
Exemplo n.º 6
0
 def search_artist(self, aid):
     LOG.debug("search artist info, the artist id is: " + str(aid))
     self.signal_search_artist.emit(aid)
Exemplo n.º 7
0
 def play_songs(self, songs_str):
     LOG.debug("play songs")
     songs = json.loads(songs_str)
     tracks = songs['tracks']
     self.signal_play_songs.emit(tracks)
Exemplo n.º 8
0
 def play_mv(self, mvid):
     LOG.debug("play mv: the mv_id is " + str(mvid))
     self.signal_play_mv.emit(mvid)
Exemplo n.º 9
0
 def play(self, mid):
     """
     """
     LOG.debug("play music: the music_id is " + str(mid))
     self.signal_play.emit(mid)
Exemplo n.º 10
0
 def search_album(self, aid):
     LOG.debug("search album info, the album id is: " + str(aid))
     self.signal_search_album.emit(aid)
Exemplo n.º 11
0
 def search_artist(self, aid):
     LOG.debug("search artist info, the artist id is: " + str(aid))
     self.signal_search_artist.emit(aid)
Exemplo n.º 12
0
 def play_songs(self, songs_str):
     LOG.debug("play songs")
     songs = json.loads(songs_str)
     tracks = songs['tracks']
     self.signal_play_songs.emit(tracks)
Exemplo n.º 13
0
 def play_mv(self, mvid):
     LOG.debug("play mv: the mv_id is " + str(mvid))
     self.signal_play_mv.emit(mvid)
Exemplo n.º 14
0
 def play(self, mid):
     """
     """
     LOG.debug("play music: the music_id is " + str(mid))
     self.signal_play.emit(mid)
Exemplo n.º 15
0
 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 ")
Exemplo n.º 16
0
 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 ")