@@ 126,6 126,39 @@ class Photo(BaseModel):
return self.filename
+class InstagramPhoto(object):
+ def __init__(self, data_dict):
+ self._data = data_dict
+ self.image = data_dict['image']
+ self.link = data_dict['link']
+ self.thumbnail = data_dict['thumbnail']
+ self.timestamp = \
+ datetime.datetime.fromtimestamp(float(data_dict['ts']))
+
+ def __str__(self):
+ return self.__unicode__()
+
+ def __unicode__(self):
+ return self.image
+
+
+class InstagramUser(object):
+ def __init__(self, data_dict, tinder_user):
+ self._data = data_dict
+ self._tinder_user = tinder_user
+ self.username = data_dict['username']
+ self.profile_picture = data_dict['profile_picture']
+ self.media_count = data_dict['media_count']
+ self.last_fetch_time = pull_date(data_dict['last_fetch_time'])
+ self.photos = [InstagramPhoto(x) for x in data_dict['photos']]
+
+ def __str__(self):
+ return self.__unicode__()
+
+ def __unicode__(self):
+ return u'{0}: {1}'.format(self.username, self.profile_picture)
+
+
class User(BaseModel):
bio = FieldDescriptor('bio')
gender = GenderDescriptor('gender')
@@ 191,6 224,12 @@ class User(BaseModel):
def schools(self):
return [x['name'] for x in self._data.get('schools', [])]
+ @property
+ def instagram(self):
+ if 'instagram' not in self._data:
+ return None
+ return InstagramUser(self._data['instagram'], self)
+
def like(self):
return self._api.like(self.id)