Skip to content

Commit

Permalink
feat(settings): Allows credentials to be stored unencrypted
Browse files Browse the repository at this point in the history
  • Loading branch information
asciidisco committed Sep 22, 2017
1 parent e009ecc commit 771a299
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 18 deletions.
3 changes: 0 additions & 3 deletions addon.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,8 @@ def router(paramstring, user, password):
"""
params = dict(parse_qsl(paramstring))
keys = params.keys()
UTILS.log(params)
UTILS.log(keys)
# settings action routes
processed = __settings_action(params=params)
UTILS.log('__settings_action ' + str(processed))
# check login
if __login_failed_action(user=user, password=password) is False:
return False
Expand Down
8 changes: 3 additions & 5 deletions addon.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="plugin.video.telekom-sport" version="1.2.0" name="Telekom Sport" provider-name="asciidisco">
<addon id="plugin.video.telekom-sport" version="1.2.1" name="Telekom Sport" provider-name="asciidisco">
<requires>
<import addon="xbmc.python" version="2.24.0"/>
<import addon="script.module.pydes" version="2.0.1"/>
Expand Down Expand Up @@ -30,9 +30,7 @@
<email>public at asciidisco dot com</email>
<source>https://github.com/asciidisco/plugin.video.telekom-sport</source>
<forum>https://www.kodinerds.net/index.php/Thread/57586-PreRelease-Telekom-Sport/</forum>
<news>v1.2.0 (2017-9-22)
- Fixes livestream playback
- Fixes playback issues with FC Bayern TV
- Improves video start time with Inputstream.Adaptive</news>
<news>v1.2.1 (2017-9-22)
- Add ability to store credentials unencrypted</news>
</extension>
</addon>
7 changes: 5 additions & 2 deletions resources/language/resource.language.de_de/strings.po
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Kodi Media Center language file
# Addon Name: Telekom Sport
# Addon id: plugin.video.telekom-sport
# Addon version: 1.2.0
# Addon version: 1.2.1
# Addon Provider: asciidisco
msgid ""
msgstr ""
Expand Down Expand Up @@ -61,7 +61,10 @@ msgctxt "#32008"
msgid "Error fetching device id"
msgstr "Device ID konnte nicht geladen werden"


msgctxt "#32009"
msgid "Match not yet available"
msgstr "Das Spiel ist zur Zeit (noch) nicht verfügbar"

msgctxt "#32010"
msgid "Encrypt credentials"
msgstr "Anmeldedaten verschlüsseln"
6 changes: 5 additions & 1 deletion resources/language/resource.language.en_gb/strings.po
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Kodi Media Center language file
# Addon Name: Telekom Sport
# Addon id: plugin.video.telekom-sport
# Addon version: 1.2.0
# Addon version: 1.2.1
# Addon Provider: asciidisco
msgid ""
msgstr ""
Expand Down Expand Up @@ -64,3 +64,7 @@ msgstr "Error fetching device id"
msgctxt "#32009"
msgid "Match not yet available"
msgstr "Match not yet available"

msgctxt "#32010"
msgid "Encrypt credentials"
msgstr "Encrypt credentials"
19 changes: 14 additions & 5 deletions resources/lib/Settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ def uniq_id(self, delay=1):
error_msg = '[%s] error: failed to get device id (%s)'
self.utils.log(error_msg % (self.addon_id, str(mac_addr)))
self.dialogs.show_storing_credentials_failed()
return False
return 'UnsafeStaticSecret'

def encode(self, data):
"""ADD ME"""
key_handle = pyDes.triple_des(
self.uniq_id(delay=2),
pyDes.CBC,
'\0\0\0\0\0\0\0\0',
"\0\0\0\0\0\0\0\0",
padmode=pyDes.PAD_PKCS5)
encrypted = key_handle.encrypt(
data=data)
Expand All @@ -50,7 +50,7 @@ def decode(self, data):
key_handle = pyDes.triple_des(
self.uniq_id(delay=2),
pyDes.CBC,
'\0\0\0\0\0\0\0\0',
"\0\0\0\0\0\0\0\0",
padmode=pyDes.PAD_PKCS5)
decrypted = key_handle.decrypt(
data=base64.b64decode(s=data))
Expand All @@ -68,15 +68,24 @@ def set_credentials(self):
addon = self.utils.get_addon()
user = self.dialogs.show_email_dialog()
password = self.dialogs.show_password_dialog()
addon.setSetting('email', self.encode(user))
addon.setSetting('password', self.encode(password))
do_encrypt = addon.getSetting('encrypt_credentials')
if do_encrypt == 'True':
_mail = self.encode(user)
_password = self.encode(password)
else:
_mail = user
_password = password
addon.setSetting('email', _mail)
addon.setSetting('password', _password)
return (user, password)

def get_credentials(self):
"""ADD ME"""
addon = self.utils.get_addon()
user = addon.getSetting('email')
password = addon.getSetting('password')
if '@' in user:
return (user, password)
return (self.decode(user), self.decode(password))

@classmethod
Expand Down
5 changes: 3 additions & 2 deletions resources/settings.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<settings>
<category label="32001">
<setting label="32033" type="bool" id="encrypt_credentials" default="true"/>
<setting id="logout" type="action" label="32002" action="RunPlugin(plugin://plugin.video.telekom-sport/?action=logout)"/>
<setting id="switch_account" type="action" label="32003" action="RunPlugin(plugin://plugin.video.telekom-sport/?action=switch_account)"/>
<setting id="email" type="text" default="" visible="false"/>
<setting id="password" type="text" default="" visible="false"/>
<setting id="settings_asked" type="bool" default="false" visible="false"/>>
<setting id="settings_asked" type="bool" default="false" visible="false"/>>
</category>
</settings>
</settings>

0 comments on commit 771a299

Please sign in to comment.