在服务器上离线下载并在线播放 Cloud Torrent
Cloud Torrent 是一个简单容易部署的服务器 BT 客户端,支持以 BT 种子或磁力链接创建离线下载,下载后可通过网页在线预览(需文件格式支持)。除了惯常在 VPS 上使用,像树莓派这种 ARM 设备也可以安装。
Cloud Torrent 安装
Cloud Torrent 是用 Go 语言编写的程序,无需安装运行环境就可以直接使用。如果想用 Docker 运行或从源代码构建(需安装 Go 环境),在 GitHub 项目页有相关介绍。
这里介绍二进制文件使用方法,适用 CentOS、Debian、Ubuntu 这些主流 Linux 发行版。
安装步骤:
1. 获取 Cloud Torrent,运行后会自动检测系统环境下载对应的二进制文件。
curl https://i.jpillora.com/cloud-torrent! | bash
安装后会显示程序路径,默认路径为 /usr/local/bin/cloud-torrent
。
2. 之后即可运行程序。
/usr/local/bin/cloud-torrent --host 0.0.0.0 --port 8080 --auth "user:password" --config-path /root/cloud-torrent.json --title "Cloud Torrent" --log >> /var/log/cloud-torrent.log
解释一下上面命令参数:监听本机 IP 使用 8080 端口,登录用户名 user 密码 password,指定程序配置文件(安装时已自动生成),设置网页标题,启用请求记录,将使用日志记录到指定文件。
根据自己需要修改选项参数,比如密码是必须要改的。完整选项可运行 cloud-torrent --help
查看。
运行后用浏览器访问你的服务器 IP 即可使用,网址格式为 http://X.X.X.X:8080/
。
如果不能访问,可能防火墙没有放行端口,需要设置一下(以 CentOS 为例)。
firewall-cmd --zone=public --add-port=8080/tcp --permanent firewall-cmd --reload
3. 手动运行有些麻烦,断开 SSH 会话会自动关闭。下面设置将程序放在后台运行并设置开机启动。
vi /usr/lib/systemd/system/cloud-torrent.service
创建服务文件,将下面内容粘贴保存。
[Unit] Description=cloud-torrent [Service] WorkingDirectory=/root/ ExecStart=/usr/local/bin/cloud-torrent --host 0.0.0.0 --port 8080 --auth "user:password" --config-path /root/cloud-torrent.json --title "Cloud Torrent" --log >> /var/log/cloud-torrent.log ExecStop=eval $(ps -ef | grep cloud-torrent | grep -v grep | awk '{print "kill "$2}') Restart=always RestartSec=3 [Install] WantedBy=multi-user.target
之后就可以用下面命令管理程序了。
- 设置开机自启:
systemctl enable cloud-torrent
- 取消开机自启:
systemctl disable cloud-torrent
- 手动启动程序:
systemctl start cloud-torrent
- 手动停止程序:
systemctl stop cloud-torrent
- 查看运行状态:
systemctl status cloud-torrent
如果你用的系统不支持 Systemd,可以将命令添加到 rc.local
文件设置开机启动(文件路径系统不同存有差异,具体请网上搜索),添加后别忘了确认文件是否有执行权限。
Cloud Torrent 使用
登录 Cloud Torrent 网页端会显示如下界面,使用非常简单,直接输入磁力链接即可创建离线下载。
若要搜索 Torrent 资源,也是在输入框内用关键词搜索,有多个搜索源可切换。右侧按钮可以从本地上传 BT 种子下载。下方文件列表可点击预览、删除、取回等操作。
右上角第一个按钮是选项设置,可以关闭上传、设置上传端口,自定义下载目录等设置。
在 VPS 上下载需留意主机商 TOS 条款,最好不要下载美剧那类版权资源,容易被停机。