Skip to content

trakt/discord-presence

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

24 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Discord Trakt Presence Bot

🎬 Automatically show what you're watching on Trakt.tv in your Discord status!

This bot connects your Trakt.tv account to Discord, displaying your current TV shows and movies as a "Watching" activity in your Discord profile.

✨ Features

  • 🎭 Proper "WATCHING" status - Shows as "Watching [Show]" not "Playing [Show]"
  • πŸ–ΌοΈ Show artwork - Displays movie/TV show posters as your activity image
  • πŸ”„ Auto-sync - Updates every 15 seconds when you're watching something
  • πŸ”Œ Reconnects automatically - Handles Discord restarts and connection issues
  • πŸ“Ί TV Shows & Movies - Works with both TV episodes and movies
  • πŸ–₯️ Cross-platform - Works on Windows, macOS, and Linux

πŸš€ Quick Start

Prerequisites

Step 1: Download & Install

  1. Download this project:

    git clone git@github.com:trakt/discord-presence.git
    cd discord-presence

    Command tip: Use whichever command launches Python 3 on your system. On macOS this is usually python3 / pip3; on Windows it may just be python / pip.

  2. Install Python dependencies:

    python3 -m pip install -r requirements.txt

Step 2: Create a Trakt.tv App

  1. Go to Trakt.tv API settings:

  2. Fill out the application form:

    • Name: Discord Presence (or any name you like)
    • Description: Shows my Trakt activity in Discord
    • Redirect URI: urn:ietf:wg:oauth:2.0:oob
    • Permissions: None needed
  3. Save your credentials:

    • After creating, you'll see:
      • Client ID - Copy this code
      • Client Secret - Copy this (keep it secret! keep it safe!)
    • Click on your app name to see the Application ID (different from Client ID!). Easiest way is to read the ID from the end of the URL.

Step 3: Discord App (Optional - Default Provided)

Good news! This project includes a default Discord app called "TV with Trakt" that you can use immediately.

Option A: Use the default app (recommended for beginners)

  • Skip this step! The default Discord Client ID is already in .env.example
  • Your status will show as "Watching TV with Trakt"

Option B: Create your own custom Discord app

  1. Go to Discord Developer Portal:

  2. Create your application:

    • Name: Choose any name (this appears in your Discord status)
    • Click "Create"
  3. Get your Discord Client ID:

    • On the "General Information" page
    • Copy the Application ID (this is your Discord Client ID)
    • Replace the default value in your .env file

Step 4: Configure the Bot

  1. Copy the example configuration:

    cp .env.example .env
  2. Edit the .env file with your Trakt credentials:

    TRAKT_CLIENT_ID=your_trakt_client_id_here
    TRAKT_CLIENT_SECRET=your_trakt_client_secret_here
    TRAKT_APPLICATION_ID=your_trakt_application_id_here
    DISCORD_CLIENT_ID=1387827471822622850  # Default app (or use your own)
    

    Note: The Discord Client ID has a working default value. Only change it if you created your own Discord app.

Step 5: Run the Bot

Option A: Quick Test (Recommended First)

python3 main.py

Option B: Install as Daemon (Linux - Runs Automatically)

# Install and enable automatic startup
python3 service.py install

# Management commands
python3 service.py start    # Start the daemon
python3 service.py stop     # Stop the daemon  
python3 service.py status   # Check if running
python3 service.py logs     # View logs
python3 service.py uninstall # Remove daemon

First-time setup (both options):

  • The bot will open a browser for Trakt.tv authentication
  • Log in to Trakt.tv and authorize the app
  • Copy the PIN code back to the terminal
  • Your credentials will be saved for future use

Check Discord:

  • Make sure Discord is running
  • Start watching something on Trakt.tv (check-in to a show/movie)
  • Your Discord status should update automatically!

πŸ“± How to Use

Check-in to Something on Trakt

  1. Go to Trakt.tv or use the Trakt mobile app
  2. Find a TV show or movie you're watching
  3. Click the "Check In" button (▢️ icon)
  4. Your Discord status will update within 15 seconds!

What You'll See in Discord

