def parse_basketball_match(data): sql = Sql() l = data.get("leagueMatch") league_match = dict(table="leaguematch") league_match["id"] = l.get("leagueId") league_match["name"] = l.get("leagueName") sql.save_if_not_exist(league_match) g1 = data.get("guestTeam") parse_team(g1) g2 = data.get("homeTeam") parse_team(g2) match = dict(table="matches") m = data.get("basketballLiveScore") match["guest_score"] = m.get("guestScore") match["home_score"] = m.get("homeScore") match["match_id"] = m.get("matchId") match["info_id"] = m.get("matchInfoId") match["match_status"] = m.get("matchStatus") match["status"] = m.get("status") match["guest_id"] = g1.get("teamId") match["home_id"] = g2.get("teamId") match["match_type"] = 1 match_time = data.get("matchTime") if match_time: match_time *= pow(10, -3) match["match_time"] = datetime.datetime.fromtimestamp(match_time) match["league_id"] = l.get("leagueId") match["league_name"] = l.get("leagueName") sql.reset_if_exist(match, "info_id") sql.close()
def parse_football_match(data): sql = Sql() l = data.get("leagueMatch") league_match = dict(table="leaguematch") league_match["id"] = l.get("leagueId") league_match["name"] = l.get("leagueName") sql.save_if_not_exist(league_match) g1 = data.get("guestTeam") parse_team(g1) g2 = data.get("homeTeam") parse_team(g2) match = dict(table="matches") d = data.get("footballLiveScore") match["match_id"] = d.get("matchId") match["info_id"] = d.get("matchInfoId") match["match_status"] = d.get("matchStatus") match["status"] = d.get("status") match["card_highlight"] = d.get("cardHighlight") match["corner_kick"] = d.get("cornerKick") match["guest_red_card"] = d.get("guestRedCard") match["guest_score"] = d.get("guestScore") match["guest_yellow_card"] = d.get("guestYellowCard") match["half_score"] = d.get("halfScore") match["home_red_card"] = d.get("homeRedCard") match["home_score"] = d.get("homeScore") match["home_yellow_card"] = d.get("homeYellowCard") match["guest_id"] = g1.get("teamId") match["home_id"] = g2.get("teamId") match["league_id"] = l.get("leagueId") match["league_name"] = l.get("leagueName") match["match_type"] = 0 match_time = data.get("matchTime") if match_time: match_time *= pow(10, -3) match["match_time"] = datetime.datetime.fromtimestamp(match_time) sql.reset_if_exist(match, "info_id") sql.close()