1
0
Fork 0
mirror of synced 2024-06-24 01:00:43 +12:00

Add support for bundles

This commit is contained in:
Dummerle 2021-06-09 13:25:57 +02:00
parent 44b7a0a37f
commit 6355dd47c1
2 changed files with 16 additions and 7 deletions

View file

@ -34,10 +34,14 @@ class ShopGameInfo(QWidget, Ui_shop_info):
self.dev.setText(self.tr("Loading"))
self.image.setPixmap(QPixmap())
self.data = data
is_bundle = False
for i in data["categories"]:
if "bundles" in i.get("path", ""):
is_bundle = True
# init API request
locale = QLocale.system().name().split("_")[0]
url = f"https://store-content.ak.epicgames.com/api/{locale}/content/products/{slug}"
url = f"https://store-content.ak.epicgames.com/api/{locale}/content/{'products' if not is_bundle else 'bundles'}/{slug}"
# game = api_utils.get_product(slug, locale)
self.request = self.manager.get(QNetworkRequest(QUrl(url)))
self.request.finished.connect(self.data_received)
@ -55,6 +59,7 @@ class ShopGameInfo(QWidget, Ui_shop_info):
logging.info(self.slug, error.errorString())
return
else:
logger.error("Data failed")
return
else:
return
@ -88,3 +93,4 @@ class ShopGameInfo(QWidget, Ui_shop_info):
def button_clicked(self):
webbrowser.open("https://www.epicgames.com/store/de/p/" + self.slug)

View file

@ -46,6 +46,7 @@ class ShopGame:
@classmethod
def from_json(cls, api_data: dict, search_data: dict):
print(api_data)
if isinstance(api_data, list):
for product in api_data:
if product["_title"] == "home":
@ -53,22 +54,24 @@ class ShopGame:
break
tmp = cls()
tmp.title = api_data.get("productName", "undefined")
if "pages" in api_data.keys():
api_data = api_data["pages"][0]
tmp.title = api_data.get("productName", api_data.get("_title", "fail"))
tmp.image_urls = _ImageUrlModel.from_json(search_data["keyImages"])
links = api_data["pages"][0]["data"]["socialLinks"]
links = api_data["data"]["socialLinks"]
tmp.links = []
for item in links:
if item.startswith("link"):
tmp.links.append(tuple((item.replace("link", ""), links[item])))
tmp.available_voice_langs = api_data["pages"][0]["data"]["requirements"]["languages"]
tmp.available_voice_langs = api_data["data"]["requirements"]["languages"]
tmp.reqs = []
for i, system in enumerate(api_data["pages"][0]["data"]["requirements"]["systems"]):
for i, system in enumerate(api_data["data"]["requirements"]["systems"]):
tmp.reqs.append({"name": system["systemType"], "value": []})
for req in system["details"]:
tmp.reqs[i]["value"].append(tuple((req["minimum"], req["recommended"])))
tmp.publisher = api_data["pages"][0]["data"]["meta"].get("publisher", "undefined")
tmp.developer = api_data["pages"][0]["data"]["meta"].get("developer", "undefined")
tmp.publisher = api_data["data"]["meta"].get("publisher", "undefined")
tmp.developer = api_data["data"]["meta"].get("developer", "undefined")
tmp.price = search_data['price']['totalPrice']['fmtPrice']['originalPrice']
tmp.discount_price = search_data['price']['totalPrice']['fmtPrice']['discountPrice']