|
|
|
@ -11,10 +11,20 @@ import RealmSwift |
|
|
|
|
|
|
|
|
|
|
|
class Downloader { |
|
|
|
class Downloader { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct TS { |
|
|
|
|
|
|
|
var id: String |
|
|
|
|
|
|
|
var date: String |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static func downloadWSOPResults() { |
|
|
|
static func downloadWSOPResults() { |
|
|
|
|
|
|
|
|
|
|
|
downloadWSOPResults(tournamentId: "19728") |
|
|
|
let infos = [TS(id: "19728", date: "02/10/2021"), |
|
|
|
downloadWSOPResults(tournamentId: "19730") |
|
|
|
TS(id: "19729", date: "03/10/2021"), |
|
|
|
|
|
|
|
TS(id: "19730", date: "02/10/2021")] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for info in infos { |
|
|
|
|
|
|
|
downloadWSOPResults(tournamentInfo: info) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// for i in 19728...19732 { |
|
|
|
// for i in 19728...19732 { |
|
|
|
// DispatchQueue.global(qos: .utility).async { |
|
|
|
// DispatchQueue.global(qos: .utility).async { |
|
|
|
@ -26,23 +36,14 @@ class Downloader { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fileprivate static func downloadWSOPResults(tournamentId: String) { |
|
|
|
fileprivate static func downloadWSOPResults(tournamentInfo: TS) { |
|
|
|
|
|
|
|
|
|
|
|
print("Importing tournament \(tournamentId)") |
|
|
|
print("Importing tournament \(tournamentInfo.id)") |
|
|
|
|
|
|
|
|
|
|
|
guard let url = URL(string: "https://www.wsop.com/tournaments/results/?aid=2&grid=4865&tid=\(tournamentId)&rr=5") else { |
|
|
|
guard let url = URL(string: "https://www.wsop.com/tournaments/results/?aid=2&grid=4865&tid=\(tournamentInfo.id)&rr=5") else { |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
|
|
|
|
<ul id="eventstats"> |
|
|
|
|
|
|
|
<li><b>Buy-in:</b> $500</li> |
|
|
|
|
|
|
|
<li><b>Prizepool:</b> $175,980 </li> |
|
|
|
|
|
|
|
<li><b>Entries:</b> 419 </li> |
|
|
|
|
|
|
|
<li><b>Remaining:</b> 63</li> |
|
|
|
|
|
|
|
</ul> |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let realm = try! Realm() |
|
|
|
let realm = try! Realm() |
|
|
|
|
|
|
|
|
|
|
|
let nf = NumberFormatter() |
|
|
|
let nf = NumberFormatter() |
|
|
|
@ -61,12 +62,20 @@ class Downloader { |
|
|
|
|
|
|
|
|
|
|
|
if let name = infos.slice(from: "<h1>", to: "</h1>") { |
|
|
|
if let name = infos.slice(from: "<h1>", to: "</h1>") { |
|
|
|
tournament.name = name |
|
|
|
tournament.name = name |
|
|
|
tournament.date = Date() |
|
|
|
tournament.date = Formatter.basicDate.date(from: tournamentInfo.date) ?? Date() |
|
|
|
|
|
|
|
|
|
|
|
if let strNumber = name.slice(from: "Event #", to: ":"), let number = nf.number(from: strNumber) { |
|
|
|
if let strNumber = name.slice(from: "Event #", to: ":"), let number = nf.number(from: strNumber) { |
|
|
|
tournament.number = number.intValue |
|
|
|
tournament.number = number.intValue |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if name.contains("6-Handed") { |
|
|
|
|
|
|
|
tournament.tableSize = 6 |
|
|
|
|
|
|
|
} else if name.contains("8-Handed") { |
|
|
|
|
|
|
|
tournament.tableSize = 8 |
|
|
|
|
|
|
|
} else if name.contains("Heads-Up") { |
|
|
|
|
|
|
|
tournament.tableSize = 2 |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
print("no name = \(infos)") |
|
|
|
print("no name = \(infos)") |
|
|
|
} |
|
|
|
} |
|
|
|
@ -146,7 +155,8 @@ class Downloader { |
|
|
|
let countryIndex = hasPOY ? 6 : 5 |
|
|
|
let countryIndex = hasPOY ? 6 : 5 |
|
|
|
if let countryraw |
|
|
|
if let countryraw |
|
|
|
= cells[countryIndex].components(separatedBy: "\'>").last { |
|
|
|
= cells[countryIndex].components(separatedBy: "\'>").last { |
|
|
|
country = countryraw.replacingOccurrences(of: "</li>", with: "") |
|
|
|
country = String(countryraw.prefix(2)) |
|
|
|
|
|
|
|
// country = countrytmp.prefix(2) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
guard let rank = rank, let name = name, let earnings = earnings else { |
|
|
|
guard let rank = rank, let name = name, let earnings = earnings else { |
|
|
|
@ -165,7 +175,6 @@ class Downloader { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// <li class='place'>1</li><li class='player cellbg'><img src='/tournaments/images/flags/US.gif' border='0' title='United States' alt='United States' /><a href='/players/profile/?playerid=200597'>James Barnett</a></li><li class='award'>$39,013</li><li class='city cellbg'>Tulare</li><li class='state'>CA</li><li class='country cellbg'>US</li> |
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
print("Bad page strresultsblock") |
|
|
|
print("Bad page strresultsblock") |
|
|
|
} |
|
|
|
} |
|
|
|
|