a
    h $                     @   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p8|}|dpFi }|dpTi }||dpj|d|dp||d	|d
p|dt|dd}t|dd tpi }	g }
|	d}|r|
| j	||ddddd |	d}|r0| jd|dd d}d}|r|d| 7 }|

||t|d |
rT|
|d< t|	d|d< |S dD ]f}|| d }|svqX|d!krtd"n.|d#|d$kr|n| d%| | d& |  S td'd S )(Nzsetup\s*=\s*({.+});setupplayer_setupvideoformatted_metadatatitleZtitle_shortZdescription_longZdescription_short	thumbnailZbrightcove_thumbnailZvideo_publish_date)idr   descriptionr   	timestampc                 S   s   | d d S )NZembed_assetsZchorus )xr   r   N/mnt/pikpak/tmp/myenv/lib/python3.9/site-packages/yt_dlp/extractor/voxmedia.py<lambda>       z0VoxMediaVolumeIE._real_extract.<locals>.<lambda>hls_urlmp4Zm3u8_nativeZhlsF)Zm3u8_idfatalmp4_urlz	-(\d+)k\.Zbitratedefaulthttp-)	format_idurltbrformatsduration)youtube
brightcoveZ_idr&   z/Vox Brightcove embeds are currently unsupportedurl_transparentr%   :)_typer!   Zie_keyz Unable to find provider video id)	_match_id_download_webpage_parse_json_search_regexgetr   r   dictextendZ_extract_m3u8_formatsappendr   r   update
capitalize)selfr!   Zvideo_idwebpager
   r   
video_datar   infoZassetr#   r   r   r"   r    provider_video_typeprovider_video_idr   r   r   _real_extract   sf    




zVoxMediaVolumeIE._real_extractN)__name__
__module____qualname__
_VALID_URLr:   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-ofZj4mLW6x17VMr   z>Material world: how Google discovered what software is made ofz$md5:dfc17e7715e3b542d66e33a109861382Z20190710ZTheVergez	The Verge)r   extr   r   upload_dateuploader_iduploaderZYoutube)r!   	info_dictadd_iez_http://www.theverge.com/2014/10/21/7025853/google-nexus-6-hands-on-photos-video-android-phabletZ fd19aa0cf3a0eea515d4fd5c8c0e9d68ZGy8Md3Eky38z+The Nexus 6: hands-on with Google's phabletz$md5:d9f0216e5fb932dd2033d6db37ac3f1dZ20141021i FT)r   r@   r   r   rB   rA   rC   r   zsimilar to the previous test)r!   md5rD   rE   skipzMhttp://www.vox.com/2016/3/31/11336640/mississippi-lgbt-religious-freedom-billZ	22986359bzZMississippi's laws are so bad that its anti-LGBTQ law isn't needed to allow discriminationz$md5:fc1317922057de31cd74bce91eb1c66cZ20150915i@Ui  )r   r@   r   r   rA   r   r$   )r!   rD   rE   rG   z1http://www.vox.com/2016/3/24/11291692/robot-danceZ 83b3080489fb103941e549352d3e0977ZFcNHTJU1ufMz=How "the robot" became the greatest novelty dance of all timez$md5:b081c0d588b8b2085870cda55e6da176Z20160324Z	voxdotcomZ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   Z 721fededf2ab74ae4176c8c8cbfe092eZ p3cThlMjE61VDi_SD9JlIteSNPWVDBB9z*Buddy Hield vs Steph Curry (and the world)u>   Let’s dissect only the most important Final Four storylines.)r   r@   r   r   )rF   rD   Z bf0c5cc115636af028be1bab79217ea9Z BmbmVjMjE6esPHxdALGubTrouQ0jYLHjz,Chasing Cinderella 2016: Syracuse basketballz$md5:e02d56b026d51aa32c010676765a690d)r!   rD   ZplaylistrG   zVhttp://www.theguardian.com/world/2014/mar/11/obama-zach-galifianakis-between-two-fernsZ
18e820ec3fz@Between Two Ferns with Zach Galifianakis: President Barack Obama)r   r@   r   zInvalid URL)r!   rD   rG   c           
   
      s    |}tj ||d fdd	}g } jg ddd d}|r ||}t|trh|g}|D ]@}|	d}|	d}|rl|rl|
||||	d|	d	 ql jd
dd d}	|	r|
||	d t|dkr|d S  ||  S d S )Nc                    s4   ddd| |  }d||p"  |p. dS )Nz%sz"http://volume.vox-cdn.com/embed/%s)r%   volumer'   )r)   r!   r   r   )_og_search_title_og_search_description)r9   r8   r   r   Z	video_urlr4   r5   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   r9   r8   r   r   zdata-volume-uuid="([^"]+)"zvolume uuidrH   r   r   )NN)r*   urllibparseunquoter+   r-   r,   
isinstancer/   r.   r1   lenZplaylist_resultrI   rJ   )
r4   r!   Z
display_idrL   entriesZentries_datar6   r9   r8   Zvolume_uuidr   rK   r   r:      s6    




zVoxMediaIE._real_extractN)r;   r<   r=   r>   Z_EMBED_REGEXZ_TESTSZ_WEBPAGE_TESTSr:   r   r   r   r   r?   G   s   	
			W
r?   )urllib.parserM   commonr   utilsr   r   r   r   r	   r?   r   r   r   r   <module>   s   ;