@@ -156,6 +156,12 @@ const initFileIpc = (): void => {
156156 size : ( size / ( 1024 * 1024 ) ) . toFixed ( 2 ) ,
157157 path : fullPath ,
158158 quality : format . bitrate ?? 0 ,
159+ replayGain : {
160+ trackGain : common . replaygain_track_gain ?. ratio ,
161+ trackPeak : common . replaygain_track_peak ?. ratio ,
162+ albumGain : common . replaygain_album_gain ?. ratio ,
163+ albumPeak : common . replaygain_album_peak ?. ratio ,
164+ } ,
159165 } ;
160166 } catch ( err ) {
161167 ipcLog . warn ( `⚠️ Failed to parse file: ${ fullPath } ` , err ) ;
@@ -193,6 +199,12 @@ const initFileIpc = (): void => {
193199 format,
194200 // md5
195201 md5 : await getFileMD5 ( filePath ) ,
202+ replayGain : {
203+ trackGain : common . replaygain_track_gain ?. ratio ,
204+ trackPeak : common . replaygain_track_peak ?. ratio ,
205+ albumGain : common . replaygain_album_gain ?. ratio ,
206+ albumPeak : common . replaygain_album_peak ?. ratio ,
207+ } ,
196208 } ;
197209 } catch ( error ) {
198210 ipcLog . error ( "❌ Error fetching music metadata:" , error ) ;
@@ -636,9 +648,26 @@ const initFileIpc = (): void => {
636648 Id3v2Settings . defaultVersion = 3 ;
637649
638650 songFile . tag . title = songData ?. name || "未知曲目" ;
639- songFile . tag . album = songData ?. album ?. name || "未知专辑" ;
640- songFile . tag . performers = songData ?. artists ?. map ( ( ar : any ) => ar . name ) || [ "未知艺术家" ] ;
641- songFile . tag . albumArtists = songData ?. artists ?. map ( ( ar : any ) => ar . name ) || [ "未知艺术家" ] ;
651+ songFile . tag . album =
652+ ( typeof songData ?. album === "string" ? songData . album : songData ?. album ?. name ) || "未知专辑" ;
653+ // 处理歌手信息(兼容字符串和数组格式)
654+ const getArtistNames = ( artists : any ) : string [ ] => {
655+ if ( Array . isArray ( artists ) ) {
656+ return artists
657+ . map ( ( ar : any ) => ( typeof ar === "string" ? ar : ar ?. name || "" ) )
658+ . filter ( ( name ) => name && name . trim ( ) . length > 0 ) ;
659+ }
660+ if ( typeof artists === "string" && artists . trim ( ) . length > 0 ) {
661+ return [ artists ] ;
662+ }
663+ return [ ] ;
664+ } ;
665+
666+ const artistNames = getArtistNames ( songData ?. artists ) ;
667+ const finalArtists = artistNames . length > 0 ? artistNames : [ "未知艺术家" ] ;
668+
669+ songFile . tag . performers = finalArtists ;
670+ songFile . tag . albumArtists = finalArtists ;
642671 if ( lyric && downloadLyric ) songFile . tag . lyrics = lyric ;
643672 if ( songCover && downloadCover ) songFile . tag . pictures = [ songCover ] ;
644673 // 保存元信息
0 commit comments