
    V|h                     h    S SK r S SKrSSKJr  SSKJrJrJrJrJ	r	   " S S\5      r
 " S S	\5      rg)
    N   )InfoExtractor   )determine_extfloat_or_noneint_or_noneparse_iso8601strip_or_nonec                       \ rS rSrSrSrSSSSSS	S
S.SS0S.SSS.SSS.SSS.SSS.SSS.SSS.SSS.SSS.SSS./
rSrSrS r	Sr
g)ToggleIE   togglezc(?:https?://(?:(?:www\.)?mewatch|video\.toggle)\.sg/(?:en|zh)/(?:[^/]+/){2,}|toggle:)(?P<id>[0-9]+)zOhttp://www.mewatch.sg/en/series/lion-moms-tif/trailers/lion-moms-premier/343115343115mp4zLion Moms Premierez$md5:aea1149404bff4d7f7b6da11fafd8e6b20150910iU)idexttitledescriptionupload_date	timestampskip_downloadm3u8 downloadurl	info_dictparamsz<http://www.mewatch.sg/en/movies/dug-s-special-mission/341413Tr   only_matchingzWhttp://www.mewatch.sg/en/series/28th-sea-games-5-show/28th-sea-games-5-show-ep11/332861zqhttp://video.toggle.sg/en/clips/seraph-sun-aloysius-will-suddenly-sing-some-old-songs-in-high-pitch-on-set/343331zphttp://www.mewatch.sg/en/clips/seraph-sun-aloysius-will-suddenly-sing-some-old-songs-in-high-pitch-on-set/343331z>http://www.mewatch.sg/zh/series/zero-calling-s2-hd/ep13/336367z`http://www.mewatch.sg/en/series/vetri-s2/webisodes/jeeva-is-an-orphan-vetri-s2-webisode-7/342302z1http://www.mewatch.sg/en/movies/seven-days/321936z\https://www.mewatch.sg/en/tv-show/news/may-2017-cna-singapore-tonight/fri-19-may-2017/512456z4http://www.mewatch.sg/en/channels/eleven-plus/401585
tvpapi_14711111c                   ^ U R                  U5      nSSSSS.SSSSU R                  U R                  S.USS.nU R                  SUS[        R
                  " U5      R                  5       S	9mTS
   n/ nTR                  S/ 5       GH$  nUR                  S5      UR                  S5      pU(       a  US:X  d  U(       d  M;  [        U5      n	UR                  SS5      nU	S:X  aC  U R                  XrSUSU S3SU S3SS9n
U
 H  nSUS   ;   a  M  UR                  U5        M!     M  U	S:X  a,  UR                  U R                  XrUSU S3SU S3SS95        M  U	S:X  a-  UR                  U R                  XrUSU S3SU S3SS95        GM  U	S:X  d  GM  UR                  U	UUS.5        GM'     U(       dx  TR                  S 5      =(       d    /  HZ  nU R                  S!5      (       a  M  UR                  S"5      S#:X  d  M2  UR                  S$5      S%:X  d  MI  U R!                  U5        M\     / nTR                  S&/ 5       H  n[#        U[$        5      (       d  M  UR                  S5      nU(       d  M4  SU0nUR                  S'S5      n[&        R(                  " S(U5      nU(       aD  UR+                  [-        UR/                  S)5      5      [-        UR/                  S*5      5      S+.5        UR                  U5        M     U4S, jnUU[1        TR                  S-5      5      [3        TR                  S.5      5      [5        TR                  S/5      =(       d    S 5      [7        TR                  S05      5      U" S15      U" S25      UUS3.
$ )4N r   )LocaleLanguageLocaleCountryLocaleDeviceLocaleUserState0)LocalePlatformSiteGuidDomainIDUDIDApiUserApiPass)initObjMediaID	mediaTypezHhttp://tvpapi.as.tvinci.com/v2_9/gateways/jsonpostgw.aspx?m=GetMediaInfozDownloading video info json)data	MediaNameFilesURLFormatNA m3u8r   zDownloading z m3u8 informationzFailed to download F)r   m3u8_idnoteerrnotefatalz/fpshls/r   mpdz MPD manifest)mpd_idr<   r=   r>   ismz ISM manifest)ism_idr<   r=   r>   )r   r   	format_idMetasallow_unplayable_formatsKey
EncryptionValue1PicturesPicSizez!(?P<width>\d+)[xX](?P<height>\d+)widthheight)rL   rM   c                    > [        TR                  U S-   5      =(       d"    TR                  U R                  5       S-   5      5      $ )NCounter_counter)r   getlower)prefixinfos    Q/home/james-whalen/.local/lib/python3.13/site-packages/yt_dlp/extractor/toggle.pycounter'ToggleIE._real_extract.<locals>.counter   s<    )+,U*9T0UW W    DescriptionDurationCreationDateRatingViewLike)
r   r   r   durationr   average_rating
view_count
like_count
thumbnailsformats)	_match_id	_API_USER	_API_PASS_download_jsonjsondumpsencoderQ   r   replace_extract_m3u8_formatsappendextend_extract_mpd_formats_extract_ism_formats	get_param
report_drm
isinstancedictresearchupdateintgroupr
   r   r	   r   )selfr   video_idr   r   rd   
video_file	video_url
vid_formatr   m3u8_formatsfmetarc   picturepic_url	thumbnailpic_sizemrV   rT   s                       @rU   _real_extractToggleIE._real_extract>   s   >>#&
 ')%'$&'(	 >>>>  !
& ""V3$**V:L:S:S:U # W [!((7B/J$.NN5$9:>>(;Sz	T 1	*C#++C4Jf}#99UJ'
|3DE1*=NO	  :  !
 &A!QuX- NN1%	 &
 t88
'
|=A1*]K	  9  ! "
 t88
'
|=A1*]K	  9  ! "
 $!+  ? 0H '*0b0'ABB HHUO|;@QUX@XOOH- 1 
