]> jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/watchindianporn.py
[extractor/toggo] Improve `_VALID_URL` (#4663)
[yt-dlp.git] / yt_dlp / extractor / watchindianporn.py
1 import re
2
3 from .common import InfoExtractor
4 from ..utils import parse_duration
5
6
7 class WatchIndianPornIE(InfoExtractor):
8 IE_DESC = 'Watch Indian Porn'
9 _VALID_URL = r'https?://(?:www\.)?watchindianporn\.net/(?:[^/]+/)*video/(?P<display_id>[^/]+)-(?P<id>[a-zA-Z0-9]+)\.html'
10 _TEST = {
11 'url': 'http://www.watchindianporn.net/video/hot-milf-from-kerala-shows-off-her-gorgeous-large-breasts-on-camera-RZa2avywNPa.html',
12 'md5': '249589a164dde236ec65832bfce17440',
13 'info_dict': {
14 'id': 'RZa2avywNPa',
15 'display_id': 'hot-milf-from-kerala-shows-off-her-gorgeous-large-breasts-on-camera',
16 'ext': 'mp4',
17 'title': 'Hot milf from kerala shows off her gorgeous large breasts on camera',
18 'thumbnail': r're:^https?://.*\.jpg$',
19 'duration': 226,
20 'view_count': int,
21 'categories': list,
22 'age_limit': 18,
23 }
24 }
25
26 def _real_extract(self, url):
27 mobj = self._match_valid_url(url)
28 video_id = mobj.group('id')
29 display_id = mobj.group('display_id')
30
31 webpage = self._download_webpage(url, display_id)
32
33 info_dict = self._parse_html5_media_entries(url, webpage, video_id)[0]
34
35 title = self._html_search_regex((
36 r'<title>(.+?)\s*-\s*Indian\s+Porn</title>',
37 r'<h4>(.+?)</h4>'
38 ), webpage, 'title')
39
40 duration = parse_duration(self._search_regex(
41 r'Time:\s*<strong>\s*(.+?)\s*</strong>',
42 webpage, 'duration', fatal=False))
43
44 view_count = int(self._search_regex(
45 r'(?s)Time:\s*<strong>.*?</strong>.*?<strong>\s*(\d+)\s*</strong>',
46 webpage, 'view count', fatal=False))
47
48 categories = re.findall(
49 r'<a[^>]+class=[\'"]categories[\'"][^>]*>\s*([^<]+)\s*</a>',
50 webpage)
51
52 info_dict.update({
53 'id': video_id,
54 'display_id': display_id,
55 'http_headers': {
56 'Referer': url,
57 },
58 'title': title,
59 'duration': duration,
60 'view_count': view_count,
61 'categories': categories,
62 'age_limit': 18,
63 })
64
65 return info_dict