1. Introduction to Overr‐Syncerr - gssariev/overr-syncerr GitHub Wiki

Overview

This PowerShell script is designed to automate the process of synchronizing subtitles and managing library metadata for media content. It interacts with several popular media management tools, including Sonarr, Radarr, Bazarr, Overseerr, and Plex. By listening for webhook payloads from Overseerr, the script can handle requests related to subtitle synchronization and library labeling, ensuring that your media library remains organized and up-to-date.

Key Features

  • Webhook Listener: The script listens for incoming webhook payloads, processing requests related to subtitles and library management.
  • Subtitle Synchronization: Automatically synchronizes subtitles for movies and TV shows, supporting both standard and 4K content.
  • Library Labeling: Adds labels to Plex media items based on user requests.
  • API Integration: Communicates with Sonarr, Radarr, Bazarr, and Overseerr APIs to fetch and update media details.
  • Dynamic Handling: Adapts to handle 4K and non-4K content, as well as subtitles for hearing-impaired users.

Environment Variables

The script relies on several environment variables for configuration. Ensure these variables are set in your environment:

Bazarr API

  • BAZARR_API_KEY: API key for Bazarr.
  • BAZARR_URL: URL for Bazarr.
  • BAZARR_4K_API_KEY: API key for 4K Bazarr.
  • BAZARR_4K_URL: URL for 4K Bazarr.

Radarr API

  • RADARR_API_KEY: API key for Radarr.
  • RADARR_URL: URL for Radarr.
  • RADARR_4K_API_KEY: API key for 4K Radarr.
  • RADARR_4K_URL: URL for 4K Radarr.

Sonarr API

  • SONARR_API_KEY: API key for Sonarr.
  • SONARR_URL: URL for Sonarr.
  • SONARR_4K_API_KEY: API key for 4K Sonarr.
  • SONARR_4K_URL: URL for 4K Sonarr.

Overseerr API

  • OVERSEERR_API_KEY: API key for Overseerr.
  • OVERSEERR_URL: URL for Overseerr.

Plex API

  • PLEX_TOKEN: API token for Plex.
  • PLEX_HOST: Host URL for Plex.

Miscellaneous

  • LANGUAGE_MAP: JSON mapping of language codes to names.
  • SYNC_KEYWORDS: JSON list of keywords related to synchronization.
  • ANIME_SECTION_ID: Section ID for anime in Plex.
  • PORT: Port number for the HTTP listener.

Script Functionality

Webhook Listener

The script starts an HTTP listener on the specified port, waiting for incoming webhook payloads.

Payload Processing

Incoming payloads are enqueued and processed sequentially. The script distinguishes between different issue types and handles them accordingly.

Subtitle Synchronization

For subtitle issues, the script:

  • Detects if the content is 4K or standard resolution.
  • Determines if the subtitles are for hearing-impaired users.
  • Fetches the relevant media details from Sonarr or Radarr.
  • Retrieves the subtitle paths from Bazarr.
  • Sends a request to Bazarr to sync the subtitles.
  • Posts a comment and resolves the issue in Overseerr.

Library Labeling

For labeling media, the script:

  • Extracts the media title and year.
  • Checks the media type (movie or TV show).
  • For TV shows, makes an additional API call to check if the series type is anime.
  • Searches for the media item in Plex.
  • Adds the specified label to the media item in Plex.
  • Posts a comment and resolves the issue in Overseerr.

Handling 4K vs Non-4K

The script switches between 4K and non-4K handling based on the presence of the "4K" keyword in the issue message. It dynamically assigns the appropriate API keys and URLs for Bazarr, Radarr, and Sonarr.

Handling Hearing-Impaired Subtitles

The script detects if the subtitles are for hearing-impaired users by checking for keywords like "hi" in the issue message. It then fetches the corresponding subtitle paths from Bazarr, ensuring the correct subtitles are synchronized.