1 from __future__ import unicode_literals
5 from .common import InfoExtractor
6 from ..utils import str_to_int
9 class MovieFapIE(InfoExtractor):
10 _VALID_URL = r'https?://(?:www\.)?moviefap\.com/videos/(?P<id>[0-9a-f]+)/(?P<name>[a-z-_]+)'
12 # normal, multi-format video
13 'url': 'http://www.moviefap.com/videos/be9867c9416c19f54a4a/experienced-milf-amazing-handjob.html',
14 'md5': '26624b4e2523051b550067d547615906',
16 'id': 'be9867c9416c19f54a4a',
18 'title': 'Experienced MILF Amazing Handjob',
19 'description': 'Experienced MILF giving an Amazing Handjob',
20 'thumbnail': 'http://img.moviefap.com/a16:9w990r/thumbs/be/322032-20l.jpg',
21 'uploader_id': 'darvinfred06',
22 'display_id': 'experienced-milf-amazing-handjob',
23 'categories': ['Amateur', 'Masturbation', 'Mature', 'Flashing']
26 # quirky single-format case where the extension is given as fid, but the video is really an flv
27 'url': 'http://www.moviefap.com/videos/e5da0d3edce5404418f5/jeune-couple-russe.html',
28 'md5': 'fa56683e291fc80635907168a743c9ad',
30 'id': 'e5da0d3edce5404418f5',
32 'title': 'Jeune Couple Russe',
33 'description': 'Amateur',
34 'thumbnail': 'http://pic.moviefap.com/thumbs/e5/949-18l.jpg',
35 'uploader_id': 'whiskeyjar',
36 'display_id': 'jeune-couple-russe',
37 'categories': ['Amateur', 'Teen']
42 def __get_thumbnail_data(xml):
45 Constructs a list of video thumbnails from timeline preview images.
46 :param xml: the information XML document to parse
49 timeline = xml.find('timeline')
51 # not all videos have the data - ah well
54 # get the required information from the XML
55 width = str_to_int(timeline.find('imageWidth').text)
56 height = str_to_int(timeline.find('imageHeight').text)
57 first = str_to_int(timeline.find('imageFirst').text)
58 last = str_to_int(timeline.find('imageLast').text)
59 pattern = timeline.find('imagePattern').text
61 # generate the list of thumbnail information dicts
63 for i in range(first, last + 1):
65 'url': pattern.replace('#', str(i)),
71 def _real_extract(self, url):
73 video_id = self._match_id(url)
74 webpage = self._download_webpage(url, video_id)
76 # find and retrieve the XML document detailing video download URLs
77 info_url = self._html_search_regex(r'flashvars\.config = escape\("(.+?)"', webpage, 'player parameters')
78 xml = self._download_xml(info_url, video_id)
82 'title': self._html_search_regex(r'<div id="view_title"><h1>(.*?)</h1>', webpage, 'title'),
83 'display_id': re.compile(self._VALID_URL).match(url).group('name'),
84 'thumbnails': self.__get_thumbnail_data(xml),
85 'thumbnail': xml.find('startThumb').text,
86 'description': self._html_search_regex(r'name="description" value="(.*?)"', webpage, 'description', fatal=False),
87 'uploader_id': self._html_search_regex(r'name="username" value="(.*?)"', webpage, 'uploader_id', fatal=False),
88 'view_count': str_to_int(self._html_search_regex(r'<br>Views <strong>([0-9]+)</strong>', webpage, 'view_count, fatal=False')),
89 'average_rating': float(self._html_search_regex(r'Current Rating<br> <strong>(.*?)</strong>', webpage, 'average_rating', fatal=False)),
90 'comment_count': str_to_int(self._html_search_regex(r'<span id="comCount">([0-9]+)</span>', webpage, 'comment_count', fatal=False)),
92 'webpage_url': self._html_search_regex(r'name="link" value="(.*?)"', webpage, 'webpage_url', fatal=False),
93 'categories': self._html_search_regex(r'</div>\s*(.*?)\s*<br>', webpage, 'categories', fatal=False).split(', ')
96 # find and add the format
97 if xml.find('videoConfig') is not None:
98 info['ext'] = xml.find('videoConfig').find('type').text
100 info['ext'] = 'flv' # guess...
102 # work out the video URL(s)
103 if xml.find('videoLink') is not None:
104 # single format available
105 info['url'] = xml.find('videoLink').text
107 # multiple formats available
110 # N.B. formats are already in ascending order of quality
111 for item in xml.find('quality').findall('item'):
112 info['formats'].append({
113 'url': item.find('videoLink').text,
114 'resolution': item.find('res').text # 480p etc.