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