Version 0.8.4

This commit is contained in:
Paco8 committed 2023-12-22 14:13:05 +01:00
1 parent 683ba9da45
commit 18d7f85b43
4 files changed
+37 -28

No files matched your search

+1 -1
View File
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="plugin.video.movistarplus"
name="Movistar+"
version="0.8.3"
version="0.8.4"
provider-name="Paco8">
<requires>
<!--- <import addon="xbmc.python" version="2.25.0"/> -->
+29 -22
View File
@@ -91,23 +91,13 @@ class Movistar(object):
self.account['device_id'] = self.cache.load_file('device_id.conf')
if self.account['device_id']:
self.account['device_id'] = self.account['device_id'].strip('"')
else:
# Create new device
if not reuse_devices:
LOG('not reusing devices')
if not self.account['device_id']:
self.account['device_id'] = self.new_device_id()
self.cache.save_file('device_id.conf', self.account['device_id'])
# Check if device is registered
device_list = self.get_devices()
found_device = False
for device in device_list:
if device['id'] == self.account['device_id']:
found_device = True
break
if not found_device:
LOG('device not found, trying to register device')
self.register_device()
device_list = self.get_devices(use_cache=False) # To store the updated list in cache
else:
LOG('reusing devices')
# Check if device is registered
@@ -127,13 +117,11 @@ class Movistar(object):
else:
LOG('device not found, registering new device')
self.account['device_id'] = self.new_device_id()
self.register_device()
device_list = self.get_devices(use_cache=False) # To store the updated list in cache
self.cache.save_file('device_id.conf', self.account['device_id'])
LOG('device_id: {}'. format(self.account['device_id']))
# Tokens
content = self.cache.load('tokens.json', 3)
content = self.cache.load('tokens.json', 60)
if content:
data = json.loads(content)
else:
@@ -295,16 +283,11 @@ class Movistar(object):
self.cache.save_file('device_id.conf', self.account['device_id'])
self.cache.remove_file('tokens.json')
def get_devices(self, use_cache=True):
content = self.cache.load('devices.json', 3)
if use_cache and content:
data = json.loads(content)
else:
def get_devices(self):
headers = self.net.headers.copy()
headers['Authorization'] = 'Bearer ' + self.account['access_token']
url = self.endpoints['obtenerdipositivos'].format(ACCOUNTNUMBER=self.account['id'])
data = self.net.load_data(url, headers)
self.cache.save_file('devices.json', json.dumps(data, ensure_ascii=False))
#print_json(data)
if not isinstance(data, list): return []
res = []
@@ -403,13 +386,37 @@ class Movistar(object):
data = self.net.post_data(url, None, headers)
return data.get('access_token')
def get_session_token(self):
data = {"accountNumber": self.account['id'],
"sessionUserProfile": self.account['profile_id'],
"streamMiscellanea":"HTTPS",
"deviceType":"WP_OTT",
"deviceManufacturerProduct":"Firefox",
"streamDRM":"Widevine",
"streamFormat":"DASH",
}
headers = self.net.headers.copy()
headers['Content-Type'] = 'application/json'
headers['Authorization'] = 'Bearer ' + self.account['access_token']
url = self.endpoints['renovacion_hztoken'].format(deviceType='webplayer', DEVICEID=self.account['device_id'])
data = self.net.post_data(url, json.dumps(data), headers)
return data.get('homeZoneID')
def get_ssp_token(self):
headers = self.net.headers.copy()
headers['Content-Type'] = 'application/json'
headers['Authorization'] = 'Bearer ' + self.account['access_token']
url = self.endpoints['renovacion_ssptoken'].format(deviceType='webplayer', ACCOUNTNUMBER=self.account['id'], DEVICEID=self.account['device_id'])
data = self.net.post_data(url, '', headers)
return data.get('access_token')
def get_profiles(self):
headers = self.net.headers.copy()
headers['X-HZId'] = self.account['session_token']
url = self.endpoints['listaperfiles']
data = self.net.load_data(url, headers=headers)
res = []
for d in data['items']:
for d in data.get('items', []):
p = {}
p['id'] = d['id']
p['name'] = d['name']
+4 -4
View File
@@ -69,6 +69,8 @@ def play(params):
session_opened = False
if addon.getSettingBool('open_session') or stype == 'vod':
hz_token = m.get_session_token()
if hz_token: session_token = hz_token
d = m.open_session(params['session_request'], session_token)
session_opened = True
LOG('Open session: d: {}'.format(d))
@@ -105,8 +107,8 @@ def play(params):
headers += '&Referer=https://ver.movistarplus.es/'
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))
@@ -144,9 +146,7 @@ def play(params):
else:
play_item.setProperty('inputstream.adaptive.license_key', '{}|{}&nv-authorizations={}|R{{SSM}}|'.format(license_url, headers, token))
if kodi_version < 20:
play_item.setProperty('inputstream.adaptive.stream_headers', manifest_headers)
else:
play_item.setProperty('inputstream.adaptive.manifest_headers', manifest_headers)
play_item.setProperty('inputstream.adaptive.server_certificate', certificate)
@@ -351,7 +351,7 @@ def add_videos(category, ctype, videos, ref=None, url_next=None, url_prev=None,
def list_devices(params):
LOG('list_devices: params: {}'.format(params))
devices = m.get_devices(False)
devices = m.get_devices()
if 'id' in params:
if params['name'] == 'select':
+3 -1
View File
@@ -143,9 +143,11 @@ class RequestHandler(BaseHTTPRequestHandler):
else:
self.send_response(404)
self.end_headers()
except Exception:
except Exception as e:
self.send_response(500)
self.end_headers()
LOG('Exception error: {}'.format(str(e)))
def do_POST(self):
"""Handle http post requests, used for license"""