Spaces:
Runtime error
Runtime error
import requests | |
import json | |
class TinderWrapper(): | |
def __init__(self, token): | |
self.headers = { | |
'Host': 'api.gotinder.com', | |
'persistent-device-id': '2A1756C9304C47E39CC4EB52BA002E59', | |
'User-Agent': 'Tinder/14.14.0 (iPhone; iOS 16.1; Scale/3.00)', | |
'app-session-id': '59B3E862-6B7A-4CFA-8D15-179326473F70', | |
'support-short-video': '1', | |
'x-hubble-entity-id': 'd213d4fe-239a-4583-87df-8907c6de59ad', | |
'app-session-time-elapsed': '2.14300799369812', | |
'X-Auth-Token': token, | |
'x-supported-image-formats': 'webp, jpeg', | |
'platform': 'ios', | |
'Connection': 'keep-alive', | |
'user-session-time-elapsed': '2.141390085220337', | |
'Accept-Language': 'ru', | |
'tinder-version': '14.14.0', | |
'Accept': 'application/json', | |
'app-version': '5363', | |
'user-session-id': 'D31F92A9-C94B-478F-A3FB-05531B18758F', | |
'os-version': '160000100000', | |
'Content-Type': 'application/json' | |
} | |
self.host = 'https://api.gotinder.com' | |
def get_updates(self, last_activity_date): | |
try: | |
url = self.host + '/updates' | |
r = requests.post(url, headers=self.headers, data=json.dumps({"last_activity_date": last_activity_date})) | |
print(r.json()) | |
return r.json() | |
except requests.exceptions.RequestException as e: | |
print(e) | |
def get_photos(self, person): | |
photos = person['photos'] | |
photo_urls = [] | |
for photo in photos: | |
photo_urls.append(photo['url']) | |
return photo_urls | |
def create_dump(self, last_activity_date='1997-03-25T22:49:41.151Z'): | |
updates = self.get_updates(last_activity_date)['matches'] | |
output = {} | |
for update in updates: | |
person = update['person'] | |
photos = self.get_photos(person) | |
person_id = person['_id'] | |
name = person['name'] | |
messages = update['messages'] | |
output[person_id] = { | |
'name': name, | |
'messages': messages, | |
'photos': photos | |
} | |
return output |