
    V|h                          S SK r S SKrSSKJr  SSKJrJr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   )ExtractorErrorint_or_noneurlencode_postdatac                   2    \ rS rSrSrSrS rSS jrS rSr	g)	CuriosityStreamBaseIE   curiositystreamNc                     UR                  S0 5      R                  S5      nU(       aM  [        U[        5      (       a  SR                  UR	                  5       5      n[        U R                   SU 3SS9eg )Nerrormessagez, z said: T)expected)get
isinstancedictjoinvaluesr   IE_NAME)selfresultr   s      Z/home/james-whalen/.local/lib/python3.13/site-packages/yt_dlp/extractor/curiositystream.py_handle_errors$CuriosityStreamBaseIE._handle_errors   si    

7B'++I6%&&		%,,.1 <<.w/$@ @     c                    0 nU R                   (       df  U R                  S5      R                  S5      nU(       a?  U R                  S5        [        R
                  R                  UR                  5      U l         U R                   (       a  U R                   US'   U R                  U R                  U-   X$US9nU R                  U5        US   $ )Nzhttps://curiositystream.com
auth_tokenzObtained auth_token cookiezX-Auth-Token)headersquerydata)_auth_token_get_cookiesr   write_debugurllibparseunquotevalue_download_json_API_BASE_URLr   )r   pathvideo_idr    r   auth_cookier   s          r   	_call_apiCuriosityStreamBaseIE._call_api   s    ++,IJNN|\K  !=>#)<<#7#78I8I#J &*&6&6GN#$$%x % OF#f~r   c           
          U R                  SS S[        UUS.5      S9nU R                  U5        US   S   [        l        g )Nz(https://api.curiositystream.com/v1/loginz
Logging in)emailpassword)noter!   r   r   )r)   r   r   r
   r"   )r   usernamer2   r   s       r   _perform_login$CuriosityStreamBaseIE._perform_login"   sU    $$6$6!$8 % %  	F#,29,=l,K)r   )r"   )N)
__name__
__module____qualname____firstlineno___NETRC_MACHINEr"   r   r.   r5   __static_attributes__ r   r   r
   r
      s    &NK@Lr   r
   c                   T    \ rS rSrSrSrSSSSSS	S
