"""
mark_qnap_zbytek_odpad.py — Zbytek Qnap bez EXIF (obaly alb, downloads,
kurzové thumbnaily) -> odpad. Potvrzeno uživatelem.
wanted=FALSE, category='Odpad-cache'
"""
import sys
import psycopg2

sys.stdout.reconfigure(encoding="utf-8")

DB = dict(host="192.168.1.76", port=5432, user="vladimir.buzalka",
          password="Vlado7309208104++", database="fotky_buzalkovi")

conn = psycopg2.connect(**DB)
conn.set_isolation_level(psycopg2.extensions.ISOLATION_LEVEL_AUTOCOMMIT)
cur = conn.cursor()

cur.execute("""
    UPDATE photos p
    SET wanted = FALSE, category = 'Odpad-cache'
    FROM zaloha_obrazku z
    WHERE p.zaloha_id = z.id
      AND z.cesta_zalohy LIKE %s
      AND p.camera_make IS NULL
      AND p.category IS DISTINCT FROM 'Odpad-cache'
""", ('/mnt/user/ZalohaVsechObrazku/Tower1/#ColdData/Qnap/%',))

print(f"Qnap (zbytek bez EXIF) -> Odpad-cache: {cur.rowcount:,} řádků")
conn.close()
