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 attrs = {attr: str_to_int(timeline.find(attr).text)
52 for attr in ['imageWidth', 'imageHeight', 'imageFirst', 'imageLast']}
53 pattern = timeline.find('imagePattern').text
55 # generate the list of thumbnail information dicts
57 for i in range(attrs['imageFirst'], attrs['imageLast'] + 1):
59 'url': pattern.replace('#', str(i)),
60 'width': attrs['imageWidth'],
61 'height': attrs['imageHeight']
65 def _real_extract(self, url):
68 video_id = self._match_id(url)
70 # retrieve the page HTML
71 webpage = self._download_webpage(url, video_id)
73 # find the URL of the XML document detailing video download URLs
74 info_url = self._html_search_regex(r'flashvars\.config = escape\("(.+?)"', webpage, 'player parameters')
77 xml = self._download_xml(info_url, video_id)
79 # create dictionary of properties we know so far, or can find easily
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'),
87 'uploader_id': self._html_search_regex(r'name="username" value="(.*?)"', webpage, 'uploader_id'),
88 'view_count': str_to_int(self._html_search_regex(r'<br>Views <strong>([0-9]+)</strong>', webpage, 'view_count')),
89 'average_rating': float(self._html_search_regex(r'Current Rating<br> <strong>(.*?)</strong>', webpage, 'average_rating')),
90 'comment_count': str_to_int(self._html_search_regex(r'<span id="comCount">([0-9]+)</span>', webpage, 'comment_count')),
92 'webpage_url': self._html_search_regex(r'name="link" value="(.*?)"', webpage, 'webpage_url'),
93 'categories': self._html_search_regex(r'</div>\s*(.*?)\s*<br>', webpage, 'categories').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.