Messy track names in.
Structured data out.
npm install trackparsePublished on npm, PyPI, crates.io and the Go module proxy; the C library is a tarball on GitHub Releases. The Rust API docs are on docs.rs, the Go API docs on pkg.go.dev, the C API in the C README.
Extract, don't delete
Section titled “Extract, don't delete”Most title parsers split on the dash and hand you two strings. Others "clean" the title and throw the featured artist and the remix away with the brackets.
trackparse keeps everything. What it recognizes goes into a labeled field, and what it doesn't stays in the title, word for word.
input 01. Wilkinson ft. Becky Hill & Tom Cane - Afterglow (Sub Focus VIP Remix) [Official Video]
| Split on the dash | trackparse | |
|---|---|---|
| Artist | Wilkinson ft. Becky Hill & Tom Cane | Wilkinson |
| Featured | lost | Becky Hill, Tom Cane |
| Title | Afterglow (Sub Focus VIP Remix) [Official Video] | Afterglow |
| Version | lost | remix + vip, by Sub Focus |
| Noise | lost | |
| Position | lost | 1 |
What you get
Section titled “What you get”Credits with roles
Primary artists, features, producers and remixers, each with the joiner it was written with.
Skrillex & Diplo x Justin Bieberis three artists; withknownArtists,Chase & Statusstays one.27 version types
Remix, VIP, bootleg, extended, radio edit, live, remaster, sped up, slowed and the rest, each with its remixers, modifiers and year.
Noise, labeled
[Official Video],[HD],- YouTubeand[NCS Release]leave the title but land injunkwith a kind, instead of disappearing.Whole tracklists
Paste the tracklist of a mix: every line is parsed, times are checked, and an out-of-order time often comes with the fix. Edits rewrite only the lines you name.
One spec, five languages
The npm package, the PyPI package, the Rust crate, the Go module and the C library pass the same 13,565 fixtures and return byte-identical JSON on every fixture input. The ports page has the one known Unicode difference.
Small and total
The JavaScript package is about 19 kB gzipped. It, the Python package and the Go module have no dependencies, and the C library needs only the C standard library,
libmand threads; the Rust crate has one,unicode-normalization. The scanners are written by hand and no regex backtracks, so a 10,000-code-point input takes at most tens of milliseconds in JavaScript, Rust, Go and C, and well under a second in Python. No string makes it throw or panic, and bad options fall back to defaults.
- shared fixtures, 100% passing in all five ports
- 13,565
- runtime dependencies in JavaScript, Python, Go and C, one in Rust
- 0
- version types, remix to nightcore
- 27
- differences between JS, Python, Rust, Go and C output on the fixtures
- 0
Same call, same answer
Section titled “Same call, same answer”import { parse } from "trackparse";
const track = parse("Noisia feat. Foreign Beggars - Shellshock");track.artists.map((a) => `${a.name} (${a.role})`);// [ 'Noisia (primary)', 'Foreign Beggars (featured)' ]
parse("Queen - Bohemian Rhapsody (Live at Wembley 1986)").versions[0];// { type: 'live', descriptor: 'at Wembley', year: 1986, … }from trackparse import parse
track = parse("Noisia feat. Foreign Beggars - Shellshock")[f"{a.name} ({a.role})" for a in track.artists]# ['Noisia (primary)', 'Foreign Beggars (featured)']
parse("Queen - Bohemian Rhapsody (Live at Wembley 1986)").versions[0]# Version(type='live', ..., descriptor='at Wembley', year=1986, ...)use trackparse::parse;
let track = parse("Noisia feat. Foreign Beggars - Shellshock");track.artists.iter().map(|a| format!("{} ({})", a.name, a.role)).collect::<Vec<_>>();// ["Noisia (primary)", "Foreign Beggars (featured)"]
parse("Queen - Bohemian Rhapsody (Live at Wembley 1986)").versions.first();// Some(Version { version_type: Live, descriptor: Some("at Wembley"), year: Some(1986), .. })import ( "fmt"
"github.com/4matic/trackparse/go")
track := trackparse.Parse("Noisia feat. Foreign Beggars - Shellshock")for _, a := range track.Artists { fmt.Printf("%s (%s)\n", a.Name, a.Role)}// Noisia (primary)// Foreign Beggars (featured)
v := trackparse.Parse("Queen - Bohemian Rhapsody (Live at Wembley 1986)").Versions[0]fmt.Println(v.Type, *v.Descriptor, *v.Year)// live at Wembley 1986#include <stdio.h>#include <trackparse.h>
trackparse_track *track = trackparse_parse("Noisia feat. Foreign Beggars - Shellshock", TRACKPARSE_NUL_TERMINATED);for (size_t i = 0; i < track->artists_count; i++) { const trackparse_artist *a = &track->artists[i]; printf("%s (%s)\n", a->name.ptr, trackparse_role_name(a->role));}// Noisia (primary)// Foreign Beggars (featured)trackparse_track_free(track);
track = trackparse_parse("Queen - Bohemian Rhapsody (Live at Wembley 1986)", TRACKPARSE_NUL_TERMINATED);const trackparse_version *v = &track->versions[0];printf("%s %s %d\n", v->type_name.ptr, v->descriptor->ptr, *v->year);// live at Wembley 1986trackparse_track_free(track);