Exemplo n.º 1
0
 def __saveAlbumInfo(self):
     """ 保存专辑信息 """
     # 禁用小部件
     self.__showLoadingGif()
     self.__setWidgetEnable(False)
     # 显示动图
     # 更新标签信息
     self.albumInfo["album"] = self.albumNameLineEdit.text()
     self.albumInfo["songer"] = self.albumSongerLineEdit.text()
     self.albumInfo["tcon"] = self.tconLineEdit.text()
     album_list = adjustAlbumName(self.albumNameLineEdit.text())
     for songInfo, songInfoWidget in zip(
         self.songInfo_list, self.songInfoWidget_list
     ):
         songInfo["album"] = album_list[0]
         songInfo["modifiedAlbum"] = album_list[-1]
         songInfo["songName"] = songInfoWidget.songNameLineEdit.text()
         songInfo["songer"] = songInfoWidget.songerLineEdit.text()
         songInfo["tcon"] = self.tconLineEdit.text()
         # 根据后缀名选择曲目标签的写入方式
         songInfo["tracknumber"] = songInfoWidget.trackNumLineEdit.text()
     self.saveInfoSig.emit(self.albumInfo)
     # 保存失败时重新启用编辑框
     self.__setWidgetEnable(True)
     self.loadingLabel.hide()
     self.movie.stop()
Exemplo n.º 2
0
 def getOneSongInfo(self, songPath: str):
     """ 获取一首歌的信息 """
     tag = TinyTag.get(songPath)
     fileInfo = QFileInfo(songPath)
     # 获取标签信息
     suffix = "." + fileInfo.suffix()
     songName = tag.title if tag.title and tag.title.strip(
     ) else fileInfo.baseName()
     songer = tag.artist if tag.artist and tag.artist.strip() else "未知艺术家"
     album = tag.album if tag.album and tag.album.strip() else "未知专辑"
     tracknumber = str(tag.track) if tag.track else "0"
     tcon = tag.genre if tag.genre else "未知流派"
     duration = f"{int(tag.duration//60)}:{int(tag.duration%60):02}"
     album_list = adjustAlbumName(album)
     # 调整曲目序号
     tracknumber = self.__adjustTrackNumber(tracknumber)
     # 获取年份
     if tag.year and tag.year[0] != "0":
         year = tag.year[:4] + "年"
     else:
         tag = File(songPath)
         key_dict = {".m4a": "©day", ".mp3": "TDRC", ".flac": "year"}
         year = (str(tag.get(key_dict[suffix])[0])[:4] +
                 "年" if tag.get(key_dict[suffix]) else "未知年份")
     # 获取时间戳
     createTime = fileInfo.birthTime().toString(Qt.ISODate)
     modifiedTime = fileInfo.lastModified().toString(Qt.ISODate)
     songInfo = {
         "songPath": songPath,
         "songer": songer,
         "songName": songName,
         "album": album_list[0],  # album为原专辑名
         "modifiedAlbum": album_list[-1],  # modifiedAlbum为修改后的专辑名
         "tcon": tcon,
         "year": year,
         "tracknumber": tracknumber,
         "duration": duration,
         "suffix": suffix,
         "createTime": createTime,
         "modifiedTime": modifiedTime,
     }
     return songInfo
Exemplo n.º 3
0
 def saveInfo(self):
     """ 保存标签卡信息 """
     album_list = adjustAlbumName(self.albumNameEditLine.text())
     self.songInfo["songName"] = self.songNameEditLine.text()
     self.songInfo["songer"] = self.songerNameEditLine.text()
     self.songInfo["album"] = album_list[0]
     self.songInfo["modifiedAlbum"] = album_list[-1]
     # 根据后缀名选择曲目标签的写入方式
     self.songInfo["tracknumber"] = self.trackNumEditLine.text()
     self.songInfo["tcon"] = self.tconEditLine.text()
     if self.yearEditLine.text()[:4] != "未知年份":
         self.songInfo["year"] = self.yearEditLine.text()[:4] + "年"
     else:
         self.songInfo["year"] = "未知年份"
     if not modifySongInfo(self.songInfo):
         self.bottomErrorLabel.setText("遇到未知错误,请稍后再试")
         self.bottomErrorLabel.show()
         self.bottomErrorIcon.show()
     else:
         self.saveInfoSig.emit(self.oldSongInfo, self.songInfo)
         self.parent().deleteLater()