piaoquan.py 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. import json
  2. import time
  3. import requests
  4. from urllib.parse import urlencode
  5. class PQ:
  6. """
  7. 新生成视频上传到对应账号下
  8. """
  9. @classmethod
  10. def insert_piaoquantv(cls, new_video_path, new_title, n_id):
  11. url = "https://vlogapi.piaoquantv.com/longvideoapi/crawler/video/send?muid=999"
  12. headers = {
  13. 'User-Agent': 'PQSpeed/486 CFNetwork/1410.1 Darwin/22.6.0',
  14. 'cookie': 'JSESSIONID=4DEA2B5173BB9A9E82DB772C0ACDBC9F; JSESSIONID=D02C334150025222A0B824A98B539B78',
  15. 'referer': 'http://appspeed.piaoquantv.com',
  16. 'token': '524a8bc871dbb0f4d4717895083172ab37c02d2f',
  17. 'accept-language': 'zh-CN,zh-Hans;q=0.9',
  18. 'Content-Type': 'application/x-www-form-urlencoded'
  19. }
  20. payload = {
  21. 'deviceToken': '9ef064f2f7869b3fd67d6141f8a899175dddc91240971172f1f2a662ef891408',
  22. 'fileExtensions': 'MP4',
  23. 'loginUid': n_id,
  24. 'networkType': 'Wi-Fi',
  25. 'platform': 'iOS',
  26. 'requestId': 'fb972cbd4f390afcfd3da1869cd7d001',
  27. 'sessionId': '362290597725ce1fa870d7be4f46dcc2',
  28. 'subSessionId': '362290597725ce1fa870d7be4f46dcc2',
  29. 'title': new_title,
  30. 'token': '524a8bc871dbb0f4d4717895083172ab37c02d2f',
  31. 'uid': n_id,
  32. 'versionCode': '486',
  33. 'versionName': '3.4.12',
  34. 'videoFromScene': '1',
  35. 'videoPath': new_video_path,
  36. 'viewStatus': '1'
  37. }
  38. encoded_payload = urlencode(payload)
  39. response = requests.request("POST", url, headers=headers, data=encoded_payload, timeout=10)
  40. data = response.json()
  41. code = data["code"]
  42. if code == 0:
  43. new_video_id = data["data"]["id"]
  44. return new_video_id
  45. return None
  46. @classmethod
  47. def get_pq_oss_path(cls, video_id):
  48. try:
  49. url = "https://longvideoapi.piaoquantv.com/longvideoapi/openapi/video/getBaseInfo"
  50. payload = json.dumps({
  51. "videoId": int(video_id)
  52. })
  53. headers = {
  54. 'Content-Type': 'application/json',
  55. 'Cookie': 'JSESSIONID=658158EABFCF6AC9B9BB0D8B61897A88'
  56. }
  57. for i in range(3):
  58. response = requests.request("POST", url, headers=headers, data=payload, timeout=30)
  59. response = response.json()
  60. code = response['code']
  61. if code == 0:
  62. data = response['data']
  63. video_path = data["videoPath"]
  64. cover_path = data["coverImgPath"]
  65. title = data["title"]
  66. return video_path, cover_path, title
  67. return None, None, None
  68. except Exception as e:
  69. return None, None, None
  70. @classmethod
  71. def get_pq_oss(cls, video_id_list):
  72. url_list = []
  73. for video_id in video_id_list:
  74. try:
  75. url = "https://longvideoapi.piaoquantv.com/longvideoapi/openapi/video/getBaseInfo"
  76. payload = json.dumps({
  77. "videoId": int(video_id)
  78. })
  79. headers = {
  80. 'Content-Type': 'application/json',
  81. 'Cookie': 'JSESSIONID=658158EABFCF6AC9B9BB0D8B61897A88'
  82. }
  83. response = requests.request("POST", url, headers=headers, data=payload, timeout=10)
  84. response = response.json()
  85. code = response['code']
  86. if code == 0:
  87. data = response['data']
  88. video_path = data["videoPath"]
  89. url_list.append(f"http://rescdn.yishihui.com/{video_path}")
  90. time.sleep(1)
  91. continue
  92. except Exception as e:
  93. time.sleep(1)
  94. continue
  95. return url_list
  96. if __name__ == '__main__':
  97. rg_pw = "47969744,47969804,47969813,47969815,47969816"
  98. PQ.get_pq_oss(rg_pw)