diff --git a/main.py b/main.py index a54fd33..5f472fe 100644 --- a/main.py +++ b/main.py @@ -337,17 +337,23 @@ def _get_matches_by_team(table): for row in rows[0:len(rows)]: match = {} - match['date'] = row.find( - "td", {"class": "date-cell"}).find("span").text + dateArr = (row.find( + "td", {"class": "date-cell"}).find("span").text).split('/') + + dateTextFromArrPadded = _padIfNeeded(dateArr[2]) + "-" + _padIfNeeded(dateArr[1]) + "-" + _padIfNeeded(dateArr[0]) + + dateFromHLTV = datetime.datetime.strptime(dateTextFromArrPadded,'%Y-%m-%d').replace(tzinfo=HLTV_ZONEINFO) + dateFromHLTV = dateFromHLTV.astimezone(LOCAL_ZONEINFO) + + date = dateFromHLTV.strftime('%Y-%m-%d') + match['date'] = date match['teams'] = {} match['teams']["team_1"] = row.find( "td", {"class": "team-center-cell"}).find("a", {"class": "team-name team-1"}).text - match['teams']["team_1_id"] = row.find( - "td", {"class": "team-center-cell"}).find("a", {"class": "team-name team-1"})['href'].split('/')[2] + match['teams']["team_1_id"] = _findTeamId(row.find( "td", {"class": "team-center-cell"}).find("a", {"class": "team-name team-1"}).text) match['teams']["team_2"] = row.find( "td", {"class": "team-center-cell"}).find("a", {"class": "team-name team-2"}).text - match['teams']["team_2_id"] = row.find( - "td", {"class": "team-center-cell"}).find("a", {"class": "team-name team-2"})['href'].split('/')[2] + match['teams']["team_2_id"] = _findTeamId(row.find( "td", {"class": "team-center-cell"}).find("a", {"class": "team-name team-2"}).text) match["confront_name"] = match['teams']["team_1"] + \ " X " + match['teams']["team_2"] match["championship"] = event_name @@ -355,7 +361,6 @@ def _get_matches_by_team(table): "td", {"class": "matchpage-button-cell"}).find("a")['href'] match['time'] = get_parsed_page("https://www.hltv.org" + match_url).find( 'div', {"class": "timeAndEvent"}).find('div', {"class": "time"}).text - match['full_time'] = match['date'] + ' at ' + match['time'] matches.append(match) return matches