- video_url = next(n.text
- for n in streams_doc.findall('.//choice/url')
- if u'//ad.doubleclick' not in n.text)
- if video_url.endswith('/Unavailable.flv'):
- raise ExtractorError(
- u'Access to this video is blocked from outside of Canada',
- expected=True)
+ post_url, form_data = extract_form_url_and_data(
+ login_webpage,
+ 'https://services.radio-canada.ca/auth/oauth/v2/authorize/login',
+ r'(?:id|name)="Form-login"')
+ form_data.update({
+ 'login-email': email,
+ 'login-password': password,
+ })
+ consent_webpage = self._download_webpage(
+ post_url, None, 'Logging in', data=urlencode_postdata(form_data))
+ post_url, form_data = extract_form_url_and_data(
+ consent_webpage,
+ 'https://services.radio-canada.ca/auth/oauth/v2/authorize/consent')
+ _, urlh = self._download_webpage_handle(
+ post_url, None, 'Following Redirection',
+ data=urlencode_postdata(form_data))
+ self._access_token = self._search_regex(
+ r'access_token=([\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12})',
+ urlh.geturl(), 'access token')
+ self._claims = self._download_json(
+ 'https://services.radio-canada.ca/media/validation/v2/getClaims',
+ None, 'Extracting Claims', query={
+ 'token': self._access_token,
+ 'access_token': self._access_token,
+ })['claims']