pqFunctions.py 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. """
  2. @author: luojunhui
  3. """
  4. import json
  5. from applications.functions.common import async_post
  6. async def publish_to_pq(video_obj):
  7. """
  8. publish video to pq
  9. :return:
  10. """
  11. oss_path = video_obj['videoPath']
  12. uid = video_obj['uid']
  13. title = video_obj['title']
  14. url = "https://vlogapi.piaoquantv.com/longvideoapi/crawler/video/send"
  15. headers = {
  16. "User-Agent": "PQSpeed/486 CFNetwork/1410.1 Darwin/22.6.0",
  17. "cookie": "JSESSIONID=4DEA2B5173BB9A9E82DB772C0ACDBC9F; JSESSIONID=D02C334150025222A0B824A98B539B78",
  18. "referer": "http://appspeed.piaoquantv.com",
  19. "token": "524a8bc871dbb0f4d4717895083172ab37c02d2f",
  20. "accept-language": "zh-CN,zh-Hans;q=0.9",
  21. "Content-Type": "application/x-www-form-urlencoded",
  22. }
  23. payload = {
  24. "deviceToken": "9ef064f2f7869b3fd67d6141f8a899175dddc91240971172f1f2a662ef891408",
  25. "fileExtensions": "MP4",
  26. "loginUid": uid,
  27. "networkType": "Wi-Fi",
  28. "platform": "iOS",
  29. "requestId": "fb972cbd4f390afcfd3da1869cd7d001",
  30. "sessionId": "362290597725ce1fa870d7be4f46dcc2",
  31. "subSessionId": "362290597725ce1fa870d7be4f46dcc2",
  32. "title": title,
  33. "token": "524a8bc871dbb0f4d4717895083172ab37c02d2f",
  34. "uid": uid,
  35. "versionCode": "486",
  36. "versionName": "3.4.12",
  37. "videoFromScene": "1",
  38. "videoPath": oss_path,
  39. "viewStatus": "1",
  40. "appType": 888880,
  41. "repeatStatus": 1
  42. }
  43. response = await async_post(url, headers, payload)
  44. return response
  45. async def get_pq_video_detail(video_id):
  46. """
  47. 获取票圈视频详情信息
  48. :return:
  49. """
  50. url = "https://longvideoapi.piaoquantv.com/longvideoapi/openapi/video/batchSelectVideoInfo"
  51. data = {
  52. "videoIdList": [video_id]
  53. }
  54. header = {
  55. "Content-Type": "application/json",
  56. }
  57. response = await async_post(url, header, json.dumps(data))
  58. return response
  59. async def get_new_video_ids(video_obj_list):
  60. """
  61. video
  62. :return:
  63. """
  64. vid_list = []
  65. for video_obj in video_obj_list:
  66. # video_obj 里面的信息对于历史数据可能不全,需要从pq获取
  67. try:
  68. if len(vid_list) >= 3:
  69. return vid_list
  70. else:
  71. pq_response = await publish_to_pq(video_obj)
  72. video_id = pq_response['data']['id']
  73. vid_list.append(video_id)
  74. except:
  75. continue
  76. return vid_list