12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- """
- @author: luojunhui
- """
- import json
- import time
- import requests
- from tqdm import tqdm
- def request_for_whisper(obj):
- """
- 请求whisper
- :param obj:
- :return:
- """
- url = "http://localhost:8888/whisper"
- body = {
- "vid": obj['video_id'],
- "title": obj['title']
- }
- a = time.time()
- header = {
- "Content-Type": "application/json",
- }
- response = requests.post(url, json=body, headers=header, timeout=600)
- b = time.time()
- print(b - a)
- return response.json()
- if __name__ == '__main__':
- with open("test.json", encoding="utf-8") as f:
- today_info = json.loads(f.read())
- dt_list = today_info['data']
- for video_obj in tqdm(dt_list):
- try:
- result = request_for_whisper(obj=video_obj)
- print(result)
- except Exception as e:
- print(e)
|