
    S^jq                     f   d dl Z d dlZd dlZd dlZd dlmZmZ d dlmZ  ee          	                                j
        d         Zedz  Zd Zd Zd Zd	 Zed
k    rS	  ej         e                       dS # e$ r0Z ede ej                    ej        d           Y dZ[dS dZ[ww xY wdS )    N)datetimetimezone)Path   z log/production-verification.jsonc                     t           | z  }|                                sd S 	 t          j        |                    d                    S # t
          $ r Y d S w xY w)Nutf-8encoding)PROJECTis_filejsonloads	read_text	Exception)relpaths     script/validate-production.pyloadr      se    S=D<<>> tz$..'.::;;;   tts   'A
 

AAc                    t          j                    }|                     d          5 t          fdd          D ]}|                    |           	 d d d            n# 1 swxY w Y   |                                S )Nrbc                  .                          d          S )Ni   )read)handles   r   <lambda>zsha.<locals>.<lambda>   s    &++o">">     r   )hashlibsha256openiterupdate	hexdigest)r   digestblockr   s      @r   shar$      s    ^F	4 !F>>>>DD 	! 	!EMM%    	!! ! ! ! ! ! ! ! ! ! ! ! ! ! ! s   ,A##A'*A'c                     t          j        dddddddddt          |           g
d	d	d	
          }t          j        |j                  S )Nffprobez-verrorz-show_entrieszformat=duration,sizez9stream=index,codec_name,width,height,sample_rate,channelsz-ofr   T)capture_outputtextcheck)
subprocessrunstrr   r   stdout)r   results     r   prober0      sY    ^4/3ITvs4yy T	3 3 3F
 :fm$$$r   c            
         t          d          } t          d          }| r|r|                    d          durt          d          |                    d          }g }ddd	d
dddddd	}i }|                                D ]\  }}t          |          }||d ud||<   |s|                    d|z              9|                    d          p|                    d          }	||                             |                    d          du |	d           |                    d          dur|                    d|z              |	|k    r|                    d|z              t          d          pi }
t          d          pi }t          d          pi }t          d          pi }t          d	          pi }t          d          pi }t          d          pi }t          d          pi }t          dz  }t          dz  }t          dz  }t          dz  }t          dz  }|                    d          dus)|                    d          dus|                                r|                    d           |                                rt          |          nd k    s|                    d!          dus|                    d"          |                    d           k    s~|                    d#          t          t          dz            k    sP|                                r<|                    d$          |                                rt          |          nd k    r|                    d%           t          d& |                    d'g           D             i           }|                    d          dus|                    d(          d)k    s|                    d          dusi|                    d          dusQ|                    d*          d+k    s7|                    d,d+          d-k     s|                                r|                                r|                    d"          |                                rt          |          nd k    s|                    d           |                                rt          |          nd k    sx|                    d          dus`|                    d           |                    d           k    s3|                    d#          t          t          dz            k    s|                                r|                    d$          |                                rt          |          nd k    s|                    d.          |                    d"          k    s|                    d/          |                    d           k    s\|                    d0          t          t          dz            k    s.|                    d1          t          t          dz            k    r|                    d2           |
                    d3i                               d          dur|                    d4           |                    d3i                               d          dur|                    d5           |                    d3i                               d6          dur|                    d7           |                    d3i                               d6          dur|                    d8           |                    d9i           }|                    d:          dus|                    d;          dur|                    d<           t          d=z  }d }|                                s|                    d>           ni	 t          |          }|                    d?g           }d@ |D             }dA |D             }t          |          d-k    st          |          d-k    sx|d+                             dB          dCk    sY|d+                             dD          |d+                             dE          fdFk    s|d+                             dB          dGk    r|                    dH           |                    d$          t          |          k    r|                    dI           n<# t          $ r/}|                    dJt          |          z              Y d }~nd }~ww xY wt          dKz                                  s|                    dL           d-| |sdMndN||d=|dO|t          j        t           j                                                  dP}t&          j                            ddQ           t&                              t/          j        |ddRS          dTz   dUV           t3          t/          j        |d         |dWdX                     |d         rd+nd-S )YNzscript/project-manifest.jsonzstory/promotion-report.jsonverifiedTz%manifest/promotion missing or invalidspoken_sha256zlog/tts-pronunciation.jsonz log/intro-tts-pronunciation.jsonzlog/tts-verification.jsonzlog/image-generation.jsonzimage/layout-manifest.jsonzlog/intro-render.jsonzlog/footage-job.jsonzlog/final-render.jsonzlog/metadata-verification.json)	pronunciationintro_pronunciationttsimageslayoutintrofootagefinalmetadata)r   presentzmissing_or_invalid_receipt:source_canon_sha256)r2   r>   zreceipt_not_verified:zreceipt_canon_mismatch:zlog/intro-voice.jsonzstory/tts-pronunciation.txtzaudio/intro-voice-source.txtz#audio/intro-voice-pronunciation.txtzaudio/intro-voice.wavzaudio/story-full.wavsemantic_content_changedFreverse_verifiedprojection_sha256pronunciation_verifiedsource_sha256pronunciation_receipt_sha256output_sha256pronunciation_tts_chainc              3   L   K   | ]}|                     d           dk    |V   dS )sourceaudioNget.0rows     r   	<genexpr>zmain.<locals>.<genexpr>`   s:      llcswwW_O`O`dkOkOkcOkOkOkOkllr   lexiconkindr9   non_lexicon_changesr   replacement_countr   intro_source_sha256intro_pronunciation_sha256"intro_pronunciation_receipt_sha256intro_voice_receipt_sha256intro_pronunciation_tts_chain	visual_qalayout_artwork_visual_qaintro_artwork_visual_qarequired&footage_visual_qa_must_be_not_required$final_visual_qa_must_be_not_requiredserver_verificationmirror_appliedsource_audio_discardedfootage_technical_verificationzoutput/final.mp4final_missingstreamsc                 <    g | ]}|                     d           |S )widthrJ   rL   s     r   
