UNPKG

4.82 kBMarkdownView Raw
1# node-id3
2
3node-id3 is a ID3-Tag library written in JavaScript without other dependencies.
4
5## Installation
6```
7npm install node-id3
8```
9
10## Usage
11
12```javascript
13const NodeID3 = require('node-id3')
14
15/* Variables found in the following usage examples */
16
17// file can be a buffer or string with the path to a file
18let file = './path/to/(mp3)file' || new Buffer("Some Buffer of a (mp3) file")
19let filebuffer = new Buffer("Some Buffer of a (mp3) file")
20let filepath = './path/to/(mp3)file'
21```
22
23### Creating/Writing tags
24
25```javascript
26// Define the tags for your file using the ID (e.g. APIC) or the alias (see at bottom)
27let tags = {
28 title: "Tomorrow",
29 artist: "Kevin Penkin",
30 album: "TVアニメ「メイドインアビス」オリジナルサウンドトラック",
31 APIC: "./example/mia_cover.jpg",
32 TRCK: "27"
33}
34
35// Create a ID3-Frame buffer from passed tags
36// Synchronous
37let ID3FrameBuffer = NodeID3.create(tags) // Returns ID3-Frame buffer
38// Asynchronous
39NodeID3.create(tags, function(frame) { })
40
41// Write ID3-Frame into (.mp3) file
42let success = NodeID3.write(tags, file) // Returns true/false or, if buffer passed as file, the tagged buffer
43NodeID3.write(tags, file, function(err, buffer) { }) // Buffer is only returned if a buffer was passed as file
44
45// Update existing ID3-Frame with new/edited tags
46let success = NodeID3.update(tags, file) // Returns true/false or, if buffer passed as file, the tagged buffer
47NodeID3.update(tags, file, function(err, buffer) { }) // Buffer is only returned if a buffer was passed as file
48```
49
50### Reading ID3-Tags
51
52```javascript
53let tags = NodeID3.read(file)
54NodeID3.read(file, function(err, tags) {
55 /*
56 tags: {
57 title: "Tomorrow",
58 artist: "Kevin Penkin",
59 image: {
60 mime: "jpeg",
61 type: {
62 id: 3,
63 name: "front cover"
64 },
65 description: String,
66 imageBuffer: Buffer
67 },
68 raw: {
69 TIT2: "Tomorrow",
70 TPE1: "Kevin Penkin",
71 APIC: Object (See above)
72 }
73 }
74 */
75})
76```
77
78### Removing ID3-Tags from file/buffer
79
80```javascript
81let success = NodeID3.removeTags(filepath) // returns true/false
82NodeID3.removeTags(filepath, function(err) { })
83
84let bufferWithoutID3Frame = NodeID3.removeTagsFromBuffer(filebuffer) // Returns Buffer
85```
86
87## Supported aliases
88```
89album:
90bpm:
91composer:
92genre:
93copyright:
94date:
95playlistDelay:
96encodedBy:
97textWriter:
98fileType:
99time:
100contentGroup:
101title:
102subtitle:
103initialKey:
104language:
105length:
106mediaType:
107originalTitle:
108originalFilename:
109originalTextwriter:
110originalArtist:
111originalYear:
112fileOwner:
113artist:
114performerInfo:
115conductor:
116remixArtist:
117partOfSet:
118publisher:
119trackNumber:
120recordingDates:
121internetRadioName:
122internetRadioOwner:
123size:
124ISRC:
125encodingTechnology:
126year:
127comment: {
128 language: "eng",
129 text: "mycomment"
130}
131unsynchronisedLyrics: {
132 language: "eng",
133 text: "lyrics"
134}
135userDefinedText: [{
136 description: "txxx name",
137 value: "TXXX value text"
138}, {
139 description: "txxx name 2",
140 value: "TXXX value text 2"
141}] // Care, update doesn't delete non-passed array items!
142image: {
143 mime: "png/jpeg"/undefined,
144 type: {
145 id: 3,
146 name: "front cover
147 }, // See https://en.wikipedia.org/wiki/ID3#ID3v2_embedded_image_extension
148 description: "image description",
149 imageBuffer: (file buffer)
150}
151```
152
153### Supported raw IDs
154You can also use the currently supported raw tags like TALB instead of album etc.
155```
156album: "TALB"
157bpm: "TBPM"
158composer: "TCOM"
159genre: "TCON"
160copyright: "TCOP"
161date: "TDAT"
162playlistDelay: "TDLY"
163encodedBy: "TENC"
164textWriter: "TEXT"
165fileType: "TFLT"
166time: "TIME"
167contentGroup: "TIT1"
168title: "TIT2"
169subtitle: "TIT3"
170initialKey: "TKEY"
171language: "TLAN"
172length: "TLEN"
173mediaType: "TMED"
174originalTitle: "TOAL"
175originalFilename: "TOFN"
176originalTextwriter: "TOLY"
177originalArtist: "TOPE"
178originalYear: "TORY"
179fileOwner: "TOWN"
180artist: "TPE1"
181performerInfo: "TPE2"
182conductor: "TPE3"
183remixArtist: "TPE4"
184partOfSet: "TPOS"
185publisher: "TPUB"
186trackNumber: "TRCK"
187recordingDates: "TRDA"
188internetRadioName: "TRSN"
189internetRadioOwner: "TRSO"
190size: "TSIZ"
191ISRC: "TSRC"
192encodingTechnology: "TSSE"
193year: "TYER"
194comment: "COMM"
195image: "APIC"
196unsynchronisedLyrics "USLT"
197userDefinedText "TXXX"
198```
\No newline at end of file