- mobj = re.match(self._VALID_URL, url)
- video_id = mobj.group('id')
- display_id = mobj.group('display_id')
-
- req = sanitized_Request(url)
- req.add_header('Cookie', 'age_verified=1')
- webpage = self._download_webpage(req, display_id)
-
- flashvars = self._parse_json(
- self._search_regex(
- r'flashvars\s*=\s*({.+?});\r?\n', webpage, 'flashvars'),
- video_id)
-
- formats = []
- for key, video_url in flashvars.items():
- if not isinstance(video_url, compat_str) or not video_url.startswith('http'):
- continue
- height = self._search_regex(
- r'quality_(\d+)[pP]', key, 'height', default=None)
- if not height:
- continue
- if flashvars.get('encrypted') is True:
- video_url = aes_decrypt_text(
- video_url, flashvars['video_title'], 32).decode('utf-8')
- formats.append({
- 'url': video_url,
- 'format_id': '%sp' % height,
- 'height': int(height),
- })
- self._sort_formats(formats)