def get_1(self): artist = self.get_artist_from_session() artist_id = artist.strkey client = soundcloud.Client(access_token = artist.access_token) current_user = client.get('/me') self.say(current_user.fields()) logging.info('artist exists') # track login on mixpanel properties = { '$username' : current_user.username, 'city' : current_user.city, 'country' : current_user.country, '$last_login' : str(dt.now()) } # set the first name for display purposes properties['$first_name'] = \ current_user.full_name or current_user.username logging.info(properties) rpc = mixpanel.track_person(str(current_user.id), properties) # create a session for the artist self.log_in(artist_id) # complete mixpanel rpc mp_result = rpc.get_result() self.say(mp_result.content) self.say(type(mp_result.content)) assert int(mp_result.content) == 1, \ 'mixpanel "login" rpc for user {} failed'.format(str(current_user.id))
def get_1(self): artist = self.get_artist_from_session() artist_id = artist.strkey client = soundcloud.Client(access_token=artist.access_token) current_user = client.get('/me') self.say(current_user.fields()) logging.info('artist exists') # track login on mixpanel properties = { '$username': current_user.username, 'city': current_user.city, 'country': current_user.country, '$last_login': str(dt.now()) } # set the first name for display purposes properties['$first_name'] = \ current_user.full_name or current_user.username logging.info(properties) rpc = mixpanel.track_person(str(current_user.id), properties) # create a session for the artist self.log_in(artist_id) # complete mixpanel rpc mp_result = rpc.get_result() self.say(mp_result.content) self.say(type(mp_result.content)) assert int(mp_result.content) == 1, \ 'mixpanel "login" rpc for user {} failed'.format(str(current_user.id))
def get(self): '''Complete oauth handshake with soundcloud ''' logging.debug(self.request.url) # get the oauth code code = self.request.get('code',None) if code is None: return self.redirect(ARTIST_LOGIN) # init the cloudsound client client = soundcloud.Client(**sc_creds) # exchange the code for an access token response = client.exchange_token(code) # pull the access token from the response access_token = response.access_token # get the access token # access_token = self.request.get("access_token",None) logging.debug(access_token) # if access_token is None: # return self.redirect(ARTIST_LOGIN) # create a new client with the access token del client client = soundcloud.Client(access_token = access_token) current_user = client.get('/me') logging.info('city: '+str(current_user.city)) # pull the artist_id from the response artist_id = str(current_user.id) logging.debug(artist_id) logging.debug(current_user) # check for an existing user try: # will raise SessionError if artist doesnt exist in db artist = self.get_artist_by_id(artist_id) except self.SessionError,e: # artist does not exist yet. Create one # log some mixpanel shiiiiit! try: properties = { '$username' : current_user.username, 'city' : current_user.city, 'country' : current_user.country, 'signed_up' : self.request.get('signed_up',0), 'tracks_added' : 0, '$created' : str(dt.now()) } # set the first name for display purposes properties['$first_name'] = \ current_user.full_name or current_user.username rpc = mixpanel.track_person(str(current_user.id), properties) except Exception,e: logging.error(e)
def get(self): '''Complete oauth handshake with soundcloud ''' logging.debug(self.request.url) # get the oauth code code = self.request.get('code', None) if code is None: return self.redirect(ARTIST_LOGIN) # init the cloudsound client client = soundcloud.Client(**sc_creds) # exchange the code for an access token response = client.exchange_token(code) # pull the access token from the response access_token = response.access_token # get the access token # access_token = self.request.get("access_token",None) logging.debug(access_token) # if access_token is None: # return self.redirect(ARTIST_LOGIN) # create a new client with the access token del client client = soundcloud.Client(access_token=access_token) current_user = client.get('/me') logging.info('city: ' + str(current_user.city)) # pull the artist_id from the response artist_id = str(current_user.id) logging.debug(artist_id) logging.debug(current_user) # check for an existing user try: # will raise SessionError if artist doesnt exist in db artist = self.get_artist_by_id(artist_id) except self.SessionError, e: # artist does not exist yet. Create one # log some mixpanel shiiiiit! try: properties = { '$username': current_user.username, 'city': current_user.city, 'country': current_user.country, 'signed_up': self.request.get('signed_up', 0), 'tracks_added': 0, '$created': str(dt.now()) } # set the first name for display purposes properties['$first_name'] = \ current_user.full_name or current_user.username rpc = mixpanel.track_person(str(current_user.id), properties) except Exception, e: logging.error(e)
def get(self): '''Store the soundcloud url to the artists audio track, also track_id ''' try: artist = self.get_artist_from_session() except self.SessionError: return self.redirect(ARTIST_LOGIN) # track login on mixpanel try: properties = {'tracks_added': 1} logging.info(properties) rpc = mixpanel.track_person(artist.strkey, properties) except Exception, e: logging.error(e)
def get(self): '''Store the soundcloud url to the artists audio track, also track_id ''' try: artist = self.get_artist_from_session() except self.SessionError: return self.redirect(ARTIST_LOGIN) # track login on mixpanel try: properties = { 'tracks_added' : 1 } logging.info(properties) rpc = mixpanel.track_person(artist.strkey, properties) except Exception,e: logging.error(e)
# artist already exists. Login and redirect to manage logging.info('artist exists') # track login on mixpanel try: properties = { '$username' : current_user.username, 'city' : current_user.city, 'country' : current_user.country, '$last_login' : str(dt.now()) } # set the first name for display purposes properties['$first_name'] = \ current_user.full_name or current_user.username logging.info(properties) rpc = mixpanel.track_person(str(current_user.id), properties) except Exception,e: logging.error(e) else: logging.info('Mixpanel rpc creation succeeded') # complete mixpanel rpc self.complete_rpc(rpc) # create a session for the artist session = self.log_in(artist_id) #=================================================================== # Determine redirect destination #===================================================================
# artist already exists. Login and redirect to manage logging.info('artist exists') # track login on mixpanel try: properties = { '$username': current_user.username, 'city': current_user.city, 'country': current_user.country, '$last_login': str(dt.now()) } # set the first name for display purposes properties['$first_name'] = \ current_user.full_name or current_user.username logging.info(properties) rpc = mixpanel.track_person(str(current_user.id), properties) except Exception, e: logging.error(e) else: logging.info('Mixpanel rpc creation succeeded') # complete mixpanel rpc self.complete_rpc(rpc) # create a session for the artist session = self.log_in(artist_id) #=================================================================== # Determine redirect destination #=================================================================== if artist.track_id is None: