diff --git a/id3.go b/id3.go index f6f590c..be8af4c 100644 --- a/id3.go +++ b/id3.go @@ -16,6 +16,7 @@ type Tagger interface { Album() string Year() string Genre() string + Comments() []string SetTitle(string) SetArtist(string) SetAlbum(string) diff --git a/id3v2.go b/id3v2.go index dbdbce3..b075259 100644 --- a/id3v2.go +++ b/id3v2.go @@ -177,6 +177,20 @@ func (t Tag) Genre() string { return t.textFrameText(t.commonMap["Genre"]) } +func (t Tag) Comments() []string { + frames := t.Frames(t.commonMap["Comments"]) + if frames == nil { + return nil + } + + comments := make([]string, len(frames)) + for i, frame := range frames { + comments[i] = frame.String() + } + + return comments +} + func (t *Tag) SetTitle(text string) { t.setTextFrameText(t.commonMap["Title"], text) } diff --git a/id3v22.go b/id3v22.go index 59ab497..77c2914 100644 --- a/id3v22.go +++ b/id3v22.go @@ -14,18 +14,19 @@ const ( var ( // Common frame IDs V22CommonFrame = map[string]string{ - "Title": "TT2", - "Artist": "TP1", - "Album": "TAL", - "Year": "TYE", - "Genre": "TCO", + "Title": "TT2", + "Artist": "TP1", + "Album": "TAL", + "Year": "TYE", + "Genre": "TCO", + "Comments": "COM", } // V22FrameTypeMap specifies the frame IDs and constructors allowed in ID3v2.2 V22FrameTypeMap = map[string]FrameType{ "BUF": FrameType{id: "BUF", description: "Recommended buffer size", constructor: NewDataFrame}, "CNT": FrameType{id: "CNT", description: "Play counter", constructor: NewDataFrame}, - "COM": FrameType{id: "COM", description: "Comments", constructor: NewDataFrame}, + "COM": FrameType{id: "COM", description: "Comments", constructor: NewUnsynchTextFrame}, "CRA": FrameType{id: "CRA", description: "Audio encryption", constructor: NewDataFrame}, "CRM": FrameType{id: "CRM", description: "Encrypted meta frame", constructor: NewDataFrame}, "ETC": FrameType{id: "ETC", description: "Event timing codes", constructor: NewDataFrame}, diff --git a/id3v23.go b/id3v23.go index 2ca5a0e..cfa002e 100644 --- a/id3v23.go +++ b/id3v23.go @@ -10,11 +10,12 @@ import ( var ( // Common frame IDs V23CommonFrame = map[string]string{ - "Title": "TIT2", - "Artist": "TPE1", - "Album": "TALB", - "Year": "TYER", - "Genre": "TCON", + "Title": "TIT2", + "Artist": "TPE1", + "Album": "TALB", + "Year": "TYER", + "Genre": "TCON", + "Comments": "COMM", } // V23DeprecatedTypeMap contains deprecated frame IDs from ID3v2.2 @@ -40,7 +41,7 @@ var ( V23FrameTypeMap = map[string]FrameType{ "AENC": FrameType{id: "AENC", description: "Audio encryption", constructor: NewDataFrame}, "APIC": FrameType{id: "APIC", description: "Attached picture", constructor: NewImageFrame}, - "COMM": FrameType{id: "COMM", description: "Comments", constructor: NewDataFrame}, + "COMM": FrameType{id: "COMM", description: "Comments", constructor: NewUnsynchTextFrame}, "COMR": FrameType{id: "COMR", description: "Commercial frame", constructor: NewDataFrame}, "ENCR": FrameType{id: "ENCR", description: "Encryption method registration", constructor: NewDataFrame}, "EQUA": FrameType{id: "EQUA", description: "Equalization", constructor: NewDataFrame},