コード例 #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
ファイル: player.py プロジェクト: kouxulei/xyplayer-package
 def musics_added(self, showAddInfo):
     widget = self.managePage.playlistWidget
     playlist = widget.get_playlist()
     newAddedTitles = []
     if widget.get_playing_used_state():
         self.playlist_modified()
     for index in widget.addedIndexes:
         title = playlist.get_music_title_at(index)
         newAddedTitles.append((title, Configures.LocalMusicId))
         if playlist.get_name() == Configures.PlaylistFavorite:
             self.playbackPanel.lovedSongs.append(title)
     if playlist.get_name() == Configures.PlaylistFavorite:
         self.playbackPanel.check_favorite()
     if showAddInfo:
         if len(newAddedTitles):
             thread = DownloadLrcThread(newAddedTitles)
             thread.setDaemon(True)
             thread.setName("downloadLrc")
             thread.start()
         addCount = len(widget.files)
         newAddedCount = len(newAddedTitles)
         text = "您选择了%s首歌曲!\n新添加了%s首歌曲,其他歌曲已在列表中不被添加!"%(addCount, newAddedCount)
         if newAddedCount >0 and addCount == newAddedCount:
             text = "已添加%s首歌曲!"%newAddedCount
         if newAddedCount == 0:
             text = "选择的歌曲已在列表中!"
         QMessageBox.information(self, "添加完成", text)   
コード例 #3
0
 def add_to_downloadtable(self, songLink, musicPath, title, album, musicId):
     for t in threading.enumerate():
         if t.name == musicPath:
             return
     k = -1
     for i in range(self.downloadModel.rowCount()):
         if musicPath == self.downloadModel.record(i).value("musicPath"):
             k = i
             break
     if k != -1:
         self.downloadTable.selectRow(k)
         self.start_download()
     else:
         self.downloadModel.add_record(title, 0, '未知', '等待', album, songLink, musicPath, musicId)
         row = self.downloadModel.rowCount()-1
         self.downloadTable.selectRow(row)
         downloadThread1 = DownloadThread(self.downloadModel, row)
         downloadThread1.setDaemon(True)
         downloadThread1.setName(musicPath)
         downloadThread1.start()
         
         lrcName = title + '.lrc'
         lrcPath = os.path.join(Configures.lrcsDir, lrcName)
         if os.path.exists(lrcPath):
             os.remove(lrcPath)
         path_item_temp = songLink + '~' + musicId
         list_temp = [(title, path_item_temp)]
         thread = DownloadLrcThread(list_temp)
         thread.setDaemon(True)
         thread.setName(musicPath)
         thread.start()
         
         if not self.timer.isActive():
             self.timer.start(700)
コード例 #4
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()
コード例 #5
0
 def searchtable_clicked(self, row):
     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()
     musicId = self.searchTable.item(row, 4).text()
     songLink = SearchOnline.get_song_link(musicId)
     if not songLink:
         return
     thread = DownloadLrcThread([(title, musicId)])
     thread.setDaemon(True)
     thread.setName('downloadLrc')
     thread.start()
     self.listen_online_signal.emit(title, album, songLink, musicId)
コード例 #6
0
 def searchtable_clicked(self, row):
     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()
     musicId = self.searchTable.item(row, 4).text()
     songLink = SearchOnline.get_song_link(musicId)
     if not songLink:
         return
     thread = DownloadLrcThread([(title, musicId)])
     thread.setDaemon(True)
     thread.setName('downloadLrc')
     thread.start()
     self.listen_online_signal.emit(title, album, songLink, musicId)
コード例 #7
0
    def add_bunch_to_list(self):
        selections = self.searchTable.selectionModel()
        selecteds = selections.selectedIndexes()
        if not len(selecteds):
            return
        model = TableModel()
        model.initial_model("在线试听")
        songsInOnlineList = []
        added_items = []
        t1 = time.time()
        for i in range(model.rowCount()):
            songsInOnlineList.append(model.record(i).value("paths"))
        t2 = time.time()
        print(t2-t1)
        self.setCursor(QCursor(Qt.BusyCursor))
        for index in selecteds:
            if index.column() == 0:
                row = index.row()
                musicId = self.searchTable.item(row, 4).text()
                songLink = SearchOnline.get_song_link(musicId)
                if not songLink:
                    continue
                songLinkWrap = songLink + '~' + musicId
                if songLinkWrap  not in songsInOnlineList:
                    musicName = self.searchTable.item(row, 1).text()
                    artist = self.searchTable.item(row, 2).text()
                    title = artist + '._.' + musicName
                    album = self.searchTable.item(row, 3).text()
                    lrcName = title + '.lrc'
                    lrcPath = os.path.join(Configures.lrcsDir, lrcName)
                    if os.path.exists(lrcPath):
                        os.remove(lrcPath)
                    added_items.append([title, songLinkWrap])
#                    SearchOnline.get_lrc_path(title, musicId)
                    model.add_record(title, '未知', album, songLinkWrap)
        if len(added_items):
            thread = DownloadLrcThread(added_items)
            thread.setDaemon(True)
            thread.setName("downloadLrc")
            thread.start()
            self.add_bunch_to_list_succeed.emit()
        self.setCursor(QCursor(Qt.ArrowCursor))
        print(time.time()-t2)
        print("Success")
コード例 #8
0
ファイル: player.py プロジェクト: kouxulei/xyplayer-package
 def tag_values_changed(self, row, oldTitle, title, album):
     widget = self.managePage.playlistWidget
     playlist = widget.get_playlist()
     if oldTitle != title:
         if widget.get_playing_used_state():
             self.playbackPanel.playlist.set_music_title_at(row, title, False)
             if row == self.playbackPanel.currentSourceRow:
                 artistName, musicName = get_artist_and_musicname_from_title(title)
                 self.playbackPanel.playAction.setText(musicName)
                 self.playbackPanel.musicTitleLabel.setText(title)
         if playlist.get_name() == Configures.PlaylistFavorite:
             index = self.playbackPanel.lovedSongs.index(oldTitle)
             self.playbackPanel.lovedSongs[index] = title
         self.playbackPanel.check_favorite()
         thread = DownloadLrcThread(((title, Configures.LocalMusicId), ))
         thread.setDaemon(True)
         thread.setName("downloadLrc")
         thread.start()
     else:
         if widget.get_playing_used_state():
             self.playbackPanel.playlist.set_music_album_at(row, album, False)