]> jfr.im git - yt-dlp.git/blame - youtube_dl/extractor/sexykarma.py
Merge remote-tracking branch 'h-collector/master'
[yt-dlp.git] / youtube_dl / extractor / sexykarma.py
CommitLineData
47408645
C
1# coding: utf-8
2from __future__ import unicode_literals
3
1723edb1 4import re
95fa5fb5
S
5
6from .common import InfoExtractor
7from ..utils import (
8 unified_strdate,
9 parse_duration,
10 int_or_none,
11)
12
47408645
C
13
14class SexyKarmaIE(InfoExtractor):
16efb369
S
15 IE_DESC = 'Sexy Karma and Watch Indian Porn'
16 _VALID_URL = r'https?://(?:www\.)?(?:sexykarma\.com|watchindianporn\.net)/(?:[^/]+/)*video/(?P<display_id>[^/]+)-(?P<id>[a-zA-Z0-9]+)\.html'
47408645
C
17 _TESTS = [{
18 'url': 'http://www.sexykarma.com/gonewild/video/taking-a-quick-pee-yHI70cOyIHt.html',
19 'md5': 'b9798e7d1ef1765116a8f516c8091dbd',
20 'info_dict': {
1723edb1 21 'id': 'yHI70cOyIHt',
95fa5fb5 22 'display_id': 'taking-a-quick-pee',
47408645
C
23 'ext': 'mp4',
24 'title': 'Taking a quick pee.',
1723edb1 25 'thumbnail': 're:^https?://.*\.jpg$',
95fa5fb5 26 'uploader': 'wildginger7',
796858a5 27 'upload_date': '20141008',
16efb369 28 'duration': 22,
95fa5fb5
S
29 'view_count': int,
30 'comment_count': int,
31 'categories': list,
47408645
C
32 }
33 }, {
34 'url': 'http://www.sexykarma.com/gonewild/video/pot-pixie-tribute-8Id6EZPbuHf.html',
35 'md5': 'dd216c68d29b49b12842b9babe762a5d',
36 'info_dict': {
1723edb1 37 'id': '8Id6EZPbuHf',
95fa5fb5 38 'display_id': 'pot-pixie-tribute',
47408645
C
39 'ext': 'mp4',
40 'title': 'pot_pixie tribute',
1723edb1 41 'thumbnail': 're:^https?://.*\.jpg$',
95fa5fb5 42 'uploader': 'banffite',
1723edb1 43 'upload_date': '20141013',
95fa5fb5
S
44 'duration': 16,
45 'view_count': int,
46 'comment_count': int,
47 'categories': list,
796858a5 48 'age_limit': 18,
47408645 49 }
16efb369
S
50 }, {
51 'url': 'http://www.watchindianporn.net/video/desi-dancer-namrata-stripping-completely-nude-and-dancing-on-a-hot-number-dW2mtctxJfs.html',
52 'md5': '9afb80675550406ed9a63ac2819ef69d',
53 'info_dict': {
54 'id': 'dW2mtctxJfs',
55 'display_id': 'desi-dancer-namrata-stripping-completely-nude-and-dancing-on-a-hot-number',
56 'ext': 'mp4',
57 'title': 'Desi dancer namrata stripping completely nude and dancing on a hot number',
58 'thumbnail': 're:^https?://.*\.jpg$',
59 'uploader': 'Don',
60 'upload_date': '20140213',
61 'duration': 83,
62 'view_count': int,
63 'comment_count': int,
64 'categories': list,
796858a5 65 'age_limit': 18,
16efb369 66 }
47408645
C
67 }]
68
69 def _real_extract(self, url):
95fa5fb5
S
70 mobj = re.match(self._VALID_URL, url)
71 video_id = mobj.group('id')
72 display_id = mobj.group('display_id')
73
74 webpage = self._download_webpage(url, display_id)
75
76 video_url = self._html_search_regex(
16efb369 77 r"url: escape\('([^']+)'\)", webpage, 'url')
95fa5fb5
S
78
79 title = self._html_search_regex(
80 r'<h2 class="he2"><span>(.*?)</span>',
81 webpage, 'title')
95fa5fb5
S
82 thumbnail = self._html_search_regex(
83 r'<span id="container"><img\s+src="([^"]+)"',
84 webpage, 'thumbnail', fatal=False)
47408645 85
95fa5fb5
S
86 uploader = self._html_search_regex(
87 r'class="aupa">\s*(.*?)</a>',
88 webpage, 'uploader')
89 upload_date = unified_strdate(self._html_search_regex(
90 r'Added: <strong>(.+?)</strong>', webpage, 'upload date', fatal=False))
1723edb1 91
95fa5fb5
S
92 duration = parse_duration(self._search_regex(
93 r'<td>Time:\s*</td>\s*<td align="right"><span>\s*(.+?)\s*</span>',
94 webpage, 'duration', fatal=False))
1723edb1 95
95fa5fb5
S
96 view_count = int_or_none(self._search_regex(
97 r'<td>Views:\s*</td>\s*<td align="right"><span>\s*(\d+)\s*</span>',
98 webpage, 'view count', fatal=False))
99 comment_count = int_or_none(self._search_regex(
100 r'<td>Comments:\s*</td>\s*<td align="right"><span>\s*(\d+)\s*</span>',
101 webpage, 'comment count', fatal=False))
47408645 102
16efb369
S
103 categories = re.findall(
104 r'<a href="[^"]+/search/video/desi"><span>([^<]+)</span></a>',
105 webpage)
7da224c9 106
47408645
C
107 return {
108 'id': video_id,
95fa5fb5
S
109 'display_id': display_id,
110 'url': video_url,
47408645 111 'title': title,
1723edb1 112 'thumbnail': thumbnail,
95fa5fb5
S
113 'uploader': uploader,
114 'upload_date': upload_date,
1723edb1
C
115 'duration': duration,
116 'view_count': view_count,
95fa5fb5 117 'comment_count': comment_count,
7da224c9 118 'categories': categories,
796858a5 119 'age_limit': 18,
47408645 120 }