async def add_handler(args): torrents = [TorrentInfo.from_file(filename, download_dir=args.download_dir) for filename in args.filenames] if args.include: paths = args.include mode = 'whitelist' elif args.exclude: paths = args.exclude mode = 'blacklist' else: paths = None mode = None if mode is not None: if len(torrents) > 1: raise ValueError('Can\'t handle "--include" and "--exclude" when several files are added') torrent_info = torrents[0] if torrent_info.download_info.single_file_mode: raise ValueError("Can't select files in a single-file torrent") paths = [PATH_SPLIT_RE.split(path) for path in paths] torrent_info.download_info.select_files(paths, mode) async with ControlClient() as client: for info in torrents: await client.execute(partial(ControlManager.add, torrent_info=info))
async def control_action_handler(args): action = getattr(ControlManager, args.action) torrents = [TorrentInfo.from_file(filename, download_dir=None) for filename in args.filenames] # FIXME: Execute action with all torrents if torrents == [] async with ControlClient() as client: for info in torrents: await client.execute(partial(action, info_hash=info.download_info.info_hash))
async def resume_torrent(paths, download_dir): torrents = map( lambda path: TorrentInfo.from_file(path, download_dir=download_dir), paths) async with ControlClient() as client: for info in torrents: await client.execute(partial( ControlManager.resume, info_hash=info.download_info.info_hash))
def _torrent_info(self, torrent_filename, download_dir=None): from torrent_client.models import TorrentInfo torrent_info = TorrentInfo.from_file(torrent_filename, download_dir=download_dir) torrent_info = torrent_info.download_info return { "suggested_name": torrent_info.suggested_name, "archive_file": self._check_archive(torrent_info.file_tree), "info_hash": torrent_info.info_hash.hex(), }
def add_torrent_files(self, paths: List[str]): for path in paths: try: torrent_info = TorrentInfo.from_file(path, download_dir=None) self._control_thread.control.last_torrent_dir = os.path.abspath(os.path.dirname(path)) if torrent_info.download_info.info_hash in self._torrent_to_item: raise ValueError('This torrent is already added') except Exception as err: self._error_happened('Failed to add "{}"'.format(path), err) continue TorrentAddingDialog(self, path, torrent_info, self._control_thread).exec()
async def add_torrent(paths, download_dir): print("starting add_torrent... paths: {}".format(paths)) torrents = list( map( lambda path: TorrentInfo.from_file(path, download_dir=download_dir ), paths)) print("finished maping torrents... {}".format(torrents)) async with ControlClient() as client: print("In async function...") for info in torrents: print("awaiting execution of 'Controlmanager.add'" ) #TOFIX Tuple error in here! await client.execute(partial(ControlManager.add, torrent_info=info))
def show_handler(args): torrent_info = TorrentInfo.from_file(args.filename, download_dir=None) content_description = formatters.join_lines( formatters.format_title(torrent_info, True) + formatters.format_content(torrent_info)) print(content_description, end='')
def show_handler(args):#getting announce urls and download info from bencoded .torrent file..... torrent_info = TorrentInfo.from_file(args.filename, download_dir=None) content_description = formatters.join_lines( formatters.format_title(torrent_info, True) + formatters.format_content(torrent_info)) print(content_description, end='')
async def add_torrent(paths, download_dir): torrents = [TorrentInfo.from_file(path, download_dir=download_dir) for path in paths] async with ControlClient() as client: for info in torrents: await client.execute(partial(ControlManager.add, torrent_info=info))