import os import sys import xbmcplugin import xbmc import xbmcgui import traceback import threading from datetime import datetime __scriptid__ = "script.video.etvnet" __scriptname__ = "eTVnet" __author__ = "POLINOM" __url__ = "http://etvnet.com/" __XBMC_Revision__ = "31000" import xbmcaddon __settings__ = xbmcaddon.Addon(id=__scriptid__) __language__ = __settings__.getLocalizedString __debugging__ = __settings__.getSetting("debug") __version__ = __settings__.getAddonInfo('version') BASE_RESOURCE_PATH = xbmc.translatePath(os.path.join(__settings__.getAddonInfo('path'), 'resources', 'lib' )) __cwd__ = __settings__.getAddonInfo('path') # if device does not have this number stored in config under key 'reauth' will be enishiated process of authorisation __reauth_required_id__ = 1 sys.path.append(BASE_RESOURCE_PATH) from etvnet.client import eTVxbmc from etvnet.auth import AuthWindow, Auth, Settings config = Settings() acces_token = config.GetValue('access_token') device_code = config.GetValue("device_code") reauth_id = config.GetValue('reauth') if config.GetValue('reauth') else 0 need_reauth = int(reauth_id) != __reauth_required_id__ config.SetValue('reauth', str(__reauth_required_id__) ) print need_reauth if device_code: au = Auth() au.device_code = device_code status, resp = au.get_token() if status == au.SUCCESS: wn = eTVxbmc() else: wn = AuthWindow() elif acces_token and not need_reauth: wn = eTVxbmc() else: wn = AuthWindow() wn.doModal() del wn