EpisodeMatcher/setup_config.py
Jarian cedc0fd51e fix: address security and ops issues (#2-#8)
- Fix path traversal vulnerability in TVDB cache (CWE-22)
- Support TVDB_API_KEY env var to avoid hardcoded secrets
- Add config.json to .gitignore, remove from git history
- Add pyproject.toml for proper packaging, remove sys.path.insert
- Add file hash to duplicate detection (reduce false positives)
- Require --force flag for --auto-delete-duplicates deletion
- Log deletions to recovery manifest
- Create .env.example template
2026-07-05 08:07:05 +00:00

56 lines
1.6 KiB
Python
Executable File

#!/usr/bin/env python3
"""
Configuration setup script for Episode Matcher.
Use this to easily set up your TVDB API key.
"""
import sys
import os
from pathlib import Path
try:
from config import config_manager
except ImportError:
sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'src'))
from config import config_manager
def main():
"""Set up configuration interactively."""
print("=== Episode Matcher Configuration Setup ===\n")
config_manager.print_config_status()
print()
# API Key setup
current_key = config_manager.get_tvdb_api_key()
if current_key:
response = input("API key is already configured. Update it? (y/n): ").strip().lower()
if response not in ['y', 'yes']:
print("Configuration unchanged.")
return
print("\nTo get a TVDB API key:")
print("1. Go to https://thetvdb.com/api-information")
print("2. Create a free account")
print("3. Generate an API key")
print()
api_key = input("Enter your TVDB API key (or press Enter to skip): ").strip()
if api_key:
if config_manager.update_api_key(api_key):
print("✓ API key saved successfully!")
print("\nYou can now use the episode matcher without the --api-key argument:")
print('python episode_matcher.py "/path/to/episodes" "Show Name" 1')
else:
print("✗ Failed to save API key.")
else:
print("No API key entered. Mock data will be used.")
print("\nConfiguration setup complete!")
if __name__ == "__main__":
main()