Documentation Index
Fetch the complete documentation index at: https://mintlify.com/avikekk/JackettSearchBot/llms.txt
Use this file to discover all available pages before exploring further.
Directory Layout
The JackettSearchBot follows a clean, modular architecture with clear separation of concerns:Core Components
app.py - Bot Application
app.py - Bot Application
The main bot class that wires everything together.Key Responsibilities:
- Initialize services (auth, jackett, ptp)
- Configure logging with rotating file handlers
- Register Pyrogram command handlers
- Manage bot lifecycle and graceful shutdown
jackett_bot/app.py:13config.py - Configuration Management
config.py - Configuration Management
Environment-based configuration using python-dotenv.Key Features:
- Validates required environment variables on startup
- Provides sensible defaults for optional settings
- Type-safe configuration with dataclasses
- Parses complex types (log levels, chat ID lists)
jackett_bot/config.py:8handlers/commands.py - Command Handlers
handlers/commands.py - Command Handlers
Implements all Telegram bot commands with authorization checks.Key Features:
- Pagination session management with TTL
- Auto-redaction of results after configurable timeout
- Owner-only administrative commands
- HTML-formatted responses with key-value styling
jackett_bot/handlers/commands.py:29Available Commands:/start- Bot access verification/help- Command list/release- Search with pagination/check- PTP availability/auth,/unauth,/unauthall- Authorization management (owner only)
services/ - Service Layer
services/ - Service Layer
Business logic separated into three focused services:AuthorizationService (
services/auth.py:5)- Thread-safe authorization management
- Supports both configured and temporary IDs
- Bootstrap from environment on startup
services/jackett.py:29)- Async HTTP client for Jackett API
- XML parsing of torznab results
- IMDB ID detection (queries starting with “tt”)
- Golden Popcorn filtering
services/ptp.py:4)- Simple health check for PassThePopcorn
- Async availability testing with timeout
Entry Point
The application entry point ismain.py in the project root:
The
initialize() class method validates configuration before starting the bot, ensuring all required environment variables are present.Data Flow
- User sends command → Pyrogram handler registered in
app.py - Handler method →
CommandHandlersinhandlers/commands.py - Authorization check →
AuthorizationService.is_authorized() - Business logic → Service layer (
JackettService,PTPService) - Response formatting → HTML-formatted reply with Telegram API
Logging Architecture
The bot uses Python’s built-in logging with dual outputs: Console Handler- Level: Configurable via
CONSOLE_LOG_LEVEL(default: INFO) - Format:
%(asctime)s | %(levelname)s | %(name)s | %(message)s
- Level: Configurable via
FILE_LOG_LEVEL(default: DEBUG) - Rotation: 10MB max size, 5 backup files
- Format: Includes filename, line number, and function name
- Location: Configurable via
LOG_FILE_PATH(default:logs/jackett_bot.log)
Dependencies
The bot has minimal dependencies managed viarequirements.txt:
- pyrogram - Telegram MTProto API framework
- python-dotenv - Environment variable loading
- httpx - Modern async HTTP client
- tgcrypto - Optional encryption speedup (Python < 3.13)
The project uses
uv for dependency management with lock files for reproducible builds.