mirror of
https://github.com/PaiGramTeam/EnkaNetwork.py.git
synced 2024-09-28 03:26:09 +00:00
funtion read from url
This commit is contained in:
parent
fc4c09ae0b
commit
e5772950f7
@ -154,3 +154,14 @@ class HTTPClient:
|
||||
endpoint='assets'
|
||||
)
|
||||
return self.request(r)
|
||||
|
||||
async def read_from_url(self, url: str) -> bytes:
|
||||
async with self.__session.get(url) as resp:
|
||||
if resp.status == 200:
|
||||
return await resp.read()
|
||||
elif resp.status == 404:
|
||||
raise HTTPException(resp, 'asset not found')
|
||||
elif resp.status == 403:
|
||||
raise Forbidden(resp, 'cannot retrieve asset')
|
||||
else:
|
||||
raise HTTPException(resp, 'failed to get asset')
|
Loading…
Reference in New Issue
Block a user