A simple Python π server that redirects to a YouTube πΊ channel's most recent live chat π¬ URL.
This script is primarily intended to run as a local server that can be embedded as multiple browser sources or Browser Docks in OBS Studio. The server will redirect π to the most recent live chat URL for the given YouTube channel ID.
My OBS setup references YouTube live chat URLs in three different places; it was
tedious updating them all prior to going live π‘ Now I reference http://localhost:8008
instead and the server takes care of the rest.
The script does not use YouTube APIs, it will blindly π derive a live chat URL
from the most recent videoId
found for the given channel; even if that videoId
wasn't a live stream. This is by design to keep things simple.
usage: redirect-livechat.py [-h] [--addr ADDR] [--port PORT] channel_id
YouTube live chat re-director
positional arguments:
channel_id youtube channel ID
optional arguments:
-h, --help show this help message and exit
--addr ADDR, -a ADDR ip address
--port PORT, -p PORT port to listen on
example:
redirect-livechat.py UCQvWX73GQygcwXOTSf_VDVg
This will start a webserver on localhost:8008, the output looks something like this:
Directing to https://www.youtube.com/live_chat?dark_theme=1&is_popout=1&v=D87-XmWigY0 via localhost:8008
127.0.0.1 - - [18/Feb/2021 13:30:15] "GET / HTTP/1.1" 302 -
Ctrl + C exits.
Run the following commands to build and run the Docker container:
$ docker build -t redirect-livechat .
$ docker run -p 8008:8008 -it redirect-livechat -a 0.0.0.0 UCQvWX73GQygcwXOTSf_VDVg
- Clone this git repository
- Run
redirect-livechat.py
with a YouTube channel ID. - Update your OBS browser source(s) and Browser Dock(s) to reference
http://localhost:8008
- Make a Snap
- Make a Docker