- Updated application name to "Oliver Metadata Tool" - Updated version to 3.0.0 - Added App Info constants to config.py (APP_NAME, APP_VERSION, APP_DESCRIPTION) - Updated web interface (title, header, footer) - Updated README with new branding and description - Added AI configuration settings to config.py - Added ExifTool check method to config.py Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
70 lines
2.4 KiB
Python
70 lines
2.4 KiB
Python
"""Configuration management for Oliver Metadata Tool."""
|
|
|
|
import os
|
|
import shutil
|
|
import logging
|
|
from pathlib import Path
|
|
from dotenv import load_dotenv
|
|
|
|
# Load environment variables
|
|
load_dotenv()
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
class Config:
|
|
"""Configuration class for managing settings."""
|
|
|
|
# App Info
|
|
APP_NAME = "Oliver Metadata Tool"
|
|
APP_VERSION = "3.0.0"
|
|
APP_DESCRIPTION = "Universal metadata creation and management tool"
|
|
|
|
# Paths
|
|
PROJECT_ROOT = Path(__file__).parent.parent
|
|
OUTPUT_DIR = PROJECT_ROOT / 'output'
|
|
BACKUP_DIR = OUTPUT_DIR / 'backup'
|
|
REPORTS_DIR = OUTPUT_DIR / 'reports'
|
|
|
|
# External tool paths (optional)
|
|
TESSERACT_PATH = os.getenv('TESSERACT_PATH')
|
|
FFMPEG_PATH = os.getenv('FFMPEG_PATH')
|
|
|
|
# Processing Settings
|
|
PDF_MAX_PAGES = 3 # Maximum pages to extract from PDF
|
|
|
|
# OCR Settings - languages for Tesseract (CGA region support)
|
|
# eng=English, chi_sim=Chinese Simplified, chi_tra=Chinese Traditional,
|
|
# jpn=Japanese, kor=Korean
|
|
OCR_LANGUAGES = os.getenv('OCR_LANGUAGES', 'eng+chi_sim+chi_tra+jpn+kor')
|
|
|
|
# AI Settings (for CLI and Web AI mode)
|
|
OPENAI_API_KEY = os.getenv('OPENAI_API_KEY')
|
|
AI_MODEL = os.getenv('AI_MODEL', 'gpt-4o-mini') # Better than gpt-3.5-turbo
|
|
MAX_TOKENS = int(os.getenv('MAX_TOKENS', '500'))
|
|
TEMPERATURE = float(os.getenv('TEMPERATURE', '0.5')) # 0.5 better for factual content
|
|
MAX_TEXT_LENGTH = int(os.getenv('MAX_TEXT_LENGTH', '4000'))
|
|
|
|
# API Rate Limiting & Retry (from open source analysis)
|
|
API_TIMEOUT = int(os.getenv('API_TIMEOUT', '30'))
|
|
API_MAX_RETRIES = int(os.getenv('API_MAX_RETRIES', '3'))
|
|
API_RETRY_DELAY = float(os.getenv('API_RETRY_DELAY', '1.0')) # exponential backoff multiplier
|
|
|
|
@classmethod
|
|
def ensure_directories(cls):
|
|
"""Ensure required directories exist."""
|
|
cls.OUTPUT_DIR.mkdir(exist_ok=True)
|
|
cls.BACKUP_DIR.mkdir(exist_ok=True)
|
|
cls.REPORTS_DIR.mkdir(exist_ok=True)
|
|
|
|
@classmethod
|
|
def check_exiftool(cls):
|
|
"""Check if ExifTool is installed."""
|
|
exiftool_path = shutil.which('exiftool')
|
|
if not exiftool_path:
|
|
logger.warning("⚠️ ExifTool not found. Install with: brew install exiftool (macOS) or apt-get install libimage-exiftool-perl (Linux)")
|
|
return False
|
|
logger.info(f"✓ ExifTool found at {exiftool_path}")
|
|
return True
|
|
|
|
# Ensure directories on import
|
|
Config.ensure_directories()
|