Пример #1
0
 def add_bunch_to_list(self):
     """向“在线试听”列表批量添加歌曲。"""
     selecteds = self.searchTable.selectedIndexes()
     if not len(selecteds):
         return
     self.added_items = []
     playlistTemp = Playlist()
     playlistTemp.fill_list(Configures.PlaylistOnline)
     musicIdsInOnlineList = playlistTemp.get_items_queue()
     for index in selecteds:
         if index.column() == 0:
             row = index.row()
             musicId = self.searchTable.item(row, 4).text()
             if musicId  not in musicIdsInOnlineList:
                 musicName = self.searchTable.item(row, 1).text()
                 artist = self.searchTable.item(row, 2).text()
                 title = connect_as_title(artist, musicName)
                 album = self.searchTable.item(row, 3).text()
                 lrcPath = composite_lyric_path_use_title(title)
                 if os.path.exists(lrcPath):
                     os.remove(lrcPath)
                 self.added_items.append([title, musicId])
                 playlistTemp.add_record(musicId, title, Configures.ZeroTime, album, Configures.NoLink, 0, musicId)
     if len(self.added_items):
         playlistTemp.commit_records()
         thread = DownloadLrcThread(self.added_items)
         thread.setDaemon(True)
         thread.setName("downloadLrc")
         thread.start()
         self.add_bunch_to_list_succeed.emit()
Пример #2
0
 def add_bunch_to_list(self):
     """向“在线试听”列表批量添加歌曲。"""
     selecteds = self.searchTable.selectedIndexes()
     if not len(selecteds):
         return
     self.added_items = []
     playlistTemp = Playlist()
     playlistTemp.fill_list(Configures.PlaylistOnline)
     musicIdsInOnlineList = playlistTemp.get_items_queue()
     for index in selecteds:
         if index.column() == 0:
             row = index.row()
             musicId = self.searchTable.item(row, 4).text()
             if musicId not in musicIdsInOnlineList:
                 musicName = self.searchTable.item(row, 1).text()
                 artist = self.searchTable.item(row, 2).text()
                 title = connect_as_title(artist, musicName)
                 album = self.searchTable.item(row, 3).text()
                 lrcPath = composite_lyric_path_use_title(title)
                 if os.path.exists(lrcPath):
                     os.remove(lrcPath)
                 self.added_items.append([title, musicId])
                 playlistTemp.add_record(musicId, title,
                                         Configures.ZeroTime, album,
                                         Configures.NoLink, 0, musicId)
     if len(self.added_items):
         playlistTemp.commit_records()
         thread = DownloadLrcThread(self.added_items)
         thread.setDaemon(True)
         thread.setName("downloadLrc")
         thread.start()
         self.add_bunch_to_list_succeed.emit()
Пример #3
0
 def download_lrc_and_artistinfo(self, title, musicId):
     """下载歌曲的同时去下载对应的歌词、歌手信息等内容。"""
     lrcPath = composite_lyric_path_use_title(title)
     if os.path.exists(lrcPath):
         os.remove(lrcPath)
     list_temp = [(title, musicId)]
     thread = DownloadLrcThread(list_temp)
     thread.setDaemon(True)
     thread.setName('downloadLrc')
     thread.start()
Пример #4
0
 def download_lrc_and_artistinfo(self, title, musicId):
     """下载歌曲的同时去下载对应的歌词、歌手信息等内容。"""
     lrcPath = composite_lyric_path_use_title(title)
     if os.path.exists(lrcPath):
         os.remove(lrcPath)
     list_temp = [(title, musicId)]
     thread = DownloadLrcThread(list_temp)
     thread.setDaemon(True)
     thread.setName('downloadLrc')
     thread.start()
Пример #5
0
 def run(self):
     i = 0
     cnt = len(self.list)
     while i < cnt and self.runPermit:
         title = self.list[i][0]
         print('开始下载及歌手信息:%s' % title)
         try:
             artist = title.split(Configures.Hyphen)[0].strip()
             SearchOnline.get_artist_image_path(artist)
         except:
             pass
         musicId = self.list[i][1]
         lrcPath = composite_lyric_path_use_title(title)
         if not os.path.exists(lrcPath):
             SearchOnline.get_lrc_contents(title, musicId)
         i += 1
Пример #6
0
 def run(self):
     i = 0
     cnt = len(self.list)
     while i < cnt and self.runPermit:
         title = self.list[i][0]
         print('开始下载及歌手信息:%s'%title)
         try:
             artist = title.split(Configures.Hyphen)[0].strip()
             SearchOnline.get_artist_image_path(artist)
         except:
             pass
         musicId = self.list[i][1]
         lrcPath = composite_lyric_path_use_title(title)
         if not os.path.exists(lrcPath):
             SearchOnline.get_lrc_contents(title, musicId)
         i  += 1
Пример #7
0
 def update_lyric(self, title, musicId):
     self.lyricOffset = 0     
     self.lrcPath = composite_lyric_path_use_title(title)
     lyric = SearchOnline.get_lrc_contents(title, musicId)
     if lyric == Configures.LyricNetError:
         self.playbackPanel.desktopLyric.set_text("网络出错,无法搜索歌词!")
         self.lyricDict.clear()
         self.managePage.lyricText.url_error_lyric()
     elif lyric == Configures.LyricNone:
         self.playbackPanel.desktopLyric.set_text("搜索不到匹配歌词!")
         self.lyricDict.clear()
         self.managePage.lyricText.no_matched_lyric()
     else:
         self.lyricOffset, self.lyricDict = parse_lrc(lyric)
         self.lyricDict[3000000] = ''
         self.t = sorted(self.lyricDict.keys())
         self.managePage.lyricText.set_lyric_offset(self.lyricOffset, self.lyricDict, self.lrcPath)
Пример #8
0
 def  get_lrc_contents(title, musicId):
     """获取歌词。"""
     lrcPath = composite_lyric_path_use_title(title)
     if os.path.exists(lrcPath):
         f = open(lrcPath, 'r')
         contents = f.read()
         if contents == 'None':
             return Configures.LyricNone
         if contents and contents not in ('Configures.UrlError', 'Error'):
             return contents
     if musicId != Configures.LocalMusicId:
         lrcContent = SearchOnline.get_lrc_from_musicid(musicId)
     else:
         lrcContent = SearchOnline.get_lrc_from_title(title)
     with open(lrcPath, 'w') as f:
         if lrcContent == Configures.LyricNone:
             f.write('None')
         elif lrcContent == Configures.LyricNetError:
             f.write('Error')
         else:
             f.write(lrcContent)
         f.close()
     return lrcContent
Пример #9
0
 def get_lrc_contents(title, musicId):
     """获取歌词。"""
     lrcPath = composite_lyric_path_use_title(title)
     if os.path.exists(lrcPath):
         f = open(lrcPath, 'r')
         contents = f.read()
         if contents == 'None':
             return Configures.LyricNone
         if contents and contents not in ('Configures.UrlError', 'Error'):
             return contents
     if musicId != Configures.LocalMusicId:
         lrcContent = SearchOnline.get_lrc_from_musicid(musicId)
     else:
         lrcContent = SearchOnline.get_lrc_from_title(title)
     with open(lrcPath, 'w') as f:
         if lrcContent == Configures.LyricNone:
             f.write('None')
         elif lrcContent == Configures.LyricNetError:
             f.write('Error')
         else:
             f.write(lrcContent)
         f.close()
     return lrcContent