Skip to content

Commit

Permalink
add contentRating for meta
Browse files Browse the repository at this point in the history
  • Loading branch information
zhaarey committed Jun 6, 2024
1 parent 0979ae0 commit 63290b6
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
7 changes: 7 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 7 additions & 0 deletions main_atmos.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
8 changes: 8 additions & 0 deletions main_select.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 63290b6

Please sign in to comment.