From 404cc6e81297c00ac2bc1b1fcbee570dc498f3cb Mon Sep 17 00:00:00 2001 From: zhaarey <157944548+zhaarey@users.noreply.github.com> Date: Sat, 4 May 2024 11:39:02 +0800 Subject: [PATCH] if disc only 1 will not add disc number --- main.go | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/main.go b/main.go index 196af98..7ebbc66 100644 --- a/main.go +++ b/main.go @@ -812,18 +812,19 @@ func writeM4a(w *mp4.Writer, info *SongInfo, meta *AutoGenerated, data []byte, t } trkn := make([]byte, 8) - binary.BigEndian.PutUint32(trkn, uint32(trackNum)) + binary.BigEndian.PutUint32(trkn, uint32(meta.Data[0].Relationships.Tracks.Data[index].Attributes.TrackNumber)) binary.BigEndian.PutUint16(trkn[4:], uint16(trackTotal)) err = addMeta(mp4.BoxType{'t', 'r', 'k', 'n'}, trkn) if err != nil { return err } - - disk := make([]byte, 8) - binary.BigEndian.PutUint32(disk, uint32(meta.Data[0].Relationships.Tracks.Data[index].Attributes.DiscNumber)) - err = addMeta(mp4.BoxType{'d', 'i', 's', 'k'}, disk) - if err != nil { - return err + if meta.Data[0].Relationships.Tracks.Data[trackTotal - 1].Attributes.DiscNumber > 1{ + disk := make([]byte, 8) + binary.BigEndian.PutUint32(disk, uint32(meta.Data[0].Relationships.Tracks.Data[index].Attributes.DiscNumber)) + err = addMeta(mp4.BoxType{'d', 'i', 's', 'k'}, disk) + if err != nil { + return err + } } ctx.UnderIlst = false @@ -2055,4 +2056,4 @@ type SongLyrics struct { } `json:"playParams"` } `json:"attributes"` } `json:"data"` -} +} \ No newline at end of file