def online_list_song_download(self): widget = self.managePage.playlistWidget playlist = widget.get_playlist() selecteds = widget.selectedIndexes() isExistsSongs = [] for index in selecteds: if index.column() == 0: row = index.row() songLink = playlist.get_music_path_at(row) title = playlist.get_music_title_at(row) musicId = playlist.get_music_id_at(row) album = playlist.get_music_album_at(row) musicName = get_full_music_name_from_title(title) musicPath = os.path.join(self.managePage.get_download_dir(), musicName) musicPathO = os.path.join(Configures.MusicsDir, musicName) if os.path.exists(musicPath): isExistsSongs.append('%s : %s'%(title, musicPath)) continue if os.path.exists(musicPathO): isExistsSongs.append('%s : %s'%(title, musicPathO)) continue self.managePage.downloadPage.add_a_download_work(songLink, musicPath, title, album, musicId, 0, self.managePage.get_threading_lock()) if len(isExistsSongs): existsSongs = '\n'.join(isExistsSongs) QMessageBox.information(self, "提示", "以下歌曲已在下载目录中不再进行下载,您可以在不联网的情况下点击在线列表播放!\n%s"%existsSongs)
def download(self): if not self.searchTable.rowCount(): return hasExisted = [] self.readyToDownloadSongs = [] selections = self.searchTable.selectionModel() selecteds = selections.selectedIndexes() if not len(selecteds): return self.setCursor(QCursor(Qt.BusyCursor)) for index in selecteds: if index.column() == 0: row = index.row() songName = self.searchTable.item(row, 1).text() artist = self.searchTable.item(row, 2).text() title = connect_as_title(artist, songName) musicName = get_full_music_name_from_title(title) musicPath = os.path.join(self.downloadDir, musicName) if os.path.exists(musicPath): hasExisted.append(title) continue for t in threading.enumerate(): if t.name == musicPath: continue album = self.searchTable.item(row, 3).text() musicId = self.searchTable.item(row, 4).text() songLink = Configures.NoLink self.readyToDownloadSongs.append([songLink, musicPath, title , album, musicId]) self.add_to_download_signal.emit() self.setCursor(QCursor(Qt.ArrowCursor)) if len(hasExisted): hasExistFiles = '\n'.join(hasExisted) self.show() QMessageBox.information(self, '提示','以下歌曲已在下载目录中,将不再进行下载!\n%s'%hasExistFiles)
def mark_as_favorite(self): if self.playlist.get_name( ) == Configures.PlaylistFavorite or not self.playlist.length( ) or self.currentSourceRow < 0: return path = self.playlist.get_music_path_at(self.currentSourceRow) title = self.playlist.get_music_title_at(self.currentSourceRow) if self.playlist.get_name() == Configures.PlaylistOnline: musicName = get_full_music_name_from_title(title) musicPath = os.path.join(self.downloadDir, musicName) musicPathO = os.path.join(Configures.MusicsDir, musicName) if not os.path.exists(musicPath) and not os.path.exists( musicPathO): QMessageBox.information(self, '提示', '请先下载该歌曲再添加喜欢!') return if os.path.exists(musicPath): path = musicPath else: path = musicPathO elif not os.path.exists(path): QMessageBox.information(self, "提示", "路径'" + "%s" % path + "'无效,无法标记喜欢!") return playlistTemp = Playlist() playlistTemp.fill_list(Configures.PlaylistFavorite) if title in self.lovedSongs: playlistTemp.remove_item_at(self.lovedSongs.index(title)) playlistTemp.commit_records() self.lovedSongs.remove(title) self.favoriteButton.setIcon(QIcon(IconsHub.FavoritesNo)) self.favoriteButton.setToolTip("收藏") else: playlistTemp.add_item_from_path(path) playlistTemp.commit_records() self.lovedSongs.append(title) self.favoriteButton.setIcon(QIcon(IconsHub.Favorites)) self.favoriteButton.setToolTip("取消收藏") self.mark_favorite_completed_signal.emit()
def mark_as_favorite(self): if ( self.playlist.get_name() == Configures.PlaylistFavorite or not self.playlist.length() or self.currentSourceRow < 0 ): return path = self.playlist.get_music_path_at(self.currentSourceRow) title = self.playlist.get_music_title_at(self.currentSourceRow) if self.playlist.get_name() == Configures.PlaylistOnline: musicName = get_full_music_name_from_title(title) musicPath = os.path.join(self.downloadDir, musicName) musicPathO = os.path.join(Configures.MusicsDir, musicName) if not os.path.exists(musicPath) and not os.path.exists(musicPathO): QMessageBox.information(self, "提示", "请先下载该歌曲再添加喜欢!") return if os.path.exists(musicPath): path = musicPath else: path = musicPathO elif not os.path.exists(path): QMessageBox.information(self, "提示", "路径'" + "%s" % path + "'无效,无法标记喜欢!") return playlistTemp = Playlist() playlistTemp.fill_list(Configures.PlaylistFavorite) if title in self.lovedSongs: playlistTemp.remove_item_at(self.lovedSongs.index(title)) playlistTemp.commit_records() self.lovedSongs.remove(title) self.favoriteButton.setIcon(QIcon(IconsHub.FavoritesNo)) self.favoriteButton.setToolTip("收藏") else: playlistTemp.add_item_from_path(path) playlistTemp.commit_records() self.lovedSongs.append(title) self.favoriteButton.setIcon(QIcon(IconsHub.Favorites)) self.favoriteButton.setToolTip("取消收藏") self.mark_favorite_completed_signal.emit()
def download(self): if not self.searchTable.rowCount(): return hasExisted = [] self.readyToDownloadSongs = [] selections = self.searchTable.selectionModel() selecteds = selections.selectedIndexes() if not len(selecteds): return self.setCursor(QCursor(Qt.BusyCursor)) for index in selecteds: if index.column() == 0: row = index.row() songName = self.searchTable.item(row, 1).text() artist = self.searchTable.item(row, 2).text() title = connect_as_title(artist, songName) musicName = get_full_music_name_from_title(title) musicPath = os.path.join(self.downloadDir, musicName) if os.path.exists(musicPath): hasExisted.append(title) continue for t in threading.enumerate(): if t.name == musicPath: continue album = self.searchTable.item(row, 3).text() musicId = self.searchTable.item(row, 4).text() songLink = Configures.NoLink self.readyToDownloadSongs.append( [songLink, musicPath, title, album, musicId]) self.add_to_download_signal.emit() self.setCursor(QCursor(Qt.ArrowCursor)) if len(hasExisted): hasExistFiles = '\n'.join(hasExisted) self.show() QMessageBox.information(self, '提示', '以下歌曲已在下载目录中,将不再进行下载!\n%s' % hasExistFiles)