"""
mark_qnap_exif_odpad.py — Qnap fotky s EXIF jsou CD inlety/obaly -> odpad.
Potvrzeno uživatelem přes náhled (81 ks).
wanted=FALSE, category='Odpad-obaly'
"""
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-obaly'
    FROM zaloha_obrazku z
    WHERE p.zaloha_id = z.id
      AND z.cesta_zalohy LIKE %s
      AND p.camera_make IS NOT NULL
      AND p.category IS DISTINCT FROM 'Odpad-obaly'
""", ('/mnt/user/ZalohaVsechObrazku/Tower1/#ColdData/Qnap/%',))

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