def get_best_conversion_rates_freebet(window): conversion_rates = {} high_conversion_rates = [] for sport in sb.ODDS: if sb.SEEN_SUREBET[sport]: continue for site in sb.BOOKMAKERS: old_stdout = sys.stdout # Memorize the default stdout stream sys.stdout = buffer = io.StringIO() best_match_freebet(site, 100, sport) sys.stdout = old_stdout # Put the old stream back in place what_was_printed = buffer.getvalue() match, _ = infos(what_was_printed) if match is None: continue conversion_rate = float(list(indicators(what_was_printed))[1][1].strip(" %")) if conversion_rates.get(site, [0])[0] < conversion_rate: conversion_rates[site] = [conversion_rate, sport] table = [] for site, details in conversion_rates.items(): if details[0] >= 80: high_conversion_rates.append(site) table.append([site]+details) table.sort(key=lambda x: x[1], reverse=True) window["CONVERT_RATES_FREEBET"].update(table) visible = len(high_conversion_rates) > 0 window["HIGH_FREEBET_PARSING"].update("Taux de conversion freebet > 80% ({})".format(", ".join(high_conversion_rates)), visible=visible)
def best_match_freebet_interface(window, values): """ :param window: Fenêtre principale PySimpleGUI :param values: Valeurs de la fenêtre principale :return: Affiche le résultat de la fonction best_match_freebet dans l'interface """ try: site = values["SITE_FREEBET"][0] freebet = float(values["BET_FREEBET"]) sport = values["SPORT_FREEBET"][0] old_stdout = sys.stdout # Memorize the default stdout stream sys.stdout = buffer = io.StringIO() best_match_freebet(site, freebet, sport) sys.stdout = old_stdout # Put the old stream back in place what_was_printed = buffer.getvalue() match, date = infos(what_was_printed) window["MATCH_FREEBET"].update(match) window["DATE_FREEBET"].update(date) window["ODDS_FREEBET"].update(odds_table(what_was_printed), visible=True) window["RESULT_FREEBET"].update(stakes(what_was_printed), visible=True) window["TEXT_FREEBET"].update(visible=True) for i, elem in enumerate(indicators(what_was_printed)): window["INDICATORS_FREEBET" + str(i)].update(elem[0].capitalize(), visible=True) window["RESULTS_FREEBET" + str(i)].update(elem[1], visible=True) buffer.close() except IndexError: pass except ValueError: pass except KeyError: pass
def best_match_freebet_interface(window, values): """ :param window: Fenêtre principale PySimpleGUI :param values: Valeurs de la fenêtre principale :return: Affiche le résultat de la fonction best_match_freebet dans l'interface """ try: site = values["SITE_FREEBET"][0] freebet = float(values["BET_FREEBET"]) sport = values["SPORT_FREEBET"][0] split_freebet = values["SPLIT_FREEBET"] nb_matches = values["NB_MATCHES_FREEBET"] old_stdout = sys.stdout # Memorize the default stdout stream sys.stdout = buffer = io.StringIO() if split_freebet: best_matches_freebet_one_site(site, freebet, sport) elif nb_matches == 1: best_match_freebet(site, freebet, sport) else: best_matches_freebet2(site, freebet, sport, nb_matches) sys.stdout = old_stdout # Put the old stream back in place what_was_printed = buffer.getvalue() match, date = infos(what_was_printed) if match is None: window["MATCH_FREEBET"].update("Aucun match trouvé") window["DATE_FREEBET"].update("") window["ODDS_FREEBET"].update(visible=False) window["RESULT_FREEBET"].update(visible=False) window["TEXT_FREEBET"].update(visible=False) for i in range(5): window["INDICATORS_FREEBET" + str(i)].update(visible=False) window["RESULTS_FREEBET" + str(i)].update(visible=False) else: window["MATCH_FREEBET"].update(match) window["DATE_FREEBET"].update(date) window["ODDS_FREEBET"].update(odds_table(what_was_printed), visible=not split_freebet and nb_matches == 1) window["RESULT_FREEBET"].update(stakes(what_was_printed), visible=True) window["TEXT_FREEBET"].update(visible=True) window["DELETE_MATCH_FREEBET"].update( visible=not split_freebet and nb_matches == 1) window["RELOAD_ODDS_FREEBET"].update( visible=not split_freebet and nb_matches == 1) for i, elem in enumerate(indicators(what_was_printed)): window["INDICATORS_FREEBET" + str(i)].update( elem[0].capitalize(), visible=True) window["RESULTS_FREEBET" + str(i)].update(elem[1], visible=True) for j in range(i + 1, 5): window["INDICATORS_FREEBET" + str(j)].update(visible=False) window["RESULTS_FREEBET" + str(j)].update(visible=False) buffer.close() except IndexError: pass except ValueError: pass except KeyError: pass