1 from __future__ import unicode_literals
5 from .common import InfoExtractor
6 from ..aes import aes_decrypt_text
9 compat_urllib_parse_unquote,
20 class KeezMoviesIE(InfoExtractor):
21 _VALID_URL = r'https?://(?:www\.)?keezmovies\.com/video/(?:(?P<display_id>[^/]+)-)?(?P<id>\d+)'
23 'url': 'http://www.keezmovies.com/video/petite-asian-lady-mai-playing-in-bathtub-1214711',
24 'md5': '1c1e75d22ffa53320f45eeb07bc4cdc0',
27 'display_id': 'petite-asian-lady-mai-playing-in-bathtub',
29 'title': 'Petite Asian Lady Mai Playing In Bathtub',
30 'thumbnail': 're:^https?://.*\.jpg$',
35 'url': 'http://www.keezmovies.com/video/1214711',
36 'only_matching': True,
39 def _extract_info(self, url):
40 mobj = re.match(self._VALID_URL, url)
41 video_id = mobj.group('id')
42 display_id = (mobj.group('display_id') if 'display_id'
43 in mobj.groupdict() else None) or mobj.group('id')
45 webpage = self._download_webpage(
46 url, display_id, headers={'Cookie': 'age_verified=1'})
56 def extract_format(format_url, height=None):
57 if not isinstance(format_url, compat_str) or not format_url.startswith('http'):
59 if format_url in format_urls:
61 format_urls.add(format_url)
62 tbr = int_or_none(self._search_regex(
63 r'[/_](\d+)[kK][/_]', format_url, 'tbr', default=None))
65 height = int_or_none(self._search_regex(
66 r'[/_](\d+)[pP][/_]', format_url, 'height', default=None))
68 format_url = aes_decrypt_text(
69 video_url, title, 32).decode('utf-8')
72 'format_id': '%dp' % height if height else None,
77 flashvars = self._parse_json(
79 r'flashvars\s*=\s*({.+?});', webpage,
80 'flashvars', default='{}'),
81 display_id, fatal=False)
84 title = flashvars.get('video_title')
85 thumbnail = flashvars.get('image_url')
86 duration = int_or_none(flashvars.get('video_duration'))
87 encrypted = flashvars.get('encrypted') is True
88 for key, value in flashvars.items():
89 mobj = re.search(r'quality_(\d+)[pP]', key)
91 extract_format(value, int(mobj.group(1)))
92 video_url = flashvars.get('video_url')
93 if video_url and determine_ext(video_url, None):
94 extract_format(video_url)
96 video_url = self._html_search_regex(
97 r'flashvars\.video_url\s*=\s*(["\'])(?P<url>http.+?)\1',
98 webpage, 'video url', default=None, group='url')
100 extract_format(compat_urllib_parse_unquote(video_url))
103 if 'title="This video is no longer available"' in webpage:
104 raise ExtractorError(
105 'Video %s is no longer available' % video_id, expected=True)
107 self._sort_formats(formats)
110 title = self._html_search_regex(
111 r'<h1[^>]*>([^<]+)', webpage, 'title')
115 'display_id': display_id,
116 'title': strip_or_none(title),
117 'thumbnail': thumbnail,
118 'duration': duration,
123 def _real_extract(self, url):
124 webpage, info = self._extract_info(url)
125 info['view_count'] = str_to_int(self._search_regex(
126 r'<b>([\d,.]+)</b> Views?', webpage, 'view count', fatal=False))