示例#1
0
from lolesports_api import Lolesports_API
from time import sleep

api = Lolesports_API()


def handle_livematches():
    while True:
        live_matches = api.get_live()
        for live_match in live_matches['schedule']['events']:
            #"completed" "unstarted" "inProgress"
            if live_match['state'] == 'unstarted':
                print(
                    f"{live_match['match']['teams'][0]['code']} vs {live_match['match']['teams'][1]['code']}"
                )
                get_live_game(api.get_event_details(live_match['id']))
                sleep(60)


def get_live_game(games):
    for game in games['event']['match']['games']:
        if game['state'] == 'inProgress':
            current_game = api.get_window(game['id'])
            print(current_game)


if __name__ == '__main__':
    handle_livematches()
示例#2
0
 def test_get_details(self):
     api = Lolesports_API()
     response = api.get_details(100205573001435494)
     self.assertTrue(response)
示例#3
0
from lolesports_api import Lolesports_API
from time import sleep

# só funciona pra jogos no momento
#get live
api = Lolesports_API()

print("funcionando2")
live_matches = api.get_live()
for live_match in live_matches['schedule']['events']:
    if live_match['state'] == 'finished':
        #id = '105562692794240160'
        #gameid = id + '2'
        #print(gameid)
        #if live_match['match']['id'] == id:
        # tem
        print(
            f"{live_match['match']['teams'][0]['code']} vs {live_match['match']['teams'][1]['code']}"
        )
        #match id
        print("funcionando2")
        print(f"{live_match['match']['id']}")
        print(f"{live_match['startTime']}")
        print(f"{live_match['league']}")
        #print(f"{live_match['id']}")
        #get_live_game(api.get_event_details(live_match['id']))

    #precisa do start time?
    #gameid = match id +2 se tiver começado ou +1 se n tiver

#idbusca = live_match['match']['id']
示例#4
0
 def test_get_leagues(self):
     api = Lolesports_API()
     response = api.get_leagues()
     self.assertTrue(response)
示例#5
0
 def test_get_window(self):
     api = Lolesports_API()
     response = api.get_window(103462460606814155)
     self.assertTrue(response)
示例#6
0
 def test_get_event_details(self):
     api = Lolesports_API()
     response = api.get_event_details(1)
     self.assertTrue(response)
示例#7
0
 def test_get_completed_events(self):
     api = Lolesports_API()
     response = api.get_completed_events()
     self.assertTrue(response)
示例#8
0
 def test_get_schedule(self):
     api = Lolesports_API()
     response = api.get_schedule()
     self.assertTrue(response)
示例#9
0
 def test_get_standings(self):
     api = Lolesports_API()
     response = api.get_standings()
     self.assertTrue(response)
示例#10
0
 def test_get_tournaments_for_league(self):
     api = Lolesports_API()
     response = api.get_tournaments_for_league()
     self.assertTrue(response)