X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=youtube_dl%2Fextractor%2Fxhamster.py;h=b4ad513a0d18ecbae558deceb6234efaa5ce5415;hb=c3124c3085e6a9a83ee31ace3a7d528a324c42da;hp=5374495f9b08f4d13fd7552fd612c19339b99e54;hpb=b8e1471d3afe2b0b26544cbcc8d4c351cb66eb63;p=youtube-dl diff --git a/youtube_dl/extractor/xhamster.py b/youtube_dl/extractor/xhamster.py index 5374495f9..b4ad513a0 100644 --- a/youtube_dl/extractor/xhamster.py +++ b/youtube_dl/extractor/xhamster.py @@ -13,12 +13,10 @@ from ..utils import ( class XHamsterIE(InfoExtractor): - """Information Extractor for xHamster""" - _VALID_URL = r'http://(?:www\.)?xhamster\.com/movies/(?P[0-9]+)/(?P.+?)\.html(?:\?.*)?' + _VALID_URL = r'(?Phttps?)://(?:.+?\.)?xhamster\.com/movies/(?P[0-9]+)/(?P.+?)\.html(?:\?.*)?' _TESTS = [ { 'url': 'http://xhamster.com/movies/1509445/femaleagent_shy_beauty_takes_the_bait.html', - 'md5': '8281348b8d3c53d39fffb377d24eac4e', 'info_dict': { 'id': '1509445', 'ext': 'mp4', @@ -31,7 +29,6 @@ class XHamsterIE(InfoExtractor): }, { 'url': 'http://xhamster.com/movies/2221348/britney_spears_sexy_booty.html?hd', - 'md5': '4cbd8d56708ecb4fb4124c23e4acb81a', 'info_dict': { 'id': '2221348', 'ext': 'mp4', @@ -41,10 +38,14 @@ class XHamsterIE(InfoExtractor): 'duration': 200, 'age_limit': 18, } - } + }, + { + 'url': 'https://xhamster.com/movies/2272726/amber_slayed_by_the_knight.html', + 'only_matching': True, + }, ] - def _real_extract(self,url): + def _real_extract(self, url): def extract_video_url(webpage): mp4 = re.search(r'', webpage) if mp4 is None: @@ -59,7 +60,8 @@ class XHamsterIE(InfoExtractor): video_id = mobj.group('id') seo = mobj.group('seo') - mrss_url = 'http://xhamster.com/movies/%s/%s.html' % (video_id, seo) + proto = mobj.group('proto') + mrss_url = '%s://xhamster.com/movies/%s/%s.html' % (proto, video_id, seo) webpage = self._download_webpage(mrss_url, video_id) title = self._html_search_regex(r'(?P<title>.+?) - xHamster\.com', webpage, 'title') @@ -69,17 +71,17 @@ class XHamsterIE(InfoExtractor): description = mobj.group(1) if mobj else None upload_date = self._html_search_regex(r'hint=\'(\d{4}-\d{2}-\d{2}) \d{2}:\d{2}:\d{2} [A-Z]{3,4}\'', - webpage, 'upload date', fatal=False) + webpage, 'upload date', fatal=False) if upload_date: upload_date = unified_strdate(upload_date) uploader_id = self._html_search_regex(r']+>(?P[^<]+)', - webpage, 'uploader id', default='anonymous') + webpage, 'uploader id', default='anonymous') thumbnail = self._html_search_regex(r'', webpage, 'thumbnail', fatal=False) duration = parse_duration(self._html_search_regex(r'Runtime: (\d+:\d+)', - webpage, 'duration', fatal=False)) + webpage, 'duration', fatal=False)) view_count = self._html_search_regex(r'Views: ([^<]+)', webpage, 'view count', fatal=False) if view_count: @@ -130,3 +132,36 @@ class XHamsterIE(InfoExtractor): 'age_limit': age_limit, 'formats': formats, } + + +class XHamsterEmbedIE(InfoExtractor): + _VALID_URL = r'https?://(?:www\.)?xhamster\.com/xembed\.php\?video=(?P\d+)' + _TEST = { + 'url': 'http://xhamster.com/xembed.php?video=3328539', + 'info_dict': { + 'id': '3328539', + 'ext': 'mp4', + 'title': 'Pen Masturbation', + 'upload_date': '20140728', + 'uploader_id': 'anonymous', + 'duration': 5, + 'age_limit': 18, + } + } + + @staticmethod + def _extract_urls(webpage): + return [url for _, url in re.findall( + r']+?src=(["\'])(?P(?:https?:)?//(?:www\.)?xhamster\.com/xembed\.php\?video=\d+)\1', + webpage)] + + def _real_extract(self, url): + video_id = self._match_id(url) + + webpage = self._download_webpage(url, video_id) + + video_url = self._search_regex( + r'href="(https?://xhamster\.com/movies/%s/[^"]+\.html[^"]*)"' % video_id, + webpage, 'xhamster url') + + return self.url_result(video_url, 'XHamster')