Esempio n. 1
0
  def __init__(self, response):
    super(YahooResponse, self).__init__(response['status'],
                                        response['raw_data'],
                                        response['email'])
    data = response['raw_data']
    profiles = []

    # TODO(mihai): Add a proper method to validate yahoo addresses
    self['username'] = response['email'][0:response['email'].find('@')]
    if 'location' in data and data['location']:
      self['location'] = data['location']
    if 'gender' in data and data['gender']:
      self['gender'] = data['gender']
    if 'displayAge' in data and data['displayAge']:
      self['age'] = data['displayAge']
    if 'profileUrl' in data and data['profileUrl']:
      profiles = [data['profileUrl']]

    display_name = None
    if 'nickname' in data and data['nickname']:
      display_name = data['nickname']
    if 'familyName' in data and 'givenName' in data:
      display_name = ' '.join([data['familyName'], data['givenName']])
    if display_name:
      self['display_name'] = display_name

    if profiles:
      response = process_profiles(profiles)
      self['profiles'] = profiles
      if response:
        self.enhance_response(response)
Esempio n. 2
0
  def __init__(self, response, username):
    super(LinkedinResponse, self).__init__(response['status'],
                          response['raw_data'], response['email'])
    data = BeautifulSoup(response['raw_data'])

    profiles = [LINKEDIN_HOST + LINKEDIN_PATH + username]
    self['username'] = username

    name = data.find(id="name")
    if name:
      try:
        family_name = name.find('span', {'class' : "family-name"}).get_text()
      except:
        family_name = ''
      try:
        given_name = name.find('span', {'class' : "given-name"}).get_text()
      except:
        given_name = ''

      if given_name or family_name:
        self['display_name'] = ("%s %s" % (given_name, family_name)).strip()

    headline = data.find(id="headline")
    if headline:
      try:
        self['location'] = \
                headline.find('span', {'class' : 'locality'}).get_text().strip()
      except:
        pass

    if profiles:
      response = process_profiles(profiles)
      self['profiles'] = profiles
      if response:
        self.enhance_response(response)
Esempio n. 3
0
  def __init__(self, response, username):
    super(PinterestResponse, self).__init__(response['status'],
                          response['raw_data'], response['email'])
    data = BeautifulSoup(response['raw_data'])
    profiles = []

    self['username'] = username
    try:
      self['display_name'] = data.find(id='ProfileHeader').h1.string
    except:
      pass
    profiles = ["%s/%s/" % (PINTEREST_HOST, username)]
    data_profiles = data.find(id='ProfileLinks')
    if data_profiles:
      for elem in data_profiles.find_all('li'):
        try:
          profiles.append(elem.a.get('href'))
        except:
          if elem.get('id') == 'ProfileLocation':
            self['location'] = elem.get_text().strip()

    if profiles:
      response = process_profiles(profiles)
      self['profiles'] = profiles
      if response:
        self.enhance_response(response)
Esempio n. 4
0
  def __init__(self, response, username):
    super(TwitterResponse, self).__init__(response['status'],
                          response['raw_data'], response['email'])
    data = BeautifulSoup(response['raw_data'])

    self['username'] = username
    profiles = [TWITTER_HOST + "/" + username]
    profile = data.find(id='profile')
    if profile:
      for x in profile.address.ul.find_all('li'):
        spans = x.find_all('span')
        if not len(spans):
          continue
        if spans[0].string == 'Name':
          self['display_name'] = spans[1].string
        elif spans[0].string == 'Location':
          self['location'] = spans[1].string
        elif spans[0].string == 'Web':
          profiles.append(x.a.get('href'))

    if profiles:
      response = process_profiles(profiles)
      self['profiles'] = profiles
      if response:
        self.enhance_response(response)
Esempio n. 5
0
  def __init__(self, response):
    super(GithubResponse, self).__init__(response['status'],
                          response['raw_data'], response['email'])
    info = simplejson.loads(response['raw_data'])['user']
    profiles = []

    if 'name' in info and info['name']:
      self['display_name'] = info['name']
    if 'location' in info and info['location']:
      self['location'] = info['location']
    if 'login' in info and info['login']:
      self['username'] = info['login']
      profiles = ["github.com/" + info['login']]
    if 'blog' in info and info['blog']:
      profiles.append(info['blog'])

    if profiles:
      response = process_profiles(profiles)
      self['profiles'] = profiles
      if response:
        self.enhance_response(response)
