3 from __future__
import unicode_literals
7 from ..compat
import compat_urllib_parse_unquote
8 from ..utils
import determine_ext
9 from .bokecc
import BokeCCBaseIE
12 class InfoQIE(BokeCCBaseIE
):
13 _VALID_URL
= r
'https?://(?:www\.)?infoq\.com/(?:[^/]+/)+(?P<id>[^/]+)'
16 'url': 'http://www.infoq.com/presentations/A-Few-of-My-Favorite-Python-Things',
17 'md5': 'b5ca0e0a8c1fed93b0e65e48e462f9a2',
19 'id': 'A-Few-of-My-Favorite-Python-Things',
21 'description': 'Mike Pirnat presents some tips and tricks, standard libraries and third party packages that make programming in Python a richer experience.',
22 'title': 'A Few of My Favorite [Python] Things',
25 'url': 'http://www.infoq.com/fr/presentations/changez-avis-sur-javascript',
26 'only_matching': True,
28 'url': 'http://www.infoq.com/cn/presentations/openstack-continued-delivery',
29 'md5': '4918d0cca1497f2244572caf626687ef',
31 'id': 'openstack-continued-delivery',
32 'title': 'OpenStack持续交付之路',
34 'description': 'md5:308d981fb28fa42f49f9568322c683ff',
38 def _extract_rtmp_videos(self
, webpage
):
39 # The server URL is hardcoded
40 video_url
= 'rtmpe://video.infoq.com/cfx/st/'
43 encoded_id
= self
._search
_regex
(
44 r
"jsclassref\s*=\s*'([^']*)'", webpage
, 'encoded id', default
=None)
46 real_id
= compat_urllib_parse_unquote(base64
.b64decode(encoded_id
.encode('ascii')).decode('utf-8'))
47 playpath
= 'mp4:' + real_id
52 'ext': determine_ext(playpath
),
53 'play_path': playpath
,
56 def _extract_http_videos(self
, webpage
):
57 http_video_url
= self
._search
_regex
(r
'P\.s\s*=\s*\'([^
\']+)\'', webpage, 'video URL
')
59 policy = self._search_regex(r'InfoQConstants
.scp\s
*=\s
*\'([^
\']+)\'', webpage, 'policy
')
60 signature = self._search_regex(r'InfoQConstants
.scs\s
*=\s
*\'([^
\']+)\'', webpage, 'signature
')
61 key_pair_id = self._search_regex(r'InfoQConstants
.sck\s
*=\s
*\'([^
\']+)\'', webpage, 'key
-pair
-id')
65 'url
': http_video_url,
67 'Cookie
': 'CloudFront
-Policy
=%s; CloudFront
-Signature
=%s; CloudFront
-Key
-Pair
-Id
=%s' % (
68 policy, signature, key_pair_id),
72 def _real_extract(self, url):
73 video_id = self._match_id(url)
74 webpage = self._download_webpage(url, video_id)
76 video_title = self._html_search_regex(r'<title
>(.*?
)</title
>', webpage, 'title
')
77 video_description = self._html_search_meta('description
', webpage, 'description
')
80 # for China videos, HTTP video URL exists but always fails with 403
81 formats = self._extract_bokecc_formats(webpage, video_id)
83 formats = self._extract_rtmp_videos(webpage) + self._extract_http_videos(webpage)
85 self._sort_formats(formats)
90 'description
': video_description,