
    ^j=                     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            
      Z   t          d          } t          d          }| r|r|                    d          durt          d          |                    d          }g }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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           |
                    d i                               d          dur|                    d!           |                    d i                               d          dur|                    d"           |                    d i                               d#          dur|                    d$           |                    d i                               d#          dur|                    d%           |                    d&i           }|                    d'          dus|                    d(          dur|                    d)           t          d*z  }d }|                                s|                    d+           ni	 t          |          }|                    d,g           }d- |D             }d. |D             }t          |          d/k    st          |          d/k    sx|d0                             d1          d2k    sY|d0                             d3          |d0                             d4          fd5k    s|d0                             d1          d6k    r|                    d7           |                    d          t          |          k    r|                    d8           n<# t          $ r/}|                    d9t          |          z              Y d }~nd }~ww xY wt          d:z                                  s|                    d;           d/| |sd<nd=||d*|d>|t          j        t          j                                                  d?}t$          j                            dd@           t$                              t-          j        |ddAB          dCz   dDE           t1          t-          j        |d         |dFdG                     |d         rd0nd/S )HNzscript/project-manifest.jsonzstory/promotion-report.jsonverifiedTz%manifest/promotion missing or invalidspoken_sha256zlog/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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story/tts-pronunciation.txtzaudio/story-full.wavsemantic_content_changedFreverse_verifiedoutput_sha256pronunciation_verifiedsource_sha256pronunciation_receipt_sha256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 )widthget.0rows     r   
<listcomp>zmain.<locals>.<listcomp>m   s)    AAAc0@0@AcAAAr   c                 <    g | ]}|                     d           |S )sample_raterS   rU   s     r   rX   zmain.<locals>.<listcomp>n   s)    GGGc0F0FGcGGGr   r   r   
codec_nameh264rR   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   rg   )rl   )r   rT   RuntimeErroritemsappendr    r   r   r$   r0   lenr   r-   r   nowr   utc	isoformatREPORTparentmkdir
write_textr   dumpsprint)manifest	promotioncanonrg   specsrf   namer   datasourcer7   r4   r5   r8   r9   r:   pronunciation_path
audio_pathfootage_server
final_pathfinal_proberP   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*-.()(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
*
+
+
1rC())/RE)**0bG())/RE #@@11J455UBB/00<<!))++ =_--M_MgMgMiMi2s#6H2I2I2Iostt77+,,D8877?##}'8'8'I'III77122c'D`:`6a6aaa!!## b77?##:;M;M;O;O(YJUYZZ/000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+W2 2
X+<%X&&X+__main__zProduction validation blocked: )file)r   r   r+   sysr   r   pathlibr   __file__resolveri   r   rv   r   r$   r0   r   __name__exitr   r   r{   stderr r   r   <module>r      sT         



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