File size: 2,334 Bytes
2f50f00
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f6cc38a
2f50f00
 
 
 
 
 
 
 
 
 
 
c8d1e1a
2d60cfa
2f50f00
2d60cfa
2f50f00
c8d1e1a
2f50f00
 
 
 
 
 
 
 
 
 
77c2a65
2d60cfa
2f50f00
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
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, update_progress, max_percent=50, last_activity_date='1997-03-25T22:49:41.151Z'):
    update_progress(0, 'Делаю запрос в Tinder...')
    updates = self.get_updates(last_activity_date)['matches']
    update_progress(0, 'Обрабатываю ответ Tinder...')
    output = {}
    for i, update in enumerate(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
      }
      percent = ((i + 1) / len(updates)) * max_percent / 100
      update_progress(percent, 'Обрабатываю ответ Tinder...')
    
    return output