Brasd99 commited on
Commit
2d60cfa
1 Parent(s): 77c2a65
Files changed (3) hide show
  1. app.py +2 -1
  2. common/helpers.py +1 -0
  3. common/tinderwrapper.py +3 -1
app.py CHANGED
@@ -33,6 +33,7 @@ if st.button('Запуск'):
33
  dump = wrapper.create_dump(update_progress)
34
  save_data(dump, dump_folder, update_progress)
35
  shutil.make_archive('output', 'zip', dump_folder)
 
36
  with open('output.zip', 'rb') as f:
37
- st.download_button('Download Zip', f, file_name='output.zip')
38
 
 
33
  dump = wrapper.create_dump(update_progress)
34
  save_data(dump, dump_folder, update_progress)
35
  shutil.make_archive('output', 'zip', dump_folder)
36
+ update_progress(1.0, 'Обработка успешно завершена!')
37
  with open('output.zip', 'rb') as f:
38
+ st.download_button('Скачать архив', f, file_name='output.zip')
39
 
common/helpers.py CHANGED
@@ -8,6 +8,7 @@ def download_photo(url, save_path):
8
  file.write(response.content)
9
 
10
  def save_data(dump, dump_folder, update_progress, min_percent=50):
 
11
  for i, (id, value) in enumerate(dump.items()):
12
  folder_path = os.path.join(dump_folder, f'{value["name"]}_{id}')
13
  os.makedirs(folder_path)
 
8
  file.write(response.content)
9
 
10
  def save_data(dump, dump_folder, update_progress, min_percent=50):
11
+ update_progress(min_percent, 'Скачиваю фото и формирую дамп...')
12
  for i, (id, value) in enumerate(dump.items()):
13
  folder_path = os.path.join(dump_folder, f'{value["name"]}_{id}')
14
  os.makedirs(folder_path)
common/tinderwrapper.py CHANGED
@@ -43,7 +43,9 @@ class TinderWrapper():
43
  return photo_urls
44
 
45
  def create_dump(self, update_progress, max_percent=50, last_activity_date='1997-03-25T22:49:41.151Z'):
 
46
  updates = self.get_updates(last_activity_date)['matches']
 
47
  output = {}
48
  for i, update in enumerate(updates):
49
  person = update['person']
@@ -57,6 +59,6 @@ class TinderWrapper():
57
  'photos': photos
58
  }
59
  percent = ((i + 1) / len(updates)) * max_percent / 100
60
- update_progress(percent, 'Обрабатываю ответ Tinder..')
61
 
62
  return output
 
43
  return photo_urls
44
 
45
  def create_dump(self, update_progress, max_percent=50, last_activity_date='1997-03-25T22:49:41.151Z'):
46
+ update_progress(0, 'Делаю запрос в Tinder...')
47
  updates = self.get_updates(last_activity_date)['matches']
48
+ update_progress(0, 'Обрабатываю ответ Tinder...')
49
  output = {}
50
  for i, update in enumerate(updates):
51
  person = update['person']
 
59
  'photos': photos
60
  }
61
  percent = ((i + 1) / len(updates)) * max_percent / 100
62
+ update_progress(percent, 'Обрабатываю ответ Tinder...')
63
 
64
  return output