Ejemplo n.º 1
0
def first_time_run():
    '''
    @summary: 第一次运行的工作
    '''
    Util.info_print('初始化')
    Util.info_print('创建resources目录', 1)
    location = locate.get_resources_folder()[:-1]
    Util.creat_a_folder(location)

    Util.info_print('创建lib目录', 1)
    location = locate.get_lib_folder()[:-1]
    Util.creat_a_folder(location)

    if Util.is_file_exists(locate.get_mhw_dinput8_file()):
        Util.info_print('尝试获取 StrackerLoader-dinput8.dll 的 MD5', 2)
        dinput8_dll_md5 = Util.get_file_MD5(locate.get_mhw_dinput8_file()) 
    else:
        dinput8_dll_md5 = ""

    to_install_VC()

    Util.info_print('创建conf.ini', 1)
    print('这次输入的信息会记录在conf.ini中,如果需要更改,用记事本修改conf.ini的内容即可')
    N_name = input('请输入N网账号或邮箱:')
    N_pwd = input('请输N网密码:')
    Conf_ini.creat_new_conf_ini(locate.get_conf_file(), dinput8_dll_md5, N_name, N_pwd)
Ejemplo n.º 2
0
def run():
    print("本程序由Recluse制作")
    print("本程序用于一键更新前置MOD-StrackerLoader")
    print("本程序不会用于盗号, 偷取信息 等非法操作")
    print("但由于源码是公开的, 可能存在被魔改成盗号程序的可能。故建议从github获取本程序。")
    print("github地址:https://github.com/RecluseXU/CheckStrackerLoader")
    print("B站联系地址:https://www.bilibili.com/video/av91993651")
    print("输入回车键开始")
    input('->')

    init_locate()

    # 信息获取
    if is_first_time_run():
        first_time_run()

    Util.info_print('检查StrackerLoader安装状态', 1)
    is_installed = Util.is_file_exists(locate.get_mhw_dinput8_file())
    Util.info_print('安装状态:\t'+str(is_installed), 2)

    Util.info_print('尝试获取 conf.ini信息', 1)
    Util.info_print('读取conf.ini', 2)
    conf_ini = Conf_ini(locate.get_run_folder())

    Util.info_print('尝试获取 Cookies 信息', 1)
    username, userpwd = conf_ini.get_nexus_account_info()
    get_cookies_info(username, userpwd)

    Util.info_print("获取MOD信息")
    Util.info_print('尝试获取N网 "Stracker\'s Loader" 文件信息页', 1)
    file_page_html, is_spider = get_mod_file_page(conf_ini.is_safe_to_spide())
    if is_spider:  # 更新最后一次爬虫的时间信息
        conf_ini.set_new_last_spide_time()

    Util.info_print(r'尝试分析文件页,得到 "Stracker\'s Loader" 最新版信息', 1)
    last_publish_date, last_download_url = analyze_mod_file_page(file_page_html)
    Util.info_print("最新版本上传日期\t" + str(last_publish_date), 2)
    Util.info_print("最新版本下载地址\t" + last_download_url, 2)
    last_publish_timeStamp = Util.transform_datetime_to_timeStamp(last_publish_date)
    installed_version_timeStamp = conf_ini.get_installed_SL_upload_date()
    if is_installed and last_publish_timeStamp == installed_version_timeStamp:
        Util.info_print("已安装的版本与最新版发布时间一致,无需更新")
        Util.warning_and_exit()

    Util.info_print('尝试获取N网 "Stracker\'s Loader" 最新版文件下载页', 1)
    download_page_html = spider_download_file_page(last_download_url)
    Util.info_print('尝试分析N网 "Stracker\'s Loader" 最新版文件下载页', 1)
    file_id, game_id = analyze_download_file_page(download_page_html)
    Util.info_print('game_id\t'+game_id, 2)
    Util.info_print('file id\t'+file_id, 2)

    Util.info_print('尝试获取N网 "Stracker\'s Loader" 最新版文件下载url', 1)
    download_url, file_type = spider_download_file(file_id, game_id)
    Util.info_print("最新版文件下载url\t" + download_url, 2)
    Util.info_print("最新版文件类型\t" + file_type, 2)

    Util.info_print('尝试下载"Stracker\'s Loader" 最新版文件', 1)
    dl_loader_location = locate.get_resources_folder() + 'StrackerLoader.' + file_type
    downloadFile(download_url, dl_loader_location, 'cf-files.nexusmods.com')

    Util.info_print("信息处理")
    Util.info_print('尝试解压"Stracker\'s Loader" 文件', 1)
    if file_type == 'zip':
        Util.unzip_all(dl_loader_location, locate.get_dl_loader_folder(), '')

    Util.info_print('尝试获取刚下载的"Stracker\'s Loader" 文件MD5', 1)
    dl_dll_location = locate.get_dl_loader_folder() + 'dinput8.dll'
    download_dll_md5 = Util.get_file_MD5(dl_dll_location)
    Util.info_print('刚下载的"Stracker\'s Loader" dll-MD5:\t'+download_dll_md5, 2)
    if is_installed and conf_ini.get_installed_mod_ddl_md5() == download_dll_md5:
        Util.info_print('刚下载的文件MD5 与 已安装的文件MD5一致, 无需更新', 2)
    else:
        Util.info_print('尝试覆盖安装', 1)
        Util.info_print('覆盖安装dinput8.dll', 2)
        Util.copy_file(dl_dll_location, locate.get_mhw_dinput8_file())
        Util.info_print('覆盖安装dinput-config.json', 2)
        dl_dinputconfig_location = locate.get_dl_loader_folder() + 'dinput-config.json'
        mhw_dinputconfig_location = locate.get_mhw_folder() + 'dinput-config.json'
        Util.copy_file(dl_dinputconfig_location, mhw_dinputconfig_location)
    Util.info_print('更新安装信息', 2)
    Util.info_print('更新 已安装版本N网作者上传时间信息', 3)
    conf_ini.set_installed_SL_upload_date(last_publish_date)
    Util.info_print('更新 已安装版本DLL的MD5 信息', 3)
    conf_ini.set_installed_mod_ddl_md5(download_dll_md5)

    locate.save_to_conf_ini_file()
    print('程序运行完毕\n3DM biss\n')
    Util.warning_and_exit(0)
