if opts.host is None: # we didn't supply host in command line => load auth data from config opts.host = utorrentcfg["host"] if opts.user is None: opts.user = utorrentcfg["login"] if opts.password is None: opts.password = utorrentcfg["password"] if opts.api is None: opts.api = utorrentcfg["api"] if opts.ssl == False and "ssl" in utorrentcfg and utorrentcfg[ "ssl"] is not None: opts.ssl = utorrentcfg["ssl"] utorrent = None if opts.action is not None: utorrent = Connection(opts.host, opts.user, opts.password, opts.ssl).utorrent(opts.api) if opts.action == "server_version": print_console(utorrent.version().verbose_str() if opts. verbose else utorrent.version()) elif opts.action == "torrent_list": total_ul, total_dl, count, total_size = 0, 0, 0, 0 opts.sort_field = opts.sort_field.lower() # ensure that int is returned opts.limit = int(opts.limit) if not opts.sort_field in utorrent.TorrentClass.get_public_attrs( ) + utorrent.TorrentClass.get_readonly_attrs(): opts.sort_field = "name" for h, t in sorted(utorrent.torrent_list().items(), key=lambda x: getattr(x[1], opts.sort_field),
def __init__(self, host, username, password): self._conn = Connection(host, username, password).utorrent(api='falcon')