flac-tagger
v1.0.7
Published
Pure JavaScript FLAC Tag writer and reader.
Downloads
63
Readme
flac-tagger
Pure JavaScript FLAC Tag writer and reader.
Installation
npm install flac-tagger
Usage
Read FLAC Tags
import { FlacTags, readFlacTags } from 'flac-tagger'
import { readFile } from 'fs/promises'
// read from file path
const tagsFromFile: FlacTags = await readFlacTags('path/to/file.flac')
// read from buffer
const buffer = await readFile('path/to/file.flac')
const tagsFromBuffer: FlacTags = await readFlacTags(buffer)
// read tag by vorbis comment name (case-insensitive)
const { title, artist, album } = tagsFromFile.tagMap
// read cover image
const coverBuffer = tagsFromFile.picture?.buffer
Write FLAC Tags
import { FlacTagMap, writeFlacTags } from 'flac-tagger'
import { readFile } from 'fs/promises'
// write vorbis comments (names are case-insensitive)
const tagMap: FlacTagMap = {
// single value
title: 'song title',
// multiple values
artist: ['artist A', 'artist B'],
album: 'album name',
}
await writeFlacTags(
{
tagMap,
// (optional) cover image
picture: {
buffer: await readFile('coverImage.jpg'),
}
},
// path to existing flac file
'path/to/file.flac',
)