-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
94 additions
and
160 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
198cea51-4528-4853-991e-acae35781b74 | ||
198cea51-4528-4853-991e-acae35781b74 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,7 @@ | ||
import urllib3 | ||
|
||
urllib3.disable_warnings() | ||
|
||
del urllib3 | ||
|
||
from .client import Client | ||
from .local import LocalClient | ||
from .threads import AsyncClient | ||
|
||
__all__ = ["Client", "AsyncClient", "LocalClient"] | ||
__author__ = "frissyn" | ||
__version__ = "0.4.3" | ||
__version__ = "0.5.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import requests | ||
|
||
from .values import ROUTES | ||
from .values import LOCALES | ||
from .values import REGIONS | ||
from .values import ENDPOINTS | ||
|
||
|
||
def value_check(*args): | ||
KEYS = ROUTES + LOCALES + REGIONS | ||
|
||
for arg in args: | ||
if arg not in KEYS: | ||
raise ValueError | ||
else: | ||
return True | ||
|
||
|
||
class WebCaller(object): | ||
def __init__(self, token: str, locale: str, region: str, route: str): | ||
self.base = "https://{root}.api.riotgames.com/" | ||
self.eps = ENDPOINTS["web"] | ||
self.sess = requests.Session() | ||
self.sess.params.update({"locale": locale}) | ||
self.sess.headers.update( | ||
{ | ||
"Accept-Charset": "application/x-www-form-urlencoded; charset=UTF-8", | ||
"User-Agent": "Mozilla/5.0", | ||
"X-Riot-Token": token, | ||
} | ||
) | ||
|
||
if value_check(locale, region, route): | ||
self.locale = locale | ||
self.region = region | ||
self.route = route | ||
|
||
def call(self, m: str, ep: str, params=None, route=False, **kw): | ||
if ep not in list(self.eps.keys()): | ||
raise ValueError | ||
else: | ||
pass | ||
|
||
prefix = self.base.format(root=self.route if route else self.region) | ||
url = prefix + self.eps[ep].format(**kw) | ||
|
||
r = self.sess.request(m, url, params=params) | ||
r.raise_for_status() | ||
|
||
return r.json() | ||
|
||
|
||
class ClientCaller(object): | ||
def __init__(self, token: str): | ||
self.base = "https://pd.{code}.a.pvp.net/" | ||
self.token = token | ||
|
||
self.sess = requests.Session() | ||
self.sess.headers.update( | ||
{ | ||
"Authorization": f"Bearer {token}", | ||
"Content-Type": "application/json", | ||
"X-Riot-Entitlements-JWT": "riot_entitlement", | ||
} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters