
    c^j.                     <   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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           j                            t          dz   | z   d          5 }t	          j        |          cd d d            S # 1 swxY w Y   d S )Nz/v1/huyenan-render-final/jobs/   timeout)urllibrequesturlopenBASEr   load)job_idresponses     r   get_jobr2   &   s    			//&8" 
  
 
 #	y""# # # # # # # # # # # # # # # # # #s   AAAc                  n   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s9|                    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s|                    di                               d          d	usV|                    d          t          t                    k    s+|                    d          t          t                    k    rt          dt          j                   dS t          t                    }t          t                    }t          d |                    dg           D                       st          dt          j                   dS t          t                    }t          t                    }t                                          r)t          j
        t                              d                    }	|	                    d
          |k    sG|	                    d          |k    s.|	                    d          |k    s|	                    d          st          dt          j                   dS t#          |	d                   }
|
                    d          }|dv r0t          t          j        |	d         |d	|dd                     dS t          d| dt          j                   dS t&                                          r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 t3          t                    t3          t                    t3          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          d0vrt          d1t          j                   dS dd|||
                    d          t.          t9          |d2         d3                   t9          |d2         d3                   t9          |d2         d3                   t9          |d2         d3                   z   ||t3          t&                              t<                              |t?          j         tB          j"                  #                                d4}t          j$        %                    d	d	5           t          &                    t          j        |dd67          d8z   d           t          t          j        ||
                    d          |d9d                     dS ):Nc              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server_verificationmirror_appliedsource_audio_discardedoutput_sha256z)Final blocked: authority receipt mismatchc              3   H   K   | ]}|                     d           dk    V  dS )
codec_nameaacN)get)r6   ss     r   r7   zmain.<locals>.<genexpr>F   s3      VVquu\""e+VVVVVVr   streamsz5Final blocked: footage does not carry narration audiointro_sha256footage_sha256r0   zJFinal blocked: prior submission belongs to different authority/input bytesstatus>   queuedrunning	completed)r0   rJ   resumedr<   F)ensure_asciir   zFinal blocked: prior job ended z); inspect before a deliberate replacementzAFinal blocked: unreceipted final already exists; do not overwritez/health   r)   ok
h264_nvencz0Final blocked: final GPU endpoint is not healthyr(   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>   rK   rL   z+Final submission did not return a valid jobformatduration)versionr;   r<   r0   rJ   endpointintro_duration_secondsfootage_duration_secondsexpected_duration_secondsrH   rI   outputpayloadsubmitted_at)parentsexist_ok   )rO   indent
)r0   rJ   r<   )'	PROMOTIONINTRO_RECEIPTFOOTAGE_RECEIPTINTROFOOTAGEanyprintsysstderrr   r#   	read_textrE   r   r&   
SUBMISSIONr5   r2   dumpsOUTPUTr+   r,   r-   r.   r/   r"   Requestencodefloatrelative_toPROJECTr   nowr   utc	isoformatparentmkdir
write_text)required	promotionintro_receiptfootage_receiptcanonintro_probefootage_probe
intro_hashfootage_hashpriorjobrJ   r1   healthre   r,   r0   receipts                     r   mainr   -   sY   =/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4b99==>NOOW[[[4b99==>VWW_ccc_--U;;//3w<<??9
KKKKq,,K'NNMVV]5F5FyRT5U5UVVVVV ECJWWWWqUJw<<L 
:///AABBII+,,55yy((J66yy)**l::99X&& ; ^eheopppp1eHo&&""777$*h6VZsxyy  IN  O  O  O  P  P  P1aaaahkhrssssq}} QX[Xbcccc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"l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$   R>>SSW((W,/W,__main__)r   r   r    rs   urllib.requestr+   r   r   pathlibr   __file__resolverg   r}   rl   rm   rn   ro   rp   rx   rv   r.   r   r&   r2   r   __name__exit r   r   <module>r      sH         



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