Skip to content

Commit 486cb5d

Browse files
committed
aurora 1.1.2
1 parent 6e1b3a0 commit 486cb5d

File tree

3 files changed

+43
-28
lines changed

3 files changed

+43
-28
lines changed

changelog

+3
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,6 @@
99
> v5.1.1 'Aurora-1.1.1':
1010
* Fixed 'TypeError' on the fortnite daily shop
1111
* Fixed incorrect interpretation of data on the music player
12+
13+
> v5.1.2 'Aurora-1.1.2':
14+
* The fortnite daily shop now shows bundles and emotes

rinbot/config/config.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"VERSION": "v5.1.1 'Aurora'",
2+
"VERSION": "v5.1.2 'Aurora'",
33
"PREFIX": "!",
44
"LANGUAGE": "en",
55
"ACTIVITY_SWITCH_INTERVAL": 10,

rinbot/fortnite/api.py

+39-27
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
text = get_lang()
2121

2222
class FortniteAPI:
23-
__types__ = ['outfit', 'pickaxe', 'backpack']
23+
# __types__ = ['outfit', 'pickaxe', 'backpack']
2424

2525
def __init__(self, language: str='en', api_key: str=None):
2626
self.language = language
@@ -106,6 +106,7 @@ async def __shop_generate_images(self, items):
106106
composites = []
107107

108108
for i in items:
109+
print(i)
109110
downloads.append(self.__shop_get_image(i["image"], i["name"]))
110111
composites.append(self.__shop_composite_image(i["name"], i["price"]))
111112

@@ -116,33 +117,45 @@ async def __shop_generate_images(self, items):
116117

117118
async def __shop_format(self, data) -> dict:
118119
try:
119-
data = data["data"]
120-
shop = {"date": None, "count": 0, "entries": []}
121-
122-
date: datetime = datetime.strptime(data["date"], "%Y-%m-%dT%H:%M:%SZ")
123-
shop["date"] = date.strftime("%d/%m/%y")
124-
125-
for entry in data["featured"]["entries"]:
126-
# Skip unwanted items
127-
if entry["bundle"]:
128-
continue
129-
if entry["items"][0]["type"]["value"] not in self.__types__:
130-
continue
131-
120+
data = data['data']
121+
shop = {
122+
'date': None,
123+
'count': len(data['featured']['entries']),
124+
'entries': []
125+
}
126+
127+
date: datetime = datetime.strptime(data['date'], '%Y-%m-%dT%H:%M:%SZ')
128+
shop['date'] = date.strftime('%d/%m/%y')
129+
130+
for entry in data['featured']['entries']:
132131
item = {}
133-
132+
134133
try:
135-
item = {
136-
"name": entry["items"][0]["name"],
137-
"price": entry["finalPrice"],
138-
"rarity": entry["items"][0]["rarity"]["value"],
139-
"image": entry["newDisplayAsset"]["materialInstances"][0]["images"]["Background"]}
140-
except KeyError:
141-
item["image"] = entry["newDisplayAsset"]["materialInstances"][0]["images"]["OfferImage"]
142-
143-
shop["entries"].append(item)
144-
145-
shop["count"] = len(shop["entries"])
134+
if entry['bundle']:
135+
item['name'] = entry['bundle']['name']
136+
item['price'] = entry['finalPrice']
137+
item['rarity'] = None
138+
139+
try:
140+
item['image'] = entry['newDisplayAsset']['materialInstances'][0]['images']['Background']
141+
except KeyError:
142+
item['image'] = entry['newDisplayAsset']['materialInstances'][0]['images']['OfferImage']
143+
elif entry['newDisplayAsset']:
144+
try:
145+
item['name'] = entry['items'][0]['name']
146+
item['price'] = entry['finalPrice']
147+
item['rarity'] = entry['items'][0]['rarity']['value']
148+
item['image'] = entry['newDisplayAsset']['materialInstances'][0]['images']['Background']
149+
except (TypeError, KeyError):
150+
try:
151+
item['image'] = entry['newDisplayAsset']['materialInstances'][0]['images']['OfferImage']
152+
except (TypeError, KeyError):
153+
continue
154+
except (TypeError, KeyError):
155+
continue
156+
157+
if item:
158+
shop['entries'].append(item)
146159

147160
return shop
148161
except Exception as e:
@@ -240,7 +253,6 @@ async def get_shop(self) -> Union[dict, None]:
240253

241254
shop = await response.json()
242255
shop = await self.__shop_format(shop)
243-
244256
try:
245257
await self.__shop_generate_images(shop["entries"])
246258
except Exception as e:

0 commit comments

Comments
 (0)