1
0
mirror of https://codeberg.org/polarisfm/youtube-dl synced 2024-11-16 06:34:31 +01:00

[adobepass] check for authz_token expiration(#10527)

This commit is contained in:
Remita Amine 2016-09-01 22:14:40 +01:00
parent b207d5ebd4
commit 6150502e47

View File

@ -37,6 +37,10 @@ class AdobePassIE(InfoExtractor):
return self._search_regex( return self._search_regex(
'<%s>(.+?)</%s>' % (tag, tag), xml_str, tag) '<%s>(.+?)</%s>' % (tag, tag), xml_str, tag)
def is_expired(token, date_ele):
token_expires = unified_timestamp(re.sub(r'[_ ]GMT', '', xml_text(token, date_ele)))
return token_expires and token_expires <= int(time.time())
mvpd_headers = { mvpd_headers = {
'ap_42': 'anonymous', 'ap_42': 'anonymous',
'ap_11': 'Linux i686', 'ap_11': 'Linux i686',
@ -47,11 +51,8 @@ class AdobePassIE(InfoExtractor):
guid = xml_text(resource, 'guid') guid = xml_text(resource, 'guid')
requestor_info = self._downloader.cache.load('mvpd', requestor_id) or {} requestor_info = self._downloader.cache.load('mvpd', requestor_id) or {}
authn_token = requestor_info.get('authn_token') authn_token = requestor_info.get('authn_token')
if authn_token: if authn_token and is_expired(authn_token, 'simpleTokenExpires'):
token_expires = unified_timestamp(re.sub(r'[_ ]GMT', '', xml_text(authn_token, 'simpleTokenExpires')))
if token_expires and token_expires <= int(time.time()):
authn_token = None authn_token = None
requestor_info = {}
if not authn_token: if not authn_token:
# TODO add support for other TV Providers # TODO add support for other TV Providers
mso_id = 'DTV' mso_id = 'DTV'
@ -98,6 +99,8 @@ class AdobePassIE(InfoExtractor):
self._downloader.cache.store('mvpd', requestor_id, requestor_info) self._downloader.cache.store('mvpd', requestor_id, requestor_info)
authz_token = requestor_info.get(guid) authz_token = requestor_info.get(guid)
if authz_token and is_expired(authz_token, 'simpleTokenTTL'):
authz_token = None
if not authz_token: if not authz_token:
authorize = self._download_webpage( authorize = self._download_webpage(
self._SERVICE_PROVIDER_TEMPLATE % 'authorize', video_id, self._SERVICE_PROVIDER_TEMPLATE % 'authorize', video_id,