#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
watch_rss.py — Optional watcher that runs update_rss.py every 60 seconds.
Use this only if you don't want to trigger via Power Automate Desktop.
Place it next to update_rss.py and run:
    python watch_rss.py
Stop with Ctrl+C.
"""

import os
import time
import subprocess
import sys

THIS_DIR = os.path.abspath(os.path.dirname(__file__))
UPDATE = os.path.join(THIS_DIR, "update_rss.py")

if not os.path.exists(UPDATE):
    print("[ERROR] update_rss.py not found alongside watch_rss.py")
    sys.exit(1)

while True:
    try:
        subprocess.run([sys.executable, UPDATE, "--verbose"], check=False)
    except Exception as e:
        print("[ERROR] update_rss.py failed:", e)
    time.sleep(60)
