]> jfr.im git - yt-dlp.git/blob - youtube_dl/extractor/hornbunny.py
Merge branch 'master' of github.com:rg3/youtube-dl
[yt-dlp.git] / 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 }
20 }
21
22 def _real_extract(self, url):
23 mobj = re.match(self._VALID_URL, url)
24 video_id = mobj.group('id')
25
26 webpage = self._download_webpage(url, video_id)
27 title = self._html_search_regex(r'class="title">(.*?)</h2>', webpage, 'title')
28 redirect_url = self._html_search_regex(r'pg&settings=(.*?)\|0"\);', webpage, 'title')
29 webpage2 = self._download_webpage(redirect_url, video_id)
30 video_url = self._html_search_regex(r'flvMask:(.*?);', webpage2, 'video_url')
31
32 mobj = re.search(r'<strong>Runtime:</strong> (?P<minutes>\d+):(?P<seconds>\d+)</div>', webpage)
33 duration = int(mobj.group('minutes')) * 60 + int(mobj.group('seconds')) if mobj else None
34
35 view_count = self._html_search_regex(r'<strong>Views:</strong> (\d+)</div>', webpage, 'view count', fatal=False)
36
37 return {
38 'id': video_id,
39 'url': video_url,
40 'title': title,
41 'ext': 'flv',
42 'duration': duration,
43 'view_count': int_or_none(view_count),
44 }