对 jkingsman 的Nobody.live 的 websocket (flask-socketio) 修改,允许用户在零观众的 twitch 流媒体上执行“突袭”(在本例中,用户全部集体收听同一流)。
工作脚本 ( scanner.py
) 循环遍历 Twitch API 的流列表并旋转,直到插入它找到的与搜索条件匹配的所有流媒体(默认零观看者),然后再次启动。这些流媒体作为过期密钥插入,假设有人会观看它们,然后它们将不再有零观看者,因此不应提供太长时间。如果流在后续传递中仍然有零观看者,则插入到 Redis 中将覆盖旧的过期时间,并且它们会停留更长时间。
需要设置的环境变量:
CLIENT_ID
:您的 Twitch 应用程序客户端 ID(可在 https://dev.twitch.tv/console 找到)CLIENT_SECRET
:您的 Twitch 应用程序客户端密钥(可在 https://dev.twitch.tv/console 找到)同时, app.py
中的 Flask 应用程序提供索引和端点以获取随机流媒体。
pip install -r requirements.txt
CLIENT_ID=xxxxxx CLIENT_SECRET=xxxxxx scanner.py
)。这需要连续运行。flask run
)这显然还没有准备好投入生产;你需要确保所有服务都作为守护进程运行(一些配置文件包含在etc
),并且你的flask应用程序正在安全运行(例如在gunicorn/nginx/pick你的毒药后面)(参见setting up deployment
)
setup.txt
)这是完整部署的过程,不是本地服务器的设置。有关设置本地服务器的说明,请参阅上文
cd /srv # wherever we want the app to be
git clone https://github.com/tybens/lonelyraids.com.git
cd lonelyraids.com
sudo apt-get update
sudo apt install python3-pip python3-dev python3-venv nginx
python3 -m venv venv
source venv/bin/activate
sudo pip3 install -r requirements.txt
# static files
sudo mkdir /var/www/static
sudo mv -v static/ * /var/www/static/
sudo chown 755 /var/www/static
# nginx config
sudo mv etc/lr-nginx /etc/nginx/sites-available/lr-nginx
sudo ln -s /etc/nginx/sites-available/lr-nginx /etc/nginx/sites-enabled/
sudo systemctl restart nginx
sudo ufw allow ' Nginx Full ' # not sure if this is necessary (the article said it was)
# redis setup
sudo wget http://download.redis.io/redis-stable.tar.gz
tar xvzf redis-stable.tar.gz
cd redis-stable
sudo make install
# supervisor setup
mkdir /var/log/streams
sudo mv etc/supervisor_services.conf /etc/supervisord.conf
sudo supervisord -c /etc/supervisord.conf # starts supervisord services
# certbot setup (for https:// ssl verification)
sudo snap install core
sudo snap refresh core
sudo snap install --classic certbot
sudo ln -s /snap/bin/certbot /usr/bin/certbot
sudo certbot --nginx
deactivate # deactivate venv...
更新requirements.in
中的直接依赖关系;如果您更新它们,请使用pip-compile
将它们编译为requirements.txt
。