def main() : (cli_parser, config_dict, argv_list) = config.partialParser(sys.argv[1:], description="Add torrent to the data model \"t.data\"") config.addArguments(cli_parser, config.ARG_MKDIR_MODE, config.ARG_DATA_DIR, config.ARG_SOURCE_DIR, config.ARG_TIMEOUT, config.ARG_CLIENT, config.ARG_CLIENT_URL, config.ARG_SET_CUSTOMS, ) cli_parser.add_argument("--link-to", dest="link_to_path", action="store", default=None, metavar="<path>") cli_parser.add_argument("torrents_list", type=str, nargs="+") cli_options = cli_parser.parse_args(argv_list) config.syncParsers(config.SECTION_RTLOAD, cli_options, config_dict) if len(cli_options.torrents_list) > 1 and not cli_options.link_to_path is None : print >> sys.stderr, "Option -l/--link-to be used with only one torrent" sys.exit(1) if cli_options.client_name is None : print >> sys.stderr, "Required client" sys.exit(1) socket.setdefaulttimeout(cli_options.socket_timeout) client = clientlib.initClient( clients.CLIENTS_MAP[cli_options.client_name], cli_options.client_url, set_customs_dict=cli_options.set_customs_dict ) loadTorrent(client, cli_options.src_dir_path, cli_options.torrents_list, cli_options.data_dir_path, cli_options.link_to_path, cli_options.mkdir_mode, cli_options.set_customs_dict, )
def main() : (cli_parser, config_dict, argv_list) = config.partialParser(sys.argv[1:], description="Update rtorrent files from popular trackers") config.addArguments(cli_parser, config.ARG_SOURCE_DIR, config.ARG_BACKUP_DIR, config.ARG_NAMES_FILTER, config.ARG_ONLY_FETCHERS, config.ARG_TIMEOUT, config.ARG_INTERACTIVE, config.ARG_NO_INTERACTIVE, config.ARG_SKIP_UNKNOWN, config.ARG_NO_SKIP_UNKNOWN, config.ARG_PASS_FAILED_LOGIN, config.ARG_NO_PASS_FAILED_LOGIN, config.ARG_SHOW_PASSED, config.ARG_NO_SHOW_PASSED, config.ARG_SHOW_DIFF, config.ARG_NO_SHOW_DIFF, config.ARG_CHECK_VERSIONS, config.ARG_NO_CHECK_VERSIONS, config.ARG_REAL_UPDATE, config.ARG_NO_REAL_UPDATE, config.ARG_URL_RETRIES, config.ARG_URL_SLEEP_TIME, config.ARG_PROXY_URL, config.ARG_CLIENT, config.ARG_CLIENT_URL, config.ARG_SAVE_CUSTOMS, config.ARG_NO_COLORS, config.ARG_USE_COLORS, config.ARG_FORCE_COLORS, config.ARG_NO_FORCE_COLORS, ) cli_options = cli_parser.parse_args(argv_list) config.syncParsers(config.SECTION_RTFETCH, cli_options, config_dict, ( # For fetchers: validate this options later config.OPTION_LOGIN, config.OPTION_PASSWD, config.OPTION_URL_RETRIES, config.OPTION_URL_SLEEP_TIME, config.OPTION_PROXY_URL, config.OPTION_INTERACTIVE, )) socket.setdefaulttimeout(cli_options.socket_timeout) fetchers_list = initFetchers(config_dict, cli_options.url_retries, cli_options.url_sleep_time, cli_options.proxy_url, cli_options.interactive_flag, cli_options.only_fetchers_list, cli_options.pass_failed_login_flag, ) if len(fetchers_list) == 0 : print >> sys.stderr, "No available fetchers in config" sys.exit(1) if len(fetchers_list) != len(fetchers.FETCHERS_MAP) : cli_options.skip_unknown_flag = True if cli_options.check_versions_flag and not fetcherlib.checkVersions(fetchers_list) : sys.exit(1) print client = None if not cli_options.client_name is None : client = clientlib.initClient( clients.CLIENTS_MAP[cli_options.client_name], cli_options.client_url, save_customs_list=cli_options.save_customs_list, ) update(fetchers_list, client, cli_options.src_dir_path, cli_options.backup_dir_path, cli_options.names_filter, cli_options.save_customs_list, cli_options.skip_unknown_flag, cli_options.pass_failed_login_flag, cli_options.show_passed_flag, cli_options.show_diff_flag, cli_options.real_update_flag, cli_options.no_colors_flag, cli_options.force_colors_flag, )