def get_user_info(self, finish_fn=None) -> str: username = Config.get("username") userid = Config.get("user_id") avatar = None if userid is not None: user_dir = os.path.join(CACHE_DIR, "user/{}".format(userid)) if os.path.exists(user_dir) == False: os.makedirs(user_dir) avatar = os.path.join(user_dir, "avatar_menu_user_av_small.jpg") if not (os.path.isfile(avatar) and os.path.exists(avatar)): avatar = None if (avatar is not None and finish_fn is not None): finish_fn() if not username or not avatar: url = "https://embed.gog.com/userData.json" response = self.__request(url) username = response["username"] userid = response["userId"] Config.set("user_id", userid) Config.set("username", username) user_dir = os.path.join(CACHE_DIR, "user/{}".format(userid)) if os.path.exists(user_dir) == False: os.makedirs(user_dir) avatar = os.path.join(user_dir, "avatar_menu_user_av_small.jpg") download = Download(response["avatar"] + "_menu_user_av_small.jpg", avatar) download.register_finish_function(finish_fn) DownloadManager.download_now(download) return username
def __add_video(self, vidx, video_url, thumbnail_url): if self.__set_video(vidx, video_url): return True # Download the thumbnail img = os.path.join(self.game.cache_dir, "video_{}.jpg".format(vidx)) download = Download(thumbnail_url, img) download.register_finish_function(self.__set_video, (vidx, video_url)) DownloadManager.download_now(download) return True
def __add_screenshot(self, image_id, image_url): if self.__set_screenshot(image_id): return True # Download the thumbnail img = os.path.join(self.game.cache_dir, "screenshot_{}_ggvgt_2x.jpg".format(image_id)) download = Download(image_url, img) download.register_finish_function(self.__set_screenshot, image_id) DownloadManager.download_now(download) return True
def load_icon(self): if self.__set_image(): return True if not self.game.sidebar_icon_url or not self.game.id: return False # Download the thumbnail image_url = "https:{}".format(self.game.sidebar_icon_url) icon = os.path.join(self.game.cache_dir, "{}_sbicon.png".format(self.game.id)) download = Download(image_url, icon) download.register_finish_function(self.__set_image) DownloadManager.download_now(download) return True
def __load_background_image(self): if self.__set_background_image(): return True if not self.game.background_url or not self.game.id: return False # Download the thumbnail image_url = "https:{}".format(self.game.background_url) img = os.path.join(self.game.cache_dir, "{}_background.jpg".format(self.game.id)) download = Download(image_url, img) download.register_finish_function(self.__set_background_image) DownloadManager.download_now(download) return True
def load_thumbnail(self): if self.__set_image(): return True if not self.game.image_url or not self.game.id: return False # Download the thumbnail image_url = "https:{}_196.jpg".format(self.game.image_url) thumbnail = os.path.join(THUMBNAIL_DIR, "{}_196.jpg".format(self.game.id)) download = Download(image_url, thumbnail) download.register_finish_function(self.__set_image) DownloadManager.download_now(download) return True
def load_icon(self): if self.__set_image(): return True if not self.achievement.image_url_unlocked or not self.achievement.achievement_id: return False # Download the thumbnail image_url = self.achievement.image_url_unlocked if self.achievement.date_unlocked is not None else self.achievement.image_url_locked icon = os.path.join( self.game.cache_dir, "achievement_{}_{}.jpg".format( self.achievement.achievement_id, "unlocked" if self.achievement.date_unlocked is not None else "locked")) download = Download(image_url, icon) download.register_finish_function(self.__set_image) DownloadManager.download_now(download) return True