Skip to main content

xes-assets

零依赖下载器 / Zero-dependency downloader for the XES Python course asset files:

  • https://livefile.xesimg.com/programme/python_assets/3f51c62b04d3aacc27b0d53f294ecc3b.rar
  • https://livefile.xesimg.com/programme/python_assets/a3635617bd88675041ba69f8398df5a0.zip

只用 Python 标准库(urllib、hashlib、zipfile),没有任何第三方依赖。 Uses nothing but the Python standard library — no third-party dependency at all.

安装 + 导库即下载 / Install & import-to-download

pip install xes-assets
import xes_assets          # 导入即自动下载两个文件到当前工作目录
print(xes_assets.AUTODOWNLOADED)   # [Path(...rar), Path(...zip)]

import xes_assets 会立刻把两个文件下载到当前工作目录(含断点续传、大小 + SHA-256 校验); 已存在且校验通过的文件直接跳过。

环境变量 作用
XES_ASSETS_DEST 下载目录(默认当前工作目录)
XES_ASSETS_AUTODOWNLOAD=0 导入时不下载(退回手动调用 API)
XES_ASSETS_QUIET=1 不显示进度条
# 指定目录导入
import os; os.environ["XES_ASSETS_DEST"] = r"D:\xes"
import xes_assets

导入失败(断网等)会抛 XesAssetError 并提示设置 XES_ASSETS_AUTODOWNLOAD=0。

命令行 / CLI

CLI 不会触发导入时下载,只做你指定的动作:

xes-assets --list                        # 查看两个文件的信息
xes-assets zip -d D:\xes                 # 下载 ZIP
xes-assets all -d D:\xes -x              # 下载两个并解压
xes-assets rar --verify-only -d D:\xes   # 只校验已下载文件
python -m xes_assets all -d D:\xes       # 等价写法
参数 说明
ASSET(位置参数) rar、zip、all、文件名或 URL;省略时等于 all
-d, --dest DIR 输出目录(默认当前目录)
-x, --extract 下载后解压(RAR 需要外部解压工具,见下)
-f, --overwrite 覆盖已存在文件
--no-verify 跳过 SHA-256 校验
-q, --quiet 不显示进度
--verify-only 只校验不下载
--list 列出已知文件

Minecraft 文件(按需下载,导入时不会下载)

同一个桶里还有两个 MC 文件。它们体积大,没有放进 ASSET_ORDER,所以 import xes_assets 和 xes-assets all 都不会碰它们,必须点名下载:

xes-assets mc-save -d D:\xes      # 9.2 MB  存档:金州高中主档(Minecraft 1.16.4)
xes-assets mc-win7 -d D:\xes      # 378 MB  32 位 Win7 / 2GB 内存的老电脑用的全离线启动包
from xes_assets import download
download("mc-save", r"D:\xes")    # 解压后是 saves\金州高中主档\
download("mc-win7", r"D:\xes")    # 解压后是 MC-Win7-1.16.5\,双击 Start-Game.bat 进游戏

mc-win7 里有:HMCL 3.6.20(官方"旧版"线,要求 Java 8+、支持 Windows 7)、Minecraft 1.16.5 的 version json + client.jar + 42 个 Windows 库 + natives\(含 32 位 dll)、1.16 资源索引和全部 2596 个资源文件(318.5 MiB,全程不用联网),外加一份 32 位 Java 8(Azul Zulu 8u181 win32)和两个 .bat。选 1.16.5 是因为存档本身是 1.16.4 建的,而原压缩包那套 Minecraft 26.1 要求 Java 25 (没有 32 位 Windows 版),老机器装不上。

Python API

from xes_assets import ASSETS, download, download_all, download_on_import, extract, verify

download("zip", r"D:\xes")            # -> Path,含大小 + SHA-256 校验
download_all(r"D:\xes")               # 两个都下
download_on_import(r"D:\xes")         # 同导入行为,可指定目录
verify("rar", r"D:\xes")              # -> True/False
extract("zip", r"D:\xes")             # 标准库解压,返回目录
extract("rar", r"D:\xes")             # 需外部 7z / UnRAR(见下)

