]>
Commit | Line | Data |
---|---|---|
b92c5486 ZF |
1 | from __future__ import unicode_literals |
2 | ||
e78a5428 YCH |
3 | import itertools |
4 | ||
b92c5486 | 5 | from .common import InfoExtractor |
e78a5428 YCH |
6 | from ..utils import ( |
7 | get_element_by_id, | |
cc69a3de | 8 | int_or_none, |
e78a5428 YCH |
9 | remove_end, |
10 | ) | |
b92c5486 ZF |
11 | |
12 | ||
13 | class FoxgayIE(InfoExtractor): | |
5886b38d | 14 | _VALID_URL = r'https?://(?:www\.)?foxgay\.com/videos/(?:\S+-)?(?P<id>\d+)\.shtml' |
b92c5486 ZF |
15 | _TEST = { |
16 | 'url': 'http://foxgay.com/videos/fuck-turkish-style-2582.shtml', | |
e78a5428 | 17 | 'md5': '344558ccfea74d33b7adbce22e577f54', |
b92c5486 ZF |
18 | 'info_dict': { |
19 | 'id': '2582', | |
20 | 'ext': 'mp4', | |
e78a5428 YCH |
21 | 'title': 'Fuck Turkish-style', |
22 | 'description': 'md5:6ae2d9486921891efe89231ace13ffdf', | |
b92c5486 | 23 | 'age_limit': 18, |
ec85ded8 | 24 | 'thumbnail': r're:https?://.*\.jpg$', |
b92c5486 ZF |
25 | }, |
26 | } | |
27 | ||
28 | def _real_extract(self, url): | |
29 | video_id = self._match_id(url) | |
b92c5486 | 30 | webpage = self._download_webpage(url, video_id) |
191cc41b | 31 | |
e78a5428 YCH |
32 | title = remove_end(self._html_search_regex( |
33 | r'<title>([^<]+)</title>', webpage, 'title'), ' - Foxgay.com') | |
34 | description = get_element_by_id('inf_tit', webpage) | |
b92c5486 | 35 | |
e78a5428 YCH |
36 | # The default user-agent with foxgay cookies leads to pages without videos |
37 | self._downloader.cookiejar.clear('.foxgay.com') | |
b92c5486 | 38 | # Find the URL for the iFrame which contains the actual video. |
e78a5428 YCH |
39 | iframe_url = self._html_search_regex( |
40 | r'<iframe[^>]+src=([\'"])(?P<url>[^\'"]+)\1', webpage, | |
41 | 'video frame', group='url') | |
b92c5486 | 42 | iframe = self._download_webpage( |
e78a5428 YCH |
43 | iframe_url, video_id, headers={'User-Agent': 'curl/7.50.1'}, |
44 | note='Downloading video frame') | |
45 | video_data = self._parse_json(self._search_regex( | |
46 | r'video_data\s*=\s*([^;]+);', iframe, 'video data'), video_id) | |
47 | ||
48 | formats = [{ | |
49 | 'url': source, | |
cc69a3de | 50 | 'height': int_or_none(resolution), |
e78a5428 YCH |
51 | } for source, resolution in zip( |
52 | video_data['sources'], video_data.get('resolutions', itertools.repeat(None)))] | |
53 | ||
54 | self._sort_formats(formats) | |
b92c5486 ZF |
55 | |
56 | return { | |
57 | 'id': video_id, | |
58 | 'title': title, | |
e78a5428 | 59 | 'formats': formats, |
b92c5486 | 60 | 'description': description, |
e78a5428 | 61 | 'thumbnail': video_data.get('act_vid', {}).get('thumb'), |
b92c5486 ZF |
62 | 'age_limit': 18, |
63 | } |