open(file_path, 'r', encoding="utf-8"), 'd.m.item') for event in events: try: sport = event.get('sn') tournament = event.get( 'ltn') if live else event.get('tn') event_name = event.get('ht') + ' vs ' + event.get( 'at') #print(bookmaker_title + ' :: Processing API event: ' + event_name) bookmaker_event = BookmakerEvent.BookmakerEvent() teams = [] _teams = [event.get('ht'), event.get('at')] team_local = BookmakerEventTeam.BookmakerEventTeam( ) team_local.title = _teams[0].strip() team_local.local = True checkTeamMembers(sport, team_local) team_away = BookmakerEventTeam.BookmakerEventTeam() team_away.title = _teams[1].strip() team_away.local = False checkTeamMembers(sport, team_away) teams = [team_local, team_away] date = '' _datetime = datetime.strptime( event.get('d'), '%Y-%m-%d %H:%M') if _datetime:
tournament = keyword_country + ' ' + keyword_tournament #print(bookmaker_title + ' :: Processing API event: ' + event_name) bookmaker_event = BookmakerEvent.BookmakerEvent() teams = [] if len(keyword_teams) > 0 and len(keyword_teams) == 2: team1_pos = event_name.find(keyword_teams[0]) team2_pos = event_name.find(keyword_teams[1]) if team1_pos > team2_pos: keyword_teams = [keyword_teams[1], keyword_teams[0]] i = 0 for keyword_team in keyword_teams: team = BookmakerEventTeam.BookmakerEventTeam() team.title = keyword_team team.local = i == 0 checkTeamMembers(keyword_sport, team) teams.append(team) i += 1 event_name = teams[0].title + ' vs ' + teams[1].title filterTeams(keyword_sport, teams) start_at = event.attrib['start_at'] _datetime = datetime.strptime(start_at, '%Y/%m/%dT%H:%M:%SZ UTC')