o
    i $                     @   sP   d dl ZddlmZ ddlmZmZmZmZ G dd deZ	G dd	 d	eZ
dS )
    N   )InfoExtractor   )ExtractorErrorint_or_nonetry_getunified_timestampc                   @   s   e Zd ZdZdd ZdS )VoxMediaVolumeIEz7https?://volume\.vox-cdn\.com/embed/(?P<id>[0-9a-f]{9})c              
   C   s  |  |}| ||}| | d|d|}|dp|}|dp#i }|dp*i }||dp5|d|dp>|d	|d
pG|dt|dd}t|dd tpYi }	g }
|	d}|rq|
| j	||ddddd |	d}|r| jd|dd d}d}|r|d| 7 }|

||t|d |
r|
|d< t|	d|d< |S dD ].}|| d }|sq|d!krtd"|d#|d$kr|n| d%| | d& |  S td')(Nzsetup\s*=\s*({.+});setupplayer_setupvideoformatted_metadatatitletitle_shortdescription_longdescription_short	thumbnailbrightcove_thumbnailvideo_publish_date)idr   descriptionr   	timestampc                 S   s   | d d S )Nembed_assetschorus )xr   r   M/home/ubuntu/.local/lib/python3.10/site-packages/yt_dlp/extractor/voxmedia.py<lambda>   s    z0VoxMediaVolumeIE._real_extract.<locals>.<lambda>hls_urlmp4m3u8_nativehlsF)m3u8_idfatalmp4_urlz	-(\d+)k\.bitratedefaulthttp-)	format_idurltbrformatsduration)youtube
brightcove_idr0   z/Vox Brightcove embeds are currently unsupportedurl_transparentr/   :)_typer+   ie_keyz Unable to find provider video id)	_match_id_download_webpage_parse_json_search_regexgetr   r   dictextend_extract_m3u8_formatsappendr   r   update
capitalize)selfr+   video_idwebpager
   r   
video_datar   infoassetr-   r   r$   r,   r*   provider_video_typeprovider_video_idr   r   r   _real_extract   sf   


zVoxMediaVolumeIE._real_extractN)__name__
__module____qualname__
_VALID_URLrI   r   r   r   r   r	      s    r	   c                   @   s   e Zd ZdZdgZddddddd	d
ddgdddddddd	dd
dddgddddddddddddgdd d!d"d#dd$d%d&d'd(ddgd)dd*d+d,d-d.d/d0dd1d2d3d4d5d6dd7d8d3d4gd)d9gZd:d;dd<d=d>d?gZd@dA ZdBS )C
VoxMediaIEzhttps?://(?:www\.)?(?:(?:theverge|vox|sbnation|eater|polygon|curbed|racked|funnyordie)\.com|recode\.net)/(?:[^/]+/)*(?P<id>[^/?]+)zJ<iframe[^>]+?src="(?P<url>https?://(?:www\.)?funnyordie\.com/embed/[^"]+)"zghttp://www.theverge.com/2014/6/27/5849272/material-world-how-google-discovered-what-software-is-made-ofj4mLW6x17VMr   z>Material world: how Google discovered what software is made ofz$md5:dfc17e7715e3b542d66e33a10986138220190710TheVergez	The Verge)r   extr   r   upload_dateuploader_iduploaderYoutube)r+   	info_dictadd_iez_http://www.theverge.com/2014/10/21/7025853/google-nexus-6-hands-on-photos-video-android-phablet fd19aa0cf3a0eea515d4fd5c8c0e9d68Gy8Md3Eky38z+The Nexus 6: hands-on with Google's phabletz$md5:d9f0216e5fb932dd2033d6db37ac3f1d20141021i FT)r   rR   r   r   rT   rS   rU   r   zsimilar to the previous test)r+   md5rW   rX   skipzMhttp://www.vox.com/2016/3/31/11336640/mississippi-lgbt-religious-freedom-bill	22986359bzZMississippi's laws are so bad that its anti-LGBTQ law isn't needed to allow discriminationz$md5:fc1317922057de31cd74bce91eb1c66c20150915i@Ui  )r   rR   r   r   rS   r   r.   )r+   rW   rX   r]   z1http://www.vox.com/2016/3/24/11291692/robot-dance 83b3080489fb103941e549352d3e0977FcNHTJU1ufMz=How "the robot" became the greatest novelty dance of all timez$md5:b081c0d588b8b2085870cda55e6da17620160324	voxdotcomVoxzPage no longer contain videoszhttp://www.sbnation.com/college-football-recruiting/2015/2/3/7970291/national-signing-day-rationalizations-itll-be-ok-itll-be-okz;national-signing-day-rationalizations-itll-be-ok-itll-be-okz625 lies you will tell yourself on National Signing DayzaIt's the most self-delusional time of the year, and everyone's gonna tell the same lies together!)r   r   r    721fededf2ab74ae4176c8c8cbfe092e p3cThlMjE61VDi_SD9JlIteSNPWVDBB9z*Buddy Hield vs Steph Curry (and the world)u>   Let’s dissect only the most important Final Four storylines.)r   rR   r   r   )r\   rW    bf0c5cc115636af028be1bab79217ea9 BmbmVjMjE6esPHxdALGubTrouQ0jYLHjz,Chasing Cinderella 2016: Syracuse basketballz$md5:e02d56b026d51aa32c010676765a690d)r+   rW   playlistr]   zVhttp://www.theguardian.com/world/2014/mar/11/obama-zach-galifianakis-between-two-ferns
18e820ec3fz@Between Two Ferns with Zach Galifianakis: President Barack Obama)r   rR   r   zInvalid URL)r+   rW   r]   c           
   
      s    |}tj ||d fdd	}g } jg ddd d}|rW ||}t|tr4|g}|D ] }|	d}|	d}|rV|rV|
||||	d|	d	 q6 jd
dd d}	|	rj|
||	d t|dkrt|d S  ||  S )Nc                    s4   ddd| |  }d||p  |p dS )Nz%sz"http://volume.vox-cdn.com/embed/%s)r/   volumer2   )r4   r+   r   r   )_og_search_title_og_search_description)rH   rG   r   r   	video_urlrA   rC   r   r   create_entry   s   z.VoxMediaIE._real_extract.<locals>.create_entry)z-Chorus\.VideoContext\.addVideo\((\[{.+}\])\);zvar\s+entry\s*=\s*({.+});z*SBN\.VideoLinkset\.entryGroup\(\s*(\[.+\])z
video datar&   rH   rG   r   r   zdata-volume-uuid="([^"]+)"zvolume uuidrk   r   r   )NN)r6   urllibparseunquoter7   r9   r8   
isinstancer;   r:   r>   lenplaylist_resultrl   rm   )
rA   r+   
display_idrp   entriesentries_datarD   rH   rG   volume_uuidr   ro   r   rI      s8   




zVoxMediaIE._real_extractN)rJ   rK   rL   rM   _EMBED_REGEX_TESTS_WEBPAGE_TESTSrI   r   r   r   r   rN   G   s    	
			W
rN   )urllib.parserq   commonr   utilsr   r   r   r   r	   rN   r   r   r   r   <module>   s
    ;