Commit 63e52ae8 authored by Hermann Krumrey's avatar Hermann Krumrey

Merge branch 'develop' into 'master'

Fix more data fetching issues

See merge request !8
parents 4fff1047 d31f7e54
V 0.5.3:
- More oddsportal fixes
- Fixed matchday fetching of football-data
- Added pre-trained model weights
V 0.5.2:
- Fixed oddsportal int conversion issues
V 0.5.1:
......
......@@ -8,6 +8,7 @@ RUN pip3 install tensorflow keras dryscrape
ADD . bot
RUN cd bot && python3 setup.py install
RUN mkdir -p /root/.config/betbot && cp -r bot/models/* /root/.config/betbot
WORKDIR bot
CMD ["docker_start.sh", "-v"]
......@@ -125,7 +125,7 @@ class FootballDataFetcher(DataFetcher):
csv_urls = self._load_csv_urls([country_enum])
current_season = max(csv_urls[country][league].keys())
now_url = "https://www.football-data.co.uk/matches.php"
now_url = "https://www.football-data.co.uk/fixtures.csv"
current_url = csv_urls[country][league][current_season]
lower_url = csv_urls[country][league + 1][current_season]
previous_url = csv_urls[country][league][current_season - 1]
......@@ -146,15 +146,23 @@ class FootballDataFetcher(DataFetcher):
with StringIO(requests.get(now_url).text) as f:
data = [x for x in csv.reader(f)]
keys = data.pop(0)
_current_matches = [
Match.from_football_data(
{keys[j]: data[i][j] for j in range(len(data))}
)
for i in range(len(keys))
if data[i][0] == league_identifier
]
current_matches = [x for x in _current_matches if x is not None]
keys = [x.lower() for x in data.pop(0)]
data = [x for x in data if x[0] == league_identifier]
current_matches = []
base_match_dict = {
"country": country,
"season": str(current_season),
"league": str(league),
"finished": str(False)
}
for item in data:
match_dict = {keys[i]: item[i] for i in range(len(keys))}
match_dict.update(base_match_dict)
match = Match.from_football_data(match_dict)
if match is not None:
current_matches.append(match)
if len(current_matches) == 0:
retry = 0
self.logger.info("football-data not available, using oddportal")
......@@ -256,10 +264,13 @@ class FootballDataFetcher(DataFetcher):
if name in bookmakers:
bookmaker_odds = []
for index in range(1, 4):
fraction = [
float(x) for x in tds[index].text.split("/")
]
odds_number = 1.0 + (fraction[0] / fraction[1])
try:
odds_number = float(tds[index].text)
except ValueError:
fraction = [
int(x) for x in tds[index].text.split("/")
]
odds_number = 1.0 + (fraction[0] / fraction[1])
bookmaker_odds.append(odds_number)
bookmaker_odds_tuple = (
bookmaker_odds[0], bookmaker_odds[1], bookmaker_odds[2]
......
......@@ -63,6 +63,11 @@ class Match:
except (KeyError, ValueError):
return None
away_ht = None if not data.get("htag") else int(data["htag"])
away_ft = None if not data.get("ftag") else int(data["ftag"])
home_ht = None if not data.get("hthg") else int(data["hthg"])
home_ft = None if not data.get("fthg") else int(data["fthg"])
return cls(
country=data["country"],
league=int(data["league"]),
......@@ -71,9 +76,9 @@ class Match:
finished=bool(data["finished"]),
home_team=data["hometeam"],
away_team=data["awayteam"],
home_ht_score=int(data["hthg"]),
home_ft_score=int(data["fthg"]),
away_ht_score=int(data["htag"]),
away_ft_score=int(data["ftag"]),
home_ht_score=home_ht,
home_ft_score=home_ft,
away_ht_score=away_ht,
away_ft_score=away_ft,
bet_odds=bet_odds
)
0.5.2
\ No newline at end of file
0.5.3
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment