") {
if let strBuyin = stats.slice(from: "Buy-in: $", to: ""), let buyin = nf.number(from: strBuyin) {
tournament.buyin = buyin.intValue
} else {
print("no buyin = \(stats)")
}
if let strprizepool = stats.slice(from: "Prizepool: $", to: " "), let pp = nf.number(from: strprizepool) {
tournament.prizepool = pp.doubleValue
} else {
print("no prizepool = \(stats)")
}
if let strentries = stats.slice(from: "Entries: ", to: " "), let entries = nf.number(from: strentries) {
tournament.entries = entries.intValue
} else {
print("no entries = \(stats)")
}
}
if let strresultsblock = string.slice(from: "Country", to: "
").last {
name = nameraw.replacingOccurrences(of: "", with: "")
}
if let earningsraw = cells[2].components(separatedBy: "$").last {
let strearnings = earningsraw.replacingOccurrences(of: "", with: "")
earnings = nf.number(from: strearnings)?.doubleValue
}
if hasPOY, let poyraw = cells[3].components(separatedBy: "\'>").last {
let strpoy = poyraw.replacingOccurrences(of: "", with: "")
poy = nf.number(from: strpoy)?.doubleValue
}
let cityIndex = hasPOY ? 4 : 3
if let cityraw = cells[cityIndex].components(separatedBy: "\'>").last {
city = cityraw.replacingOccurrences(of: "", with: "")
}
let stateIndex = hasPOY ? 5 : 4
if let stateraw
= cells[stateIndex].components(separatedBy: "\'>").last {
state = stateraw.replacingOccurrences(of: "", with: "")
}
let countryIndex = hasPOY ? 6 : 5
if let countryraw
= cells[countryIndex].components(separatedBy: "\'>").last {
country = countryraw.replacingOccurrences(of: "", with: "")
}
guard let rank = rank, let name = name, let earnings = earnings else {
print("Missing data: R: \(rank), N: \(name), E: \(earnings)")
continue
}
let player = realm.getOrCreatePlayer(name: name, city: city ?? "", state: state ?? "", country: country ?? "")
let result = realm.create(Result.self)
result.player = player
result.earnings = earnings
result.rank = rank
tournament.results.append(result)
}
//
1
James Barnett$39,013TulareCAUS
} else {
print("Bad page strresultsblock")
}
}
}
} catch {
print(error)
}
}
}