Skip to content

Getting started

  1. Install the package.

    npm install trackparse # or: pnpm add / yarn add / bun add trackparse

    Node 18 or newer, or any runtime with ES2020. ESM and CommonJS both work, and the TypeScript types are included. The package is trackparse on npm.

  2. Parse a track with parse (try it in the playground).

    import { parse } from "trackparse";
    // CommonJS: const { parse } = require("trackparse");
    const track = parse("Noisia feat. Foreign Beggars - Shellshock");
    track.title; // 'Shellshock'
    track.artists.map((a) => a.name); // [ 'Noisia', 'Foreign Beggars' ]
    track.artists[1].role; // 'featured'
  3. Look at the versions and the noise.

    const t = parse("Daft Punk - One More Time (Official Music Video) [HD]");
    t.title; // 'One More Time'
    t.junk; // [ { raw: 'Official Music Video', kind: 'video' }, { raw: 'HD', kind: 'quality' } ]
    const r = parse("Dimension - Offshore (Mefjus Remix / Noisia Remix)");
    r.versions.map((v) => `${v.type} by ${v.artists[0].name}`);
    // [ 'remix by Mefjus', 'remix by Noisia' ]
  4. Tell it about names that contain a joiner with knownArtists (try it).

    parse("Chase & Status - Baddadan").artists.map((a) => a.name);
    // [ 'Chase', 'Status' ]
    parse("Chase & Status - Baddadan", { knownArtists: ["Chase & Status"] }).artists.map((a) => a.name);
    // [ 'Chase & Status' ]
  5. Write it back with format, or turn it into JSON.

    import { format } from "trackparse";
    format(t); // 'Daft Punk - One More Time'
    JSON.stringify(t); // '{"input":"Daft Punk - One More Time (Official Music Video) [HD]","mode":"youtube",…}'
  6. Parse a whole tracklist.

    import { parseTracklist } from "trackparse/tracklist";
    const list = parseTracklist("00:00 Noisia - Stigma\n04:10 Mefjus - Sleepless (Phace Remix)");
    list.entries.map((e) => `${e.time.seconds}s ${e.track.title}`); // [ '0s Stigma', '250s Sleepless' ]
    list.warnings; // []
You want to Read
see what kinds of input it reads What it understands
read every field of the result parse and ParsedTrack
pass options or your own keywords Options, Modes
split a bare artist string parseArtists, Artists and credits
write a track back as a string Formatting
parse and check a tracklist Tracklists, Tracklist API
fix times and edit a tracklist Editing tracklists
react to warnings Warnings
serialize to JSON and read it back Serializing to JSON