GolinksPRO Download Manager
  1. 主页
  2. 帮助
  3. 命令行和自动化

命令行和自动化

GDM can be driven without its window in three ways:

  • 应用程序自带的命令行,使用与 IDM 相同的开关:通过脚本、批处理文件或其他程序,将下载任务交给正在运行的应用程序。
  • misterdownloadmanager-cli,一个独立的命令行工具:无需打开应用程序,即可在终端中下载文件、视频和种子,并显示进度。
  • The automation API: other programs list the running app's downloads (as JSON) and pause, start, remove or delete them, over a local, token-protected channel. AI assistants use it through GDM's MCP server: see AI assistants.

To run the whole app without a window, on a home server or a NAS, see Run GDM on a server (misterdownloadmanager --headless); to control it from a phone, Control GDM from your phone.

示例使用 Windows 路径;在 macOS 和 Linux 上,程序名称相同,不带 .exe。

应用程序的命令行

misterdownloadmanager.exe /d URL [/p folder] [/f name] [/a] [/n] [/s]
开关 功能
/d URL 要下载的网址。
/p folder 将其保存到此文件夹(否则保存到选项 → 保存到中对应类别的文件夹)。
/f name 以此名称保存。
/a 将其添加到主下载队列,但不开始下载。
/n 静默模式:不显示下载文件信息窗口,立即开始下载(或使用 /a 将其加入队列)。
/s 开始主下载队列。
/exit 保存并关闭正在运行的应用程序(安装程序会在升级前使用此开关)。
/startup Start in the notification area, the window hidden: what Launch GolinksPRO Download Manager on startup starts GDM with when you sign in. Where no notification area shows GDM's icon (some Linux desktops), GDM starts minimized. A running GDM stays as it is.
一个 .torrent 文件或 magnet: 链接 Open it in Add torrent (what Windows passes when GDM opens torrents).

Switches can start with / or -, in any case. If GDM is running, the command goes to it; if not, GDM starts and carries it out. For example:

misterdownloadmanager.exe /d https://example.com/files/report.pdf /p D:\Reports /n
misterdownloadmanager.exe /d https://example.com/big.iso /a
misterdownloadmanager.exe /s

misterdownloadmanager-cli

