get_pro_names.py 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660
  1. #! /usr/bin/env python
  2. # Use this script to populate bot.txt with names from https://www.procyclingstats.com
  3. # Refer to http://cdn.zwift.com/gameassets/GameDictionary.xml
  4. # pip install beautifulsoup4 country-converter fuzzywuzzy
  5. # scripts/get_pro_names.py -h
  6. from bs4 import BeautifulSoup
  7. import urllib.request
  8. import json
  9. import country_converter as coco
  10. import argparse
  11. import os
  12. import sys
  13. import xml.etree.ElementTree as ET
  14. from fuzzywuzzy import process
  15. from fuzzywuzzy import fuzz
  16. base_url = "https://www.procyclingstats.com/rankings.php?filter=Filter"
  17. cc = coco.CountryConverter()
  18. teams = {
  19. "UAE Team Emirates": {
  20. "abv": "UAD",
  21. "jersey_name": "UAE",
  22. "jersey_signature": 1751349769,
  23. "bike_name": "Colnago Colnago V3RS",
  24. "bike_signature": 3628259811,
  25. "front_wheel_name": "Enve SES 3.4",
  26. "front_wheel_signature": 2223270801,
  27. "rear_wheel_name": "Enve SES 3.4",
  28. "rear_wheel_signature": 3835575171
  29. },
  30. "Soudal Quick-Step": {
  31. "abv": "SOQ",
  32. "jersey_name": "Deceuninck-Quick-Step",
  33. "jersey_signature": 2906189156,
  34. "bike_name": "Specialized Tarmac SL7",
  35. "bike_signature": 935373427,
  36. "front_wheel_name": "Roval Rapide CLX",
  37. "front_wheel_signature": 2181416413,
  38. "rear_wheel_name": "Roval Rapide CLX",
  39. "rear_wheel_signature": 3548735686,
  40. "helmet_name": "S-Works Evade",
  41. "helmet_signature": 3109903878
  42. },
  43. "Team Visma | Lease a Bike": {
  44. "abv": "TVL",
  45. "jersey_name": "Jumbo Visma TdF Edition 2023",
  46. "jersey_signature": 2246416303,
  47. "womens_jersey": 2922761319,
  48. "bike_name": "Cervelo CerveloS52021",
  49. "bike_signature": 1972610461,
  50. "front_wheel_name": "Reserve Reserve 25 GR",
  51. "front_wheel_signature": 635220876,
  52. "rear_wheel_name": "Reserve Reserve 25 GR",
  53. "rear_wheel_signature": 1842698274,
  54. "helmet_name": "LOC_ACCESSORY_LAZERBULLET",
  55. "helmet_signature": 1292376041
  56. },
  57. "Alpecin - Deceuninck": {
  58. "abv": "ADC",
  59. "jersey_name": "Alpecin Deceuninck 2023",
  60. "jersey_signature": 1905664161,
  61. "bike_name": "Canyon Aeroad2024",
  62. "bike_signature": 2629993294,
  63. "bike_frame_colour_name": "Canyon Aeroad2024-Aeroad Alpecin-Deceuninck",
  64. "bike_frame_colour_signature": 1978783051,
  65. "front_wheel_name": "Shimano C50",
  66. "front_wheel_signature": 1742598126,
  67. "rear_wheel_name": "Shimano C50",
  68. "rear_wheel_signature": 3725678091,
  69. "helmet_name": "ABUS GameChanger",
  70. "helmet_signature": 1387973863
  71. },
  72. "Lidl - Trek": {
  73. "abv": "TRK",
  74. "jersey_name": "Trek-Segafredo Men",
  75. "jersey_signature": 2140478849,
  76. "womens_jersey_signature": 1154847422,
  77. "bike_name": "Trek Madone",
  78. "bike_signature": 4129467727,
  79. "front_wheel_name": "Bontrager Aeolus5",
  80. "front_wheel_signature": 702195190,
  81. "rear_wheel_name": "Bontrager Aeolus5",
  82. "rear_wheel_signature": 3594144634
  83. },
  84. "Movistar Team": {
  85. "abv": "MOV",
  86. "jersey_name": "Movistar 2023",
  87. "jersey_signature": 436926002,
  88. "bike_name": "Canyon Aeroad Team Edition",
  89. "bike_signature": 390579581,
  90. "bike_frame_colour_name": "Canyon Aeroad Team Edition-Movistar 2023",
  91. "bike_frame_colour_signature": 2280475316,
  92. "front_wheel_name": "Zipp 404",
  93. "front_wheel_signature": 613983807,
  94. "rear_wheel_name": "Zipp 404",
  95. "rear_wheel_signature": 4183014640,
  96. "helmet_name": "ABUS GameChanger Movistar Team",
  97. "helmet_signature": 4241132751
  98. },
  99. "Lotto Dstny": {
  100. "abv": "LTD",
  101. "jersey_name": "Lotto Dstny 2023",
  102. "jersey_signature": 712380058,
  103. "bike_name": "Ridley Noah Fast 2019",
  104. "bike_signature": 4288910569,
  105. "bike_frame_colour_name": "Ridley Noah Fast 2019-Lotto Soudal",
  106. "bike_frame_colour_signature": 1205664811,
  107. "front_wheel_name": "DTSwiss ARC 1100 DICUT 62",
  108. "front_wheel_signature": 346409677,
  109. "rear_wheel_name": "DTSwiss ARC 1100 DICUT 62",
  110. "rear_wheel_signature": 2049111692
  111. },
  112. "EF Education - EasyPost": {
  113. "abv": "EFE",
  114. "jersey_name": "EF Education First",
  115. "jersey_signature": 2349035663,
  116. "bike_name": "Cannondale System Six",
  117. "bike_signature": 2005280203,
  118. "bike_frame_colour_name": "Cannondale Super Six Evo-Education First",
  119. "bike_frame_colour_signature": 507139888,
  120. "front_wheel_name": "HED HED Vanquish RC6 Pro",
  121. "front_wheel_signature": 1791179228,
  122. "rear_wheel_name": "HED HED Vanquish RC6 Pro",
  123. "rear_wheel_signature": 2913819265,
  124. "helmet_name": "POC Ventral Air EF",
  125. "helmet_signature": 3707571564
  126. },
  127. "INEOS Grenadiers": {
  128. "abv": "IGD",
  129. "jersey_name": "INEOS Grenadiers 2022 Pro",
  130. "jersey_signature": 542207259,
  131. "bike_name": "Pinarello Dogma F",
  132. "bike_signature": 4208139356,
  133. "bike_frame_colour_name": "Pinarello Dogma F-Ineos",
  134. "bike_frame_colour_signature": 870887764,
  135. "front_wheel_name": "Shimano C50",
  136. "front_wheel_signature": 1742598126,
  137. "rear_wheel_name": "Shimano C50",
  138. "rear_wheel_signature": 3725678091,
  139. "helmet_name": "Protone INEOS Grenadier",
  140. "helmet_signature": 3438211262
  141. },
  142. "Groupama - FDJ": {
  143. "abv": "GFC",
  144. "jersey_name": "Groupama FDJ 2023",
  145. "jersey_signature": 2814449542,
  146. "bike_name": "Specialized Tarmac SL7",
  147. "bike_signature": 935373427,
  148. "front_wheel_name": "Shimano C50",
  149. "front_wheel_signature": 1742598126,
  150. "rear_wheel_name": "Shimano C50",
  151. "rear_wheel_signature": 3725678091,
  152. "helmet_name": "Giro Eclipse FDJ",
  153. "helmet_signature": 3912703277
  154. },
  155. "Bahrain - Victorious": {
  156. "abv": "TBV",
  157. "jersey_name": "Bahrain McLaren",
  158. "jersey_signature": 2155858980,
  159. "bike_frame_colour_name": "Merida Scultura-Merida Scultura Bahrain McLaren",
  160. "bike_frame_colour_signature": 2063693653,
  161. "bike_name": "Merida Scultura",
  162. "bike_signature": 3033010663
  163. },
  164. "Team dsm-firmenich PostNL": {
  165. "abv": "DSM",
  166. "jersey_name": "Team ODZ",
  167. "jersey_signature": 2695025247,
  168. "bike_name": "Scott Foil",
  169. "bike_signature": 1315158373,
  170. "front_wheel_name": "Shimano C50",
  171. "front_wheel_signature": 1742598126,
  172. "rear_wheel_name": "Shimano C50",
  173. "rear_wheel_signature": 3725678091
  174. },
  175. "Team Jayco AlUla": {
  176. "abv": "JAY",
  177. "jersey_name": "Team Jayco Alula 2023",
  178. "jersey_signature": 91507230,
  179. "womens_jersey": 1912060275,
  180. "bike_name": "Giant Propel Advanced SL Disc",
  181. "bike_signature": 103914490,
  182. "front_wheel_name": "Cadex CADEX 42",
  183. "front_wheel_signature": 1497226614,
  184. "rear_wheel_name": "Cadex CADEX 42",
  185. "rear_wheel_signature": 1347687916
  186. },
  187. "Uno-X Mobility": {
  188. "abv": "UXT",
  189. "bike_name": "Ridley Noah Fast 2019",
  190. "bike_signature": 4288910569,
  191. "jersey_name": "UnoXPro2022",
  192. "jersey_signature": 1756517729
  193. },
  194. "Cofidis": {
  195. "abv": "COF",
  196. "bike_name": "Zwift Carbon",
  197. "bike_signature": 2106340733,
  198. "bike_frame_colour_name": "Zwift Carbon-Cofidis De Rosa",
  199. "bike_frame_colour_signature": 2273815071,
  200. "jersey_name": "Cofidis 2018",
  201. "jersey_signature": 927604154,
  202. "front_wheel_name": "Shimano C50",
  203. "front_wheel_signature": 1742598126,
  204. "rear_wheel_name": "Shimano C50",
  205. "rear_wheel_signature": 3725678091
  206. },
  207. "Intermarché - Wanty": {
  208. "abv": "ICW",
  209. "jersey_name": "Intermarché Wanty Circus 2023",
  210. "jersey_signature": 2642337455,
  211. "bike_name": "Cube Cube Litening",
  212. "bike_signature": 1767548815,
  213. "front_wheel_name": "Shimano C50",
  214. "front_wheel_signature": 1742598126,
  215. "rear_wheel_name": "Shimano C50",
  216. "rear_wheel_signature": 3725678091
  217. },
  218. "Red Bull - BORA - hansgrohe": {
  219. "abv": "BOH",
  220. "jersey_name": "Bora Hansgrohe",
  221. "jersey_signature": 3798832688,
  222. "bike_name": "Specialized Tarmac SL7",
  223. "bike_signature": 935373427,
  224. "front_wheel_name": "Roval Rapide CLX",
  225. "front_wheel_signature": 2181416413,
  226. "rear_wheel_name": "Roval Rapide CLX",
  227. "rear_wheel_signature": 3548735686,
  228. "helmet_name": "S-Works Evade",
  229. "helmet_signature": 3109903878
  230. },
  231. "Arkéa - B&B Hotels": {
  232. "abv": "ARK",
  233. "jersey_name": "Arkea-Samsic",
  234. "jersey_signature": 598687666,
  235. "front_wheel_name": "Shimano C50",
  236. "front_wheel_signature": 1742598126,
  237. "rear_wheel_name": "Shimano C50",
  238. "rear_wheel_signature": 3725678091
  239. },
  240. "Decathlon AG2R La Mondiale Team": {
  241. "abv": "ACT",
  242. "bike_name": "Zwift Carbon",
  243. "bike_signature": 2106340733,
  244. "bike_frame_colour_name": "Zwift Carbon-AG2R",
  245. "bike_frame_colour_signature": 455876950,
  246. "jersey_name": "AG2R La Mondiale",
  247. "jersey_signature": 1587982785,
  248. "front_wheel_name": "Campagnolo Bora Ultra 35",
  249. "front_wheel_signature": 1053884173,
  250. "rear_wheel_name": "Campagnolo Bora Ultra 35",
  251. "rear_wheel_signature": 1614586487
  252. },
  253. "Astana Qazaqstan Team": {
  254. "abv": "AST",
  255. "jersey_name": "ASTANA PRO TEAM",
  256. "jersey_signature": 1969335676,
  257. "bike_name": "Zwift Carbon",
  258. "bike_signature": 2106340733,
  259. "bike_frame_colour_name": "Zwift Carbon-Astana",
  260. "bike_frame_colour_signature": 1208416225,
  261. "front_wheel_name": "Shimano C50",
  262. "front_wheel_signature": 1742598126,
  263. "rear_wheel_name": "Shimano C50",
  264. "rear_wheel_signature": 3725678091,
  265. "helmet_name": "Limar Air Speed TWENTY24",
  266. "helmet_signature": 9439966
  267. },
  268. "Israel - Premier Tech": {
  269. "abv": "IPT",
  270. "jersey_name": "Israel Premier-Tech",
  271. "jersey_signature": 552170906,
  272. "bike_name": "Factor One",
  273. "bike_signature": 3469325930
  274. },
  275. "TotalEnergies": {
  276. "abv": "TEN",
  277. "bike_name": "Zwift Carbon",
  278. "bike_signature": 2106340733,
  279. "bike_frame_colour_name": "Zwift Carbon-Total Direct Energie",
  280. "bike_frame_colour_signature": 1215759893,
  281. "jersey_name": "Total Direct Energie",
  282. "jersey_signature": 2092402045,
  283. "front_wheel_name": "Shimano C50",
  284. "front_wheel_signature": 1742598126,
  285. "rear_wheel_name": "Shimano C50",
  286. "rear_wheel_signature": 3725678091
  287. },
  288. "Team SD Worx - Protime": {
  289. "abv": "SDW",
  290. "jersey_name": "Team SD Worx",
  291. "jersey_signature": 1494272741,
  292. "bike_name": "Specialized Tarmac SL7",
  293. "bike_signature": 935373427,
  294. "helmet_name": "S-Works Evade",
  295. "helmet_signature": 3109903878
  296. },
  297. "UAE Team ADQ": {
  298. "abv": "UAD",
  299. "jersey_name": "UAE",
  300. "jersey_signature": 1751349769,
  301. "bike_name": "Colnago Colnago V3RS",
  302. "bike_signature": 3628259811,
  303. "front_wheel_name": "Enve SES 3.4",
  304. "front_wheel_signature": 2223270801,
  305. "rear_wheel_name": "Enve SES 3.4",
  306. "rear_wheel_signature": 3835575171
  307. },
  308. "UAE Development Team": {
  309. "abv": "UDT",
  310. "bike_name": "Colnago Colnago V3RS",
  311. "bike_signature": 3628259811,
  312. "jersey_name": "UAE",
  313. "jersey_signature": 1751349769
  314. },
  315. "FDJ - SUEZ": {
  316. "abv": "FST",
  317. "bike_name": "Zwift Carbon",
  318. "bike_signature": 2106340733,
  319. "bike_frame_colour_name": "Zwift Carbon-Lapierre FDJ",
  320. "bike_frame_colour_signature": 1248651886,
  321. "jersey_name": "FDJ Suez 2023",
  322. "jersey_signature": 3360845221,
  323. "front_wheel_name": "Shimano C50",
  324. "front_wheel_signature": 1742598126,
  325. "rear_wheel_name": "Shimano C50",
  326. "rear_wheel_signature": 3725678091
  327. },
  328. "Canyon//SRAM Racing": {
  329. "abv": "CSR",
  330. "jersey_name": "CANYON//SRAM Racing",
  331. "jersey_signature": 3970245639,
  332. "bike_name": "Canyon AeroadSRAM2024",
  333. "bike_signature": 1122831861,
  334. "front_wheel_name": "Zipp 404",
  335. "front_wheel_signature": 613983807,
  336. "rear_wheel_name": "Zipp 404",
  337. "rear_wheel_signature": 4183014640,
  338. "helmet_name": "Giro Eclipse Canyon SRAM",
  339. "helmet_signature": 3346861673
  340. },
  341. "Canyon//SRAM Generation": {
  342. "abv": "CSR",
  343. "jersey_name": "Canyon//SRAM Generation",
  344. "jersey_signature": 189587516,
  345. "bike_name": "Canyon AeroadSRAM2024",
  346. "bike_signature": 1122831861,
  347. "front_wheel_name": "Zipp 404",
  348. "front_wheel_signature": 613983807,
  349. "rear_wheel_name": "Zipp 404",
  350. "rear_wheel_signature": 4183014640,
  351. "helmet_name": "Giro Eclipse Canyon SRAM",
  352. "helmet_signature": 3346861673
  353. },
  354. "AG Insurance - Soudal Quick-Step": {
  355. "abv": "AGS",
  356. "jersey_name": "Lotto-Soudal",
  357. "jersey_signature": 3103938066,
  358. "bike_name": "Specialized Tarmac SL7",
  359. "bike_signature": 935373427,
  360. "helmet_name": "S-Works Evade",
  361. "helmet_signature": 3109903878
  362. },
  363. "Human Powered Health": {
  364. "abv": "HPW",
  365. "jersey_name": "Human Powered Health Fan",
  366. "jersey_signature": 854534852,
  367. "bike_name": "Felt AR",
  368. "bike_signature": 3002729519
  369. },
  370. "Liv AlUla Jayco": {
  371. "abv": "LAJ",
  372. "jersey_name": "Liv AlUla Jayco 2024",
  373. "jersey_signature": 2095486697,
  374. "bike_name": "Liv Langma Advanced SL",
  375. "bike_signature": 3495124341
  376. },
  377. "Israel Premier Tech Roland": {
  378. "abv": "CGS",
  379. "jersey_name": "Israel Premier-Tech",
  380. "jersey_signature": 552170906,
  381. "bike_name": "Factor One",
  382. "bike_signature": 3469325930,
  383. "bike_frame_colour_name": "Factor One-One Israel",
  384. "bike_frame_colour_signature": 3959514452,
  385. "helmet_name": "Limar Air Speed TWENTY24",
  386. "helmet_signature": 9439966
  387. },
  388. "EF Education-TIBCO-SVB": {
  389. "abv": "TIB",
  390. "jersey_name": "Team EF Education-TIBCO-SVB",
  391. "jersey_signature": 2795352821,
  392. "bike_name": "Cannondale System Six",
  393. "bike_signature": 2005280203,
  394. "helmet_name": "POC Ventral Air EF",
  395. "helmet_signature": 3707571564
  396. },
  397. "Fenix-Deceuninck": {
  398. "abv": "FED",
  399. "jersey_name": "Fenix Deceuninck 2023",
  400. "jersey_signature": 3290712389,
  401. "bike_name": "Canyon Aeroad2024",
  402. "bike_signature": 2629993294
  403. },
  404. "Fenix-Deceuninck Continental": {
  405. "abv": "FDD",
  406. "bike_name": "Canyon Aeroad2024",
  407. "bike_signature": 2629993294,
  408. "jersey_name": "Fenix Deceuninck 2023",
  409. "jersey_signature": 3290712389
  410. },
  411. "Ceratizit-WNT": {
  412. "abv": "WNT",
  413. "bike_name": "Zwift Carbon",
  414. "bike_signature": 2106340733,
  415. "bike_frame_colour_name": "Zwift Carbon-Orbea Orca",
  416. "bike_frame_colour_signature": 806402273,
  417. "jersey_name": "Ceratizit-WNT",
  418. "jersey_signature": 97975537
  419. },
  420. "St Michel - Mavic - Auber93 WE": {
  421. "abv": "AUB",
  422. "jersey_name": "South Africa Elite",
  423. "jersey_signature": 3305515323,
  424. "bike_name": "Cannondale System Six",
  425. "bike_signature": 2005280203,
  426. "front_wheel_name": "Mavic Comete Pro Carbon SL UST",
  427. "front_wheel_signature": 897949453,
  428. "rear_wheel_name": "Mavic Comete Pro Carbon SL UST",
  429. "rear_wheel_signature": 4001596344
  430. },
  431. "Lifeplus Wahoo": {
  432. "abv": "DRP",
  433. "bike_name": "Ribble Endurance",
  434. "bike_signature": 3247466139,
  435. "jersey_name": "Wahoo",
  436. "jersey_signature": 3553917933
  437. },
  438. "Cofidis Women Team": {
  439. "abv": "COF",
  440. "bike_name": "Zwift Carbon",
  441. "bike_signature": 2106340733,
  442. "bike_frame_colour_name": "Zwift Carbon-Cofidis De Rosa",
  443. "bike_frame_colour_signature": 2273815071,
  444. "jersey_name": "Cofidis",
  445. "jersey_signature": 4191972189
  446. },
  447. "Arkéa Pro Cycling Team": {
  448. "abv": "ARK",
  449. "jersey_name": "Arkea",
  450. "jersey_signature": 1128201030
  451. },
  452. "MAT Atom Deweloper Wrocław": {
  453. "abv": "MAW",
  454. "bike_name": "Ridley Noah Fast 2019",
  455. "bike_signature": 4288910569,
  456. "jersey_name": "Atom Racing Team",
  457. "jersey_signature": 851470392
  458. },
  459. "Top Girls Fassa Bortolo": {
  460. "abv": "TOP",
  461. "bike_name": "Pinarello Dogma F",
  462. "bike_signature": 4208139356,
  463. "jersey_name": "Clash Of Clubs Blue",
  464. "jersey_signature": 520081294
  465. },
  466. "EOLO-Kometa": {
  467. "abv": "EOK",
  468. "jersey_name": "Eolo Kometa",
  469. "jersey_signature": 2422819298,
  470. "front_wheel_name": "Enve SES 3.4",
  471. "front_wheel_signature": 2223270801,
  472. "rear_wheel_name": "Enve SES 3.4",
  473. "rear_wheel_signature": 3835575171
  474. },
  475. "Green Project-Bardiani CSF-Faizanè": {
  476. "abv": "GBF",
  477. "jersey_name": "Bardiani 2019",
  478. "jersey_signature": 3503002798,
  479. "front_wheel_name": "Campagnolo Bora Ultra 35",
  480. "front_wheel_signature": 1053884173,
  481. "rear_wheel_name": "Campagnolo Bora Ultra 35",
  482. "rear_wheel_signature": 1614586487
  483. },
  484. "L39ION of Los Angeles": {
  485. "abv": "LLA",
  486. "bike_name": "Factor One",
  487. "bike_signature": 3469325930,
  488. "jersey_name": "L39ION of LA 2022",
  489. "jersey_signature": 2330819669
  490. },
  491. "Lotto Dstny Ladies": {
  492. "abv": "LDL",
  493. "jersey_name": "Lotto Dstny 2023",
  494. "jersey_signature": 712380058
  495. },
  496. "Parkhotel Valkenburg": {
  497. "abv": "PHV",
  498. "bike_name": "Giant Propel Advanced SL Disc",
  499. "bike_signature": 103914490,
  500. "jersey_name": "Parkhotel Valkenburg",
  501. "jersey_signature": 4102459937
  502. },
  503. "Tudor Pro Cycling Team": {
  504. "abv": "TUD",
  505. "bike_name": "BMC BmcTeamMachine2022",
  506. "bike_signature": 3868468027,
  507. "helmet_name": "ABUS GameChanger",
  508. "helmet_signature": 1387973863,
  509. "front_wheel_name": "DTSwiss ARC 1100 DICUT 62",
  510. "front_wheel_signature": 346409677,
  511. "rear_wheel_name": "DTSwiss ARC 1100 DICUT 62",
  512. "rear_wheel_signature": 2049111692
  513. },
  514. "EF-Oatly-Cannondale": {
  515. "abv": "EOC",
  516. "jersey_name": "EF Education First",
  517. "jersey_signature": 2349035663,
  518. "bike_name": "Cannondale System Six",
  519. "bike_signature": 2005280203
  520. },
  521. "Roland": {
  522. "abv": "CGS",
  523. "bike_name": "Pinarello Dogma F",
  524. "bike_signature": 4208139356
  525. },
  526. "AG Insurance - Soudal Team": {
  527. "abv": "AGS",
  528. "jersey_name": "Lotto-Soudal",
  529. "jersey_signature": 3103938066,
  530. "bike_name": "Specialized Tarmac SL7",
  531. "bike_signature": 935373427
  532. },
  533. "VolkerWessels Women\"s Pro Cycling Team": {
  534. "abv": "VWT",
  535. "bike_name": "Specialized Tarmac SL7",
  536. "bike_signature": 935373427
  537. }
  538. }
  539. def get_pros(url, male, get_jersey, get_equipment, team_abbrv):
  540. data = []
  541. req = urllib.request.Request(url, headers={'User-Agent': 'Mozilla/5.0'})
  542. site = urllib.request.urlopen(req).read()
  543. soup = BeautifulSoup(site)
  544. for td in soup.find_all('td'):
  545. if td.span and td.contents[0]:
  546. tmp = {}
  547. if "flag" in repr(td.contents[0]):
  548. code = td.span.get_attribute_list("class")[1]
  549. tmp['country_code'] = cc.convert(names=code, to='ISOnumeric')
  550. tmp['is_male'] = male
  551. if td.a:
  552. fn = []
  553. ln = []
  554. for n in td.a.contents[0].split():
  555. if n.isupper():
  556. ln.append(n.title())
  557. else:
  558. fn.append(n)
  559. tmp['first_name'] = ' '.join(fn)
  560. tmp['last_name'] = ' '.join(ln)
  561. if td.a and td.contents[0]:
  562. if "cu600" in repr(td) and td.a.contents:
  563. if 'first_name' in tmp:
  564. if team_abbrv:
  565. if td.a.contents[0] in teams and 'abv' in teams[td.a.contents[0]]:
  566. tmp['last_name'] += " ("+teams[td.a.contents[0]]['abv']+")"
  567. if get_jersey:
  568. if not male and td.a.contents[0] in teams and 'womens_jersey_signature' in teams[td.a.contents[0]]:
  569. tmp['ride_jersey'] = teams[td.a.contents[0]]['womens_jersey_signature']
  570. elif td.a.contents[0] in teams and 'jersey_signature' in teams[td.a.contents[0]]:
  571. tmp['ride_jersey'] = teams[td.a.contents[0]]['jersey_signature']
  572. else:
  573. best_match = process.extractOne(td.a.contents[0], jerseys.keys(), scorer=fuzz.token_set_ratio)
  574. print ("%s %s : %s - %s" % (tmp['first_name'],tmp['last_name'],td.a.contents[0], best_match))
  575. tmp['ride_jersey'] = jerseys[best_match[0]]
  576. if get_equipment:
  577. if td.a.contents[0] in teams:
  578. team = teams[td.a.contents[0]]
  579. if 'bike_signature' in team:
  580. tmp['bike_frame'] = team['bike_signature']
  581. if 'bike_frame_colour_signature' in team:
  582. tmp['bike_frame_colour'] = team['bike_frame_colour_signature'] << 32
  583. if 'front_wheel_signature' in team:
  584. tmp['bike_wheel_front'] = team['front_wheel_signature']
  585. if 'rear_wheel_signature' in team:
  586. tmp['bike_wheel_rear'] = team['rear_wheel_signature']
  587. if 'helmet_signature' in team:
  588. tmp['ride_helmet_type'] = team['helmet_signature']
  589. data.append(tmp)
  590. return data
  591. gd_file = 'GameDictionary.xml'
  592. if not os.path.isfile(gd_file):
  593. open(gd_file, 'wb').write(urllib.request.urlopen('http://cdn.zwift.com/gameassets/%s' % gd_file).read())
  594. tree = ET.parse(gd_file)
  595. jerseys = {}
  596. for x in tree.findall("./JERSEYS/JERSEY"):
  597. jerseys[x.get('name')] = int(x.get('signature'))
  598. def main(argv):
  599. global args
  600. parser = argparse.ArgumentParser(description='Populate Bot names with professional riders')
  601. parser.add_argument('-n', '--nation', help='Riders from specified nation only', default=False)
  602. parser.add_argument('-f', '--female', help='Female riders only', default=False, action='store_true')
  603. parser.add_argument('-m', '--male', help='Male riders only', default=False, action='store_true')
  604. parser.add_argument('-a', '--alltime', help='Use all time ranking', default=False, action='store_true')
  605. parser.add_argument('-p', '--pages', help='Number of pages to process', default=1)
  606. parser.add_argument('-j', '--jersey', help='Get team jerseys', default=False, action='store_true')
  607. parser.add_argument('-e', '--equipment', help='Get team bike and wheels', default=False, action='store_true')
  608. parser.add_argument('-t', '--teamabbrv', help='Add team abbreviation to last name', default=False, action='store_true')
  609. args = parser.parse_args()
  610. url_additions = ""
  611. url_list = []
  612. if args.alltime:
  613. url_additions += "&s=all-time"
  614. if args.nation:
  615. url_additions += "&nation="+args.nation
  616. if args.female:
  617. url_list = [ { "url": base_url + url_additions + "&p=we", "is_male": False } ]
  618. elif args.male:
  619. url_list = [ { "url": base_url + url_additions + "&p=me", "is_male": True } ]
  620. else:
  621. url_list = [ { "url": base_url + url_additions + "&p=me", "is_male": True }, { "url": base_url + url_additions + "&p=we", "is_male": False } ]
  622. if args.pages:
  623. new_url_list = url_list.copy()
  624. for x in range(1,int(args.pages)):
  625. offset = str(x*100)
  626. for url in url_list:
  627. new_url_list += [ { "url": url['url'] + "&offset=" + offset, "is_male": url['is_male'] }]
  628. url_list = new_url_list.copy()
  629. total_data = {}
  630. total_data['riders'] = []
  631. for item in url_list:
  632. total_data['riders'] = total_data['riders'] + get_pros(item['url'], item['is_male'], args.jersey, args.equipment, args.teamabbrv)
  633. with open('bot.txt', 'w') as outfile:
  634. json.dump(total_data, outfile, indent=2)
  635. if __name__ == '__main__':
  636. try:
  637. main(sys.argv)
  638. except KeyboardInterrupt:
  639. pass
  640. except SystemExit as se:
  641. print("ERROR:", se)