codeagencybe / django-twitch-archive

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool


This project creates a complete off side backup of the clips of a Twitch streamer. Top clips on the start page per week/month/ever, search function, sorting and statistics. A live demo can be seen here.


Font page


Search function



images/screenshot3.png images/screenshot4.png

Installation process

1. Clone repo and cd into it

git clone
cd django-twitch-archive

2. Get your .env file ready

Copy the "TEMPLATE.env" to ".env" and edit the file to your needs.

3. Create python virtual environment

python3 -m venv .venv

On Linux/Mac:

source .venv/bin/activate

On Windows:


4. Install python dependencies

pip install -r requirements.txt

5. Initialize database

python migrate

6. Create a superuser for the database

python createsuperuser

7. Add Twitch credentials to database

python runserver

Navigate to http://localhost:8000/admin/, login with your account created in the previous step.

Click on "Twitch Settingss" and add a new entry. There are 5 fields, but you just need to fill the 3 marked fields saying "CHANGE THIS".

"So what do I paste there?"

"Broadcaster name" is the twitch streamer you want to save the clips from. For example "shroud". Make sure it matches exactly the twitch username.

"Client id" and "Client secret" can be gathered from Create a new app, give it whatever name you like, add "http://localhost" as URL and select a category. Once done, twitch will give you a "Client-ID". Click on "New secret" and paste both into the django database and save it.

8. Add clips to database

python updateDB

This will search for all clips from the streamer. Not just Twitch's limit of 1000 clips but all clips available. Python will search for clips by week until the channel creation date is reached. This might take a while, since it's using the twitch api.

By now you can see the website at http://localhost:8000/ when you run the server. But there are no clips or images yet. Just metadata.

9. Download clips and thumbnails

python download

This will download all data available in our database to the MEDIA_ROOT path.

10. Run the server

python runserver

Congrats, we are up and running for development or private use. If you want to publish your archive, go on reading.

Going for production

If you deploy for production, you shouldn't use the default django key in your .env file. Go ahead and generate a new one.

python shell -c 'from import utils; print(utils.get_random_secret_key())'

Edit and paste the generated key in your .env file under "SECRET_KEY".

Also set DEBUG=False and enter your domain under ALLOWED_HOSTS.

Run python collectstatic to copy the static files to your webroot.

Next, setup your reverse proxy to forward everything to django except our STATIC_ROOT and MEDIA_ROOT files.

Caddy Server config {
    root * /var/www/
    @notStatic {
        not path /static/* /media/*
    reverse_proxy @notStatic localhost:8000
    encode gzip

Run it as a system service

I attached a file django-twitch-archive.service. Copy it to /etc/systemd/system/django-twitch-archive.service and modify the user, group and paths.

Next, run

sudo systemctl daemon-reload
sudo systemctl enable --now django-twitch-archive.service

Automatically update database and download clips

I've created a cronjob which does this automatically every hour.

@hourly /home/max/git/django-twitch-archive/.venv/bin/python /home/max/git/django-twitch-archive/ updateDB && /home/max/git/django-twitch-archive/.venv/bin/python /home/max/git/django-twitch-archive/ download && /home/max/git/django-twitch-archive/.venv/bin/python collectstatic --noinput

Change language

You can edit clips/ where it says class globalConf():.

It's not the best solution, but will work for now.


  • Better css. My css is horible
  • Dark mode toggle



Language:Python 61.3%Language:HTML 25.8%Language:CSS 6.7%Language:JavaScript 6.2%