
    V|hT                     V    S SK Jr  SSKJrJrJrJrJrJrJ	r	J
r
JrJr   " S S\5      rg)   )InfoExtractor   )
ExtractorError
clean_htmlint_or_nonemerge_dictsparse_countstr_or_nonetry_getunified_strdateurlencode_postdataurljoinc                       \ rS rSrSrSrSrS/rSrSSS	S
SSSSSS.SS.SSSS
SSSS0 S.SS./r	SSSSSSS S!S"S#.	r
S$S%S&.rS'rS( rS)rg*)+HKETVIE   hketvuX   香港教育局教育電視 (HKETV) Educational Television, Hong Kong Educational BureauFHKz<https?://(?:www\.)?hkedcity\.net/etv/resource/(?P<id>[0-9]+)z0https://www.hkedcity.net/etv/resource/2932360618 f193712f5f7abb208ddef3c5ea6ed0b7
2932360618mp4u>   喜閱一生(共享閱讀樂) (中、英文字幕可供選擇)z$md5:d5286d05219ef50e0613311cbe96e56020181024i  zcount:2)idexttitledescriptionupload_dateduration	subtitleszGeo restricted to HK)urlmd5	info_dictskipz/https://www.hkedcity.net/etv/resource/972641418 1ed494c1c6cf7866a8290edad9b07dc9	972641418u!   衣冠楚楚 (天使系列之一)z$md5:10bb3d659421e74f58e5db5691627b0f20070109i  zzh-Hantzzh-Hansenr   hinetlthur)	u   中文（繁體中文）u   中文（简体中文）EnglishzBahasa Indonesiau   हिन्दीu   नेपालीTagalogu	   ไทยu   اردوih  i  )SDHDzhttps://apps.hkedcity.netc                 T   U R                  U5      nU R                  X5      nU R                  SUS S9=(       dD    U R                  SUSS SS9=(       d*    U R	                  SUSS S9=(       d    U R                  U5      nU R                  SUS	5      nU R                  S
US5      nSUUUS.nU R                  U R                  S-   U[        U5      [        SS0U R                  5       5      S9nUS   n	UR                  S5      (       a  UR                  S5      (       dD  [        UR                  S5      5      n
SU
;   a  U R                  XR                  S9  O
[        U
SS9e/ n[!        U	R                  S5      5      n[!        U	R                  S5      5      nU	S   S   nUS    H  n[#        U R                  UR                  S5      5      nU(       d  M1  UR                  S 5      nU R$                  R                  U5      nU(       a  U(       a  U(       a  UU-  U-  OS nUR'                  UUR                  S!5      UUUS".5        M     0 n[)        US# [*        5      =(       d    / nU H  n[-        U[.        5      (       d  M  [1        UR                  S$5      5      nU(       a  [-        U[2        5      (       d  MR  UR5                  5       S%;  a  Mh  [#        U R                  UR                  S5      5      nU(       d  M  UR                  S 5      nUR7                  U R8                  R                  UU5      / 5      R'                  U R;                  U5      S&S'.5        M     U R                  S(U[        S)S*US+.5      SS0S,S-9=(       d    0 n[!        [)        US. 5      5      nUUU R                  S/US,S09[=        U R                  S1US,S09S,S29[!        U	R                  S35      5      UU[#        U R                  U	R                  S45      5      [?        U	R                  S55      5      US6.
$ )7N)ed_titlezsearch.ed_title)defaultz=data-favorite_title_(?:eng|chi)=(["\'])(?P<id>(?:(?!\1).)+)\1r   r   )r2   groupz<h1>([^<]+)</h1>z-post_var\[["\']file_id["\']\s*\]\s*=\s*(.+?);zfile IDz0post_var\[["\']curr_url["\']\s*\]\s*=\s*"(.+?)";zcurr URLget_info)actioncurr_urlfile_id	video_urlz/media/play/handler.phpzContent-Typez!application/x-www-form-urlencoded)dataheadersresultsuccessaccessaccess_err_msgz0Video streaming is not available in your country)msg	countriesT)expectedwidthheightplaylist    sourcesfilelabeltype)	format_idr   r   rB   rC   c                     U S   $ )Ntracks xs    P/home/james-whalen/.local/lib/python3.13/site-packages/yt_dlp/extractor/hketv.py<lambda>'HKETVIE._real_extract.<locals>.<lambda>   s    ak    kind)captionsr   srt)r   r   z+https://emocounter.hkedcity.net/handler.phpget_emotionetv)r5   zdata[bucket_id]zdata[identifier]F)r9   r:   fatalc                     U S   S   S   S   $ )Nr9   emotion_datarE   countrM   rN   s    rP   rQ   rR      s    qy8;GDrS   r   )rY   ed_date)	day_firstlengthimage
view_count)
r   r   r   r   r   formatsr   	thumbnailra   
like_count) 	_match_id_download_webpage_html_search_meta_search_regex_html_search_regex_og_search_title_download_json_APPS_BASE_URLr   r   geo_verification_headersgetr   raise_geo_restricted_GEO_COUNTRIESr   r   r   _FORMAT_HEIGHTSappendr   list
isinstancedictr
   strlower
setdefault	_CC_LANGS_proto_relative_urlr   r	   )selfr   video_idwebpager   r7   r6   r9   responser;   errorrb   rB   rC   	playlist0fmtfile_urlrH   hwr   rL   track
track_kind	track_urltrack_labelemotionrd   s                               rP   _real_extractHKETVIE._real_extractC   sX   >>#&((7 ""/$ # H .!!P$e " =.
 &&#Wgt ' E. $$W- 	 $$<Y  %%?Z! !  	
 &&";;X#D) C!E--/1 ' 2 (#||I&&hll8.D.Dx||,<=>EAUJ)))<)< * > %UT::FJJw/0VZZ12:&q)	Y'Ct22CGGFODH
 GGG$E$$((/A'(UvE	V#4ANN"wwv  (& 	$94@FBEeT**$UYYv%67JZ
C%@%@!)BB 3 3UYYv5FGI))G,K  !3!3["*+-//5v33I> 7 0 & %%98#'#($,% 
 $%HI &    	 !D"F G
 11we 2 5*4+A+A7% ,B ,1<AC#FJJx$89" !4!4fjj6IJ%fjj&>?$
 	
rS   rM   N)__name__
__module____qualname____firstlineno__IE_NAMEIE_DESC_GEO_BYPASSrp   
_VALID_URL_TESTSry   rq   rl   r   __static_attributes__rM   rS   rP   r   r      s    GhGKVNPJA1UA%"
 ' A18A%
 'F: %.$- 0404"$(
I O 1Nt
rS   r   N)commonr   utilsr   r   r   r   r	   r
   r   r   r   r   r   rM   rS   rP   <module>r      s%    !  g
m g
rS   