add support for Adobe Pass auth in tbs,tnt and trutv extractors(fixes #10642)(closes #10222)(closes #10519)

This commit is contained in:
Remita Amine 2016-09-20 11:55:30 +01:00
parent cb57386873
commit c38f06818d
4 changed files with 28 additions and 16 deletions

View file

@ -83,7 +83,7 @@ class AdobePassIE(InfoExtractor):
'User-Agent': self._USER_AGENT, 'User-Agent': self._USER_AGENT,
} }
guid = xml_text(resource, 'guid') guid = xml_text(resource, 'guid') if '<' in resource else resource
count = 0 count = 0
while count < 2: while count < 2:
requestor_info = self._downloader.cache.load(self._MVPD_CACHE, requestor_id) or {} requestor_info = self._downloader.cache.load(self._MVPD_CACHE, requestor_id) or {}

View file

@ -4,10 +4,7 @@ from __future__ import unicode_literals
import re import re
from .turner import TurnerBaseIE from .turner import TurnerBaseIE
from ..utils import ( from ..utils import extract_attributes
extract_attributes,
ExtractorError,
)
class TBSIE(TurnerBaseIE): class TBSIE(TurnerBaseIE):
@ -37,10 +34,6 @@ class TBSIE(TurnerBaseIE):
site = domain[:3] site = domain[:3]
webpage = self._download_webpage(url, display_id) webpage = self._download_webpage(url, display_id)
video_params = extract_attributes(self._search_regex(r'(<[^>]+id="page-video"[^>]*>)', webpage, 'video params')) video_params = extract_attributes(self._search_regex(r'(<[^>]+id="page-video"[^>]*>)', webpage, 'video params'))
if video_params.get('isAuthRequired') == 'true':
raise ExtractorError(
'This video is only available via cable service provider subscription that'
' is not currently supported.', expected=True)
query = None query = None
clip_id = video_params.get('clipid') clip_id = video_params.get('clipid')
if clip_id: if clip_id:
@ -56,4 +49,8 @@ class TBSIE(TurnerBaseIE):
'media_src': 'http://androidhls-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,
}, },
}, {
'url': url,
'site_name': site.upper(),
'auth_required': video_params.get('isAuthRequired') != 'false',
}) })

View file

@ -22,9 +22,17 @@ class TruTVIE(TurnerBaseIE):
def _real_extract(self, url): def _real_extract(self, url):
path, video_id = re.match(self._VALID_URL, url).groups() path, video_id = re.match(self._VALID_URL, url).groups()
auth_required = False
if path: if path:
data_src = 'http://www.trutv.com/video/cvp/v2/xml/content.xml?id=%s.xml' % path data_src = 'http://www.trutv.com/video/cvp/v2/xml/content.xml?id=%s.xml' % path
else: else:
webpage = self._download_webpage(url, video_id)
video_id = self._search_regex(
r"TTV\.TVE\.episodeId\s*=\s*'([^']+)';",
webpage, 'video id', default=video_id)
auth_required = self._search_regex(
r'TTV\.TVE\.authRequired\s*=\s*(true|false);',
webpage, 'auth required', default='false') == 'true'
data_src = 'http://www.trutv.com/tveverywhere/services/cvpXML.do?titleId=' + video_id data_src = 'http://www.trutv.com/tveverywhere/services/cvpXML.do?titleId=' + video_id
return self._extract_cvp_info( return self._extract_cvp_info(
data_src, path, { data_src, path, {
@ -32,4 +40,8 @@ class TruTVIE(TurnerBaseIE):
'media_src': 'http://androidhls-secure.cdn.turner.com/trutv/big', 'media_src': 'http://androidhls-secure.cdn.turner.com/trutv/big',
'tokenizer_src': 'http://www.trutv.com/tveverywhere/processors/services/token_ipadAdobe.do', 'tokenizer_src': 'http://www.trutv.com/tveverywhere/processors/services/token_ipadAdobe.do',
}, },
}, {
'url': url,
'site_name': 'truTV',
'auth_required': auth_required,
}) })

View file

@ -3,7 +3,7 @@ from __future__ import unicode_literals
import re import re
from .common import InfoExtractor from .adobepass import AdobePassIE
from ..compat import compat_str from ..compat import compat_str
from ..utils import ( from ..utils import (
xpath_text, xpath_text,
@ -16,11 +16,11 @@ from ..utils import (
) )
class TurnerBaseIE(InfoExtractor): class TurnerBaseIE(AdobePassIE):
def _extract_timestamp(self, video_data): def _extract_timestamp(self, video_data):
return int_or_none(xpath_attr(video_data, 'dateCreated', 'uts')) return int_or_none(xpath_attr(video_data, 'dateCreated', 'uts'))
def _extract_cvp_info(self, data_src, video_id, path_data={}): def _extract_cvp_info(self, data_src, video_id, path_data={}, ap_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)
@ -70,11 +70,14 @@ class TurnerBaseIE(InfoExtractor):
secure_path = self._search_regex(r'https?://[^/]+(.+/)', video_url, 'secure path') + '*' secure_path = self._search_regex(r'https?://[^/]+(.+/)', video_url, 'secure path') + '*'
token = tokens.get(secure_path) token = tokens.get(secure_path)
if not token: if not token:
auth = self._download_xml( query = {
secure_path_data['tokenizer_src'], video_id, query={
'path': secure_path, 'path': secure_path,
'videoId': content_id, '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=query)
error_msg = xpath_text(auth, 'error/msg') error_msg = xpath_text(auth, 'error/msg')
if error_msg: if error_msg:
raise ExtractorError(error_msg, expected=True) raise ExtractorError(error_msg, expected=True)