piaoquan.py 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. import requests
  2. from urllib.parse import urlencode
  3. import json
  4. class PQ:
  5. @classmethod
  6. def install_tj_pq(cls, video_id, new_video_path, new_title, n_id, cover_path):
  7. url = "https://longvideoapi.piaoquantv.com/longvideoapi/crawler/video/send?muid=999"
  8. payload = {
  9. 'loginUid': n_id,
  10. 'oldVideoReRecommendVideoId': video_id,
  11. 'videoPath': new_video_path,
  12. 'coverImgPath': cover_path,
  13. 'appType': 999000,
  14. 'viewStatus': 1,
  15. 'versionCode': 100,
  16. 'fileExtensions': 'mp4',
  17. 'videoFromScene': 1,
  18. 'title': new_title,
  19. 'descr': "",
  20. 'copyType': 2
  21. }
  22. headers = {
  23. 'User-Agent': 'PQSpeed/486 CFNetwork/1410.1 Darwin/22.6.0',
  24. 'cookie': 'JSESSIONID=4DEA2B5173BB9A9E82DB772C0ACDBC9F; JSESSIONID=D02C334150025222A0B824A98B539B78; JSESSIONID=3538C8F690744960BC2B4F02B4A3B1E4',
  25. 'referer': 'http://appspeed.piaoquantv.com',
  26. 'token': '524a8bc871dbb0f4d4717895083172ab37c02d2f',
  27. 'accept-language': 'zh-CN,zh-Hans;q=0.9',
  28. 'Content-Type': 'application/x-www-form-urlencoded'
  29. }
  30. response = requests.request("POST", url, headers=headers, data=payload, timeout=30)
  31. data = response.json()
  32. code = data["code"]
  33. if code == 0:
  34. new_video_id = data["data"]["id"]
  35. print(new_video_id)
  36. return new_video_id
  37. """
  38. 新生成视频上传到对应账号下
  39. """
  40. @classmethod
  41. def insert_piaoquantv(cls, new_video_path, new_title, n_id, cover_path):
  42. url = "https://videopre.piaoquantv.com/longvideoapi/crawler/video/send?muid=999"
  43. headers = {
  44. 'User-Agent': 'PQSpeed/486 CFNetwork/1410.1 Darwin/22.6.0',
  45. 'cookie': 'JSESSIONID=4DEA2B5173BB9A9E82DB772C0ACDBC9F; JSESSIONID=D02C334150025222A0B824A98B539B78',
  46. 'referer': 'http://appspeed.piaoquantv.com',
  47. 'token': '524a8bc871dbb0f4d4717895083172ab37c02d2f',
  48. 'accept-language': 'zh-CN,zh-Hans;q=0.9',
  49. 'Content-Type': 'application/x-www-form-urlencoded'
  50. }
  51. payload = {
  52. 'deviceToken': '9ef064f2f7869b3fd67d6141f8a899175dddc91240971172f1f2a662ef891408',
  53. 'fileExtensions': 'MP4',
  54. 'loginUid': n_id,
  55. 'networkType': 'Wi-Fi',
  56. 'platform': 'iOS',
  57. 'requestId': 'fb972cbd4f390afcfd3da1869cd7d001',
  58. 'sessionId': '362290597725ce1fa870d7be4f46dcc2',
  59. 'subSessionId': '362290597725ce1fa870d7be4f46dcc2',
  60. 'title': new_title,
  61. 'token': '524a8bc871dbb0f4d4717895083172ab37c02d2f',
  62. 'uid': n_id,
  63. 'versionCode': '486',
  64. 'versionName': '3.4.12',
  65. 'videoFromScene': '1',
  66. 'videoPath': new_video_path,
  67. 'viewStatus': '1',
  68. 'coverImgPath' : cover_path
  69. }
  70. encoded_payload = urlencode(payload)
  71. response = requests.request("POST", url, headers=headers, data=encoded_payload, timeout=30)
  72. data = response.json()
  73. code = data["code"]
  74. if code == 0:
  75. new_video_id = data["data"]["id"]
  76. print(new_video_id)
  77. return new_video_id
  78. return None
  79. @classmethod
  80. def get_pq_oss(cls,video_id):
  81. try:
  82. url = "https://longvideoapi.piaoquantv.com/longvideoapi/openapi/video/getBaseInfo"
  83. payload = json.dumps({
  84. "videoId": int(video_id)
  85. })
  86. headers = {
  87. 'Content-Type': 'application/json',
  88. 'Cookie': 'JSESSIONID=658158EABFCF6AC9B9BB0D8B61897A88'
  89. }
  90. for i in range(3):
  91. response = requests.request("POST", url, headers=headers, data=payload, timeout=30)
  92. response = response.json()
  93. code = response['code']
  94. if code == 0:
  95. data = response['data']
  96. video_path = data["videoPath"]
  97. video_title = data["title"]
  98. return video_title, video_path
  99. return None
  100. except Exception as e:
  101. return None
  102. @classmethod
  103. def video_tag(cls, pq_id: str, tag: str):
  104. url = "https://admin.piaoquantv.com/manager/video/tag/addVideoTags"
  105. payload = json.dumps({
  106. "videoId": pq_id,
  107. "tagNames": tag
  108. })
  109. headers = {
  110. 'Content-Type': 'application/json'
  111. }
  112. requests.request("POST", url, headers=headers, data=payload)
  113. @classmethod
  114. def get_pd_id(cls, video_id: str):
  115. """获取封面id"""
  116. url = "https://admin.piaoquantv.com/manager/video/multiTitleV2/listV2?muid=999"
  117. payload = json.dumps({
  118. "videoId": video_id,
  119. "range": "4h"
  120. })
  121. headers = {
  122. 'accept': 'application/json',
  123. 'accept-language': 'zh-CN,zh;q=0.9',
  124. 'cache-control': 'no-cache',
  125. 'content-type': 'application/json',
  126. 'cookie': 'SESSION=YjVlOTI0ZWMtN2JkMy00MWIyLTk1NWItNmY5NTFlYjgxNjAy',
  127. 'origin': 'https://admin.piaoquantv.com',
  128. 'pragma': 'no-cache',
  129. 'priority': 'u=1, i',
  130. 'sec-ch-ua-mobile': '?0',
  131. 'sec-ch-ua-platform': '"macOS"',
  132. 'sec-fetch-dest': 'empty',
  133. 'sec-fetch-mode': 'cors',
  134. 'sec-fetch-site': 'same-origin'
  135. }
  136. response = requests.request("POST", url, headers=headers, data=payload)
  137. response = response.json()
  138. code = response['code']
  139. if code != 0:
  140. return None
  141. pq_id = response['content'][0]['id']
  142. return pq_id
  143. @classmethod
  144. def update_pq_title(cls ,video_id: str, new_title: str):
  145. pq_id = cls.get_pd_id(video_id)
  146. if not pq_id:
  147. return
  148. url = "https://admin.piaoquantv.com/manager/video/multiTitleV2/update?muid=999"
  149. payload = json.dumps([
  150. {
  151. "id": pq_id,
  152. "title": new_title,
  153. "videoId": video_id,
  154. "distributionWeight": 1000,
  155. "shareWeight": 1000
  156. }
  157. ])
  158. headers = {
  159. 'accept': 'application/json',
  160. 'accept-language': 'zh-CN,zh;q=0.9',
  161. 'content-type': 'application/json',
  162. 'cookie': 'SESSION=YjVlOTI0ZWMtN2JkMy00MWIyLTk1NWItNmY5NTFlYjgxNjAy',
  163. 'origin': 'https://admin.piaoquantv.com',
  164. 'priority': 'u=1, i',
  165. 'sec-ch-ua-mobile': '?0',
  166. 'sec-ch-ua-platform': '"macOS"',
  167. 'sec-fetch-dest': 'empty',
  168. 'sec-fetch-mode': 'cors',
  169. 'sec-fetch-site': 'same-origin',
  170. }
  171. response = requests.request("POST", url, headers=headers, data=payload)
  172. response = response.json()
  173. code = response['code']
  174. return code
  175. if __name__ == '__main__':
  176. PQ.get_pq_oss(47377130)