def sliderMovedEvent(self): """用于拖动时显示当前位置的时间。""" # 进度条移动事件,会显示当前的时间。 value = self.slider.value() currentSliderTime = self.player.allTime() * value / 1000 self.currentTime.setText(addition.itv2time(currentSliderTime))
def selectFolder(self): folder = QFileDialog() selectFolder = folder.getExistingDirectory() if not selectFolder: pass else: self.folder.append(selectFolder) mediaFiles = glob.glob(selectFolder + '\\*.mp3') length = len(mediaFiles) self.singsTable.setRowCount(self.singsTable.rowCount() + length) self.musicList = [] for i in enumerate(mediaFiles): temp = eyed3.load(i[1]) name = temp.tag.title if not name: name = i[1].split('\\')[-1][:-4] author = temp.tag.artist if not author: author = '未知歌手' time = itv2time(temp.info.time_secs) self.musicList.append({ 'name': name, 'author': author, 'time': time, 'url': i[1], 'music_img': 'None' }) self.singsTable.setItem(i[0], 0, QTableWidgetItem(name)) self.singsTable.setItem(i[0], 1, QTableWidgetItem(author)) self.singsTable.setItem(i[0], 2, QTableWidgetItem(time))
def selectFolder(self): folder = QFileDialog() selectFolder = folder.getExistingDirectory() if not selectFolder: pass else: self.folder.append(selectFolder) mediaFiles = glob.glob(selectFolder + '/*.mp3') allFolder = getAllFolder(selectFolder) for i in allFolder: mediaFiles.extend(glob.glob(i + '/*.mp3')) length = len(mediaFiles) self.native.singsTable.setRowCount( self.native.singsTable.rowCount() + length) self.musicList = [] for i in enumerate(mediaFiles): music = eyed3.load(i[1]) if not music: self.singsTable.removeRow(i[0]) continue try: name = music.tag.title author = music.tag.artist if not name: filePath = i[1].replace(selectFolder, '') name = filePath[1:][:-4] if not author: author = '' except: try: # TODO # if more folders exist. filePath = i[1].replace(selectFolder, '') name = filePath[1:][:-4] except Exception as e: name = i[1] author = '' time = itv2time(music.info.time_secs) self.musicList.append({ 'name': name, 'author': author, 'time': time, 'url': i[1], 'music_img': 'None' }) self.native.singsTable.setItem(i[0], 0, QTableWidgetItem(name)) self.native.singsTable.setItem(i[0], 1, QTableWidgetItem(author)) self.native.singsTable.setItem(i[0], 2, QTableWidgetItem(time))
def selectFolder(self): folder = QFileDialog() selectFolder = folder.getExistingDirectory() if not selectFolder: pass else: self.folder.append(selectFolder) mediaFiles = glob.glob(selectFolder+'/*.mp3') allFolder = getAllFolder(selectFolder) for i in allFolder: mediaFiles.extend(glob.glob(i+'/*.mp3')) length = len(mediaFiles) self.native.singsTable.clearContents() self.native.singsTable.setRowCount(length) self.musicList = [] for i in enumerate(mediaFiles): music = eyed3.load(i[1]) if not music: self.singsTable.removeRow(i[0]) continue try: name = music.tag.title author = music.tag.artist if not name: filePath = i[1].replace(selectFolder, '') name = filePath[1:][:-4] if not author: author = '' except: try: # TODO # if more folders exist. filePath = i[1].replace(selectFolder, '') name = filePath[1:][:-4] except Exception as e: name = i[1] author = '' try: time = itv2time(music.info.time_secs) except: time = '00:00' self.musicList.append({'name': name, 'author': author, 'time': time, 'url': i[1], 'music_img': 'None'}) self.native.singsTable.setItem(i[0], 0, QTableWidgetItem(name)) self.native.singsTable.setItem(i[0], 1, QTableWidgetItem(author)) self.native.singsTable.setItem(i[0], 2, QTableWidgetItem(time))
def fromPathLoadSong(self, selectFolder): if not os.path.isdir(selectFolder): os.mkdir(selectFolder) return mediaFiles = glob.glob(selectFolder+'/*.mp3') allFolder = getAllFolder(selectFolder) for i in allFolder: mediaFiles.extend(glob.glob(i+'/*.mp3')) length = len(mediaFiles) self.downloadFrame.singsTable.clearContents() self.downloadFrame.singsTable.setRowCount(length) self.musicList = [] for i in enumerate(mediaFiles): music = eyed3.load(i[1]) if not music: self.singsTable.removeRow(i[0]) continue try: name = music.tag.title author = music.tag.artist if not name: filePath = i[1].replace(selectFolder, '') name = filePath[1:][:-4] if not author: author = '' except: try: # TODO # if more folders exist. filePath = i[1].replace(selectFolder, '') name = filePath[1:][:-4] except Exception as e: name = i[1] author = '' try: time = itv2time(music.info.time_secs) except: time = '00:00' self.musicList.append({'name': name, 'author': author, 'time': time, 'url': i[1], 'music_img': 'None'}) self.downloadFrame.singsTable.setItem(i[0], 0, QTableWidgetItem(name)) self.downloadFrame.singsTable.setItem(i[0], 1, QTableWidgetItem(author)) self.downloadFrame.singsTable.setItem(i[0], 2, QTableWidgetItem(time))
def selectFolder(self): folder = QFileDialog() selectFolder = folder.getExistingDirectory() if not selectFolder: pass else: self.folder.append(selectFolder) mediaFiles = glob.glob(selectFolder+'/*.mp3') allFolder = getAllFolder(selectFolder) for i in allFolder: mediaFiles.extend(glob.glob(i+'/*.mp3')) length = len(mediaFiles) self.native.singsTable.setRowCount(self.native.singsTable.rowCount()+length) self.musicList = [] for i in enumerate(mediaFiles): music = eyed3.load(i[1]) if not music: self.singsTable.removeRow(i[0]) continue try: name = music.tag.title except: print('获取该歌曲信息出错: {},已跳过。'.format(i)) self.singsTable.removeRow(i[0]) continue if not name: name = i[1].split('\\')[-1][:-4] author = music.tag.artist if not author: author = '未知歌手' time = itv2time(music.info.time_secs) self.musicList.append({'name': name, 'author': author, 'time': time, 'url': i[1], 'music_img': 'None'}) self.native.singsTable.setItem(i[0], 0, QTableWidgetItem(name)) self.native.singsTable.setItem(i[0], 1, QTableWidgetItem(author)) self.native.singsTable.setItem(i[0], 2, QTableWidgetItem(time))