Guest User

yuh

a guest
May 16th, 2026
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 41.84 KB | None | 0 0
  1. import requests
  2. from bs4 import BeautifulSoup
  3. import pandas
  4. import timeit
  5. import time
  6. from timeit import default_timer
  7. import playsound3
  8. import multiprocessing
  9. import threading
  10.  
  11. global links_used
  12. links_used = 0
  13.  
  14. VCT_TEAMS = [
  15. #EMEA
  16. "https://www.vlr.gg/team/397/bbl-esports",#1
  17. "https://www.vlr.gg/team/6392/eternal-fire",#2 TODO: Make special case that includes ULF
  18. "https://www.vlr.gg/team/2593/fnatic",#3
  19. "https://www.vlr.gg/team/1184/fut-esports",#4
  20. "https://www.vlr.gg/team/12694/gentle-mates",#5
  21. "https://www.vlr.gg/team/14419/giantx",#6
  22. "https://www.vlr.gg/team/1001/team-heretics",#7
  23. "https://www.vlr.gg/team/8877/karmine-corp",#8
  24. "https://www.vlr.gg/team/474/team-liquid",#9
  25. "https://www.vlr.gg/team/4915/natus-vincere",#10
  26. "https://www.vlr.gg/team/3478/pcific-esports",#11
  27. "https://www.vlr.gg/team/2059/team-vitality",#12
  28. #AMER
  29. "https://www.vlr.gg/team/120/100-thieves",
  30. "https://www.vlr.gg/team/188/cloud9",
  31. "https://www.vlr.gg/team/427/envy",
  32. "https://www.vlr.gg/team/5248/evil-geniuses",
  33. "https://www.vlr.gg/team/2406/furia",
  34. "https://www.vlr.gg/team/11058/g2-esports",
  35. "https://www.vlr.gg/team/2355/krü-esports",
  36. "https://www.vlr.gg/team/2359/leviatán",
  37. "https://www.vlr.gg/team/6961/loud",
  38. "https://www.vlr.gg/team/7386/mibr",
  39. "https://www.vlr.gg/team/1034/nrg",
  40. "https://www.vlr.gg/team/2/sentinels",
  41. #Pacific
  42. "https://www.vlr.gg/team/278/detonation-focusme",
  43. "https://www.vlr.gg/team/4050/full-sense",
  44. "https://www.vlr.gg/team/17/gen-g",
  45. "https://www.vlr.gg/team/918/global-esports",
  46. "https://www.vlr.gg/team/8185/drx", #KIWOOM DRX aka "KRX"... absolute terror of a rename
  47. "https://www.vlr.gg/team/11060/nongshim-redforce",
  48. "https://www.vlr.gg/team/624/paper-rex",
  49. "https://www.vlr.gg/team/878/rex-regum-qeon",
  50. "https://www.vlr.gg/team/6199/team-secret",
  51. "https://www.vlr.gg/team/14/t1",
  52. "https://www.vlr.gg/team/11229/varrel",
  53. "https://www.vlr.gg/team/5448/zeta-division", #´//,
  54. #CN
  55. "https://www.vlr.gg/team/1119/all-gamers",
  56. "https://www.vlr.gg/team/12010/bilibili-gaming",
  57. "https://www.vlr.gg/team/11981/dragon-ranger-gaming",
  58. "https://www.vlr.gg/team/1120/edward-gaming",
  59. "https://www.vlr.gg/team/11328/funplus-phoenix",
  60. "https://www.vlr.gg/team/13576/jdg-esports",
  61. "https://www.vlr.gg/team/12064/nova-esports",
  62. "https://www.vlr.gg/team/14137/titan-esports-club",
  63. "https://www.vlr.gg/team/12685/trace-esports",
  64. "https://www.vlr.gg/team/731/tyloo",
  65. "https://www.vlr.gg/team/13790/wolves-esports",
  66. "https://www.vlr.gg/team/13581/xi-lai-gaming" #⹁-´`-,
  67. ]
  68.  
  69. all_data = []
  70.  
  71. def extract_file_data(file_name:str, debug:bool = False):
  72. read_file = open(file_name)
  73. readable_file = str(read_file.read())
  74. read_file.close()
  75.  
  76. readable_file = readable_file.replace("\n", " ")
  77. readable_file = readable_file.replace("'", "")
  78. readable_file = readable_file.replace("round diff", ": round diff")
  79. readable_file = readable_file.split(":")
  80.  
  81. remove = ["[",
  82. "]"]
  83.  
  84. global Savedlink
  85. global Savedtname
  86. global Savedtscore
  87. global Savedtfkfddiff
  88. global Savedtfk
  89. global Savedtfd
  90. global Savedtk
  91. global Savedtd
  92. global Savedta
  93. global Savedtkd
  94.  
  95. global SavedM
  96.  
  97. global Savedokd
  98. global Savedoa
  99. global Savedod
  100. global Savedok
  101. global Savedofd
  102. global Savedofk
  103. global Savedofkfddiff
  104. global Savedoscore
  105. global Savedoname
  106.  
  107. Savedlink = f"https:{readable_file[readable_file.index('lastLink')+2]}"
  108.  
  109. Savedtname = readable_file[readable_file.index(" Team")+1]
  110. Savedtscore = readable_file[readable_file.index(" Team score")+1]
  111. Savedtfkfddiff = readable_file[readable_file.index(" Team fk-fd")+1]
  112. Savedtfk = readable_file[readable_file.index(" Team fk")+1]
  113. Savedtfd = readable_file[readable_file.index(" Team fd")+1]
  114. Savedtk = readable_file[readable_file.index(" Team Kills")+1]
  115. Savedtd = readable_file[readable_file.index(" Team Deaths")+1]
  116. Savedta = readable_file[readable_file.index(" Team Assists")+1]
  117. Savedtkd = readable_file[readable_file.index(" Team Kill-Death")+1]
  118.  
  119. SavedM = readable_file[readable_file.index(" maps played")+1]
  120.  
  121. Savedokd = readable_file[readable_file.index(" Opponent Kill-Death")+1]
  122. Savedoa = readable_file[readable_file.index(" Opponent Assists")+1]
  123. Savedod = readable_file[readable_file.index(" Opponent Deaths")+1]
  124. Savedok = readable_file[readable_file.index(" Opponent Kills")+1]
  125. Savedofd = readable_file[readable_file.index(" Opponent fd")+1]
  126. Savedofk = readable_file[readable_file.index(" Opponent fk")+1]
  127. Savedofkfddiff = readable_file[readable_file.index(" Opponent fk-fd")+1]
  128. Savedoscore = readable_file[readable_file.index(" Opponent score")+1]
  129. Savedoname = readable_file[readable_file.index(" Opponent")+1]
  130.  
  131. Savedrnddiff = readable_file[readable_file.index(" round diff")+1]
  132. Savedkddiff = readable_file[readable_file.index(" k-d diff")+1]
  133. Savedfkfddiff = readable_file[readable_file.index(" fk-fd diff")+1]
  134.  
  135. global Saved
  136. Saved = [
  137. Savedtname,
  138. Savedtscore,
  139. Savedtfkfddiff,
  140. Savedtfk,
  141. Savedtfd,
  142. Savedtk,
  143. Savedtd,
  144. Savedta,
  145. Savedtkd,
  146.  
  147. SavedM,
  148.  
  149. Savedokd,
  150. Savedoa,
  151. Savedod,
  152. Savedok,
  153. Savedofd,
  154. Savedofk,
  155. Savedofkfddiff,
  156. Savedoscore,
  157. Savedoname,
  158.  
  159. Savedrnddiff,
  160. Savedkddiff,
  161. Savedfkfddiff
  162. ]
  163.  
  164. for y in range(len(Saved)):
  165. for x in range(len(remove)):
  166. Saved[y] = Saved[y].replace(remove[x], "")
  167.  
  168. Saved[y] = Saved[y].split(",")
  169. if debug:
  170. print("\n",Saved[y])
  171.  
  172. for x in range(len(Saved)):
  173. for y in range(len(Saved[x])):
  174. try:
  175. Saved[x][y] = float(Saved[x][y])
  176. except ValueError:
  177. pass
  178. if debug:
  179. print("\n",Saved[x])
  180.  
  181.  
  182.  
  183. #Calculate Event stats (mainly for teams now, idk if it works for events still) is for compiling team or even data 👍
  184. def Calculate_Event_stats(VCT_event:str, #(slight lie 💀)
  185. print_response_code:bool = False, #prints the response code of VLR to check if the website is available
  186. debug:bool = False, #prints compiled data in the terminal
  187. aom = 10, #ammount of matches: the ammount of matchlinks used in compiling
  188. VCTOnly:bool = False, #TODO:Fix this
  189. FranchiseOnly:bool = False): #TODO: Fix this too 😮‍💨
  190.  
  191. global links_used
  192. links_used += 1
  193. event = VCT_event
  194. eventcheck1 = event.split("-")
  195. eventcheck2 = event.split("/")
  196.  
  197. playoffs = False
  198. check = "/vct"
  199. team = False
  200.  
  201. if "team" in eventcheck1 or eventcheck2: #checks for the subfix "team" in the link which then tells the programm to compile team data
  202. if "matches" not in eventcheck2: #to even compile team data we need the matches suffix inserted into the link to even extract the matches from the individual match links
  203. event = event.replace("team/","team/matches/")
  204. eventcheck2 = event.split("/")
  205. if debug:
  206. print(event)
  207.  
  208. selectedTeam = eventcheck2[6] #to tell in a later comparison on what side the program should put the data
  209.  
  210. Team_File = f"Team-Files/{selectedTeam}-data.txt"
  211.  
  212. file_exists = False
  213.  
  214. try:
  215. Team_File = open(Team_File,"x")
  216. except FileExistsError:
  217. extract_file_data(Team_File)
  218. file_exists = True
  219. Team_File = open(Team_File,"w")
  220.  
  221.  
  222. if selectedTeam == "varrel": #checks if selected team has undergone changes, wont be needed unless "Core=All" is in the link
  223. second = "slt-seongnam"
  224. elif selectedTeam == "eternal-fire":
  225. second = "ulf-esport"
  226. else:
  227. second = ""
  228.  
  229. if debug:
  230. print(selectedTeam)
  231. check = "/stats"
  232. team = True
  233. #print("hi")
  234. elif "kickoff" or "playoffs" in eventcheck1 or eventcheck2: #TODO: Actually make the statement correct
  235. playoffs = True
  236. event =f"https://www.vlr.gg/event/matches/{eventcheck2[4]}/{eventcheck2[5]}"
  237.  
  238. #print(playoffs)
  239. Matches = []
  240. def fetchinfo(eventormatchlink:str):
  241.  
  242. global links_used
  243.  
  244. links_used += 1
  245. response = requests.get(eventormatchlink)
  246.  
  247. time.sleep(1)
  248.  
  249. if print_response_code:
  250. print("VLR status code: ",response.status_code)
  251. if str(response.status_code) == "404":
  252. print("site not found")
  253. quit()
  254. site = response.text
  255.  
  256. soup = BeautifulSoup(site, "html.parser")
  257.  
  258. Http = str(soup.find_all('a'))
  259. # ⬇️ makes it simpler for the code to find all match links (or at least it should :P)
  260. Http = Http.replace('href',"match-here ")
  261. Http = Http.replace("<"," ")
  262. Http = Http.replace(">"," ")
  263. Http = Http.replace('https'," not ")
  264. Http = Http.replace("/team/", " not ")
  265. Http = Http.replace("/event/"," not ")
  266. Http = Http.replace("/player/", " not ")
  267. Http = Http.replace("mailto"," not ")
  268. Http = Http.replace("/privacy"," not ")
  269. Http = Http.replace("/terms"," not ")
  270. Http = Http.replace("/login"," not")
  271. Http = Http.replace('"',"")
  272. Http = Http.replace("=","")
  273. Http = Http.replace("/standings"," /standings")
  274. Http = Http.replace("/vct","/vct ")
  275. if team:
  276. Http=Http.replace("/?game"," ")
  277. Http = Http.split()
  278.  
  279. x = 0
  280.  
  281.  
  282.  
  283. try:
  284. for x in range(len(Http)):
  285. index = Http.index("match-here")
  286. if Http[index+1] == "not":
  287. Http.pop(index)
  288. else:
  289. Matches.append(Http[index+1])
  290. Http.pop(index)
  291. except ValueError:
  292. pass
  293.  
  294. if debug:
  295. print(Matches)
  296. page = 1
  297. link = event.replace(eventcheck2[6],f"{eventcheck2[6]}/?page={page}")
  298. if team and aom == 0:
  299. if debug:
  300. print(link,"\n")
  301. idk = requests.get(link)
  302. time.sleep(1)
  303. idk = BeautifulSoup(idk.text,"html.parser")
  304. idk = str(idk.find_all(name="a"))
  305. idk = idk.replace("?page="," check-here ")
  306. idk = idk.replace('">', ' ">')
  307. idk = idk.split()
  308. if debug:
  309. print(idk)
  310. while True:
  311. try:
  312. checks = idk.index("check-here")
  313. idk.pop(checks)
  314. current = checks
  315. except ValueError:
  316. try:
  317. maxpages = int(idk[current])
  318. if debug:
  319. print(maxpages)
  320. break
  321. except ValueError:
  322. maxpages = 1
  323. break
  324. while page-1 != maxpages:
  325. link = event.replace(eventcheck2[6],f"{eventcheck2[6]}/?page={page}")
  326. if debug:
  327. print(link,"\n")
  328.  
  329. fetchinfo(link)
  330. page += 1
  331. else:
  332. fetchinfo(event)
  333. current = Matches.index(check) + 4
  334. if debug:
  335. print(f"Matches = {Matches}")
  336.  
  337. def sort_matches(links:list):
  338. list_ = links
  339. to_be_sorted = []
  340. extra = 0
  341. if debug:
  342. print(f"list_ = \n{list_}")
  343. for x in range(len(links)):
  344. current = str(list_[x])
  345. current = current.replace("/"," ")
  346. current = current.split()
  347. while "" in current:
  348. current.remove("")
  349. to_be_sorted.append(current)
  350. try:
  351. match_id = int(to_be_sorted[x].pop(2))
  352. to_be_sorted[x].insert(2,match_id)
  353. except IndexError:
  354. to_be_sorted.pop(x-extra)
  355. extra +=1
  356. except ValueError:
  357. to_be_sorted.pop(x-extra)
  358. extra +=1
  359. if debug:
  360. print(to_be_sorted)
  361.  
  362.  
  363. def quick_sort(arr):
  364. if len(arr) <= 1:
  365. return arr
  366. pivot = arr[0]
  367. left = [x for x in arr[1:] if x < pivot]
  368. right = [x for x in arr[1:] if x >= pivot]
  369. return quick_sort(left) + [pivot] + quick_sort(right)
  370.  
  371. to_be_sorted2 = []
  372. for x in range(len(to_be_sorted)):
  373. to_be_sorted2.append(to_be_sorted[x][2])
  374. sorted_list2 = quick_sort(to_be_sorted2)
  375. if debug:
  376. print(f"sorted_list2= {sorted_list2}")
  377. sorted_list = []
  378. try:
  379. for x in range(len(sorted_list2)):
  380. for y in range(len(to_be_sorted)):
  381. if to_be_sorted[y][2] == sorted_list2[x]:
  382. sorted_list.append(f"{to_be_sorted[y][0]}//{to_be_sorted[y][1]}/{to_be_sorted[y][2]}/{to_be_sorted[y][3]}")
  383. except IndexError:
  384. pass
  385. if debug:
  386. print(sorted_list)
  387. return sorted_list
  388.  
  389. Forbidden = [
  390. "/",
  391. "/threads",
  392. "/matches",
  393. "/events",
  394. "/stats",
  395. "/rankings",
  396. "/target_blank",
  397. "/History",
  398. "target_blank",
  399. "History"
  400. ]
  401. for x in range(len(Forbidden)):
  402. while Forbidden[x] in Matches:
  403. if debug:
  404. print(Matches.index(Forbidden[x]))
  405. print(Matches[Matches.index(Forbidden[x])])
  406. Matches.remove(Forbidden[x])
  407.  
  408. Full_Match_Links= []
  409. for x in range(len(Matches)-1):
  410. if Matches[x+1] == "/vct":
  411. pass
  412. else:
  413. Full_Match_Links.append(f"https://www.vlr.gg{Matches[x+1]}")
  414.  
  415. Full_Match_Links = sort_matches(Full_Match_Links)
  416.  
  417.  
  418. n = len(Full_Match_Links)
  419. y = 1
  420. for x in range(n):
  421. try:
  422. current_Link = Full_Match_Links[x]
  423. while current_Link == Full_Match_Links[y]:
  424. Full_Match_Links.pop(y)
  425. y+=1
  426. except IndexError:
  427. break
  428. if debug:
  429. print(Full_Match_Links)
  430.  
  431.  
  432. winner_info = ["win:"]
  433. loser_info = ["lose:"]
  434. general_info = []
  435. runs = []
  436.  
  437. #extracts general match info (score, team names, maps played)
  438. def extract_match_info(matchlink:str):
  439. global links_used
  440.  
  441. links_used += 1
  442.  
  443. team1_kills = []
  444. team1_first_kills = []
  445. team2_kills = []
  446. team2_first_kills = []
  447.  
  448. team1_deaths = []
  449. team1_first_deaths = []
  450. team2_deaths = []
  451. team2_first_deaths = []
  452.  
  453. team1_assists = []
  454. team2_assists = []
  455.  
  456. #extract performance info takes "all" player stats from both teams and adds them together for each team 😋
  457. def extract_performance_info(matchlink):
  458. global links_used
  459.  
  460. links_used += 1
  461.  
  462. web = requests.get(matchlink)
  463. time.sleep(1)
  464. rweb = BeautifulSoup(web.text, "html.parser")
  465.  
  466. eweb = str(rweb)
  467. eweb = eweb.replace('"',' ')
  468. eweb = eweb.replace("<"," ")
  469. eweb = eweb.replace(">"," ")
  470. eweb = eweb.replace("e m","e-m")
  471. eweb = eweb.replace("t m","t-m")
  472. eweb = eweb.replace("side-mod-both", " check-here")
  473. eweb = eweb.split()
  474.  
  475. available_data = True
  476. try:
  477. indexidk = eweb.index("vm-stats-game-mod-active")
  478. if debug:
  479. print(indexidk)
  480. wiped = 0
  481. while wiped!= indexidk:
  482. eweb.pop(0)
  483. wiped += 1
  484. except ValueError:
  485. available_data = False
  486.  
  487. for x in range(10):
  488. for y in range(2):
  489. if available_data:
  490. check_index = eweb.index("check-here")
  491. if debug:
  492. print("popped from:\n",eweb[check_index-4],eweb[check_index-3],eweb[check_index-2],eweb[check_index-1],eweb[check_index],eweb[check_index+1],eweb[check_index+2],eweb[check_index+3],eweb[check_index+4])
  493. eweb.pop(check_index)
  494.  
  495. for y in range(3):
  496. if available_data:
  497. check_index = eweb.index("check-here")
  498. data = eweb[check_index+1]
  499. if data == "/span":
  500. if debug:
  501. print("added from:\n",eweb[check_index-4],eweb[check_index-3],eweb[check_index-2],eweb[check_index-1],eweb[check_index],eweb[check_index+1],eweb[check_index+2],eweb[check_index+3],eweb[check_index+4])
  502.  
  503. data = 0
  504. eweb.pop(check_index)
  505. else:
  506. data = 0
  507. if x < 5:
  508. if y == 0:
  509. team1_kills.append(data)
  510. elif y == 1:
  511. team1_deaths.append(data)
  512. else:
  513. team1_assists.append(data)
  514. else:
  515. if y == 0:
  516. team2_kills.append(data)
  517. elif y == 1:
  518. team2_deaths.append(data)
  519. else:
  520. team2_assists.append(data)
  521.  
  522. for y in range(4):
  523. if available_data:
  524. check_index = eweb.index("check-here")
  525. if debug:
  526. print("popped from:\n",eweb[check_index-4],eweb[check_index-3],eweb[check_index-2],eweb[check_index-1],eweb[check_index],eweb[check_index+1],eweb[check_index+2],eweb[check_index+3],eweb[check_index+4])
  527. eweb.pop(check_index)
  528.  
  529. for y in range(2):
  530. if available_data:
  531. check_index = eweb.index("check-here")
  532. data = eweb[check_index+1]
  533. if data == "/span":
  534. if debug:
  535. print("added from:\n",eweb[check_index-4],eweb[check_index-3],eweb[check_index-2],eweb[check_index-1],eweb[check_index],eweb[check_index+1],eweb[check_index+2],eweb[check_index+3],eweb[check_index+4])
  536.  
  537. data = 0
  538. eweb.pop(check_index)
  539. else:
  540. data = 0
  541. if x < 5:
  542. if y == 0:
  543. team1_first_kills.append(data)
  544. else:
  545. team1_first_deaths.append(data)
  546. else:
  547. if y == 0:
  548. team2_first_kills.append(data)
  549. else:
  550. team2_first_deaths.append(data)
  551. if available_data:
  552. check_index = eweb.index("check-here")
  553. if debug:
  554. print("popped from:\n",eweb[check_index-4],eweb[check_index-3],eweb[check_index-2],eweb[check_index-1],eweb[check_index],eweb[check_index+1],eweb[check_index+2],eweb[check_index+3],eweb[check_index+4])
  555. eweb.pop(check_index)
  556.  
  557. if debug:
  558. print(team1_kills,"\n",team1_deaths,"\n",team1_assists,"\n",team1_first_kills,"\n",team1_first_deaths)
  559. print("")
  560. print(team2_kills,"\n",team2_deaths,"\n",team2_assists,"\n",team2_first_kills,"\n",team2_first_deaths)
  561.  
  562. extract_performance_info(matchlink)
  563.  
  564. mi = requests.get(matchlink) #mi = match info
  565. time.sleep(1)
  566. rmi = mi.text # rmi = readable match info
  567.  
  568. emi = BeautifulSoup(rmi,"html.parser")
  569. mmi = str(emi.find_all("span"))
  570. emi = str(emi.find_all("div"))
  571. emi = emi.replace(" ","-")
  572. emi = emi.replace("score-mod-win","score")
  573. emi = emi.replace("<"," ")
  574. emi = emi.replace(">"," ")
  575. emi= emi.replace('"'," ")
  576. emi = emi.replace("vm-stats-","vm-stats ")
  577.  
  578. mmi = mmi.replace(" ","-")
  579. mmi = mmi.replace("<"," ")
  580. mmi = mmi.replace(">"," ")
  581. mmi= mmi.replace('"'," ")
  582.  
  583. mmi = mmi.split()
  584. emi = emi.split()
  585.  
  586. team1_info = []
  587. team2_info = []
  588. map_info = []
  589. for x in range(5):
  590. try:
  591. team1_score_index = emi.index("score") +2
  592. emi.pop(team1_score_index-2)
  593. team1_score = emi[team1_score_index]
  594. team1_score = float(team1_score.replace("-",""))
  595.  
  596. team1_team_index =emi.index("team-name")
  597. emi.pop(team1_team_index)
  598. team1_team = emi[team1_team_index]
  599.  
  600. map_index = mmi.index("position:-relative;")
  601. mmi.pop(map_index)
  602. map_played = mmi[map_index]
  603.  
  604. team2_score_index = emi.index("score") +2
  605. emi.pop(team2_score_index-2)
  606. team2_score = float(emi[team2_score_index])
  607.  
  608. team2_team_index = emi.index("team-name")
  609. emi.pop(team2_team_index)
  610. team2_team = emi[team2_team_index]
  611.  
  612. if x == 0:
  613. team1_info.append(team1_team)
  614. team2_info.append(team2_team)
  615. team1_info.append(team1_score)
  616. team2_info.append(team2_score)
  617. map_info.append(map_played)
  618.  
  619. if debug:
  620. print(team1_score)
  621. print(team1_team)
  622. print(team2_score)
  623. print(team2_team)
  624. except ValueError:
  625. break
  626. team1_tk = 0
  627. team1_td = 0
  628. team1_ta = 0
  629. team1_tfk = 0
  630. team1_tfd = 0
  631.  
  632. team2_tk = 0
  633. team2_td = 0
  634. team2_ta = 0
  635. team2_tfk = 0
  636. team2_tfd = 0
  637. for x in range(5):
  638. team1_tk += float(team1_kills[x])
  639. team1_td += float(team1_deaths[x])
  640. team1_ta += float(team1_assists[x])
  641. team1_tfk += float(team1_first_kills[x])
  642. team1_tfd += float(team1_first_deaths[x])
  643.  
  644. team2_tk += float(team2_kills[x])
  645. team2_td += float(team2_deaths[x])
  646. team2_ta += float(team2_assists[x])
  647. team2_tfk += float(team2_first_kills[x])
  648. team2_tfd += float(team2_first_deaths[x])
  649.  
  650. if debug:
  651. print(team1_tk,"\n",team1_td,"\n",team1_ta,"\n",team1_tfk,"\n",team1_tfd)
  652. print("")
  653. print(team2_tk,"\n",team2_td,"\n",team2_ta,"\n",team2_tfk,"\n",team2_tfd)
  654. print(team1_info)
  655.  
  656. team2_total_score = 0
  657. team1_total_score = 0
  658. runs.append("1")
  659. for x in range(len(map_info)):
  660. team1_total_score += team1_info[x+1]
  661. team2_total_score += team2_info[x+1]
  662. try:
  663. team1 = team1_info[0]
  664. team1 = team1.replace(".","-")
  665. except IndexError:
  666. pass
  667.  
  668. if team == False:
  669. team1w = 0
  670. team2w = 0
  671. for x in range(len(map_info)):
  672. if team1_info[x+1] > team2_info[x+1]:
  673. team1w += 1
  674. else:
  675. team2w += 1
  676. if team1w > team2w:
  677. winner_info.append(team1_info[0])
  678. winner_info.append(team1_total_score)
  679. winner_info.append([team1_tk,
  680. team1_td,
  681. team1_ta,
  682. team1_tfk,
  683. team1_tfd])
  684. loser_info.append(team2_info[0])
  685. loser_info.append(team2_total_score)
  686. loser_info.append( [team2_tk,
  687. team2_td,
  688. team2_ta,
  689. team2_tfk,
  690. team2_tfd])
  691. else:
  692. winner_info.append(team2_info[0])
  693. winner_info.append(team2_total_score)
  694. winner_info.append( [team2_tk,
  695. team2_td,
  696. team2_ta,
  697. team2_tfk,
  698. team2_tfd])
  699. loser_info.append(team1_info[0])
  700. loser_info.append(team1_total_score)
  701. loser_info.append([team1_tk,
  702. team1_td,
  703. team1_ta,
  704. team1_tfk,
  705. team1_tfd])
  706. else:
  707. try:
  708. if team1.lower() == selectedTeam.lower() or team1.lower() == second.lower():
  709. #print("team1.lower = selectedteam.lower")
  710. winner_info.append(team1_info[0])
  711. winner_info.append(team1_total_score)
  712. winner_info.append([team1_tk,
  713. team1_td,
  714. team1_ta,
  715. team1_tfk,
  716. team1_tfd])
  717. loser_info.append(team2_info[0])
  718. loser_info.append(team2_total_score)
  719. loser_info.append( [team2_tk,
  720. team2_td,
  721. team2_ta,
  722. team2_tfk,
  723. team2_tfd])
  724. else:
  725. #print("team1.lower != selectedteam.lower")
  726. winner_info.append(team2_info[0])
  727. winner_info.append(team2_total_score)
  728. winner_info.append( [team2_tk,
  729. team2_td,
  730. team2_ta,
  731. team2_tfk,
  732. team2_tfd])
  733. loser_info.append(team1_info[0])
  734. loser_info.append(team1_total_score)
  735. loser_info.append([team1_tk,
  736. team1_td,
  737. team1_ta,
  738. team1_tfk,
  739. team1_tfd])
  740. except IndexError:
  741. pass
  742. except UnboundLocalError:
  743. pass
  744. general_info.append(len(map_info))
  745. general_info.append(" ")
  746. general_info.append(" ")
  747.  
  748. y = 0
  749. z = 0
  750. use_links = []
  751. if aom == 0:
  752. run = len(Full_Match_Links)
  753. else:
  754. run = aom
  755.  
  756. def what(current_match):
  757. checking = True
  758. comparing = True
  759.  
  760. checkfor = [
  761. ["vct", 1],
  762. ["masters",2],
  763. ["champions",1]
  764. ]
  765. check=currentmatch.split("-")
  766. z = 0
  767. while comparing:
  768. try:
  769. if checkfor[z][0] in check:
  770. if "ascension" in check:
  771. pass
  772. else:
  773. no_vct = False
  774.  
  775. # if FranchiseOnly:
  776. # print(check)
  777. # extra = 0
  778. # if check[check.index(checkfor[z][0])+checkfor[z][1]] == "tour":
  779. # extra = 1
  780. # if int(check[check.index(checkfor[z][0])+checkfor[z][1]+ extra]) >= 2023:
  781.  
  782. # if debug:
  783. # print(currentmatch)
  784. # checking = False
  785. # comparing = False
  786. # use_links.append(currentmatch)
  787. #else:
  788. if debug:
  789. print(currentmatch)
  790. checking = False
  791. comparing = False
  792. use_links.append(currentmatch)
  793. else:
  794. no_vct = True
  795. z += 1
  796. except IndexError:
  797. #print("comparing index error")
  798. comparing = False
  799. no_vct = True
  800. if no_vct:
  801. pass
  802.  
  803. for x in range(run):
  804. try:
  805. currentmatch = Full_Match_Links[len(Full_Match_Links)-x]
  806. if VCTOnly:
  807. what(currentmatch)
  808. else:
  809. use_links.append(currentmatch)
  810. except IndexError:
  811. print("here")
  812.  
  813. usedmatches = 0
  814. for x in range(len(use_links)):
  815. if team:
  816. if file_exists and use_links[x] == Savedlink:
  817. print("ended extraction")
  818. break
  819. if debug:
  820. print(use_links[x])
  821. extract_match_info(use_links[x])
  822. usedmatches += 1
  823.  
  824. y= 0
  825. winners = []
  826. score_w = []
  827. fk_w = []
  828. fd_w = []
  829. fkfd_diff_w =[]
  830. kills_w = []
  831. deaths_w = []
  832. assists_w = []
  833. kd_diff_w = []
  834. kd_diff_l = []
  835. assists_l = []
  836. deaths_l = []
  837. kills_l = []
  838. fkfd_diff_l =[]
  839. fk_l = []
  840. fd_l = []
  841. score_l = []
  842. losers = []
  843. maps = []
  844. diffl = []
  845. kd_diff = []
  846. fkfd_diff = []
  847.  
  848. mainlists = [
  849. winners,
  850. score_w,
  851. fkfd_diff_w,
  852. fk_w,
  853. fd_w,
  854. kills_w,
  855. deaths_w,
  856. assists_w,
  857. kd_diff_w ,
  858.  
  859. maps,
  860.  
  861. kd_diff_l,
  862. assists_l,
  863. deaths_l,
  864. kills_l,
  865. fk_l,
  866. fd_l,
  867. fkfd_diff_l,
  868. score_l,
  869. losers,
  870.  
  871. diffl,
  872. kd_diff,
  873. fkfd_diff
  874. ]
  875.  
  876.  
  877.  
  878. if aom == 0:
  879. run = len(runs)
  880. if file_exists:
  881. run = usedmatches
  882. else:
  883. run = aom - 1
  884. for x in range(run):
  885. try:
  886.  
  887. winners.append(winner_info[y+1])
  888. score_w.append(winner_info[y+2])
  889. fk_w.append(winner_info[y+3][3])
  890. fd_w.append(winner_info[y+3][4])
  891. kills_w.append(winner_info[y+3][0])
  892. deaths_w.append(winner_info[y+3][1])
  893. assists_w.append(winner_info[y+3][2])
  894. maps.append(general_info[y])
  895. assists_l.append(loser_info[y+3][2])
  896. deaths_l.append(loser_info[y+3][1])
  897. kills_l.append(loser_info[y+3][0])
  898. fd_l.append(loser_info[y+3][4])
  899. fk_l.append(loser_info[y+3][3])
  900. score_l.append(loser_info[y+2])
  901. losers.append(loser_info[y+1])
  902.  
  903. diff = score_w[x] - score_l[x]
  904. diffl.append(diff)
  905.  
  906. kddiff_w = kills_w[x]-deaths_w[x]
  907. kd_diff_w.append(kddiff_w)
  908.  
  909. kddiff_l = kills_l[x]-deaths_l[x]
  910. kd_diff_l.append(kddiff_l)
  911.  
  912. kddiff = kd_diff_w[x]-kd_diff_l[x]
  913. kd_diff.append(kddiff)
  914.  
  915. fkfddiffw = fk_w[x]-fd_w[x]
  916. fkfd_diff_w.append(fkfddiffw)
  917.  
  918. fkfddiffl = fk_l[x]-fd_l[x]
  919. fkfd_diff_l.append(fkfddiffl)
  920.  
  921. fkfddiff = fkfd_diff_w[x] - fkfd_diff_l[x]
  922. fkfd_diff.append(fkfddiff)
  923.  
  924. y+=3
  925. except IndexError:
  926. break
  927.  
  928. if file_exists:
  929. for x in range(len(mainlists)):
  930. for y in range(len(Saved[x])-2):
  931. mainlists[x].append(Saved[x][y])
  932.  
  933. winner_total_score = 0
  934. loser_total_score =0
  935. maps_total = 0
  936. diff_total = 0
  937. w_kills_total = 0
  938. w_deaths_total = 0
  939. w_assists_total = 0
  940. w_fk_total = 0
  941. w_fd_total = 0
  942. l_kills_total = 0
  943. l_deaths_total = 0
  944. l_assists_total = 0
  945. l_fk_total = 0
  946. l_fd_total = 0
  947. kd_diff_total = 0
  948. fkfd_diff_total = 0
  949.  
  950. if file_exists:
  951. winner_total_score = Saved[1][11]
  952. w_fk_total = Saved[3][11]
  953. w_fd_total = Saved[4][11]
  954. w_kills_total = Saved[5][11]
  955. w_deaths_total = Saved[6][11]
  956. w_assists_total = Saved[7][11]
  957.  
  958. maps_total = Saved[9][11]
  959.  
  960. l_kills_total = Saved[13][11]
  961. l_deaths_total = Saved[12][11]
  962. l_assists_total = Saved[11][11]
  963. l_fk_total = Saved[14][11]
  964. l_fd_total = Saved[13][11]
  965. loser_total_score = Saved[17][11]
  966.  
  967. diff_total = Saved[19][11]
  968. kd_diff_total = Saved[20][11]
  969. fkfd_diff_total = Saved[21][11]
  970.  
  971. for x in range(usedmatches):
  972. try:
  973. winner_total_score += score_w[x]
  974. loser_total_score += score_l[x]
  975. maps_total += maps[x]
  976. diff_total += diffl[x]
  977. w_kills_total += kills_w[x]
  978. w_deaths_total += deaths_w[x]
  979. w_assists_total += assists_w[x]
  980. w_fk_total += fk_w[x]
  981. w_fd_total += fd_w[x]
  982. l_kills_total += kills_l[x]
  983. l_deaths_total += deaths_l[x]
  984. l_assists_total += assists_l[x]
  985. l_fk_total += fk_l[x]
  986. l_fd_total += fd_l[x]
  987. kd_diff_total += kd_diff[x]
  988. fkfd_diff_total += fkfd_diff[x]
  989.  
  990. except IndexError:
  991. break
  992. else:
  993. for x in range(run):
  994. try:
  995. winner_total_score += score_w[x]
  996. loser_total_score += score_l[x]
  997. maps_total += maps[x]
  998. diff_total += diffl[x]
  999. w_kills_total += kills_w[x]
  1000. w_deaths_total += deaths_w[x]
  1001. w_assists_total += assists_w[x]
  1002. w_fk_total += fk_w[x]
  1003. w_fd_total += fd_w[x]
  1004. l_kills_total += kills_l[x]
  1005. l_deaths_total += deaths_l[x]
  1006. l_assists_total += assists_l[x]
  1007. l_fk_total += fk_l[x]
  1008. l_fd_total += fd_l[x]
  1009. kd_diff_total += kd_diff[x]
  1010. fkfd_diff_total += fkfd_diff[x]
  1011.  
  1012. except IndexError:
  1013. break
  1014.  
  1015. for x in range(12):
  1016. winners.insert(10+x," ")
  1017. score_w.insert(10+x," ")
  1018.  
  1019. fkfd_diff_w.insert(10+x, " ") # i tunnel visioned on this
  1020.  
  1021. fk_w.insert(10+x," ")
  1022. fd_w.insert(10+x," ")
  1023. kills_w.insert(10+x," ")
  1024. deaths_w.insert(10+x," ")
  1025. assists_w.insert(10+x," ")
  1026.  
  1027. kd_diff_w.insert(10+x," ") #this was missing
  1028.  
  1029. maps.insert(10+x," ")
  1030. fkfd_diff_l.insert(10+x," ")
  1031. fk_l.insert(10+x," ")
  1032. fd_l.insert(10+x," ")
  1033. kills_l.insert(10+x," ")
  1034. deaths_l.insert(10+x," ")
  1035. assists_l.insert(10+x," ")
  1036. score_l.insert(10+x," ")
  1037. losers.insert(10+x," ")
  1038. diffl.insert(10+x," ")
  1039. kd_diff.insert(10+x," ")
  1040. fkfd_diff.insert(10+x," ")
  1041. score_w.insert(11,winner_total_score)
  1042. maps.insert(11,maps_total)
  1043. score_l.insert(11,loser_total_score)
  1044. diffl.insert(11,diff_total)
  1045. fk_w.insert(11,w_fk_total)
  1046. fd_w.insert(11,w_fd_total)
  1047. kills_w.insert(11,w_kills_total)
  1048. deaths_w.insert(11,w_deaths_total)
  1049. assists_w.insert(11,w_assists_total)
  1050. fk_l.insert(11,l_fk_total)
  1051. fd_l.insert(11,l_fd_total)
  1052. kills_l.insert(11,l_kills_total)
  1053. deaths_l.insert(11,l_deaths_total)
  1054. assists_l.insert(11,l_assists_total)
  1055. kd_diff.insert(11,kd_diff_total)
  1056. fkfd_diff.insert(11,fkfd_diff_total)
  1057.  
  1058. fitwinner= []
  1059. fitwinnerscore=[]
  1060. fitwfkfddiff = []
  1061. fitwfk = []
  1062. fitwfd = []
  1063. fitwk = []
  1064. fitwd = []
  1065. fitwa = []
  1066. fitwkddiff = []
  1067.  
  1068. fitmaps=[]
  1069.  
  1070. fitlkddiff = []
  1071. fitla = []
  1072. fitld = []
  1073. fitlk = []
  1074. fitlfd = []
  1075. fitlfk = []
  1076. fitlfkfddiff = []
  1077. fitlosertscore=[]
  1078. fitloser =[]
  1079.  
  1080. fitdiff =[]
  1081. fitkddiff = []
  1082. fitfkfddiff = []
  1083.  
  1084. for x in range(12):
  1085. try:
  1086. fitwinner.insert(x,winners[x])
  1087. fitwinnerscore.insert(x,score_w[x])
  1088. fitwfkfddiff.insert(x,fkfd_diff_w[x])
  1089. fitwfk.insert(x,fk_w[x])
  1090. fitwfd.insert(x,fd_w[x])
  1091. fitwk.insert(x,kills_w[x])
  1092. fitwd.insert(x,deaths_w[x])
  1093. fitwa.insert(x,assists_w[x])
  1094. fitwkddiff.insert(x,kd_diff_w[x])
  1095.  
  1096. fitmaps.insert(x,maps[x])
  1097.  
  1098. fitlkddiff.insert(x,fkfd_diff_l[x])
  1099. fitla.insert(x,assists_l[x])
  1100. fitld.insert(x,deaths_l[x])
  1101. fitlk.insert(x,kills_l[x])
  1102. fitlfd.insert(x,fd_l[x])
  1103. fitlfk.insert(x,fk_l[x])
  1104. fitlfkfddiff.insert(x,fkfd_diff_l[x])
  1105. fitlosertscore.insert(x,score_l[x])
  1106. fitloser.insert(x,losers[x])
  1107.  
  1108. fitdiff.insert(x,diffl[x])
  1109. fitkddiff.insert(x,kd_diff[x])
  1110. fitfkfddiff.insert(x,fkfd_diff[x])
  1111. except IndexError:
  1112. break
  1113.  
  1114. if team == False:
  1115. data = {
  1116. "winner": fitwinner,
  1117. "winner-score": fitwinnerscore,
  1118. "maps-played": fitmaps,
  1119. "loser-score": fitlosertscore,
  1120. "loser": fitloser,
  1121. "diff": fitdiff
  1122. }
  1123. else:
  1124. data = {
  1125. "Team": fitwinner,
  1126. "Team score": fitwinnerscore,
  1127. "Team fk-fd": fitwfkfddiff,
  1128. "Team fk": fitwfk,
  1129. "Team fd": fitwfd,
  1130. "Team Kills": fitwk,
  1131. "Team Deaths": fitwd,
  1132. "Team Assists": fitwa,
  1133. "Team Kill-Death": fitwkddiff,
  1134.  
  1135. "maps played": fitmaps,
  1136.  
  1137. "Opponent Kill-Death": fitlkddiff,
  1138. "Opponent Assists": fitla,
  1139. "Opponent Deaths": fitld,
  1140. "Opponent Kills": fitlk,
  1141. "Opponent fd": fitlfd,
  1142. "Opponent fk": fitlfk,
  1143. "Opponent fk-fd":fitlfkfddiff,
  1144. "Opponent score": fitlosertscore,
  1145. "Opponent": fitloser,
  1146. " " : " ",
  1147. "round diff": fitdiff,
  1148. "k-d diff": fitkddiff,
  1149. "fk-fd diff": fitfkfddiff
  1150. }
  1151.  
  1152. Vctdata = pandas.DataFrame(data
  1153. ,index= [1,2,3,4,5,6,7,8,9,10," ","Total"])
  1154. print("\n\n",Vctdata,"\n\n")
  1155. all_data.append([Vctdata,diff_total])
  1156.  
  1157.  
  1158. if team:
  1159. write_data = str(data)
  1160. write_data = write_data.replace("{", "")
  1161. write_data = write_data.replace("}","")
  1162. write_data = write_data.replace("],","] :\n")
  1163. Team_File.write(f"lastLink: {use_links[0]}:\n{write_data}")
  1164. Team_File.close()
  1165.  
  1166.  
  1167. t = 0
  1168.  
  1169. # Calculate_Event_stats("https://www.vlr.gg/team/2593/fnatic",debug=True, aom=0)
  1170.  
  1171.  
  1172.  
  1173. start = default_timer()
  1174.  
  1175.  
  1176.  
  1177. # for x in range(len(VCT_TEAMS)):
  1178. # Calculate_Event_stats(VCT_TEAMS[x],aom=0)
  1179.  
  1180.  
  1181.  
  1182.  
  1183.  
  1184.  
  1185. if __name__ == "__main__":
  1186. with multiprocessing.Pool() as pool:
  1187. #use max number of cores to run processes if you don't specify in Pool()
  1188. #keep returns both logical + physical cores
  1189. # can check yours using os.cpu_count(), fast af on some VPS
  1190. print(pool.map(Calculate_Event_stats, VCT_TEAMS))
  1191.  
  1192.  
  1193.  
  1194.  
  1195. #Dont run this⬇️
  1196.  
  1197. # test = []
  1198. # for x in range(len(VCT_TEAMS)):
  1199.  
  1200. # test.append(multiprocessing.Process(target=Calculate_Event_stats, args=(VCT_TEAMS[x], False, False, 0))) #adding a process for each VCT team
  1201.  
  1202. # test[0].start()
  1203.  
  1204.  
  1205.  
  1206. end = default_timer()
  1207.  
  1208. print(f"running the whole program took \n{end-start} seconds")
  1209.  
  1210. # redo = [
  1211. # "https://www.vlr.gg/team/2593/fnatic"
  1212.  
  1213.  
  1214. # ]
  1215. # start = default_timer()
  1216. # while t != len(redo):
  1217. # Calculate_Event_stats(redo[t],aom=0,debug=True)
  1218. # t+=1
  1219. # end = default_timer()
  1220. # print(f"running the whole program took \n{round(end-start,2)} seconds")
  1221.  
  1222. # sortts = []
  1223. # for x in range(len(all_data)):
  1224. # sortts.append(all_data[x][1])
  1225.  
  1226. # sorted_data = []
  1227.  
  1228. # sortts.sort()
  1229. # for x in range(len(sortts)):
  1230. # for y in range(len(all_data)):
  1231. # if sortts[x] == all_data[y][1]:
  1232. # sorted_data.append(all_data[y][0])
  1233.  
  1234. # Vctdataexcel = pandas.ExcelWriter("vct Data.xlsx")
  1235.  
  1236. # for x in range(len(sorted_data)):
  1237. # sorted_data[(len(sorted_data)-1)-x].to_excel(Vctdataexcel,startrow = (14*x))
  1238.  
  1239. # Vctdataexcel.close()
  1240.  
  1241. print(f"links used = {links_used}")
Advertisement
Add Comment
Please, Sign In to add comment