A comprehensive Python tool for migrating and normalizing large digital comic collections (Western comics, manga, and hentai/doujin) into a consistent structure for use with Komga and Mylar3.
Phase 0 - Project Bootstrap has been implemented. The core infrastructure is ready for Phase 1-7 development.
- β Complete project structure and directory layout
- β Configuration system with Pydantic validation
- β Centralized JSON-structured logging
- β Comprehensive safety checks (paths, permissions, disk space, Python version)
- β Dry-run infrastructure for safe testing
- β CLI skeleton with safety check integration
- β Full documentation and coding standards
- β³ Phase 1: Inventory & Backup
- β³ Phase 2: Metadata Enrichment
- β³ Phase 3: Mapping Logic
- β³ Phase 4: Dry-Run Reporting
- β³ Phase 5: Migration Execution
- β³ Phase 6: Validation (Komga/Mylar3)
- β³ Phase 7: Rollback & Cleanup
- Safety First: All operations default to dry-run mode
- Metadata-Driven: ComicInfo.xml standards for all comics
- Confidence-Based: High/medium/low confidence levels for automated decisions
- Reversible: Complete rollback capability
- Cross-Platform: Windows, Linux, macOS, Unraid compatible
- Python 3.8+ (required)
- Operating System: Windows 10/11, Linux, macOS, or Unraid
- Disk Space: Sufficient space on target filesystems (100GB+ recommended)
- Optional: LANraragi (for hentai/doujin metadata)
git clone <repository-url>
cd project_comic_sort# Create virtual environment
python -m venv venv
# Activate virtual environment
# Windows:
venv\Scripts\activate
# Linux/macOS:
source venv/bin/activate
# Install dependencies
pip install -r requirements.txt
# Install development dependencies (optional)
pip install -r requirements-dev.txt# Copy example configs
cp config/example_config.yml config/config.yml
cp config/paths.example.yml config/paths.yml
# Edit config/paths.yml with your actual paths
# - Set source_libraries to your existing comic directories
# - Set target_roots to where you want organized libraries
# - Configure backup_location for safety# Test that your environment is properly configured
python -m src.cli.inventory --safety-checks-onlyYou should see output like:
======================================================================
SAFETY CHECK RESULTS
======================================================================
β PYTHON_VERSION: PASS [CRITICAL]
Python 3.11.0 (minimum: 3.8)
β SOURCE_LIBRARIES_EXIST: PASS [CRITICAL]
2/2 source libraries accessible
...
β
ALL CRITICAL CHECKS PASSED
======================================================================
environment:
dry_run: true # ALWAYS start in dry-run mode!
profile: "development"
logging:
level: "INFO"
console_output: true
safety:
require_backup: true
min_free_space_bytes: 107374182400 # 100GB
# ... see config/example_config.yml for all optionssource_libraries:
- path: "C:/Comics/Western"
content_type: "western"
enabled: true
- path: "C:/Comics/Manga"
content_type: "manga"
enabled: true
target_roots:
western: "C:/Media/Comics"
manga: "C:/Media/Manga"
hentai: "C:/Media/H-Manga"
temp_workspace: "C:/Temp/comic_migration_workspace"
backup_location: "E:/Backups/comic_migration_backup"For sensitive data (API keys), use environment variables or a .env file:
# .env file
COMICVINE_API_KEY=your_api_key_here
LANRARAGI_URL=http://localhost:3000
LANRARAGI_API_KEY=your_api_key_herepython -m src.cli.inventory --safety-checks-onlypython -m src.cli.inventory --help# These commands show what will be available in Phase 1
python -m src.cli.inventory scan --source /path/to/comics
python -m src.cli.inventory verify --original inventory.json --backup /pathproject_comic_sort/
βββ src/ # Source code
β βββ core/ # Core infrastructure (config, logging, dry-run)
β βββ metadata/ # Metadata providers (Phase 2 - TODO)
β βββ parsers/ # File and filename parsing (Phase 2 - TODO)
β βββ mappers/ # Path mapping logic (Phase 3 - TODO)
β βββ operations/ # High-level operations (safety checks implemented)
β βββ cli/ # Command-line interfaces (skeleton implemented)
βββ config/ # Configuration templates
βββ docs/ # Documentation (TODO)
βββ logs/ # Runtime logs (auto-generated)
βββ output/ # Generated outputs (inventories, reports, etc.)
βββ tests/ # Test suite (Phase 0 - TODO)
βββ scripts/ # Utility scripts (Phase 7 - TODO)
Tests will be added in later phases:
# Run all tests
pytest
# Run with coverage
pytest --cov=src --cov-report=html
# Run specific test file
pytest tests/test_config.py- Implementation Plan: Comprehensive 7-phase plan
- Agent Instructions (TODO): Guidelines for AI coding agents
- Metadata Strategy (TODO): Metadata provider details
- Confidence Levels (TODO): Confidence system explanation
- Troubleshooting (TODO): Common issues and solutions
ALL operations default to dry-run mode. Nothing happens to your files until you:
- Review dry-run reports
- Explicitly set
dry_run: falsein config - Re-run commands
Before any operation:
- β Python version verification
- β Source paths exist and readable
- β Target paths writable
- β No dangerous path overlaps
- β Sufficient disk space
- β Temp workspace accessible
All operations logged to JSON files:
logs/operations_{timestamp}.log- All operations (INFO+)logs/debug_{timestamp}.log- Verbose debug outputlogs/errors_{timestamp}.log- Errors only
System can require backups before destructive operations (configurable).
/media/Comics/
βββ DC/
β βββ Batman (1940)/
β βββ Batman (1940) #001 (1940-04-25).cbz
βββ Marvel/
βββ Amazing Spider-Man (1963)/
βββ Amazing Spider-Man (1963) #001 (1963-03-10).cbz
/media/Manga/
βββ One Piece/
β βββ One Piece v01.cbz
β βββ One Piece v02.cbz
βββ Naruto/
βββ Naruto v01.cbz
βββ Naruto v02.cbz
/media/H-Manga/
βββ _oneshots/
β βββ (123456) - Title (English) [nhentai].cbz
βββ [CircleName]/
βββ Series Title/
βββ Series Title v01.cbz
- Pathlib: Always use
pathlib.Pathfor path operations - Type Hints: Required for all public functions
- Docstrings: Google format for all modules/functions
- Line Length: Maximum 100 characters
- Formatting: Use
blackfor code formatting - Linting: Use
pylintfor code quality
- Provider Pattern: Metadata sources inherit from
BaseMetadataProvider - Factory Pattern: Mapper selection based on content type
- Strategy Pattern: Confidence level assignment
- Repository Pattern: Inventory/ledger persistence
This project is designed for AI-assisted development. See docs/agent_instructions.md (TODO) for guidelines.
[License information to be added]
- Komga: https://komga.org/
- Mylar3: https://github.com/mylar3/mylar3
- LANraragi: https://github.com/Difegue/LANraragi
- ComicVine: https://comicvine.gamespot.com/
- AniList: https://anilist.co/
- File scanning and discovery
- SHA256 hash calculation
- Inventory generation
- Backup verification
- ComicInfo.xml parsing
- API integrations (ComicVine, AniList, LANraragi)
- Confidence level assignment
- Target path calculation
- Conflict detection
- Mapping table generation
- Summary reports
- Confidence breakdowns
- Conflict reports
- Safe file copy operations
- Batch processing
- Progress tracking
- Inventory comparison
- Komga/Mylar3 integration
- Corruption checks
- Rollback mechanism
- Safe cleanup
- Archive old files
Status: Phase 0 Complete β | Next: Phase 1 Implementation