X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=youtube_dl%2Fextractor%2Fsexykarma.py;h=e33483674439fb2fcfcdce60a9de6a6ca328dfdd;hb=b24d6336a797b99339c12a0aa1b431755e22e8cf;hp=629499e72356d66d6032a598af3304d39cfd2bb1;hpb=77c3c5c5ed79e5b9d07dc4246f940cbb3e1b8de4;p=youtube-dl diff --git a/youtube_dl/extractor/sexykarma.py b/youtube_dl/extractor/sexykarma.py index 629499e72..e33483674 100644 --- a/youtube_dl/extractor/sexykarma.py +++ b/youtube_dl/extractor/sexykarma.py @@ -1,77 +1,121 @@ # coding: utf-8 from __future__ import unicode_literals -from .common import InfoExtractor import re -import datetime + +from .common import InfoExtractor +from ..utils import ( + unified_strdate, + parse_duration, + int_or_none, +) + class SexyKarmaIE(InfoExtractor): - _VALID_URL = r'https?://(?:www\.)?sexykarma\.com/gonewild/video/.+\-(?P[a-zA-Z0-9\-]+)(.html)' + IE_DESC = 'Sexy Karma and Watch Indian Porn' + _VALID_URL = r'https?://(?:www\.)?(?:sexykarma\.com|watchindianporn\.net)/(?:[^/]+/)*video/(?P[^/]+)-(?P[a-zA-Z0-9]+)\.html' _TESTS = [{ 'url': 'http://www.sexykarma.com/gonewild/video/taking-a-quick-pee-yHI70cOyIHt.html', 'md5': 'b9798e7d1ef1765116a8f516c8091dbd', 'info_dict': { 'id': 'yHI70cOyIHt', + 'display_id': 'taking-a-quick-pee', 'ext': 'mp4', 'title': 'Taking a quick pee.', - 'uploader_id': 'wildginger7', 'thumbnail': 're:^https?://.*\.jpg$', - 'duration': int, + 'uploader': 'wildginger7', + 'upload_date': '20141008', + 'duration': 22, 'view_count': int, - 'upload_date': '20141007', + 'comment_count': int, + 'categories': list, + 'age_limit': 18, } }, { 'url': 'http://www.sexykarma.com/gonewild/video/pot-pixie-tribute-8Id6EZPbuHf.html', 'md5': 'dd216c68d29b49b12842b9babe762a5d', 'info_dict': { 'id': '8Id6EZPbuHf', + 'display_id': 'pot-pixie-tribute', 'ext': 'mp4', 'title': 'pot_pixie tribute', - 'uploader_id': 'banffite', 'thumbnail': 're:^https?://.*\.jpg$', - 'duration': int, - 'view_count': int, + 'uploader': 'banffite', 'upload_date': '20141013', + 'duration': 16, + 'view_count': int, + 'comment_count': int, + 'categories': list, + 'age_limit': 18, + } + }, { + 'url': 'http://www.watchindianporn.net/video/desi-dancer-namrata-stripping-completely-nude-and-dancing-on-a-hot-number-dW2mtctxJfs.html', + 'md5': '9afb80675550406ed9a63ac2819ef69d', + 'info_dict': { + 'id': 'dW2mtctxJfs', + 'display_id': 'desi-dancer-namrata-stripping-completely-nude-and-dancing-on-a-hot-number', + 'ext': 'mp4', + 'title': 'Desi dancer namrata stripping completely nude and dancing on a hot number', + 'thumbnail': 're:^https?://.*\.jpg$', + 'uploader': 'Don', + 'upload_date': '20140213', + 'duration': 83, + 'view_count': int, + 'comment_count': int, + 'categories': list, + 'age_limit': 18, } }] def _real_extract(self, url): - video_id = self._match_id(url) + mobj = re.match(self._VALID_URL, url) + video_id = mobj.group('id') + display_id = mobj.group('display_id') + + webpage = self._download_webpage(url, display_id) + + video_url = self._html_search_regex( + r"url: escape\('([^']+)'\)", webpage, 'url') - webpage = self._download_webpage(url, video_id) - - title = self._html_search_regex(r'

(.*?)', webpage, 'title') - uploader_id = self._html_search_regex(r'class="aupa">\n*(.*?)', webpage, 'uploader') - url = self._html_search_regex(r'

[\n\s]*Time: [\n\s]*(.+)\n*', webpage, 'duration') - duration = self._to_seconds(str_duration) + title = self._html_search_regex( + r'

(.*?)', + webpage, 'title') + thumbnail = self._html_search_regex( + r'[\n\s]*Views: [\n\s]*(.+)', webpage, 'view_count') - view_count = int(str_views) - # print view_count + uploader = self._html_search_regex( + r'class="aupa">\s*(.*?)', + webpage, 'uploader') + upload_date = unified_strdate(self._html_search_regex( + r'Added: (.+?)', webpage, 'upload date', fatal=False)) - date = self._html_search_regex(r'class="aup">Added: (.*?)', webpage, 'date') - d = datetime.datetime.strptime(date, '%B %d, %Y') - upload_date = d.strftime('%Y%m%d') + duration = parse_duration(self._search_regex( + r'Time:\s*\s*\s*(.+?)\s*', + webpage, 'duration', fatal=False)) - categories = re.findall(r'http://www.sexykarma.com/gonewild/search/video/(?:.+?)">(.*?)', webpage) + view_count = int_or_none(self._search_regex( + r'Views:\s*\s*\s*(\d+)\s*', + webpage, 'view count', fatal=False)) + comment_count = int_or_none(self._search_regex( + r'Comments:\s*\s*\s*(\d+)\s*', + webpage, 'comment count', fatal=False)) + + categories = re.findall( + r'([^<]+)', + webpage) return { 'id': video_id, + 'display_id': display_id, + 'url': video_url, 'title': title, - 'uploader_id': uploader_id, - 'url': url, 'thumbnail': thumbnail, + 'uploader': uploader, + 'upload_date': upload_date, 'duration': duration, 'view_count': view_count, - 'upload_date': upload_date, + 'comment_count': comment_count, 'categories': categories, + 'age_limit': 18, } - - def _to_seconds(self, timestr): - seconds= 0 - for part in timestr.split(':'): - seconds= seconds*60 + int(part) - return seconds