kodi-altnet-wifi/addon.py
Benjamin Collet 85c7cfd213 Cleanup
2017-07-22 15:50:49 +02:00

28 lines
745 B
Python

import xbmcaddon
import xbmcgui
import mysql.connector
addon = xbmcaddon.Addon()
addonname = addon.getAddonInfo('name')
ssid = addon.getSetting('ssid')
bdd_host = addon.getSetting('host')
bdd_user = addon.getSetting('username')
bdd_pass = addon.getSetting('password')
bdd_base = addon.getSetting('database')
cnx = mysql.connector.connect(user=bdd_user, password=bdd_pass,
host=bdd_host, database=bdd_base)
cursor = cnx.cursor()
query = ("SELECT password FROM alt_guest_wifi "
"WHERE ssid LIKE \"%s\" LIMIT 1") % ssid
cursor.execute(query)
row = cursor.fetchone()
cursor.close()
cnx.close()
line = "This week's password for %s is:\n\n%s" % (ssid, row[0])
xbmcgui.Dialog().ok(addonname, line)