mirror of
https://github.com/plexguide/Huntarr.io.git
synced 2025-12-23 22:18:23 -05:00
b8476ea51eef36f25e320eeffd302ff696306541
Sonarr-Hunter
Assists Sonarr to check for missing TV Shows
Sonarr Missing Episode Search Tool
Overview
This script continually searches your Sonarr library for shows with missing episodes and automatically triggers searches for those missing episodes. It's designed to run continuously while being gentle on your indexers, helping you gradually complete your TV show collection.
Features
- 🔄 Continuous Operation: Runs indefinitely until manually stopped
- 🎲 Random Selection: By default, selects shows randomly to distribute searches across your library
- ⏱️ Throttled Searches: Includes configurable delays to prevent overloading indexers
- 📊 Status Reporting: Provides clear feedback about what it's doing and which shows it's searching for
- 🛡️ Error Handling: Gracefully handles connection issues and API failures
How It Works
- Initialization: Connects to your Sonarr instance and retrieves a list of all shows
- Selection Process: Randomly selects shows from your library (or sequentially if configured)
- Detection: Checks if the selected show has missing episodes by comparing episode counts
- Search Trigger: For shows with missing episodes, it instructs Sonarr to search for those episodes
- Throttling: After finding and processing a show with missing episodes, it pauses for a configurable amount of time
- Cycling: After processing the configured number of shows, it starts a new cycle, refreshing the show data
Configuration Options
At the top of the script, you'll find these configurable options:
API_KEY="your_api_key_here" # Your Sonarr API key
SONARR_URL="http://your.sonarr.ip:port" # URL to your Sonarr instance
MAX_SHOWS=1 # Shows to process before restarting cycle
SLEEP_DURATION=30 # Seconds to wait after finding missing episodes
RANDOM_SELECTION=true # true for random selection, false for sequential
Use Cases
- Library Completion: Gradually fill in missing episodes of TV shows
- New Show Setup: Automatically find episodes for newly added shows
- Background Service: Run it in the background to continuously maintain your library
How to Run (Unraid Users)
- Install the plugin called
UserScripts - Copy and paste the following json -
How to Run (Non-Unraid Users)
- Save the script to a file (e.g.,
sonarr-search.sh) - Make it executable:
chmod +x sonarr-search.sh - Run it:
./sonarr-search.sh
For continuous background operation:
- Use
screenortmux:screen -S sonarr-search ./sonarr-search.sh - Or create a systemd service to run it automatically on startup
Tips
- First-Time Use: Start with default settings to ensure it works with your setup
- Adjusting Speed: Lower the
SLEEP_DURATIONto search more frequently (be careful with indexer limits) - Multiple Shows: Increase
MAX_SHOWSif you want to search for more shows per cycle - System Resources: The script uses minimal resources and can run continuously on even low-powered systems
Troubleshooting
- API Key Issues: Check that your API key is correct in Sonarr settings
- Connection Problems: Ensure the Sonarr URL is accessible from where you're running the script
- High Resource Usage: If you notice high CPU usage, ensure jq is installed properly
This script helps automate the tedious process of finding missing episodes in your TV collection, running quietly in the background while respecting your indexers' rate limits.
Languages
Python
43.5%
JavaScript
34.9%
HTML
15.9%
CSS
4.6%
Inno Setup
0.6%
Other
0.5%