From 87a31b524c792dca6e94d1dd586ee9c17d87e250 Mon Sep 17 00:00:00 2001 From: User Name Date: Wed, 28 Feb 2024 19:25:31 -0500 Subject: [PATCH] Fixed issue with some team not being valid. Hard coded end of day time. --- config/firstrun | 0 src/data/data.py | 18 ++++++------------ 2 files changed, 6 insertions(+), 12 deletions(-) create mode 100644 config/firstrun diff --git a/config/firstrun b/config/firstrun new file mode 100644 index 00000000..e69de29b diff --git a/src/data/data.py b/src/data/data.py index c1aa0a23..a303917f 100644 --- a/src/data/data.py +++ b/src/data/data.py @@ -204,8 +204,8 @@ def __parse_today(self): today = datetime.today() noon = datetime.strptime("12:00", "%H:%M").replace(year=today.year, month=today.month, day=today.day) - end_of_day = datetime.strptime(self.config.end_of_day, "%H:%M").replace(year=today.year, month=today.month, - day=today.day) + #end_of_day = datetime.strptime(self.config.end_of_day, "%H:%M").replace(year=today.year, month=today.month,day=today.day) + end_of_day = datetime.strptime("03:00", "%H:%M").replace(year=today.year, month=today.month,day=today.day) if noon < end_of_day < datetime.now() and datetime.now() > noon: today += timedelta(days=1) elif end_of_day > datetime.now(): @@ -492,20 +492,14 @@ def get_pref_teams_id(self): pref_teams_id = [] # Put all the team's in a dict with there name as KEY and ID as value. for team_id, team in self.teams_info.items(): - name_array = team.details.name.split(" ") - # TODO: This doesn't work. We should use the tri code instead. - # It will either break on St Louis Blues, or Vegas Golden Knights - # Can't have both using the same style of array parsing. - name = ' '.join(name_array[1:]) - allteams_id[name] = team_id + allteams_id[team.details.name] = team_id # Go through the list of preferred teams name. If the team's name exist, put the ID in a new list. if pref_teams: for team in pref_teams: - if team in allteams_id: - pref_teams_id.append(allteams_id[team]) - else: - debug.warning(team + " is not a team of the NHL. Make sure you typed team's name properly") + #Search for the team in the key + res = {key: val for key, val in allteams_id.items() if team in key} + pref_teams_id.append(list(res.values())[0]) return pref_teams_id else: