Skip to content

Commit

Permalink
if disc only 1 will not add disc number
Browse files Browse the repository at this point in the history
  • Loading branch information
zhaarey committed May 4, 2024
1 parent 3f285da commit 404cc6e
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -2055,4 +2056,4 @@ type SongLyrics struct {
} `json:"playParams"`
} `json:"attributes"`
} `json:"data"`
}
}

0 comments on commit 404cc6e

Please sign in to comment.