dev.py 871 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. """
  2. @author: luojunhui
  3. """
  4. import json
  5. import time
  6. import requests
  7. from tqdm import tqdm
  8. def request_for_whisper(obj):
  9. """
  10. 请求whisper
  11. :param obj:
  12. :return:
  13. """
  14. url = "http://localhost:8888/whisper"
  15. body = {
  16. "vid": obj['video_id'],
  17. "title": obj['title']
  18. }
  19. a = time.time()
  20. header = {
  21. "Content-Type": "application/json",
  22. }
  23. response = requests.post(url, json=body, headers=header, timeout=600)
  24. b = time.time()
  25. print(b - a)
  26. return response.json()
  27. if __name__ == '__main__':
  28. with open("test.json", encoding="utf-8") as f:
  29. today_info = json.loads(f.read())
  30. dt_list = today_info['data']
  31. for video_obj in tqdm(dt_list):
  32. try:
  33. result = request_for_whisper(obj=video_obj)
  34. print(result)
  35. except Exception as e:
  36. print(e)