基于 GoFileDownloader 重构的精简命令行版本,移除了 Rich 富文本依赖,新增 Cloudflare Workers 代理支持。
| 特性 | 原项目 | 本项目 |
|---|---|---|
| 依赖 | requests + rich | 仅 requests |
| UI | Rich 富文本实时面板 | 简洁命令行输出 |
| 代理 | 不支持 | --proxy 支持 Cloudflare Workers |
| 文件结构 | 多模块(8+ 文件) | 单包 |
| 批量下载 | URLs.txt 文件 | 暂不支持 |
| 进度条 | Rich 复杂面板 | 终端 █░ 进度条 |
| 安装方式 | 克隆仓库 | pip install gofile-dl-proxy |
pip install gofile-dl-proxy
安装后即可全局使用 gofile-dl 命令:
gofile-dl https://gofile.io/d/xxxxx
pipx install gofile-dl-proxy
git clone https://github.com/Lysagxra/GoFileDownloader.git
cd GoFileDownloader
pip install .
apt install -y python3 python3-pip && pip install requests && python3 gofile_dl/cli.py https://gofile.io/d/xxxxx --proxy https://c.map987.dpdns.org/ -o ./output -w 16
或:
apt install -y python3 python3-pip && pip install requests && python -m gofile_dl https://gofile.io/d/xxxxx --proxy https://c.map987.dpdns.org/ -o ./output -w 16
拉取并运行,参数与 pip 安装版完全一致,通过 -v 挂载目录保存文件:
docker pull docker.cnb.cool/kfc50/kemono-downloader-and-gofile-downloadef:latest && docker run --rm -v $(pwd)/output:/app/output docker.cnb.cool/kfc50/kemono-downloader-and-gofile-downloadef:latest https://gofile.io/d/xxxxx --proxy https://c.map987.dpdns.org/ -o /app/output -w 16
注意:
-v将宿主机目录挂载到容器内,-o参数需指向容器内的挂载路径(如/app/output),下载的文件才会保存到宿主机。
docker build -t docker.cnb.cool/kfc50/kemono-downloader-and-gofile-downloadef:latest .
docker push docker.cnb.cool/kfc50/kemono-downloader-and-gofile-downloadef:latest
gofile-dl https://gofile.io/d/xxxxx --proxy https://c.map987.dpdns.org/ -o ./output -w 16
positional arguments:
url GoFile URL (e.g. https://gofile.io/d/xxxxx)
options:
-h, --help show help message and exit
--password PASSWORD, -p PASSWORD
密码保护的相册密码
--output OUTPUT, -o OUTPUT
保存目录 (默认: ./Downloads)
--proxy PROXY Cloudflare Workers 代理 URL 前缀
--workers WORKERS, -w WORKERS
并发下载线程数 (默认: 3)
--sequential 顺序下载(默认并发下载)
--version, -V 显示版本号
GoFile 在国内时常无法连接,可通过 Cloudflare Workers 反代解决。
--proxy 参数会将代理 URL 前缀拼接到所有 GoFile 请求前:
原始请求: https://api.gofile.io/accounts
代理请求: https://c.map987.dpdns.org/https://api.gofile.io/accounts
代理会应用于所有三个阶段的请求(见下方下载流程)。
如果下载中断,再次运行相同命令即可自动续传。脚本会:
本项目全程走 GoFile API,无 HTML 页面抓取。流程如下:
POST https://api.gofile.io/accounts
→ 获取 accountToken
无需注册,GoFile 会自动创建一个临时访客账户,返回的 token 用于后续所有请求的认证。
基于 accountToken + 当前时间窗口,通过 SHA-256 计算生成
→ 获取 X-Website-Token(动态校验令牌)
这是 GoFile 的反爬机制,每 4 小时(14400 秒)变化一次。
GET https://api.gofile.io/contents/{contentId}?cache=true&sortField=createTime&sortDirection=1
Headers:
Authorization: Bearer {accountToken}
X-Website-Token: {websiteToken}
Cookie: accountToken={accountToken}
→ 获取文件名、下载链接、文件夹结构
contentId 从 URL 中提取,如 https://gofile.io/d/5tkZZi → 5tkZZiGET {download_link}(如 https://store1.gofile.io/download/...)
Headers:
Cookie: accountToken={accountToken}
Referer: {下载链接的源站}
→ 流式写入本地文件
-w 调整)当使用 --proxy https://c.map987.dpdns.org/ 时:
| 步骤 | 原始 URL | 代理后 URL |
|---|---|---|
| 创建账户 | https://api.gofile.io/accounts | https://c.map987.dpdns.org/https://api.gofile.io/accounts |
| 获取文件列表 | https://api.gofile.io/contents/xxx | https://c.map987.dpdns.org/https://api.gofile.io/contents/xxx |
| 下载文件 | https://store1.gofile.io/download/... | https://c.map987.dpdns.org/https://store1.gofile.io/download/... |
本项目使用双远程仓库策略:CNB(主仓库,含大文件)和 GitHub(发布仓库,仅源码)。主分支开发完成后,同步指定文件到 GitHub 发布分支,通过 GitHub Actions 自动发布到 PyPI。
| 远程 | 地址 | 分支 | 用途 |
|---|---|---|---|
origin (CNB) | https://cnb.cool/kfc50/kemono-downloader-and-gofile-downloadef.git | main | 主开发仓库,含大文件 |
github | https://github.com/Map9876/gofile-downloader-with-proxy.git | github-publish-clean | 发布仓库,仅源码 |
CNB 环境重启后只有 CNB 远程仓库,每次需要重新添加 GitHub remote:
# 1. 添加 GitHub 远程(从 PYPI_CREDENTIALS.md 获取 token)
git remote add github https://Map9876:<GITHUB_TOKEN>@github.com/Map9876/gofile-downloader-with-proxy.git
# 2. 拉取 GitHub 发布分支
git fetch github github-publish-clean
# 3. 切换到发布分支(首次用 orphan 方式,后续直接 checkout)
git checkout github-publish-clean
git checkout main
# 正常开发、提交...
git add .
git commit -m "feat: xxx"
git push origin main
只同步指定文件(避免泄露大文件、密钥、真实代理 URL 等):
# 切换到发布分支
git checkout github-publish-clean
# 从 main 分支检出需要同步的文件(按需选择)
git checkout main -- gofile_dl/ pyproject.toml README.md requirements.txt
# 注意:以下文件不要从 main 同步!
# - gofile_dl.py(旧版单文件,发布分支不需要)
# - PYPI_CREDENTIALS.md(密钥)
# - 5tkZZi/ 等大文件目录
# - 包含真实代理 URL 的文件(发布分支使用占位符 https://your-worker.example.com/)
发布分支的 commit 必须使用 GitHub noreply 邮箱,避免暴露 CNB 账号信息:
GIT_AUTHOR_NAME="Map9876" \
GIT_AUTHOR_EMAIL="Map9876@users.noreply.github.com" \
GIT_COMMITTER_NAME="Map9876" \
GIT_COMMITTER_EMAIL="Map9876@users.noreply.github.com" \
git -c commit.gpgsign=false add .
GIT_AUTHOR_NAME="Map9876" \
GIT_AUTHOR_EMAIL="Map9876@users.noreply.github.com" \
GIT_COMMITTER_NAME="Map9876" \
GIT_COMMITTER_EMAIL="Map9876@users.noreply.github.com" \
git -c commit.gpgsign=false commit -m "v1.0.2"
# 推送到 GitHub
git push github github-publish-clean
# 打 tag(同样用 noreply 身份)
GIT_AUTHOR_NAME="Map9876" \
GIT_AUTHOR_EMAIL="Map9876@users.noreply.github.com" \
GIT_COMMITTER_NAME="Map9876" \
GIT_COMMITTER_EMAIL="Map9876@users.noreply.github.com" \
git -c commit.gpgsign=false tag v1.0.2
git push github v1.0.2
# 通过 GitHub API 创建 Release(触发 Actions)
curl -X POST \
-H "Authorization: token <GITHUB_TOKEN>" \
-H "Accept: application/vnd.github+json" \
https://api.github.com/repos/Map9876/gofile-downloader-with-proxy/releases \
-d '{"tag_name":"v1.0.2","target_commitish":"github-publish-clean","name":"v1.0.2","body":"Release v1.0.2","draft":false,"prerelease":false}'
也可以在 GitHub 网页上手动创建 Release。
git checkout main
包含:gofile_dl/、pyproject.toml、README.md、requirements.txt、.github/、.gitignore、.gitattributes
排除:
5tkZZi/ 等大文件目录PYPI_CREDENTIALS.md(含密钥)gofile_dl.py(旧版单文件)dist/、__pycache__/、*.egg-info/、*.loghttps://your-worker.example.com/ 替代)在仓库 Settings → Secrets and variables → Actions 中添加:
PYPI_API_TOKEN:PyPI API Token(以 pypi- 开头)pip install build twine
python -m build
twine upload dist/*
# 用户名: __token__
# 密码: PyPI API Token
CNB 环境重启后,只有 origin (CNB) 远程,需要重新配置:
# 1. 添加 GitHub remote
git remote add github https://Map9876:<GITHUB_TOKEN>@github.com/Map9876/gofile-downloader-with-proxy.git
# 2. 拉取 GitHub 分支
git fetch github
# 3. 恢复本地发布分支
git checkout -b github-publish-clean github/github-publish-clean