获取歌词

        如果测试频繁会发如下信息:
        {'msg': 'You API access rate limit has been exceeded.
                 Contact api-master@douban.com if you want higher limit. ',
         'code': 1998,
         'request': 'GET /j/v2/lyric'}

def get_lrc(self, playingsong):
        """
        获取歌词

        如果测试频繁会发如下信息:
        {'msg': 'You API access rate limit has been exceeded.
                 Contact api-master@douban.com if you want higher limit. ',
         'code': 1998,
         'request': 'GET /j/v2/lyric'}
        """
        try:
            url = "https://douban.fm/j/v2/lyric"
            postdata = {
                'sid': playingsong['sid'],
                'ssid': playingsong['ssid'],
            }
            s = requests.session()
            response = s.get(url, params=postdata, headers=HEADERS)

            # 把歌词解析成字典
            lyric = json.loads(response.text, object_hook=decode_dict)
            logger.info(lyric)
            if lyric.get('code', None) == 1998:
                logger.info('lrc API access rate limit has been exceeded')
                return {}
            elif lyric.get('code', None) == 107:
                logger.info('lrc API invalid_request_uri')
                return {}
            lrc_dic = lrc2dict(lyric['lyric'])

            # 原歌词用的unicode,为了兼容
            for key, value in iteritems(lrc_dic):
                # lrc_dic[key] = value.decode('utf-8')
                lrc_dic[key] = value
            if lrc_dic:
                logger.debug('Get lyric success!')
            return lrc_dic
        except requests.exceptions.RequestException:
            logger.error('Get lyric failed!')
            return {}