mirror of
https://github.com/SocksPls/hltv-api
synced 2025-04-30 23:43:08 +00:00
chore(main): add countdown directly from date/time
This commit is contained in:
parent
5f7ed6ec31
commit
312c96c59d
1 changed files with 9 additions and 0 deletions
9
main.py
9
main.py
|
@ -182,6 +182,15 @@ def get_matches():
|
||||||
matchObj['url'] = "https://hltv.org" + getMatch.find("a", {"class": "match a-reset"}).get("href")
|
matchObj['url'] = "https://hltv.org" + getMatch.find("a", {"class": "match a-reset"}).get("href")
|
||||||
matchObj['time'] = getMatch.find("div", {"class": "matchTime"}).text
|
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"}):
|
if getMatch.find("div", {"class": "matchEvent"}):
|
||||||
matchObj['event'] = getMatch.find("div", {"class": "matchEvent"}).text.strip()
|
matchObj['event'] = getMatch.find("div", {"class": "matchEvent"}).text.strip()
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Add table
Reference in a new issue