GeezerVison is showing 4matic.github.io — Warnings
Warnings
trackparse never fails, but it does tell you when it had to guess. Warnings are how. There are
three kinds: on a single track, on a tracklist, and on an edit.
In JavaScript and Python a warning code is a string. In Rust it is an enum variant, and as_str()
or Display gives the same string. In Go it is a constant of a string type, whose value is the
string. In C it is an enum value, and its _name() function gives the string. The tables below
give the string and what it means, and each section says once how the Rust, Go and C names are
made from it. The names follow that rule for every code, with no exceptions. Each meaning links
the rule of the spec that raises it.
ParsedTrack.warnings is a list of codes: an array of strings in JavaScript, a tuple of strings in
Python, a Vec<Warning> in Rust (Warning), a []Warning in Go
(Warning), a const trackparse_warning * with warnings_count in C
(trackparse.h). An empty list means every decision was unambiguous. Click an example
to open it in the playground.
Warning
Means
Example
noSeparator
No artist/title separator was found. The whole string is the title (R6.8)
In the other languages the name is the code with its first letter capitalized, after a prefix:
Warning:: in Rust, Warning in Go (trackparse.WarningNoSeparator). In C the code is written
in upper case with an underscore between its words, after TRACKPARSE_WARNING_
(TRACKPARSE_WARNING_NO_SEPARATOR).
What to do with them depends on your data. For a music library, a track with any warning is a good
candidate for a human to look at. For scrobbling, most of them are fine to accept.
Modes explains which mode takes which guess. The example below is
in the playground too.
Warning::UnspacedDashSplit|Warning::AsymmetricDashSplit=>println!("check the dash"),
other=>println!("{other}"),// Display prints the code, such as bySplit
}
}
// check the dash
Warning is #[non_exhaustive], so a match needs a catch-all arm: a later spec version can add
a warning. Warning::ALL lists the variants, and Warning::from_name("bySplit") reads a code back.
import(
"fmt"
"slices"
"strings"
"github.com/4matic/trackparse/go"
)
track:=trackparse.ParseWith("Blink-182-All The Small Things",trackparse.ParseOptions{Mode:trackparse.ModeYouTube})
fmt.Println(warning)// the code itself, such as bySplit
}
}
// check the dash
Warning is a string type, so a warning prints as its code and compares with the constants
(trackparse.WarningBySplit). Keep a default case: a later spec version can add a warning.
trackparse.AllWarnings() lists the codes.
Tracklist.warnings holds objects: { code, line, severity, suggestion }
(TracklistWarning). They are sorted by line.
In Rust the code is a WarningCode and the severity is
Severity::Info or Severity::Warning. In Go they are a
WarningCode and SeverityInfo or SeverityWarning,
and Suggestion is a pointer. In C they are a trackparse_tracklist_warning_code and
TRACKPARSE_SEVERITY_INFO or TRACKPARSE_SEVERITY_WARNING, and suggestion is a pointer. All of them are
R13.7 in the spec.
The names drop the dashes and capitalize each word after a prefix: WarningCode:: in Rust
(WarningCode::TimeOutOfOrder), WarningCode in Go (trackparse.WarningCodeTimeOutOfOrder). In
C the dashes become underscores, in upper case, after TRACKPARSE_TL_
(TRACKPARSE_TL_TIME_OUT_OF_ORDER).
Code
Severity
When
time-missing
warning
A track line has no time while other lines do (not raised on a w/ line, which plays at the previous track's time)
time-out-of-order
warning
Earlier than the previous timed line. May carry a suggestion
time-duplicate
warning
Same time as the previous timed line
no-start-at-zero
info
The first time isn't 0:00
time-after-audio-end
warning
Later than audioSeconds (audio_seconds, AudioSeconds)
invalid-time
warning
Looks like a time but isn't one (1:75, 0:61:00). The line keeps it in rest
position-gap
warning
A track number isn't the previous one plus 1
position-duplicate
warning
Same track number as the previous one
line-unparsed
warning
A track line with no artist/title separator, or nothing after the time
Warnings of each line's own track stay on entries[i].track.warnings. They are the
track warnings above and are not repeated in the list's warnings.
The list in this example opens in the playground, where both warnings show.
A suggestion is { line, raw, seconds }: the one time, one or two digits away from what was
written, that puts the list back in order. It's written in the same style as the original.
The search runs in two steps. First it tries the flagged line itself. If no time fits there, it
tries the previous timed line, since sometimes that's where the typo is:
01:22:21 followed by 01:03:55 suggests changing the first line to 01:02:21. If more than one
candidate fits, or none does, suggestion is null (None in Python and Rust, nil in Go, NULL in C). A wrong
suggestion would be worse than none.
To apply one, pass its line and seconds to a set-time edit. See
Editing tracklists. In the
playground,
a warning with a suggestion has a button that applies it.
applyEdits (apply_edits in Python and Rust, ApplyEdits in Go, trackparse_apply_edits in C) returns { code, edit, line }
objects (EditWarning in Rust,
EditWarning in Go, trackparse_edit_warning in C). edit is the index in your list of edits, and line is
null (None, nil in Go, NULL in C) when the edit names no line. The rules are
R13.9.
The names follow the tracklist codes with another prefix: EditWarningCode:: in Rust
(EditWarningCode::EditInvalid), EditWarningCode in Go
(trackparse.EditWarningCodeEditInvalid) and TRACKPARSE_EDIT_WARNING_ in C
(TRACKPARSE_EDIT_WARNING_EDIT_INVALID), of the enum trackparse_edit_warning_code.
Code
When
style-upgraded
a time without hours passed one hour and gained them (R13.9.2)
time-clamped
a time would go below zero and was set to zero (R13.9.3)
edit-invalid
the edit could not apply and changed nothing (R13.9.6)
You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.