
    =^j                       d dl m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d          Z	dZ
dZdZe	d	z  d
z  ez  dz  Ze	d
z  dz  Ze	d
z  dz  Ze	d	z  d
z  ez  dz  Zg dZddZddZddZddZedk    r e e                      dS )    )annotationsN)datetimetimezone)PathzE/data/video-pipeline/HaTramAudio/project/014-Nguoi-Ve-Ban-Do-Mua-Dongz014-Nguoi-Ve-Ban-Do-Mua-Dongzrun-20260720T152357Z-c85a2128zoroworkstoryzcandidate.txtzstory-canon.txtzspoken-narration.txtzvalidation-independent.json)
zscript/creative-options.jsonscript/story-brief.jsonzscript/outline.jsonzscript/identity-registry.jsonzscript/reveal-ledger.jsonzscript/continuity-ledger.jsonzscript/originality-report.jsonscript/story-qa.jsonscript/promotion-report.jsonzscript/story-manifest.jsonreturnstrc                     t          j        t          j                                                                      dd          S )Nz+00:00Z)r   nowr   utc	isoformatreplace     \/data/video-pipeline/HaTramAudio/project/014-Nguoi-Ve-Ban-Do-Mua-Dong/work/validate_story.pyr   r       s0    <%%//1199(CHHHr   databytesc                N    t          j        |                                           S )N)hashlibsha256	hexdigest)r   s    r   shar   $   s    >$))+++r   Nonec                    t          j        t          dz                      d                    } t          t
          t          dd}|                                D ]0\  }}|                     |          |k    rt          d|           1d S )Nz.ownership-lock.jsonutf-8encodingactive)
project_idrun_idownerstatuszownership mismatch: )
jsonloadsROOT	read_text
PROJECT_IDRUN_IDOWNERitemsgetRuntimeError)lockexpectedkeyvalues       r   guardr7   (   s    :t44???QQRRD(FUV^__Hnn&& = =
U88C==E!!;c;;<<< "= =r   intc                 4   t                       d t          t          t          fD             } | d t          D             z  } | r%t          dd                    |           z             t                                          }t                                          }t                                          }|                    d          }t          t          j        d|t          j                            }|dz  }i }t          D ]5}t          j        t          |z                      d	                    ||<   6|d
         }	|d         }
||cxk    o|k    nc }t#          t          j        d|                    t#          t          j        d|                    t#          t          j        d|                    t#          t          j        d|                    d}t'          |          }t'          |          }|	                    d          p|	                    d          |k    }|	                    d          |k    }|d|cxk    odk    nc d|cxk    odk    nc |	                    d          du o|	                    d          dv |||
                    d          du o|
                    d          dv t+          |                                           dt          j        |d         d           v d!	}d"t0          t2          t5          |                                          rd#nd$t5          |                                          |||d|t'          |          ||d% t          D             t7                      d&}t                       t8          j                            dd'           t8                              t          j        |dd()          d*z   d	           tA          t          j        |d                      |d         rd+nd"S ),Nc                T    g | ]%}|                                 t          |          &S r   )is_filer   ).0paths     r   
<listcomp>zmain.<locals>.<listcomp>2   s+    YYYT$,,..Ys4yyYYYr   c                J    g | ] }t           |z                                  |!S r   )r+   r;   r<   rels     r   r>   zmain.<locals>.<listcomp>3   s-    GGG0D0D0F0FGGGGr   zstory authority incomplete: z, r!   z\b\w+\b)flags   r"   r   r   z(?m)^#{1,6}\su2   (?mi)^\s*(chương|phần|hồi)\s+[0-9ivxlcdm]+\bu2   (?i)(đăng ký kênh|like video|hạ trâm audio)u8   (?mi)^\s*(tiêu đề|mô tả|hashtag|thể loại)\s*:)markdown_headingchapter_headingchannel_ctametadata_labelcanon_sha256source_canon_sha256spoken_narration_sha256i$  i$6  (   <   verifiedTr(   >   passed	completedcompleted_content_only>   rN   rO   passed_content_scopeu    Ngày Bưu Cục Cũ Sáng Đènr
   F)ensure_ascii)	(candidate_canon_narration_byte_identicalword_count_in_9240_13860duration_in_40_60_at_231_wpmpromotion_verifiedpromotion_canon_hash_matches promotion_narration_hash_matchesstory_qa_verifiedno_forbidden_narration_markers canonical_title_present_in_brief   rN   failedc                b    i | ],}|t          t          |z                                            -S r   )r   r+   
read_bytesr@   s     r   
<dictcomp>zmain.<locals>.<dictcomp>e   s2    VVVSS#tcz&=&=&?&?"@"@VVVr   )schema_versionr%   r&   r(   rM   checkscontent_markers
word_countplanning_words_per_minuteestimated_duration_minutescandidate_sha256rH   rJ   authority_sha256validated_at)parentsexist_ok   )rR   indent
r   )!r7   	CANDIDATECANON	NARRATION	AUTHORITYr2   joinr_   decodelenrefindallUNICODEr)   r*   r+   r,   boolsearchr   r1   anyvaluesdumpsr-   r.   allr   REPORTparentmkdir
write_textprint)missing	candidatecanon	narrationtextrd   duration	json_docsrA   	promotionstory_qahashes_equalrc   
canon_hashnarration_hashpromotion_hash_oknarration_hash_okrb   reports                      r   mainr   0   s0   	GGGYYi	%BYYYGGGyGGGGG P9DIIg<N<NNOOO$$&&IE$$&&IG$$DRZ
D
CCCDDJCHI N NTCZ$:$:G$:$L$LMM	#89I/0H22222222L +;T!B!BCC	*_ae f fggBI&[]abbccry)dfjkkll	 O UJ^^N"~66^)--H]:^:^cmm!&?@@NR4@$(J$?$?$?$?%$?$?$?$?(*h(<(<(<(<"(<(<(<(<'mmJ774?  QIMMRZD[D[  `Q  EQ(9,=%\\*55=  L(,,xBXBX  ]L  CL.1/2H2H2J2J.K.K*K,NRVR\]f  hA  ^B  QV  SW  SW  SW  -W
 
F  !&--//22@((((* %(&.	NN"#1VVIVVV F" 
GGG
Mt444
djeAFFFMX_```	$*V%
0
0
0111z")11)r   __main__)r   r   )r   r   r   r   )r   r   )r   r8   )
__future__r   r   r)   rv   r   r   pathlibr   r+   r-   r.   r/   ro   rp   rq   r   rr   r   r   r7   r   __name__
SystemExitr   r   r   <module>r      s[   " " " " " "   				 ' ' ' ' ' ' ' '      tSTT+
	(6MG#f,>	w**7N33			 6	),I	I  	I I I I, , , ,= = = =<* <* <* <*~ z
*TTVV

 r   