def get_status(self, info_hash): """ Return torrent status. Example result: ``` 'hash': '35b814f1438054158b0bd07d305dc0edeb20b704' 'is_finished': False 'ratio': 0.0 'paused': False 'name': '[FFA] Haikyuu!!: To the Top 2nd Season - 11 [1080p][HEVC][Multiple Subtitle].mkv' 'stop_ratio': 2.0 'state': 'Downloading' 'progress': 23.362499237060547 'files': ({'index': 0, 'offset': 0, 'path': '[FFA] Haikyuu!!: To ...title].mkv', 'size': 362955692},) 'is_seed': False ``` """ if not self.connect(): log.warning('Error while fetching torrents status') return torrent = self.drpc._torrent_properties(info_hash) if not torrent: return False client_status = ClientStatus() if torrent['state'] == 'Downloading': client_status.add_status_string('Downloading') if torrent['paused']: client_status.add_status_string('Paused') # TODO: Find out which state the torrent get's when it fails. # if torrent[1] & 16: # client_status.add_status_string('Failed') if torrent['is_finished']: client_status.add_status_string('Completed') if torrent['ratio'] >= torrent['stop_ratio']: client_status.add_status_string('Seeded') # Store ratio client_status.ratio = torrent['ratio'] # Store progress client_status.progress = int(torrent['progress']) # Store destination client_status.destination = torrent['download_location'] # Store resource client_status.resource = torrent['name'] return client_status
def update_history_processed(self, process_results): """Update the history table when we have a processed path + resource.""" from medusa.schedulers.download_handler import ClientStatus status = ClientStatus() # Postpone the process, and setting the client_status. if not process_results.postpone_any: # Resource postprocessed status.add_status_string('Postprocessed') # If succeeded store Postprocessed + Completed. (384) # If failed store Postprocessed + Failed. (272) if process_results.result and not process_results.failed: status.add_status_string('Completed') self.success = True else: status.add_status_string('Failed') self.success = False self.update_resource(status) else: log.info( 'Postponed PP for: {path} and resource: {resource} keeping existing status', { 'path': self.path, 'resource': self.resource_name })