This bot allows users to create clips on specified Twitch channels via chat commands. It uses the Twitch API to capture and create clips and can be configured for multiple channels.
There are obviously other services that do this, but they are rate limited. If you host your own, you can do unlimited clipping (within reason).
- Create clips via chat command
!clip
- Supports multiple Twitch channels
- Provides error messages if clip creation fails.
- Python 3.7+
- Twitch Developer account
- Access Token with the
clips:edit
scope
git clone https://github.com/gorgarp/twitchclip.git
cd twitchclip
python3 -m venv venv
source venv/bin/activate
pip install twitchio requests
Update the clippy.py
script with your details:
CLIENT_ID
ACCESS_TOKEN
BOT_NICK
CHANNELS
BROADCASTER_IDS
- Go to the Twitch Developer Console and register a new application.
- Set the OAuth Redirect URL to
https://oauth-redirect.cloudapp.net/
or any other valid redirect URL you control. - Note down your
Client ID
andClient Secret
.
- Open the following URL in your browser, replacing
YOUR_CLIENT_ID
with your actual Client ID:
https://id.twitch.tv/oauth2/authorize?client_id=YOUR_CLIENT_ID&redirect_uri=https://oauth-redirect.cloudapp.net/&response_type=token&scope=clips:edit
- Authorize the application to access your Twitch account.
- Copy the access token from the URL fragment (
#access_token=YOUR_ACCESS_TOKEN
).
Use the following script to find the broadcaster ID:
import requests
CLIENT_ID = 'your_client_id'
ACCESS_TOKEN = 'your_access_token'
USERNAME = 'streamer_name'
headers = {
'Authorization': f'Bearer {ACCESS_TOKEN}',
'Client-Id': CLIENT_ID,
}
params = {
'login': USERNAME
}
response = requests.get('https://api.twitch.tv/helix/users', headers=headers, params=params)
user_info = response.json()
print(user_info['data'][0]['id'])
Create a service file /etc/systemd/system/clippy.service
:
[Unit]
Description=Twitch Clip Bot
After=network.target
[Service]
ExecStart=/path/to/venv/bin/python /path/to/twitchclip/clippy.py
WorkingDirectory=/path/to/twitchclip
StandardOutput=file:/var/log/clippy.log
StandardError=file:/var/log/clippy.err.log
Restart=always
User=root
Group=root
[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl start clippy.service
sudo systemctl enable clippy.service
sudo systemctl status clippy.service
Once the bot is running, users can create clips by typing !clip
in the configured Twitch channels. The bot will respond with a link to the created clip.
- Standard output:
/var/log/clippy.log
- Standard error:
/var/log/clippy.err.log
This project is licensed under the MIT License.