]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/hornbunny.py
Annotate changelog with bug closed.
[youtubedl] / 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 (
8 int_or_none,
9 parse_duration,
10 )
11
12
13 class HornBunnyIE(InfoExtractor):
14 _VALID_URL = r'http?://(?:www\.)?hornbunny\.com/videos/(?P<title_dash>[a-z-]+)-(?P<id>\d+)\.html'
15 _TEST = {
16 'url': 'http://hornbunny.com/videos/panty-slut-jerk-off-instruction-5227.html',
17 'md5': '95e40865aedd08eff60272b704852ad7',
18 'info_dict': {
19 'id': '5227',
20 'ext': 'flv',
21 'title': 'panty slut jerk off instruction',
22 'duration': 550,
23 'age_limit': 18,
24 }
25 }
26
27 def _real_extract(self, url):
28 mobj = re.match(self._VALID_URL, url)
29 video_id = mobj.group('id')
30
31 webpage = self._download_webpage(
32 url, video_id, note='Downloading initial webpage')
33 title = self._html_search_regex(
34 r'class="title">(.*?)</h2>', webpage, 'title')
35 redirect_url = self._html_search_regex(
36 r'pg&settings=(.*?)\|0"\);', webpage, 'title')
37 webpage2 = self._download_webpage(redirect_url, video_id)
38 video_url = self._html_search_regex(
39 r'flvMask:(.*?);', webpage2, 'video_url')
40
41 duration = parse_duration(self._search_regex(
42 r'<strong>Runtime:</strong>\s*([0-9:]+)</div>',
43 webpage, 'duration', fatal=False))
44 view_count = int_or_none(self._search_regex(
45 r'<strong>Views:</strong>\s*(\d+)</div>',
46 webpage, 'view count', fatal=False))
47
48 return {
49 'id': video_id,
50 'url': video_url,
51 'title': title,
52 'ext': 'flv',
53 'duration': duration,
54 'view_count': view_count,
55 'age_limit': 18,
56 }