]> gitweb @ CieloNegro.org - youtube-dl.git/blob - youtube_dl/extractor/empflix.py
[generic] Do not download images as videos by accident
[youtube-dl.git] / youtube_dl / extractor / empflix.py
1 from __future__ import unicode_literals
2
3 import re
4
5 from .common import InfoExtractor
6 from ..utils import fix_xml_ampersands
7
8
9 class EmpflixIE(InfoExtractor):
10     _VALID_URL = r'^https?://www\.empflix\.com/videos/.*?-(?P<id>[0-9]+)\.html'
11     _TEST = {
12         'url': 'http://www.empflix.com/videos/Amateur-Finger-Fuck-33051.html',
13         'md5': 'b1bc15b6412d33902d6e5952035fcabc',
14         'info_dict': {
15             'id': '33051',
16             'ext': 'mp4',
17             'title': 'Amateur Finger Fuck',
18             'description': 'Amateur solo finger fucking.',
19             'age_limit': 18,
20         }
21     }
22
23     def _real_extract(self, url):
24         mobj = re.match(self._VALID_URL, url)
25         video_id = mobj.group('id')
26
27         webpage = self._download_webpage(url, video_id)
28         age_limit = self._rta_search(webpage)
29
30         video_title = self._html_search_regex(
31             r'name="title" value="(?P<title>[^"]*)"', webpage, 'title')
32         video_description = self._html_search_regex(
33             r'name="description" value="([^"]*)"', webpage, 'description', fatal=False)
34
35         cfg_url = self._html_search_regex(
36             r'flashvars\.config = escape\("([^"]+)"',
37             webpage, 'flashvars.config')
38
39         cfg_xml = self._download_xml(
40             cfg_url, video_id, note='Downloading metadata',
41             transform_source=fix_xml_ampersands)
42
43         formats = [
44             {
45                 'url': item.find('videoLink').text,
46                 'format_id': item.find('res').text,
47             } for item in cfg_xml.findall('./quality/item')
48         ]
49         thumbnail = cfg_xml.find('./startThumb').text
50
51         return {
52             'id': video_id,
53             'title': video_title,
54             'description': video_description,
55             'thumbnail': thumbnail,
56             'formats': formats,
57             'age_limit': age_limit,
58         }