
    VGh&                         d dl Z ddlmZ ddlmZ ddlmZmZmZm	Z	m
Z
mZmZmZmZmZmZ  G d de      Z G d	 d
e      Zy)    N   )InfoExtractor)
VHXEmbedIE   )ExtractorErrorOnDemandPagedList
clean_htmlextract_attributesget_element_by_classget_element_by_idget_elements_html_by_classint_or_nonetraverse_objunified_strdateurlencode_postdatac                       e Zd ZdZdZdZdddi ddd	d
ddddddddddddddddddddddd d!d"d#d$d%d&gd'd(d)d*d+d,dd-d.d/d0d1d2d1d-d3d!d#d%d4d&gd'd5d6d7d8d9dd:d;d<d=d>d!d#d%d?d&gd'gZd@ ZdA ZdB Z	yC)D	DropoutIEzhttps://www.dropout.tv/logindropoutzAhttps?://(?:www\.)?dropout\.tv/(?:[^/]+/)*videos/(?P<id>[^/]+)/?$z=https://www.dropout.tv/game-changer/season:2/videos/yes-or-nozEpisode in a series 5e000fdfd8d8fa46ff40456f1c2af04aid738153
display_idz	yes-or-noextmp4titlez	Yes or NodescriptionzRAlly, Brennan, and Zac are asked a simple question, but is there a correct answer?release_date20200508	thumbnailzYhttps://vhx.imgix.net/chuncensoredstaging/assets/351e3f24-c4a3-459a-8b79-dc80f1e5b7fd.jpgserieszGame Changerseason_numberr   seasonzSeason 2episode_number   episodedurationi  uploader_iduser80538407uploader_urlzhttps://vimeo.com/user80538407uploaderz
OTT Videosz2Ignoring subtitle tracks found in the HLS manifest)urlnotemd5	info_dictexpected_warningszJhttps://www.dropout.tv/dimension-20-fantasy-high/season:1/videos/episode-1z*Episode in a series (missing release_date) 712caf7c191f1c47c8f1879520c2fa5c320562z	episode-1zThe Beginning BeginszdThe cast introduces their PCs, including a neurotic elf, a goblin PI, and a corn-worshipping cleric.zYhttps://vhx.imgix.net/chuncensoredstaging/assets/4421ed0d-f630-4c88-9004-5251b2b8adfa.jpgzDimension 20: Fantasy Highr   zSeason 1i  )r   r   r   r   r   r   r    r!   r"   r#   r%   r&   r'   r)   r*   z;https://www.dropout.tv/videos/misfits-magic-holiday-specialzEpisode not in a series c30fa18999c5880d156339f13c953a261915774zmisfits-magic-holiday-specialzMisfits & Magic Holiday SpecialzQThe magical misfits spend Christmas break at Gowpenny, with an unwelcome visitor.20211215zbhttps://vhx.imgix.net/chuncensoredstaging/assets/d91ea8a6-b250-42ed-907e-b30fb1c65176-8e24b8e5.jpgi-  )r   r   r   r   r   r   r   r&   r'   r)   r*   c                 d    | j                  | j                  |d      }| j                  d|d      S )NzGetting authenticity token)r,   z7name=["\']authenticity_token["\'] value=["\'](.+?)["\']authenticity_token)_download_webpage
_LOGIN_URL_html_search_regex)selfr   signin_pages      a/var/www/it7/html/youtubeDownloader/venv/lib/python3.12/site-packages/yt_dlp/extractor/dropout.py_get_authenticity_tokenz!DropoutIE._get_authenticity_token^   s@    ,,OOZ.J - L&&F-/ 	/    c                 $   | j                         \  }}|sy| j                  | j                  |ddt        ||| j	                  |      dd            }| j                  d|dd	      }|j                         d
k(  ry |j                         dk(  ryy)NTz
Logging inF)emailpasswordr6   utf8)r,   fataldataz(user_has_subscription:\s*["\'](.+?)["\']zsubscription statusnonedefaulttruefalsezAccount is not subscribedzIncorrect username/password)_get_login_infor7   r8   r   r=   _search_regexlower)r:   r   usernamerA   responseuser_has_subscriptions         r<   _loginzDropoutIE._logine   s    !113())OOZl%#!$&*&B&B:&N	%  *  !% 2 27CXbh !3 !j &&(F2"((*g5.0r>   c                    | j                  |      }d }| j                  d      j                  d      r| j                  ||      }|rd|v rL| j	                  |      }| j                  ||      }|r'd|v r#|du r| j                  d       t        |d      | j                  d|d	      }| j                  |      }t        d
|      xs d}t        t        d|            }t        dt        d|            }	t        | j                  d|	xs ddd             }
dt        j                         t        j                   |d      | j                  d|d      ||| j#                  d|d      |r|j%                  d      d   nd t        t        d|            |
|
r|nd t        | j                  d|	xs ddd             t'        | j                  d|dd             dS ) Nzhttps://www.dropout.tv_sessionz<div id="watch-unauthorized"Tany)method)expectedzembed_url:\s*["\'](.+?)["\']z	embed urlz
watch-info zvideo-titlezsite-font-secondary-colortextzEpisode (\d+)r%   rF   url_transparentzembed\.vhx\.tv/videos/(.+?)\?r   r   F)rC   ?r   zseries-titlezSeason (\d+),r"   zRdata-meta-field-name=["\']release_dates["\'] data-meta-field-value=["\'](.+?)["\']zrelease date)_typeie_keyr+   r   r   r   r   r   r    r#   r%   r!   r   )	_match_id_get_cookiesgetr7   rP   raise_login_requiredr   r9   _og_search_thumbnailr   r	   r   r   rK   r   r[   _smuggle_referrer_html_search_metasplitr   )r:   r+   r   webpage	login_err	embed_urlr   
watch_infor   season_episoder#   s              r<   _real_extractzDropoutIE._real_extract|   s   ^^C(
56:::F,,S*=G8GCJ/I,,S*=G;wF$--U-;$Y>>++,KWVab	--g6	&|W=C
/zJK-')=fj)QS$T%7%7n2It &8 &M N ' '')//	;ST$$%EyRVW$11-PU1V4=-a04 !5nj!QR, .uD();); ."6B$ *< *P Q+D,>,>eND -? -: ;
 	
