piaoquan.py 4.1 KB

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