def process_batch_job(caller: PixivUtil2): caller.set_console_title("Batch Menu") if os.path.exists(_default_batch_filename): jobs_file = open(_default_batch_filename, encoding="utf-8") jobs = demjson.decode(jobs_file.read()) for job_name in jobs["jobs"]: print(f"Processing {job_name}") curr_job = jobs["jobs"][job_name] if "enabled" not in curr_job or not bool(curr_job["enabled"]): print(f"Skipping {job_name} because not enabled.") continue if "job_type" not in curr_job: print(f"Cannot find job_type in {job_name}") continue job_option = JobOption(curr_job, caller.__config__) if curr_job["job_type"] == '1': handle_members(caller, curr_job, job_name, job_option) elif curr_job["job_type"] == '2': handle_images(caller, curr_job, job_name, job_option) elif curr_job["job_type"] == '3': handle_tags(caller, curr_job, job_name, job_option) else: print(f"Unsupported job_type {curr_job['job_type']} in {job_name}") else: print(f"Cannot found {_default_batch_filename} in the application folder, see https://github.com/Nandaka/PixivUtil2/wiki/Using-Batch-Job-(Experimental) for example. ")
def process_batch_job(caller: PixivUtil2, batch_file=None): PixivHelper.get_logger().info('Batch Mode from json (b).') caller.set_console_title("Batch Menu") if batch_file is None: batch_file = _default_batch_filename batch_file = os.path.abspath(batch_file) if os.path.exists(batch_file): jobs_file = open(batch_file, encoding="utf-8") jobs = json.load(jobs_file) total_job = len(jobs["jobs"]) active_job = len( [y for y in jobs["jobs"] if jobs["jobs"][y]["enabled"]]) PixivHelper.print_and_log( "info", f"Found {active_job} active job(s) of {total_job} jobs from {batch_file}." ) for job_name in jobs["jobs"]: PixivHelper.print_and_log("info", f"Processing {job_name}") curr_job = jobs["jobs"][job_name] if "enabled" not in curr_job or not bool(curr_job["enabled"]): PixivHelper.print_and_log( "warn", f"Skipping {job_name} because not enabled.") continue if "job_type" not in curr_job: PixivHelper.print_and_log( "error", f"Cannot find job_type in {job_name}") continue job_option = JobOption(curr_job, caller.__config__) if curr_job["job_type"] == '1': handle_members(caller, curr_job, job_name, job_option) elif curr_job["job_type"] == '2': handle_images(caller, curr_job, job_name, job_option) elif curr_job["job_type"] == '3': handle_tags(caller, curr_job, job_name, job_option) else: PixivHelper.print_and_log( "error", f"Unsupported job_type {curr_job['job_type']} in {job_name}" ) else: PixivHelper.print_and_log( "error", f"Cannot found {batch_file}, see https://github.com/Nandaka/PixivUtil2/wiki/Using-Batch-Job-(Experimental) for example. " )
def prepare(): ## Log in username = __config__.username if username == "": username = raw_input("Username ? ") password = __config__.password if password == "": password = getpass.getpass("Password ? ") result = False if len(__config__.cookie) > 0: result = PixivUtil2.pixiv_login_cookie() if not result: if __config__.useSSL: result = PixivUtil2.pixiv_login_ssl(username, password) else: result = PixivUtil2.pixiv_login(username, password) return result
def prepare(): ## Log in username = __config__.username if username == '': username = raw_input('Username ? ') password = __config__.password if password == '': password = getpass.getpass('Password ? ') result = False if len(__config__.cookie) > 0: result = PixivUtil2.pixivLoginCookie() if not result: if __config__.useSSL: result = PixivUtil2.pixivLoginSSL(username,password) else: result = PixivUtil2.pixivLogin(username,password) return result
def prepare(): ## Log in username = __config__.username if username == '': username = raw_input('Username ? ') password = __config__.password if password == '': password = getpass.getpass('Password ? ') result = False if len(__config__.cookie) > 0: result = PixivUtil2.pixiv_login_cookie() if not result: if __config__.useSSL: result = PixivUtil2.pixiv_login_ssl(username, password) else: result = PixivUtil2.pixiv_login(username, password) return result
def prepare(): global br PixivUtil2.__config__.loadConfig() br = PixivUtil2.configBrowser() ## Log in username = PixivUtil2.__config__.username if username == '': username = raw_input('Username ? ') password = PixivUtil2.__config__.password if password == '': password = getpass.getpass('Password ? ') result = False if len(PixivUtil2.__config__.cookie) > 0: result = PixivUtil2.pixivLoginCookie() if not result: if PixivUtil2.__config__.useSSL: result = PixivUtil2.pixivLoginSSL(username,password) else: result = PixivUtil2.pixivLogin(username,password)