r>   N)
__name__
__module____qualname__r8   _NETRC_MACHINE
_VALID_URL_TESTSr=   rP   ri    r>   r<   r   r      s   /JNUJ S)5hk u 	
 s 
 x .   * !! ; D ~  @  L!$ #W!W-	
2 `@5)/  Fx6!"$"#1 - @(" #W!W+	
0 Q-5=:r * B!- @( #W!W#	
aCFJ/1.)
r>   r   c            	       l    e Zd ZdZdZdddddddd	d
dddddddddddddddddddgZd Zd Zy)DropoutSeasonIE   zVhttps?://(?:www\.)?dropout\.tv/(?P<id>[^\/$&?#]+)(?:/?$|/season:(?P<season>[0-9]+)/?$)z9https://www.dropout.tv/dimension-20-fantasy-high/season:1z.Multi-season series with the season in the urlz"dimension-20-fantasy-high-season-1z$Dimension 20 Fantasy High - Season 1)r   r   )r+   r,   playlist_countr.   z0https://www.dropout.tv/dimension-20-fantasy-highz2Multi-season series with the season not in the urlz/https://www.dropout.tv/dimension-20-shriek-weekzSingle-season series   z!dimension-20-shriek-week-season-1z#Dimension 20 Shriek Week - Season 1z?https://www.dropout.tv/breaking-news-no-laugh-newsroom/season:3zCMulti-season series with season in the url that requires pagination   z(breaking-news-no-laugh-newsroom-season-3z*Breaking News No Laugh Newsroom - Season 3c              #      K   |dz  }| j                  | d| |d| dh      }t        t        d|      dt        hdf      D cg c]  }| j	                  |t
               c}E d {    y c c}w 7 
w)	Nr   z?page=zDownloading page i  )r,   expected_statuszbrowse-item-link.href)r7   r   r   r
   
url_resultr   )r:   r+   	season_idpagerd   item_urls         r<   _fetch_pagezDropoutSeasonIE._fetch_page   s     	((e6$ )4EdV2L_b^c ) eIU&'97CcL^K_agEhJj kXDOOHi8 k 	k 	k k 	ks   AA6A/#A6)A4*A6c           	      L   | j                  |      }| j                  |      j                  d      xs d}|j                  dd      j	                         }| j                  t        t        j                  | j                  ||      | j                        | d| | d|       S )Nr"   r   - z-season-z
 - Season )r\   _match_valid_urlgroupreplacer   playlist_resultr   	functoolspartialr~   
_PAGE_SIZE)r:   r+   r{   
season_numseason_titles        r<   ri   zDropoutSeasonIE._real_extract   s    NN3'	**3/55h?D1
 ((c288:##i//0@0@#yQSWSbSbck*.<.
:,0WY 	Yr>   N)rj   rk   rl   r   rn   ro   r~   ri   rp   r>   r<   rr   rr      s    JjJ OD :?		
 FH :?		
 E*9>		
 UY @E		
9%FNkYr>   rr   )r   commonr   vimeor   utilsr   r   r	   r
   r   r   r   r   r   r   r   r   rr   rp   r>   r<   <module>r      s?     !    Q
 Q
h8Ym 8Yr>   