A Docker container to automatically record Twitch streams.
This repository hosts the source code for a Docker container that can automatically record livestreams from Twitch as they go live. The main component is from Ancalentari Twitch Stream Recorder.
To run this container and record streams from Twitch, you need to register a dummy app and get a client_id and client_secret. Both is explained in the setup section.
Create a config.py
file in a directory of your choice (you will need to mount this file into the container later):
root_path = "/opt/recordings"
username = "gronkh"
client_id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
client_secret = "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"
root_path
- path in the container to where your VODs will be saved to (Don't change this!)
username
- name of the streamer you want to record by default (Change this accordingly!)
client_id
- you can grab this from here once you register your application (Replace with your own!)
client_secret
- you generate this here as well, for your registered application (Replace with your own!)
Start the container with the following docker run
command:
docker run \
-v /path/to/config.py:/opt/config.py \
-v /path/to/recordings:/opt/recordings \
ghcr.io/mkody/twitch-stream-recorder:master
The options in this command:
-v /path/to/config.py:/opt/config.py
Map the created config file to a defined location in the container, so the python script can find it.
-v /path/to/recordings:/opt/recordings
Map a folder of your choice to a defined location in the container. This is the place where all recordings will be saved to.
ghcr.io/mkody/twitch-stream-recorder:master
Use the "master" tag for the latest version, that's the GitHub branch from which the Docker images will be built.
You can also run it as a Docker Compose setup, see docker-compose.yml.
If you want to build the image while using Compose (ie. you changed the UID/GID) run docker-compose up -d --build
.
Open TODOs for future improvements:
- Run process as non-root user
- Add "latest" tag
- Switch to alpine based images
- Run GitHub Action on a regular base
- Separate container tags for the regular built images?
- How many versions of the image do i want to store on GitHub?