Change common map type from string to FrameType

develop
Michael Yang 2014-01-17 17:36:29 -05:00
rodzic e326fd920b
commit 93894f2ae9
4 zmienionych plików z 24 dodań i 24 usunięć

Wyświetl plik

@ -44,8 +44,8 @@ type FrameHead struct {
owner *Tag
}
func (h FrameHead) Id() string {
return h.id
func (ft FrameType) Id() string {
return ft.id
}
func (h FrameHead) Size() uint {

Wyświetl plik

@ -19,7 +19,7 @@ type Tag struct {
*Header
frames map[string][]Framer
padding uint
commonMap map[string]string
commonMap map[string]FrameType
frameHeaderSize int
frameConstructor func(io.Reader) Framer
frameBytesConstructor func(Framer) []byte
@ -217,7 +217,7 @@ func (t Tag) Genre() string {
}
func (t Tag) Comments() []string {
frames := t.Frames(t.commonMap["Comments"])
frames := t.Frames(t.commonMap["Comments"].Id())
if frames == nil {
return nil
}
@ -250,8 +250,8 @@ func (t *Tag) SetGenre(text string) {
t.setTextFrameText(t.commonMap["Genre"], text)
}
func (t *Tag) textFrame(id string) TextFramer {
if frame := t.Frame(id); frame != nil {
func (t *Tag) textFrame(ft FrameType) TextFramer {
if frame := t.Frame(ft.Id()); frame != nil {
if textFramer, ok := frame.(TextFramer); ok {
return textFramer
}
@ -260,16 +260,16 @@ func (t *Tag) textFrame(id string) TextFramer {
return nil
}
func (t Tag) textFrameText(id string) string {
if frame := t.textFrame(id); frame != nil {
func (t Tag) textFrameText(ft FrameType) string {
if frame := t.textFrame(ft); frame != nil {
return frame.Text()
}
return ""
}
func (t *Tag) setTextFrameText(id, text string) {
if frame := t.textFrame(id); frame != nil {
func (t *Tag) setTextFrameText(ft FrameType, text string) {
if frame := t.textFrame(ft); frame != nil {
frame.SetText(text)
}
}

Wyświetl plik

@ -14,13 +14,13 @@ const (
var (
// Common frame IDs
V22CommonFrame = map[string]string{
"Title": "TT2",
"Artist": "TP1",
"Album": "TAL",
"Year": "TYE",
"Genre": "TCO",
"Comments": "COM",
V22CommonFrame = map[string]FrameType{
"Title": V22FrameTypeMap["TT2"],
"Artist": V22FrameTypeMap["TP1"],
"Album": V22FrameTypeMap["TAL"],
"Year": V22FrameTypeMap["TYE"],
"Genre": V22FrameTypeMap["TCO"],
"Comments": V22FrameTypeMap["COM"],
}
// V22FrameTypeMap specifies the frame IDs and constructors allowed in ID3v2.2

Wyświetl plik

@ -10,13 +10,13 @@ import (
var (
// Common frame IDs
V23CommonFrame = map[string]string{
"Title": "TIT2",
"Artist": "TPE1",
"Album": "TALB",
"Year": "TYER",
"Genre": "TCON",
"Comments": "COMM",
V23CommonFrame = map[string]FrameType{
"Title": V23FrameTypeMap["TIT2"],
"Artist": V23FrameTypeMap["TPE1"],
"Album": V23FrameTypeMap["TALB"],
"Year": V23FrameTypeMap["TYER"],
"Genre": V23FrameTypeMap["TCON"],
"Comments": V23FrameTypeMap["COMM"],
}
// V23DeprecatedTypeMap contains deprecated frame IDs from ID3v2.2