diff --git a/rare/components/tabs/shop/__init__.py b/rare/components/tabs/shop/__init__.py index 64067c9d..f6af5c59 100644 --- a/rare/components/tabs/shop/__init__.py +++ b/rare/components/tabs/shop/__init__.py @@ -1,12 +1,12 @@ import os from PyQt5.QtWidgets import QStackedWidget, QTabWidget -from custom_legendary.core import LegendaryCore +from custom_legendary.core import LegendaryCore +from rare.components.tabs.shop.browse_games import BrowseGames from rare.components.tabs.shop.search_results import SearchResults from rare.components.tabs.shop.shop_info import ShopGameInfo from rare.components.tabs.shop.shop_widget import ShopWidget -from rare.components.tabs.shop.browse_games import BrowseGames class Shop(QStackedWidget): @@ -28,6 +28,7 @@ class Shop(QStackedWidget): self.store_tabs = QTabWidget() self.store_tabs.addTab(self.shop, self.tr("Games")) self.store_tabs.addTab(self.browse_games, self.tr("Browse")) + self.store_tabs.tabBarClicked.connect(lambda x: self.browse_games.load() if x == 1 else None) self.addWidget(self.store_tabs) @@ -48,7 +49,7 @@ class Shop(QStackedWidget): if not self.init: self.init = True self.shop.load() - self.browse_games.prepare_request() + # self.browse_games.prepare_request() def show_game_info(self, data): self.info.update_game(data) diff --git a/rare/components/tabs/shop/browse_games.py b/rare/components/tabs/shop/browse_games.py index a6e8f4bb..0b027f4e 100644 --- a/rare/components/tabs/shop/browse_games.py +++ b/rare/components/tabs/shop/browse_games.py @@ -64,6 +64,9 @@ class BrowseGames(QWidget, Ui_browse_games): checkbox.deactivated.connect(lambda x: self.prepare_request(removed_type=x)) self.type_gb.layout().addWidget(checkbox) + def load(self): + self.prepare_request() + def prepare_request(self, price: str = None, added_tag: int = 0, removed_tag: int = 0, added_type: str = "", removed_type: str = ""): diff --git a/rare/components/tabs/shop/thread.py b/rare/components/tabs/shop/thread.py deleted file mode 100644 index 3139c666..00000000 --- a/rare/components/tabs/shop/thread.py +++ /dev/null @@ -1,57 +0,0 @@ -import requests -from PyQt5.QtCore import QThread, pyqtSignal - -from custom_legendary.core import LegendaryCore -from rare.components.tabs.shop.browse_games import game_query -from rare.components.tabs.shop.shop_models import ShopGame -from rare.utils.utils import get_lang - - -class AnalyzeThread(QThread): - get_tags = pyqtSignal(dict) - - def __init__(self, core: LegendaryCore): - super(AnalyzeThread, self).__init__() - self.tags = {} - self.core = core - - def run(self) -> None: - locale = get_lang() - for igame in self.core.get_installed_list(): - data = { - "query": game_query, - "variables": {"category": "games/edition/base|bundles/games|editors|software/edition/base", - "count": 20, - "country": locale.upper(), "keywords": igame.title, "locale": locale, "sortDir": "DESC", - "allowCountries": locale.upper(), - "start": 0, "tag": "", "withMapping": False, "withPrice": True} - } - - try: - search_game = \ - requests.post("https://www.epicgames.com/graphql", json=data).json()["data"]["Catalog"]["searchStore"][ - "elements"][0] - except: - continue - slug = search_game["productSlug"] - is_bundle = False - for i in search_game["categories"]: - if "bundles" in i.get("path", ""): - is_bundle = True - - api_game = requests.get( - f"https://store-content.ak.epicgames.com/api/{locale}/content/{'products' if not is_bundle else 'bundles'}/{slug}").json() - - if api_game.get("error"): - print(igame.title) - continue - - game = ShopGame.from_json(api_game, search_game) - - for i in game.tags: - if i not in self.tags.keys(): - self.tags[i] = 1 - else: - self.tags[i] += 1 - - print(self.tags)