
    V|hF                         S SK rS SKrSSKJr  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Jr  SSKJr   " S S	\5      r " S
 S\5      r " S S\5      r " S S\5      r " S S\5      rg)    N   )InfoExtractor   )Request)ExtractorErrorOnDemandPagedListUserNotLivedetermine_extfilter_dictint_or_none
orderedSetparse_iso8601url_or_noneurlencode_postdataurljoin)traverse_objc                   8    \ rS rSrSrS rSS jr\S 5       rSr	g)	AfreecaTVBaseIE   	afreecatvc                    SSUUSSSS.nU R                  SS S[        U5      S	9nS
SSSSSSSSSSSSS.n[        UR                  S5      5      nUS:w  a,  UR                  US5      n[	        SU R
                   SU 3SS9eg )Nloginjsonfalse	oLoginRet )szWorkszTypeszUid
szPasswordisSaveIdszScriptVarszActionz0https://login.sooplive.co.kr/app/LoginAction.phpz
Logging indatazMYour account has been suspended due to a violation of our terms and policies.z:https://member.sooplive.co.kr/app/user_delete_progress.phpz8https://login.sooplive.co.kr/membership/changeMember.phpzHello! Soop here.
The username you have entered belongs to 
 an account that requires a legal guardian's consent. 
If you wish to use our services without restriction, 
please make sure to go through the necessary verification process.z5https://member.sooplive.co.kr/app/pop_login_block.phpz5https://login.sooplive.co.kr/afreeca/second_login.phpz3https://member.sooplive.co.kr/app/user_security.phpzCThe username does not exist or you have entered the wrong password.z4You have entered your username/password incorrectly.z>You cannot use your Global Soop account to access Korean Soop.zSorry for the inconvenience. 
Your account has been blocked due to an unauthorized access. 
Please contact our Help Center for assistance.z:You have failed to log in. Please contact our Help Center.)iiiir   iiiRESULTr   zYou have failed to log in.zUnable to login: z said: Texpected)_download_jsonr   r   getr   IE_NAME)selfusernamepassword
login_formresponse_ERRORSresulterrors           T/home/james-whalen/.local/lib/python3.13/site-packages/yt_dlp/extractor/afreecatv.py_perform_loginAfreecaTVBaseIE._perform_login   s    "&

 &&>1*= ' ?
 `LJ BGHFTUFP `P
  X\\(34Q;KK(DEE #DLL>@      Nc           
      H    U R                  [        SU 3X4USS0S9USS5      $ )Nzhttps://api.m.sooplive.co.kr/
legacy_sslT)r%   headersquery
extensionszDownloading API JSONzUnable to download API JSON)r.   r   )r1   endpoint
display_idr%   r?   r@   s         r9   	_call_apiAfreecaTVBaseIE._call_api?   s@    ""7+H:6e$d+$- /9"$A	C 	Cr<   c                 0    [        U 5      (       d  g U SS./$ )Njpg)urlextr   )	thumb_urls    r9   _fixup_thumbAfreecaTVBaseIE._fixup_thumbF   s     9%% "%011r<    )NNN)
__name__
__module____qualname____firstlineno___NETRC_MACHINEr:   rD   staticmethodrL   __static_attributes__rN   r<   r9   r   r      s'     N$LC 2 2r<   r   c                       \ rS rSrSrSrSrSSS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0S.SSSSSS S!S"S#S$.SS0S%S&.S'SS(.S)SS(.S*SS(./rS+ rS,r	g-).AfreecaTVIEO   soopzsooplive.co.krzdhttps?://vod\.(?:sooplive\.co\.kr|afreecatv\.com)/(?:PLAYER/STATION|player)/(?P<id>\d+)/?(?:$|[?#&])z*https://vod.sooplive.co.kr/player/9675336320230108_9FF5BEE1_244432674_1mp4
rlantnghksu   페이즈으iX*  z<re:https?://videoimg\.(?:sooplive\.co\.kr|afreecatv\.com)/.+20230108ie̺cu   젠지 페이즈)	idrI   uploader_iduploaderduration	thumbnailupload_date	timestamptitleskip_downloadT)rH   	info_dictparamsz1http://vod.sooplive.co.kr/PLAYER/STATION/20515605!20170411_BE689A0E_190960999_1_2_hu   혼자사는여자집zCre:https?://(?:video|st)img\.(?:sooplive\.co\.kr|afreecatv\.com)/.+u   ♥이슬이dasl812120170411i	X   )	r^   rI   re   rb   r`   r_   rc   rd   ra   z*https://vod.sooplive.co.kr/player/9726769020180327_27901457_202289533_1u   [생]빨개요♥ (part 1)u
   [SA]서아bjdyrksu20180327i  )r^   rI   re   rb   r`   r_   rc   ra   The VOD does not exist)rH   rg   rh   skipz*https://vod.sooplive.co.kr/player/70395877rH   only_matchingz+https://vod.sooplive.co.kr/player/104647403z*https://vod.sooplive.co.kr/player/81669846c                    U R                  U5      nU R                  SUSU0[        USS.5      S9S   n[        US[        145      nUS:X  a
  [        S	S
S9eUS:X  a
  [        SS
S9e[        US[        14S[        14S[        14S[        SS914SU R                  14S.5      n/ n[        [        USS 45      SS9 H  u  pxUS   n	[        U	5      S:X  a  U R                  XSSSU S3S 9n
OU	S!S"./n
UR                  0 UEUR                  S#5      =(       d    U S$U 3UR                  S5      =(       d    S% S&U S'3U
S(.E[        US)[        SS914S*[        S+[        R                   " S,S-9S.914S/.5      E5        M     [        US0[        145      S1:X  a:  U(       d  U R#                  S2S3S49  U R%                  S5U R'                  S35       35        U(       d(  [        US6[        145      (       a  U R#                  S7S3S49  [)        U5      S:X  a  0 US8   ESUR                  S5      0E$ [        US9S:S;9US<'   U R*                  " Xb4S=S
0UD6$ )>Nzstation/video/a/viewReferer
   )nTitleNo	nApiLevel)r?   r%   r%   codeirp   Tr,   izThis VOD is privatere   writer_nickbj_idtotal_file_duration  scalethumb)re   r`   r_   ra   
