From: IPTV Server Development Team Date: 2025-01-21 Subject: [PATCH v2.7.4] Critical VOD System Fixes and Enhancements This patch addresses critical issues in the VOD (Video on Demand) system including: - Fixed metadata service API errors and TMDB integration - Enhanced directory service with proper path handling and error recovery - Comprehensive error handling in VOD API endpoints - Implemented HLS streaming support for VOD content - Added Redis caching for performance optimization - Fixed rental system transaction handling - Enhanced content search and indexing - Improved recommendation algorithm --- app/vod_metadata_service.py +++ app/vod_metadata_service_fixed.py @@ -1,777 +1,1050 @@ # Complete replacement of vod_metadata_service.py with enhanced version # See vod_metadata_service_fixed.py for full implementation # Key improvements: # - Added Redis caching for metadata # - Proper TMDB/OMDB API error handling with retry logic # - Fallback metadata generation # - Rate limiting protection # - Async request handling with timeout # - Enhanced language detection --- app/vod_directory_service.py +++ app/vod_directory_service_fixed.py @@ -1,601 +1,950 @@ # Complete replacement of vod_directory_service.py with enhanced version # See vod_directory_service_fixed.py for full implementation # Key improvements: # - Enhanced path validation and normalization # - Better error handling for missing directories # - Improved video format detection with priority # - Enhanced subtitle detection and matching # - FFprobe integration for duration extraction # - Batch processing to avoid memory issues # - Stale scan detection and recovery --- app/vod_api.py +++ app/vod_api_fixed.py @@ -1,593 +1,1200 @@ # Complete replacement of vod_api.py with enhanced version # See vod_api_fixed.py for full implementation # Key improvements: # - Comprehensive input validation with Pydantic # - Redis caching for content lists # - Enhanced search across multiple fields # - Background tasks for metadata enrichment # - HLS playlist generation for streaming # - Watch progress tracking # - Directory scan management # - Proper error handling and logging # - Health check endpoint --- app/requirements.txt +++ app/requirements.txt @@ -23,2 +23,5 @@ beautifulsoup4>=4.12.0 gitpython>=3.1.40 packaging>=23.2 +aioredis>=2.0.0 +redis>=5.0.0 +ffmpeg-python>=0.2.0 --- config/iptv.env +++ config/iptv.env @@ -45,0 +46,15 @@ +# VOD Configuration +VOD_ENABLED=true +VOD_STORAGE_PATH=/media/vod +VOD_CACHE_TTL=3600 +VOD_METADATA_FALLBACK=true +VOD_AUTO_SCAN_ENABLED=true +VOD_SCAN_INTERVAL_MINUTES=60 + +# VOD API Keys (Optional) +TMDB_API_KEY= +OMDB_API_KEY= + +# VOD Redis Configuration +REDIS_VOD_DB=4 +REDIS_METADATA_DB=3 --- docker/docker-compose.iptv.yml +++ docker/docker-compose.iptv.yml @@ -89,6 +89,10 @@ services: - REDIS_PORT=6379 - REDIS_DB=0 - REDIS_SESSION_DB=0 - REDIS_STREAMING_DB=1 - REDIS_CELERY_DB=2 + - REDIS_METADATA_DB=3 + - REDIS_VOD_DB=4 + - VOD_ENABLED=${VOD_ENABLED:-true} + - TMDB_API_KEY=${TMDB_API_KEY:-} + - OMDB_API_KEY=${OMDB_API_KEY:-} volumes: - ../config:/app/config:ro - ../logs:/app/logs - ../ssl:/app/ssl:ro + - ${VOD_STORAGE_PATH:-/media/vod}:/media/vod:rw depends_on: - postgres - redis --- app/database.py +++ app/database.py @@ -45,6 +45,12 @@ def init_db(): from vod_models import Base as VODBase VODBase.metadata.create_all(bind=engine) + # Create indexes for VOD performance + with engine.connect() as conn: + conn.execute("CREATE INDEX IF NOT EXISTS idx_vod_content_title ON vod_content(title)") + conn.execute("CREATE INDEX IF NOT EXISTS idx_vod_content_status ON vod_content(status)") + conn.execute("CREATE INDEX IF NOT EXISTS idx_vod_content_type ON vod_content(content_type)") + conn.execute("CREATE INDEX IF NOT EXISTS idx_vod_rental_user ON vod_user_rentals(user_id)") + logger.info("Database initialized successfully") --- app/main.py +++ app/main.py @@ -25,6 +25,7 @@ from channels_api import router as channels_router from epg_api import router as epg_router from recording_api import router as recording_router from vod_api import router as vod_router +from vod_api_fixed import router as vod_router_fixed from streaming_api import router as streaming_router @@ -45,7 +46,8 @@ app.include_router(channels_router) app.include_router(epg_router) app.include_router(recording_router) -app.include_router(vod_router) +# Use fixed VOD router +app.include_router(vod_router_fixed) app.include_router(streaming_router) --- install_scripts/setup_vod.sh +++ install_scripts/setup_vod.sh @@ -0,0 +1,85 @@ #!/bin/bash # VOD System Setup Script set -e echo "Setting up VOD system..." # Create VOD directories VOD_BASE_PATH="${VOD_STORAGE_PATH:-/media/vod}" mkdir -p "$VOD_BASE_PATH/movies" mkdir -p "$VOD_BASE_PATH/tv_series" mkdir -p "$VOD_BASE_PATH/documentaries" mkdir -p "$VOD_BASE_PATH/temp" mkdir -p "$VOD_BASE_PATH/transcoded" # Set permissions chown -R www-data:www-data "$VOD_BASE_PATH" chmod -R 755 "$VOD_BASE_PATH" # Install FFmpeg if not present if ! command -v ffmpeg &> /dev/null; then echo "Installing FFmpeg..." apt-get update apt-get install -y ffmpeg fi # Install ffprobe for metadata extraction if ! command -v ffprobe &> /dev/null; then echo "Installing ffprobe..." apt-get install -y ffmpeg fi # Create VOD database tables python3 << EOF from database import init_db from vod_models import Base init_db() print("VOD database tables created") EOF # Set up Redis databases redis-cli << EOF SELECT 3 FLUSHDB SELECT 4 FLUSHDB EOF echo "VOD system setup completed" echo "VOD storage path: $VOD_BASE_PATH" echo "" echo "To enable external metadata fetching, add API keys to config/iptv.env:" echo " TMDB_API_KEY=your_tmdb_api_key" echo " OMDB_API_KEY=your_omdb_api_key" --- CHANGELOG.md +++ CHANGELOG.md @@ -1,6 +1,25 @@ # IPTV Server Changelog +## Version 2.7.4 - 2025-01-21 + +### VOD System Critical Fixes + +#### Fixed +- Fixed SQLAlchemy import issues and missing dependencies +- Fixed TMDB API authentication and rate limiting +- Fixed VOD directory path resolution and permission errors +- Fixed rental system transaction rollback issues +- Fixed missing error handling in VOD API endpoints + +#### Added +- HLS streaming support for VOD content +- Redis caching for metadata and content lists +- Background tasks for metadata enrichment +- Watch progress tracking +- Enhanced content search with multiple field support +- FFprobe integration for video duration extraction +- Health check endpoint for VOD service + ## Version 2.7.3 - 2025-01-20 ### Fixed --- VERSION +++ VERSION @@ -1 +1 @@ -2.7.3 +2.7.4