It comes with every download of GDM, next to the app (the installer puts it in GDM's folder). It works on its own: the app needn't run, except for status and api.

命令 功能
get URL [-o folder\|file] [-c connections] [-H "Header: value"]... [--checksum hash] [--dns choice] [--adapter name] 下载文件,最多使用 8 个连接(-c,范围为 1 到 128),并显示进度。Ctrl+C 暂停下载;resume 继续下载。--checksum 检查已下载完成的文件:以十六进制格式显示 MD5、SHA-1、SHA-256、SHA-512 或 CRC32 校验和,也可以指定名称(sha256:…)。--dns 选择 DNS:system(默认);选择服务及其查询方式,cloudflare-https、quad9-tls、google-plain、adguard-https、nextdns-tls;指定 DNS 服务器地址,9.9.9.9,149.112.112.112;或指定 DNS-over-HTTPS 地址。它不会回退到系统 DNS。--adapter 通过一个网络适配器发送所有连接,可指定适配器名称(Ethernet、wg0)或其地址之一;如果适配器未连接,则不会发送任何内容,下载也会失败。文件托管网站的链接如果受网盘服务帐户(选项 → 帐户)支持,就会像在应用程序中一样通过该帐户处理;get 表示 through Real-Debrid;--direct 则直接下载该网址(网盘服务帐户)。
resume file.mdm.json [-c connections] [-H ...] [--direct] 从同一文件夹中的 .mdm.json 文件继续已暂停或中断的下载。通过网盘服务帐户继续下载时,使用 get:旧链接过期后,服务会提供新链接;--direct 则从原网址继续下载。
install-gallery-dl 安装或更新用于下载图片图库的 gallery-dl:使用作者的签名密钥验证其校验和列表,再根据该列表验证程序(适用于 Windows 和 Linux x86-64;其他系统需自行安装)。
gallery-get URL [-o folder] [--limit N] [--adapter name] 将图库中的图片(如 Wikimedia Commons 分类、Flickr 相册等)下载到 -o 中以图库名称命名的文件夹;--limit 限制下载数量,最多下载网站列出的前若干张图片。再次运行时,只下载新增图片。--adapter 通过一个网络适配器发送 gallery-dl 的连接,方式与 get 相同。
video-info URL 查看网页中包含的视频(YouTube、Vimeo 等)以及可选画质。
playlist-info URL [--from N] [--count N] 列出播放列表或频道中的视频,每行一个,按列表顺序显示其位置、时长、标题和网址。
playlist-get URL [-f selector] [-o folder] [--from N] [--count N] 将播放列表或频道中的视频逐个下载到 -o 中以列表名称命名的文件夹。-f 为所有视频选择相同画质,选项与 video-get 相同(默认选择每个视频的最佳画质;bv*[height<=720]+ba/b[height<=720] = 最高 720p;ba = 原始音频;mp3:320、opus:、flac: 与 video-get 相同)。
video-get URL [-f selector] [-o folder] [--subs langs] [--auto-subs] [--embed-subs] [--adapter name] 下载视频;-f 从 video-info 中选择画质选项(b = 最佳的单个文件;ba = 网站提供的纯音频,不进行转换;mp3:320、mp3:256、mp3:192 或 mp3:128 = 转换为指定比特率的 MP3 音频,mp3:0 = 转换为最佳可变比特率;opus: = 转换为 Opus;flac: = 转换为 FLAC,无损,但音质不会优于网站提供的音频;转换需要 ffmpeg)。--subs 将字幕保存到视频文件旁边:指定 video-info 中的语言代码(en,fr),或使用 all 下载上传者提供的所有字幕;--auto-subs 改为使用网站的自动字幕;--embed-subs 将字幕嵌入视频(需要 ffmpeg,支持 MP4 或 MKV)。--adapter 通过一个网络适配器发送 yt-dlp 和 ffmpeg 的连接,方式与 get 相同;如果适配器未连接,则不会开始下载。
install-ytdlp, install-ffmpeg Install or update the helpers videos need: yt-dlp (checked against its signing key) and ffmpeg (Windows; on macOS and Linux GDM uses the system's).
torrent-info SOURCE 种子的名称、文件(编号)和大小;SOURCE 是磁力链接或 .torrent 文件。
torrent-get SOURCE [-o folder] [--files 0,2] [--use-existing] 下载种子,或只下载其中部分文件。如果文件夹中已存在其中部分文件,操作会停止并列出这些文件;--use-existing 会使用这些文件(保留匹配的部分,下载其余部分)。
torrent-create PATH -o file.torrent 为文件或文件夹创建 .torrent(对等方通过 DHT 找到它)。
status 正在运行的应用程序的下载,以 JSON 格式显示,包含其 ID(自动化 API 必须开启)。
pause ID..., start ID... 暂停正在运行的下载,或在运行中的应用里开始(恢复)已停止、已排队或失败的下载。
remove ID..., delete ID... 将下载从运行中的应用列表中移除:remove 保留文件,delete 也删除文件。正在进行的下载会先暂停(pause)。
api on, api off 开启或关闭运行中的应用的自动化 API。

misterdownloadmanager-cli help <command>显示所有选项。如果命令失败(应用未运行,应用返回错误,下载中断),则以代码 1 退出。例如:

misterdownloadmanager-cli get https://example.com/big.iso -o D:\Downloads -c 16 --checksum sha256:9f86d0…
misterdownloadmanager-cli video-get "https://www.youtube.com/watch?v=aqz-KE-bpKQ" -f "b[height=720]"
misterdownloadmanager-cli torrent-get "magnet:?xt=urn:btih:…" --files 0

用于脚本和程序的 JSON

使用 --json(在命令之前或之后),每个命令都会打印 JSON 而不是文本,每行一个对象,供脚本和 AI 代理读取:

命令 打印
get, resume {"event": "through", "service"}首先当下载通过网盘服务帐户时,然后每半秒一行{"event": "progress", "downloaded", "size", "speed", "connections", "segments"},然后{"event": "done", "path", "size", "seconds"},或者在Ctrl+C之后{"event": "paused", "state"}(state是resume获取的文件)。
video-get {"event": "progress", "downloaded", "size", "speed"}行,然后 {"event": "done", "path", "subtitles", "subtitle_problems"}:旁边保存的字幕文件,以及网站拒绝的语言({"code", "name", "reason", "beside"};beside:它们在第二次尝试时出现,在视频旁边而不是在视频中)。
torrent-get {"event": "progress", "phase", "downloaded", "size", "speed", "peers", "peers_seen"}行,然后是 {"event": "done", "path", "size"},或者 --seconds 的 {"event": "stopped", "downloaded", "seconds"}。
video-info {"title", "choices": [{"label", "format", "size"}], "subtitles": [{"code", "name", "automatic"}]};一个选项的 format 是 video-get -f 所接受的,一个字幕的 code 是 --subs 所接受的。
torrent-info {"name", "info_hash", "size", "files": [{"index", "size", "path"}]}.
torrent-create {"info_hash", "path"}.
install-ytdlp, install-ffmpeg {"tool", "version", "path"}.
status、pause、start、remove、delete、api 应用的回答,已经是 JSON 格式(见下文)。

大小以字节为单位(null 表示未知),速度以字节每秒为单位。失败会打印 {"error": "…"} 并以代码 1 退出。例如:

misterdownloadmanager-cli --json get https://example.com/big.iso -o D:\Downloads
{"event":"progress","downloaded":4194304,"size":1073741824,"speed":52428800,"connections":8,"segments":8}
…
{"event":"done","path":"D:\\Downloads\\big.iso","size":1073741824,"seconds":20.4}

自动化 API

其他程序可以询问正在运行的应用正在下载什么,并暂停、开始、移除或删除下载。API 默认关闭;使用 misterdownloadmanager-cli api on 开启(使用 api off 关闭)。

How a program talks to GDM

  1. While it runs, GDM listens on a port of 127.0.0.1 (this computer only) and writes the port and a secret token to ipc.json in its data folder: - Windows: %APPDATA%\misterdownloadmanager\ipc.json - macOS: ~/Library/Application Support/misterdownloadmanager/ipc.json - Linux: ~/.local/share/misterdownloadmanager/ipc.json - A portable copy: data\ipc.json next to the program.

The token changes at every start; only programs that can read your data folder (yours) can use it. 2. Connect to that port and send one line of JSON: the token and the command's fields, e.g. {"token": "<token>", "query": "list"}. 3. GDM answers with one line: ok for a command, or a JSON object for a question.

支持的操作

字段(除了 token) 回答
{"query": "list"} 每个下载和总速度:{"downloads": [{"id", "file", "url", "path", "status", "size", "downloaded", "speed", "added", "category", "error"}], "speed": bytes per second, "queues": [{"name", "running", "ids"}], "categories": [{"key", "name"}], "free": bytes}。status 是 Queued、Downloading、Stopped、Complete 或 Error;size 在未知时是 null;error(失败原因)仅在下载处于 Error 状态时存在;category 是类别的 key;free 是下载存储的可用空间(未知时为 null)。仅在 API 开启时可用。
{"action": "pause", "ids": [3, 4]} 根据 ID 操作下载:"pause"、"start"、"remove"(保留文件)或 "delete"(也删除文件)。返回 {"done": [3], "skipped": [{"id": 4, "why": "not running"}]};移除或删除正在进行的下载前,必须先暂停。仅在 API 开启时可用。
{"action": "start_queue", "queue": "Main download queue"} 启动(或使用 "stop_queue" 停止)该名称的队列(列表中的 queues 名称)。回答 {"done": [], "skipped": []} 或 {"error": …, "code": "unknown-queue"}。仅在 API 开启时可用。
{"api": true} / {"api": false} 开启或关闭 API:{"api": true}。
{"url": "https://…", "dir": "D:\\Files", "name": "a.zip", "silent": true} 添加下载,如同命令行中的 /d /p /f /n("later": true 是 /a);ok。"category"(列表中的 categories 键)将其放入该类别的文件夹,而不是其类型选择的文件夹;"queue"(队列名称)是它与 "later" 一起等待的队列。在 API 关闭时也可用,如同命令行。
{"start_queue": true} 启动主下载队列;ok。

当 API 关闭时,未知的问题或操作会得到{"error": "…"}的回答(此时会显示"code": "api-off",供程序检查:错误文本可能会更改)。错误的令牌会得到denied的回答。

每个请求和回答都按字段在 JSON Schema 中描述:automation-api.schema.json(也在 https://misterdownloadmanager.com/automation-api.schema.json)。它由应用回答的代码生成,因此保持精确;程序可以根据它检查发送和读取的内容,或从中生成其类型。

示例

PowerShell (Windows):

$ep = Get-Content "$env:APPDATA\misterdownloadmanager\ipc.json" | ConvertFrom-Json
$client = New-Object Net.Sockets.TcpClient("127.0.0.1", $ep.port)
$stream = $client.GetStream()
$writer = New-Object IO.StreamWriter($stream); $reader = New-Object IO.StreamReader($stream)
$writer.WriteLine((@{ token = $ep.token; query = "list" } | ConvertTo-Json -Compress))
$writer.Flush()
$reader.ReadLine() | ConvertFrom-Json | Select-Object -ExpandProperty downloads | Format-Table file, status, downloaded, size
$client.Close()

Python:

import json, os, socket

ipc = os.path.join(os.environ["APPDATA"], "misterdownloadmanager", "ipc.json")  # see above elsewhere
ep = json.load(open(ipc))
with socket.create_connection(("127.0.0.1", ep["port"])) as s:
    s.sendall((json.dumps({"token": ep["token"], "query": "list"}) + "\n").encode())
    answer = json.loads(s.makefile().readline())
for d in answer["downloads"]:
    print(d["file"], d["status"], d["downloaded"], d["size"])

若要添加下载,请发送{"token": "…", "url": "https://example.com/a.zip", "silent": true}。

免费、开源、无广告、无试用版。

Download GolinksPRO Download Manager