"""Enrichit les sets filtrés avec des métadonnées et la présence en collection."""

import os
from pathlib import Path

from dotenv import load_dotenv

from lib.rebrickable.enrich_sets import (
    enrich_sets,
    load_owned_set_ids,
    parse_set_collection_root,
    write_missing_sets_markdown,
)


SOURCE_PATH = Path("data/intermediate/sets_filtered.csv")
DESTINATION_PATH = Path("data/intermediate/sets_enriched.csv")
MISSING_MARKDOWN_PATH = Path("data/final/sets_missing.md")


def main() -> None:
    """Lance l'enrichissement des sets filtrés."""
    load_dotenv()
    owned_root = parse_set_collection_root(os.environ.get("MY_SETS", ""))
    owned_set_ids = load_owned_set_ids(owned_root) if owned_root is not None else set()
    enrich_sets(SOURCE_PATH, DESTINATION_PATH, owned_set_ids)
    write_missing_sets_markdown(DESTINATION_PATH, MISSING_MARKDOWN_PATH)


if __name__ == "__main__":
    main()
