-
Notifications
You must be signed in to change notification settings - Fork 52
/
id3v2.go
61 lines (55 loc) · 1.37 KB
/
id3v2.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
// Copyright 2016 Albert Nigmatzianov. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
// Package id3v2 is the ID3 parsing and writing library for Go.
package id3v2
import (
"io"
"os"
)
// Available picture types for picture frame.
const (
PTOther = iota
PTFileIcon
PTOtherFileIcon
PTFrontCover
PTBackCover
PTLeafletPage
PTMedia
PTLeadArtistSoloist
PTArtistPerformer
PTConductor
PTBandOrchestra
PTComposer
PTLyricistTextWriter
PTRecordingLocation
PTDuringRecording
PTDuringPerformance
PTMovieScreenCapture
PTBrightColouredFish
PTIllustration
PTBandArtistLogotype
PTPublisherStudioLogotype
)
// Open opens file with name and passes it to OpenFile.
// If there is no tag in file, it will create new one with version ID3v2.4.
func Open(name string, opts Options) (*Tag, error) {
file, err := os.Open(name)
if err != nil {
return nil, err
}
return ParseReader(file, opts)
}
// ParseReader parses rd and finds tag in it considering opts.
// If there is no tag in rd, it will create new one with version ID3v2.4.
func ParseReader(rd io.Reader, opts Options) (*Tag, error) {
tag := NewEmptyTag()
err := tag.parse(rd, opts)
return tag, err
}
// NewEmptyTag returns an empty ID3v2.4 tag without any frames and reader.
func NewEmptyTag() *Tag {
tag := new(Tag)
tag.init(nil, 0, 4)
return tag
}