def _update_status(self):

        status = self.debrid.torrent_info(self.transfer_info["id"])
        downloading_status = [
            "queued",
            "downloading",
            "compressing",
            "magnet_conversion",
            "waiting_files_selection",
        ]
        if "error" in status or status.get("status",
                                           "") in ["", "magnet_error"]:
            g.log("Failure to create cache: {} - {}".format(
                self.debrid_readable, status))
            raise FailureAtRemoteParty(status["error"])
        if status["status"] == "waiting_files_selection":
            self._select_files()
        if status["status"] in downloading_status:
            self.status = "downloading"
        elif status["status"] == "downloaded":
            self.status = "finished"
        else:
            g.log("invalid status: {}".format(status["status"]))
            self.status = "failed"

        self.seeds = status.get("seeders", 0)
        self.download_speed = status.get("speed", 0)

        self.previous_percent = self.current_percent
        self.current_percent = tools.safe_round(status["progress"], 2)
 def _select_files(self):
     if not self.file_keys:
         raise GeneralCachingFailure(
             "Unable to select any relevent files for torrent")
     g.log("Selecting files: {} - Transfer ID: {}".format(
         self.file_keys, self.transfer_id))
     response = self.debrid.torrent_select(self.transfer_id,
                                           ",".join(self.file_keys))
     if "error" in response:
         raise FailureAtRemoteParty(
             "Unable to select torrent files - {}".format(response))