Exemplo n.º 1
0
def process_profiles(json_settings, session_manager, site_name, original_api):
    apis = []
    profile_directories = json_settings["profile_directories"]
    for profile_directory in profile_directories:
        x = os.path.join(profile_directory, site_name)
        x = os.path.abspath(x)
        os.makedirs(x, exist_ok=True)
        temp_users = os.listdir(x)
        temp_users = remove_mandatory_files(temp_users)
        if not temp_users:
            default_profile_directory = os.path.join(x, "default")
            os.makedirs(default_profile_directory)
            temp_users.append("default")
        for user in temp_users:
            user_profile = os.path.join(x, user)
            user_auth_filepath = os.path.join(user_profile, "auth.json")
            api = original_api.start(session_manager)
            if os.path.exists(user_auth_filepath):
                temp_json_auth = ujson.load(open(user_auth_filepath))
                json_auth = temp_json_auth["auth"]
                if not json_auth.get("active", None):
                    continue
                json_auth["username"] = user
                api.auth.profile_directory = user_profile
                api.set_auth_details(json_auth)
            datas = {}
            datas["auth"] = api.auth.auth_details.__dict__
            export_data(datas, user_auth_filepath, encoding=None)
            apis.append(api)
            print
        print
    return apis
Exemplo n.º 2
0
def process_profiles(json_settings, original_sessions, site_name,
                     api: Union[OnlyFans.start]):
    profile_directories = json_settings["profile_directories"]
    for profile_directory in profile_directories:
        x = os.path.join(profile_directory, site_name)
        x = os.path.abspath(x)
        os.makedirs(x, exist_ok=True)
        temp_users = os.listdir(x)
        temp_users = remove_mandatory_files(temp_users)
        if not temp_users:
            default_profile_directory = os.path.join(x, "default")
            os.makedirs(default_profile_directory)
            temp_users.append("default")
        for user in temp_users:
            user_profile = os.path.join(x, user)
            user_auth_filepath = os.path.join(user_profile, "auth.json")
            datas = {}
            if os.path.exists(user_auth_filepath):
                temp_json_auth = ujson.load(open(user_auth_filepath))
                json_auth = temp_json_auth["auth"]
                if not json_auth.get("active", None):
                    continue
                json_auth["username"] = user
                auth = api.set_auth_details(json_auth)
                auth.session_manager.copy_sessions(original_sessions)
                auth.profile_directory = user_profile
                datas["auth"] = auth.auth_details.__dict__
            if datas:
                export_data(datas, user_auth_filepath)
            print
        print
    return api