]> jfr.im git - yt-dlp.git/blame - youtube_dl/extractor/hornbunny.py
[smotri] Adapt to new API and modernize
[yt-dlp.git] / youtube_dl / extractor / hornbunny.py
CommitLineData
bbc9dc56 1# coding: utf-8
2from __future__ import unicode_literals
3
4import re
5
6from .common import InfoExtractor
e4039057
PH
7from ..utils import (
8 int_or_none,
9 parse_duration,
10)
11
bbc9dc56 12
13class 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',
e4039057
PH
22 'duration': 550,
23 'age_limit': 18,
bbc9dc56 24 }
25 }
26
27 def _real_extract(self, url):
28 mobj = re.match(self._VALID_URL, url)
29 video_id = mobj.group('id')
30
e4039057
PH
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')
bbc9dc56 37 webpage2 = self._download_webpage(redirect_url, video_id)
e4039057
PH
38 video_url = self._html_search_regex(
39 r'flvMask:(.*?);', webpage2, 'video_url')
bbc9dc56 40
e4039057
PH
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))
bbc9dc56 47
48 return {
49 'id': video_id,
50 'url': video_url,
51 'title': title,
52 'ext': 'flv',
53 'duration': duration,
e4039057
PH
54 'view_count': view_count,
55 'age_limit': 18,
bbc9dc56 56 }