README | 简体中文
Golang版本的M3U8下载器

# 默认安装到 /usr/local/bin
curl https://i.jpillora.com/cxjava/m3u8-downloader! | bash
# 或者
curl https://gobin.fly.dev/cxjava/m3u8-downloader! | bash
# 默认安装到 /usr/local/bin/
curl -sSfL https://goblin.run/github.com/cxjava/m3u8-downloader | sh
# 自定义路径为 /tmp
curl -sSfL https://goblin.run/github.com/cxjava/m3u8-downloader | PREFIX=/tmp sh
./m3u8-downloader p -h
With this command, you can ping multiple IPs to detect IP response speeds. Easily get the fastest CDN IPs.IP is separated by commas, for example: ./m3u8-downloader p 8.8.8.8,1.1.1.1,9.9.9.9, The have two output format, default output is speed of each IP, for example:
./m3u8-downloader p 8.8.8.8,1.1.1.1,9.9.9.9,
9.9.9.9 time: 23.9635ms
8.8.8.8 time: 61.2325ms
1.1.1.1 time: 225.7115ms
Other output is the parameter of download m3u8, for example:
./m3u8-downloader p 8.8.8.8,1.1.1.1,9.9.9.9, -d www.google.com -o p
-C 'www.google.com:8.8.8.8' -C 'www.google.com:1.1.1.1' -C 'www.google.com:9.9.9.9'
Usage:
m3u8-downloader ping [flags]
Aliases:
ping, p
Flags:
-d, --domain string Only avaliable when output type is 'p', domain to use output as a parameter, such as: -C 'www.google.com:1.1.1.1' -C 'www.google.com:8.8.8.8' (default "www.google.com")
-h, --help help for ping
-l, --logLevel string logging level on a Logger,logging levels: Trace, Debug, Info, Warning, Error, Fatal and Panic. (default "Info")
-o, --outputType string output type, can be 't' or 'p', if the type is 'p', it will print "-C 'www.example.com:1.1.1.1' -C 'www.example.com:9.9.9.9'". If the type is 't', it will print 8.8.8.8 time: 62.17ms (default "t")
Global Flags:
--config string config file (default is $HOME/.m3u8-downloader.yaml)

ping 命令查询每个IP的ping时间./m3u8-downloader p 8.8.8.8,1.1.1.1,9.9.9.9,
INFO[2021-09-16T08:56:33+08:00] Try to ping 8.8.8.8,1.1.1.1,9.9.9.9,
3 / 3 [-----------------------------------------------------------------------------------------] 100.00% 3 p/s 1.3s
8.8.8.8 time: 55.4175ms
9.9.9.9 time: 71.2685ms
1.1.1.1 time: 196.496ms
ping命令带上参数-o P -d www.google.com得到download命令需要的参数./m3u8-downloader ping 8.8.8.8,1.1.1.1,9.9.9.9, -d www.google.com -o p
INFO[2021-09-16T08:57:21+08:00] Try to ping 8.8.8.8,1.1.1.1,9.9.9.9,
3 / 3 [-----------------------------------------------------------------------------------------] 100.00% 3 p/s 1.3s
-C 'www.google.com:8.8.8.8' -C 'www.google.com:9.9.9.9' -C 'www.google.com:1.1.1.1'
-C 'www.google.com:8.8.8.8' -C 'www.google.com:9.9.9.9' -C 'www.google.com:1.1.1.1'到download命令里面./m3u8-downloader download -h
All ts segments will be downloaded into a folder then be joined into a single TS file.
Usage:
m3u8-downloader download [flags]
Aliases:
download, d
Flags:
-u, --baseUrl string base url for m3u8.
-C, --cdn stringArray CDN(s) for the download domain, eg. -C 'www.google.com:8.8.8.8' -C 'www.google.com:1.1.1.1' -C 'www.google.com:9.9.9.9' .
-d, --deleteSyncByte some TS files do not start with SyncByte 0x47, they can not be played after merging, need to remove the bytes before the SyncByte.
-D, --deleteTS delete all the downloaded TS file. (default true)
-f, --downloadDir string download directory, base on current folder. (default "./outputFolder")
-H, --header stringArray custom http header(s), eg. -H 'user-agent: Mozilla/5.0...' -H 'accept: */*' .
-h, --help help for download
--key string custom key to decrypt ts data.
--keyFormat string format of key, format can be those values: original, hex, base64. (default "original")
-l, --logLevel string logging level on a Logger,logging levels: Trace, Debug, Info, Warning, Error, Fatal and Panic. (default "Info")
-o, --output string file name for save.
-x, --proxy string use proxy. eg. http://127.0.0.1:8080
-n, --threadNumber int the number of download thread. (default 10)
Global Flags:
--config string config file (default is $HOME/.m3u8-downloader.yaml)
-u, --baseUrl string 覆盖下载m3u8的host
-C, --cdn stringArray CDN参数,例子如: -C 'www.google.com:8.8.8.8' -C 'www.google.com:1.1.1.1' -C 'www.google.com:9.9.9.9' .
-d, --deleteSyncByte TS二包头,参见: https://en.wikipedia.org/wiki/MPEG_transport_stream .
-D, --deleteTS 删除下载的TS文件,默认是true
-f, --downloadDir string 下载的目录. (默认是 "./outputFolder")
-H, --header stringArray 自定义请求头,参数兼容curl命令的参数,可以用chrome开发者工具,复制为cUrl命令。例如: -H 'user-agent: Mozilla/5.0...' -H 'accept: */*' .
-h, --help 帮助命令
--key string 自定义解密的key.
--keyFormat string 自定义秘钥的格式,有原始格式,hex格式,base64格式: original, hex, base64. (默认 "original")
-l, --logLevel string 日志级别: Trace, Debug, Info, Warning, Error, Fatal and Panic. (默认 "Info")
-o, --output string 下载之后的文件名称,建议设置为ts结尾.
-x, --proxy string 设置代理下载. 比如:http://127.0.0.1:8080
-n, --threadNumber int 下载请求的线程数量. (默认 10)
复制-->复制为cURL,如下图
curl 为 ./m3u8-downloader download, 如果有 --compressed 也去掉./m3u8-downloader download 'https://abc.com/def.m3u8' \
-H 'sec-ch-ua: "Microsoft Edge";v="93", " Not;A Brand";v="99", "Chromium";v="93"' \
-H 'accept: text/html' \
-H 'dnt: 1' \
-H 'x-requested-with: XMLHttpRequest' \
-H 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.63 Safari/537.36 Edg/93.0.961.47' \
-H 'accept-language: en,en-US;q=0.9' \
$ claude mcp add m3u8-downloader \
-- python -m otcore.mcp_server <graph>