2021-04-06 19:40:04 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
|
|
|
import json
|
|
|
|
import requests
|
|
|
|
import pytz
|
|
|
|
from datetime import datetime, timedelta
|
|
|
|
from pytz import timezone
|
|
|
|
|
|
|
|
print("```")
|
|
|
|
print(" _ _ ")
|
|
|
|
print(" _____ ___| |_ ___| |_ ___ ___ ")
|
|
|
|
print("| | .'| _| _| | -_|_ -|")
|
|
|
|
print("|_|_|_|__,|_| |___|_|_|___|___|")
|
|
|
|
print("```")
|
|
|
|
print("")
|
|
|
|
|
|
|
|
current_tz = timezone('US/Pacific')
|
|
|
|
|
|
|
|
def print_matches(match_list):
|
|
|
|
for match in match_list:
|
|
|
|
stars = int(match["stars"])
|
|
|
|
start_time = None;
|
|
|
|
star_rating = ""
|
|
|
|
title = match["event_name"]
|
|
|
|
if stars != 0:
|
|
|
|
title = title.split("-", 1)
|
|
|
|
if len(title) > 1:
|
|
|
|
title = "".join(title[1]).strip()
|
|
|
|
else:
|
|
|
|
title = "".join(title[0]).strip()
|
|
|
|
star_rating += "("
|
|
|
|
for i in range(stars):
|
|
|
|
star_rating += "★"
|
|
|
|
star_rating += ")"
|
|
|
|
else:
|
|
|
|
stars = ""
|
|
|
|
print("┏━━━━━━━━━━━")
|
|
|
|
print("## {} {}".format(title, star_rating))
|
|
|
|
|
|
|
|
if match["maps_won"] != []:
|
|
|
|
if match["rounds_won"] == []: # match is over
|
|
|
|
print(
|
|
|
|
"{} [{}] - [{}] {}".format(
|
|
|
|
match["team_names"][0],
|
|
|
|
match["maps_won"][0],
|
|
|
|
match["maps_won"][1],
|
|
|
|
match["team_names"][1],
|
|
|
|
)
|
|
|
|
)
|
|
|
|
print("FINAL")
|
|
|
|
else: # match is live
|
|
|
|
print(
|
|
|
|
"{} [{}({})]\nVS.\n{} [{}({})]".format(
|
|
|
|
match["team_names"][0],
|
|
|
|
match["rounds_won"][0],
|
|
|
|
match["maps_won"][0],
|
|
|
|
match["team_names"][1],
|
|
|
|
match["rounds_won"][1],
|
|
|
|
match["maps_won"][1],
|
|
|
|
)
|
|
|
|
)
|
|
|
|
print("⏺️ LIVE")
|
|
|
|
else: # match is upcoming, start time will always be an int here
|
|
|
|
start_time = int(match["start_time"]) // 1000 # convert ms unix time to normal
|
|
|
|
start_time = datetime.utcfromtimestamp(start_time)
|
|
|
|
start_time = pytz.utc.localize(start_time).astimezone(current_tz)
|
|
|
|
start_time = start_time.strftime("%I:%M %p")
|
|
|
|
print(
|
|
|
|
"{}\nVS.\n{}".format(
|
|
|
|
match["team_names"][0],
|
|
|
|
match["team_names"][1],
|
|
|
|
)
|
|
|
|
)
|
|
|
|
print("🕗 " + start_time)
|
|
|
|
print("┗━━━━━━━━━━━")
|
|
|
|
print("")
|
|
|
|
|
|
|
|
matches = json.loads(requests.get("https://illegaldrugs.net/skor").text)
|
|
|
|
updated_on = matches.pop(0)
|
|
|
|
live_matches = [ x for x in matches if x["start_time"] == "LIVE" ]
|
|
|
|
upcoming_matches = [ x for x in matches if x["start_time"] != "LIVE" and x["start_time"] != "OVER" ]
|
|
|
|
ended_matches = [ x for x in matches if x["start_time"] == "OVER" ]
|
|
|
|
|
2021-04-06 23:45:58 +00:00
|
|
|
|
2021-04-06 19:40:04 +00:00
|
|
|
if len(live_matches) != 0:
|
|
|
|
print("# LIVE")
|
|
|
|
print_matches(live_matches)
|
|
|
|
else:
|
|
|
|
print("# LIVE")
|
|
|
|
print("No live matches right now.\n")
|
|
|
|
if len(upcoming_matches) != 0:
|
|
|
|
print("# UPCOMING")
|
|
|
|
print_matches(upcoming_matches)
|
|
|
|
if len(ended_matches) != 0:
|
|
|
|
print("# COMPLETED")
|
|
|
|
print_matches(ended_matches)
|
|
|
|
|
2021-04-06 23:45:58 +00:00
|
|
|
print("=> ?reload Refresh match list (only use this if a match that should be live is still in \"upcoming\")")
|
|
|
|
|
2021-04-06 19:40:04 +00:00
|
|
|
print("Powered by sk0R")
|