Add comments to common fields

develop
Michael Yang 2013-12-31 13:48:00 -05:00
rodzic b312beddc1
commit c861b29e23
4 zmienionych plików z 29 dodań i 12 usunięć

1
id3.go
Wyświetl plik

@ -16,6 +16,7 @@ type Tagger interface {
Album() string
Year() string
Genre() string
Comments() []string
SetTitle(string)
SetArtist(string)
SetAlbum(string)

Wyświetl plik

@ -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)
}

Wyświetl plik

@ -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},

Wyświetl plik

@ -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},