def main(api_token, timezone, live, today, matches, standings, league, sort_by, days, history, details, odds, not_started, refresh, bet, profile, all_bets, open_bets, closed_bets, watch_bets, possible_leagues): params = get_params(api_token, timezone) try: writer = get_writer() rh = RequestHandler(params, LEAGUES_DATA, writer, ch) betting = Betting(params, LEAGUES_DATA, writer, rh, ch) betting.main() Parameters = namedtuple( "parameters", "url, msg, league_name, sort_by, days, " "show_history, show_details, show_odds, not_started, refresh, place_bet, date_format, type_sort" ) def get_multi_matches(filename, parameters): bets = betting.get_bets(ch.get_data('betting_files')[filename]) match_ids = ','.join([i[0] for i in bets]) predictions = [i[0] + ';' + i[1] for i in bets] return rh.get_multi_matches(match_ids, predictions, parameters) def bet_matches(type, sort_by): date_format = convert.format_date(ch.get('profile', 'date_format')) if sort_by is None: sort_by = 'date' parameters = Parameters('fixtures/multi', [ "No open bets at the moment.", "There was problem getting live scores, check your parameters" ], None, sort_by, None, None, details, True, False, True, None, date_format, 'watch_bets') if type == 'open' and watch_bets: filename = 'open_bets' while True: betting.check_open_bets() quit = get_multi_matches(filename, parameters) if quit: return else: time.sleep(60) elif type == 'open': filename = 'open_bets' else: filename = 'closed_bets' get_multi_matches(filename, parameters) return if live or today or matches: check_options(history, bet, live, today, refresh, matches) date_format = convert.format_date(ch.get('profile', 'date_format')) if sort_by is None: sort_by = 'league' if bet: odds = True if live: not_started = False parameters = Parameters('livescores/now', [ "No live action at this moment", "There was problem getting live scores, check your parameters" ], league, sort_by, days, history, details, odds, not_started, refresh, bet, date_format, "live") elif today: parameters = Parameters('livescores', [ "No matches today", "There was problem getting today's scores, check your parameters" ], league, sort_by, days, history, details, odds, not_started, refresh, bet, date_format, "today") else: parameters = Parameters( 'fixtures/between/', [[f"No matches in the past {str(days)} days."], [f"No matches in the coming {str(days)} days."]], league, sort_by, days, history, details, odds, not_started, refresh, bet, date_format, "matches") rh.get_matches(parameters) return if standings: check_options_standings(league, history) rh.get_standings(league, details) return if profile: rh.show_profile() return if all_bets: betting.view_bets('open') betting.view_bets('closed') return if open_bets: if details: bet_matches('open', sort_by) else: betting.view_bets('open') return if closed_bets: if details: bet_matches('closed', sort_by) else: betting.view_bets('closed') return if watch_bets: bet_matches('open', sort_by) if possible_leagues: rh.show_leagues() return except IncorrectParametersException as e: click.secho(str(e), fg="red", bold=True)