Ero-Lab部分游戏资源下载脚本

import os

import requests
import json


def test():
    index_url = "https://nidg.bhjsj8.com/new_patch/files/index.txt.623f677d60bab9e181b00a26f8bf2d77"

    try:
        response = requests.get(index_url, timeout=10)
        response.raise_for_status()
        data = json.loads(response.text)
        base_url = "https://nidg.bhjsj8.com/new_patch/files/{filename}.{hash}"
        with open("ssmx.txt", "w", encoding="utf-8") as outfile:
            for filename, values in data.items():
                if isinstance(values, list) and len(values) >= 2:
                    file_hash = values[1]
                    download_url = base_url.format(filename=filename, hash=file_hash)
                    outfile.write(f"{download_url}\n   out={filename}\n")
        print(f"共处理 {len(data)} 个资源条目。")
    except requests.exceptions.RequestException as e:
        print(f"下载资源清单失败: {e}")
    except json.JSONDecodeError as e:
        print(f"解析JSON数据失败: {e}")
    except Exception as e:
        print(f"发生未知错误: {e}")


if __name__ == "__main__":
    test()
    os.system("aria2c -i ssmx.txt -j 32 --check-certificate=false --dir=resdownload/绅士冒险")

试试看行不行

1 个赞