
    V|hM                     B    S SK Jr  SSKJrJrJrJrJr   " S S\5      rg)   )InfoExtractor   )ExtractorErrorint_or_nonetry_geturl_or_noneurlencode_postdatac                   ^    \ rS rSrSrSrSrSrSSSSS	S
S
S.SS0SS./rS r	0 4S jr
S rSrg)HiDiveIE   zPhttps?://(?:www\.)?hidive\.com/stream/(?P<id>(?P<title>[^/]+)/(?P<key>[^/?#&]+))Fhidivez$https://www.hidive.com/account/loginzIhttps://www.hidive.com/stream/the-comic-artist-and-his-assistants/s01e001z+the-comic-artist-and-his-assistants/s01e001mp4z#the-comic-artist-and-his-assistantsr   )idexttitleseriesseason_numberepisode_numberskip_downloadTzRequires Authentication)url	info_dictparamsskipc                    U R                  U R                  S 5      nU R                  SUSS S9nU(       d  g U R                  U5      nUR	                  UUS.5        U R                  U R                  S S[        U5      S9nU R                  SUSS S9nUc  g U R                  S	S [        UU R                  S
US5      SS.5      S9  g )Nz7(?s)<form[^>]+action="/account/login"[^>]*>(.+?)</form>z
login formdefault)EmailPasswordz
Logging in)dataz%<button [^>]+?data-profile-id="(\w+)"z
profile idz)https://www.hidive.com/ajax/chooseprofilez \<button [^>]+?data-hash="(\w+)"zprofile id hashz
/dashboard)	profileIdhash	returnUrl)_download_webpage
_LOGIN_URL_search_regex_hidden_inputsupdater	   _request_webpage)selfusernamepasswordwebpageformr   login_webpage
profile_ids           Q/home/james-whalen/.local/lib/python3.13/site-packages/yt_dlp/extractor/hidive.py_perform_loginHiDiveIE._perform_login#   s    (($?!!F\4 " 1 ""4( 
 	 ..OOT<6H6N / P ''4m\[_ ( a
7#'**7HY[)	%  	 	    c                 f    0 UEUUSS.EnU R                   " SU4S[        U5      0UD6=(       d    0 $ )N(f4f895ce1ca713ba263b91caeb1daa2d08904783)TitleKeyPlayerIdz$https://www.hidive.com/play/settingsr   )_download_jsonr	   )r)   video_idr   keyr   kwargss         r0   	_call_apiHiDiveIE._call_api?   sV    

B	
 ""2H5#D)5-35 ;8:	;r3   c                 J   U R                  U5      R                  SSS5      u  p#nU R                  X#U5      nUR                  S5      nUS:X  a  U R	                  5         U(       a  US:w  a  [        U R                   SU 3SS	9e/ S 1pUS
   R                  5        H  u  pU	R                  S5      u  pn[        [        U
S 5      5      nX;  d  M6  UR                  U5        U R                  XSSU	SS9nU H  nUUS'   U SU 3US'   M     UR                  U5        M     0 nUS
   R                  5        H  u  pU	R                  S5      u  pnU
R                  S5      =(       d    /  Hs  n[        [        US 5      5      n[        US S 4[        5      nUU;  d  M6  U(       d  M?  UR                  U5        UR                  U/ 5      R!                  SU05        Mu     M     UUUUU[#        U R%                  SUSS S95      [#        U R%                  SUSS S95      SU0S.$ ) Nr   r   r;   restrictionReasonRegionRestrictedNonez said: T)expected
renditions_c                     U S   S   $ )Nbitrateshls xs    r0   <lambda>(HiDiveIE._real_extract.<locals>.<lambda>X   s    *e@Tr3   r   m3u8_nativeF)entry_protocolm3u8_idfatallanguagez, format_noteccFilesc                     U S   $ )Nr   rI   rJ   s    r0   rL   rM   f   s    !r3   c                 H    U S   R                  SS5      R                  5       $ )Nr    -)replacelowerrJ   s    r0   rL   rM   g   s    adll36L6R6R6Tr3   c                     U S   $ )N    rI   rJ   s    r0   rL   rM   g   s    `abc`dr3   r   zs(\d+)zseason numberr   ze(\d+)zepisode numberReferer)r   r   	subtitlesformatsr   r   r   http_headers)_match_valid_urlgroupr=   getraise_geo_restrictedr   IE_NAMEitemssplitr   r   add_extract_m3u8_formatsextendstr
setdefaultappendr   r%   )r)   r   r:   r   r;   settingsrestrictionr_   parsed_urlsrendition_id	renditionaudioversionextram3u8_urlfrmtfr^   cc_filecc_urlcc_langs                        r0   _real_extractHiDiveIE._real_extractJ   sU   #44S9??guU>>(37ll#67,,%%';&0 <<.}5F F  "D6'/'='C'C'E#L$0$6$6s$;!EE"796T#UVH*)11mUain 2 pA$)AjM*1"UG'<Am$  t$ (F 	'/'='C'C'E#L$0$6$6s$;!EE$==39r9$WWn%EF!',TVd+egjk,OOF+(("5<<eV_M : (F "(""9c?D"QS)""9c3CT"RT&,
 	
r3   rI   N)__name__
__module____qualname____firstlineno__
_VALID_URL_GEO_BYPASS_NETRC_MACHINEr$   _TESTSr1   r=   r|   __static_attributes__rI   r3   r0   r   r      sf    dJ KN7J [?B;
 T
 * F 8 46 	;-
r3   r   N)	commonr   utilsr   r   r   r   r	   r   rI   r3   r0   <module>r      s     ! l
} l
r3   