From 63290b67b7c4fa649c25c0e178da3b0a9ec24540 Mon Sep 17 00:00:00 2001 From: zhaarey <157944548+zhaarey@users.noreply.github.com> Date: Thu, 6 Jun 2024 16:35:07 +0800 Subject: [PATCH] add contentRating for meta --- main.go | 7 +++++++ main_atmos.go | 7 +++++++ main_select.go | 8 ++++++++ 3 files changed, 22 insertions(+) diff --git a/main.go b/main.go index e38b5a2..12c8624 100644 --- a/main.go +++ b/main.go @@ -1387,6 +1387,13 @@ func rip(albumId string, token string, storefront string, userToken string) erro tags := []string{ fmt.Sprintf("lyrics=%s", lrc), } + if track.Attributes.ContentRating=="explicit"{ + tags = append(tags, "rating=1") + }else if track.Attributes.ContentRating=="clean"{ + tags = append(tags, "rating=2") + }else{ + tags = append(tags, "rating=0") + } if config.EmbedCover { if strings.Contains(albumId, "pl.") && config.DlAlbumcoverForPlaylist { err = writeCover(sanAlbumFolder,track.ID, track.Attributes.Artwork.URL) diff --git a/main_atmos.go b/main_atmos.go index e7fb2f6..ea50b66 100644 --- a/main_atmos.go +++ b/main_atmos.go @@ -1346,6 +1346,13 @@ func rip(albumId string, token string, storefront string, userToken string) erro tags = append(tags, fmt.Sprintf("tracknum=%d/%d", meta.Data[0].Relationships.Tracks.Data[index].Attributes.TrackNumber, trackTotal)) tags = append(tags, fmt.Sprintf("album=%s", meta.Data[0].Relationships.Tracks.Data[index].Attributes.AlbumName)) } + if track.Attributes.ContentRating=="explicit"{ + tags = append(tags, "rating=1") + }else if track.Attributes.ContentRating=="clean"{ + tags = append(tags, "rating=2") + }else{ + tags = append(tags, "rating=0") + } tagsString := strings.Join(tags, ":") cmd := exec.Command("MP4Box", "-add", trackPath, "-name", fmt.Sprintf("1=%s", meta.Data[0].Relationships.Tracks.Data[index].Attributes.Name), "-itags", tagsString, "-brand", "mp42", "-ab", "dby1", m4atrackPath) fmt.Printf("Encapsulating %s into %s\n", filepath.Base(trackPath), filepath.Base(m4atrackPath)) diff --git a/main_select.go b/main_select.go index 2ddad87..8584ad8 100644 --- a/main_select.go +++ b/main_select.go @@ -1466,6 +1466,14 @@ func rip(albumId string, token string, storefront string, userToken string) erro tags = append(tags, fmt.Sprintf("cover=%s/%s.%s", sanAlbumFolder,"cover", config.CoverFormat)) } } + + if track.Attributes.ContentRating=="explicit"{ + tags = append(tags, "rating=1") + }else if track.Attributes.ContentRating=="clean"{ + tags = append(tags, "rating=2") + }else{ + tags = append(tags, "rating=0") + } tagsString := strings.Join(tags, ":") cmd := exec.Command("MP4Box", "-itags", tagsString, trackPath) if err := cmd.Run(); err != nil {