U
    g                     @   s\   d dl Z ddlmZ ddl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   )
clean_htmlget_element_by_classget_elements_by_classjoin_nonemptytraverse_objunified_timestampurljoinc                   @   s0   e Zd ZdZdddddddd	gZd
d ZdS )CamFMShowIEz4https?://(?:www\.)?camfm\.co\.uk/shows/(?P<id>[^/]+)   z&https://camfm.co.uk/shows/soul-mining/zsoul-miningz$md5:6a873091f92c936f23bdcce80f75e66azSoul MiningzITelling the stories of jazz, funk and soul from all corners of the world.)id	thumbnailtitledescription)Zplaylist_mincounturl	info_dictc                    sj     |} ||}d| fddtd|D td jd|ddd	 jd
|ddd	ttd|dS )NZplaylistc                    s   g | ]}  td |tqS )https://camfm.co.uk)Z
url_resultr   CamFMEpisodeIE).0iself :/tmp/pip-unpacked-wheel-q5ljy6pj/yt_dlp/extractor/camfm.py
<listcomp>#   s   z-CamFMShowIE._real_extract.<locals>.<listcomp>z-javascript:popup\('(/player/[^']+)', 'listen'r   z/<img[^>]+class="thumb-expand"[^>]+src="([^"]+)"r   Ffatalz<h1>([^<]+)</h1>r   zsmall-12 medium-8 cell)_typer   entriesr   r   r   )		_match_id_download_webpagerefindallr   _search_regex_html_search_regexr   r   )r   r   Zshow_idpager   r   r   _real_extract   s     


   zCamFMShowIE._real_extractN__name__
__module____qualname__Z
_VALID_URLZ_TESTSr(   r   r   r   r   r      s   r   c                   @   s<   e Zd ZdZdddddddd	d
ddgd	dgZdd ZdS )r   z5https?://(?:www\.)?camfm\.co\.uk/player/(?P<id>[^/]+)z https://camfm.co.uk/player/43336zIEpisode will expire - don't actually know when, but it will go eventuallyZ43336z2AITAA: Am I the Agony Aunt? - 19:00 Tue 16/05/2023Zmp3Z20230516z$md5:f165144f94927c0f1bfa2ee6e6ab7bbficdzAITAA: Am I the Agony Aunt?z$md5:5980a831360d0744c3764551be3d09c1ZEntertainment)	r   r   extZupload_dater   	timestampseriesr   
categories)r   skipr   c           	      C   s   |  |}| ||}| d||}td|}ttdd|}td|}| jd|ddd	}|t||d
dt	|dt
||ttdd|td| jd|ddd	td|dd	S )Nzhttps://audio.camfm.co.ukcaptionz<span[^<]+<[^<]+> zcard-sectionz>Aired at ([^<]+)<zair dateFr   z - )delim).formats.z<b>[^<]+</b><br[^>]+/>r   z:<div[^>]+class="cover-art"[^>]+style="[^"]+url\(\'([^\']+)r   labelT)	r   r   r5   r.   r/   r   r   r0   Zwas_live)r!   r"   Z_parse_html5_media_entriesr   r   r#   subr&   r   r	   r
   r   r%   r   )	r   r   Z
episode_idr'   Zaudiosr2   r/   Zcard_sectiondater   r   r   r(   >   s,    


  zCamFMEpisodeIE._real_extractNr)   r   r   r   r   r   ,   s   r   )r#   commonr   utilsr   r   r   r   r	   r
   r   r   r   r   r   r   r   <module>   s   $