U
    g%                     @   sX   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dS )
    N   )InfoExtractor   )extract_attributesget_elements_by_class'get_elements_text_and_html_by_attributeint_or_noneparse_durationtraverse_objc                   @   sh   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	igdddidgZdd Zd S )!WordpressPlaylistEmbedIEFzwordpress:playlistzRhttps://xlino.com/wordpress-playlist-shortcode-with-external-audio-or-video-files/z?wordpress-playlist-shortcode-with-external-audio-or-video-filesu`   WordPress: Playlist shortcode with external audio or video files – Birgir Erlendsson (birgire)r   )idtitle	age_limit   )url	info_dictplaylist_countzVhttps://pianoadventures.com/products/piano-adventures-level-1-lesson-book-enhanced-cd/z>piano-adventures-level-1-lesson-book-enhanced-cd-wp-playlist-1Wordpress PlaylistzOhttps://pianoadventures.com/wp-content/uploads/sites/13/2022/01/CD1002cover.jpg)r   r   	thumbnailr   r   z	CD1002-21mp3z21 Half-Time Showz_https://pianoadventures.com/wp-content/plugins/media-library-assistant/images/crystal/audio.pngz2Piano Adventures Level 1 Lesson Book (2nd Edition)Z	Classicalg     H@zNancy and Randall Faberz$md5:a9f8e9aeabbd2912bc13cc0fab1a4ce8)	r   extr   r   albumgenredurationartistdescription   skip_downloadTr   r   Zplaylistr   paramsc                 #   s   t td|D ]l\}} j| |ddddp2i }|s:q fddt|dtd	D } | |d
|d   dV  qd S )Nzwp-playlist-scriptFT )fatalZignore_extraZerrnotec                    sz   g | ]r}  |d  |d|d t|dt|dt|dt|dtt|d|dtt|dtt|d	d
qS )srcr   )Zthumbr"   )metar   )r#   r   )r#   r   )r#   Zlength_formattedr   )
dimensionsoriginalheight)r$   r%   width)r   r   r   r   r   r   r   r   r   r&   r'   )_generic_idgetr
   r	   r   ).0trackself >/tmp/pip-unpacked-wheel-q5ljy6pj/yt_dlp/extractor/wordpress.py
<listcomp><   s   zBWordpressPlaylistEmbedIE._extract_from_webpage.<locals>.<listcomp>)Ztracks.)Zexpected_typez-wp-playlist-r   r   )	enumerater   Z_parse_jsonr(   r
   dictZplaylist_result)r-   r   webpageijZplaylist_jsonentriesr.   r,   r/   _extract_from_webpage5   s    
z.WordpressPlaylistEmbedIE._extract_from_webpageN)__name__
__module____qualname__
_VALID_URLIE_NAME_WEBPAGE_TESTSr7   r.   r.   r.   r/   r      s@   #r   c                   @   s|   e Zd ZdZdZddddddd	d
dddddigdddidddddddddddddeeddd d!dgZd"d# Zd$S )%WordpressMiniAudioPlayerEmbedIEFzwordpress:mb.miniAudioPlayerz`https://news.samsung.com/global/over-the-horizon-the-evolution-of-the-samsung-galaxy-brand-soundz@over-the-horizon-the-evolution-of-the-samsung-galaxy-brand-soundzAOver the Horizon: The Evolution of the Samsung Galaxy Brand Soundr   zghttps://img.global.news.samsung.com/global/wp-content/uploads/2015/04/OTH_Main_Title-e1429612467870.jpgz$md5:bc3dd738d1f11d9232e94e6629983bf7)r   r   r   r   r   r   Zover_the_horizon_2013r   zOver the Horizon 2013zUhttp://news.samsung.com/global/wp-content/uploads/ringtones/over_the_horizon_2013.mp3)r   r   r   r   r   r   Tr   zGhttps://www.booksontape.com/collections/audiobooks-with-teacher-guides/zaudiobooks-with-teacher-guidesz.Audiobooks with Teacher Guides | Books on TapezLhttps://www.booksontape.com/wp-content/uploads/2016/09/bot-logo-1200x630.jpg)r   r   r   r      )r   r   Zplaylist_mincountz$https://www.estudiords.com.br/temas/ZtemaszTemas VariadoszGhttps://www.estudiords.com.br/wp-content/uploads/2021/03/LOGO-TEMAS.pngz$md5:ab24d6a7ed0312ad2d466e721679f5a0)r   r   r   	timestampZupload_dater   r      c           	      #   s   | j d|dd d}|sd S td|}|s.d S tddd| d|d	d
d}|D ]V\}}t| t fddtd|D rqR d }| ||p| ||dV  qRd S )NzJfunction\s*initializeMiniAudioPlayer\(\){[^}]+jQuery([^;]+)\.mb_miniPlayerzmb player params)defaultz#a\[href\s*\*=\s*\'\.([a-zA-Z\d]+)\'hrefz(?:[^\"\']+\.(?:|z))Fa)Zescape_valuetagc                 3   s    | ]}|  d pdkV  qdS )classr    N)r)   )r*   cattrsr.   r/   	<genexpr>   s     zHWordpressMiniAudioPlayerEmbedIE._extract_from_webpage.<locals>.<genexpr>z\.not\("\.([^"]+))r   r   r   )	Z_search_regexrefindallr   joinr   anyr(   Z_generic_title)	r-   r   r3   Zmb_player_paramsZ	file_exts
candidatesr   htmlrC   r.   rI   r/   r7      s6          z5WordpressMiniAudioPlayerEmbedIE._extract_from_webpageN)	r8   r9   r:   r;   r<   floatstrr=   r7   r.   r.   r.   r/   r>   L   sP   	.r>   )rL   commonr   utilsr   r   r   r   r	   r
   r   r>   r.   r.   r.   r/   <module>   s    =