def portal(self): pandora = Pandora(self.pool.getAgent()) user, walkman_user, connector = retrieve_user_info(cherrypy.session, self.Connector) try: stations = pandora.get_station_list(user) stations = [{'stationName': s['stationName'], 'stationId': s['stationId']} for s in stations] stationIds = [long(station['stationId']) for station in stations] chosenStation = walkman_user.station_id if walkman_user.station_id in stationIds else stationIds[0] walkman_user.station_id = chosenStation connector.commit() return self.templates.get_template("portal.html").render( userId = user['userId'], userToken = user['userAuthToken'], stations = stations, stationId = chosenStation ) except ValueError: #return "Login failed, please do an 180" return self.login()
def getNameForStation(self, stationNameLike): if self.stationList == None: logging.info( "logging into pandora") russPandora = Pandora() username = "******" password = "******" russPandora.authenticate(username, password) logging.info( "loading station list") self.stationList = russPandora.get_station_list() logging.info( "station list loaded ") for station in self.stationList: if stationNameLike in station['stationName']: logging.info( 'found track "%s"' % station['stationName']) return station['stationName'] logging.error( 'error no station found') return -1
def stations(self): pandora = Pandora(self.pool.getAgent()) user = cherrypy.session.get('user') return self.respond_success(pandora.get_station_list(user))