thumbnailsfilesc                     [        US   5      $ )NfilerJ   _vs     r9   <lambda>+AfreecaTVIE._real_extract.<locals>.<lambda>   s    +ai:Pr<   r   startr   m3u8r[   hlszDownloading part z m3u8 information)m3u8_idnotehttp)rH   	format_idfile_info_keyr   Untitledz (part ))r^   re   formatsra   
file_start 	   hours	delimitertimezone)ra   rd   adult_statusnotLoginz5Only users older than 19 are able to watch this videor3   methodzIn accordance with local laws and regulations, underage users are restricted from watching adult content. Only content suitable for all ages will be downloaded. sub_upload_typez This VOD is for subscribers onlyr   ).rd   F)get_allrd   multi_video)	_match_idrD   r   r   intr   strr   rL   	enumerater
   _extract_m3u8_formatsappendr/   r   dt	timedeltaraise_login_requiredreport_warning_login_hintlenplaylist_result)r1   rH   video_idr%   
error_codecommon_infoentriesfile_numfile_elementfile_urlr   s              r9   _real_extractAfreecaTVIE._real_extract   s   >>#&~~"Hy#6F#$%   
  "$#8
 !9DII5  !6FF"4u%&.#cU+.41H0IJ"T%6%6$78*
  &/TG-P#QRZ[']"H#F+HX&&044u,XJ6GH 5 J
 $!' 
 NN 		"&&7ShZq
;S'OOG4B
C78*TUV"		
 |!+k.E-F G".WYWcWcjkWl1m0n!o. 	 	']0 ~u56*D))KT^ * `,,0,<,<Z,H+IKL
 </@3%.HII%%&HQ[%\w<1!*1 
 $09KUZ#[K ##GW4W;WWr<   rN   N)
rO   rP   rQ   rR   r0   IE_DESC
_VALID_URL_TESTSr   rU   rN   r<   r9   rW   rW   O   s    GGxJ;1'&X%#'

 T
$ C5,_&%%#

 T
& <11_$%%	
 T
 )!& < = <u>F@DXr<   rW   c                   >    \ rS rSrSrSrSrSSS0SS	./rS
 rS r	Sr
