diff --git a/README.md b/README.md index fc4f291..b89187d 100644 --- a/README.md +++ b/README.md @@ -120,9 +120,12 @@ func main() { } if mp3tag.Header.Version == id3v2.V2_3 { - // get certain frame by identifier - title := mp3tag.Frames["TIT2"] - artist := mp3tag.Frames["TPE1"] + // get certain frame by identifier. + // Contents is []byte. CAN AND PROBABLY WILL + // CONTAIN NULL OR OTHER NON-PRINTABLE BYTES !!! + // Text encoding support is still not implemented. + title := mp3tag.Frames["TIT2"].Contents + artist := mp3tag.Frames["TPE1"].Contents } diff --git a/v2/read_test.go b/v2/read_test.go index f880b4c..14f385d 100644 --- a/v2/read_test.go +++ b/v2/read_test.go @@ -4,6 +4,8 @@ import ( "os" "path/filepath" "testing" + + "github.com/Unbewohnte/id3ed/util" ) func TestReadV2Tag(t *testing.T) { @@ -12,8 +14,15 @@ func TestReadV2Tag(t *testing.T) { t.Errorf("%s", err) } - _, err = ReadV2Tag(f) + tag, err := ReadV2Tag(f) if err != nil { t.Errorf("GetV2Tag failed: %s", err) } + + titleFrame := tag.Frames["TIT2"] + + if util.ToStringLossy(titleFrame.Contents) != "title" { + t.Errorf("ReadV2Tag failed: expected contents to be %s; got %s", + "title", util.ToStringLossy(titleFrame.Contents)) + } }