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

# Download audio from YouTube
download:
	python3 $(SCRIPTS)/download_audio.py .

# Convert SRT files to transcripts (run after MacWhisper)
convert:
	python3 $(SCRIPTS)/convert_srt.py .

# Match quotes to timestamps
match:
	python3 $(SCRIPTS)/match_quotes.py .

# Full build (convert + match + webapp setup)
build: convert match webapp

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

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

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

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