Don't attempt to parse days from aria2c ETA

I had initially suggested this but then went and checked in the source and the largest unit in the format is hours. 52da4e40ea/src/util.cc (L518-L534)
This commit is contained in:
Brandon Evans 2021-02-18 19:16:08 -07:00
parent e301ad8818
commit 899eec7dae
No known key found for this signature in database
GPG key ID: D58A4B8DB64F8E93

View file

@ -43,16 +43,11 @@ extension Progress {
}
// MARK: Estimated Time Remaining
let regexETA = try! NSRegularExpression(pattern: #"(?<=ETA:)(?<days>\d*d)?(?<hours>\d*h)?(?<minutes>\d*m)?(?<seconds>\d*s)?"#)
let regexETA = try! NSRegularExpression(pattern: #"(?<=ETA:)(?<hours>\d*h)?(?<minutes>\d*m)?(?<seconds>\d*s)?"#)
if let match = regexETA.firstMatch(in: string, options: [], range: range) {
var seconds: Int = 0
if let matchRange = Range(match.range(withName: "days"), in: string),
let days = Int(string[matchRange].replacingOccurrences(of: "d", with: "")) {
seconds += (days * 60 * 60 * 24)
}
if let matchRange = Range(match.range(withName: "hours"), in: string),
let hours = Int(string[matchRange].replacingOccurrences(of: "h", with: "")) {
seconds += (hours * 60 * 60)