Ejemplo n.º 3
0
def run():
    print("本程序由Recluse制作")
    print("本程序用于一键更新前置MOD-StrackerLoader")
    print("本程序不会用于盗号, 偷取信息 等非法操作")
    print("但由于源码是公开的, 可能存在被魔改成盗号程序的可能。故建议从github获取本程序。")
    print("github地址:https://github.com/RecluseXU/CheckStrackerLoader")
    print("B站联系地址:https://www.bilibili.com/video/av91993651")
    print("输入回车键开始")
    input()

    Util.info_print('初始化')
    Util.info_print('创建resources目录', 1)
    location = Util.get_resources_folder()[:-1]
    Util.creat_a_folder(location)
    Util.info_print('创建lib目录', 1)
    location = Util.get_lib_folder()[:-1]
    Util.creat_a_folder(location)

    # 信息获取
    Util.info_print("获取本地信息")
    Util.info_print('尝试获取 MHW 目录', 1)
    MHW_Install_Address = Util.get_MHW_Install_Address()
    Util.info_print('MHW 目录:\t' + MHW_Install_Address, 2)

    Util.info_print('尝试获取当前目录', 1)
    run_folder_location = Util.get_run_folder()
    Util.info_print('当前目录:\t' + run_folder_location, 2)

    Util.info_print('检查StrackerLoader安装状态', 1)
    is_installed = Util.is_file_exists(MHW_Install_Address + 'dinput8.dll')
    Util.info_print('安装状态:\t' + str(is_installed), 2)

    if is_installed:
        Util.info_print('尝试获取 StrackerLoader-dinput8.dll 的 MD5', 2)
        dinput8_dll_md5 = Util.get_file_MD5(MHW_Install_Address +
                                            'dinput8.dll')
    else:
        dinput8_dll_md5 = ""

    Util.info_print('尝试获取 conf.ini信息', 1)
    if not Util.is_file_exists(run_folder_location + 'conf.ini'):
        Util.info_print('conf.ini不存在,创建conf.ini', 2)
        print('这次输入的信息会记录在conf.ini中,如果需要更改,用记事本修改conf.ini的内容即可')
        N_name = input('请输入N网账号或邮箱:')
        N_pwd = input('请输N网密码:')
        Conf_ini.creat_new_conf_ini(run_folder_location + 'conf.ini',
                                    dinput8_dll_md5, N_name, N_pwd)
    Util.info_print('读取conf.ini', 2)
    conf_ini = Conf_ini(run_folder_location)

    Util.info_print('尝试获取 Cookies 信息', 1)
    username, userpwd = conf_ini.get_nexus_account_info()
    get_cookies_info(run_folder_location, username, userpwd)
    #
    Util.info_print("获取MOD信息")
    Util.info_print('尝试获取N网 "Stracker\'s Loader" 文件信息页', 1)
    file_page_html, is_spider = get_mod_file_page(conf_ini.is_safe_to_spide())
    if is_spider:  # 更新最后一次爬虫的时间信息
        conf_ini.set_new_last_spide_time()

    Util.info_print(r'尝试分析文件页,得到 "Stracker\'s Loader" 最新版信息', 1)
    last_publish_date, last_download_url = analyze_mod_file_page(
        file_page_html)
    Util.info_print("最新版本上传日期\t" + str(last_publish_date), 2)
    Util.info_print("最新版本下载地址\t" + last_download_url, 2)
    last_publish_timeStamp = Util.transform_datetime_to_timeStamp(
        last_publish_date)
    installed_version_timeStamp = conf_ini.get_installed_SL_upload_date()
    if is_installed and last_publish_timeStamp == installed_version_timeStamp:
        Util.info_print("已安装的版本与最新版发布时间一致,无需更新")
        Util.warning_and_exit()

    Util.info_print('尝试获取N网 "Stracker\'s Loader" 最新版文件下载页', 1)
    download_page_html = spider_download_file_page(last_download_url)
    Util.info_print('尝试分析N网 "Stracker\'s Loader" 最新版文件下载页', 1)
    file_id, game_id = analyze_download_file_page(download_page_html)
    Util.info_print('game_id\t' + game_id, 2)
    Util.info_print('file id\t' + file_id, 2)

    Util.info_print('尝试获取N网 "Stracker\'s Loader" 最新版文件下载url', 1)
    download_url, file_type = spider_download_file(file_id, game_id)
    Util.info_print("最新版文件下载url\t" + download_url, 2)
    Util.info_print("最新版文件类型\t" + file_type, 2)

    Util.info_print('尝试下载"Stracker\'s Loader" 最新版文件', 1)
    location = Util.get_resources_folder() + 'StrackerLoader.' + file_type
    downloadFile(download_url, location)

    Util.info_print("信息处理")
    Util.info_print('尝试解压"Stracker\'s Loader" 文件', 1)
    downloaded_mod_location = Util.get_resources_folder(
    ) + 'StrackerLoader.' + file_type
    downloaded_mod_unpack_location = Util.get_resources_folder(
    ) + 'StrackerLoade\\'
    if file_type == 'zip':
        Util.unzip_all(downloaded_mod_location, downloaded_mod_unpack_location,
                       '')

    Util.info_print('尝试获取刚下载的"Stracker\'s Loader" 文件MD5', 1)
    download_dll_location = Util.get_resources_folder(
    ) + '\\StrackerLoade\\dinput8.dll'
    download_dll_md5 = Util.get_file_MD5(download_dll_location)
    Util.info_print('刚下载的"Stracker\'s Loader" dll-MD5:\t' + download_dll_md5,
                    2)
    if is_installed and conf_ini.get_installed_mod_ddl_md5(
    ) == download_dll_md5:
        Util.info_print('刚下载MD5 与 已安装MD5一致,无需更新', 2)
        Util.info_print('更新 已安装版本DLL的MD5 信息', 3)
        conf_ini.set_installed_mod_ddl_md5(download_dll_md5)
        Util.info_print('更新 已安装版本N网作者上传时间信息', 3)
        conf_ini.set_installed_SL_upload_date(last_publish_date)
        Util.warning_and_exit()

    Util.info_print('尝试覆盖安装', 1)
    Util.info_print('覆盖安装dinput8.dll', 2)
    mhw_ddl_location = MHW_Install_Address + 'dinput8.dll'
    Util.copy_file(download_dll_location, mhw_ddl_location)
    Util.info_print('覆盖安装dinput-config.json', 2)
    download_dinputconfig_location = Util.get_resources_folder(
    ) + '\\StrackerLoade\\dinput-config.json'
    mhw_dinputconfig_location = MHW_Install_Address + 'dinput-config.json'
    Util.copy_file(download_dinputconfig_location, mhw_dinputconfig_location)
    Util.info_print('更新安装信息', 2)
    Util.info_print('更新 已安装版本N网作者上传时间信息', 3)
    conf_ini.set_installed_SL_upload_date(last_publish_date)
    Util.info_print('更新 已安装版本DLL的MD5 信息', 3)
    conf_ini.set_installed_mod_ddl_md5(download_dll_md5)

    print('程序运行完毕\n3DM biss')
    Util.warning_and_exit(0)