
    [j$                     (   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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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)pathresults     script/submit-final.pyprober      sY    ^4/3ITvs4yy T	3 3 3F
 :fm$$$    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sI|                    d          d	us2|                    d
          |k    s|                    d
          |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&          t3          |d$         d%                   t3          |d$         d%                   t3          |d$         d%                   t3          |d$         d%                   z   t+          t                              t6                              |	t9          j        t<          j                                                   d&}tB          j"        #                    d	d	'           tB          $                    t          j        |d#d()          d*z   d           t          t          j        ||                    d          |d+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_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>4   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    r!   r8   r*   endpointintro_duration_secondsfootage_duration_secondsexpected_duration_secondsoutputpayloadsubmitted_at)parentsexist_ok   )ensure_asciiindent
)r8   r*   r!   )rH   r   )%	PROMOTIONINTRO_RECEIPTFOOTAGE_RECEIPTINTROFOOTAGEanyprintsysstderrr
   r   	read_textr%   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healthrC   rW   jobr8   receipts                 r   mainrs      s0   =/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>>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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$   I99I= I=N##N'*N'__main__)r
   r   rR   urllib.requestrV   r   r   pathlibr   __file__resolverE   r`   rK   rL   rM   rN   rO   rU   rd   rY   r   rs   __name__exit r   r   <module>r|      s        



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