#!/usr/bin/env python3 """Retrofit the bg-image + bg-overlay layer into an existing index.html. Idempotent — running twice has no extra effect. Usage: retrofit-bg-image.py retrofit-bg-image.py /video # also accepted Inserts (only if not already present): -
+
right after
- CSS rules for #bg-image, #bg-overlay, .scene z-index inside the ) if "#bg-image" not in html: m = re.search(r"", html) if not m: print(f" ✗ no tag in {html_path}, cannot inject CSS") return False html = html[:m.start()] + CSS_INJECT + html[m.start():] changed = True print(f" + CSS injected") else: # Update existing CSS to tuned values (idempotent) html = re.sub( r"background-image:\s*url\('[^']+'\);", "background-image: url('bg.png');", html, count=1, ) html = re.sub( r"filter:\s*blur\([^)]+\)\s*brightness\([^)]+\)\s*saturate\([^)]+\);", "filter: blur(30px) brightness(0.65) saturate(0.85);", html, count=1, ) html = re.sub( r"background:\s*rgba\(14,\s*11,\s*8,\s*[\d.]+\);", "background: rgba(14, 11, 8, 0.28);", html, count=1, ) # Inject HTML divs (right after opening
) if 'id="bg-image"' not in html: m = re.search(r'(
]*>)', html) if not m: print(f" ✗ no
in {html_path}, cannot inject divs") return False html = html[:m.end()] + HTML_INJECT + html[m.end():] changed = True print(f" + HTML divs injected") if changed: html_path.write_text(html) print(f" ✓ {html_path}") else: print(f" · already has bg-image, no change") return changed def main(): if len(sys.argv) < 2: sys.exit(__doc__) for arg in sys.argv[1:]: video_dir = find_video_dir(arg) print(f"[retrofit] {video_dir}") retrofit(video_dir) if __name__ == "__main__": main()