Esempio n. 6
0
  def __init__(self, response):
    super(FoursquareResponse, self).__init__(response['status'],
                          response['raw_data'], response['email'])
    data = simplejson.loads(self['raw_data'])
    info = data['response']['results'][0]
    profiles = []

    firstName = ''
    lastName = ''
    if 'firstName' in info and info['firstName']:
      firstName = info['firstName']
    if 'lastName' in info and info['lastName']:
      lastName = info['lastName']
    if firstName or lastName:
      self['display_name'] = ('%s %s' % (firstName, lastName)).strip()

    if 'gender' in info and info['gender']:
      self['gender'] = info['gender']
    if 'homeCity' in info and info['homeCity']:
      self['location'] = info['homeCity']
    if 'id' in info and info['id']:
      profiles = ['foursquare.com/user/' + info['id']]

    #TODO(diana) check if contact field has others than fb, twitter
    if 'contact' in info:
      if 'facebook' in info['contact'] and info['contact']['facebook']:
        profiles.append(
              "facebook.com/profile.php?id=%s" % info['contact']['facebook'])
      if 'twitter' in info['contact'] and info['contact']['twitter']:
        profiles.append("twitter.com/%s" % info['contact']['twitter'])

    if 'bio' in info and info['bio']:
      profiles.append(info['bio'])

    if profiles:
      response = process_profiles(profiles)
      self['profiles'] = profiles
      if response:
        self.enhance_response(response)
  def __init__(self, response):
    super(GooglePlusResponse, self).__init__(response['status'],
                          response['raw_data'], response['email'])
    info = simplejson.loads(self['raw_data'])
    profiles = []

    if 'displayName' in info and info['displayName']:
      self['display_name'] = info['displayName']
    if 'name' in info and info['name']:
      name = info['name']
      givenName = ''
      familyName = ''
      if 'givenName' in name and name['givenName']:
        givenName = name['givenName']
      if 'familyName' in name and name['familyName']:
        familyName = name['familyName']
      if givenName or familyName:
        self['display_name'] = ('%s %s' % (givenName, familyName)).strip()

    if 'gender' in info and info['gender']:
      self['gender'] = info['gender']

    if 'urls' in info and info['urls']:
      for url in info['urls']:
        if 'type' in url.keys():
          if url['type'] == "profile":
            if 'value' in url and url['value']:
              profiles.insert(0, url['value'])
          else:
            continue
        else:
          if 'value' in url and url['value']:
            profiles.append(url['value'])

    if profiles:
      response = process_profiles(profiles)
      self['profiles'] = profiles
      if response:
        self.enhance_response(response)
Esempio n. 8
0
  def __init__(self, response, username):
    super(SoundcloudResponse, self).__init__(response['status'],
                          response['raw_data'], response['email'])
    users_list = simplejson.loads(response['raw_data'])
    profiles = []

    found = False
    for info in users_list:
      if info['permalink'] != username:
        continue
      found = True

      self['username'] = username
      self['raw_data'] = info
      if 'full_name' in info and info['full_name']:
        self['display_name'] = info['full_name']
      city = ''
      country = ''
      if 'city' in info and info['city']:
        city = info['city']
      if 'country' in info and info['country']:
        country = info['country']
      if city or country:
        self['location'] = ("%s %s" % (city, country)).strip()
      if 'permalink_url' in info and info['permalink_url']:
        profiles = [info['permalink_url']]
      if 'website' in info and info['website']:
        profiles.append(info['website'])
      break

    if not found:
      self['status'] = NOT_FOUND_ERROR_CODE

    if profiles:
      response = process_profiles(profiles)
      self['profiles'] = profiles
      if response:
        self.enhance_response(response)
Esempio n. 9
0
  def __init__(self, response):
    super(FlickrResponse, self).__init__(response['status'],
                         response['raw_data'], response['email'])
    message = response['raw_data']
    message = message[RESPONSE_PREFIX_LENGTH:len(message)-1]
    info = simplejson.loads(message)['person']
    profiles = []

    if 'username' in info and info['username']['_content']:
      self['username'] = info['username']['_content']
    if 'realname' in info and info['realname']['_content']:
      self['display_name'] = info['realname']['_content']
    if 'location' in info and info['location']['_content']:
      self['location'] = info['location']['_content']
    profiles = []
    if 'profileurl' in info and info['profileurl']['_content']:
      profiles = [info['profileurl']['_content']]

    if profiles:
      response = process_profiles(profiles)
      self['profiles'] = profiles
      if response:
        self.enhance_response(response)