g)AfreecaTVCatchStoryIE   zsoop:catchstoryzsooplive.co.kr catch storyzOhttps?://vod\.(?:sooplive\.co\.kr|afreecatv\.com)/player/(?P<id>\d+)/catchstoryz3https://vod.sooplive.co.kr/player/103247/catchstoryr^   103247r   rH   rg   playlist_countc                     U R                  U5      nU R                  SUSU0SUS.S9nU R                  U R                  U5      U5      $ )Nzcatchstory/a/viewru   r   )aStoryListIdx	nStoryIdx)r?   r@   )r   rD   r   _entries)r1   rH   r   r%   s       r9   r   #AfreecaTVCatchStoryIE._real_extract   sV    >>#&~~Is3C$&X>  @ ##DMM$$7BBr<   c              #      #    [        USS SS SSS[        14SSS[        14SSS	[        S
S914S[        14S[        14S[        14SU R                  14S[        14S.45       S h  vN   g  N7f)Nr%   c                     US   S:H  $ )N
story_typecatchrN   r   s     r9   r   0AfreecaTVCatchStoryIE._entries.<locals>.<lambda>   s    <G!;r<   
catch_listc                     US   S   S   $ )Nr   r   r   rN   r   s     r9   r   r      s    qz!}V'<r<   r   r   r   r   ra   r}   r~   re   rz   	writer_idr   write_timestamp)r^   rH   ra   re   r`   r_   r   rd   )r   r   r   r   rL   )r1   r%   s     r9   r   AfreecaTVCatchStoryIE._entries   s     ;<?SE:F[M:$ak6M5NO!C5)*SE2 +cU3&):):(;</+?	?'  	 	s   A'A1)A/*A1rN   N)rO   rP   rQ   rR   r0   r   r   r   r   r   rU   rN   r<   r9   r   r      s:    G*GcJD(
  FCr<   r   c            	       n    \ 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./rSr/ SQr	/ SQr
