U
    $Pf                     @   sH   d dl mZ d dlZddlmZ ddlmZmZmZ G dd deZ	dS )	    )unicode_literalsN   )InfoExtractor   )get_element_by_idint_or_none
remove_endc                	   @   s2   e Zd ZdZdddddddd	d
dZdd ZdS )FoxgayIEzAhttps?://(?:www\.)?foxgay\.com/videos/(?:\S+-)?(?P<id>\d+)\.shtmlz6http://foxgay.com/videos/fuck-turkish-style-2582.shtmlZ 344558ccfea74d33b7adbce22e577f54Z2582Zmp4zFuck Turkish-stylez$md5:6ae2d9486921891efe89231ace13ffdf   zre:https?://.*\.jpg$)idexttitledescription	age_limit	thumbnail)urlmd5Z	info_dictc           
   	   C   s   |  |}| ||}t| d|dd}td|}| jjd | jd|ddd	}| j||d
didd}| | 	d|d|}dd t
|d |dtd D }	| |	 |||	||di dddS )Nz<title>([^<]+)</title>r   z - Foxgay.comZinf_titz.foxgay.comz)<iframe[^>]+src=([\'"])(?P<url>[^\'"]+)\1zvideo framer   )groupz
User-Agentzcurl/7.50.1zDownloading video frame)headersZnotezvideo_data\s*=\s*([^;]+);z
video datac                 S   s   g | ]\}}|t |d qS ))r   height)r   ).0source
resolution r   ?/tmp/pip-unpacked-wheel-7zdooeg3/youtube_dl/extractor/foxgay.py
<listcomp>0   s   z*FoxgayIE._real_extract.<locals>.<listcomp>sourcesZresolutionsZact_vidZthumbr
   )r   r   formatsr   r   r   )Z	_match_idZ_download_webpager   Z_html_search_regexr   Z_downloader	cookiejarclearZ_parse_jsonZ_search_regexzipget	itertoolsrepeatZ_sort_formats)
selfr   Zvideo_idZwebpager   r   Z
iframe_urliframeZ
video_datar   r   r   r   _real_extract   sX    
  
       
zFoxgayIE._real_extractN)__name__
__module____qualname__Z
_VALID_URLZ_TESTr&   r   r   r   r   r	      s   r	   )

__future__r   r"   commonr   utilsr   r   r   r	   r   r   r   r   <module>   s   