1
0
Fork 0
mirror of https://github.com/SocksPls/hltv-api synced 2025-04-29 23:23:08 +00:00

chore(main): add countdown directly from date/time

This commit is contained in:
David Silva 2022-07-14 11:13:17 +02:00
parent 5f7ed6ec31
commit 312c96c59d

View file

@ -181,6 +181,15 @@ def get_matches():
matchObj['date'] = date
matchObj['url'] = "https://hltv.org" + getMatch.find("a", {"class": "match a-reset"}).get("href")
matchObj['time'] = getMatch.find("div", {"class": "matchTime"}).text
if (matchObj['date'] and matchObj['time']):
timenow = datetime.datetime.now().strftime('%Y-%m-%d %H:%M')
deadline = matchObj["date"] + " " + matchObj["time"]
start = datetime.datetime.strptime(timenow,'%Y-%m-%d %H:%M')
ends = datetime.datetime.strptime(deadline, '%Y-%m-%d %H:%M')
if start < ends:
matchObj['countdown'] = str(ends - start)
if getMatch.find("div", {"class": "matchEvent"}):
matchObj['event'] = getMatch.find("div", {"class": "matchEvent"}).text.strip()