Options
interface ParseOptions { mode?: "auto" | "clean" | "youtube" | "filename" | "tracklist"; knownArtists?: string[]; uploader?: string; splitAnd?: "auto" | "always" | "never"; keywords?: KeywordOptions;}parse( input, *, mode: ModeOption = "auto", # "auto" | "clean" | "youtube" | "filename" | "tracklist" known_artists: Sequence[str] = (), uploader: Optional[str] = None, split_and: str = "auto", # "auto" | "always" | "never" keywords: Optional[KeywordOptions] = None,)| Option (Python) | Default | |
|---|---|---|
mode |
"auto" |
Which mode to use. auto picks filename, youtube or clean from the string |
knownArtists (known_artists) |
[] |
Names that are never split, like Chase & Status or Earth, Wind & Fire. Matched case- and accent-insensitively |
uploader |
– | The YouTube channel. In youtube mode it becomes the artist when there's no separator. - Topic and VEVO are dropped |
splitAnd (split_and) |
"auto" |
auto splits on and only after a comma (A, B and C), so Simon and Garfunkel stays whole. always and never do what they say |
keywords |
– | Extra vocabulary, see below |
Options never cause an error. An unknown mode, a knownArtists that isn't a list or a keyword of the wrong
type is ignored and the default is used.
keywords
Section titled “keywords”keywords adds words to the built-in vocabulary. It can't take any away. In Python its keys are
snake_case too: version_heads, feat_markers.
interface KeywordOptions { versionHeads?: Record<string, VersionType>; // { rerub: "rework" } descriptors?: string[]; // extra style words, like the built-in "D'n'B" genres?: string[]; // extra genre names (junk kind 'genre') junk?: Record<string, JunkKind>; // { "live stream": "other" } featMarkers?: string[]; // extra feat markers}class KeywordOptions(TypedDict, total=False): version_heads: dict[str, VersionType] # {"rerub": "rework"} descriptors: list[str] # extra style words, like the built-in "D'n'B" genres: list[str] # extra genre names (junk kind 'genre') junk: dict[str, JunkKind] # {"live stream": "other"} feat_markers: list[str] # extra feat markersKeys are compared the same way as the built-in words: ASCII letters are lowercased and one trailing
. , ! ? : ; is ignored.
import { createParser } from "trackparse";
const parser = createParser({ knownArtists: ["Chase & Status", "Camo & Krooked"], keywords: { versionHeads: { rerub: "rework" } },});
const t = parser.parse("Chase & Status x Camo & Krooked - Track (Alix Perez Rerub)");t.artists.map((a) => a.name); // [ 'Chase & Status', 'Camo & Krooked' ]t.versions[0].type; // 'rework'from trackparse import create_parser
parser = create_parser( known_artists=["Chase & Status", "Camo & Krooked"], keywords={"version_heads": {"rerub": "rework"}},)
t = parser.parse("Chase & Status x Camo & Krooked - Track (Alix Perez Rerub)")[a.name for a in t.artists] # ['Chase & Status', 'Camo & Krooked']t.versions[0].type # 'rework'Tracklist options
Section titled “Tracklist options”parseTracklist and applyEdits (parse_tracklist, apply_edits) take mode (default
"tracklist"), knownArtists, splitAnd and keywords, plus two of their own:
| Option | Default | |
|---|---|---|
audioSeconds (audio_seconds) |
– | Length of the audio. Turns on the time-after-audio-end check |
markerWords (marker_words) |
[] |
Extra marker words. With ["drop"], 03:00 Drop is a marker, not a track |
See the Tracklist API.