Example #1
0
 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))
Example #2
0
 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
Example #3
0
File: lyric.py Project: rex3092/123
 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))