1 from __future__ import unicode_literals
5 from .common import InfoExtractor
6 from ..compat import compat_urllib_parse_unquote
9 class InfoQIE(InfoExtractor):
10 _VALID_URL = r'https?://(?:www\.)?infoq\.com/(?:[^/]+/)+(?P<id>[^/]+)'
13 'url': 'http://www.infoq.com/presentations/A-Few-of-My-Favorite-Python-Things',
14 'md5': 'b5ca0e0a8c1fed93b0e65e48e462f9a2',
16 'id': '12-jan-pythonthings',
18 'description': 'Mike Pirnat presents some tips and tricks, standard libraries and third party packages that make programming in Python a richer experience.',
19 'title': 'A Few of My Favorite [Python] Things',
22 'url': 'http://www.infoq.com/fr/presentations/changez-avis-sur-javascript',
23 'only_matching': True,
26 def _real_extract(self, url):
27 video_id = self._match_id(url)
28 webpage = self._download_webpage(url, video_id)
30 video_title = self._html_search_regex(r'<title>(.*?)</title>', webpage, 'title')
31 video_description = self._html_search_meta('description', webpage, 'description')
33 # The server URL is hardcoded
34 video_url = 'rtmpe://video.infoq.com/cfx/st/'
37 encoded_id = self._search_regex(
38 r"jsclassref\s*=\s*'([^']*)'", webpage, 'encoded id')
39 real_id = compat_urllib_parse_unquote(base64.b64decode(encoded_id.encode('ascii')).decode('utf-8'))
40 playpath = 'mp4:' + real_id
42 video_filename = playpath.split('/')[-1]
43 video_id, extension = video_filename.split('.')
45 http_video_url = self._search_regex(r'P\.s\s*=\s*\'([^\']+)\'', webpage, 'video URL')
47 policy = self._search_regex(r'InfoQConstants.scp\s*=\s*\'([^\']+)\'', webpage, 'policy')
48 signature = self._search_regex(r'InfoQConstants.scs\s*=\s*\'([^\']+)\'', webpage, 'signature')
49 key_pair_id = self._search_regex(r'InfoQConstants.sck\s*=\s*\'([^\']+)\'', webpage, 'key-pair-id')
55 'play_path': playpath,
58 'url': http_video_url,
60 'Cookie': 'CloudFront-Policy=%s; CloudFront-Signature=%s; CloudFront-Key-Pair-Id=%s' % (
61 policy, signature, key_pair_id),
64 self._sort_formats(formats)
69 'description': video_description,