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:
parent
5f7ed6ec31
commit
312c96c59d
1 changed files with 9 additions and 0 deletions
9
main.py
9
main.py
|
@ -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()
|
||||
|
|
Loading…
Add table
Reference in a new issue