-
Notifications
You must be signed in to change notification settings - Fork 94
/
__init__.py
138 lines (115 loc) · 4.27 KB
/
__init__.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
"""
initialisation du module
"""
import collections
import json
import os
import queue
import re
import sys
import urllib.error
import chromedriver_autoinstaller
import colorama
from fake_useragent import UserAgent
import termcolor
ALL_ODDS_COMBINE = {}
ODDS = {}
TEAMS_NOT_FOUND = []
PROGRESS = 0
SUB_PROGRESS_LIMIT = 1
SITE_PROGRESS = collections.defaultdict(int)
QUEUE_TO_GUI = queue.Queue()
QUEUE_FROM_GUI = queue.Queue()
ODDS_INTERFACE = ""
EXPECTED_TIME = 0
INTERFACE = False
IS_PARSING = False
ABORT = False
SPORTS = ["basketball", "football", "handball", "hockey-sur-glace", "rugby", "tennis"]
PATH_DRIVER = ""
SELENIUM_SITES = {"joa"}
DB_BOOKMAKERS = ["betclic", "betfair", "betway", "bwin", "france_pari", "joa", "netbet", "parionssport",
"pasinobet", "pinnacle", "pmu", "pokerstars", "unibet", "winamax", "zebet"]
BOOKMAKERS = sorted(DB_BOOKMAKERS + ["barrierebet", "vbet"])
BOOKMAKERS_BOOST = sorted(BOOKMAKERS + ["unibet_boost"])
TEST = False
DB_MANAGEMENT = False
COOKIES_JOA_ACCEPTED = False
TRANSLATION = {}
BETA = False
SUREBETS = {}
MIDDLES = {}
MILES_RATES = {"5€" : 385, "10€" : 770, "20€" : 1510, "50€" : 3700, "100€": 7270, "200€" : 14290, "500€" : 35090, "1000€" : 69000, "2000€":135600, "5000€": 333330}
SEEN_SUREBET = {x:True for x in SPORTS}
FREEBETS_RATES = {bookmaker : 80 for bookmaker in BOOKMAKERS if bookmaker not in ["pinnacle", "betfair"]}
class UnavailableCompetitionException(Exception):
"""
Exception renvoyée lorsqu'une compétition est introuvable
"""
def __init__(self, *args, **kwargs):
Exception.__init__(self, *args, **kwargs)
class UnavailableSiteException(Exception):
"""
Exception renvoyée lorsqu'un bookmaker est indisponible
"""
def __init__(self, *args, **kwargs):
Exception.__init__(self, *args, **kwargs)
class AbortException(Exception):
"""
Exception renvoyée lorsqu'on interropt le parsing
"""
def __init__(self, *args, **kwargs):
Exception.__init__(self, *args, **kwargs)
def grp(pat, txt):
res = re.search(pat, txt)
return res.group(0) if res else '&'
def find_files(filename, search_path):
for root, _, files in os.walk(search_path):
if filename in files:
return os.path.abspath(os.path.join(root, filename))
chrome_version = ""
colorama.init()
try:
PATH_DRIVER = chromedriver_autoinstaller.install(True)
chrome_version = chromedriver_autoinstaller.get_chrome_version()
print("Chrome version :", chrome_version)
except IndexError:
PATH_DRIVER = find_files("chromedriver.exe", ".")
print("Chrome version not found")
print(termcolor.colored('Chrome version not found{}'
.format(colorama.Style.RESET_ALL),
'yellow'))
chromedriver_version = ""
if sys.platform.startswith("win"):
chromedriver_version = PATH_DRIVER.split("\\")[-2]
else:
chromedriver_version = PATH_DRIVER.split("/")[-2]
if chrome_version.split(".")[0] == chromedriver_version:
print(termcolor.colored('Matching Chrome and chromedriver versions{}'
.format(colorama.Style.RESET_ALL),
'green'))
else:
print(termcolor.colored('Unmatching Chrome and chromedriver versions\nPlease update Chrome{}'
.format(colorama.Style.RESET_ALL),
'yellow'))
print(PATH_DRIVER)
colorama.deinit()
PATH_DB = os.path.dirname(__file__) + "/resources/teams.db"
PATH_TOKENS = os.path.dirname(__file__) + "/bookmakers/tokens.txt"
PATH_FREEBETS = os.path.dirname(__file__) + "/freebets.txt"
if not os.path.exists(PATH_FREEBETS):
with open(PATH_FREEBETS, "a+") as file:
for bookmaker, rate in FREEBETS_RATES.items():
if bookmaker in ["pinnacle", "betfair"]:
continue
file.write("{} {}\n".format(bookmaker, rate))
else:
with open(PATH_FREEBETS, "r") as file:
lines = file.readlines()
for line in lines:
bookmaker, rate = line.split()
FREEBETS_RATES[bookmaker] = float(rate)
PATH_TRANSLATION = os.path.dirname(__file__) + "/resources/translation.json"
with open(PATH_TRANSLATION, encoding='utf-8') as file:
TRANSLATION = json.load(file)
PATH_FONT = os.path.dirname(__file__) + "/resources/DejaVuSansMono.ttf"