
    Si                     f   d Z ddlZddlZddlmZmZ ddlmZ  ej                         Z	i ddddd	d
dddddddddddddddddddddd d!d"d#d$d%d&i d'd(d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;d<d=d>d?d@dAdBdCdDdEdFdGdHdIdJiZ
dKedLedMefdNZdO ZedPk(  r e        yy)Qa  Capture screenshots for all services using Jina Reader API.

Jina Reader: r.jina.ai/{URL} with X-Respond-With: screenshot
- No API key required
- 500 RPM free
- Puppeteer-based real browser rendering
- Bypasses bot detection, cookie banners, Cloudflare

Usage:
    python3 scripts/capture_jina_screenshots.py           # all missing
    python3 scripts/capture_jina_screenshots.py stripe     # single
    python3 scripts/capture_jina_screenshots.py --all      # force all
    N)ThreadPoolExecutoras_completed)Path	atlassianzhttps://atlassian.comaxiomzhttps://axiom.cocalzhttps://cal.comclerkzhttps://clerk.com
contentfulzhttps://contentful.comconvexzhttps://convex.devdiscordzhttps://discord.comdubzhttps://dub.cofigmazhttps://figma.comframerzhttps://framer.comgithubzhttps://github.comhashnodezhttps://hashnode.comzlemon-squeezyzhttps://lemonsqueezy.comlinearzhttps://linear.appmintlifyzhttps://mintlify.comneonzhttps://neon.technotionzhttps://notion.soplanetscalezhttps://planetscale.composthogzhttps://posthog.comprismazhttps://prisma.iorailwayzhttps://railway.appraycastzhttps://raycast.comresendzhttps://resend.comretoolzhttps://retool.comshopifyzhttps://shopify.comslackzhttps://slack.comspotifyzhttps://spotify.comstripezhttps://stripe.comsupabasezhttps://supabase.comtailwindcsszhttps://tailwindcss.comtinybirdzhttps://tinybird.cotwitchzhttps://twitch.tvvercelzhttps://vercel.comwarpzhttps://warp.dev
planetfallzHhttps://www.paradoxinteractive.com/games/age-of-wonders-planetfall/aboutslugurlreturnc           
         t         dz  | z  dz  }|j                  dd       | |dddd}	 t        j                  d	d
ddddd| gdd      }|j                  dk7  rd|j                   |d<   |S |j
                  }t        |      dk  s|dd dk(  sdt        |       d|d<   |S |dz  j                  |       	 ddlm	} |dz  }|dz  }|j                  |      }	|	j                  \  }
}t        d|      }|	j                  dd|
|f      }|j                  |       d|d<   t        |      |d<   |S # t        $ r Y  w xY w# t         $ r}t#        |      |d<   Y d}~|S d}~ww xY w)z'Capture screenshot via Jina Reader API.insane-designscreenshotsT)parentsexist_okFNr   )r(   r)   okerrorsizecurlz-sLz-HzX-Respond-With: screenshotz
--max-time30zhttps://r.jina.ai/#   )capture_outputtimeoutz
curl exit r1   i     s   PNGznot PNG or too small (z bytes)jina-hero.png)Imagezhero-cropped.pngi   r0   r2   )ROOTmkdir
subprocessrun
returncodestdoutlenwrite_bytesPILr:   openr2   mincropsaveImportError	Exceptionstr)r(   r)   out_dirresultrdatar:   srcdstimgwhcrop_hcroppedes                  ]/home/jay/workspace/.worktrees/task-2117-dev1/tools/insane-design/capture_jina_screenshots.pycapture_jinarX   >   s   _$t+m;GMM$M.3edANF*!NN,$SE*  
 <<1 *1<<.9F7OMxxt9t48z#9 6s4ykIF7OM	?	"//5	!O+C..C**S/C88DAqa[Fhh1a01GLL tTv M  		
  !a&wM!sI   AE 15E 'E <A"D3 E 3	D?<E >D??E 	E$EE$c                  x   t         j                  dd  } d| v }| D cg c]
  }|dk7  s	| } }| r@g }| D ]+  }|t        v r|j                  |       t	        d| d       - |s{t	        d       y |rt        t        j                               }nOg }t        D ]6  }t        dz  |z  dz  dz  }|j                         r&|j                  |       8 |st	        d	       y t	        d
t        |       d       g }t        d      5 }|D ci c]!  }|j                  t        |t        |         |# }	}t        t        |	      d      D ]k  \  }
}|j                         }|d   rdnd}|d   r|d   dz   dn|d   }t	        d|
 dt        |       d| d|d   dd| 
       |j                  |       m 	 d d d        t!        d |D              }t!        d |D              }t	        d| d| d       |r0t	        d        |D ]  }|d   r	t	        d!|d    d"|d           ! y y c c}w c c}w # 1 sw Y   |xY w)#N   z--allu   ⚠ Unknown slug 'u/   ' — use a URL directly or add to SLUG_URL_MAPzNo valid slugs provided.r,   r-   r9   z:All Jina screenshots already captured. Use --all to force.z
Capturing u+    services via Jina Reader (5 concurrent)…   )max_workersr0   u   ✓u   ✗r2   i   KBr1   z  [/z]  r(   15sc              3   ,   K   | ]  }|d    s	d  ywr0   rZ   N .0rM   s     rW   	<genexpr>zmain.<locals>.<genexpr>   s     +11T7Q+   
c              3   ,   K   | ]  }|d    r	d  ywrb   rc   rd   s     rW   rf   zmain.<locals>.<genexpr>   s     1Q4q1rg   z
Done: z
 success, z failedzFailed:z  z: )sysargvSLUG_URL_MAPappendprintlistkeysr;   existsrA   r   submitrX   	enumerater   rL   sum)args	force_allaslugssr(   	jina_fileresultsexfuturesifutrM   statusszr0   fails                    rW   mainr   t   sr   88AB<D4I,!qG|A,D, 	_AL Q*1#-\]^		_
 ,-	\&&()   	#D.5EWI##%T"	# NO	Js5zl"M
NOG		* bW\]t299\4d1CDdJ]]W 5q9 	FAs

AgU5F+,T7AfItO$B''
BCs!CJ<r&1V9S/2$GHNN1	 
++	+B1'11D	HRD
4&
01i 	6AT71V9+R'
|45	6 Q -: ^ s)   
H&H&H0	&H+/BH0+H00H9__main__)__doc__r=   ri   concurrent.futuresr   r   pathlibr   cwdr;   rk   rJ   dictrX   r   __name__rc       rW   <module>r      s-    
 ? txxz$($$ 
$  	$
 *$ "$ $$ 
$  $ "$ "$ &$ /$ "$ &$  !$" !#$$ ,%$& $'$( !)$* $+$, $-$. "/$0 "1$2 $3$4  5$6 $7$8 "9$: &;$< ,=$> %?$@ !A$B "C$D E$F \G$N3s 3 3 3l/6d zF r   