Esempio n. 10
0
  def __init__(self, response):
    super(JigsawResponse, self).__init__(response['status'],
                         response['raw_data'], response['email'])
    message = response['raw_data']
    info = simplejson.loads(message)['contacts'][0]
    profiles = []

    firstName = ''
    lastName = ''
    if 'firstname' in info and info['firstname']:
      firstName = info['firstname']
    if 'lastname' in info and info['lastname']:
      lastName = info['lastname']
    if firstName or lastName:
      self['display_name'] = ('%s %s' % (firstName, lastName)).strip()

    #TODO(diana) maybe add address?
    city = ''
    state = ''
    country = ''
    if 'city' in info and info['city']:
      city = info['city']
    if 'state' in info and info['state']:
      state = info['state']
    if 'country' in info and info['country']:
      country = info['country']
    if city or state or country:
      self['location'] = ('%s %s %s' % (city, state, country)).strip()

    if 'contactURL' in info and info['contactURL']:
      profiles = [info['contactURL']]

    if profiles:
      response = process_profiles(profiles)
      self['profiles'] = profiles
      if response:
        self.enhance_response(response)
Esempio n. 11
0
  def __init__(self, response, username):
    super(AboutmeResponse, self).__init__(response['status'],
                          response['raw_data'], response['email'])
    data = BeautifulSoup(response['raw_data'])

    profiles = [ABOUTME_HOST + "/" + username]
    self['username'] = username

    profile_box = data.find(id='profile_box')
    if profile_box:
      try:
        if profile_box.div.h1.string:
          self['display_name'] = profile_box.div.h1.string
      except:
        pass

    for website in data.find_all('a', {'class': 'website'}):
      profiles.append(website.get('href'))

    for content in ABOUTME_CONTENT:
      content_response = http_request(self['email'], 'GET', ABOUTME_HOST,
                      "/content/%s/%s" % (urllib.quote(username), content), {})
      data = BeautifulSoup(content_response['raw_data'])
      body = data.find('body', {'class':'aboutmeapp'})
      try:
        profile = body.find('div', {'class':'top_section'}).h1.a.get('href')
        if profile:
          profiles.append(profile)
      except:
        pass

    if profiles:
      response = process_profiles(profiles)
      self['profiles'] = profiles
      if response:
        self.enhance_response(response)
Esempio n. 12
0
  def __init__(self, response):
    super(MyspaceResponse, self).__init__(response['status'],
                          response['raw_data'], response['email'])
    # TODO(diana) check if profiles are given back
    data = simplejson.loads(self['raw_data'])
    info = data['entry'][0]
    profiles = []

    if 'displayName' in info and info['displayName']:
      self['display_name'] = info['displayName']
    if 'gender' in info and info['gender']:
      self['gender'] = info['gender']
    if 'age' in info and info['age']:
      self['age'] = info['age']
    if 'location' in info and info['location']:
      self['location'] = info['location']
    if 'profileUrl' in info and info['profileUrl']:
      profiles = [info['profileUrl']]

    if profiles:
      response = process_profiles(profiles)
      self['profiles'] = profiles
      if response:
        self.enhance_response(response)
Esempio n. 13
0
  def __init__(self, response):
    super(LastfmResponse, self).__init__(response['status'],
                          response['raw_data'], response['email'])
    info = simplejson.loads(response['raw_data'])['user']
    profiles = []

    if 'realname' in info and info['realname']:
      self['display_name'] = info['realname']
    if 'name' in info and info['name']:
      self['username'] = info['name']
    if 'country' in info and info['country']:
      self['location'] = info['country']
    if 'age' in info and info['age']:
      self['age'] = info['age']
    if 'gender' in info and info['gender']:
      self['gender'] = info['gender']
    if 'url' in info and info['url']:
      profiles = [info['url']]

    if profiles:
      response = process_profiles(profiles)
      self['profiles'] = profiles
      if response:
        self.enhance_response(response)