def get_user_token(): """send user login info and retrieve token for session""" stored_token = cache.get('NRLTOKEN') if stored_token != '': utils.log('Using token: {0}******'.format(stored_token[:-6])) return stored_token free_sub = int(addon.getSetting('SUBSCRIPTION_TYPE')) if free_sub: token = telstra_auth.get_free_token(username, password) else: login_resp = telstra_auth.get_paid_token(username, password) json_data = json.loads(login_resp) if 'ErrorCode' in json_data: if json_data.get('ErrorCode') == 'MIS_EMPTY': raise Exception('No paid subscription found ' 'on this Telstra ID') if json_data.get('ErrorCode') == '5': raise Exception('Please check your username ' 'and password in the settings') raise Exception(json_data.get('ErrorMessage')) token = json_data.get('UserToken') cache.set('NRLTOKEN', token) utils.log('Using token: {0}******'.format(token[:-6])) return token
def get_user_ticket(): """ send user login info and retrieve ticket for session """ stored_ticket = cache.get('NETBALLTICKET') if stored_ticket != '': utils.log('Using ticket: {0}******'.format(stored_ticket[:-6])) return stored_ticket else: ticket = telstra_auth.get_free_token(username, password) cache.set('NETBALLTICKET', ticket) return ticket
def get_nrl_user_token(): """send user login info and retrieve user id for session""" free_sub = int(addon.getSetting('SUBSCRIPTION_TYPE')) if free_sub: return telstra_auth.get_free_token(username, password) login_resp = telstra_auth.get_paid_token(username, password) json_data = json.loads(login_resp) if 'ErrorCode' in json_data: if json_data.get('ErrorCode') == 'MIS_EMPTY': raise Exception('No paid subscription found on this Telstra ID') if json_data.get('ErrorCode') == '5': raise Exception('Please check your username ' 'and password in the settings') raise Exception(json_data.get('ErrorMessage')) return json_data.get('UserToken')
def get_user_ticket(): """ send user login info and retrieve ticket for session """ stored_ticket = cache.get('NRLTICKET') if stored_ticket != '': utils.log('Using ticket: {0}******'.format(stored_ticket[:-6])) return stored_ticket sub_type = int(addon.getSetting('SUBSCRIPTION_TYPE')) if sub_type == 1: ticket = telstra_auth.get_free_token(telstra_username, telstra_password) elif sub_type == 2: # mobile activated subscription ticket = telstra_auth.get_mobile_token() else: ticket = telstra_auth.get_paid_token(nrl_username, nrl_password) cache.set('NRLTICKET', ticket) return ticket
def get_user_ticket(): """ send user login info and retrieve ticket for session """ stored_ticket = cache.get('SOCCERTICKET') if stored_ticket != '': utils.log('Using ticket: {0}******{1}******'.format( stored_ticket[:8], stored_ticket[15:-6])) return stored_ticket else: subscription_type = int(addon.getSetting('SUBSCRIPTION_TYPE')) if subscription_type == 0: ticket = telstra_auth.get_free_token( addon.getSetting('LIVE_USERNAME'), addon.getSetting('LIVE_PASSWORD')) elif subscription_type == 2: ticket = telstra_auth.get_paid_token( addon.getSetting('PAID_USERNAME'), addon.getSetting('PAID_PASSWORD')) else: ticket = telstra_auth.get_mobile_token() cache.set('SOCCERTICKET', ticket) return ticket