コード例 #1
0
ファイル: interpreter.py プロジェクト: lazerl0rd/lutris
    def swap_gog_game_files(self):
        """Replace user provided file with downloads from GOG"""
        if not self.gogid:
            raise UnavailableGame("The installer has no GOG ID!")
        try:
            links = get_gog_download_links(self.gogid, self.runner)
        except HTTPError:
            raise UnavailableGame(
                "Couldn't load the download links for this game")
        except MultipleInstallerError:
            raise UnavailableGame(
                "Don't know how to deal with multiple installers yet.")
        if not links:
            raise UnavailableGame("Could not fing GOG game")

        installer_file_id = self.pop_user_provided_file()
        if not installer_file_id:
            raise UnavailableGame("Installer has no user provided file")

        file_id_provided = False  # Only assign installer_file_id once
        for index, link in enumerate(links):
            if link["filename"].lower().endswith(
                (".exe", ".sh")) and not file_id_provided:
                file_id = installer_file_id
                file_id_provided = True
            else:
                file_id = "gog_file_%s" % index
            self.files.append(
                InstallerFile(self.game_slug, file_id, {
                    "url": link["url"],
                    "filename": link["filename"],
                }))
コード例 #2
0
    def swap_gog_game_files(self):
        if not self.gogid:
            raise UnavailableGame("The installer has no GOG ID!")
        links = self.get_gog_download_links()
        installer_file_id = None
        if links:
            for index, file in enumerate(self.files):
                file_id = file.id
                if file.url.startswith("N/A"):
                    logger.debug("Removing file %s", file.id)
                    self.files.pop(index)
                    installer_file_id = file.id
                    break

        if not installer_file_id:
            raise ScriptingError("Could not match a GOG installer file in the files")

        for index, link in enumerate(links):

            filename = link.split("?")[0].split("/")[-1]

            if filename.lower().endswith((".exe", ".sh")):
                file_id = installer_file_id
            else:
                file_id = "gog_file_%s" % index

            logger.debug("Adding GOG file %s as %s", filename, file_id)
            self.files.append(
                InstallerFile(self.game_slug, file_id, {
                    "url": link,
                    "filename": filename,
                })
            )
コード例 #3
0
 def get_download_info(self, downlink):
     """Return file download information"""
     logger.info("Getting download info for %s", downlink)
     try:
         response = self.make_api_request(downlink)
     except HTTPError:
         raise UnavailableGame()
     if not response:
         raise UnavailableGame()
     for field in ("checksum", "downlink"):
         field_url = response[field]
         parsed = urlparse(field_url)
         query = dict(parse_qsl(parsed.query))
         response[field + "_filename"] = os.path.basename(
             query.get("path") or parsed.path)
     return response
コード例 #4
0
ファイル: interpreter.py プロジェクト: levpaul/lutris
 def swap_humble_game_files(self):
     """Replace the user provided file with download links from Humble Bundle"""
     if not self.humbleid:
         raise UnavailableGame("This installer has no Humble Bundle ID ('humbleid' in the game section)")
     installer_file_id = self.pop_user_provided_file()
     if not installer_file_id:
         raise UnavailableGame("Installer has no user provided file")
     try:
         link = get_humble_download_link(self.humbleid, self.runner)
     except Exception as ex:
         logger.exception("Failed to get Humble Bundle game: %s", ex)
         raise UnavailableGame
     if not link:
         raise UnavailableGame("No game found on Humble Bundle")
     filename = link.split("?")[0].split("/")[-1]
     self.files.append(
         InstallerFile(self.game_slug, installer_file_id, {
             "url": link,
             "filename": filename
         })
     )