🎬 Watching TV with Trakt
   Shark Tank
   S16E2 - Episode 2
   [Show poster image]
   Started watching 5 minutes ago

πŸ€– Daemon Mode (Linux)

The bot can run as a system daemon that automatically starts on boot and runs in the background.

Quick Daemon Setup:

# Test your configuration first
python3 service.py test

# Install and enable daemon
python3 service.py install

# Check if it's running
python3 service.py status

Daemon Features:

  • βœ… Auto-start on login - No need to manually start
  • βœ… Background operation - Runs silently in background
  • βœ… Automatic restart - Restarts if it crashes
  • βœ… System integration - Uses systemd for proper service management
  • βœ… Log management - Logs to system journal

Daemon Management:

python3 service.py start     # Start the daemon
python3 service.py stop      # Stop the daemon  
python3 service.py restart   # Restart the daemon
python3 service.py enable    # Enable auto-start on login
python3 service.py disable   # Disable auto-start
python3 service.py status    # Show current status
python3 service.py logs      # View recent logs (Ctrl+C to exit)
python3 service.py uninstall # Remove daemon completely

🍎 Daemon Mode (macOS)

Launchd support lets the bot run automatically whenever you log in.

Quick LaunchAgent Setup:

# Test your configuration first
python3 service.py test

# Install and load the LaunchAgent
python3 service.py install

# Check if it's running
python3 service.py status

LaunchAgent Management:

python3 service.py start     # Load and start the LaunchAgent
python3 service.py stop      # Unload (stop) the LaunchAgent
python3 service.py restart   # Reload the LaunchAgent
python3 service.py enable    # Enable auto-start on login
python3 service.py disable   # Disable auto-start
python3 service.py status    # Show LaunchAgent status
python3 service.py logs      # Tail the launch agent logs
python3 service.py uninstall # Remove the LaunchAgent

Launchd writes stdout/stderr to logs/trakt-discord*.log. Use python3 service.py logs (Ctrl+C to exit) or tail -f logs/trakt-discord.log for live output.

Platform Support:

  • βœ… Linux - systemd integration
  • βœ… macOS - launchd integration
  • ⚠️ Windows - Manual setup (instructions provided)

Windows daemon automation is planned for a future release.

πŸ› οΈ Troubleshooting

General Issues

"Could not connect to Discord"

  • βœ… Make sure Discord Desktop app is running (not just web browser)
  • βœ… Restart Discord completely
  • βœ… Try running the bot as administrator (Windows)

"Authentication failed"

  • βœ… Double-check your Trakt credentials in .env
  • βœ… Make sure you copied the Application ID (not just Client ID)
  • βœ… Verify redirect URI is exactly: urn:ietf:wg:oauth:2.0:oob

"Not watching anything"

  • βœ… Check-in to something on Trakt.tv first
  • βœ… Make sure you're actively checked in (not just marked as watched)
  • βœ… Try checking in to a different show/movie

Discord shows "Playing" instead of "Watching"

  • βœ… Make sure your Discord app is named "TV with Trakt"
  • βœ… Restart Discord to clear cache
  • βœ… Wait a few minutes for Discord to update

Daemon Issues

"systemctl not found" or "systemd not available"

  • βœ… You're not on a systemd Linux distribution
  • βœ… Run manually: python3 main.py --daemon
  • βœ… Use your distribution's service manager (upstart, OpenRC, etc.)

Daemon installed but not starting

  • βœ… Check logs: python3 service.py logs
  • βœ… Verify configuration: python3 service.py test
  • βœ… Check if Discord is running: ps aux | grep -i discord

Daemon running but Discord not updating

  • βœ… Make sure you're logged into the same user account where Discord runs
  • βœ… Check if you're checked into something on Trakt.tv
  • βœ… View daemon logs: journalctl --user -u trakt-discord-presence -f

πŸ”§ Advanced Configuration

Running as a Daemon (Background Service)

Cross-Platform - Automatic Installation:

This project includes scripts to easily install the app as a daemon that starts automatically on login. The installer automatically detects your operating system:

# Install as daemon (runs automatically on login)
./scripts/install.sh

# Check daemon status and logs  
./scripts/status.sh

