/twitch-live-discord

Python script to post Twitch Live stream details to a channel in Discord

Primary LanguagePython

twitch-live-discord

Python script to authenticate against the Twitch API, get live user details and then post a rich text message to a channel in Discord. The reason I built this instead of using a bot is that most bots do not add a random number to the preview URL, resulting in a cached image in Discord

Setup

  • Register an application with Twitch. Note the Client ID and Client Secret

twitch-app

  • Create a Webhook in Discord. Note the Webhook URL

webhook

brew install python
/opt/homebrew/bin/python3 -m pip install --break-system-packages python-dotenv requests
  • Create a .env file in the root directory to put the follow variables
TWITCH_USER="twitch_streamer_name"
CLIENT_ID="<your twitch app client id"
CLIENT_SECRET="<your twitch dev secret>"
WEBHOOK_URL="https://discord.com/api/webhooks/<REST OF THE URL>

Execute the script

  • Run the script to with the following command.
python3 script.py
  • Example output in Discord discord

StreamDeck Integration

  • To launch with StreamDeck Use the System -> Open option

Windows

wsl.exe "/usr/bin/python3" "/home/user/git/twitch-live-discord/script.py"

Mac

  • StreamDeck will only open .sh files so select bash-python.sh

you will need to edit the hardcoded path to script.py inside this file to match your system

streamdeck