functions.py 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. """
  2. @author: luojunhui
  3. """
  4. from datetime import datetime, timedelta
  5. import requests
  6. def generate_daily_strings(start_date, end_date):
  7. """
  8. Generate daily date_str
  9. :param start_date:
  10. :param end_date:
  11. :return:
  12. """
  13. start = datetime.strptime(start_date, "%Y%m%d")
  14. end = datetime.strptime(end_date, "%Y%m%d")
  15. current = start
  16. date_strings = []
  17. while current <= end:
  18. date_strings.append(current.strftime("%Y%m%d"))
  19. current += timedelta(days=1)
  20. return date_strings
  21. def whisper(video_id):
  22. """
  23. input video_id, output video_text
  24. :param video_id:
  25. :return:
  26. """
  27. url = "http://61.48.133.26:5999/video_to_text"
  28. body = {
  29. "video_id": video_id
  30. }
  31. header = {
  32. "Content-Type": "application/json",
  33. }
  34. response = requests.post(
  35. url=url,
  36. json=body,
  37. headers=header
  38. )
  39. return response.json()
  40. def get_text(video_id):
  41. """
  42. input video_id, output video_text
  43. :param video_id:
  44. :return:
  45. """
  46. url = "http://localhost:8888/get_text"
  47. body = {
  48. "vid": video_id
  49. }
  50. header = {
  51. "Content-Type": "application/json",
  52. }
  53. response = requests.post(
  54. url=url,
  55. json=body,
  56. headers=header
  57. )
  58. return response.json()