forked from frolovo22/tag
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconvert.go
75 lines (71 loc) · 1.86 KB
/
convert.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package tag
import (
"fmt"
)
// nolint:gocyclo
func GetMap(metadata Metadata) map[string]interface{} {
var tags = map[string]interface{}{}
var val interface{}
var err error
if val, err = metadata.GetTitle(); err == nil {
tags["title"] = val
}
if val, err = metadata.GetArtist(); err == nil {
tags["artist"] = val
}
if val, err = metadata.GetAlbum(); err == nil {
tags["album"] = val
}
if val, err = metadata.GetYear(); err == nil {
tags["year"] = val
}
if val, err = metadata.GetComment(); err == nil {
tags["comment"] = val
}
if val, err = metadata.GetGenre(); err == nil {
tags["genre"] = val
}
if val, err = metadata.GetAlbumArtist(); err == nil {
tags["album artist"] = val
}
if val, err = metadata.GetDate(); err == nil {
tags["date"] = val
}
if val, err = metadata.GetArranger(); err == nil {
tags["arranger"] = val
}
if val, err = metadata.GetAuthor(); err == nil {
tags["author"] = val
}
if val, err = metadata.GetBPM(); err == nil {
tags["bmp"] = val
}
if val, err = metadata.GetCatalogNumber(); err == nil {
tags["catalog number"] = val
}
if val, err = metadata.GetCompilation(); err == nil {
tags["compilation"] = val
}
if val, err = metadata.GetComposer(); err == nil {
tags["composer"] = val
}
if val, err = metadata.GetConductor(); err == nil {
tags["conductor"] = val
}
if val, err = metadata.GetCopyright(); err == nil {
tags["copyright"] = val
}
if val, err = metadata.GetDescription(); err == nil {
tags["description"] = val
}
if number, total, errGetDiskNumber := metadata.GetDiscNumber(); errGetDiskNumber == nil {
tags["disc number"] = fmt.Sprintf("%d/%d", number, total)
}
if val, err = metadata.GetEncodedBy(); err == nil {
tags["encoded by"] = val
}
if number, total, err := metadata.GetTrackNumber(); err == nil {
tags["track number"] = fmt.Sprintf("%d/%d", number, total)
}
return tags
}