Files
ohm_streaming/app/config.py
T
root 1fe7392063 feat: Complete Sonarr integration with security enhancements
This commit adds comprehensive Sonarr webhook integration and implements
critical security improvements identified in code review.

## Sonarr Integration
- Full webhook support for Grab, Download, Rename, Delete, and Test events
- HMAC SHA256 signature verification for webhook authentication
- Series mapping system (Sonarr TVDB ID → Anime Provider URL)
- 11 new API endpoints for configuration, mappings, search, and downloads
- Comprehensive test suite (31 tests, all passing)
- Complete documentation in docs/SONARR_INTEGRATION.md

## Security Enhancements
- CORS restricted to specific origins (user's IP: 192.168.1.204:3000)
- Path traversal prevention via sanitize_filename() and is_safe_filename()
- Structured logging infrastructure (replaced all print() statements)
- Environment-based configuration with .env support
- Filename sanitization prevents malicious path attacks

## New Features
- Lpayer and Sibnet downloader support
- Kitsu API integration for anime metadata
- Recommendation engine based on download history
- Latest releases endpoint for new anime
- Modular web interface with component-based templates

## Configuration
- Centralized settings via app/config.py with pydantic-settings
- Sonarr config auto-created in config/ directory
- Example configurations provided for easy setup

## Tests
- 31 Sonarr integration tests (23 functionality + 9 security)
- 100+ tests passing in core test files
- Security utilities fully tested

## Documentation
- Updated CLAUDE.md with Sonarr and testing info
- Added IMPROVEMENTS_2024-01-24.md analysis
- Added SONARR_IMPLEMENTATION.md technical summary

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
2026-01-24 21:25:47 +00:00

59 lines
1.3 KiB
Python

"""Application configuration using environment variables"""
from pydantic_settings import BaseSettings
from typing import List
import os
class Settings(BaseSettings):
"""Application settings loaded from environment variables"""
# Application
app_name: str = "Ohm Stream Downloader"
app_version: str = "2.2"
debug: bool = False
# Server
host: str = "0.0.0.0"
port: int = 3000
reload: bool = True
# Downloads
download_dir: str = "downloads"
max_parallel_downloads: int = 3
chunk_size: int = 1024 * 1024 # 1MB chunks
# CORS
cors_origins: List[str] = [
"http://localhost:3000",
"http://127.0.0.1:3000",
"http://192.168.1.204:3000",
"http://192.168.1.204"
]
# Storage
favorites_storage_path: str = "favorites.json"
# Sonarr
sonarr_config_path: str = "config/sonarr.json"
sonarr_mappings_path: str = "config/sonarr_mappings.json"
# API Timeouts
http_timeout: float = 10.0
download_timeout: int = 300 # 5 minutes
# Logging
log_level: str = "INFO"
class Config:
env_file = ".env"
env_file_encoding = "utf-8"
case_sensitive = False
# Global settings instance
settings = Settings()
def get_settings() -> Settings:
"""Get the global settings instance"""
return settings