xx
B/Ggt,,kk%(GwI {{9b1H		>IA   !12!!''("34"  i(! 0$	W
 (-)@A#DHHZ$89&txx'?'G4H+DHHX,>?!&/!&/$
 	
rX    N)__name__
__module____qualname____firstlineno__IE_NAME
_VALID_URL_TESTSrf   rg   r   __static_attributes__r   rX   rU   r   r      s    GwJ`)A%#
 _
 N i C B P r C n FK(FT IIj
rX   r   c                   Z    \ rS rSrSrSrSSSSSS	S
S.SS0S.SSS.SSS.SSS./rS rSrg)	MeWatchIE   mewatchzEhttps?://(?:(?:www|live)\.)?mewatch\.sg/watch/[^/?#&]+-(?P<id>[0-9]+)z5https://www.mewatch.sg/watch/Recipe-Of-Life-E1-1793711008625r   u   Recipe Of Life 味之道i_z$md5:6e88cde8af2068444fc8e1bc3ebf257c20201021)r   r   r   r   r   r   r   r   r   ub   https://www.mewatch.sg/watch/Little-Red-Dot-Detectives-S2-搜密。打卡。小红点-S2-E1-176232Tr   zhttps://www.mewatch.sg/watch/Little-Red-Dot-Detectives-S2-%E6%90%9C%E5%AF%86%E3%80%82%E6%89%93%E5%8D%A1%E3%80%82%E5%B0%8F%E7%BA%A2%E7%82%B9-S2-E1-176232z7https://live.mewatch.sg/watch/Recipe-Of-Life-E41-189759c                     U R                  U5      nU R                  SU-   USS0S9S   nU R                  SU-   [        R	                  5       U5      $ )Nz!https://cdn.mewatch.sg/api/items/segmentsall)querycustomIdztoggle:)re   rh   
url_resultr   ie_key)r{   r   item_id	custom_ids       rU   r   MeWatchIE._real_extract   sg    ..%''/'9J. ( 00:<	 	!8??#4iA 	ArX   r   N)	r   r   r   r   r   r   r   r   r   r   rX   rU   r   r      sn    GYJF/#A%
 _
 t j I'F0ArX   r   )ri   rv   commonr   utilsr   r   r   r	   r
   r   r   r   rX   rU   <module>r      s5     	 ! Z
} Z
z!A !ArX   