Version 0.9.15
This commit is contained in:
1 parent
3ff31353c0
commit
fe2f12b714
6 files changed
+87
-22
No files matched your search
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||||
<addon id="plugin.video.movistarplus"
|
<addon id="plugin.video.movistarplus"
|
||||||
name="Movistar+"
|
name="Movistar+"
|
||||||
version="0.9.14"
|
version="0.9.15"
|
||||||
provider-name="Paco8">
|
provider-name="Paco8">
|
||||||
<requires>
|
<requires>
|
||||||
<!--- <import addon="xbmc.python" version="2.25.0"/> -->
|
<!--- <import addon="xbmc.python" version="2.25.0"/> -->
|
||||||
|
|||||||
@@ -422,6 +422,22 @@ msgctxt "#30192"
|
|||||||
msgid "Use a {} account"
|
msgid "Use a {} account"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
msgctxt "#30193"
|
||||||
|
msgid "Select the credentials file"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
msgctxt "#30194"
|
||||||
|
msgid "Select a folder to save the credentials file"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
msgctxt "#30195"
|
||||||
|
msgid "Export credentials"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
msgctxt "#30196"
|
||||||
|
msgid "Import credentials"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
msgctxt "#30200"
|
msgctxt "#30200"
|
||||||
msgid "Error"
|
msgid "Error"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|||||||
@@ -399,6 +399,22 @@ msgctxt "#30192"
|
|||||||
msgid "Use a {} account"
|
msgid "Use a {} account"
|
||||||
msgstr "Usar una cuenta de {}"
|
msgstr "Usar una cuenta de {}"
|
||||||
|
|
||||||
|
msgctxt "#30193"
|
||||||
|
msgid "Select the credentials file"
|
||||||
|
msgstr "Selecciona el fichero de credenciales"
|
||||||
|
|
||||||
|
msgctxt "#30194"
|
||||||
|
msgid "Select a folder to save the credentials file"
|
||||||
|
msgstr "Seleccion una carpeta donde guardar las credenciales"
|
||||||
|
|
||||||
|
msgctxt "#30195"
|
||||||
|
msgid "Export credentials"
|
||||||
|
msgstr "Exportar credenciales"
|
||||||
|
|
||||||
|
msgctxt "#30196"
|
||||||
|
msgid "Import credentials"
|
||||||
|
msgstr "Importar credenciales"
|
||||||
|
|
||||||
msgctxt "#30200"
|
msgctxt "#30200"
|
||||||
msgid "Error"
|
msgid "Error"
|
||||||
msgstr "Error"
|
msgstr "Error"
|
||||||
|
|||||||
+31
-15
@@ -116,7 +116,7 @@ class Movistar(object):
|
|||||||
if content:
|
if content:
|
||||||
data = json.loads(content)
|
data = json.loads(content)
|
||||||
if not data or 'ofertas' not in data:
|
if not data or 'ofertas' not in data:
|
||||||
data = self.authenticate()
|
data = self.get_account_info()
|
||||||
if not data or 'ofertas' not in data: return
|
if not data or 'ofertas' not in data: return
|
||||||
self.cache.save_file('account.json', json.dumps(data, ensure_ascii=False))
|
self.cache.save_file('account.json', json.dumps(data, ensure_ascii=False))
|
||||||
self.account['id'] = data['ofertas'][0]['accountNumber']
|
self.account['id'] = data['ofertas'][0]['accountNumber']
|
||||||
@@ -139,7 +139,7 @@ class Movistar(object):
|
|||||||
if not reuse_devices:
|
if not reuse_devices:
|
||||||
LOG('not reusing devices')
|
LOG('not reusing devices')
|
||||||
if not self.account['device_id']:
|
if not self.account['device_id']:
|
||||||
self.account['device_id'] = self.new_device_id()
|
self.account['device_id'] = self.request_device_id()
|
||||||
self.cache.save_file('device_id.conf', self.account['device_id'])
|
self.cache.save_file('device_id.conf', self.account['device_id'])
|
||||||
else:
|
else:
|
||||||
LOG('reusing devices')
|
LOG('reusing devices')
|
||||||
@@ -159,7 +159,7 @@ class Movistar(object):
|
|||||||
self.account['device_id'] = wp_device
|
self.account['device_id'] = wp_device
|
||||||
else:
|
else:
|
||||||
LOG('device not found, registering new device')
|
LOG('device not found, registering new device')
|
||||||
self.account['device_id'] = self.new_device_id()
|
self.account['device_id'] = self.request_device_id()
|
||||||
self.cache.save_file('device_id.conf', self.account['device_id'])
|
self.cache.save_file('device_id.conf', self.account['device_id'])
|
||||||
LOG('device_id: {}'. format(self.account['device_id']))
|
LOG('device_id: {}'. format(self.account['device_id']))
|
||||||
|
|
||||||
@@ -293,7 +293,7 @@ class Movistar(object):
|
|||||||
pass
|
pass
|
||||||
return success, content
|
return success, content
|
||||||
|
|
||||||
def authenticate(self):
|
def get_account_info(self):
|
||||||
headers = self.net.headers.copy()
|
headers = self.net.headers.copy()
|
||||||
headers['Content-Type'] = 'application/x-www-form-urlencoded'
|
headers['Content-Type'] = 'application/x-www-form-urlencoded'
|
||||||
#headers['x-movistarplus-deviceid'] = self.account['device_id']
|
#headers['x-movistarplus-deviceid'] = self.account['device_id']
|
||||||
@@ -302,9 +302,9 @@ class Movistar(object):
|
|||||||
headers['Authorization'] = 'Bearer ' + self.account['access_token']
|
headers['Authorization'] = 'Bearer ' + self.account['access_token']
|
||||||
url = self.endpoints['autenticacion_tk'].format(deviceType=self.dplayer) + '?_=' + str(int(time.time()*1000))
|
url = self.endpoints['autenticacion_tk'].format(deviceType=self.dplayer) + '?_=' + str(int(time.time()*1000))
|
||||||
#LOG(url)
|
#LOG(url)
|
||||||
#LOG('authenticate: headers: {}'.format(headers))
|
#LOG('get_account_info: headers: {}'.format(headers))
|
||||||
data = self.net.load_data(url, headers)
|
data = self.net.load_data(url, headers)
|
||||||
#LOG('authenticate: data: {}'.format(data))
|
#LOG('get_account_info: data: {}'.format(data))
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def change_device(self, id):
|
def change_device(self, id):
|
||||||
@@ -348,7 +348,7 @@ class Movistar(object):
|
|||||||
def unregister_device(self):
|
def unregister_device(self):
|
||||||
return self.delete_device(self.account['device_id'])
|
return self.delete_device(self.account['device_id'])
|
||||||
|
|
||||||
def new_device_id(self):
|
def request_device_id(self):
|
||||||
headers = self.net.headers.copy()
|
headers = self.net.headers.copy()
|
||||||
headers['Content-Type'] = 'application/json'
|
headers['Content-Type'] = 'application/json'
|
||||||
#headers['x-movistarplus-ui'] = '2.36.30'
|
#headers['x-movistarplus-ui'] = '2.36.30'
|
||||||
@@ -361,10 +361,11 @@ class Movistar(object):
|
|||||||
content = response.content.decode('utf-8')
|
content = response.content.decode('utf-8')
|
||||||
return content.strip('"')
|
return content.strip('"')
|
||||||
|
|
||||||
#import random
|
#def generate_device_id(self):
|
||||||
#s = ''
|
# import random
|
||||||
#for _ in range(0, 32): s += random.choice('abcdef0123456789')
|
# s = ''
|
||||||
#return s
|
# for _ in range(0, 32): s += random.choice('abcdef0123456789')
|
||||||
|
# return s
|
||||||
|
|
||||||
def delete_device(self, device_id):
|
def delete_device(self, device_id):
|
||||||
headers = self.net.headers.copy()
|
headers = self.net.headers.copy()
|
||||||
@@ -1281,6 +1282,16 @@ class Movistar(object):
|
|||||||
data = {'timestamp': int(time.time()*1000), 'response': d}
|
data = {'timestamp': int(time.time()*1000), 'response': d}
|
||||||
self.cache.save_file('auth.key', json.dumps(data, ensure_ascii=False))
|
self.cache.save_file('auth.key', json.dumps(data, ensure_ascii=False))
|
||||||
|
|
||||||
|
def import_credentials(self, filename):
|
||||||
|
if sys.version_info[0] > 2:
|
||||||
|
filename = bytes(filename, 'utf-8')
|
||||||
|
shutil.copyfile(filename, self.cache.config_directory + 'credentials.json')
|
||||||
|
|
||||||
|
def export_credentials(self, filename):
|
||||||
|
if sys.version_info[0] > 2:
|
||||||
|
filename = bytes(filename, 'utf-8')
|
||||||
|
shutil.copyfile(self.cache.config_directory + 'credentials.json', filename)
|
||||||
|
|
||||||
def delete_session_files(self):
|
def delete_session_files(self):
|
||||||
for f in ['access_token.conf', 'account.json', 'device_id.conf', 'devices.json', 'profile_id.conf', 'tokens.json', 'channels2.json', 'channels_UHD.json', 'channels_HD.json', 'epg2.json', 'epg_UHD.json', 'epg_HD.json']:
|
for f in ['access_token.conf', 'account.json', 'device_id.conf', 'devices.json', 'profile_id.conf', 'tokens.json', 'channels2.json', 'channels_UHD.json', 'channels_HD.json', 'epg2.json', 'epg_UHD.json', 'epg_HD.json']:
|
||||||
self.cache.remove_file(f)
|
self.cache.remove_file(f)
|
||||||
@@ -1464,9 +1475,11 @@ class Movistar(object):
|
|||||||
else:
|
else:
|
||||||
return '', ''
|
return '', ''
|
||||||
|
|
||||||
def get_token_expire_date(self, token):
|
def get_token_properties(self, token=None):
|
||||||
from .b64 import decode_base64
|
from .b64 import decode_base64
|
||||||
res = 0
|
if not token:
|
||||||
|
token = self.account['access_token']
|
||||||
|
data = None
|
||||||
try:
|
try:
|
||||||
l = token.split('.')
|
l = token.split('.')
|
||||||
if len(l) > 1:
|
if len(l) > 1:
|
||||||
@@ -1474,10 +1487,13 @@ class Movistar(object):
|
|||||||
l[1] += '=' * (4 - padding) if padding != 0 else ''
|
l[1] += '=' * (4 - padding) if padding != 0 else ''
|
||||||
s = decode_base64(l[1])
|
s = decode_base64(l[1])
|
||||||
data = json.loads(s)
|
data = json.loads(s)
|
||||||
res = data['exp']
|
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
return res
|
return data
|
||||||
|
|
||||||
|
def get_token_expire_date(self, token):
|
||||||
|
data = self.get_token_properties(token)
|
||||||
|
return data.get('exp', 0)
|
||||||
|
|
||||||
def get_accounts(self):
|
def get_accounts(self):
|
||||||
accounts = []
|
accounts = []
|
||||||
|
|||||||
+21
-4
@@ -221,9 +221,9 @@ def play(params):
|
|||||||
subpaths.append(filename_srt)
|
subpaths.append(filename_srt)
|
||||||
play_item.setSubtitles(subpaths)
|
play_item.setSubtitles(subpaths)
|
||||||
|
|
||||||
if True:
|
#if True:
|
||||||
m.unregister_device()
|
# m.unregister_device()
|
||||||
m.register_device()
|
# m.register_device()
|
||||||
|
|
||||||
xbmcplugin.setResolvedUrl(_handle, True, listitem=play_item)
|
xbmcplugin.setResolvedUrl(_handle, True, listitem=play_item)
|
||||||
|
|
||||||
@@ -647,6 +647,16 @@ def export_key():
|
|||||||
if directory:
|
if directory:
|
||||||
m.export_key_file(directory + 'movistarplus.key')
|
m.export_key_file(directory + 'movistarplus.key')
|
||||||
|
|
||||||
|
def import_credentials():
|
||||||
|
filename = xbmcgui.Dialog().browseSingle(1, addon.getLocalizedString(30193), '', '.json')
|
||||||
|
if filename:
|
||||||
|
m.import_credentials(filename)
|
||||||
|
|
||||||
|
def export_credentials():
|
||||||
|
directory = xbmcgui.Dialog().browseSingle(0, addon.getLocalizedString(30194), '')
|
||||||
|
if directory:
|
||||||
|
m.export_credentials(os.path.join(directory, 'credenciales.json'))
|
||||||
|
|
||||||
def select_account(id, name):
|
def select_account(id, name):
|
||||||
m.switch_account(id)
|
m.switch_account(id)
|
||||||
open_folder(name)
|
open_folder(name)
|
||||||
@@ -656,7 +666,10 @@ def select_account(id, name):
|
|||||||
if os.path.exists(os.path.join(m.cache.config_directory, 'auth.key')):
|
if os.path.exists(os.path.join(m.cache.config_directory, 'auth.key')):
|
||||||
add_menu_option(addon.getLocalizedString(30184), get_url(action='export_key')) # Export key
|
add_menu_option(addon.getLocalizedString(30184), get_url(action='export_key')) # Export key
|
||||||
add_menu_option(addon.getLocalizedString(30150), get_url(action='logout')) # Close session
|
add_menu_option(addon.getLocalizedString(30150), get_url(action='logout')) # Close session
|
||||||
close_folder()
|
add_menu_option(addon.getLocalizedString(30196), get_url(action='import_credentials'))
|
||||||
|
if os.path.exists(os.path.join(m.cache.config_directory, 'credentials.json')):
|
||||||
|
add_menu_option(addon.getLocalizedString(30195), get_url(action='export_credentials'))
|
||||||
|
close_folder(cacheToDisc=False)
|
||||||
|
|
||||||
def list_accounts(params):
|
def list_accounts(params):
|
||||||
LOG('list_accounts: {}'.format(params))
|
LOG('list_accounts: {}'.format(params))
|
||||||
@@ -779,6 +792,10 @@ def router(paramstring):
|
|||||||
login()
|
login()
|
||||||
elif params['action'] == 'export_key':
|
elif params['action'] == 'export_key':
|
||||||
export_key()
|
export_key()
|
||||||
|
elif params['action'] == 'export_credentials':
|
||||||
|
export_credentials()
|
||||||
|
elif params['action'] == 'import_credentials':
|
||||||
|
import_credentials()
|
||||||
elif params['action'] == 'select_account':
|
elif params['action'] == 'select_account':
|
||||||
select_account(params['id'], params['name'])
|
select_account(params['id'], params['name'])
|
||||||
elif params['action'] == 'accounts':
|
elif params['action'] == 'accounts':
|
||||||
|
|||||||
@@ -217,12 +217,12 @@ class RequestHandler(BaseHTTPRequestHandler):
|
|||||||
LOG('license response: {}'.format(license_data))
|
LOG('license response: {}'.format(license_data))
|
||||||
d = try_load_json(license_data)
|
d = try_load_json(license_data)
|
||||||
if d and 'errorCode' in d:
|
if d and 'errorCode' in d:
|
||||||
|
from .gui import show_notification
|
||||||
|
show_notification('Error {}: {}'.format(d['errorCode'], d['message']))
|
||||||
if d['errorCode'] == 4027:
|
if d['errorCode'] == 4027:
|
||||||
if not reregister_needed and addon.getSettingBool('reregister'):
|
if not reregister_needed and addon.getSettingBool('reregister'):
|
||||||
reregister_needed = True
|
reregister_needed = True
|
||||||
continue
|
continue
|
||||||
from .gui import show_notification
|
|
||||||
show_notification('Error {}: {}'.format(d['errorCode'], d['message']))
|
|
||||||
else:
|
else:
|
||||||
LOG('license response: {}'.format(encode_base64(license_data)))
|
LOG('license response: {}'.format(encode_base64(license_data)))
|
||||||
break
|
break
|
||||||
|
|||||||
Reference in new issue
Block a user