def LogLoginInfo(self, loginJSON): self.log(u'is_paid_subscriber: %s' % utils.getDictionaryValue(loginJSON[u'user'], u'is_paid_subscriber')) self.log(u'login: %s' % utils.getDictionaryValue(loginJSON[u'user'], u'login')) self.log(u'status: %s' % utils.getDictionaryValue(loginJSON[u'user'], u'status')) packages = utils.getDictionaryValue(loginJSON[u'user'], u'packages') if packages: self.log(u'status: %s' % utils.drepr(packages))
def Login(self): self.log(u"", xbmc.LOGDEBUG) """ { 'epg': 'WEB_STD', 'user': { 'decay': 40, 'email': 'email', 'fname': 'fname', 'id': '87354', 'ipicid': 'aertv530916c892b25', 'is_paid_subscriber': 0/1, 'lname': 'lname', 'login': True, 'mailchimp': None, 'packages': [ { 'code': 'WEB_STD', 'desc': 'Free Channel Pack', 'package_id': '1' }, { "code":"AERTV_PLUS", "desc":"Aertv Plus", "package_id":"6" } ], 'session': 'YWVydHY1MzA5MTZjODkyYjI0_1393452432', 'status': '1', 'val_code': None } } """ loginJSON = None email = self.addon.getSetting( u'AerTV_email' ).decode(u'utf8') password = self.addon.getSetting( u'AerTV_password' ).decode(u'utf8') if len(email) == 0 or len(password) == 0: if not xbmcvfs.exists(self.aertvNoticeFilePath): file = open(self.aertvNoticeFilePath, u'w') try: file.write(" ") finally: file.close() dialog = xbmcgui.Dialog() dialog.ok(self.language(30105), self.language(30106)) self.addon.openSettings(sys.argv[ 0 ]) email = self.addon.getSetting( u'AerTV_email' ).decode(u'utf8') password = self.addon.getSetting( u'AerTV_password' ).decode(u'utf8') if len(email) == 0 or len(password) == 0: self.log(u"No AerTV login details", xbmc.LOGDEBUG) return False try: loginJSON = self.LoginViaCookie() except (Exception) as exception: if not isinstance(exception, LoggingException): exception = LoggingException.fromException(exception) # 'AerTV login failed', exception.addLogMessage(self.language(30101)) exception.process(severity = self.logLevel(xbmc.LOGWARNING)) if loginJSON is None: try: values = [{u'api':u'login'},{u'user':email},{u'pass':password}] loginJSON = self.AttemptLogin(values, logUrl = False) self.log(u"After weblogin loginJSON is None: " + unicode(loginJSON is None), xbmc.LOGDEBUG) if loginJSON is None: # 'AerTV login failed', exception = LoggingException(self.language(30101)) # "Status Message: %s exception.process(severity = self.logLevel(xbmc.LOGERROR)) return False self.log(u"Login successful", xbmc.LOGDEBUG) sessionId = loginJSON[u'user'][u'session'] days02 = 2*24*60*60 expiry = int(time.time()) + days02 self.log(u"Aertv_login expiry: " + unicode(expiry), xbmc.LOGDEBUG) sessionCookie = self.MakeCookie(u'Aertv_login', sessionId, domain, expiry ) self.cookiejar.set_cookie(sessionCookie) self.cookiejar.save() loginJSON = self.LoginViaCookie() except (Exception) as exception: if not isinstance(exception, LoggingException): exception = LoggingException.fromException(exception) # Error logging into AerTV exception.addLogMessage(self.language(30101)) exception.process(severity = self.logLevel(xbmc.LOGERROR)) return False self.LogLoginInfo(loginJSON) if len(utils.getDictionaryValue(loginJSON[u'user'], u'packages')) < 2: # Error logging into AerTV exception = LoggingException(self.language(30101)) exception.process(severity = self.logLevel(xbmc.LOGERROR)) return False return True