nilaoda/N_m3u8DL-RE · error · ArgumentException
时间格式无效
Error message
时间格式无效
What it means
OtherUtil.ParseSeconds is a validation helper that parses CLI time-span strings like '1h3m20s' into total seconds using a regex. It throws this ArgumentException when the input string does not match the expected <number><h|m|s> unit pattern at all — i.e. the user passed a malformed value to an option that expects a duration (e.g. --live-real-time-deletion or similar time arguments).
Solutions
- Write the duration using the accepted unit syntax, e.g. 30s, 5m, 2h, or combined like 1h3m20s
- Do not use other formats such as '00:30:00', '30' without a unit suffix, or '30sec'
- Check for stray spaces or non-ASCII characters copied into the argument
Example fix
Replace --live-record-limit 01:00:00 with --live-record-limit 1h (or 1h30m / 90m as needed).
Defensive patterns
Strategy: validation
Prevention
- Always include unit suffixes h/m/s when specifying durations
- Use combined forms like 1h30m20s rather than clock-style notation
When it happens
Trigger: A command-line time argument (e.g. live buffer/record durations) does not match the TimeStrRegex pattern like ^(\d+h)?(\d+m)?(\d+s)?$ — missing units, wrong separators, or a totally different duration format.
Common situations: Users habitually type HH:mm:ss style durations, plain numbers without unit suffixes, or values with spaces such as '1h 3m' which the regex cannot match.
AI-assisted analysis of nilaoda/N_m3u8DL-RE@e113dee70c (2026-09-13).
Data as JSON: /api/errors/c1ed287c7ff2d1ce.
Report an issue: GitHub.
Appendix: source
Thrown at src/N_m3u8DL-RE/Util/OtherUtil.cs:136
/// <summary>
/// 从1h3m20s解析出总秒数
/// </summary>
/// <param name="timeStr"></param>
/// <returns></returns>
/// <exception cref="ArgumentException"></exception>
public static double ParseSeconds(string timeStr)
{
var pattern = TimeStrRegex();
var match = pattern.Match(timeStr);
if (!match.Success)
{
throw new ArgumentException("时间格式无效");
}
int hours = match.Groups[1].Success ? int.Parse(match.Groups[1].Value) : 0;
int minutes = match.Groups[2].Success ? int.Parse(match.Groups[2].Value) : 0;
int seconds = match.Groups[3].Success ? int.Parse(match.Groups[3].Value) : 0;
return hours * 3600 + minutes * 60 + seconds;
}View on GitHub (pinned to e113dee70c)