How tangilab/lightroom-path-migrator works
Project Type and Purpose
• This is a lightweight CLI-driven Python utility (“Lightroom Recover”) composed of two primary scripts:
• scan_photos.py – walks a configured directory of image files, reads metadata (path, filename, width, height), and writes out JSON/CSV/SQLite snapshots.
• update_lightroom_paths.py – reads that snapshot plus an existing Lightroom catalog, matches records, and updates the catalog’s root paths (dry-run or real).
• It is not a web app or microservice, but a command-line tool focused on offline file scanning and catalog mutation.
File‐Structure Analysis
Top‐level artifacts:
• .env.example / .env – environment variables for directory paths, filenames, and dry-run flag
• pyproject.toml / requirements.txt – build/typing/test configurations and Python dependencies
• scan_photos.py / update_lightroom_paths.py – two main modules, each tested in tests/
• resultats_scan/ – output directory for scan snapshots (JSON, CSV, SQLite)
• catalogue_lightroom/ – target Lightroom catalog files (not versioned)
• tests/ – pytest suite covering both scripts
No frontend or long-running service; it’s purely an offline batch‐processing tool.
Key Insights from README
• Uses environment variables for configuration (dotenv)
• Produces three output formats to suit different consumers (human-readable JSON/CSV, and SQLite DB for queries)
• Supports dry-run vs real update modes
• High test coverage, strict typing (mypy) and docstring standards (pydocstyle)
Main Components
a. Configuration Layer
• .env file (DRY_RUN_MODE, PHOTOS_DIRECTORY, SCAN_DB_FILENAME, CATALOG_FILENAME)
b. Scan Module
• Python process “scan_photos.py”
• Input: PHOTOS_DIRECTORY
• Output: resultats_scan/{.json, .csv, .db}
c. Storage Formats (Results)
• JSON snapshot
• CSV snapshot
• SQLite database
d. Update Module
• Python process “update_lightroom_paths.py”
• Inputs: scan DB (SQLite), Lightroom catalog files (from catalogue_lightroom/)
• Logic: match file records → update root paths in catalog
• Controlled by DRY_RUN_MODE flag
e. External Artifact
• Lightroom Catalog (file-based database)
Relationships & Data Flows
1. User invokes scan_photos.py
– Reads .env → scans PHOTOS_DIRECTORY → writes out three formats into resultats_scan/
2. User invokes update_lightroom_paths.py
– Reads .env → loads scan DB (SQLite) and reads Lightroom catalog
– Matches records → writes updates back to catalog (or simulates if dry‐run)
Architectural Patterns & Principles
• Separation of Concerns: scanning vs updating are totally separate processes
• Configuration‐driven: everything derived from .env
• Multiple persistence formats for flexibility (human vs machine query)
• Emphasis on safety: dry-run mode, backups, clear disclaimers
Relevant Technologies
• Python 3.x
• SQLite (via sqlite3 or an ORM)
• JSON & CSV stdlib
• python-dotenv for config
• pytest, mypy, pydocstyle for quality gates