o
    i'                     @   sx   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 deZG d	d
 d
eZdS )    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                   @   s  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&d'gd(d)d*d+d,d-dd.d/d0d1d2d3d2d.d4d!d#d%d5d&d'gd(d6d7d8d9d:dd;d<d=d>d?d!d#d%d@d&d'gd(gZdAdB ZdCdD ZdEdF Z	dGS )H	DropoutIEzhttps://watch.dropout.tv/logindropoutzPhttps?://(?:watch\.)?dropout\.tv/(?:[^/?#]+/)*videos/(?P<id>[^/?#]+)/?(?:[?#]|$)z?https://watch.dropout.tv/game-changer/season:2/videos/yes-or-nozEpisode in a series 4b76963f904f8bc4ba22dcf0e66ada06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 manifestz$Failed to parse XML: not well-formed)urlnotemd5	info_dictexpected_warningszghttps://watch.dropout.tv/tablepop-presents-megadungeon-live/season:1/videos/enter-through-the-gift-shopz*Episode in a series (missing release_date) b08fb03050585ea25cd7ee092db9134c624270zenter-through-the-gift-shopzEnter Through the Gift ShopzdA new adventuring party explores a gift shop and runs into a friendly orc -- and some angry goblins.zYhttps://vhx.imgix.net/chuncensoredstaging/assets/a1d876c3-3dee-4cd0-87c6-27a851b1d0ec.jpgz$TablePop Presents: MEGADUNGEON LIVE!r   zSeason 1i  )r   r   r   r   r   r   r   r   r    r!   r#   r$   r%   r'   r(   z=https://watch.dropout.tv/videos/misfits-magic-holiday-specialzEpisode not in a series 1e6428f7756b02c93b573d39ddd789fe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                 C   s    | j | j|dd}| d|dS )NzGetting authenticity token)r*   z7name=["\']authenticity_token["\'] value=["\'](.+?)["\']authenticity_token)_download_webpage
_LOGIN_URL_html_search_regex)selfr   signin_page r9   L/home/ubuntu/.local/lib/python3.10/site-packages/yt_dlp/extractor/dropout.py_get_authenticity_token^   s   z!DropoutIE._get_authenticity_tokenc                 C   st   |   \}}|s
dS | j| j|ddt||| |ddd}| jd|ddd	}| d
kr0d S | dkr8dS dS )NTz
Logging inF)emailpasswordr3   utf8)r*   fataldataz(user_has_subscription:\s*["\'](.+?)["\']zsubscription statusnonedefaulttruefalsezAccount is not subscribedzIncorrect username/password)_get_login_infor4   r5   r   r;   _search_regexlower)r7   r   usernamer=   responseuser_has_subscriptionr9   r9   r:   _logine   s(   
	zDropoutIE._loginc                 C   sd  |  |}d }| ddr| ||}|rd|v r<| |}| ||}|r<d|v r<|du r6| jdd t|dd| d|d	}| |}t	d
|pNd}t
td|}tdtd|}	t| jd|	peddd d}
dt t|d| d|d||| jd|dd|r|dd nd t
td||
|
r|nd t| jd|	pddd dt| jd|dd ddS ) Nzhttps://watch.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#   rB   url_transparentzembed\.vhx\.tv/videos/(.+?)\?r   r   F)r?   ?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getr4   rL   raise_login_requiredr   r6   _og_search_thumbnailr   r   r
   r   rG   r   rV   _smuggle_referrer_html_search_metasplitr   )r7   r)   r   webpage	login_err	embed_urlr   
watch_infor   season_episoder!   r9   r9   r:   _real_extract|   sP   





zDropoutIE._real_extractN)
__name__
__module____qualname__r5   _NETRC_MACHINE
_VALID_URL_TESTSr;   rL   rd   r9   r9   r9   r:   r      s    	
Er   c                	   @   sp   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d Zdd ZdS )DropoutSeasonIE   zXhttps?://(?:watch\.)?dropout\.tv/(?P<id>[^\/$&?#]+)(?:/?$|/season:(?P<season>[0-9]+)/?$)z;https://watch.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,   z2https://watch.dropout.tv/dimension-20-fantasy-highz2Multi-season series with the season not in the urlz1https://watch.dropout.tv/dimension-20-shriek-weekzSingle-season series   z!dimension-20-shriek-week-season-1z#Dimension 20 Shriek Week - Season 1zAhttps://watch.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                 #   s^    |d7 } j | d| |d| dhd} fddttd|d	thd
fD E d H  d S )Nr   z?page=zDownloading page i  )r*   expected_statusc                    s   g | ]}  |tqS r9   )
url_resultr   ).0item_urlr7   r9   r:   
<listcomp>   s    z/DropoutSeasonIE._fetch_page.<locals>.<listcomp>zbrowse-item-link.href)r4   r   r   r	   )r7   r)   	season_idpager_   r9   rt   r:   _fetch_page   s   zDropoutSeasonIE._fetch_pagec                 C   sd   |  |}| |dpd}|dd }| tt| j	||| j
| d| | d| S )Nr    r   - z-season-z
 - Season )rW   _match_valid_urlgroupreplacer   playlist_resultr   	functoolspartialry   
_PAGE_SIZE)r7   r)   rw   
season_numseason_titler9   r9   r:   rd      s   
zDropoutSeasonIE._real_extractN)re   rf   rg   r   ri   rj   ry   rd   r9   r9   r9   r:   rk      sD    


'rk   )r   commonr   vimeor   utilsr   r   r   r	   r
   r   r   r   r   r   r   r   rk   r9   r9   r9   r:   <module>   s    4 