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 'url': 'http://www.moviefap.com/videos/e5da0d3edce5404418f5/jeune-couple-russe.html',
13 'md5': 'fa56683e291fc80635907168a743c9ad',
15 'id': 'e5da0d3edce5404418f5',
17 'title': 'Jeune Couple Russe',
18 'description': 'Amateur',
19 'thumbnail': 'http://pic.moviefap.com/thumbs/e5/949-18l.jpg',
20 'uploader_id': 'whiskeyjar',
21 'display_id': 'jeune-couple-russe'
24 'url': 'http://www.moviefap.com/videos/3080837f6712355015c2/busty-british-blonde-takes-backdoor-in-fake-taxi.html',
25 'md5': 'bedef72cb23d27a20755fc430a6d7a0e',
27 'id': '3080837f6712355015c2',
29 'title': 'Busty British blonde takes backdoor in fake taxi',
30 'description': 'Big boobs British blonde flashing in fake taxi then giving titsjob and rimjob in the back seat before getting big cock up her tight ass',
31 'thumbnail': 'http://img.moviefap.com/a16:9w990r/thumbs/30/322021-18l.jpg',
32 'uploader_id': 'momcikoper',
33 'display_id': 'busty-british-blonde-takes-backdoor-in-fake-taxi'
38 def __get_thumbnail_data(xml):
41 Constructs a list of video thumbnails from timeline preview images.
42 :param xml: the information XML document to parse
45 timeline = xml.find('timeline')
47 # not all videos have the data - ah well
50 # get the required information from the XML
51 width = str_to_int(timeline.find('imageWidth').text)
52 height = str_to_int(timeline.find('imageHeight').text)
53 first = str_to_int(timeline.find('imageFirst').text)
54 last = str_to_int(timeline.find('imageLast').text)
55 pattern = timeline.find('imagePattern').text
57 # generate the list of thumbnail information dicts
59 for i in range(first, last + 1):
61 'url': pattern.replace('#', str(i)),
67 def _real_extract(self, url):
70 video_id = self._match_id(url)
72 # retrieve the page HTML
73 webpage = self._download_webpage(url, video_id)
75 # find the URL of the XML document detailing video download URLs
76 info_url = self._html_search_regex(r'flashvars\.config = escape\("(.+?)"', webpage, 'player parameters')
79 xml = self._download_xml(info_url, video_id)
81 # create dictionary of properties we know so far, or can find easily
84 'title': self._html_search_regex(r'<div id="view_title"><h1>(.*?)</h1>', webpage, 'title'),
85 'display_id': re.compile(self._VALID_URL).match(url).group('name'),
86 'thumbnails': self.__get_thumbnail_data(xml),
87 'thumbnail': xml.find('startThumb').text,
88 'description': self._html_search_regex(r'name="description" value="(.*?)"', webpage, 'description'),
89 'uploader_id': self._html_search_regex(r'name="username" value="(.*?)"', webpage, 'uploader_id'),
90 'view_count': str_to_int(self._html_search_regex(r'<br>Views <strong>([0-9]+)</strong>', webpage, 'view_count')),
91 'average_rating': float(self._html_search_regex(r'Current Rating<br> <strong>(.*?)</strong>', webpage, 'average_rating')),
92 'comment_count': str_to_int(self._html_search_regex(r'<span id="comCount">([0-9]+)</span>', webpage, 'comment_count')),
94 'webpage_url': self._html_search_regex(r'name="link" value="(.*?)"', webpage, 'webpage_url'),
95 'categories': self._html_search_regex(r'</div>\s*(.*?)\s*<br>', webpage, 'categories').split(', ')
98 # find and add the format
99 if xml.find('videoConfig') is not None:
100 info['ext'] = xml.find('videoConfig').find('type').text
102 info['ext'] = 'flv' # guess...
104 # work out the video URL(s)
105 if xml.find('videoLink') is not None:
106 # single format available
107 info['url'] = xml.find('videoLink').text
109 # multiple formats available
112 # N.B. formats are already in ascending order of quality
113 for item in xml.find('quality').findall('item'):
114 info['formats'].append({
115 'url': item.find('videoLink').text,
116 'resolution': item.find('res').text # 480p etc.