Skip to content

Commit 63ebdb1

Browse files
committed
Complete text frame fields.
1 parent 5212a88 commit 63ebdb1

14 files changed

Lines changed: 319 additions & 129 deletions

README.md

Lines changed: 40 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,12 @@ main() {
4949
- [x] Emphasis
5050
- [x] CBR (Constant Bitrate) support
5151
- [ ] VBR (Variable Bitrate) support
52+
- [ ] ID3 v1 Tag support
5253
- [ ] ID3 v2 Tag support
5354
- [ ] AENC Audio encryption
5455
- [ ] APIC Attached picture
5556
- [x] CHAP Chapters
56-
- [ ] COMM Comments
57+
- [x] COMM Comments
5758
- [ ] COMR Commercial frame
5859
- [ ] ENCR Encryption method registration
5960
- [ ] EQUA Equalization
@@ -74,45 +75,45 @@ main() {
7475
- [ ] RVRB Reverb
7576
- [ ] SYLT Synchronized lyric/text
7677
- [ ] SYTC Synchronized tempo codes
77-
- [ ] TALB Album/Movie/Show title
78-
- [ ] TBPM BPM (beats per minute)
79-
- [ ] TCOM Composer
80-
- [ ] TCON Content type
81-
- [ ] TCOP Copyright message
82-
- [ ] TDAT Date
83-
- [ ] TDLY Playlist delay
84-
- [ ] TENC Encoded by
85-
- [ ] TEXT Lyricist/Text writer
86-
- [ ] TFLT File type
87-
- [ ] TIME Time
88-
- [ ] TIT1 Content group description
78+
- [x] TALB Album/Movie/Show title
79+
- [x] TBPM BPM (beats per minute)
80+
- [x] TCOM Composer
81+
- [x] TCON Content type
82+
- [x] TCOP Copyright message
83+
- [x] TDAT Date
84+
- [x] TDLY Playlist delay
85+
- [x] TENC Encoded by
86+
- [x] TEXT Lyricist/Text writer
87+
- [x] TFLT File type
88+
- [x] TIME Time
89+
- [x] TIT1 Content group description
8990
- [x] TIT2 Title/songname/content description
90-
- [ ] TIT3 Subtitle/Description refinement
91-
- [ ] TKEY Initial key
92-
- [ ] TLAN Language(s)
93-
- [ ] TLEN Length
94-
- [ ] TMED Media type
95-
- [ ] TOAL Original album/movie/show title
96-
- [ ] TOFN Original filename
97-
- [ ] TOLY Original lyricist(s)/text writer(s)
98-
- [ ] TOPE Original artist(s)/performer(s)
99-
- [ ] TORY Original release year
100-
- [ ] TOWN File owner/licensee
101-
- [ ] TPE1 Lead performer(s)/Soloist(s)
102-
- [ ] TPE2 Band/orchestra/accompaniment
103-
- [ ] TPE3 Conductor/performer refinement
104-
- [ ] TPE4 Interpreted, remixed, or otherwise modified by
105-
- [ ] TPOS Part of a set
106-
- [ ] TPUB Publisher
107-
- [ ] TRCK Track number/Position in set
108-
- [ ] TRDA Recording dates
109-
- [ ] TRSN Internet radio station name
110-
- [ ] TRSO Internet radio station owner
111-
- [ ] TSIZ Size
112-
- [ ] TSRC ISRC (international standard recording code)
113-
- [ ] TSSE Software/Hardware and settings used for encoding
114-
- [ ] TYER Year
115-
- [ ] TXXX User defined text information frame
91+
- [x] TIT3 Subtitle/Description refinement
92+
- [x] TKEY Initial key
93+
- [x] TLAN Language(s)
94+
- [x] TLEN Length
95+
- [x] TMED Media type
96+
- [x] TOAL Original album/movie/show title
97+
- [x] TOFN Original filename
98+
- [x] TOLY Original lyricist(s)/text writer(s)
99+
- [x] TOPE Original artist(s)/performer(s)
100+
- [x] TORY Original release year
101+
- [x] TOWN File owner/licensee
102+
- [x] TPE1 Lead performer(s)/Soloist(s)
103+
- [x] TPE2 Band/orchestra/accompaniment
104+
- [x] TPE3 Conductor/performer refinement
105+
- [x] TPE4 Interpreted, remixed, or otherwise modified by
106+
- [x] TPOS Part of a set
107+
- [x] TPUB Publisher
108+
- [x] TRCK Track number/Position in set
109+
- [x] TRDA Recording dates
110+
- [x] TRSN Internet radio station name
111+
- [x] TRSO Internet radio station owner
112+
- [x] TSIZ Size
113+
- [x] TSRC ISRC (international standard recording code)
114+
- [x] TSSE Software/Hardware and settings used for encoding
115+
- [x] TYER Year
116+
- [x] TXXX User defined text information frame
116117
- [ ] UFID Unique file identifier
117118
- [ ] USER Terms of use
118119
- [ ] USLT Unsychronized lyric/text transcription
Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
import 'dart:typed_data';
66

77
import 'package:mp3_info/src/extensions/parse_extension.dart';
8-
import 'package:mp3_info/src/model/id3/frame.dart';
9-
import 'package:mp3_info/src/model/id3/frame_header.dart';
10-
import 'package:mp3_info/src/model/id3/text_frame.dart';
8+
import 'package:mp3_info/src/metadata/id3/frame.dart';
9+
import 'package:mp3_info/src/metadata/id3/frame_header.dart';
10+
import 'package:mp3_info/src/metadata/id3/text_frame.dart';
1111

1212
/// A 'CHAP' (Chapter) frame in an ID3v2 tag.
1313
///
@@ -76,6 +76,8 @@ class ChapterFrame extends Frame {
7676

7777
do {
7878
var subFrame = Frame.fromBytes(offset: 0, bytes: bytesRemaining);
79+
subFrame.parse();
80+
7981
bytesRemaining = subFrame.remainingBytes;
8082

8183
if (subFrame is TextFrame) {
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
import 'dart:convert';
66
import 'dart:typed_data';
77

8-
import 'package:mp3_info/src/model/id3/frame.dart';
9-
import 'package:mp3_info/src/model/id3/frame_header.dart';
8+
import 'package:mp3_info/src/metadata/id3/frame.dart';
9+
import 'package:mp3_info/src/metadata/id3/frame_header.dart';
1010

1111
/// Represents an ID3 text frame (e.g., TIT2, TPE1, COMM).
1212
///
@@ -19,11 +19,8 @@ class CommentFrame extends Frame {
1919
/// The raw tag bytes.
2020
final Uint8List tags;
2121

22-
/// The parsed text value of the frame.
2322
String value = '';
24-
2523
String language = '';
26-
2724
String description = '';
2825

2926
CommentFrame({required this.frameHeader, required this.tags});
@@ -33,12 +30,15 @@ class CommentFrame extends Frame {
3330
@override
3431
void parse() {
3532
final int encodingByte = frameHeader.data[0];
33+
3634
language = latin1.decode(frameHeader.data.sublist(1, 4));
35+
3736
final descBytes = terminatedStringBytes(
3837
encodingByte, frameHeader.data.sublist(4),
3938
includeTerminatorBytes: true);
4039
description = readString(frameHeader.data.sublist(4, 4 + descBytes),
4140
encoding: encodingByte);
41+
4242
final valueBytes = frameHeader.data.sublist(4 + descBytes);
4343
value = readString(valueBytes, encoding: encodingByte);
4444
}
Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
import 'dart:convert';
66
import 'dart:typed_data';
77

8-
import 'package:mp3_info/src/model/id3/chapter_frame.dart';
9-
import 'package:mp3_info/src/model/id3/comment_frame.dart';
10-
import 'package:mp3_info/src/model/id3/frame_header.dart';
11-
import 'package:mp3_info/src/model/id3/text_frame.dart';
12-
import 'package:mp3_info/src/model/id3/unsupported_frame.dart';
8+
import 'package:mp3_info/src/metadata/id3/chapter_frame.dart';
9+
import 'package:mp3_info/src/metadata/id3/comment_frame.dart';
10+
import 'package:mp3_info/src/metadata/id3/frame_header.dart';
11+
import 'package:mp3_info/src/metadata/id3/text_frame.dart';
12+
import 'package:mp3_info/src/metadata/id3/unsupported_frame.dart';
1313

1414
/// An abstract representation of an ID3 frame.
1515
///
@@ -45,8 +45,6 @@ abstract class Frame {
4545
factory Frame.fromBytes({required int offset, required Uint8List bytes}) {
4646
final frameHeader = FrameHeader(offset: offset, bytes: bytes);
4747

48-
print(frameHeader.name);
49-
5048
switch (frameHeader.name) {
5149
case 'CHAP':
5250
return ChapterFrame(frameHeader: frameHeader, tags: bytes);

lib/src/metadata/id3/id3.dart

Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
// Copyright 2019-2020 Ben Hills (ben.hills@amugofjava.me.uk).
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
import 'package:mp3_info/src/metadata/model/chapter.dart';
6+
import 'package:mp3_info/src/metadata/model/comment.dart';
7+
8+
/// Represents the parsed metadata from an ID3 tag.
9+
///
10+
/// This includes the tag version, header flags, and common frames
11+
/// like title, artist, comments, and chapters.
12+
class ID3 {
13+
/// The major version of the ID3 tag (e.g., 3 for ID3v2.3).
14+
final int majorVersion;
15+
16+
/// The minor version of the ID3 tag.
17+
final int minorVersion;
18+
19+
/// Indicates whether the tag uses unsynchronisation.
20+
final bool syncSafe;
21+
22+
/// Indicates whether the tag includes an extended header.
23+
final bool extendedHeader;
24+
25+
/// Indicates whether the tag includes a footer.
26+
final bool footer;
27+
28+
/// The size of the tag header in bytes.
29+
final int headerSize;
30+
31+
/// A list of chapters extracted from the ID3 tag.
32+
final List<ID3Chapter> chapters = <ID3Chapter>[];
33+
34+
/// TPE1: The song artist.
35+
String artist = '';
36+
37+
/// TPE2: The song artist.
38+
String albumArtist = '';
39+
40+
/// TALB: The song album.
41+
String album = '';
42+
43+
/// TDAT: The song album.
44+
String date = '';
45+
46+
/// TDLY: The playlist delay.
47+
String delay = '';
48+
49+
/// TENC: Encoded by.
50+
String encodedBy = '';
51+
52+
/// TFLT: File type.
53+
String fileType = '';
54+
55+
/// TIME: Time.
56+
String time = '';
57+
58+
/// TIT1: Content group description.
59+
String groupDescription = '';
60+
61+
/// TKEY: Initial key.
62+
String key = '';
63+
64+
/// TEXT: Lyricist/Text writer
65+
String writer = '';
66+
67+
/// TLAN: Language
68+
String language = '';
69+
70+
/// TLEN: Length
71+
String length = '';
72+
73+
/// TMED: Media type
74+
String mediaType = '';
75+
76+
/// TOAL: Original title
77+
String originalTitle = '';
78+
79+
/// TOFL: Original filename
80+
String originalFilename = '';
81+
82+
/// TOLY: Original writer
83+
String originalWriter = '';
84+
85+
/// TOPE: Original writer
86+
String originalArtist = '';
87+
88+
/// TORY: Original year
89+
String originalYear = '';
90+
91+
/// TOWN: File owner/licensee
92+
String owner = '';
93+
94+
/// TPE3: Performer/conductor
95+
String performer = '';
96+
97+
/// TPE4: Interpreted, remixed, or otherwise modified by
98+
String modifiedBy = '';
99+
100+
/// TRDA: Recording dates
101+
String recordingDates = '';
102+
103+
/// TRSN: Internet radio station name
104+
String stationName = '';
105+
106+
/// TRSO: Internet radio station owner
107+
String stationOwner = '';
108+
109+
/// TSIZ: Size
110+
String size = '';
111+
112+
/// TSRC: ISRC (international standard recording code)
113+
String recordingCode = '';
114+
115+
/// TSEE: Software/Hardware and settings used for encoding
116+
String encodingSettings = '';
117+
118+
/// TXXX: User defined text information frame
119+
String information = '';
120+
121+
/// TBPM: Beats per minute.
122+
String bpm = '';
123+
124+
/// TCOP: The song album.
125+
String copyright = '';
126+
127+
/// TPOS: The song album.
128+
String disc = '';
129+
130+
/// TCON: The genre.
131+
String genre = '';
132+
133+
/// TCOP: The composer.
134+
String composer = '';
135+
136+
/// TPUB: The publisher.
137+
String publisher = '';
138+
139+
/// TYER: The composer.
140+
String year = '';
141+
142+
/// TRCK: The song track.
143+
String track = '';
144+
145+
/// TIT2: The song title.
146+
String title = '';
147+
148+
/// TIT3: The song description.
149+
String description = '';
150+
151+
/// Any comment extracted from the COMM frame.
152+
Comment? comment;
153+
154+
/// IPLS
155+
String people = '';
156+
157+
ID3({
158+
required this.majorVersion,
159+
required this.minorVersion,
160+
required this.syncSafe,
161+
required this.extendedHeader,
162+
required this.footer,
163+
required this.headerSize,
164+
});
165+
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
import 'dart:typed_data';
66

7-
import 'package:mp3_info/src/model/id3/frame.dart';
8-
import 'package:mp3_info/src/model/id3/frame_header.dart';
7+
import 'package:mp3_info/src/metadata/id3/frame.dart';
8+
import 'package:mp3_info/src/metadata/id3/frame_header.dart';
99

1010
/// Represents an ID3 text frame (e.g., TIT2, TPE1, COMM).
1111
///

lib/src/model/id3/unsupported_frame.dart renamed to lib/src/metadata/id3/unsupported_frame.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
import 'dart:typed_data';
66

7-
import 'package:mp3_info/src/model/id3/frame.dart';
8-
import 'package:mp3_info/src/model/id3/frame_header.dart';
7+
import 'package:mp3_info/src/metadata/id3/frame.dart';
8+
import 'package:mp3_info/src/metadata/id3/frame_header.dart';
99

1010
/// A placeholder for ID3 frames that are not explicitly supported by the library.
1111
///
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
class Comment {
2+
final String comment;
3+
final String language;
4+
final String description;
5+
6+
Comment(this.comment, this.language, this.description);
7+
}

0 commit comments

Comments
 (0)