From 7fbc2b6c9b2d1849a82a49db7115240653308ff7 Mon Sep 17 00:00:00 2001 From: pokurt Date: Fri, 11 Sep 2020 14:38:15 +0500 Subject: [PATCH 1/2] simple code much fun --- .gitignore | 7 +++++++ tinder_api/user.py | 33 +++++++++++---------------------- 2 files changed, 18 insertions(+), 22 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ed0063b --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ + +tinder_api/utils/config.py +*.py +example.py +*.pyc +tinder_api/utils/config.py +tinder_api/utils/config.py diff --git a/tinder_api/user.py b/tinder_api/user.py index 6d59efb..2c1b4bb 100644 --- a/tinder_api/user.py +++ b/tinder_api/user.py @@ -33,9 +33,8 @@ def report(self, cause, text=''): 1 : 'spam' 4 : 'inappropriate photos' """ - resp = r.post('/report/{}'.format(uid), + return r.post('/report/{}'.format(uid), {"cause": cause, "text": text}) - return resp class NormalUser(UserModel): def __init__(self, uid, name, bio, age, birth_date, photos, gender, @@ -92,14 +91,8 @@ def __init__(self, data, uid, name): self.data = data self.sent = dateutil.parser.parse(data['sent_date']) self.body = data['message'] - if data['from'] == uid: - self.sender = name - else: - self.sender = "Me" - if data['to'] == uid: - self.to = name - else: - self.to = "Me" + self.sender = name if data['from'] == uid else "Me" + self.to = name if data['to'] == uid else "Me" def like_message(self): """Likes a message""" @@ -118,10 +111,7 @@ def unlike_message(self): def is_liked(self): """Returns True if the messages is liked, otherwise False""" liked_messages = [x['message_id'] for x in session.Session().get_updates()['liked_messages']] - for mess_id in liked_messages: - if mess_id == self.message_id: - return True - return False + return self.message_id in liked_messages def __unicode__(self): return self.body @@ -144,7 +134,7 @@ def __init__(self, uid): def get_data(self): """Returns the data of the user""" - if self.user_type is 'Me': + if self.user_type == 'Me': data = r.get('/profile') return data else: @@ -180,15 +170,15 @@ def get_user(self): ping_time = self.const.ping_time top_song = self._decode_theme_song() instagram_photos = [photo.image for photo in self.const.instagram.photos] - if self.user_type is 'Normal': + if self.user_type == 'Normal': return NormalUser(self.id, name, bio, age, birth_date, photos, gender, distance, job_name, job_title, school_name, school_id, ping_time, top_song, instagram_photos) - elif self.user_type is 'Match': + elif self.user_type == 'Match': return MatchUser(self.id, self.match_id, name, bio, age, birth_date, photos, gender, distance, job_name, job_title, school_name, school_id, ping_time, top_song, instagram_photos) - elif self.user_type is 'Me': + elif self.user_type == 'Me': return UserModel(self.id, name, bio, age, birth_date, photos, gender, distance, job_name, job_title, school_name, school_id, ping_time, top_song, instagram_photos) @@ -208,9 +198,9 @@ def _decode_age(self): def _decode_gender(self): """Converts gender to a human readable format""" gender = self.const.gender - if gender is 1: + if gender == 1: return 'female' - elif gender is 0: + elif gender == 0: return 'male' def _decode_distance(self): @@ -231,5 +221,4 @@ def _decode_theme_song(self): 'id': theme_s.id, 'artist': theme_s.artists[0].name} -if __name__ == '__main__': - pass +pass From 0e317702dd77eb59962a97026bce89623cb35fe0 Mon Sep 17 00:00:00 2001 From: pokurt Date: Fri, 11 Sep 2020 18:54:24 +0500 Subject: [PATCH 2/2] gitignored config --- .gitignore | 2 ++ example.py | 27 ++++++++------------------- tinder_api/utils/config.py | 2 +- 3 files changed, 11 insertions(+), 20 deletions(-) diff --git a/.gitignore b/.gitignore index ed0063b..3b045e8 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,5 @@ example.py *.pyc tinder_api/utils/config.py tinder_api/utils/config.py +tinder_api/utils/config.py +example.py diff --git a/example.py b/example.py index e86e48b..bfee128 100644 --- a/example.py +++ b/example.py @@ -1,23 +1,12 @@ import tinder_api.session -import itertools -from datetime import datetime -sess = tinder_api.session.Session() # inits the session -print("My _id is %s" %sess.get_id()) - -#sess.update_profile(bio="VIM is the best") - -for user in itertools.islice(sess.yield_users(), 10): - print(user.name) # prints the name of the user see __init__ - # How to check if it exists, if it doesnt, it returns - if user.bio is not "": - print(user.bio) - print(user.like()) # returns false if not a match - -for match in sess.yield_matches(): - print(match.name) - print(match.match_data) # prints all the match_data - print([x.body for x in match.get_messages()]) # gets the body of messages - #print(match.message("Hello")) # sends hello to the match +sess = tinder_api.session.Session() # creates a session +print(sess.meta) # prints your meta data +# sess.update_profile(bio="I love VIM") # updates your bio - see kwargs +for user in sess.yield_users(): + print(user.name) + print(user.id) + print(user.age) + print(user.bio) \ No newline at end of file diff --git a/tinder_api/utils/config.py b/tinder_api/utils/config.py index 5c90366..e4f9b84 100644 --- a/tinder_api/utils/config.py +++ b/tinder_api/utils/config.py @@ -10,7 +10,7 @@ 'platform': 'ios', 'content-type': 'application/json', 'User-agent': 'Tinder/7.5.3 (iPohone; iOS 10.3.2; Scale/2.00)', - 'X-Auth-Token': tinder_token, + 'X-Auth-Token': 'b5210594-06ae-40b6-a3db-05f10308e5bb', } host = 'https://api.gotinder.com'