
    ,r\ja                     6   d dl Z 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edz  Zedz  Zedz  Zed	z  Zed
z  Zedz  ZdZd Zd Zd Zedk    r ej         e                       dS dS )    N)datetimetimezone)Path   zstory/promotion-report.jsonzlog/intro-render.jsonzlog/footage-job.jsonzoutput/intro/intro.mp4zoutput/footage/footage.mp4zoutput/final.mp4zlog/final-submission.jsonzhttp://192.168.1.104:8023c                    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   script/submit-final.py<lambda>zsha.<locals>.<lambda>   s    &++o">">     r   )hashlibsha256openiterupdate	hexdigest)path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-ofjsonT)capture_outputtextcheck)
subprocessrunstrr   loadsstdout)r   results     r   prober&      sY    ^4/3ITvs4yy T	3 3 3F
 :fm$$$r   c                     t           t          t          t          t          g} t          d | D                       rt          dt          j                   dS t          j
        t                               d                    }t          j
        t                              d                    }t          j
        t                              d                    }|                    d          }|                    d          d	us|                    d          d	us|                    d          d	us|                    d
          |k    s|                    d
          |k    s|                    di                               d          d	us|                    di                               d          d	usV|                    d          t          t                    k    s+|                    d          t          t                    k    rt          dt          j                   dS t                                          rt          dt          j                   dS t!          t                    }t!          t                    }t          d |                    dg           D                       st          dt          j                   dS t"          j                            t(          dz   d          5 }t          j        |          }d d d            n# 1 swxY w Y   |                    d          dk    s|                    d          d	urt          dt          j                   dS t-          t                    t-          t                    t-          t                    dddd}	t"          j                            t(          dz   t          j        |	                                          ddid !          }
t"          j                            |
d          5 }t          j        |          }d d d            n# 1 swxY w Y   |                    d"          }|r|                    d          d#vrt          d$t          j                   dS dd%|||                    d          t(          t5          |d&         d'                   t5          |d&         d'                   t5          |d&         d'                   t5          |d&         d'                   z   t          t                    t          t                    t-          t                              t8                              |	t;          j        t>          j                   !                                d(}tD          j#        $                    d	d	)           tD          %                    t          j        |d%d*+          d,z   d           t          t          j        ||                    d          |d-d%.                     d/S )0Nc              3   @   K   | ]}|                                  V  d S )N)exists).0r   s     r   	<genexpr>zmain.<locals>.<genexpr>(   s-      
2
2t{{}}
2
2
2
2
2
2r   z8Final blocked: verified intro/footage inputs are missing)filer   zutf-8)encodingspoken_sha256verifiedTsource_canon_sha256	visual_qaoutput_sha256z)Final blocked: authority receipt mismatchzPFinal blocked: final already exists; inspect existing job instead of overwritingc              3   H   K   | ]}|                     d           dk    V  dS )
codec_nameaacN)get)r*   ss     r   r+   zmain.<locals>.<genexpr>A   s3      VVquu\""e+VVVVVVr   streamsz5Final blocked: footage does not carry narration audioz/health   )timeoutstatusok
h264_nvencz0Final blocked: final GPU endpoint is not healthy   i  i8  )intro_video_pathfootage_video_pathoutput_video_pathfpswidthheightz/v1/huyenan-render-final/jobszContent-Typezapplication/jsonPOST)dataheadersmethodjob_id>   queuedrunningz+Final submission did not return a valid jobFformatduration)versionr/   r0   rI   r;   endpointintro_duration_secondsfootage_duration_secondsexpected_duration_secondsintro_sha256footage_sha256outputpayloadsubmitted_at)parentsexist_ok   )ensure_asciiindent
)rI   r;   r0   )r[   r   )&	PROMOTIONINTRO_RECEIPTFOOTAGE_RECEIPTINTROFOOTAGEanyprintsysstderrr   r#   	read_textr6   r   OUTPUTr)   r&   urllibrequesturlopenBASEloadr"   Requestdumpsencodefloatrelative_toPROJECTr   nowr   utc	isoformat
SUBMISSIONparentmkdir
write_text)required	promotionintro_receiptfootage_receiptcanonintro_probefootage_proberesponsehealthrV   rj   jobrI   receipts                 r   mainr   &   s   =/5'JH

2
2
2
2
222 HszZZZZq
9...@@AAIJ}666HHIIMj!:!:G!:!L!LMMOMM/**Ej!!--Z((44z**$66233u<<455>>["--11*==TII{B//33J??tKK_--U;;//3w<<??9
KKKKq}} `gjgqrrrrq,,K'NNMVV]5F5FyRT5U5UVVVVV ECJWWWWq			y 0"		=	= %8$$% % % % % % % % % % % % % % %zz(t##vzz,'?'?t'K'K@szRRRRq  JJ!'ll [[ G n$$..Z  ''))NDV3W`f %  G 
				4	4 "i!!" " " " " " " " " " " " " " "WWXF SWWX&&.CCC;#*MMMMq%CGGH$5$54"'H(=j(I"J"J$)-*A**M$N$N%*;x+@+L%M%MPUVcdlVmnxVyPzPz%zE

c'llf((1122w X\22<<>>	 	G D4888$*W5KKKdR]deee	$*#''(2C2C\abbqv
w
w
wxxx1s$   L&&L*-L*/QQQ__main__)r   r   r    re   urllib.requestri   r   r   pathlibr   __file__resolverX   rs   r^   r_   r`   ra   rb   rh   rw   rl   r   r&   r   __name__exit r   r   <module>r      s9         



     ' ' ' ' ' ' ' '      
$x..
 
 
"
"
*1
-33	1122**
0
0	%	%22
"  % % %D D DN zCHTTVV r   