2 from __future__ import unicode_literals
4 from .common import InfoExtractor
8 class SexyKarmaIE(InfoExtractor):
9 _VALID_URL = r'https?://(?:www\.)?sexykarma\.com/gonewild/video/.+\-(?P<id>[a-zA-Z0-9\-]+)(.html)'
11 'url': 'http://www.sexykarma.com/gonewild/video/taking-a-quick-pee-yHI70cOyIHt.html',
12 'md5': 'b9798e7d1ef1765116a8f516c8091dbd',
16 'title': 'Taking a quick pee.',
17 'uploader_id': 'wildginger7',
18 'thumbnail': 're:^https?://.*\.jpg$',
21 'upload_date': '20141007',
24 'url': 'http://www.sexykarma.com/gonewild/video/pot-pixie-tribute-8Id6EZPbuHf.html',
25 'md5': 'dd216c68d29b49b12842b9babe762a5d',
29 'title': 'pot_pixie tribute',
30 'uploader_id': 'banffite',
31 'thumbnail': 're:^https?://.*\.jpg$',
34 'upload_date': '20141013',
38 def _real_extract(self, url):
39 video_id = self._match_id(url)
41 webpage = self._download_webpage(url, video_id)
43 title = self._html_search_regex(r'<h2 class="he2"><span>(.*?)</span>', webpage, 'title')
44 uploader_id = self._html_search_regex(r'class="aupa">\n*(.*?)</a>', webpage, 'uploader')
45 url = self._html_search_regex(r'<p><a href="(.*?)" ?\n*target="_blank"><font color', webpage, 'url')
46 thumbnail = self._html_search_regex(r'<div id="player" style="z-index:1;"> <span id="edge"></span> <span id="container"><img[\n ]*src="(.+?)"', webpage, 'thumbnail')
48 str_duration = self._html_search_regex(r'<tr>[\n\s]*<td>Time: </td>[\n\s]*<td align="right"><span>(.+)\n*', webpage, 'duration')
49 duration = self._to_seconds(str_duration)
51 str_views = self._html_search_regex(r'<tr>[\n\s]*<td>Views: </td>[\n\s]*<td align="right"><span>(.+)</span>', webpage, 'view_count')
52 view_count = int(str_views)
55 date = self._html_search_regex(r'class="aup">Added: <strong>(.*?)</strong>', webpage, 'date')
56 d = datetime.datetime.strptime(date, '%B %d, %Y')
57 upload_date = d.strftime('%Y%m%d')
59 categories = re.findall(r'http://www.sexykarma.com/gonewild/search/video/(?:.+?)"><span>(.*?)</span>', webpage)
64 'uploader_id': uploader_id,
66 'thumbnail': thumbnail,
68 'view_count': view_count,
69 'upload_date': upload_date,
70 'categories': categories,
73 def _to_seconds(self, timestr):
75 for part in timestr.split(':'):
76 seconds= seconds*60 + int(part)