Skip to content

Commit e1ae4ef

Browse files
committed
Use wrapper class URI instead of str
- Disteam/requests_async.py: Update API set to use wrapper class `URI` instead of `str` - Disteam/steam_user.py: Use new API set
1 parent 0ca6867 commit e1ae4ef

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

Disteam/requests_async.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import aiohttp
22
from typing import Tuple
33

4+
from uri import URI
45

5-
async def get(url: str) -> Tuple[str, int]:
6+
7+
async def get(uri: URI) -> Tuple[str, int]:
68
async with aiohttp.ClientSession() as session:
7-
async with session.get(url, headers={"User-Agent" : "Mozilla/5.0"}) as response:
9+
async with session.get(str(uri), headers={"User-Agent" : "Mozilla/5.0"}) as response:
810
return (await response.text(), response.status)

Disteam/steam_user.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ async def query_user_async(uri: URI) -> Union[SteamUser, None]:
3636
req: URI = URI(
3737
URLS.CUSTOM_URL, {"key": __api_key, "vanityurl": url.split("/")[-1]}
3838
)
39-
res: Tuple[str, int] = await requests_async.get(str(req))
39+
res: Tuple[str, int] = await requests_async.get(req)
4040
dat = json.loads(res[0])
4141
__user_id = (
4242
None if dat["response"]["success"] == 42 else dat["response"]["steamid"]
@@ -59,7 +59,7 @@ async def get_profile_async(self) -> Union[SteamProfile, None]:
5959
req: URI = URI(
6060
URLS.USER_INFO, {"key": self.__api_key, "steamids": self.__user_id}
6161
)
62-
res: Tuple[str, int] = await requests_async.get(str(req))
62+
res: Tuple[str, int] = await requests_async.get(req)
6363
dat = json.loads(res[0])
6464

6565
if len(dat["response"]["players"]) == 0:
@@ -71,7 +71,7 @@ async def get_level_async(self) -> Union[str, None]:
7171
req: URI = URI(
7272
URLS.USER_LEVEL, {"key": self.__api_key, "steamid": self.__user_id}
7373
)
74-
res: Tuple[str, int] = await requests_async.get(str(req))
74+
res: Tuple[str, int] = await requests_async.get(req)
7575
if res[1] == 500:
7676
return None
7777

@@ -85,7 +85,7 @@ async def get_owned_game_count_async(self) -> Union[int, None]:
8585
req: URI = URI(
8686
URLS.OWNED_GAMES, {"key": self.__api_key, "steamid": self.__user_id}
8787
)
88-
res: Tuple[str, int] = await requests_async.get(str(req))
88+
res: Tuple[str, int] = await requests_async.get(req)
8989
if res[1] == 500:
9090
return None
9191

@@ -102,7 +102,7 @@ async def get_recent_games_async(
102102
URLS.RECENT_GAME,
103103
{"key": self.__api_key, "steamid": self.__user_id, "count": count},
104104
)
105-
res: Tuple[str, int] = await requests_async.get(str(req))
105+
res: Tuple[str, int] = await requests_async.get(req)
106106
dat = json.loads(res[0])
107107

108108
games: list[SteamGame] = list()

0 commit comments

Comments
 (0)