Version 0.4.1
This commit is contained in:
1 parent
97984337a5
commit
7b856bed8b
5 files changed
+88
-34
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.3.13"
|
version="0.4.1"
|
||||||
provider-name="Paco8">
|
provider-name="Paco8">
|
||||||
<requires>
|
<requires>
|
||||||
<!--- <import addon="xbmc.python" version="2.25.0"/> -->
|
<!--- <import addon="xbmc.python" version="2.25.0"/> -->
|
||||||
|
|||||||
@@ -241,6 +241,10 @@ msgctxt "#30182"
|
|||||||
msgid "Select the key file"
|
msgid "Select the key file"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
msgctxt "#30183"
|
||||||
|
msgid "Login with username"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
msgctxt "#30200"
|
msgctxt "#30200"
|
||||||
msgid "Error"
|
msgid "Error"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|||||||
@@ -241,6 +241,10 @@ msgctxt "#30182"
|
|||||||
msgid "Select the key file"
|
msgid "Select the key file"
|
||||||
msgstr "Selecciona el fichero key"
|
msgstr "Selecciona el fichero key"
|
||||||
|
|
||||||
|
msgctxt "#30183"
|
||||||
|
msgid "Login with username"
|
||||||
|
msgstr "Iniciar sesión con nombre y clave"
|
||||||
|
|
||||||
msgctxt "#30200"
|
msgctxt "#30200"
|
||||||
msgid "Error"
|
msgid "Error"
|
||||||
msgstr "Error"
|
msgstr "Error"
|
||||||
|
|||||||
+38
-26
@@ -48,6 +48,9 @@ class Movistar(object):
|
|||||||
# Cache
|
# Cache
|
||||||
self.cache = Cache(config_directory)
|
self.cache = Cache(config_directory)
|
||||||
|
|
||||||
|
# Endpoints
|
||||||
|
self.endpoints = self.get_endpoints()
|
||||||
|
|
||||||
# Access token
|
# Access token
|
||||||
self.load_key_file() # Default access_token
|
self.load_key_file() # Default access_token
|
||||||
content = self.cache.load_file('access_token.conf')
|
content = self.cache.load_file('access_token.conf')
|
||||||
@@ -56,9 +59,6 @@ class Movistar(object):
|
|||||||
#LOG('access_token: {}'.format(self.account['access_token']))
|
#LOG('access_token: {}'.format(self.account['access_token']))
|
||||||
if not self.account['access_token']: return
|
if not self.account['access_token']: return
|
||||||
|
|
||||||
# Endpoints
|
|
||||||
self.endpoints = self.get_endpoints()
|
|
||||||
|
|
||||||
# Account
|
# Account
|
||||||
data = None
|
data = None
|
||||||
content = self.cache.load('account.json')
|
content = self.cache.load('account.json')
|
||||||
@@ -155,19 +155,6 @@ class Movistar(object):
|
|||||||
#print_json(self.entitlements)
|
#print_json(self.entitlements)
|
||||||
self.logged = True
|
self.logged = True
|
||||||
|
|
||||||
def install_key_file(self, filename):
|
|
||||||
import shutil
|
|
||||||
if sys.version_info[0] > 2:
|
|
||||||
filename = bytes(filename, 'utf-8')
|
|
||||||
shutil.copyfile(filename, self.cache.config_directory + 'auth.key')
|
|
||||||
|
|
||||||
def load_key_file(self):
|
|
||||||
content = self.cache.load_file('auth.key')
|
|
||||||
if content:
|
|
||||||
data = json.loads(content)
|
|
||||||
data = json.loads(data['data'])
|
|
||||||
self.account['access_token'] = data['response']['access_token']
|
|
||||||
|
|
||||||
def get_token(self):
|
def get_token(self):
|
||||||
data = {"accountNumber": self.account['id'],
|
data = {"accountNumber": self.account['id'],
|
||||||
"userProfile": self.account['profile_id'],
|
"userProfile": self.account['profile_id'],
|
||||||
@@ -224,28 +211,33 @@ class Movistar(object):
|
|||||||
#LOG("**** open_session response: {}".format(d))
|
#LOG("**** open_session response: {}".format(d))
|
||||||
return d
|
return d
|
||||||
|
|
||||||
def login(self):
|
def login(self, username, password):
|
||||||
headers = self.net.headers.copy()
|
headers = self.net.headers.copy()
|
||||||
|
if self.account['device_id']:
|
||||||
headers['x-movistarplus-deviceid'] = self.account['device_id']
|
headers['x-movistarplus-deviceid'] = self.account['device_id']
|
||||||
headers['x-movistarplus-ui'] = '2.36.30'
|
headers['x-movistarplus-ui'] = '2.36.30'
|
||||||
headers['x-movistarplus-os'] = 'Linux88'
|
headers['x-movistarplus-os'] = 'Linux88'
|
||||||
|
|
||||||
if sys.version_info[0] < 3:
|
|
||||||
p = base64.b64decode(bytes(self.account['password']))
|
|
||||||
else:
|
|
||||||
p = base64.b64decode(bytes(self.account['password'], encoding='ascii')).decode('ascii')
|
|
||||||
|
|
||||||
data = {
|
data = {
|
||||||
'grant_type': 'password',
|
'grant_type': 'password',
|
||||||
'deviceClass': 'webplayer',
|
'deviceClass': 'webplayer',
|
||||||
'username': self.account['username'],
|
'username': username,
|
||||||
'password': p,
|
'password': password,
|
||||||
'captchaResult': '',
|
|
||||||
}
|
}
|
||||||
|
|
||||||
url = self.endpoints['token']
|
url = self.endpoints['token']
|
||||||
response = self.net.session.post(url, headers=headers, data=data)
|
response = self.net.session.post(url, headers=headers, data=data)
|
||||||
print(response.content)
|
content = response.content.decode('utf-8')
|
||||||
|
LOG(content)
|
||||||
|
success = False
|
||||||
|
try:
|
||||||
|
d = json.loads(content)
|
||||||
|
if 'access_token' in d:
|
||||||
|
success = True
|
||||||
|
self.save_key_file(d)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
return success, content
|
||||||
|
|
||||||
def authenticate(self):
|
def authenticate(self):
|
||||||
headers = self.net.headers.copy()
|
headers = self.net.headers.copy()
|
||||||
@@ -749,3 +741,23 @@ class Movistar(object):
|
|||||||
url += '&topic=IN'
|
url += '&topic=IN'
|
||||||
#LOG('vod url: {}'.format(url))
|
#LOG('vod url: {}'.format(url))
|
||||||
return url
|
return url
|
||||||
|
|
||||||
|
def install_key_file(self, filename):
|
||||||
|
import shutil
|
||||||
|
if sys.version_info[0] > 2:
|
||||||
|
filename = bytes(filename, 'utf-8')
|
||||||
|
shutil.copyfile(filename, self.cache.config_directory + 'auth.key')
|
||||||
|
|
||||||
|
def load_key_file(self):
|
||||||
|
content = self.cache.load_file('auth.key')
|
||||||
|
if content:
|
||||||
|
data = json.loads(content)
|
||||||
|
if 'response' in data:
|
||||||
|
self.account['access_token'] = data['response']['access_token']
|
||||||
|
elif 'data' in data:
|
||||||
|
data = json.loads(data['data'])
|
||||||
|
self.account['access_token'] = data['response']['access_token']
|
||||||
|
|
||||||
|
def save_key_file(self, d):
|
||||||
|
data = {'timestamp': int(time.time()*1000), 'response': d}
|
||||||
|
self.cache.save_file('auth.key', json.dumps(data, ensure_ascii=False))
|
||||||
+41
-7
@@ -369,10 +369,7 @@ def list_vod():
|
|||||||
add_menu_option(name, get_url(action='listing', name=name, url=m.get_vod_list_url(cat='kids'))) # Kids
|
add_menu_option(name, get_url(action='listing', name=name, url=m.get_vod_list_url(cat='kids'))) # Kids
|
||||||
close_folder()
|
close_folder()
|
||||||
|
|
||||||
def login_with_key():
|
def clear_session():
|
||||||
filename = xbmcgui.Dialog().browseSingle(1, addon.getLocalizedString(30182), '', '.key')
|
|
||||||
if filename:
|
|
||||||
m.install_key_file(filename)
|
|
||||||
m.cache.remove_file('access_token.conf')
|
m.cache.remove_file('access_token.conf')
|
||||||
m.cache.remove_file('account.json')
|
m.cache.remove_file('account.json')
|
||||||
m.cache.remove_file('device_id.conf')
|
m.cache.remove_file('device_id.conf')
|
||||||
@@ -380,6 +377,40 @@ def login_with_key():
|
|||||||
m.cache.remove_file('profile_id.conf')
|
m.cache.remove_file('profile_id.conf')
|
||||||
m.cache.remove_file('tokens.json')
|
m.cache.remove_file('tokens.json')
|
||||||
|
|
||||||
|
def logout():
|
||||||
|
clear_session()
|
||||||
|
m.cache.remove_file('auth.key')
|
||||||
|
|
||||||
|
def login():
|
||||||
|
def ask_credentials(username=''):
|
||||||
|
username = input_window(addon.getLocalizedString(30163), username) # Username
|
||||||
|
if username:
|
||||||
|
password = input_window(addon.getLocalizedString(30164), hidden=True) # Password
|
||||||
|
if password:
|
||||||
|
return username, password
|
||||||
|
return None, None
|
||||||
|
|
||||||
|
username, password = ask_credentials()
|
||||||
|
if username:
|
||||||
|
success, _ = m.login(username, password)
|
||||||
|
if success:
|
||||||
|
clear_session()
|
||||||
|
else:
|
||||||
|
show_notification(addon.getLocalizedString(30166)) # Failed
|
||||||
|
|
||||||
|
def login_with_key():
|
||||||
|
filename = xbmcgui.Dialog().browseSingle(1, addon.getLocalizedString(30182), '', '.key')
|
||||||
|
if filename:
|
||||||
|
m.install_key_file(filename)
|
||||||
|
clear_session()
|
||||||
|
|
||||||
|
def list_users():
|
||||||
|
open_folder(addon.getLocalizedString(30160)) # Change user
|
||||||
|
add_menu_option(addon.getLocalizedString(30183), get_url(action='login')) # Login with username
|
||||||
|
add_menu_option(addon.getLocalizedString(30181), get_url(action='login_with_key')) # Login with key
|
||||||
|
add_menu_option(addon.getLocalizedString(30150), get_url(action='logout')) # Close session
|
||||||
|
close_folder()
|
||||||
|
|
||||||
def router(paramstring):
|
def router(paramstring):
|
||||||
"""
|
"""
|
||||||
Router function that calls other functions
|
Router function that calls other functions
|
||||||
@@ -405,8 +436,12 @@ def router(paramstring):
|
|||||||
list_profiles(params)
|
list_profiles(params)
|
||||||
elif params['action'] == 'login_with_key':
|
elif params['action'] == 'login_with_key':
|
||||||
login_with_key()
|
login_with_key()
|
||||||
|
elif params['action'] == 'login':
|
||||||
|
login()
|
||||||
|
elif params['action'] == 'user':
|
||||||
|
list_users()
|
||||||
elif params['action'] == 'logout':
|
elif params['action'] == 'logout':
|
||||||
pass
|
logout()
|
||||||
elif params['action'] == 'epg':
|
elif params['action'] == 'epg':
|
||||||
list_epg(params)
|
list_epg(params)
|
||||||
elif params['action'] == 'wishlist':
|
elif params['action'] == 'wishlist':
|
||||||
@@ -438,9 +473,8 @@ def router(paramstring):
|
|||||||
add_menu_option(addon.getLocalizedString(30111), get_url(action='vod')) # VOD
|
add_menu_option(addon.getLocalizedString(30111), get_url(action='vod')) # VOD
|
||||||
add_menu_option(addon.getLocalizedString(30180), get_url(action='profiles')) # Profiles
|
add_menu_option(addon.getLocalizedString(30180), get_url(action='profiles')) # Profiles
|
||||||
add_menu_option(addon.getLocalizedString(30108), get_url(action='devices')) # Devices
|
add_menu_option(addon.getLocalizedString(30108), get_url(action='devices')) # Devices
|
||||||
#add_menu_option(addon.getLocalizedString(30150), get_url(action='logout')) # Close session
|
|
||||||
|
|
||||||
add_menu_option(addon.getLocalizedString(30181), get_url(action='login_with_key')) # Login with key
|
add_menu_option(addon.getLocalizedString(30160), get_url(action='user')) # Accounts
|
||||||
close_folder(cacheToDisc=False)
|
close_folder(cacheToDisc=False)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user