-
Notifications
You must be signed in to change notification settings - Fork 5
/
id3v24.go
860 lines (704 loc) · 17.5 KB
/
id3v24.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
package tag
import (
"bytes"
"errors"
"fmt"
"image"
"image/jpeg"
"image/png"
"io"
"io/ioutil"
"os"
"strconv"
"strings"
"time"
)
type id3v24Flags byte
func (flags id3v24Flags) String() string {
return strconv.Itoa(int(flags))
}
func (flags id3v24Flags) IsUnsynchronisation() bool {
return GetBit(byte(flags), 7) == 1
}
func (flags id3v24Flags) SetUnsynchronisation(data bool) {
SetBit((*byte)(&flags), data, 7)
}
func (flags id3v24Flags) HasExtendedHeader() bool {
return GetBit(byte(flags), 6) == 1
}
func (flags id3v24Flags) SetExtendedHeader(data bool) {
SetBit((*byte)(&flags), data, 7)
}
func (flags id3v24Flags) IsExperimentalIndicator() bool {
return GetBit(byte(flags), 5) == 1
}
func (flags id3v24Flags) SetExperimentalIndicator(data bool) {
SetBit((*byte)(&flags), data, 7)
}
type ID3v24Frame struct {
Key string
Value []byte
}
type ID3v24 struct {
Marker string // Always 'ID3'
Version Version
SubVersion int
Flags id3v24Flags
Length int
Frames []ID3v24Frame
Data []byte
}
type AttachedPicture struct {
MIME string
PictureType byte
Description string
Data []byte
}
func (id3v2 *ID3v24) GetAllTagNames() []string {
var result []string
for i := range id3v2.Frames {
result = append(result, id3v2.Frames[i].Key)
}
return result
}
func (id3v2 *ID3v24) GetVersion() Version {
return id3v2.Version
}
func (id3v2 *ID3v24) GetFileData() []byte {
return id3v2.Data
}
func (id3v2 *ID3v24) GetTitle() (string, error) {
return id3v2.GetString("TIT2")
}
func (id3v2 *ID3v24) GetArtist() (string, error) {
return id3v2.GetString("TPE1")
}
func (id3v2 *ID3v24) GetAlbum() (string, error) {
return id3v2.GetString("TALB")
}
func (id3v2 *ID3v24) GetYear() (int, error) {
date, err := id3v2.GetTimestamp("TDOR")
return date.Year(), err
}
func (id3v2 *ID3v24) GetComment() (string, error) {
// id3v2
// Comment struct must be greater than 4
// [lang \x00 text] - comment format
// lang - 3 symbols
// \x00 - const, delimeter
// text - all after
commentStr, err := id3v2.GetString("COMM")
if err != nil {
return "", err
}
if len(commentStr) < 4 {
return "", ErrIncorrectLength
}
return commentStr[4:], nil
}
func (id3v2 *ID3v24) GetGenre() (string, error) {
return id3v2.GetString("TCON")
}
func (id3v2 *ID3v24) GetAlbumArtist() (string, error) {
return id3v2.GetString("TPE2")
}
func (id3v2 *ID3v24) GetDate() (time.Time, error) {
return id3v2.GetTimestamp("TDRC")
}
func (id3v2 *ID3v24) GetArranger() (string, error) {
return id3v2.GetString("TIPL")
}
func (id3v2 *ID3v24) GetAuthor() (string, error) {
return id3v2.GetString("TOLY")
}
func (id3v2 *ID3v24) GetBPM() (int, error) {
return id3v2.GetInt("TBPM")
}
func (id3v2 *ID3v24) GetCatalogNumber() (string, error) {
return id3v2.GetStringTXXX("CATALOGNUMBER")
}
func (id3v2 *ID3v24) GetCompilation() (string, error) {
return id3v2.GetString("TCMP")
}
func (id3v2 *ID3v24) GetComposer() (string, error) {
return id3v2.GetString("TCOM")
}
func (id3v2 *ID3v24) GetConductor() (string, error) {
return id3v2.GetString("TPE3")
}
func (id3v2 *ID3v24) GetCopyright() (string, error) {
return id3v2.GetString("TCOP")
}
func (id3v2 *ID3v24) GetDescription() (string, error) {
return id3v2.GetString("TIT3")
}
func (id3v2 *ID3v24) GetDiscNumber() (int, int, error) {
dickNumber, err := id3v2.GetString("TPOS")
if err != nil {
return 0, 0, err
}
numbers := strings.Split(dickNumber, "/")
if len(numbers) != 2 {
return 0, 0, ErrIncorrectLength
}
number, err := strconv.Atoi(numbers[0])
if err != nil {
return 0, 0, err
}
total, err := strconv.Atoi(numbers[1])
if err != nil {
return 0, 0, err
}
return number, total, nil
}
func (id3v2 *ID3v24) GetEncodedBy() (string, error) {
return id3v2.GetString("TENC")
}
func (id3v2 *ID3v24) GetTrackNumber() (int, int, error) {
track, err := id3v2.GetInt("TRCK")
return track, track, err
}
func (id3v2 *ID3v24) GetPicture() (image.Image, error) {
pic, err := id3v2.GetAttachedPicture()
if err != nil {
return nil, err
}
switch pic.MIME {
case mimeImageJPEG:
return jpeg.Decode(bytes.NewReader(pic.Data))
case mimeImagePNG:
return png.Decode(bytes.NewReader(pic.Data))
case mimeImageLink:
return downloadImage(string(pic.Data))
default:
return nil, ErrIncorrectTag
}
}
func (id3v2 *ID3v24) SetTitle(title string) error {
return id3v2.SetString("TIT2", title)
}
func (id3v2 *ID3v24) SetArtist(artist string) error {
return id3v2.SetString("TPE1", artist)
}
func (id3v2 *ID3v24) SetAlbum(album string) error {
return id3v2.SetString("TALB", album)
}
func (id3v2 *ID3v24) SetYear(year int) error {
curDate, err := id3v2.GetTimestamp("TDOR")
if err != nil {
// set only year
return id3v2.SetTimestamp(
"TDOR",
time.Date(year, 0, 0, 0, 0, 0, 0, time.Local),
)
}
return id3v2.SetTimestamp(
"TDOR",
time.Date(
year,
curDate.Month(),
curDate.Day(),
curDate.Hour(),
curDate.Minute(),
curDate.Second(),
curDate.Nanosecond(),
curDate.Location(),
),
)
}
func (id3v2 *ID3v24) SetComment(comment string) error {
return id3v2.SetString("COMM", comment)
}
func (id3v2 *ID3v24) SetGenre(genre string) error {
return id3v2.SetString("TCON", genre)
}
func (id3v2 *ID3v24) SetAlbumArtist(albumArtist string) error {
return id3v2.SetString("TPE2", albumArtist)
}
func (id3v2 *ID3v24) SetDate(date time.Time) error {
return id3v2.SetTimestamp("TDRC", date)
}
func (id3v2 *ID3v24) SetArranger(arranger string) error {
return id3v2.SetString("IPLS", arranger)
}
func (id3v2 *ID3v24) SetAuthor(author string) error {
return id3v2.SetString("TOLY", author)
}
func (id3v2 *ID3v24) SetBPM(bmp int) error {
return id3v2.SetInt("TBMP", bmp)
}
func (id3v2 *ID3v24) SetCatalogNumber(catalogNumber string) error {
return id3v2.SetString("TXXX", catalogNumber)
}
func (id3v2 *ID3v24) SetCompilation(compilation string) error {
return id3v2.SetString("TCMP", compilation)
}
func (id3v2 *ID3v24) SetComposer(composer string) error {
return id3v2.SetString("TCOM", composer)
}
func (id3v2 *ID3v24) SetConductor(conductor string) error {
return id3v2.SetString("TPE3", conductor)
}
func (id3v2 *ID3v24) SetCopyright(copyright string) error {
return id3v2.SetString("TCOP", copyright)
}
func (id3v2 *ID3v24) SetDescription(description string) error {
return id3v2.SetString("TIT3", description)
}
func (id3v2 *ID3v24) SetDiscNumber(number int, total int) error {
return id3v2.SetString("TPOS", fmt.Sprintf("%d/%d", number, total))
}
func (id3v2 *ID3v24) SetEncodedBy(encodedBy string) error {
return id3v2.SetString("TENC", encodedBy)
}
func (id3v2 *ID3v24) SetTrackNumber(number int, total int) error {
// only number
return id3v2.SetInt("TRCK", number)
}
func (id3v2 *ID3v24) SetPicture(picture image.Image) error {
// Only PNG
buf := new(bytes.Buffer)
err := png.Encode(buf, picture)
if err != nil {
return err
}
attacheched, err := id3v2.GetAttachedPicture()
if err != nil {
// Set default params
newPicture := AttachedPicture{
MIME: "image/png",
PictureType: 2, // Other file info
Description: "",
Data: buf.Bytes(),
}
return id3v2.SetAttachedPicture(&newPicture)
}
// save metainfo
attacheched.MIME = mimeImagePNG
attacheched.Data = buf.Bytes()
return id3v2.SetAttachedPicture(attacheched)
}
func (id3v2 *ID3v24) DeleteAll() error {
id3v2.Frames = []ID3v24Frame{}
return nil
}
func (id3v2 *ID3v24) DeleteTitle() error {
return id3v2.DeleteTag("TIT2")
}
func (id3v2 *ID3v24) DeleteArtist() error {
return id3v2.DeleteTag("TPE1")
}
func (id3v2 *ID3v24) DeleteAlbum() error {
return id3v2.DeleteTag("TALB")
}
func (id3v2 *ID3v24) DeleteYear() error {
return id3v2.DeleteTag("TDOR")
}
func (id3v2 *ID3v24) DeleteComment() error {
return id3v2.DeleteTag("COMM")
}
func (id3v2 *ID3v24) DeleteGenre() error {
return id3v2.DeleteTag("TCON")
}
func (id3v2 *ID3v24) DeleteAlbumArtist() error {
return id3v2.DeleteTag("TPE2")
}
func (id3v2 *ID3v24) DeleteDate() error {
return id3v2.DeleteTag("TDRC")
}
func (id3v2 *ID3v24) DeleteArranger() error {
return id3v2.DeleteTag("IPLS")
}
func (id3v2 *ID3v24) DeleteAuthor() error {
return id3v2.DeleteTag("TOLY")
}
func (id3v2 *ID3v24) DeleteBPM() error {
return id3v2.DeleteTag("TBMP")
}
func (id3v2 *ID3v24) DeleteCatalogNumber() error {
return id3v2.DeleteTagTXXX("CATALOGNUMBER")
}
func (id3v2 *ID3v24) DeleteCompilation() error {
return id3v2.DeleteTag("TCMP")
}
func (id3v2 *ID3v24) DeleteComposer() error {
return id3v2.DeleteTag("TCOM")
}
func (id3v2 *ID3v24) DeleteConductor() error {
return id3v2.DeleteTag("TPE3")
}
func (id3v2 *ID3v24) DeleteCopyright() error {
return id3v2.DeleteTag("TCOP")
}
func (id3v2 *ID3v24) DeleteDescription() error {
return id3v2.DeleteTag("TIT3")
}
func (id3v2 *ID3v24) DeleteDiscNumber() error {
return id3v2.DeleteTag("TPOS")
}
func (id3v2 *ID3v24) DeleteEncodedBy() error {
return id3v2.DeleteTag("TENC")
}
func (id3v2 *ID3v24) DeleteTrackNumber() error {
return id3v2.DeleteTag("TRCK")
}
func (id3v2 *ID3v24) DeletePicture() error {
return id3v2.DeleteTag("APIC")
}
func (id3v2 *ID3v24) SaveFile(path string) error {
file, err := os.Create(path)
if err != nil {
return err
}
defer file.Close()
return id3v2.Save(file)
}
func (id3v2 *ID3v24) Save(input io.WriteSeeker) error {
// write header
err := id3v2.writeHeaderID3v24(input)
if err != nil {
return err
}
// write tags
err = id3v2.writeFramesID3v24(input)
if err != nil {
return err
}
// write data
_, err = input.Write(id3v2.Data)
if err != nil {
return err
}
return nil
}
func (id3v2 *ID3v24) writeHeaderID3v24(writer io.Writer) error {
headerByte := make([]byte, 10)
// ID3
copy(headerByte[0:3], id3MarkerValue)
// Version, Subversion, Flags
copy(headerByte[3:6], []byte{4, 0, 0})
// Length
length := id3v2.getFramesLength()
lengthByte := IntToByteSynchsafe(length)
copy(headerByte[6:10], lengthByte)
nWriten, err := writer.Write(headerByte)
if err != nil {
return err
}
if nWriten != 10 {
return ErrWriting
}
return nil
}
func (id3v2 *ID3v24) writeFramesID3v24(writer io.Writer) error {
for i := range id3v2.Frames {
header := make([]byte, 10)
// Frame id
copy(header, id3v2.Frames[i].Key)
// Frame size
length := len(id3v2.Frames[i].Value)
header[4] = byte(length >> 24)
header[5] = byte(length >> 16)
header[6] = byte(length >> 8)
header[7] = byte(length)
// write header
_, err := writer.Write(header)
if err != nil {
return err
}
// write data
_, err = writer.Write(id3v2.Frames[i].Value)
if err != nil {
return err
}
}
return nil
}
func (id3v2 *ID3v24) getFramesLength() int {
result := 0
for i := range id3v2.Frames {
// 10 - size of tag header
result += 10 + len(id3v2.Frames[i].Value)
}
return result
}
func (id3v2 *ID3v24) String() string {
result := "Marker: " + id3v2.Marker + "\n" +
"Version: " + id3v2.Version.String() + "\n" +
"Subversion: " + strconv.Itoa(id3v2.SubVersion) + "\n" +
"Flags: " + id3v2.Flags.String() + "\n" +
"Length: " + strconv.Itoa(id3v2.Length) + "\n"
for i := range id3v2.Frames {
result += id3v2.Frames[i].Key + ": " + string(id3v2.Frames[i].Value) + "\n"
}
return result
}
func checkID3v24(input io.ReadSeeker) bool {
if input == nil {
return false
}
// read marker (3 bytes) and version (1 byte) for ID3v2
data, err := seekAndRead(input, 0, io.SeekStart, 4)
if err != nil {
return false
}
marker := string(data[0:3])
// id3v2
if marker != id3MarkerValue {
return false
}
versionByte := data[3]
return versionByte == 4
}
func ReadID3v24(input io.ReadSeeker) (*ID3v24, error) {
header := ID3v24{}
if input == nil {
return nil, ErrEmptyFile
}
// Header size
headerByte, err := seekAndRead(input, 0, io.SeekStart, 10)
if err != nil {
return nil, err
}
// Marker
marker := string(headerByte[0:3])
if marker != "ID3" {
return nil, errors.New("error file marker")
}
header.Marker = marker
// Version
versionByte := headerByte[3]
if versionByte != 4 {
return nil, ErrUnsupportedFormat
}
header.Version = VersionID3v24
// Sub version
subVersionByte := headerByte[4]
header.SubVersion = int(subVersionByte)
// Flags
header.Flags = id3v24Flags(headerByte[5])
// Length
length := ByteToIntSynchsafe(headerByte[6:10])
header.Length = length
// Extended headers
header.Frames = []ID3v24Frame{}
curRead := 0
for curRead < length {
var bytesExtendedHeader []byte
bytesExtendedHeader, err = readBytes(input, 10)
if err != nil {
return nil, err
}
// Frame identifier
key := string(bytesExtendedHeader[0:4])
/*if bytesExtendedHeader[0] == 0 &&
bytesExtendedHeader[1] == 0 &&
bytesExtendedHeader[2] == 0 &&
bytesExtendedHeader[3] == 0 {
break
}*/
// Frame data size
size := ByteToInt(bytesExtendedHeader[4:8])
var bytesExtendedValue []byte
bytesExtendedValue, err = readBytes(input, size)
if err != nil {
return nil, err
}
header.Frames = append(header.Frames, ID3v24Frame{
key,
bytesExtendedValue,
})
curRead += 10 + size
}
// TODO
if curRead != length {
return nil, errors.New("error extended frames")
}
// file data
header.Data, err = ioutil.ReadAll(input)
if err != nil {
return nil, err
}
return &header, nil
}
func (id3v2 *ID3v24) GetString(name string) (string, error) {
for i := range id3v2.Frames {
if id3v2.Frames[i].Key == name {
return GetString(id3v2.Frames[i].Value)
}
}
return "", ErrTagNotFound
}
func (id3v2 *ID3v24) SetString(name string, value string) error {
frame := ID3v24Frame{
Key: name,
Value: SetString(value),
}
for i := range id3v2.Frames {
if id3v2.Frames[i].Key == name {
id3v2.Frames[i].Value = frame.Value
return nil
}
}
id3v2.Frames = append(id3v2.Frames, frame)
return nil
}
func (id3v2 *ID3v24) GetTimestamp(name string) (time.Time, error) {
str, err := id3v2.GetString(name)
if err != nil {
return time.Now(), err
}
result, err := time.Parse("2006-01-02T15:04:05", str)
if err != nil {
return time.Now(), err
}
return result, nil
}
func (id3v2 *ID3v24) SetTimestamp(name string, value time.Time) error {
str := value.Format("2006-01-02T15:04:05")
return id3v2.SetString(name, str)
}
func (id3v2 *ID3v24) GetInt(name string) (int, error) {
intStr, err := id3v2.GetString(name)
if err != nil {
return 0, err
}
return strconv.Atoi(intStr)
}
func (id3v2 *ID3v24) SetInt(name string, value int) error {
return id3v2.SetString(name, strconv.Itoa(value))
}
func (id3v2 *ID3v24) GetAttachedPicture() (*AttachedPicture, error) {
var picture AttachedPicture
picStr, err := id3v2.GetString("APIC")
if err != nil {
return nil, err
}
values := strings.SplitN(picStr, "\x00", 3)
if len(values) != 3 {
return nil, ErrIncorrectTag
}
// MIME
picture.MIME = values[0]
// Type
if len(values[1]) == 0 {
return nil, ErrIncorrectTag
}
picture.PictureType = values[1][0]
// Description
picture.Description = values[1][1:]
// Image data
picture.Data = []byte(values[2])
return &picture, nil
}
// nolint:gocritic
func (id3v2 *ID3v24) SetAttachedPicture(picture *AttachedPicture) error {
// set UTF-8
result := []byte{0}
// MIME type
result = append(result, []byte(picture.MIME)...)
result = append(result, 0x00)
// Picture type
result = append(result, picture.PictureType)
// Picture description
result = append(result, []byte(picture.Description)...)
result = append(result, 0x00)
// Picture data
result = append(result, picture.Data...)
return id3v2.SetString("APIC", string(result))
}
func (id3v2 *ID3v24) DeleteTag(name string) error {
index := -1
for i := range id3v2.Frames {
if id3v2.Frames[i].Key == name {
index = i
break
}
}
// already deleted
if index == -1 {
return nil
}
id3v2.Frames = append(id3v2.Frames[:index], id3v2.Frames[index+1:]...)
return nil
}
func (id3v2 *ID3v24) DeleteTagTXXX(name string) error {
index := -1
for i := range id3v2.Frames {
if id3v2.Frames[i].Key == id3v2FrameTXXX {
str, err := GetString(id3v2.Frames[i].Value)
if err != nil {
return err
}
info := strings.SplitN(str, "\x00", 2)
if len(info) != 2 {
return ErrIncorrectTag
}
if info[0] == name {
index = i
break
}
}
}
// already deleted
if index == -1 {
return nil
}
id3v2.Frames = append(id3v2.Frames[:index], id3v2.Frames[index+1:]...)
return nil
}
// GetStringTXXX - get user frame
// Header for 'User defined text information frame'
// Text encoding $xx
// Description <text string according to encoding> $00 (00)
// Value <text string according to encoding>.
func (id3v2 *ID3v24) GetStringTXXX(name string) (string, error) {
for i := range id3v2.Frames {
if id3v2.Frames[i].Key == id3v2FrameTXXX {
str, err := GetString(id3v2.Frames[i].Value)
if err != nil {
return "", err
}
info := strings.SplitN(str, "\x00", 2)
if len(info) != 2 {
return "", ErrIncorrectTag
}
if info[0] == name {
return info[1], nil
}
}
}
return "", ErrTagNotFound
}
func (id3v2 *ID3v24) SetStringTXXX(name string, value string) error {
result := ID3v24Frame{
Key: id3v2FrameTXXX,
Value: SetString(name + "\x00" + value),
}
// find tag
for i := range id3v2.Frames {
if id3v2.Frames[i].Key == id3v2FrameTXXX {
str, err := GetString(id3v2.Frames[i].Value)
if err != nil {
continue
}
info := strings.SplitN(str, "\x00", 2)
if len(info) != 2 {
continue
}
if info[0] == name {
id3v2.Frames[i] = result
return nil
}
}
}
id3v2.Frames = append(id3v2.Frames, result)
return nil
}
func (id3v2 *ID3v24) GetIntTXXX(name string) (int, error) {
str, err := id3v2.GetStringTXXX(name)
if err != nil {
return 0, err
}
return strconv.Atoi(str)
}