使用docker 快速运行BT下载器,可持久保存资源,可在线播放 — webtorrent-cli – dockerfile

# dockerfile 构建 docker images
mkdir -p ./test01 && cd ./test01
tee dockerfile <<EOF  
FROM node:lts-alpine
WORKDIR /app
RUN apk add --no-cache git && npm cache clean -f >/dev/null 2>&1 && npm install webtorrent-cli -g && npm cache clean -f >/dev/null 2>&1
ENTRYPOINT [ "node", "/usr/local/lib/node_modules/webtorrent-cli/bin/cmd.js" ]
EOF
docker build -t btwget:v1 . && rm -rf ../test01
docker images btwget
# REPOSITORY   TAG       IMAGE ID       CREATED          SIZE
# btwget       v1        0cbfca5a1df9   59 seconds ago   151MB

快速启动 webtorrent-cli 脚本

#!/bin/bash
# vim /usr/bin/btwget
dport=`echo $RANDOM`
# dwork 改成你需要保存的视频文件的路径
dwork=\'/opt/btdown\'
# dip 改成 你的ip
dip=\'192.168.1.2\'
docker run --rm -d --name "bt_$dport" -p "$dport":8000  -v $dwork:/app btwget:v4 $1
clear
while :
do
    durl=`docker logs -n 200 "bt_$dport" | grep \'.*http\' | awk \'NR == 1 {print $4}\' | sed "s/localhost:8000/$dip:$dport/"`
    if [ -n "$durl" ];then
        sleep 1
        clear
        break
    fi
done
echo "容器 name为: bt_$dport, 查看日志 执行 docker logs -n 50 bt_$dport"
echo "在线观看地址为: $durl"

webtorrent-cli 脚本 使用方说明

# 启动方式
btwget \'磁力链接\'

搭配 nginx 网页服务器,进行局域网内在线点播

yum -y install epel-release
yum -y install nginx
# 开启目录索引,查看功能
    location /video {
        alias /opt/btdown;
        autoindex on;
        autoindex_exact_size off;
        autoindex_localtime on;
    }

复制url ,使用播放器进行播放

版权声明:本文为yunweizhijun原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/yunweizhijun/p/14459151.html