對 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
。