-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathgetSkinOffers.py
59 lines (47 loc) · 2.33 KB
/
getSkinOffers.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import aiohttp
import json
async def getStore(headers,user_id,region):
session = aiohttp.ClientSession()
async with session.get(f'https://pd.{region}.a.pvp.net/store/v2/storefront/{user_id}', headers=headers) as r:
data = json.loads(await r.text())
await session.close()
skinPanel=data['SkinsPanelLayout']
return await getSkinDetails(headers,skinPanel,region)
def convert(seconds):
seconds = seconds % (24 * 3600)
hour = seconds // 3600
seconds %= 3600
minutes = seconds // 60
seconds %= 60
return f"{hour} hours {minutes} minutes and {seconds} seconds remaining"
async def getAllSkins():
allSkinNames=[]
session = aiohttp.ClientSession()
async with session.get(f'https://valorant-api.com/v1/weapons/skins') as r:
content=json.loads(await r.text())
for item in content['data']:
allSkinNames.append({"id":item["uuid"].lower(),"name":item["displayName"],"img":item["displayIcon"]})
await session.close()
return allSkinNames
async def getSkinDetails(headers,skinPanel,region):
skinIDcost=[]
skinNames=[]
offerSkins=[]
session = aiohttp.ClientSession()
async with session.get(f'https://shared.{region}.a.pvp.net/content-service/v2/content', headers=headers) as r:
content = json.loads(await r.text())
async with session.get(f'https://pd.{region}.a.pvp.net/store/v1/offers/', headers=headers) as r:
offers=json.loads(await r.text())
for item in skinPanel['SingleItemOffers']:
async with session.get(f'https://valorant-api.com/v1/weapons/skinlevels/{item}', headers=headers) as r:
content=json.loads(await r.text())
skinNames.append({"id":content["data"]["uuid"].lower(),"name":content["data"]["displayName"]})
await session.close()
for item in offers["Offers"]:
if (skinPanel['SingleItemOffers'].count(item["OfferID"].lower())>0):
skinIDcost.append({"id":item["OfferID"].lower(),"cost":list(item["Cost"].values())[0]})
for item in skinNames:
for item2 in skinIDcost:
if item['id'] in item2['id']:
offerSkins.append([item["name"],item2["cost"],f"https://media.valorant-api.com/weaponskinlevels/{item['id']}/displayicon.png"])
return(offerSkins,convert(skinPanel["SingleItemOffersRemainingDurationInSeconds"]))