piaoquan.py 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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, cover):
  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. if cover:
  39. payload['coverImgPath'] = cover
  40. encoded_payload = urlencode(payload)
  41. response = requests.request("POST", url, headers=headers, data=encoded_payload, timeout=30)
  42. data = response.json()
  43. code = data["code"]
  44. if code == 0:
  45. new_video_id = data["data"]["id"]
  46. return new_video_id
  47. return None
  48. @classmethod
  49. def get_pq_oss_path(cls, video_id):
  50. try:
  51. url = "https://longvideoapi.piaoquantv.com/longvideoapi/openapi/video/getBaseInfo"
  52. payload = json.dumps({
  53. "videoId": int(video_id)
  54. })
  55. headers = {
  56. 'Content-Type': 'application/json',
  57. 'Cookie': 'JSESSIONID=658158EABFCF6AC9B9BB0D8B61897A88'
  58. }
  59. for i in range(3):
  60. response = requests.request("POST", url, headers=headers, data=payload, timeout=30)
  61. response = response.json()
  62. code = response['code']
  63. if code == 0:
  64. data = response['data']
  65. video_path = data["videoPath"]
  66. cover_path = data["coverImgPath"]
  67. title = data["title"]
  68. return video_path, cover_path, title
  69. return None, None, None
  70. except Exception as e:
  71. return None, None, None
  72. @classmethod
  73. def get_pq_oss(cls, video_id_list):
  74. url_list = []
  75. for video_id in video_id_list:
  76. try:
  77. url = "https://longvideoapi.piaoquantv.com/longvideoapi/openapi/video/getBaseInfo"
  78. payload = json.dumps({
  79. "videoId": int(video_id)
  80. })
  81. headers = {
  82. 'Content-Type': 'application/json',
  83. 'Cookie': 'JSESSIONID=658158EABFCF6AC9B9BB0D8B61897A88'
  84. }
  85. response = requests.request("POST", url, headers=headers, data=payload, timeout=10)
  86. response = response.json()
  87. code = response['code']
  88. if code == 0:
  89. data = response['data']
  90. video_path = data["videoPath"]
  91. url_list.append(f"http://rescdn.yishihui.com/{video_path}")
  92. time.sleep(1)
  93. continue
  94. except Exception as e:
  95. time.sleep(1)
  96. continue
  97. return url_list
  98. if __name__ == '__main__':
  99. rg_pw = "47969744,47969804,47969813,47969815,47969816"
  100. PQ.get_pq_oss(rg_pw)