piaoquan_api.py 1013 B

1234567891011121314151617181920212223242526272829303132
  1. import json
  2. import requests
  3. from tenacity import retry
  4. from requests.exceptions import RequestException
  5. from typing import Optional, Dict, List
  6. from applications.utils import request_retry
  7. retry_desc = request_retry(retry_times=3, min_retry_delay=2, max_retry_delay=30)
  8. @retry(**retry_desc)
  9. def fetch_piaoquan_video_list_detail(video_id_list: List[int]) -> Optional[Dict]:
  10. """
  11. 获取票圈视频详情信息
  12. :param: video_list: 视频id 列表
  13. :return: Detail
  14. """
  15. url = "https://longvideoapi.piaoquantv.com/longvideoapi/openapi/video/batchSelectVideoInfo"
  16. data = {"videoIdList": video_id_list}
  17. header = {
  18. "Content-Type": "application/json",
  19. }
  20. try:
  21. response = requests.post(url, headers=header, json=data, timeout=60)
  22. response.raise_for_status()
  23. return response.json()
  24. except RequestException as e:
  25. print(f"API请求失败: {e}")
  26. except json.JSONDecodeError as e:
  27. print(f"响应解析失败: {e}")
  28. return None