piaoquan.py 4.2 KB

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