Skip to content

Commit

Permalink
feat: Adds the riot api key as a constant in the config class (League…
Browse files Browse the repository at this point in the history
…OfPoro#131)

* Adds the riot api key as a constant in the config class

* Use class constant

* Fix best streams loading

---------

Co-authored-by: League of Poro <[email protected]>
  • Loading branch information
14ROVI and LeagueOfPoro authored Feb 22, 2023
1 parent 0017c0d commit 9650517
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/Config.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class Config:
"""

REMOTE_BEST_STREAMS_URL = "https://raw.githubusercontent.com/LeagueOfPoro/CapsuleFarmerEvolved/master/config/bestStreams.txt"
RIOT_API_KEY = "0TvQnueqKa5mxJntVWt0w4LpLfEkrV1Ta8rQBb9Z"

def __init__(self, configPath: str) -> None:
"""
Expand Down
9 changes: 5 additions & 4 deletions src/DataProviderThread.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import cloudscraper

from AssertCondition import AssertCondition
from Config import Config
from Exceptions.StatusCodeAssertException import StatusCodeAssertException
from Match import Match
from SharedData import SharedData
Expand Down Expand Up @@ -44,8 +45,8 @@ def fetchLiveMatches(self):
"""
Retrieve data about currently live matches and store them.
"""
headers = {"Origin": "https://lolesports.com",
"x-api-key": "0TvQnueqKa5mxJntVWt0w4LpLfEkrV1Ta8rQBb9Z"}
headers = {"Origin": "https://lolesports.com", "Referrer": "https://lolesports.com",
"x-api-key": Config.RIOT_API_KEY}
res = self.client.get(
"https://esports-api.lolesports.com/persisted/gw/getLive?hl=en-GB", headers=headers)
AssertCondition.statusCodeMatches(200, res)
Expand Down Expand Up @@ -77,8 +78,8 @@ def fetchTimeUntilNextMatch(self):
"""
Retrieve data about currently live matches and store them.
"""
headers = {"Origin": "https://lolesports.com",
"x-api-key": "0TvQnueqKa5mxJntVWt0w4LpLfEkrV1Ta8rQBb9Z"}
headers = {"Origin": "https://lolesports.com", "Referrer": "https://lolesports.com",
"x-api-key": Config.RIOT_API_KEY}
try:
res = self.client.get(
"https://esports-api.lolesports.com/persisted/gw/getSchedule?hl=en-GB", headers=headers)
Expand Down
3 changes: 2 additions & 1 deletion src/FarmThread.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from threading import Thread
from time import sleep
from Browser import Browser
from Config import Config
from Exceptions.InvalidIMAPCredentialsException import InvalidIMAPCredentialsException
from Exceptions.Fail2FAException import Fail2FAException
import requests
Expand Down Expand Up @@ -121,7 +122,7 @@ def getLeagueFromID(leagueId):
return ""
def getLeagues():
headers = {"Origin": "https://lolesports.com", "Referrer": "https://lolesports.com",
"x-api-key": "0TvQnueqKa5mxJntVWt0w4LpLfEkrV1Ta8rQBb9Z"}
"x-api-key": Config.RIOT_API_KEY}
res = requests.get(
"https://esports-api.lolesports.com/persisted/gw/getLeagues?hl=en-GB", headers=headers)
leagues = res.json()["data"].get("leagues", [])
Expand Down

0 comments on commit 9650517

Please sign in to comment.