TOOL := $(shell python3 -c "import yaml; print(yaml.safe_load(open('project.yaml'))['tool'])")
SCRIPTS := $(TOOL)/scripts
PORT := 9123

.PHONY: download convert match build serve clean

# MP3s herunterladen (idempotent, ueberspringt vorhandene Dateien)
download:
	./download_ldn.sh

# SRTs zu Transkripten konvertieren (nach MacWhisper-Lauf)
convert:
	python3 $(SCRIPTS)/convert_srt.py .

# Zitate auf Timestamps abbilden
match:
	python3 $(SCRIPTS)/match_quotes.py .

# Vollstaendiger Build
build: convert match webapp

# Webapp aufsetzen
webapp:
	python3 $(SCRIPTS)/pipeline.py . --step webapp

# Server starten
serve:
	python3 $(SCRIPTS)/pipeline.py . --step serve --port $(PORT)

# Komplette Pipeline
all:
	python3 $(SCRIPTS)/pipeline.py .

clean:
	rm -rf webapp/mindmap_data.json webapp/audio data/srt_index.json
