X-Git-Url: http://git.cielonegro.org/gitweb.cgi?a=blobdiff_plain;f=youtube_dl%2Fextractor%2Fmoviefap.py;h=9de052a9987f5583018839228121a707dc265b01;hb=1a5fd4eebc2717b5173df50d65007f90cb05ee30;hp=880ea224764d93fa98c5de3a3e5196115f372b6b;hpb=802d74aa6ba2613f95d19c3be6c2480b9a2ebe5b;p=youtube-dl.git diff --git a/youtube_dl/extractor/moviefap.py b/youtube_dl/extractor/moviefap.py index 880ea2247..9de052a99 100644 --- a/youtube_dl/extractor/moviefap.py +++ b/youtube_dl/extractor/moviefap.py @@ -3,24 +3,17 @@ from __future__ import unicode_literals import re from .common import InfoExtractor -from ..utils import str_to_int +from ..utils import ( + xpath_text, + str_to_int +) +from ..compat import compat_str class MovieFapIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?moviefap\.com/videos/(?P[0-9a-f]+)/(?P[a-z-_]+)' _TESTS = [{ - 'url': 'http://www.moviefap.com/videos/e5da0d3edce5404418f5/jeune-couple-russe.html', - 'md5': 'fa56683e291fc80635907168a743c9ad', - 'info_dict': { - 'id': 'e5da0d3edce5404418f5', - 'ext': 'flv', - 'title': 'Jeune Couple Russe', - 'description': 'Amateur', - 'thumbnail': 'http://pic.moviefap.com/thumbs/e5/949-18l.jpg', - 'uploader_id': 'whiskeyjar', - 'display_id': 'jeune-couple-russe' - } - }, { + # normal, multi-format video 'url': 'http://www.moviefap.com/videos/be9867c9416c19f54a4a/experienced-milf-amazing-handjob.html', 'md5': '26624b4e2523051b550067d547615906', 'info_dict': { @@ -30,7 +23,22 @@ class MovieFapIE(InfoExtractor): 'description': 'Experienced MILF giving an Amazing Handjob', 'thumbnail': 'http://img.moviefap.com/a16:9w990r/thumbs/be/322032-20l.jpg', 'uploader_id': 'darvinfred06', - 'display_id': 'experienced-milf-amazing-handjob' + 'display_id': 'experienced-milf-amazing-handjob', + 'categories': ['Amateur', 'Masturbation', 'Mature', 'Flashing'] + } + }, { + # quirky single-format case where the extension is given as fid, but the video is really an flv + 'url': 'http://www.moviefap.com/videos/e5da0d3edce5404418f5/jeune-couple-russe.html', + 'md5': 'fa56683e291fc80635907168a743c9ad', + 'info_dict': { + 'id': 'e5da0d3edce5404418f5', + 'ext': 'flv', + 'title': 'Jeune Couple Russe', + 'description': 'Amateur', + 'thumbnail': 'http://pic.moviefap.com/thumbs/e5/949-18l.jpg', + 'uploader_id': 'whiskeyjar', + 'display_id': 'jeune-couple-russe', + 'categories': ['Amateur', 'Teen'] } }] @@ -58,7 +66,7 @@ class MovieFapIE(InfoExtractor): thumbnails = [] for i in range(first, last + 1): thumbnails.append({ - 'url': pattern.replace('#', str(i)), + 'url': pattern.replace('#', compat_str(i)), 'width': width, 'height': height }) @@ -66,33 +74,36 @@ class MovieFapIE(InfoExtractor): def _real_extract(self, url): - # find the video ID video_id = self._match_id(url) - - # retrieve the page HTML webpage = self._download_webpage(url, video_id) - # find the URL of the XML document detailing video download URLs - info_url = self._html_search_regex(r'flashvars\.config = escape\("(.+?)"', webpage, 'player parameters') - - # download that XML + # find and retrieve the XML document detailing video download URLs + info_url = self._html_search_regex( \ + r'flashvars\.config = escape\("(.+?)"', webpage, 'player parameters') xml = self._download_xml(info_url, video_id) - # create dictionary of properties we know so far, or can find easily info = { 'id': video_id, - 'title': self._html_search_regex(r'

(.*?)

', webpage, 'title'), + 'title': self._html_search_regex( \ + r'

(.*?)

', webpage, 'title'), 'display_id': re.compile(self._VALID_URL).match(url).group('name'), 'thumbnails': self.__get_thumbnail_data(xml), - 'thumbnail': xml.find('startThumb').text, - 'description': self._html_search_regex(r'name="description" value="(.*?)"', webpage, 'description'), - 'uploader_id': self._html_search_regex(r'name="username" value="(.*?)"', webpage, 'uploader_id'), - 'view_count': str_to_int(self._html_search_regex(r'
Views ([0-9]+)', webpage, 'view_count')), - 'average_rating': float(self._html_search_regex(r'Current Rating
(.*?)', webpage, 'average_rating')), - 'comment_count': str_to_int(self._html_search_regex(r'([0-9]+)', webpage, 'comment_count')), + 'thumbnail': xpath_text(xml, 'startThumb', 'thumbnail'), + 'description': self._html_search_regex( \ + r'name="description" value="(.*?)"', webpage, 'description', fatal=False), + 'uploader_id': self._html_search_regex( \ + r'name="username" value="(.*?)"', webpage, 'uploader_id', fatal=False), + 'view_count': str_to_int(self._html_search_regex( \ + r'
Views ([0-9]+)', webpage, 'view_count, fatal=False')), + 'average_rating': float(self._html_search_regex( \ + r'Current Rating
(.*?)', webpage, 'average_rating', fatal=False)), + 'comment_count': str_to_int(self._html_search_regex( \ + r'([0-9]+)', webpage, 'comment_count', fatal=False)), 'age_limit': 18, - 'webpage_url': self._html_search_regex(r'name="link" value="(.*?)"', webpage, 'webpage_url'), - 'categories': self._html_search_regex(r'
\s*(.*?)\s*
', webpage, 'categories').split(', ') + 'webpage_url': self._html_search_regex( \ + r'name="link" value="(.*?)"', webpage, 'webpage_url', fatal=False), + 'categories': self._html_search_regex( \ + r'
\s*(.*?)\s*
', webpage, 'categories', fatal=False).split(', ') } # find and add the format @@ -104,16 +115,19 @@ class MovieFapIE(InfoExtractor): # work out the video URL(s) if xml.find('videoLink') is not None: # single format available - info['url'] = xml.find('videoLink').text + info['url'] = xpath_text(xml, 'videoLink', 'url', True) else: # multiple formats available info['formats'] = [] - # N.B. formats are already in ascending order of quality for item in xml.find('quality').findall('item'): + resolution = xpath_text(item, 'res', 'resolution', True) # 480p etc. info['formats'].append({ - 'url': item.find('videoLink').text, - 'resolution': item.find('res').text # 480p etc. + 'url': xpath_text(item, 'videoLink', 'url', True), + 'resolution': resolution, + 'height': int(re.findall(r'\d+', resolution)[0]) }) + self._sort_formats(info['formats']) + return info