XstreamDL-CLI简单尝试和使用教程

本文最后更新于:3 个月前

前言


群内成员有会抓web-dl的,工具也挺多了,就是下载器如何用盒子下载,有人找了个GitHub地址丢给我,折腾了一晚上,虽说不是很懂,但是环境之类的总算弄好了。记录一下过程。

链接:https://github.com/xhlove/XstreamDL-CLI

过程


  1. 克隆项目到盒子。

git clone https://github.com/xhlove/XstreamDL-CLI.git

  1. 因为工具基于python3.7.4+的,所以得看看当前的python3版本

python3 --version

  1. 如果显示的版本低于3.7.4,那么就需要升级了,本次选择3.7.5版本的。
# 下载python包解压并进入
wget https://www.python.org/ftp/python/3.7.5/Python-3.7.5.tgz
tar zxvf Python-3.7.5.tgz
cd Python-3.7.5

# 配置,编译,安装
sudo apt-get install libffi-dev
./configure --with-ssl --enable-shared
make
sudo make install

# 删除旧的软连接
sudo rm -rf /usr/bin/python3
sudo rm -rf /usr/bin/pip3

# 添加python3的软链接
sudo ln -s /usr/local/bin/python3.7 /usr/bin/python3
# 添加 pip3 的软链接
sudo ln -s /usr/local/bin/pip3.7 /usr/bin/pip3

# 再度查看版本号
python3 --version

# 如果报错:python3: error while loading shared libraries: libpython3.7m.so.1.0: cannot open shared object file: No such file or directory
sudo apt-get install libpython3.7

# 然后就可以看到python3升级成功了
  1. 进人XstreamDL-CLI根目录进行环境配置:
pip3 install -r requirements.txt

# 如果报错:subprocess.CalledProcessError: Command '('lsb_release', '-a')' returned non-zero exit status 1.
sudo ln -s /usr/share/pyshared/lsb_release.py /usr/local/lib/python3.7/site-packages/lsb_release.py

# 提示pip版本低
ARNING: You are using pip version 19.2.3, however version 21.2.4 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
# 运行下述命令进行升级
pip3 install --upgrade pip

# 然后进行python包的安装
pip3 install -r requirements.txt
  1. pyinstaller打包:由于盒子没有界面,所以选择进行打包丢到/usr/bin目录下作为命令行工具使用。
pip3 install pyinstaller

pyinstaller -i logo.ico -n XstreamDL-CLI_v1.2.9 -F XstreamDL_CLI/__main__.py

# 如果出现ModuleNotFoundError: No module named '_ctypes'
sudo apt-get install libffi-dev

# 然后重新编译安装python3...所以我在后边又把这一句补回去了。。

# 打包完成会提示成功并且在XstreamDL-CLI根目录出现一个dist目录
INFO: Building EXE because EXE-00.toc is non existent
INFO: Building EXE from EXE-00.toc
INFO: Appending archive to ELF section in EXE /home/guai/XstreamDL-CLI/dist/XstreamDL-CLI_v1.2.9
INFO: Building EXE from EXE-00.toc completed successfully.

# dist目录下有一个可执行文件:
ls dist/
XstreamDL-CLI_v1.2.9

# 然后把这个文件拷贝到/usr/bin
cp ./dist/XstreamDL-CLI_v1.2.9 /usr/bin/XstreamDL-CLI

# 以后就可以执行该命令行了
XstreamDL-CLI,输入Xs可以按tab键补全。
  1. 帮助文档:XstreamDL-CLI -h即可召唤帮助文档
version 1.2.9, A downloader that download the HLS/DASH stream.
usage: XstreamDL-CLI [OPTION]... URL/FILE/FOLDER...

A downloader that download the HLS/DASH stream

positional arguments:
  URI                   URL/FILE/FOLDER string

optional arguments:
  -v, --version         Print version and exit
  -h, --help            Print help message and exit
  -name NAME, --name NAME
                        Specific stream base name
  -base BASE_URL, --base-url BASE_URL
                        Set base url for Stream
  -save-dir SAVE_DIR, --save-dir SAVE_DIR
                        Set save dir for Stream
  --ffmpeg FFMPEG       Set executable ffmpeg path
  --mp4decrypt MP4DECRYPT
                        Set executable mp4decrypt path
  --select              Show stream to select and download, default is to
                        download all
  --disable-force-close
                        Default make all connections closed securely, but it
                        will make DL speed slower
  --limit-per-host LIMIT_PER_HOST
                        Increase the value if your connection to the stream
                        host is poor, suggest >100 for DASH stream
  --user-agent USER_AGENT
                        set user-agent headers for request
  --referer REFERER     set custom referer for request
  --headers HEADERS     set custom headers for request, separators is |, e.g.
                        "header1:value1|header2:value2"
  --overwrite           Overwrite output files
  --raw-concat          Concat content as raw
  --disable-auto-concat
                        Disable auto-concat
  --enable-auto-delete  Enable auto-delete files after concat success
  --disable-auto-decrypt
                        Disable auto-decrypt segments before dump to disk
  --key KEY             <id>:<k>, <id> is either a track ID in decimal or a
                        128-bit KID in hex, <k> is a 128-bit key in hex
  --b64key B64KEY       base64 format aes key, only for HLS standard
                        AES-128-CBC encryption
  --hexiv HEXIV         hex format aes iv
  --proxy PROXY         use http proxy, e.g. http://127.0.0.1:1080
  --split               Dash option, split one stream to multi sections
  --repl                REPL mode

注意点:合并需要先将ffmpeg置于环境变量。

  1. 使用实例:
# 一般用法
XstreamDL-CLI --raw-concat --b64key oKi/hwKVuLveo/hISX1PQw== --hexiv b3d5ca56926d49d8e96b70aa5c7b358e --name 第一节总论  --save-dir /home/guai/Downloads/ https://hls.videocc.net/d06ae002cb/2/d06ae002cb4a0bed78fb912c874fdbb2_2.m3u8

# 其中--raw-concat表示要合并所有的分段, --b64key和 --hexiv参数不是很懂,欢迎大家讨论。-
# -name表示合并之后的视频名称,--save-dir表示下载路径,最后一个是m3u8的链接地址。
# ISM EXAMPLE
XstreamDL-CLI --select --overwrite http://playready.directtaps.net/smoothstreaming/SSWSS720H264/SuperSpeedway_720.ism/Manifest

# drm ism content
XstreamDL-CLI --disable-auto-concat --select --overwrite https://akamaicdn.hbogo.eu/5acb29be-eba0-46b1-8646-0e8354ff9cda_hbo/COMP/140258727_adr_comp_0cc2c364-5dba-4f1c-96f9-5640f98f5bbb_3400000_v2.ism/manifest

其他更多详情请查看GitHub链接,也可以下载exe桌面应用程序。

总结


你不努力,别人也会催着你努力,加油!!!



本博客所有文章除特别声明外,均采用 CC BY-SA 4.0 协议 ,转载请注明出处!