o
    i                     @   sh   d dl Z ddlmZ ddlmZmZmZmZmZm	Z	 G dd deZ
G dd	 d	e
ZG d
d de
ZdS )    N   )InfoExtractor   )
clean_htmlfloat_or_noneint_or_noneparse_qstry_geturlencode_postdatac                   @   s:   e Zd ZdZdZdZdZdeedZddd	Zd
d Z	dS )CiscoLiveBaseIEz#https://events.rainfocus.com/api/%s Na3vqYdAlJFSxhYTYQGuMbpafMqftalz n6l4Lo05R8fiy3RpUBm447dZN8uNWoyezShttp://players.brightcove.net/5647924234001/SyK2FdqjM_default/index.html?videoId=%szhttps://ciscolive.cisco.com)OriginrfApiProfileId
rfWidgetIdNc                 C   s0   | j  }||d< | j| j| ||t||dS )NReferer)notedataheaders)HEADERScopy_download_jsonRAINFOCUS_API_URLr
   )selfeprf_idqueryreferrerr   r    r   N/home/ubuntu/.local/lib/python3.10/site-packages/yt_dlp/extractor/ciscolive.py	_call_api   s   
zCiscoLiveBaseIE._call_apic           
   
   C   s   | d}|d }t| d}t|dd }|d d d }| j| }tt|d	d }t|d
d }	|r:|d }d|d|||||	|d	S )N	eventNametitleabstractc                 S      | d d d S )Nparticipantsr   fullNamer   xr   r   r   <lambda>'       z0CiscoLiveBaseIE._parse_rf_item.<locals>.<lambda>videosr   urlc                 S   r$   )Ntimesr   lengthr   r'   r   r   r   r)   *   r*   c                 S   r$   )Nr-   r   roomr   r'   r   r   r   r)   +   r*   <   url_transparentBrightcoveNew)	_typer,   ie_keyr"   descriptiondurationcreatorlocationseries)getr   r	   BRIGHTCOVE_URL_TEMPLATEr   )
r   rf_item
event_namer"   r5   presenter_namebc_idbc_urlr6   r8   r   r   r   _parse_rf_item#   s(   

zCiscoLiveBaseIE._parse_rf_item)N)
__name__
__module____qualname__r   RAINFOCUS_API_PROFILE_IDRAINFOCUS_WIDGET_IDr;   r   r    rA   r   r   r   r   r      s    
r   c                   @   sH   e Zd ZdZdddddddd	d
dddddddddgZdd ZdS )CiscoLiveSessionIEzLhttps?://(?:www\.)?ciscolive(?:\.cisco)?\.com/[^#]*#/session/(?P<id>[^/?&]+)zMhttps://ciscolive.cisco.com/on-demand-library/?#/session/1423353499155001FoSs c98acf395ed9c9f766941c70f5352e225803694304001mp4z613 Smart Automations to Monitor Your Cisco IOS Networkz$md5:ec4a436019e09a918dec17714803f7ccis6[201806295647924234001z	16B Mezz.)idextr"   r5   	timestampupload_dateuploader_idr8   )r,   md5	info_dictzthttps://www.ciscolive.com/global/on-demand-library.html?search.event=ciscoliveemea2019#/session/15361595531500013WOUTr,   only_matchingzVhttps://www.ciscolive.com/global/on-demand-library.html?#/session/1490051371645001kNaSc                 C   s0   |  |}| d|d|i|}| |d d S )NsessionrM   itemsr   )	_match_idr    rA   )r   r,   r   	rf_resultr   r   r   _real_extractT   s   
z CiscoLiveSessionIE._real_extractN)rB   rC   rD   
_VALID_URL_TESTSrZ   r   r   r   r   rG   =   s,    rG   c                       sb   e Zd ZdZdddiddddd	d
dd	gZe fddZedd Zdd Z	dd Z
  ZS )CiscoLiveSearchIEzWhttps?://(?:www\.)?ciscolive(?:\.cisco)?\.com/(?:global/)?on-demand-library(?:\.html|/)zhttps://ciscolive.cisco.com/on-demand-library/?search.event=ciscoliveus2018&search.technicallevel=scpsSkillLevel_aintroductory&search.focus=scpsSessionFocus_designAndDeployment#/r"   Search query   )r,   rS   playlist_countzhttps://ciscolive.cisco.com/on-demand-library/?search.technology=scpsTechnology_applicationDevelopment&search.technology=scpsTechnology_ipv6&search.focus=scpsSessionFocus_troubleshootingTroubleshooting#/TrT   zhttps://www.ciscolive.com/global/on-demand-library.html?search.technicallevel=scpsSkillLevel_aintroductory&search.event=ciscoliveemea2019&search.technology=scpsTechnology_dataCenter&search.focus=scpsSessionFocus_bestPractices#/c                    s   t |rdS t |S )NF)rG   suitablesuper)clsr,   	__class__r   r   ra   j   s   zCiscoLiveSearchIE.suitablec                 C   s   t t| dd d uS )Nc                 S   r$   )Nr+   r   r,   r   r'   r   r   r   r)   p   r*   z7CiscoLiveSearchIE._check_bc_id_exists.<locals>.<lambda>)r   r	   )r<   r   r   r   _check_bc_id_existsn   s   z%CiscoLiveSearchIE._check_bc_id_existsc           
   	   c   s   d|d< d|d< t dD ]q}| dd ||d| }t|dd	 t}|r(|}|d
}|r4t|ts7 d S |D ]}t|tsAq9| |sGq9| 	|V  q9t
|d}|d ur]||d< t
|d}	|	d uru|d |d  |	kru d S |d  |d 7  < qd S )N2   sizer   fromr   searchzDownloading search JSON page c                 S   s   | d d S )NsectionListr   r   r'   r   r   r   r)   y   s    z,CiscoLiveSearchIE._entries.<locals>.<lambda>rW   total)	itertoolscountr    r	   dictr:   
isinstancelistrf   rA   r   )
r   r   r,   page_numresultsslrW   itemrh   rl   r   r   r   _entriesr   s8   


zCiscoLiveSearchIE._entriesc                 C   s&   t |}d|d< | j| ||ddS )NrV   typer^   )playlist_title)r   playlist_resultrv   )r   r,   r   r   r   r   rZ      s
   zCiscoLiveSearchIE._real_extract)rB   rC   rD   r[   r\   classmethodra   staticmethodrf   rv   rZ   __classcell__r   r   rd   r   r]   Z   s(    
r]   )rm   commonr   utilsr   r   r   r   r	   r
   r   rG   r]   r   r   r   r   <module>   s     
/