Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions v2/tag.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,10 +234,18 @@ func (tag *Tag) Artist() string {
return tag.GetTextFrame(tag.CommonID("Artist")).Text
}

func (tag *Tag) AlbumArtist() string {
return tag.GetTextFrame(tag.CommonID("Band/Orchestra/Accompaniment")).Text
}

func (tag *Tag) SetArtist(artist string) {
tag.AddTextFrame(tag.CommonID("Artist"), tag.DefaultEncoding(), artist)
}

func (tag *Tag) SetAlbumArtist(albumArtist string) {
tag.AddTextFrame(tag.CommonID("Band/Orchestra/Accompaniment"), tag.DefaultEncoding(), albumArtist)
}

func (tag *Tag) Album() string {
return tag.GetTextFrame(tag.CommonID("Album/Movie/Show title")).Text
}
Expand Down
13 changes: 9 additions & 4 deletions v2/tag_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ const (
frontCoverPath = "testdata/front_cover.jpg"
backCoverPath = "testdata/back_cover.jpg"

framesSize = 211978
framesSize = 212001
tagSize = tagHeaderSize + framesSize
musicSize = 3840834
countOfFrames = 15
countOfFrames = 16
)

var (
Expand Down Expand Up @@ -111,6 +111,7 @@ func resetMP3Tag() error {

tag.SetTitle("Title")
tag.SetArtist("Artist")
tag.SetAlbumArtist("AlbumArtist")
tag.SetAlbum("Album")
tag.SetYear("2016")
tag.SetGenre("Genre")
Expand Down Expand Up @@ -155,8 +156,8 @@ func TestCountLenSize(t *testing.T) {
}

// Check len of tag.AllFrames().
if len(tag.AllFrames()) != 12 {
t.Errorf("Expected: %v, got: %v", 11, len(tag.AllFrames()))
if len(tag.AllFrames()) != 13 {
t.Errorf("Expected: %v, got: %v", 13, len(tag.AllFrames()))
}

// Check saved tag size by reading the 6:10 bytes of mp3 file.
Expand Down Expand Up @@ -391,6 +392,7 @@ func TestEmptyTagWriteTo(t *testing.T) {

tag := NewEmptyTag()
tag.SetArtist("Artist")
tag.SetAlbumArtist("AlbumArtist")
tag.SetTitle("Title")

buf := new(bytes.Buffer)
Expand All @@ -408,6 +410,9 @@ func TestEmptyTagWriteTo(t *testing.T) {
if parsedTag.Artist() != "Artist" {
t.Error("Expected Artist, got", parsedTag.Artist())
}
if parsedTag.AlbumArtist() != "AlbumArtist" {
t.Error("Expected AlbumArtist, got", parsedTag.Artist())
}
if parsedTag.Title() != "Title" {
t.Error("Expected Title, got", parsedTag.Title())
}
Expand Down
Binary file modified v2/testdata/test.mp3
Binary file not shown.