How to use the riotwatcher.RiotWatcher function in riotwatcher

To help you get started, we’ve selected a few riotwatcher examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pseudonym117 / Riot-Watcher / riotwatcher / tests.py View on Github external
# these tests are pretty bad, mostly to make sure no exceptions are thrown

import time
from riotwatcher import RiotWatcher, NORTH_AMERICA

key = 'YOUR-KEY-HERE'
# if summoner doesnt have ranked teams, teams tests will fail
# if summoner doesnt have ranked stats, stats tests will fail
# these are not graceful failures, so try to use a summoner that has them
summoner_name = 'pseudonym117'

w = RiotWatcher(key)


def wait():
    while not w.can_make_request():
        time.sleep(1)


def champion_tests():
    wait()
    temp = w.get_all_champions()
    wait()
    w.get_champion(temp['champions'][0]['id'])


def current_game_tests():
    wait()
github pseudonym117 / Riot-Watcher / tests / full_test_RiotWatcher.py View on Github external
def setUp(self):
        if not os.path.isfile("api_key"):
            raise FileNotFoundError(
                'API Key not found (should be in file "api_key" in same directory tests run)'
            )

        with open("api_key", "r") as key_file:
            key = key_file.read()
            self._watcher = RiotWatcher(key.strip())

        self._region = "na1"

        self._test_accounts = ["pseudonym117", "fakename117"]

        self._versions = {
            "item": "8.16.1",
            "rune": "7.23.1",
            "mastery": "7.23.1",
            "summoner": "8.16.1",
            "champion": "8.16.1",
            "profileicon": "8.16.1",
            "map": "8.16.1",
            "language": "8.16.1",
            "sticker": "8.16.1",
        }
github christophM / LolCrawler / crawl-top-matches.py View on Github external
## Connect to MongoDB database
client = MongoClient(config['mongodb']['host'], config['mongodb']['port'])
db = client[config['mongodb']['db']]

## Initialise Riot API wrapper
rate_limits = limits=(RateLimit(3000,10), RateLimit(180000,600))
api_key = config['api_key']

if api_key=='':
    raise LookupError("Provide your API key in config.py")

api = RiotWatcher(config['api_key'], limits = rate_limits, default_region='euw')
summoner_id = '32450058'
match = api.get_match_list(summoner_id=summoner_id)



crawler = TopLolCrawler(api,db_client=db)




crawler.start(begin_time=datetime(2016, 1, 1),
              regions=['euw', 'na', 'eune', 'kr'])
github christophM / LolCrawler / crawl.py View on Github external
client = MongoClient(config['mongodb']['host'], config['mongodb']['port'])
    db = client[config['mongodb']['db']]

    ## Initialise Riot API wrapper
    api_key = config['api_key']
    if api_key=='':
        raise LookupError("Provide your API key in config.py")

    region=config["region"]

    #if config['is_production_key']:
    #    limits = (Limit(3000,10), Limit(180000,600), )
    #else:
    #    limits = (Limit(10, 10), Limit(500, 600), )

    api = RiotWatcher(config['api_key'])


    if action=="top":
        yesterday = date.today() - timedelta(1)
        crawler = TopLolCrawler(api,db_client=db, include_timeline=config["include_timeline"])
        crawler.start(regions=['euw1', 'na', 'kr', 'eune'], leagues=['challenger'])
    else:
        ## Initialise crawler
        crawler =  LolCrawler(api, db_client=db, include_timeline=config["include_timeline"], region = "euw1")
        crawler.start(config['summoner_seed_id'])
github pajbot / pajbot / pajbot / modules / leaguerank.py View on Github external
),
                )
                return False
            else:
                pass
        else:
            region = def_region.lower()

        if len(summoner_name) == 0 or len(region) == 0:
            return False

        error_404 = "Game data not found"
        error_429 = "Too many requests"

        try:
            rw = RiotWatcher(riot_api_key, default_region=region)

            summoner = rw.get_summoner(name=summoner_name)
            summoner_id = str(summoner["id"])
            summoner_name = summoner["name"]

        except LoLException as e:
            if e == error_429:
                bot.say("Too many requests. Try again in {} seconds".format(e.headers["Retry-After"]))
                return False
            elif e == error_404:
                bot.say("The summoner not found. Use a valid summoner name (remove spaces) and region FailFish")
                return False
            else:
                log.info("Something unknown went wrong: {}".format(e))
                return False
github pseudonym117 / Riot-Watcher / riotwatcher / legacy / riotwatcher.py View on Github external
def __init__(self, key, default_region=NORTH_AMERICA, limits=None):
        logging.warn('legacy RiotWatcher class is not intended to be used long term')
        logging.warn('please update to RiotWatcher v2.0.0 APIs as soon as possible')
        logging.warn('THIS WILL BE REMOVED IN THE NEXT UPDATE OF RIOT WATCHER')
        self.key = key
        self._watcher = RW(key)
        self.default_region = default_region