Skip to content

Commit c67655b

Browse files
committed
feat(wrtag): write multi valued RELEASETYPE, write COMPILATION only if VA
closes #183
1 parent 276fc10 commit c67655b

File tree

3 files changed

+16
-11
lines changed

3 files changed

+16
-11
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -619,8 +619,8 @@ Example track is [America Is Waiting](https://musicbrainz.org/release/3b28412d-8
619619
| `LABEL` | Record label | `Virgin` |
620620
| `CATALOGNUMBER` | Catalogue number | `BEDBX 1` |
621621
| `BARCODE` | Release barcode/UPC | `0094633134126` |
622-
| `COMPILATION` | Release has type compilation / is Various Artists | `1` |
623-
| `RELEASETYPE` | Release primary type | `album` |
622+
| `COMPILATION` | Release is by Various Artists | `1` |
623+
| `RELEASETYPE` | Release primary and secondary types (multi-valued) | `album`, `soundtrack` |
624624
| `TITLE` | Track title | `America Is Waiting` |
625625
| `ARTIST` | Track artist as string | `Brian Eno + David Byrne` |
626626
| `ARTISTS` | Track artist names as multi-valued tag | `Brian Eno`, `David Byrne` |

musicbrainz/musicbrainz.go

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -452,15 +452,9 @@ func artistEnName(artist Artist) string {
452452
const variousArtistsMBID = "89ad4ac3-39f7-470e-963a-56509c546377"
453453

454454
func IsCompilation(rg ReleaseGroup) bool {
455-
if hasComp := slices.Contains(rg.SecondaryTypes, Compilation); hasComp {
456-
return true
457-
}
458-
if hasVA := slices.ContainsFunc(rg.Artists, func(ac ArtistCredit) bool {
455+
return slices.ContainsFunc(rg.Artists, func(ac ArtistCredit) bool {
459456
return ac.Artist.ID == variousArtistsMBID
460-
}); hasVA {
461-
return true
462-
}
463-
return false
457+
})
464458
}
465459

466460
func FlatTracks(media []Media) []Track {

wrtag.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ func WriteRelease(
503503
normtag.Set(t, normtag.CatalogueNum, trimZero(labelInfo.CatalogNumber)...)
504504
normtag.Set(t, normtag.Barcode, trimZero(release.Barcode)...)
505505
normtag.Set(t, normtag.Compilation, trimZero(formatBool(musicbrainz.IsCompilation(release.ReleaseGroup)))...)
506-
normtag.Set(t, normtag.ReleaseType, trimZero(strings.ToLower(string(release.ReleaseGroup.PrimaryType)))...)
506+
normtag.Set(t, normtag.ReleaseType, trimZero(releaseTypes(release.ReleaseGroup)...)...)
507507

508508
normtag.Set(t, normtag.MusicBrainzReleaseID, trimZero(release.ID)...)
509509
normtag.Set(t, normtag.MusicBrainzReleaseGroupID, trimZero(release.ReleaseGroup.ID)...)
@@ -1165,6 +1165,17 @@ func trimZero[T comparable](elms ...T) []T {
11651165
return slices.DeleteFunc(elms, func(t T) bool { return t == zero })
11661166
}
11671167

1168+
func releaseTypes(rg musicbrainz.ReleaseGroup) []string {
1169+
var types []string
1170+
if rg.PrimaryType != "" {
1171+
types = append(types, strings.ToLower(string(rg.PrimaryType)))
1172+
}
1173+
for _, st := range rg.SecondaryTypes {
1174+
types = append(types, strings.ToLower(string(st)))
1175+
}
1176+
return types
1177+
}
1178+
11681179
func parseAnyTime(str string) time.Time {
11691180
t, _ := dateparse.ParseAny(str)
11701181
return t

0 commit comments

Comments
 (0)