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 publishToPQ(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. cover = video_obj['coverPath']
  15. url = "https://vlogapi.piaoquantv.com/longvideoapi/crawler/video/send"
  16. headers = {
  17. "User-Agent": "PQSpeed/486 CFNetwork/1410.1 Darwin/22.6.0",
  18. "cookie": "JSESSIONID=4DEA2B5173BB9A9E82DB772C0ACDBC9F; JSESSIONID=D02C334150025222A0B824A98B539B78",
  19. "referer": "http://appspeed.piaoquantv.com",
  20. "token": "524a8bc871dbb0f4d4717895083172ab37c02d2f",
  21. "accept-language": "zh-CN,zh-Hans;q=0.9",
  22. "Content-Type": "application/x-www-form-urlencoded",
  23. }
  24. payload = {
  25. "coverImgPath": cover,
  26. "deviceToken": "9ef064f2f7869b3fd67d6141f8a899175dddc91240971172f1f2a662ef891408",
  27. "fileExtensions": "MP4",
  28. "loginUid": uid,
  29. "networkType": "Wi-Fi",
  30. "platform": "iOS",
  31. "requestId": "fb972cbd4f390afcfd3da1869cd7d001",
  32. "sessionId": "362290597725ce1fa870d7be4f46dcc2",
  33. "subSessionId": "362290597725ce1fa870d7be4f46dcc2",
  34. "title": title,
  35. "token": "524a8bc871dbb0f4d4717895083172ab37c02d2f",
  36. "uid": uid,
  37. "versionCode": "486",
  38. "versionName": "3.4.12",
  39. "videoFromScene": "1",
  40. "videoPath": oss_path,
  41. "viewStatus": "1",
  42. }
  43. response = await async_post(url, headers, payload)
  44. return response
  45. async def getPQVideoDetail(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 getNewVideoIds(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 publishToPQ(video_obj)
  72. video_id = pq_response['data']['id']
  73. vid_list.append(video_id)
  74. except:
  75. continue
  76. return vid_list