diff --git a/addon.xml b/addon.xml index 07fc2fd..82a5388 100644 --- a/addon.xml +++ b/addon.xml @@ -1,7 +1,7 @@ diff --git a/resources/lib/endpoints.py b/resources/lib/endpoints.py index e6175d8..254d26d 100644 --- a/resources/lib/endpoints.py +++ b/resources/lib/endpoints.py @@ -87,6 +87,7 @@ endpoints = { "renovacion_hztoken": "https://clientservices.dof6.com/movistarplus/{deviceType}/mediaPlayers/{DEVICEID}/hz-token", "keepAliveStream": "https://alkasvaspub.imagenio.telefonica.net/asvas/ccs/{PID}/{deviceCode}/{PLAYREADYID}/Session/{SessionID}", "renovacion_ssptoken": "https://clientservices.dof6.com/movistarplus/{deviceType}/accounts/{ACCOUNTNUMBER}/ssp-token?mediaPlayerId={DEVICEID}", + "renovacion_cdntoken2": "https://lite.dof6.com/tcdnidserver/{ACCOUNTNUMBER}/devices/webplayer/cdn/token/refresh", "config": "https://ottcache.dof6.com/movistarplus/{origin}/webplayer/{profile}/configuration/config?format=json&uisegment={uisegment}", "registro": "https://www.movistar.es/particulares/ver-tv/contenidos/yomvi?origen=activar", "consulta_producto": "https://clientservices.dof6.com/movistarplus/upselling/{deviceType}/{PLAYREADYID}/contents/{contents}/{contentId}/subscription?mdrm={mdrm}", diff --git a/resources/lib/movistar.py b/resources/lib/movistar.py index a3c8d05..933c558 100644 --- a/resources/lib/movistar.py +++ b/resources/lib/movistar.py @@ -394,6 +394,13 @@ class Movistar(object): content = response.content.decode('utf-8') return content + def get_cdntoken(self): + headers = self.net.headers.copy() + headers['Authorization'] = 'Bearer ' + self.account['access_token'] + url = self.endpoints['renovacion_cdntoken2'].format(ACCOUNTNUMBER=self.account['id']) + data = self.net.post_data(url, None, headers) + return data.get('access_token') + def get_profiles(self): headers = self.net.headers.copy() headers['X-HZId'] = self.account['session_token'] diff --git a/resources/lib/plugin.py b/resources/lib/plugin.py index b896188..acbf8e3 100644 --- a/resources/lib/plugin.py +++ b/resources/lib/plugin.py @@ -104,6 +104,12 @@ def play(params): headers += '&Origin=https://ver.movistarplus.es&Connection=keep-alive' headers += '&Host=wv-ottlic-f3.imagenio.telefonica.net' + manifest_headers = 'User-Agent=Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:88.0) Gecko/20100101 Firefox/88.0' + if stype == 'tv': + cdn_token = m.get_cdntoken() + LOG('cdn_token: {}'.format(cdn_token)) + manifest_headers += '&x-tcdn-token=' + cdn_token + license_url = 'https://wv-ottlic-f3.imagenio.telefonica.net/TFAESP/wvls/contentlicenseservice/v1/licenses' certificate = ( 'CsECCAMSEBcFuRfMEgSGiwYzOi93KowYgrSCkgUijgIwggEKAoIBAQCZ7Vs7Mn2rXiTvw7YqlbWY' @@ -135,7 +141,8 @@ def play(params): play_item.setProperty('inputstream.adaptive.license_key', license_url) else: play_item.setProperty('inputstream.adaptive.license_key', '{}|{}&nv-authorizations={}|R{{SSM}}|'.format(license_url, headers, token)) - play_item.setProperty('inputstream.adaptive.stream_headers', 'User-Agent=Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:88.0) Gecko/20100101 Firefox/88.0') + play_item.setProperty('inputstream.adaptive.stream_headers', manifest_headers) + play_item.setProperty('inputstream.adaptive.manifest_headers', manifest_headers) # Kodi 21 play_item.setProperty('inputstream.adaptive.server_certificate', certificate) #play_item.setProperty('inputstream.adaptive.license_flags', 'persistent_storage') #play_item.setProperty('inputstream.adaptive.license_flags', 'force_secure_decoder') diff --git a/resources/lib/proxy.py b/resources/lib/proxy.py index 4cef879..d36467c 100644 --- a/resources/lib/proxy.py +++ b/resources/lib/proxy.py @@ -88,7 +88,12 @@ class RequestHandler(BaseHTTPRequestHandler): pos = path.find('=') url = path[pos+1:] LOG('url: {}'.format(url)) - response = session.get(url, allow_redirects=True) + #LOG('request headers: {}'.format(self.headers)) + additional_headers = {} + if 'x-tcdn-token' in self.headers: + additional_headers['x-tcdn-token'] = self.headers['x-tcdn-token'] + #LOG('additional_headers: {}'.format(additional_headers)) + response = session.get(url, allow_redirects=True, headers=additional_headers) LOG('headers: {}'.format(response.headers)) baseurl = os.path.dirname(response.url) LOG('baseurl: {}'.format(baseurl))