# -*- coding: utf-8 -*- import xbmcgui, xbmcaddon, sys, xbmc, os, time, json PY2 = sys.version_info[0] == 2 PY3 = sys.version_info[0] == 3 if PY2: from urllib import urlencode, unquote_plus from urlparse import parse_qs, parse_qsl, urlparse translatePath = xbmc.translatePath else: from urllib.parse import urlencode, unquote_plus, parse_qs, parse_qsl, urlparse import xbmcvfs translatePath = xbmcvfs.translatePath unicode = str def py2dec(msg): if PY2: return msg.decode("utf-8") return msg def py3dec(msg): if PY3: return msg.decode("utf-8") return msg def py2enc(msg): if PY2: return msg.encode("utf-8") return msg addon = xbmcaddon.Addon() addonInfo = addon.getAddonInfo addonID = addonInfo('id') addonpath = py2dec(translatePath(addonInfo('profile'))) if not os.path.exists(addonpath): os.makedirs(addonpath) def handle(): return int(sys.argv[1]) def selectDialog(list, heading=None, multiselect = False): if heading == 'default' or heading is None: heading = xbmcaddon.Addon().getAddonInfo('name') if multiselect: return xbmcgui.Dialog().multiselect(str(heading), list) return xbmcgui.Dialog().select(str(heading), list) home = xbmcgui.Window(10000) def set_cache(key, value, timeout=300): data={"sigValidUntil": int(time.time()) +timeout,"value": value} home.setProperty(key, json.dumps(data)) def get_cache(key): keyfile = home.getProperty(key) if keyfile: r = json.loads(keyfile) if r.get('sigValidUntil', 0) > int(time.time()): return r.get('value') home.clearProperty(key) return def getAuthSignature(): signfile = get_cache('signfile') if signfile: return signfile vec = {"vec": "9frjpxPjxSNilxJPCJ0XGYs6scej3dW/h/VWlnKUiLSG8IP7mfyDU7NirOlld+VtCKGj03XjetfliDMhIev7wcARo+YTU8KPFuVQP9E2DVXzY2BFo1NhE6qEmPfNDnm74eyl/7iFJ0EETm6XbYyz8IKBkAqPN/Spp3PZ2ulKg3QBSDxcVN4R5zRn7OsgLJ2CNTuWkd/h451lDCp+TtTuvnAEhcQckdsydFhTZCK5IiWrrTIC/d4qDXEd+GtOP4hPdoIuCaNzYfX3lLCwFENC6RZoTBYLrcKVVgbqyQZ7DnLqfLqvf3z0FVUWx9H21liG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eic2U1w1JpSEjdH/u/hXrWKSMWAxaj34uQnMuWxPZEXoVxzGyuUbroXRfkhzpqmqqqOcypjsWPdq5BOUGL/Riwjm6yMI0x9kbO8+VoQ6RYfjAbxNriZ1cQ+AW1fqEgnRWXmjt4Z1M0ygUBi8w71bDML1YG6UHeC2cJ2CCCxSrfycKQhpSdI1QIuwd2eyIpd4LgwrMiY3xNWreAF+qobNxvE7ypKTISNrz0iYIhU0aKNlcGwYd0FXIRfKVBzSBe4MRK2pGLDNO6ytoHxvJweZ8h1XG8RWc4aB5gTnB7Tjiqym4b64lRdj1DPHJnzD4aqRixpXhzYzWVDN2kONCR5i2quYbnVFN4sSfLiKeOwKX4JdmzpYixNZXjLkG14seS6KR0Wl8Itp5IMIWFpnNokjRH76RYRZAcx0jP0V5/GfNNTi5QsEU98en0SiXHQGXnROiHpRUDXTl8FmJORjwXc0AjrEMuQ2FDJDmAIlKUSLhjbIiKw3iaqp5TVyXuz0ZMYBhnqhcwqULqtFSuIKpaW8FgF8QJfP2frADf4kKZG1bQ99MrRrb2A="} url = 'https://www.vavoo.tv/api/box/ping2' import requests req = requests.post(url, data=vec).json() signed = req['response'].get('signed') set_cache('signfile', signed) return signed def log(*args): msg="" for arg in args: msg += repr(arg) xbmc.log(msg, xbmc.LOGINFO) def yesno(heading, line1, line2='', line3='', nolabel='', yeslabel=''): if PY3:return xbmcgui.Dialog().yesno(heading, line1+"\n"+line2+"\n"+line3, nolabel, yeslabel) else:return xbmcgui.Dialog().yesno(heading, line1,line2,line3, nolabel, yeslabel) def ok(heading, line1, line2='', line3=''): if PY3:return xbmcgui.Dialog().ok(heading, line1+"\n"+line2+"\n"+line3) else:return xbmcgui.Dialog().ok(heading, line1,line2,line3) def getIcon(name): return py2dec(translatePath('special://home/addons/' + addonID + '/resources/' + name + '.png')) def convertUrlParameter(param): param = param.split('?', 1)[1] params = parse_qs(param) params = {key:value[0] if len(value) == 1 else value for key, value in list(params.items())} return params def convertPluginParams(params): p = [] for key, value in list(params.items()): if isinstance(value, unicode): value = py2enc(value) p.append(urlencode({key: value})) return ('&').join(sorted(p)) def getPluginUrl(params): return 'plugin://' + addonID + '/?' + convertPluginParams(params)