S rS rSrg)AfreecaTVLiveIE   z	soop:livezsooplive.co.kr livestreamszThttps?://play\.(?:sooplive\.co\.kr|afreecatv\.com)/(?P<id>[^/?#]+)(?:/(?P<bno>\d+))?z-https://play.sooplive.co.kr/pyh3646/237852185	237852185r[   u,   【 우루과이 오늘은 무슨일이? 】u   박진우[JINU]pyh3646iaT)r^   rI   re   r`   r_   rd   is_livezLivestream has ended)rH   rg   rq   rr   z#https://play.sooplive.co.kr/pyh3646z7https://live.sooplive.co.kr/afreeca/player_live_api.php)gcp_cdngs_cdn_pc_appgs_cdn_mobile_webgs_cdn_pc_web)gs_cdngs_cdn_chromecast	azure_cdnaws_cfkt_cdnc                 f  ^  UR                  S5      =(       d    Sn[        / [        US[        1[        U 4S j45      QT R
                  Q5      nT R                  SU5      n[        USS9 HZ  u  px[        T R                  [        US5      US	U S
3SU S
3SUU S3S.S9S[        145      n	 T R                  XSSSU0SS0S9s  $    g ! [         a[  n
U[        U5      :X  a  e T R                  U
R                  =(       d    U
R                    SU S[        U5       S35         S n
A
M  S n
A
ff = f)NRMDz)https://livestream-manager.sooplive.co.krCDNc                 "   > UTR                   ;  $ )N)	_BAD_CDNS)r   r   r1   s     r9   r   2AfreecaTVLiveIE._extract_formats.<locals>.<lambda>*  s    RVR`R`I`r<   cdnr   r   zbroad_stream_assign.htmlDownloading z stream infozUnable to download Fz-common-master-hls)return_type	broad_key)fatalr@   view_urlr[   r   aidru   zhttps://play.sooplive.co.kr/)r   r@   r?   z. Retrying... (attempt z of r   )r/   r   r   r   all_WORKING_CDNS_configuration_argr   r.   r   r   r   r   r   r   causemsg)r1   channel_infobroadcast_nor   stream_base_urldefault_cdn_idscdn_idsattemptcdn_idm3u8_urles   `          r9   _extract_formats AfreecaTVLiveIE._extract_formats%  sx   &**51`5` % &
,s<`(ab&
&
  ))%A(:OG#D$7$7)CDlvhl37J6(R^5_#)$0>1C!D$ %8 %  +/1H^11E5PS&(FG 2 I I  ; " ^c'l*##ww'!%%((?ySQX\NZ[\^ ^^s   /C
D0AD++D0c                    U R                  U5      R                  SS5      u  p#[        U R                  U R                  U[        SU05      S9S[        145      =(       d    0 nUR                  S5      =(       d    UnUR                  S5      =(       d    UnU(       dA  UR                  S5      nUS	:X  a	  [        US
9eUS:X  a  U R                  SSS9  [        S5      eU R                  S5      nUR                  S5      S:X  a  Uc
  [        SSS9e[        U R                  U R                  USS[        [        USSSUS.5      5      S9S[        145      =(       d    0 nUR                  S5      nU(       dB  UR                  S5      nUS	:X  a
  [        SSS9eUS:X  a  U R                  SSS9  [        S5      eU R                  XCU5      n	[        U R                  S US!S"S#U0S$S%9[        15      =(       d    0 n
UUR                  S&5      =(       d    U
R                  S'5      UR                  S(5      =(       d    U
R                  S)5      U[        U
R                  S*5      S+[        R                   " S,S-9S.9U	SS/U0S0.$ )1Nr^   bnobidr$   CHANNELBJIDBNOr+   r   )r   r(   z.This channel is streaming for subscribers onlyr3   r   z"Unable to extract broadcast numbervideopasswordBPWDYzKThis livestream is protected by a password, use the --video-password optionTr,   z#Downloading access token for streamz*Unable to download access token for streamcommonr   master)r   stream_typetypequalitypwdAIDzThis livestream has endedz'This livestream is for subscribers onlyzUnable to extract access tokenz4https://st.sooplive.co.kr/api/get_station_status.phpzDownloading channel metadataz#Unable to download channel metadataszBjIdF)r@   r   TITLEstation_titleBJNICKstation_namebroad_startr   r   r   r   ru   )r^   re   r`   r_   rd   r   r   http_headers)_match_valid_urlgroupr   r.   _LIVE_API_URLr   dictr/   r	   r   r   	get_paramr   r   r   r   r   )r1   rH   broadcaster_idr   r   r7   r3   
token_infor   r   station_infos              r9   r   AfreecaTVLiveIE._real_extractA  s   '+'<'<S'A'G'Ge'T$#D$7$75GP^H_5` %8 %b! '$& 	 &))&1C^#''.>,!%%h/F{!>::2))DZ * Y !EFF>>/2F#s*x/? ]  "$"5"5.S8?QR]#'#_ S @ #6 # tf%' - +- 	 nnU#^^H-F{$%@4PP2))*S\f)g !ABB''CH#D$7$7BL*,Q^,E %8 %; >BFD J HJ 	 !%%g.S,2B2B?2S$((2Vl6F6F~6V)&|'7'7'FRU`b`l`lst`uv&,	
 		
r<   rN   N)rO   rP   rQ   rR   r0   r   r   r   r  r   r   r   r   rU   rN   r<   r9   r   r      sz    G*GhJ>C)$#
 ' ? 5F( NMMI^89
r<   r   c                   x    \ 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S
.SSSSS.SS
./rSrS rS r	Sr
g)AfreecaTVUserIEi}  z	soop:userz^https?://ch\.(?:sooplive\.co\.kr|afreecatv\.com)/(?P<id>[^/?#]+)/vods/?(?P<slug_type>[^/?#]+)?z.https://ch.sooplive.co.kr/ryuryu24/vods/reviewplaylistryuryu24zryuryu24 - review)_typer^   re   r   r   z3https://ch.sooplive.co.kr/parang1995/vods/highlight
parang1995zparang1995 - highlighti  z'https://ch.sooplive.co.kr/ryuryu24/vodszryuryu24 - all   z3https://ch.sooplive.co.kr/ryuryu24/vods/balloonclipzryuryu24 - balloonclipr   <   c           	   #      #    US-  nU R                  SU SU 3UX0R                  SS.SU SU 3S9nUS	    H&  nU R                  S
US    S3[        US   5      v   M(     g 7f)Nr   z!https://chapi.sooplive.co.kr/api/z/vods/reg_date)pageper_pageorderbyr   z video page )r@   r   r%   z"https://vod.sooplive.co.kr/player/title_no/)r.   	_PER_PAGE
url_resultrW   )r1   user_id	user_typer)  infoitems         r9   _fetch_pageAfreecaTVUserIE._fetch_page  s     	""%FwivV_U`#acj26NN_i)j*6ykdV(T # V LD//4T*5E4FaH+W[\fWgi i !s   A!A#c                     U R                  U5      R                  SS5      u  p#U=(       d    Sn[        [        R                  " U R
                  X#5      U R                  5      nU R                  XBU SU 35      $ )Nr^   	slug_typer   z - )r  r  r   	functoolspartialr4  r.  r   )r1   rH   r0  r1  r   s        r9   r   AfreecaTVUserIE._real_extract  sp    !2237==dKP&	#I$5$5d6F6F$[]a]k]kl##G	YK6PQQr<   rN   N)rO   rP   rQ   rR   r0   r   r   r.  r4  r   rU   rN   r<   r9   r   r   }  s    GrJ?(

  E-

  9%

  E-

 1 FB IiRr<   r   )datetimer   r8  r  r   
networkingr   utilsr   r   r	   r
   r   r   r   r   r   r   r   utils.traversalr   r   rW   r   r   r   rN   r<   r9   <module>r?     sr      !      +62m 62rHX/ HXV!O !H|
o |
~3Ro 3Rr<   