def load_thumbnail(self): if self.gamesdb_info["cover"]: cover_path = os.path.join(COVER_DIR, "{}.jpg".format(self.game.id)) if os.path.isfile(cover_path): pixbuf = GdkPixbuf.Pixbuf.new_from_file(cover_path) pixbuf = pixbuf.scale_simple(340, 480, GdkPixbuf.InterpType.BILINEAR) GLib.idle_add(self.image.set_from_pixbuf, pixbuf) else: url = "{}".format(self.gamesdb_info["cover"]) download = Download(url, cover_path) DownloadManager.download_now(download) response = urllib.request.urlopen(url) input_stream = Gio.MemoryInputStream.new_from_data( response.read(), None) pixbuf = GdkPixbuf.Pixbuf.new_from_stream(input_stream, None) pixbuf = pixbuf.scale_simple(340, 480, GdkPixbuf.InterpType.BILINEAR) GLib.idle_add(self.image.set_from_pixbuf, pixbuf) else: thumbnail_path = os.path.join(THUMBNAIL_DIR, "{}.jpg".format(self.game.id)) if not os.path.isfile(thumbnail_path) and self.game.is_installed: thumbnail_path = os.path.join(self.game.install_dir, "thumbnail.jpg") GLib.idle_add(self.image.set_from_file, thumbnail_path)
def get_async_image_dlc_icon(self, dlc_id, image, icon, title): dlc_icon_path = os.path.join(ICON_DIR, "{}.jpg".format(dlc_id)) if icon: if os.path.isfile(dlc_icon_path): GLib.idle_add(image.set_from_file, dlc_icon_path) else: url = "http:{}".format(icon) dlc_icon = os.path.join(ICON_DIR, "{}.jpg".format(dlc_id)) download = Download(url, dlc_icon) DownloadManager.download_now(download) GLib.idle_add(image.set_from_file, dlc_icon_path)
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, "{}.jpg".format(self.game.id)) download = Download(image_url, thumbnail, finish_func=self.__set_image) DownloadManager.download_now(download) return True
def load_thumbnail(self): set_result = self.__set_image() if not set_result: tries = 10 performed_try = 0 while performed_try < tries: if self.game.image_url and self.game.id: # Download the thumbnail image_url = "https:{}_196.jpg".format(self.game.image_url) thumbnail = os.path.join(THUMBNAIL_DIR, "{}.jpg".format(self.game.id)) download = Download(image_url, thumbnail, finish_func=self.__set_image) DownloadManager.download_now(download) set_result = True break performed_try += 1 time.sleep(1) return set_result