Skip to content

Send Discord notifications for newly released episodes imported by Sonarr.

License

Notifications You must be signed in to change notification settings

joobert/Interceptarr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Interceptarr

Interceptarr is a simple Flask-based web application specifically designed to send notifications for new episodes of continuing series in Sonarr. This is done by fetching "On Import" webhooks from Sonarr and forwarding them to a user-defined Discord webhook URL. The script listens for webhooks from Sonarr, processes the data, and if the release date of the episode is less than a week old, it forwards the message to the specified Discord webhook.

Features

  • Listens for webhook events from Sonarr and processes incoming data.
  • Fetches and parses data from TVDB to extract episode air dates.
  • Forwards processed data to a Discord webhook if the episode is less than a week old.
  • Logs all events and errors to the endpoint /logs and saves to interceptarr_logs.txt.

Prerequisites

  • Python 3.7+
  • Flask library
  • requests library
  • beautifulsoup4 library
  • python-dotenv library

Configuration

Create a '.env' file in the same directory as the script with the following variables:

  • DISCORD_WEBHOOK_URL: The Discord webhook URL where notifications for new episodes will be sent.
  • DISCORD_OVERRIDE_WEBHOOK_URL: Optionally assign a Discord webhook URL where warning messages will be sent if the original embed data from Sonarr is overwritten with new data from TVDB. (Leave this blank unless "Episode Title Required" is set to "Never" in your Sonarr settings.)
  • SHOW_EPISODE_THUMBNAIL: Optionally replace the generic show thumbnail with the episode thumbnail.
  • WEBHOOK_HOST: The IP address or hostname the Flask app will bind to.
  • WEBHOOK_PORT: The port the Flask app will listen on.

Sonarr Configuration

To integrate Interceptarr with Sonarr, create a new connection in Sonarr with only the "On Import" notification trigger checked, and set the connection's webhook URL to point to the IP address and port where Interceptarr is running. (e.g., 'http://10.0.0.1:8700')

Installation

  1. Clone the repository:

    git clone https://github.com/joobert/interceptarr.git
    cd interceptarr
  2. Install dependencies:

    pip install -r requirements.txt
  3. Create a .env file with the following content:

    DISCORD_WEBHOOK_URL=your_webhook_url
    DISCORD_OVERRIDE_WEBHOOK_URL=your_alt_webhook_url
    SHOW_EPISODE_THUMBNAIL=True
    WEBHOOK_HOST=your_host_ip
    WEBHOOK_PORT=8700
  4. Run the application:

    python interceptarr.py

(Optional) Running with Docker

Ensure you have both Docker and Docker Compose installed on your machine.
  1. Clone the repository:

    git clone https://github.com/joobert/interceptarr.git
    cd interceptarr
  2. Create a .env file with the following content:

    DISCORD_WEBHOOK_URL=your_webhook_url
    DISCORD_OVERRIDE_WEBHOOK_URL=your_alt_webhook_url
    SHOW_EPISODE_THUMBNAIL=True
    WEBHOOK_HOST=your_host_ip
    WEBHOOK_PORT=8700
  3. Ensure that the port configurations in both the compose.yml and Dockerfile match the port specified in your .env file (WEBHOOK_PORT). By default, it should be set to 8700. Adjust the port settings in these files if necessary.

  4. Create an empty interceptarr_logs.txt file:

    touch interceptarr_logs.txt
  5. Start the service with Docker Compose:

    docker compose up -d

Usage

Once the script or container is running, the application will be listening for webhook events on the specified IP address and port.

  • Webhook Listener: The application listens for POST requests at the root endpoint / and processes incoming webhook data.
  • Logging: All events and errors are logged to the endpoint /logs and saved to interceptarr_logs.txt.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request or open an Issue.

License

MIT