pqFunctionApi.py 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. """
  2. @author: luojunhui
  3. @description: 票圈后台的接口方法
  4. """
  5. import requests
  6. class PQAPI(object):
  7. """
  8. PQ API
  9. """
  10. @classmethod
  11. def getPQVideoListDetail(cls, video_list):
  12. """
  13. 获取票圈视频详情信息
  14. :param: video_list: 视频id 列表
  15. :return: Detail
  16. """
  17. url = "https://longvideoapi.piaoquantv.com/longvideoapi/openapi/video/batchSelectVideoInfo"
  18. data = {
  19. "videoIdList": video_list
  20. }
  21. header = {
  22. "Content-Type": "application/json",
  23. }
  24. response = requests.request(
  25. "POST",
  26. url=url,
  27. headers=header,
  28. json=data
  29. )
  30. return response.json()
  31. @classmethod
  32. def changeVideoStatus(cls, videoId, statusCode=5):
  33. """
  34. 通过接口,来修改视频状态
  35. :param videoId: 视频 id
  36. :param statusCode: (1 审核中,2 不通过 3 待修改,4 自己可见 5 通过) 默认等于 5,把视频设置为可见
  37. :return: True / False
  38. """
  39. url = "https://admin.piaoquantv.com/manager/video/audit/v2/updateAuditStatus"
  40. payload = "videoId={}&auditStatus={}&updateReasonJson=&rejectReasonJson=%5B%7B%22reason%22%3A%22%E9%95%BF%E6%96%87%E8%87%AA%E5%8A%A8%E4%B8%8B%E6%9E%B6%22%2C%22reasonId%22%3A-1%7D%5D&adminUid=206".format(
  41. videoId, statusCode)
  42. headers = {
  43. 'accept': 'application/json',
  44. 'accept-language': 'en,zh;q=0.9,zh-CN;q=0.8',
  45. 'content-type': 'application/x-www-form-urlencoded;charset=UTF-8',
  46. 'cookie': 'SESSION=NTljNTg2YjktMTU0MC00YWQ5LWE4ZTktNDFhODY0NzM3NTcx',
  47. 'origin': 'https://admin.piaoquantv.com',
  48. 'priority': 'u=1, i',
  49. 'sec-ch-ua': '"Not/A)Brand";v="8", "Chromium";v="126", "Google Chrome";v="126"',
  50. 'sec-ch-ua-mobile': '?0',
  51. 'sec-ch-ua-platform': '"macOS"',
  52. 'sec-fetch-dest': 'empty',
  53. 'sec-fetch-mode': 'cors',
  54. 'sec-fetch-site': 'same-origin',
  55. 'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36'
  56. }
  57. response = requests.request(
  58. "POST",
  59. url,
  60. headers=headers,
  61. data=payload,
  62. timeout=10
  63. )
  64. if response.status_code == 200:
  65. if response.json().get("code") == 0:
  66. return True
  67. else:
  68. return False
  69. else:
  70. return False