upstairs neighbour start

This commit is contained in:
Alexander Munch-Hansen 2019-04-06 16:38:23 +02:00
parent 482e0a9ab9
commit 060a8eef36

View file

@ -0,0 +1,35 @@
import requests
from bs4 import BeautifulSoup
from datetime import datetime
from ..util import Prediction, Context
def update():
requests.post('https://euw.op.gg/summoner/ajax/renew.json/', data = {'summonerId': 34009256})
def check_games(context: Context) -> Prediction:
update()
r = requests.get('https://euw.op.gg/summoner/userName=Im+Eating+Pros')
#if not "is not in an active game" in str(r.content):
# return 1.0
p = Prediction()
soup = BeautifulSoup(r.content, features='html5lib')
timestamp = int(soup.find('div', {'class': 'GameItemList'}).find('div', {'class': 'GameItem'})['data-game-time'])
last_played_game = datetime.fromtimestamp(timestamp)
last_game_in_hours = (((datetime.now() - last_played_game).seconds)/60/60)
if last_game_in_hours < 2:
p.reasons.append("Alexanders upstairs neighbour is currently playing league")
p.probability = 0.8
else:
p.reasons.append(f"Alexanders upstairs neighbour has not played league for {last_game_in_hours} hours!")
p.probability = last_game_in_hours / 24
return p