def handle_player_stop(info_hash, name=None, initial_delay=0.5, listing_timeout=10): if not ask_to_delete_torrent(): return try: info = api.torrent_info(info_hash) except TorrestError: return if name is None: name = info.name sleep(int(initial_delay * 1000)) start_time = time.time() while getCondVisibility( "Window.IsActive(busydialog)" ) and not 0 < listing_timeout < time.time() - start_time: sleep(100) remove_torrent = Dialog().yesno(ADDON_NAME, name + "\n" + translate(30241)) if remove_torrent: api.remove_torrent(info_hash, delete=True) current_folder = getInfoLabel("Container.FolderPath") if current_folder == plugin.url_for(torrent_files, info_hash): executebuiltin("Action(Back)") elif current_folder == plugin.url_for(torrents): refresh()
def file_action(info_hash, file_id, action_str): if action_str == "download": api.download_file(info_hash, file_id) elif action_str == "stop": api.stop_file(info_hash, file_id) else: logging.error("Unknown action '%s'", action_str) return refresh()
def torrent_action(info_hash, action_str): needs_refresh = True if action_str == "stop": api.stop_torrent(info_hash) elif action_str == "download": api.download_torrent(info_hash) elif action_str == "pause": api.pause_torrent(info_hash) elif action_str == "resume": api.resume_torrent(info_hash) elif action_str == "remove_torrent": api.remove_torrent(info_hash, delete=False) elif action_str == "remove_torrent_and_files": api.remove_torrent(info_hash, delete=True) elif action_str == "torrent_status": torrent_status(info_hash) needs_refresh = False else: logging.error("Unknown action '%s'", action_str) needs_refresh = False if needs_refresh: refresh()