Skip to content

Junk, flags and prefixes

Junk is everything that describes the upload and not the song. It leaves the title, and it goes into junk with a kind so you can decide what to do with it. You can open the example below in the playground.

import { parse } from "trackparse";
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' } ]
Kind Examples
video Official Video, Official Music Video, Visualizer
audio Official Audio, Audio
lyrics Lyrics, Lyric Video
quality HD, HQ, 4K, 1080p
promo Free Download, Out Now, Premiere
platform - YouTube, - SoundCloud suffixes
label NCS Release, Monstercat Release in brackets (not the label field)
genre a bracketed genre such as [Drum & Bass]
other a bare (Official)
note text after a second bullet: VISION RADIO RELOAD in concussion • VISION • VISION RADIO RELOAD (below)

The phrases are in junk.json (plus genres.json for the genre kind) and platform-suffixes.json. Seeing junk is also one of the ways mode: "auto" decides a string came from YouTube (see Modes). A bracket of junk is R5.1, a platform suffix R2.2, and unbracketed junk at the end of a YouTube title R8.4. A note is not noise: it goes to junk because it is not part of the track's identity either (R8.7).

In Rust the kind is the enum JunkKind (JunkKind::Video, JunkKind::Quality and so on). Its as_str() gives the lowercase names in the table. In Go the kind is the string type JunkKind, and its constants (trackparse.JunkKindVideo, trackparse.JunkKindQuality) hold those names. In C the kind is the enum trackparse_junk_kind (TRACKPARSE_JUNK_VIDEO and so on), and kind_name holds the name as a string. The two differ only for a kind that keywords.junk introduced: kind is then TRACKPARSE_JUNK_OTHER and kind_name the new name.

parse("Porter Robinson - Shelter - YouTube").junk; // [ { raw: 'YouTube', kind: 'platform' } ]
parse("Elektronomia - Sky High [NCS Release]").junk; // [ { raw: 'NCS Release', kind: 'label' } ]

Both lines are in the playground: the platform suffix and the label. Catalog numbers like [HOSP123] are not junk yet. They stay in the title. See the roadmap.

To treat a phrase of your own as junk, add it with keywords.junk.

Radio show tracklists often put the record label after the title, behind a spaced bullet (•), and sometimes a note after a second one. The first segment after the bullet becomes label, and each later one goes to junk with the kind note. You can open this example in the playground.

const l = parse("Noisia - concussion • VISION • VISION RADIO RELOAD");
l.title; // 'concussion'
l.label; // 'VISION'
l.junk; // [ { raw: 'VISION RADIO RELOAD', kind: 'note' } ]

The label is kept as written, after normalization: same case, no lookup, null when there is none (None in Python and Rust, nil in Go, NULL in C). Only the part before the first bullet is the track, so versions, features and the year come from there: WHO (K-LONE VIP) • IAMSIAM keeps its VIP as a version, and Stigma • HOSPITAL (2024) has the label HOSPITAL (2024) and no year. A bracket of junk after the bullet is junk as usual, and a segment made only of junk phrases (Stigma • FREE DOWNLOAD) is junk too, not a label.

The bullet has to be U+2022 with a space on each side, after the artist/title dash and outside every bracket. What it understands lists the cases that don't count, and the one false positive: a bullet inside a title (Song • Part 2) is read as a label too. The rule is R8.7, and format writes the label back.

parse("Eminem - Without Me (Explicit)").flags;
// { explicit: true, clean: false, unknownArtist: false, unknownTitle: false }

explicit and clean come from (Explicit), [Clean] and the like (R5.4; try it). unknownArtist and unknownTitle (unknown_artist and unknown_title in Python and Rust, UnknownArtist and UnknownTitle in Go, unknown_artist and unknown_title in C) are set when the artist or title is a placeholder such as ID. See Unknown artists.

A year on its own in brackets, or as a dash suffix, goes into year (R5.5; if there are several, the first in the string wins, R9.6):

const t = parse("Noisia - Stigma (2015)");
t.title; // 'Stigma'
t.year; // 2015

A year inside a version (Remastered 2015) belongs to that version instead, in versions[i].year. In Rust both are Option<u32>; in Go both are *int, nil when there is no year; in C both are const int *, NULL when there is no year. Try it in the playground.

parse("01. Aphex Twin - Xtal").position; // { raw: '01', number: 1 }
parse("2 Unlimited - No Limit").position; // null

raw keeps the digits as written, so you can tell 01 from 1. These count as track numbers:

  • a number followed by . or ): 01. Title, 1) Intro;
  • a zero-padded number and a space: 01 Aphex Twin - Xtal;
  • a number and a dash, when another dash follows: 3 - Artist - Title;
  • in file names, also 07_Burial, 01-Track and 3 My Song.mp3.

A plain number before a word is part of the name: 2 Unlimited, 50 Cent, 808 State. The rule is R4.2, and the playground shows both 01. Aphex Twin and 2 Unlimited. In a tracklist, a bare number can still count when the lines around it continue the sequence: see Bare track numbers.

A time at the start becomes timestamp, with the seconds worked out for you (R4.1; try it):

parse("[12:34] Noisia - Stigma").timestamp; // { raw: '12:34', seconds: 754 }
parse("1:02:03 Noisia - Stigma").timestamp; // { raw: '1:02:03', seconds: 3723 }

For whole tracklists with a time on every line, use parseTracklist (parse_tracklist in Python and Rust, ParseTracklist in Go, trackparse_parse_tracklist in C) instead. It reads more time formats and checks the order.

  • ParsedTrack in the reference for the types of junk, label, flags, year, position and timestamp.
  • Modes for how junk and file extensions pick the mode.
  • Formatting: junk is never written back, and the track number only when you ask.