<listcomp>zmain.<locals>.<listcomp>   s)    AAAc0@0@AcAAAr   c                 <    g | ]}|                     d           |S )sample_raterJ   rL   s     r   rg   zmain.<locals>.<listcomp>   s)    GGGc0F0FGcGGGr   
codec_nameh264rf   height)i  i8  aacfinal_codec_dimensions_streamsfinal_hash_mismatchzfinal_probe:zoutput/info.txtmetadata_file_missingpassedfailed)r   r0   )versionr2   statusr>   receiptsr;   issues
checked_at)parentsexist_ok   )ensure_asciiindent
r   r	   )r2   rv   )r{   )r   rK   RuntimeErroritemsappendr    r   r   r$   nextr0   lenr   r-   r   nowr   utc	isoformatREPORTparentmkdir
write_textr   dumpsprint) manifest	promotioncanonrv   specsru   namer   datarH   r8   r4   r5   intro_voicer6   r9   r:   r;   pronunciation_pathintro_source_pathintro_projection_pathintro_voice_path
audio_path	audio_rowfootage_server
final_pathfinal_proberd   videosaudiosexcreports                                    r   mainr   (   s
   233H233I D9 D	j(A(A(M(MBCCCMM/**EF5A*-.()(4
 
E H[[]] < <	cCyy"%$d2BCC 	MM7$>???/00MDHH_4M4M488J+?+?4+G`fgghhh88Jt++MM1D8999U??MM3d:;;;.//52F566<"MABBHb-..4"K
*
+
+
1rC())/RE)**0bG())/RE #@@"@@#&KK!8811J455UBB/00<<!))++ =011QcQkQkQmQm6wc:L6M6M6Mswxx77+,,D8877?##}'8'89L'M'MMM77122c'D`:`6a6aaa!!## b77?##:;M;M;O;O(YJUYZZ/000ll%8%<%<Y%K%KlllnpqqI
++477""6**g55""#=>>eKK""#566dBB""#899Q>>==,a00144 ((** 5$,,.. 5 ""?33RcRkRkRmRm8w<M8N8N8Nswxx""#677ZoZwZwZyZy  =DC@U<V<V<V  @D  E  E??:&&d22??.//3F3J3JK^3_3___??9::c'LnBn>o>ooo'')) p???++IYIaIaIcIc0m4D0E0E0Eimnn99*++/B/F/F/W/WWW991226I6M6MNa6b6bbb999::c'LnBn>o>ooo99122c'DZ:Z6[6[[[5666zz+r""&&z22$>>0111yyb!!%%j11==/000{{;##''
335@@>???yyb!!%%j11>><===[[!6;;N*++477>;M;MNf;g;gos;s;s6777--JK 5o&&&&
	5
++K!ooi44GAAWAAAFGGWGGGF6{{a3v;;!#3#3vay}}\7R7RV\7\7\aghiajananovawawy  AB  zC  zG  zG  HP  zQ  zQ  aR  Vb  ab  ab  fl  mn  fo  fs  fs  t@  fA  fA  EJ  fJ  fJ>???yy))S__<<3444 	5 	5 	5MM.3s88344444444	5''0022 /-...f*8\T\$(,{CCX\(B(B(L(L(N(N	 F Mt444
djeAFFFMX_```	$*&"4GGV[
\
\
\]]]z")11)s   =D+d) )
e"3%ee"__main__zProduction validation blocked: )file)r   r   r+   sysr   r   pathlibr   __file__resolverx   r   r   r   r$   r0   r   __name__exitr   r   r   stderr r   r   <module>r      sT         



 ' ' ' ' ' ' ' '      
$x..
 
 
"
"
*1
-	5	5    % % %u* u* u*p z   555CJGGGG s   A9 9B.>%B))B.