X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=youtube_dl%2Fextractor%2Fturner.py;h=1c0be9fc6aa97260622b1148763a57dbf25ce50f;hb=329e3dd5adf52520c87ba31395d090455114783b;hp=f5736bd155979a8de005e71431c8060c9556d115;hpb=5a80e7b43a7abc83e104f1cd711d8fe7985c30eb;p=youtube-dl diff --git a/youtube_dl/extractor/turner.py b/youtube_dl/extractor/turner.py index f5736bd15..1c0be9fc6 100644 --- a/youtube_dl/extractor/turner.py +++ b/youtube_dl/extractor/turner.py @@ -3,7 +3,7 @@ from __future__ import unicode_literals import re -from .common import InfoExtractor +from .adobepass import AdobePassIE from ..compat import compat_str from ..utils import ( xpath_text, @@ -12,15 +12,19 @@ from ..utils import ( parse_duration, xpath_attr, update_url_query, - compat_urlparse, + ExtractorError, ) -class TurnerBaseIE(InfoExtractor): - def _extract_cvp_info(self, data_src, video_id, path_data={}): +class TurnerBaseIE(AdobePassIE): + def _extract_timestamp(self, video_data): + return int_or_none(xpath_attr(video_data, 'dateCreated', 'uts')) + + def _extract_cvp_info(self, data_src, video_id, path_data={}, ap_data={}): video_data = self._download_xml(data_src, video_id) - video_id = video_data.attrib['id'].split('/')[-1].split('.')[0] + video_id = video_data.attrib['id'] 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') # if rtmp_src: # splited_rtmp_src = rtmp_src.split(',') @@ -51,7 +55,7 @@ class TurnerBaseIE(InfoExtractor): # auth = self._download_webpage( # protected_path_data['tokenizer_src'], query={ # 'path': protected_path, - # 'videoId': video_id, + # 'videoId': content_id, # 'aifp': aifp, # }) # token = xpath_text(auth, 'token') @@ -66,11 +70,17 @@ class TurnerBaseIE(InfoExtractor): secure_path = self._search_regex(r'https?://[^/]+(.+/)', video_url, 'secure path') + '*' token = tokens.get(secure_path) if not token: + query = { + 'path': secure_path, + 'videoId': content_id, + } + if ap_data.get('auth_required'): + query['accessToken'] = self._extract_mvpd_auth(ap_data['url'], video_id, ap_data['site_name'], ap_data['site_name']) auth = self._download_xml( - secure_path_data['tokenizer_src'], video_id, query={ - 'path': secure_path, - 'videoId': video_id, - }) + secure_path_data['tokenizer_src'], video_id, query=query) + error_msg = xpath_text(auth, 'error/msg') + if error_msg: + raise ExtractorError(error_msg, expected=True) token = xpath_text(auth, 'token') if not token: continue @@ -91,18 +101,12 @@ class TurnerBaseIE(InfoExtractor): video_url, video_id, fatal=False)) elif ext == 'm3u8': m3u8_formats = self._extract_m3u8_formats( - video_url, video_id, 'mp4', 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) + video_url, video_id, 'mp4', + m3u8_id=format_id or 'hls', fatal=False) + if '/secure/' in video_url and '?hdnea=' in video_url: + for f in m3u8_formats: + f['_seekable'] = False + formats.extend(m3u8_formats) elif ext == 'f4m': formats.extend(self._extract_f4m_formats( update_url_query(video_url, {'hdcore': '3.7.0'}), @@ -159,10 +163,6 @@ class TurnerBaseIE(InfoExtractor): 'height': int_or_none(image.get('height')), } for image in video_data.findall('images/image')] - timestamp = None - if 'cnn.com' not in data_src: - timestamp = int_or_none(xpath_attr(video_data, 'dateCreated', 'uts')) - return { 'id': video_id, 'title': title, @@ -171,7 +171,7 @@ class TurnerBaseIE(InfoExtractor): 'thumbnails': thumbnails, 'description': xpath_text(video_data, 'description'), 'duration': parse_duration(xpath_text(video_data, 'length') or xpath_text(video_data, 'trt')), - 'timestamp': timestamp, + 'timestamp': self._extract_timestamp(video_data), 'upload_date': xpath_attr(video_data, 'metas', 'version'), 'series': xpath_text(video_data, 'showTitle'), 'season_number': int_or_none(xpath_text(video_data, 'seasonNumber')),