[turner] use android secure hls host and catch token extraction errors

This commit is contained in:
Remita Amine 2016-09-06 15:34:40 +01:00
parent f3eeaacb4e
commit bdcc046d12
3 changed files with 12 additions and 18 deletions

View file

@ -30,7 +30,7 @@ def _real_extract(self, url):
return self._extract_cvp_info( return self._extract_cvp_info(
'http://www.cartoonnetwork.com/video-seo-svc/episodeservices/getCvpPlaylist?networkName=CN2&' + query, video_id, { 'http://www.cartoonnetwork.com/video-seo-svc/episodeservices/getCvpPlaylist?networkName=CN2&' + query, video_id, {
'secure': { 'secure': {
'media_src': 'http://apple-secure.cdn.turner.com/toon/big', 'media_src': 'http://androidhls-secure.cdn.turner.com/toon/big',
'tokenizer_src': 'http://www.cartoonnetwork.com/cntv/mvpd/processors/services/token_ipadAdobe.do', 'tokenizer_src': 'http://www.cartoonnetwork.com/cntv/mvpd/processors/services/token_ipadAdobe.do',
}, },
}) })

View file

@ -53,7 +53,7 @@ def _real_extract(self, url):
'media_src': 'http://ht.cdn.turner.com/%s/big' % site, 'media_src': 'http://ht.cdn.turner.com/%s/big' % site,
}, },
'secure': { 'secure': {
'media_src': 'http://apple-secure.cdn.turner.com/%s/big' % site, 'media_src': 'http://androidhls-secure.cdn.turner.com/%s/big' % site,
'tokenizer_src': 'http://www.%s.com/video/processors/services/token_ipadAdobe.do' % domain, 'tokenizer_src': 'http://www.%s.com/video/processors/services/token_ipadAdobe.do' % domain,
}, },
}) })

View file

@ -12,7 +12,7 @@
parse_duration, parse_duration,
xpath_attr, xpath_attr,
update_url_query, update_url_query,
compat_urlparse, ExtractorError,
) )
@ -24,6 +24,7 @@ def _extract_cvp_info(self, data_src, video_id, path_data={}):
video_data = self._download_xml(data_src, video_id) video_data = self._download_xml(data_src, video_id)
video_id = video_data.attrib['id'] video_id = video_data.attrib['id']
title = xpath_text(video_data, 'headline', fatal=True) title = xpath_text(video_data, 'headline', fatal=True)
content_id = xpath_text(video_data, 'contentId') or video_id
# rtmp_src = xpath_text(video_data, 'akamai/src') # rtmp_src = xpath_text(video_data, 'akamai/src')
# if rtmp_src: # if rtmp_src:
# splited_rtmp_src = rtmp_src.split(',') # splited_rtmp_src = rtmp_src.split(',')
@ -54,7 +55,7 @@ def _extract_cvp_info(self, data_src, video_id, path_data={}):
# auth = self._download_webpage( # auth = self._download_webpage(
# protected_path_data['tokenizer_src'], query={ # protected_path_data['tokenizer_src'], query={
# 'path': protected_path, # 'path': protected_path,
# 'videoId': video_id, # 'videoId': content_id,
# 'aifp': aifp, # 'aifp': aifp,
# }) # })
# token = xpath_text(auth, 'token') # token = xpath_text(auth, 'token')
@ -72,8 +73,11 @@ def _extract_cvp_info(self, data_src, video_id, path_data={}):
auth = self._download_xml( auth = self._download_xml(
secure_path_data['tokenizer_src'], video_id, query={ secure_path_data['tokenizer_src'], video_id, query={
'path': secure_path, 'path': secure_path,
'videoId': video_id, 'videoId': content_id,
}) })
error_msg = xpath_text(auth, 'error/msg')
if error_msg:
raise ExtractorError(error_msg, expected=True)
token = xpath_text(auth, 'token') token = xpath_text(auth, 'token')
if not token: if not token:
continue continue
@ -93,19 +97,9 @@ def _extract_cvp_info(self, data_src, video_id, path_data={}):
formats.extend(self._extract_smil_formats( formats.extend(self._extract_smil_formats(
video_url, video_id, fatal=False)) video_url, video_id, fatal=False))
elif ext == 'm3u8': elif ext == 'm3u8':
m3u8_formats = self._extract_m3u8_formats( formats.extend(self._extract_m3u8_formats(
video_url, video_id, 'mp4', m3u8_id=format_id or 'hls', video_url, video_id, 'mp4',
fatal=False) m3u8_id=format_id or 'hls', fatal=False))
if m3u8_formats:
# Sometimes final URLs inside m3u8 are unsigned, let's fix this
# ourselves
qs = compat_urlparse.urlparse(video_url).query
if qs:
query = compat_urlparse.parse_qs(qs)
for m3u8_format in m3u8_formats:
m3u8_format['url'] = update_url_query(m3u8_format['url'], query)
m3u8_format['extra_param_to_segment_url'] = qs
formats.extend(m3u8_formats)
elif ext == 'f4m': elif ext == 'f4m':
formats.extend(self._extract_f4m_formats( formats.extend(self._extract_f4m_formats(
update_url_query(video_url, {'hdcore': '3.7.0'}), update_url_query(video_url, {'hdcore': '3.7.0'}),