Add age limit to anysex, beeg, eporner, hornbuny and sunporno
[youtube-dl] / youtube_dl / extractor / hornbunny.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4 import re
5
6 from .common import InfoExtractor
7 from ..utils import int_or_none
8
9 class HornBunnyIE(InfoExtractor):
10     _VALID_URL = r'http?://(?:www\.)?hornbunny\.com/videos/(?P<title_dash>[a-z-]+)-(?P<id>\d+)\.html'
11     _TEST = {
12         'url': 'http://hornbunny.com/videos/panty-slut-jerk-off-instruction-5227.html',
13         'md5': '95e40865aedd08eff60272b704852ad7',
14         'info_dict': {
15             'id': '5227',
16             'ext': 'flv',
17             'title': 'panty slut jerk off instruction',
18             'duration': 550,
19             'age_limit': 18,
20         }
21     }
22
23     def _real_extract(self, url):
24         mobj = re.match(self._VALID_URL, url)
25         video_id = mobj.group('id')
26
27         webpage = self._download_webpage(url, video_id)
28         title = self._html_search_regex(r'class="title">(.*?)</h2>', webpage, 'title')
29         redirect_url = self._html_search_regex(r'pg&settings=(.*?)\|0"\);', webpage, 'title')
30         webpage2 = self._download_webpage(redirect_url, video_id)
31         video_url = self._html_search_regex(r'flvMask:(.*?);', webpage2, 'video_url')
32         
33         mobj = re.search(r'<strong>Runtime:</strong> (?P<minutes>\d+):(?P<seconds>\d+)</div>', webpage)
34         duration = int(mobj.group('minutes')) * 60 + int(mobj.group('seconds')) if mobj else None
35
36         view_count = self._html_search_regex(r'<strong>Views:</strong>  (\d+)</div>', webpage, 'view count', fatal=False)
37
38         return {
39             'id': video_id,
40             'url': video_url,
41             'title': title,
42             'ext': 'flv',
43             'duration': duration,
44             'view_count': int_or_none(view_count),
45             'age_limit': 18,
46         }