TwitchDownloader/README.md

144 lines
6.1 KiB
Markdown
Raw Normal View History

2022-12-03 08:57:56 -05:00
# Twitch Archive
Inspired by https://github.com/EnterGin/Auto-Stream-Recording-Twitch
2022-12-03 09:00:40 -05:00
2026-02-22 23:12:11 +01:00
## Git LFS
This repository stores large media files (recorded video and some binaries). Use Git LFS to manage large objects.
Quick setup (Windows):
1. Install Git LFS: `git lfs install`
2. Ensure `.gitattributes` is committed (this repo includes one).
3. If you already have large files tracked by normal Git, migrate them:
```powershell
git lfs install
git lfs track "*.mp4" "*.mkv" "bin/*"
git add .gitattributes
git add -A
git commit -m "Migrate large files to LFS"
git push origin main
```
Notes:
- Git LFS needs server-side support. If using GitHub, enable Git LFS on the remote and ensure you have sufficient bandwidth/storage quota.
- You can customize tracked patterns in `.gitattributes`.
2022-12-09 06:10:02 -05:00
Python script to check, download live stream, VOD, chat and upload them to any cloud storage supported by rclone.
## Docker
This repository now includes a Python-only container setup for the archiver. The dotnet subapp is not part of this container flow.
Files:
- `docker/python.Dockerfile`: production image for the Python archiver
- `docker-compose.yml`: deployment-oriented compose file
- `docker-compose.override.yml`: local development and testing override
- `.env.production`: production container and app environment template
- `.env.development`: development container and app environment template
- `dockerstart.bat`: Windows helper to run the container like the old batch launcher
### Container layout
- Mount your external archive folder to `/app/archive`
- Mount your external config folder to `/app/config`
- Put your `rclone.conf` file at `/app/config/rclone.conf` on the mounted host path
- The container exports `RCLONE_CONFIG=/app/config/rclone.conf`, so rclone will use that file automatically
### Production deployment
1. Edit `.env.production` with your image name, Twitch credentials, bind paths, and default arguments.
2. Place your streamer JSON files and `rclone.conf` in the mounted config folder.
3. Start the container:
```powershell
docker compose --env-file .env.production up -d
```
4. Follow logs:
```powershell
docker compose --env-file .env.production logs -f twitch-archive
```
### Development and local testing
The override compose file builds the image locally and mounts the repository for faster iteration.
Start it with:
```powershell
docker compose --env-file .env.development -f docker-compose.yml -f docker-compose.override.yml up --build
```
Run a one-off manual test for another streamer:
```powershell
docker compose --env-file .env.development -f docker-compose.yml -f docker-compose.override.yml run --rm twitch-archive python twitch-archive.py -u hackerling --verbose
```
Or use the Windows helper:
```powershell
.\dockerstart.bat vinesauce --verbose
```
That batch launcher mirrors the old pattern and expands to a compose `run` command, so you can test any streamer manually.
If the host has the NVIDIA Container Toolkit installed and you want FFmpeg/NVENC inside the container, use the optional NVIDIA override:
```powershell
.\dockerrebuild.bat
.\dockerstart.bat --nvidia vinesauce --verbose
```
The image built by `.\dockerrebuild.bat` already includes the NVIDIA-capable FFmpeg/container toolchain. The optional [docker-compose.nvidia.yml](docker-compose.nvidia.yml) layer is only for runtime GPU passthrough: it requests `gpus: all` and sets `NVIDIA_VISIBLE_DEVICES` plus `NVIDIA_DRIVER_CAPABILITIES=compute,utility,video` for the container.
On systems without NVIDIA support, keep using the normal command without `--nvidia`; the image still builds the same way, it just runs without GPU passthrough.
### Healthcheck and smoke tests
- Container healthcheck command: `python twitch-archive.py --healthcheck -u vinesauce`
- Rclone smoke test command: `python twitch-archive.py -u vinesauce --rclone-smoke-test`
The healthcheck verifies config loading plus `streamlink`, `ffmpeg`, `TwitchDownloaderCLI`, and `rclone` availability. The smoke test writes a tiny file, uploads it with the configured rclone remote, and prints the live rclone output into the container logs.
## ⚡ FFmpeg 8.0 Enhanced
Now with FFmpeg 8.0+ support featuring hardware acceleration and performance improvements!
- **5-10x faster encoding** with NVIDIA, Intel, or AMD GPUs
- **Docker-ready** with Linux builds
- **Configurable options** for different scenarios
- 📖 **[See FFMPEG_SETUP.md for detailed setup instructions](FFMPEG_SETUP.md)**
2022-12-03 08:57:56 -05:00
## Requirements
- [Python 3](https://www.python.org/downloads/)
- [Streamlink](https://github.com/streamlink/streamlink)
- [FFmpeg 8.0+](https://ffmpeg.org/download.html) (see [FFMPEG_SETUP.md](FFMPEG_SETUP.md) for platform-specific versions)
2022-12-03 08:57:56 -05:00
## Getting started
2022-12-09 06:10:02 -05:00
1. Install Python 3.x
2. Install Streamlink 5.1.x
3. If you want to upload to any cloud storage using rclone, [configure rclone](https://rclone.org/docs/#configure).
2022-12-03 09:08:38 -05:00
4. `git clone https://github.com/piero0920/Twitch-Archive.git`
2022-12-03 08:57:56 -05:00
5. `cd Twitch-Archive`
6. `pip install -r requirements.txt`
7. Edit the `.env.sample` and rename it to `.env`
2022-12-03 09:04:15 -05:00
```.env
2022-12-03 08:57:56 -05:00
CLIENT-ID=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
CLIENT-SECRET=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
2022-12-11 10:09:52 -05:00
OAUTH-PRIVATE-TOKEN=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx # optional to record without ADS or download sub-only VODS
2022-12-03 08:57:56 -05:00
```
2026-02-09 21:29:47 +01:00
8. Copy `config.sample.json` to `config.json` and edit it with your settings (username, quality, paths, etc.)
2022-12-03 08:57:56 -05:00
9. run `Python twitch-archive.py` or for multiple streamers `Python twitch-archive.py -u streamer`
2022-12-15 13:14:44 -05:00
[...](https://github.com/piero0920/Twitch-Archive/blob/main/extra.md)
2022-12-11 10:09:52 -05:00
<!---
2022-12-03 08:57:56 -05:00
## Features
2022-12-06 11:02:35 -05:00
- Auto records the live stream | [Streamlink](https://streamlink.github.io/)
- Downloads the VOD after stream ended | [Streamlink](https://streamlink.github.io/)
- Downloads the chat logs of the VOD and renders it | [TwitchDownloaderCLI](https://github.com/lay295/TwitchDownloader)
- Downloads the metadata of the VOD | [Twitch api](https://dev.twitch.tv/docs/api/reference#get-videos)
- Uploads them to the Cloud | [rclone](https://rclone.org/)
- Notifies you through Gmail of the progress | [smtplib](https://docs.python.org/3/library/smtplib.html)
2022-12-11 10:09:52 -05:00
-->