Skip to content

the1812/flac-tagger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

e479596 · Aug 25, 2023

History

23 Commits
Jul 1, 2023
Jun 27, 2023
Aug 20, 2023
Aug 20, 2023
Jun 27, 2023
Jul 1, 2023
Jun 27, 2023
Jun 27, 2023
Jul 1, 2023
Jun 27, 2023
Aug 25, 2023
Aug 25, 2023
Jul 1, 2023
Jun 27, 2023
Aug 20, 2023

Repository files navigation

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',
)

Specification