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' } ]from trackparse import parse
t = parse("Daft Punk - One More Time (Official Music Video) [HD]")t.title # 'One More Time't.junk # (Junk(raw='Official Music Video', kind='video'), Junk(raw='HD', kind='quality'))use trackparse::parse;
let t = parse("Daft Punk - One More Time (Official Music Video) [HD]");&t.title; // "One More Time"&t.junk; // [Junk { raw: "Official Music Video", kind: Video }, Junk { raw: "HD", kind: Quality }]import ( "fmt"
"github.com/4matic/trackparse/go")
t := trackparse.Parse("Daft Punk - One More Time (Official Music Video) [HD]")fmt.Printf("%q\n", t.Title) // "One More Time"fmt.Printf("%+v\n", t.Junk) // [{Raw:Official Music Video Kind:video} {Raw:HD Kind:quality}]#include <trackparse.h>
trackparse_track *t = trackparse_parse("Daft Punk - One More Time (Official Music Video) [HD]", TRACKPARSE_NUL_TERMINATED);printf("%s\n", t->title.ptr); // One More Timefor (size_t i = 0; i < t->junk_count; i++) { printf("%s: %s\n", t->junk[i].kind_name.ptr, t->junk[i].raw.ptr);}// video: Official Music Video// quality: HDtrackparse_track_free(t);| 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' } ]parse("Porter Robinson - Shelter - YouTube").junk # (Junk(raw='YouTube', kind='platform'),)parse("Elektronomia - Sky High [NCS Release]").junk # (Junk(raw='NCS Release', kind='label'),)parse("Porter Robinson - Shelter - YouTube").junk; // [Junk { raw: "YouTube", kind: Platform }]parse("Elektronomia - Sky High [NCS Release]").junk; // [Junk { raw: "NCS Release", kind: Label }]fmt.Printf("%+v\n", trackparse.Parse("Porter Robinson - Shelter - YouTube").Junk) // [{Raw:YouTube Kind:platform}]fmt.Printf("%+v\n", trackparse.Parse("Elektronomia - Sky High [NCS Release]").Junk) // [{Raw:NCS Release Kind:label}]t = trackparse_parse("Porter Robinson - Shelter - YouTube", TRACKPARSE_NUL_TERMINATED);printf("%s: %s\n", t->junk[0].kind_name.ptr, t->junk[0].raw.ptr); // platform: YouTubetrackparse_track_free(t);t = trackparse_parse("Elektronomia - Sky High [NCS Release]", TRACKPARSE_NUL_TERMINATED);printf("%s: %s\n", t->junk[0].kind_name.ptr, t->junk[0].raw.ptr); // label: NCS Releasetrackparse_track_free(t);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.
Labels after a bullet
Section titled “Labels after a bullet”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' } ]l = parse("Noisia - concussion • VISION • VISION RADIO RELOAD")l.title # 'concussion'l.label # 'VISION'l.junk # (Junk(raw='VISION RADIO RELOAD', kind='note'),)let l = parse("Noisia - concussion • VISION • VISION RADIO RELOAD");&l.title; // "concussion"&l.label; // Some("VISION")&l.junk; // [Junk { raw: "VISION RADIO RELOAD", kind: Note }]l := trackparse.Parse("Noisia - concussion • VISION • VISION RADIO RELOAD")fmt.Printf("%q\n", l.Title) // "concussion"fmt.Printf("%q\n", *l.Label) // "VISION"fmt.Printf("%+v\n", l.Junk) // [{Raw:VISION RADIO RELOAD Kind:note}]trackparse_track *l = trackparse_parse("Noisia - concussion • VISION • VISION RADIO RELOAD", TRACKPARSE_NUL_TERMINATED);printf("%s\n", l->title.ptr); // concussionif (l->label) printf("%s\n", l->label->ptr); // VISIONprintf("%s: %s\n", l->junk[0].kind_name.ptr, l->junk[0].raw.ptr); // note: VISION RADIO RELOADtrackparse_track_free(l);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 }parse("Eminem - Without Me (Explicit)").flags# Flags(explicit=True, clean=False, unknown_artist=False, unknown_title=False)parse("Eminem - Without Me (Explicit)").flags;// Flags { explicit: true, clean: false, unknown_artist: false, unknown_title: false }fmt.Printf("%+v\n", trackparse.Parse("Eminem - Without Me (Explicit)").Flags)// {Explicit:true Clean:false UnknownArtist:false UnknownTitle:false}t = trackparse_parse("Eminem - Without Me (Explicit)", TRACKPARSE_NUL_TERMINATED);printf("explicit %d, clean %d, unknown_artist %d, unknown_title %d\n", t->flags.explicit_, t->flags.clean, t->flags.unknown_artist, t->flags.unknown_title);// explicit 1, clean 0, unknown_artist 0, unknown_title 0trackparse_track_free(t);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; // 2015t = parse("Noisia - Stigma (2015)")t.title # 'Stigma't.year # 2015let t = parse("Noisia - Stigma (2015)");&t.title; // "Stigma"t.year; // Some(2015)t = trackparse.Parse("Noisia - Stigma (2015)")fmt.Printf("%q\n", t.Title) // "Stigma"fmt.Println(*t.Year) // 2015t = trackparse_parse("Noisia - Stigma (2015)", TRACKPARSE_NUL_TERMINATED);printf("%s\n", t->title.ptr); // Stigmaif (t->year) printf("%d\n", *t->year); // 2015trackparse_track_free(t);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.
Track numbers
Section titled “Track numbers”parse("01. Aphex Twin - Xtal").position; // { raw: '01', number: 1 }parse("2 Unlimited - No Limit").position; // nullparse("01. Aphex Twin - Xtal").position # Position(raw='01', number=1)parse("2 Unlimited - No Limit").position # Noneparse("01. Aphex Twin - Xtal").position; // Some(Position { raw: "01", number: 1 })parse("2 Unlimited - No Limit").position; // Nonefmt.Printf("%+v\n", *trackparse.Parse("01. Aphex Twin - Xtal").Position) // {Raw:01 Number:1}fmt.Println(trackparse.Parse("2 Unlimited - No Limit").Position == nil) // truet = trackparse_parse("01. Aphex Twin - Xtal", TRACKPARSE_NUL_TERMINATED);printf("%s %d\n", t->position->raw.ptr, t->position->number); // 01 1trackparse_track_free(t);t = trackparse_parse("2 Unlimited - No Limit", TRACKPARSE_NUL_TERMINATED);printf("%s\n", t->position == NULL ? "NULL" : "set"); // NULLtrackparse_track_free(t);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-Trackand3 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.
Cue times
Section titled “Cue times”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 }parse("[12:34] Noisia - Stigma").timestamp # Timestamp(raw='12:34', seconds=754)parse("1:02:03 Noisia - Stigma").timestamp # Timestamp(raw='1:02:03', seconds=3723)parse("[12:34] Noisia - Stigma").timestamp; // Some(Timestamp { raw: "12:34", seconds: 754 })parse("1:02:03 Noisia - Stigma").timestamp; // Some(Timestamp { raw: "1:02:03", seconds: 3723 })fmt.Printf("%+v\n", *trackparse.Parse("[12:34] Noisia - Stigma").Timestamp) // {Raw:12:34 Seconds:754}fmt.Printf("%+v\n", *trackparse.Parse("1:02:03 Noisia - Stigma").Timestamp) // {Raw:1:02:03 Seconds:3723}t = trackparse_parse("[12:34] Noisia - Stigma", TRACKPARSE_NUL_TERMINATED);printf("%s %d\n", t->timestamp->raw.ptr, t->timestamp->seconds); // 12:34 754trackparse_track_free(t);t = trackparse_parse("1:02:03 Noisia - Stigma", TRACKPARSE_NUL_TERMINATED);printf("%s %d\n", t->timestamp->raw.ptr, t->timestamp->seconds); // 1:02:03 3723trackparse_track_free(t);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.
See also
Section titled “See also”ParsedTrackin the reference for the types ofjunk,label,flags,year,positionandtimestamp.- Modes for how junk and file extensions pick the mode.
- Formatting: junk is never written back, and the track number only when you ask.