def view_lyric(self, song_id): url = default.lyric_url.format(str(song_id)) s = requests.session() try: s = BeautifulSoup( s.get(url, headers=self.__headers).content, "html.parser") lrc = json.loads(s.text)['lrc']['lyric'] if pysql.single("lyric163", "song_id", song_id): self.session.add(pysql.Lyric163(song_id=song_id, txt=lrc)) self.session.commit() except: pylog.Log("抓取歌词出现问题,歌曲ID:" + str(song_id))
def view_lyric(self, song_id): url = default.lyric_url.format(str(song_id)) s = requests.session() try: s = BeautifulSoup(s.get(url, headers=self.__headers).content, "html.parser") lrc = json.loads(s.text)['lrc']['lyric'] if pysql.single("lyric163", "song_id", song_id): self.session.add(pysql.Lyric163(song_id=song_id, txt=lrc)) self.session.query(pysql.Music163).filter(pysql.Music163.song_id == song_id).update({"has_lyric": "Y"}) self.session.commit() except Exception: pylog.log.error("抓取歌词出现问题,歌曲ID:" + str(song_id)) raise
def view_lyric(self, song_id): url = uapi.lyric_url.format(str(song_id)) try: data = tools.curl(url,self.__headers) lrc = data['lrc']['lyric'] if pysql.single("lyric163", "song_id", song_id): self.session.add(pysql.Lyric163(song_id=song_id, txt=lrc)) self.session.query(pysql.Music163).filter(pysql.Music163.song_id == song_id).update({"has_lyric": "Y"}) self.session.commit() except Exception as e: self.session.query(pysql.Music163).filter(pysql.Music163.song_id == song_id).update({"has_lyric": "E"}) self.session.commit() pylog.log.error("抓取歌词出现问题:{} 歌曲ID:{}".format(e, song_id))