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