单个函数的行为:

  • download(key, dest=".", *, overwrite=False, verify_checksum=True, progress=None, timeout=60, retries=3) 先写 <文件名>.part,校验大小与 SHA-256 通过后才原子改名为正式文件;断点续传用 HTTP Range (服务器返回 206 时继续,否则从头开始),网络中断自动重试。
  • download_all(dest=".", *, keys=None, **kwargs) → List[Path]
  • extract(key, dest=None, *, archive=None, overwrite=False) → 解压目录 Path
  • verify(key, path=None, dest=".") → bool
  • asset_path(key, dest=".") → 预期的本地路径
  • AUTODOWNLOADED 为本次导入已下载/已确认的路径列表
  • ASSETS / ASSET_ORDER 为元数据常量;XesAssetError 为统一异常

文件与校验值 / Files

key 文件名 大小 SHA-256
rar 3f51c62b04d3aacc27b0d53f294ecc3b.rar 568,456,521 B ea41b34bd193cf0039386c0cfe22f93c2225bb43ef01d69740106a35e05d7c85
zip a3635617bd88675041ba69f8398df5a0.zip 39,463,900 B 63fdddb6c37849606ae32d08e522bbd2a627be90971005946b6c332a7715ff93
mc-save 3d613c7ffd23634cf78feeb85cecc8ca.zip 9,624,157 B 8d18d4c12ad8708b749233fa94065dce41188f44b522272d4e64e4a85132d624
mc-win7 c4474573ca108a11a7d62c693431d18a.zip 396,793,993 B 66b9f1e89c25a706362def04132d51e9e706d08b296697066d239958ceeb0b60

后两个是 MC 文件,只在点名下载时取(见上节)。

校验值在主文件被上游替换前一直有效;上游变更时下载会明确报 checksum mismatch (不会静默留下坏文件)。

关于 RAR 解压 / About RAR extraction

下载永远只需要标准库。解压 .rar 时本包会依次查找 7z / 7zz / 7za / unrar / unar / bsdtar(PATH 中或常见安装路径 C:\Program Files\7-Zip\7z.exe、C:\Program Files\WinRAR\UnRAR.exe), 找不到就抛 XesAssetError 并提示手工解压。ZIP 解压完全由标准库完成。

Changelog

  • 1.2.0 — 新增两个按需下载的 MC 文件 mc-save(1.16.4 存档)与 mc-win7(32 位 Win7 / 2GB 内存的全离线 1.16.5 启动包,含 HMCL 3.6.20 + 全部资源 + 32 位 Java 8);--list 现在用 [auto] / [only] 标出哪些是导入时下载、哪些要点名;ON_DEMAND_ORDER 常量。导入时自动下载的文件集合没有变化(仍是 rar + zip)。
  • 1.1.0 — import xes_assets 直接下载(XES_ASSETS_DEST / XES_ASSETS_AUTODOWNLOAD / XES_ASSETS_QUIET),新增 download_on_import() 与 AUTODOWNLOADED;CLI 不再触发导入下载。
  • 1.0.0 — 首个版本:手动下载 API + CLI,断点续传、大小/SHA-256 校验。

License

MIT

Metadata

Release files for xes-assets 1.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for xes-assets 1.2.0
File Size Uploaded Provenance Actions
xes_assets-1.2.0.tar.gz 17.0 kB Without provenance Details for xes_assets-1.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for xes-assets 1.2.0
File Interpreter ABI Platform Actions
xes_assets-1.2.0-py3-none-any.whl Python 3 none any Details for xes_assets-1.2.0-py3-none-any.whl

Total release size: 31.8 kB

Release files / xes_assets-1.2.0.tar.gz

Download URL xes_assets-1.2.0.tar.gz
Size 17.0 kB
Tags Source
SHA-256 checksum
How to use checksums
e5f5a18fd296fda1c23c846723daa09e7f544854c09314ba4bee76460735b799
BLAKE2b-256 checksum
How to use checksums
1f01c34dff6841ec0312f6838093b248b5abbde8296b6c0833c4d6fe2c46551e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.9

Release files / xes_assets-1.2.0-py3-none-any.whl

Download URL xes_assets-1.2.0-py3-none-any.whl
Size 14.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e7f6cd8f4847e2d353fdc42dedfb500f601effb2a2fb329e820b136fa6c03566
BLAKE2b-256 checksum
How to use checksums
2388b2178016065ea70db32d89597537a85a3be66eba02eb7028cf1e04262c81
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.9

Security for xes-assets 1.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page