{"record":{"id":"c1ed287c7ff2d1ce","repo":"nilaoda/N_m3u8DL-RE","slug":"otherutil","errorCode":null,"errorMessage":"时间格式无效","messagePattern":"时间格式无效","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/N_m3u8DL-RE/Util/OtherUtil.cs","lineNumber":136,"sourceCode":"/// <summary>\n/// 从1h3m20s解析出总秒数\n/// </summary>\n/// <param name=\"timeStr\"></param>\n/// <returns></returns>\n/// <exception cref=\"ArgumentException\"></exception>\npublic static double ParseSeconds(string timeStr)\n{\n    var pattern = TimeStrRegex();\n\n    var match = pattern.Match(timeStr);\n\n    if (!match.Success)\n    {\n        throw new ArgumentException(\"时间格式无效\");\n    }\n\n    int hours = match.Groups[1].Success ? int.Parse(match.Groups[1].Value) : 0;\n    int minutes = match.Groups[2].Success ? int.Parse(match.Groups[2].Value) : 0;\n    int seconds = match.Groups[3].Success ? int.Parse(match.Groups[3].Value) : 0;\n\n    return hours * 3600 + minutes * 60 + seconds;\n}","sourceCodeStart":118,"sourceCodeEnd":154,"githubUrl":"https://github.com/nilaoda/N_m3u8DL-RE/blob/e113dee70c924ee08dae5460624909b04d84cb76/src/N_m3u8DL-RE/Util/OtherUtil.cs#L118-L154","documentation":"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).","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"Replace --live-record-limit 01:00:00 with --live-record-limit 1h (or 1h30m / 90m as needed).","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always include unit suffixes h/m/s when specifying durations","Use combined forms like 1h30m20s rather than clock-style notation"],"tags":[],"backgroundTag":null,"analyzedSha":"e113dee70c924ee08dae5460624909b04d84cb76","analyzedAt":"2026-09-13T02:43:21.078Z","contentChangedAt":"2026-09-13T02:43:21.078Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}