# Uninstall daemon (keeps project files)
./scripts/uninstall.sh

Platform Support:

  • βœ… macOS - Uses LaunchAgents for proper user-level daemon management
  • βœ… Windows - Uses Task Scheduler with PowerShell scripts
  • 🚧 Linux - Coming soon (systemd user services)

What the daemon installer does:

  • βœ… Creates and activates Python virtual environment
  • βœ… Installs all dependencies automatically
  • βœ… Sets up auto-start on login (macOS: LaunchAgent, Windows: Task Scheduler)
  • βœ… Creates log files for monitoring
  • βœ… Handles automatic restarts if the app crashes
  • βœ… Runs in background without terminal/command prompt window

Manual Installation Examples:

Windows (Task Scheduler):

  1. Open Task Scheduler
  2. Create Basic Task β†’ Daily β†’ Start at computer startup
  3. Action: Start a program β†’ Point to your Python installation and script

Linux (systemd):

# Create a systemd user service
systemctl --user enable trakt-discord-presence.service

Custom Polling Interval

Edit main.py and change this line:

time.sleep(15)  # Change 15 to your preferred seconds

πŸ“ Project Structure

discord-presence/
β”œβ”€β”€ main.py                                    # Main application
β”œβ”€β”€ discord_ipc.py                            # Custom Discord integration
β”œβ”€β”€ requirements.txt                           # Python dependencies
β”œβ”€β”€ .env.example                               # Configuration template
β”œβ”€β”€ .env                                       # Your credentials (keep private!)
β”œβ”€β”€ scripts/                                   # Cross-platform daemon scripts
β”‚   β”œβ”€β”€ install.sh                            # Universal installer (detects OS)
β”‚   β”œβ”€β”€ status.sh                             # Universal status checker  
β”‚   β”œβ”€β”€ uninstall.sh                          # Universal uninstaller
β”‚   β”œβ”€β”€ macos/                                # macOS-specific files
β”‚   β”‚   β”œβ”€β”€ install.sh                        # macOS daemon installer
β”‚   β”‚   β”œβ”€β”€ uninstall.sh                      # macOS daemon uninstaller
β”‚   β”‚   β”œβ”€β”€ status.sh                         # macOS status checker
β”‚   β”‚   └── README.md                         # macOS documentation
β”‚   β”œβ”€β”€ windows/                              # Windows-specific files
β”‚   β”‚   β”œβ”€β”€ install.ps1                      # Windows PowerShell installer
β”‚   β”‚   β”œβ”€β”€ uninstall.ps1                    # Windows PowerShell uninstaller
β”‚   β”‚   β”œβ”€β”€ status.ps1                       # Windows PowerShell status checker
β”‚   β”‚   β”œβ”€β”€ install.bat                      # Windows batch wrapper
β”‚   β”‚   β”œβ”€β”€ uninstall.bat                    # Windows batch wrapper
β”‚   β”‚   β”œβ”€β”€ status.bat                       # Windows batch wrapper
β”‚   β”‚   └── README.md                        # Windows documentation
β”‚   └── linux/                                # Linux-specific files (coming soon)
β”‚       └── README.md                         # Linux documentation
β”œβ”€β”€ logs/                                      # Daemon log files (created by installer)
β”‚   β”œβ”€β”€ trakt-discord.log                     # Application output
β”‚   └── trakt-discord-error.log               # Error messages
└── README.md                                  # This file

🀝 Contributing

Found a bug or want to add a feature?

  1. Fork this repository
  2. Create a feature branch: git checkout -b my-new-feature
  3. Make your changes and test them
  4. Submit a pull request

⚠️ Security Note

Never share your .env file or commit it to version control! It contains your secret API keys.

The .env file is already in .gitignore to prevent accidental commits.

πŸ“„ License

This project is open source. Feel free to use, modify, and distribute!

πŸ†˜ Support

Having issues?

  1. Check the troubleshooting section above
  2. Search existing GitHub issues
  3. Create a new issue with:
    • Your operating system
    • Python version (python3 --version or python --version)
    • Error messages (remove any API keys first!)

Enjoy showing off what you're watching! 🍿

About

Rich presence for Trakt activity

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors