import os
import re

files_to_remove = [
    r"assets/images/gallery/WhatsApp Image 2026-08-10 at 2.17.26 PM (2).jpeg",
    r"assets/images/gallery/WhatsApp Image 2026-08-10 at 2.17.25 PM.jpeg",
    r"assets/images/gallery/WhatsApp Image 2026-08-10 at 2.17.26 PM.jpeg"
]

for f in files_to_remove:
    norm_p = os.path.normpath(f)
    if os.path.exists(norm_p):
        try:
            os.remove(norm_p)
            print(f"Deleted file: {norm_p}")
        except Exception as e:
            print(f"Error deleting {norm_p}: {e}")

# Update gallery.html
with open('gallery.html', 'r', encoding='utf-8') as f:
    gal_c = f.read()

del_basenames = [os.path.basename(f) for f in files_to_remove]

def filter_out_items(match):
    src_line = match.group(0)
    for db in del_basenames:
        if db in src_line:
            return ""
    return src_line

gal_c = re.sub(r'\{\s*src:\s*[\'"][^\'"]+[\'"],\s*category:\s*\[[^\]]+\],\s*alt:\s*[\'"][^\'"]+[\'"]\s*\},?\n?', filter_out_items, gal_c)

with open('gallery.html', 'w', encoding='utf-8') as f:
    f.write(gal_c)

print("Updated gallery.html to remove the 3 specified images!")
