Artists and credits
Every credit in the output is an Artist:
{ name: string; role: "primary" | "featured" | "producer" | "remixer"; joiner: string | null; source: "artist" | "title" | "version" }Artist(name: str, role: ArtistRole, joiner: Optional[str], source: ArtistSource)# role: "primary" | "featured" | "producer" | "remixer"; source: "artist" | "title" | "version"pub struct Artist { pub name: String, pub role: ArtistRole, // Primary | Featured | Remixer | Producer pub joiner: Option<String>, pub source: ArtistSource, // Artist | Title | Version}type Artist struct { Name string Role Role // RolePrimary | RoleFeatured | RoleRemixer | RoleProducer Joiner *string // nil for the first name of a list Source Source // SourceArtist | SourceTitle | SourceVersion}typedef struct trackparse_artist { trackparse_str name; trackparse_role role; /* TRACKPARSE_ROLE_PRIMARY, _FEATURED, _REMIXER, _PRODUCER */ const trackparse_str *joiner; /* NULL for the first name of a list */ trackparse_source source; /* TRACKPARSE_SOURCE_ARTIST, _TITLE, _VERSION */} trackparse_artist;role says what the person did. joiner is the text that introduced the name, exactly as written
("&", ",", "ft.", "prod. by"), and null for the first name of a list (None in Python and
Rust, nil in Go, where Joiner is a *string, NULL in C, where joiner is a
const trackparse_str *). source says where the credit was found: left of the dash (artist), right of it (title),
or inside a version (version). In Rust, role and source are the enums
ArtistRole and ArtistSource;
as_str() and Display give the lowercase names used here. In Go they are the string types
Role and Source, with constants such as trackparse.RolePrimary
and trackparse.SourceTitle whose values are those names. In C they are the enums
trackparse_role and trackparse_source (TRACKPARSE_ROLE_PRIMARY, TRACKPARSE_SOURCE_TITLE),
and trackparse_role_name() and trackparse_source_name() give the names; the structs are in
trackparse.h. The full field list is under
Artist in the reference.
Remixers live inside versions, not in artists. Use allArtists(track)
(all_artists in Python and Rust, AllArtists in Go, trackparse_all_artists in C) when you want everyone in one list.
Joiners
Section titled “Joiners”&, x, vs., ,, ;, +, / and and separate names, and so do b2b, meets, pres. and
the others in joiners.json.
They're joiners, not roles: every name they produce is still primary.
import { parse, parseArtists } from "trackparse";
parse("Skrillex & Diplo x Justin Bieber - Where Are Ü Now").artists.map((a) => [a.name, a.joiner, a.role]);// [ [ 'Skrillex', null, 'primary' ], [ 'Diplo', '&', 'primary' ], [ 'Justin Bieber', 'x', 'primary' ] ]
parse("Kanye West vs. Daft Punk - Stronger").artists.map((a) => a.name);// [ 'Kanye West', 'Daft Punk' ]from trackparse import parse, parse_artists
[(a.name, a.joiner, a.role) for a in parse("Skrillex & Diplo x Justin Bieber - Where Are Ü Now").artists]# [('Skrillex', None, 'primary'), ('Diplo', '&', 'primary'), ('Justin Bieber', 'x', 'primary')]
[a.name for a in parse("Kanye West vs. Daft Punk - Stronger").artists]# ['Kanye West', 'Daft Punk']use trackparse::{parse, parse_artists, parse_artists_with, parse_with, ParseOptions, SplitAnd};
parse("Skrillex & Diplo x Justin Bieber - Where Are Ü Now") .artists.iter().map(|a| (&a.name, &a.joiner, a.role)).collect::<Vec<_>>();// [("Skrillex", None, Primary), ("Diplo", Some("&"), Primary), ("Justin Bieber", Some("x"), Primary)]
parse("Kanye West vs. Daft Punk - Stronger").artists.iter().map(|a| &a.name).collect::<Vec<_>>();// ["Kanye West", "Daft Punk"]import ( "fmt"
"github.com/4matic/trackparse/go")
names := func(artists []trackparse.Artist) []string { out := []string{} for _, a := range artists { out = append(out, a.Name) } return out}
for _, a := range trackparse.Parse("Skrillex & Diplo x Justin Bieber - Where Are Ü Now").Artists { if a.Joiner == nil { fmt.Println(a.Name, "(joiner nil),", a.Role) } else { fmt.Printf("%s (joiner %q), %s\n", a.Name, *a.Joiner, a.Role) }}// Skrillex (joiner nil), primary// Diplo (joiner "&"), primary// Justin Bieber (joiner "x"), primary
fmt.Printf("%q\n", names(trackparse.Parse("Kanye West vs. Daft Punk - Stronger").Artists))// ["Kanye West" "Daft Punk"]#include <trackparse.h>
trackparse_track *t = trackparse_parse("Skrillex & Diplo x Justin Bieber - Where Are Ü Now", TRACKPARSE_NUL_TERMINATED);for (size_t i = 0; i < t->artists_count; i++) { const trackparse_artist *a = &t->artists[i]; printf("%s (joiner %s), %s\n", a->name.ptr, a->joiner ? a->joiner->ptr : "NULL", trackparse_role_name(a->role));}// Skrillex (joiner NULL), primary// Diplo (joiner &), primary// Justin Bieber (joiner x), primarytrackparse_track_free(t);
t = trackparse_parse("Kanye West vs. Daft Punk - Stronger", TRACKPARSE_NUL_TERMINATED);for (size_t i = 0; i < t->artists_count; i++) printf("%s\n", t->artists[i].name.ptr);// Kanye West// Daft Punktrackparse_track_free(t);Some things look like joiners and aren't:
- An unspaced
/,&or+never splits.AC/DCandDrum&Bassstay whole. xonly splits in lowercase, soMalcolm Xkeeps its X.& Sons,& Co.,& His Orchestraand a few others never start a new artist. The list is inno-split-before.json.- A comma between two digits (
1,000) is part of the name.
The rules for the artist side are R7 in the spec, and the splitting itself is R7.3. Open the first example in the playground to see every joiner.
and is special
Section titled “and is special”and is common inside band names, so by default it only splits after a comma or semicolon has already
split the same list:
parse("Simon and Garfunkel - The Boxer").artists.map((a) => a.name);// [ 'Simon and Garfunkel' ]
parseArtists("Crosby, Stills, Nash and Young").map((a) => a.name);// [ 'Crosby', 'Stills', 'Nash', 'Young' ][a.name for a in parse("Simon and Garfunkel - The Boxer").artists]# ['Simon and Garfunkel']
[a.name for a in parse_artists("Crosby, Stills, Nash and Young")]# ['Crosby', 'Stills', 'Nash', 'Young']parse("Simon and Garfunkel - The Boxer").artists.iter().map(|a| &a.name).collect::<Vec<_>>();// ["Simon and Garfunkel"]
parse_artists("Crosby, Stills, Nash and Young").iter().map(|a| &a.name).collect::<Vec<_>>();// ["Crosby", "Stills", "Nash", "Young"]fmt.Printf("%q\n", names(trackparse.Parse("Simon and Garfunkel - The Boxer").Artists))// ["Simon and Garfunkel"]
fmt.Printf("%q\n", names(trackparse.ParseArtists("Crosby, Stills, Nash and Young")))// ["Crosby" "Stills" "Nash" "Young"]t = trackparse_parse("Simon and Garfunkel - The Boxer", TRACKPARSE_NUL_TERMINATED);for (size_t i = 0; i < t->artists_count; i++) printf("%s\n", t->artists[i].name.ptr);// Simon and Garfunkeltrackparse_track_free(t);
trackparse_artists *list = trackparse_parse_artists("Crosby, Stills, Nash and Young", TRACKPARSE_NUL_TERMINATED);for (size_t i = 0; i < list->count; i++) printf("%s\n", list->items[i].name.ptr);// Crosby// Stills// Nash// Youngtrackparse_artists_free(list);Set splitAnd (split_and in Python and Rust,
SplitAnd in Go, trackparse_parse_options_set_split_and in C) to "always" or "never" to change that
(try it):
parse("Simon and Garfunkel - The Boxer", { splitAnd: "always" }).artists.map((a) => a.name);// [ 'Simon', 'Garfunkel' ]
parseArtists("Crosby, Stills, Nash and Young", { splitAnd: "never" }).map((a) => a.name);// [ 'Crosby', 'Stills', 'Nash and Young' ][a.name for a in parse("Simon and Garfunkel - The Boxer", split_and="always").artists]# ['Simon', 'Garfunkel']
[a.name for a in parse_artists("Crosby, Stills, Nash and Young", split_and="never")]# ['Crosby', 'Stills', 'Nash and Young']let always = ParseOptions::new().split_and(SplitAnd::Always);parse_with("Simon and Garfunkel - The Boxer", &always).artists.iter().map(|a| &a.name).collect::<Vec<_>>();// ["Simon", "Garfunkel"]
let never = ParseOptions::new().split_and(SplitAnd::Never);parse_artists_with("Crosby, Stills, Nash and Young", &never).iter().map(|a| &a.name).collect::<Vec<_>>();// ["Crosby", "Stills", "Nash and Young"]always := trackparse.ParseOptions{SplitAnd: trackparse.SplitAndAlways}fmt.Printf("%q\n", names(trackparse.ParseWith("Simon and Garfunkel - The Boxer", always).Artists))// ["Simon" "Garfunkel"]
never := trackparse.ParseOptions{SplitAnd: trackparse.SplitAndNever}fmt.Printf("%q\n", names(trackparse.ParseArtistsWith("Crosby, Stills, Nash and Young", never)))// ["Crosby" "Stills" "Nash and Young"]trackparse_parse_options *always = trackparse_parse_options_new();trackparse_parse_options_set_split_and(always, TRACKPARSE_SPLIT_AND_ALWAYS);t = trackparse_parse_with("Simon and Garfunkel - The Boxer", TRACKPARSE_NUL_TERMINATED, always);for (size_t i = 0; i < t->artists_count; i++) printf("%s\n", t->artists[i].name.ptr);// Simon// Garfunkeltrackparse_track_free(t);trackparse_parse_options_free(always);
trackparse_parse_options *never = trackparse_parse_options_new();trackparse_parse_options_set_split_and(never, TRACKPARSE_SPLIT_AND_NEVER);list = trackparse_parse_artists_with("Crosby, Stills, Nash and Young", TRACKPARSE_NUL_TERMINATED, never);for (size_t i = 0; i < list->count; i++) printf("%s\n", list->items[i].name.ptr);// Crosby// Stills// Nash and Youngtrackparse_artists_free(list);trackparse_parse_options_free(never);Features
Section titled “Features”feat., ft. and featuring work on either side of the dash and in brackets. with and w/
only count at the start of a bracket, since "with" turns up in plenty of titles. All of these give
the second name the role featured. In a bracket the rule is
R5.2, left of the dash
R7.2 and right of it
R8.3:
parse("Noisia feat. Foreign Beggars - Shellshock").artists[1];// { name: 'Foreign Beggars', role: 'featured', joiner: 'feat.', source: 'artist' }parse("Noisia - Shellshock ft. Foreign Beggars").artists[1];// { name: 'Foreign Beggars', role: 'featured', joiner: 'ft.', source: 'title' }parse("Silk City - Electricity (with Dua Lipa)").artists[1];// { name: 'Dua Lipa', role: 'featured', joiner: 'with', source: 'title' }parse("Noisia feat. Foreign Beggars - Shellshock").artists[1]# Artist(name='Foreign Beggars', role='featured', joiner='feat.', source='artist')parse("Noisia - Shellshock ft. Foreign Beggars").artists[1]# Artist(name='Foreign Beggars', role='featured', joiner='ft.', source='title')parse("Silk City - Electricity (with Dua Lipa)").artists[1]# Artist(name='Dua Lipa', role='featured', joiner='with', source='title')&parse("Noisia feat. Foreign Beggars - Shellshock").artists[1];// Artist { name: "Foreign Beggars", role: Featured, joiner: Some("feat."), source: Artist }&parse("Noisia - Shellshock ft. Foreign Beggars").artists[1];// Artist { name: "Foreign Beggars", role: Featured, joiner: Some("ft."), source: Title }&parse("Silk City - Electricity (with Dua Lipa)").artists[1];// Artist { name: "Dua Lipa", role: Featured, joiner: Some("with"), source: Title }for _, s := range []string{ "Noisia feat. Foreign Beggars - Shellshock", "Noisia - Shellshock ft. Foreign Beggars", "Silk City - Electricity (with Dua Lipa)",} { a := trackparse.Parse(s).Artists[1] fmt.Printf("%q %s %q %s\n", a.Name, a.Role, *a.Joiner, a.Source)}// "Foreign Beggars" featured "feat." artist// "Foreign Beggars" featured "ft." title// "Dua Lipa" featured "with" titleconst char *inputs[] = { "Noisia feat. Foreign Beggars - Shellshock", "Noisia - Shellshock ft. Foreign Beggars", "Silk City - Electricity (with Dua Lipa)",};for (size_t i = 0; i < 3; i++) { t = trackparse_parse(inputs[i], TRACKPARSE_NUL_TERMINATED); const trackparse_artist *a = &t->artists[1]; printf("%s | %s | %s | %s\n", a->name.ptr, trackparse_role_name(a->role), a->joiner->ptr, trackparse_source_name(a->source)); trackparse_track_free(t);}// Foreign Beggars | featured | feat. | artist// Foreign Beggars | featured | ft. | title// Dua Lipa | featured | with | titleIf the same person is credited twice, they appear once:
parse("Noisia feat. Foreign Beggars - Shellshock (feat. Foreign Beggars)").artists.map((a) => a.name);// [ 'Noisia', 'Foreign Beggars' ][a.name for a in parse("Noisia feat. Foreign Beggars - Shellshock (feat. Foreign Beggars)").artists]# ['Noisia', 'Foreign Beggars']parse("Noisia feat. Foreign Beggars - Shellshock (feat. Foreign Beggars)") .artists.iter().map(|a| &a.name).collect::<Vec<_>>();// ["Noisia", "Foreign Beggars"]fmt.Printf("%q\n", names(trackparse.Parse("Noisia feat. Foreign Beggars - Shellshock (feat. Foreign Beggars)").Artists))// ["Noisia" "Foreign Beggars"]t = trackparse_parse("Noisia feat. Foreign Beggars - Shellshock (feat. Foreign Beggars)", TRACKPARSE_NUL_TERMINATED);for (size_t i = 0; i < t->artists_count; i++) printf("%s\n", t->artists[i].name.ptr);// Noisia// Foreign Beggarstrackparse_track_free(t);Names are compared with full Unicode lowercasing and accents removed, so Sigur Rós and
SIGUR ROS count as the same artist
(R9.2). Try the
example
in the playground.
Producers
Section titled “Producers”prod., prod. by and produced by credit a producer, in brackets
(R5.3) or after the title
(R8.3). The producer gets the role producer and
leaves the title:
const t = parse("Future - Mask Off (prod. by Metro Boomin)");t.artists[1]; // { name: 'Metro Boomin', role: 'producer', joiner: 'prod. by', source: 'title' }t.title; // 'Mask Off't = parse("Future - Mask Off (prod. by Metro Boomin)")t.artists[1] # Artist(name='Metro Boomin', role='producer', joiner='prod. by', source='title')t.title # 'Mask Off'let t = parse("Future - Mask Off (prod. by Metro Boomin)");&t.artists[1]; // Artist { name: "Metro Boomin", role: Producer, joiner: Some("prod. by"), source: Title }&t.title; // "Mask Off"t := trackparse.Parse("Future - Mask Off (prod. by Metro Boomin)")a := t.Artists[1]fmt.Printf("%q %s %q %s\n", a.Name, a.Role, *a.Joiner, a.Source) // "Metro Boomin" producer "prod. by" titlefmt.Printf("%q\n", t.Title) // "Mask Off"t = trackparse_parse("Future - Mask Off (prod. by Metro Boomin)", TRACKPARSE_NUL_TERMINATED);const trackparse_artist *a = &t->artists[1];printf("%s | %s | %s | %s\n", a->name.ptr, trackparse_role_name(a->role), a->joiner->ptr, trackparse_source_name(a->source)); // Metro Boomin | producer | prod. by | titleprintf("%s\n", t->title.ptr); // Mask Offtrackparse_track_free(t);knownArtists
Section titled “knownArtists”(Python and Rust: known_artists; Go: KnownArtists; C: trackparse_parse_options_add_known_artist)
trackparse has no artist database, on purpose. A built-in list would be wrong for half its users and out of date within a month. You tell it the names you care about:
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' ][a.name for a in parse("Chase & Status - Baddadan").artists]# ['Chase', 'Status']
[a.name for a in parse("Chase & Status - Baddadan", known_artists=["Chase & Status"]).artists]# ['Chase & Status']parse("Chase & Status - Baddadan").artists.iter().map(|a| &a.name).collect::<Vec<_>>();// ["Chase", "Status"]
let options = ParseOptions::new().known_artists(["Chase & Status"]);parse_with("Chase & Status - Baddadan", &options).artists.iter().map(|a| &a.name).collect::<Vec<_>>();// ["Chase & Status"]fmt.Printf("%q\n", names(trackparse.Parse("Chase & Status - Baddadan").Artists))// ["Chase" "Status"]
options := trackparse.ParseOptions{KnownArtists: []string{"Chase & Status"}}fmt.Printf("%q\n", names(trackparse.ParseWith("Chase & Status - Baddadan", options).Artists))// ["Chase & Status"]t = trackparse_parse("Chase & Status - Baddadan", TRACKPARSE_NUL_TERMINATED);for (size_t i = 0; i < t->artists_count; i++) printf("%s\n", t->artists[i].name.ptr);// Chase// Statustrackparse_track_free(t);
trackparse_parse_options *options = trackparse_parse_options_new();trackparse_parse_options_add_known_artist(options, "Chase & Status", TRACKPARSE_NUL_TERMINATED);t = trackparse_parse_with("Chase & Status - Baddadan", TRACKPARSE_NUL_TERMINATED, options);for (size_t i = 0; i < t->artists_count; i++) printf("%s\n", t->artists[i].name.ptr);// Chase & Statustrackparse_track_free(t);trackparse_parse_options_free(options);A known name is matched case- and accent-insensitively wherever a name starts in a credit list. It also
protects names that begin with digits from being read as a track number (3 Doors Down). If you
parse a lot of strings with the same names, put them in
createParser (create_parser in Python,
Parser::new in Rust, NewParser in Go, trackparse_parser_new in C). You can try it in the
playground.
The option is listed under Options, and the
matching rule is R7.3 (a).
Unknown artists
Section titled “Unknown artists”ID (and Unknown, Untitled, ?, ???) means the track hasn't been announced yet. It doesn't become a name.
The track gets flags.unknownArtist: true (flags.unknown_artist in Python and Rust,
Flags.UnknownArtist in Go, flags.unknown_artist in C) instead, and the same goes for titles
(R7.5, R8.6;
open it in the playground):
const t = parse("ID - ID (ID Remix)");t.artists; // []t.flags.unknownArtist; // truet.flags.unknownTitle; // truet.versions[0].unknownArtist; // truet = parse("ID - ID (ID Remix)")t.artists # ()t.flags.unknown_artist # Truet.flags.unknown_title # Truet.versions[0].unknown_artist # Truelet t = parse("ID - ID (ID Remix)");&t.artists; // []t.flags.unknown_artist; // truet.flags.unknown_title; // truet.versions[0].unknown_artist; // truet = trackparse.Parse("ID - ID (ID Remix)")fmt.Println(len(t.Artists)) // 0fmt.Println(t.Flags.UnknownArtist) // truefmt.Println(t.Flags.UnknownTitle) // truefmt.Println(t.Versions[0].UnknownArtist) // truet = trackparse_parse("ID - ID (ID Remix)", TRACKPARSE_NUL_TERMINATED);printf("%zu\n", t->artists_count); // 0printf("%s\n", t->flags.unknown_artist ? "true" : "false"); // trueprintf("%s\n", t->flags.unknown_title ? "true" : "false"); // trueprintf("%s\n", t->versions[0].unknown_artist ? "true" : "false"); // truetrackparse_track_free(t);See also
Section titled “See also”Artistin the reference for the field list.parseArtistssplits an artist string that has no title, andallArtistslists the remixers too.- Options covers
knownArtists,splitAndand extra feat markers inkeywords. - Versions and remixes is where the remixers go.