Oct 06
详情见 MeTube 主页,我这里流水账一下:
#安装、升级 npm / n apt install npm npm -g install n n lts cd metube/ui # 安装 Angular,构建 UI npm install node_modules/.bin/ng build # 安装 Python 依赖 cd .. pip3 install pipenv pipenv install python3 -m pip install aiohttp pipenv install aiohttp #安装 ffmpeg,合并音频视频,Youtube 新视频基本都需要合并 apt install ffmpeg # 自定义环境文件测试运行 export DOWNLOAD_DIR=/home/wwwroot/metube export URL_PREFIX=/metube pipenv run python3 app/main.py
正常会输出:
INFO:ytdl:waiting for item to download
======== Running on http://0.0.0.0:8081 ========
(Press CTRL+C to quit)
可以浏览器连接: http://VPS-IP:8081,测试一下下载,没问题往下走。
配置 Nginx 转发:
#主转发代码 location /metube/ { proxy_pass http://127.0.0.1:8081; proxy_redirect off; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_set_header Host $host; } #没有问题这一块可以不要 location ~* .(css|js)$ { proxy_pass http://127.0.0.1:8081; proxy_redirect off; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_set_header Host $host; }
添加到开机自动运行:
systemctl edit metube --full --force
粘贴如下代码,metube 源码路径,下载路径,反代目录,改成自己的:
[Unit] Description=Metube Web Service After=network.target [Service] Environment=DOWNLOAD_DIR=/home/wwwroot/metube Environment=URL_PREFIX=/metube Restart=always Type=simple WorkingDirectory=/root/src/metube ExecStart=/usr/local/bin/pipenv run python3 /root/src/metube/app/main.py [Install] WantedBy=multi-user.target
然后执行:
systemctl enable --now metube
metube 就启动了,并且下次开机也会自己启动。
追加:
添加简单的密码认证:
#生成密码文件,添加用户名 sudo sh -c "echo -n 'sammy:' >> /etc/nginx/.htpasswd" #为此用户设置密码 sudo sh -c "openssl passwd -apr1 >> /etc/nginx/.htpasswd"
然后添加到 metube 反代中:
location /metube/ { auth_basic "Administrator’s Area"; auth_basic_user_file /etc/nginx/.htpasswd"; ... }
引用本文,复制粘贴...