S/\SS/ SS.SS0S./rSrS r	Sr
g)CuriosityStreamIE-   r   z9https?://(?:app\.)?curiositystream\.com/video/(?P<id>\d+)z&http://app.curiositystream.com/video/22mp4z!How Did You Develop The Internet?zbVint Cerf, Google's Chief Internet Evangelist, describes how he and Bob Kahn created the internet.zCuriosity Stream
Technology	Interviewz*re:https://img.curiositystream.com/.+\.jpg   )idexttitledescriptionchannel
categoriesaverage_rating	series_id	thumbnailtagsdurationskip_downloadT)url	info_dictparamsz)https://api.curiositystream.com/v1/media/c                 h   U R                  U5      n/ nS GH  nU R                  X"SUS.S9nUR                  S/ 5       GH  nUR                  S5      nUS:X  a"  UR                  U R	                  XrSS	S
S95        O&US:X  a   UR                  U R                  XrSS
S95        UR                  S5      nUR                  S5      n	U(       d	  U	(       d  M  [        UR                  S5      5      [        UR                  S5      5      [        UR                  S5      5      [        UR                  S5      5      [        UR                  S5      5      UR                  S5      UR                  S5      UR                  S5      S.n
X4 H  nU(       d  M  U
R                  5       n[        R                  " SU5      nU(       aE  UR                  UR                  S5      UR                  S5      UR                  S5      SSS.5        OUR                  US S!.5        UR                  U5        M     GM     GM!     WS"   n0 nUR                  S#/ 5       Hr  nUR                  S$5      nU(       d  M  UR                  S%5      =(       d    UR                  S&5      =(       d    S'nUR                  U/ 5      R                  SU05        Mt     UUUUR                  S(5      UR                  S)5      =(       d)    UR                  S*5      =(       d    UR                  S+5      [        UR                  S,5      5      UR                  S-5      UUR                  S.5      UR                  S/5      UR                  S05      /UR                  S15      [        UR                  S25      =(       d    S35      =(       d    S S4.$ )5N)m3u8mpdtrue)encodingsNewencodingsFormat)r    	encodingsmaster_playlist_urlrV   rB   hlsF)m3u8_idfatalrW   dash)mpd_idr_   rR   file_urlwidthheightvideo_bitrateaudio_bitratesize_in_bytesvideo_codecaudio_codeccontainer_type)rc   rd   vbrabrfilesizevcodecacodec	containerzG^(?P<url>rtmpe?://(?P<host>[^/]+)/(?P<app>.+))/(?P<playpath>mp[34]:.+)$playpathappflvrtmp)rR   	play_pathrr   rG   	format_idhttp)rR   rv   rH   closed_captionsfilecodelanguageenrI   image_largeimage_mediumimage_smallrP   rO   producerprimary_categorytyperating_percentagecollection_id )rF   formatsrH   rI   rN   rP   rO   	subtitlesrJ   rK   rL   rM   )	_match_idr.   r   extend_extract_m3u8_formats_extract_mpd_formatsr   copyresearchupdategroupappend
setdefaultstr)r   rR   r,   r   encoding_formatmediaencodingplaylist_urlencoding_urlrb   ff_urlfmtrt   rH   r   closed_captionsub_urllangs                      r   _real_extractCuriosityStreamIE._real_extractG   sC   >>#&.ONN8 &#2>N E "IIk26'||,AB"f,NN4#=#=$ %U $> $4 5 %-NN4#<#<$vU $= $L M'||E2#<<
3#H(g)>?)(,,x*@A&x||O'DE&x||O'DE +HLL,I J&ll=9&ll=9!).>!?	 +5E  &&(C99%oqvwD

#'::e#4)-J)?#'::e#4#()/$  

#()/$  NN3'% 61 7  /b g	#ii(92>N$((0G!%%f-W1C1CJ1OWSWD  r*11w3  ?  99]3=1jUYY~5NjRWR[R[\iRj#EIIj$9:IIf%"yy, 99%78%))F:KL#ii(;<UYY7=2>F$
 	
r   r=   N)r7   r8   r9   r:   r   
_VALID_URLfloat_TESTSr*   r   r<   r=   r   r   r?   r?   -   sc    GMJ78 A)'5#F
 T
 F* @MN
r   r?   c                       \ rS rSrS rSrg)CuriosityStreamCollectionBaseIE   c           	         U R                  U5      nU R                  X"5      n/ nUR                  S/ 5       Hy  n[        UR                  S5      5      nUR                  S5      (       a  S[        4OS[
        4u  pxUR                  U R                  SU SU 3UR                  5       US95        M{     U R                  XBUR                  S	5      UR                  S
5      5      $ )Nr   rF   is_collectionseriesvideozhttps://curiositystream.com//)ier,   rH   rI   )
r   r.   r   r   CuriosityStreamSeriesIEr?   r   
url_resultie_keyplaylist_result)	r   rR   r   
collectionentriesr   media_id
media_typer   s	            r   r   -CuriosityStreamCollectionBaseIE._real_extract   s    s+^^MA
^^GR0E599T?+HDIIIoD^D^h(?@eln  eANJNN4??.zl!H:F99; + 3 4 1 ##NN7#Z^^M%BD 	Dr   r=   N)r7   r8   r9   r:   r   r<   r=   r   r   r   r      s    Dr   r   c                   >    \ rS rSrSrSrSrSSSSS	.S
S.SSS./rSrg)CuriosityStreamCollectionsIE   zcuriositystream:collectionsz?https?://(?:app\.)?curiositystream\.com/collections/(?P<id>\d+)z/https://api.curiositystream.com/v2/collections/z*https://curiositystream.com/collections/8686zStaff PickszeWondering where to start? Here are a few of our favorite series and films... from our couch to yours.rF   rH   rI      rR   rS   playlist_mincountz*https://curiositystream.com/collections/36TrR   only_matchingr=   N	r7   r8   r9   r:   r   r   r*   r   r<   r=   r   r   r   r      sC    +GSJEM;" C

  <Fr   r   c                   >    \ rS rSrSrSrSrSSSSS	.S
S.SSS./rSrg)r      zcuriositystream:serieszIhttps?://(?:app\.)?curiositystream\.com/(?:series|collection)/(?P<id>\d+)z*https://api.curiositystream.com/v2/series/z$https://curiositystream.com/series/2rA   zCurious Minds: The Internetz:How is the internet shaping our lives in the 21st Century?r      r   z(https://curiositystream.com/collection/2Tr   r=   Nr   r=   r   r   r   r      s@    &G]J@M52W

   :Fr   r   )r   urllib.parser%   commonr   utilsr   r   r   r
   r?   r   r   r   r=   r   r   <module>r      s\    	  ! C C"LM "LJh
- h
VD&; D"#B $= r   