piaoquan.py 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  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. cover_path = data["coverImgPath"]
  98. title = data["title"]
  99. return video_path, cover_path, title
  100. return None, None, None
  101. except Exception as e:
  102. return None, None, None
  103. @classmethod
  104. def video_tag(cls, pq_id: str, tag: str):
  105. url = "https://admin.piaoquantv.com/manager/video/tag/addVideoTags"
  106. payload = json.dumps({
  107. "videoId": pq_id,
  108. "tagNames": tag
  109. })
  110. headers = {
  111. 'Content-Type': 'application/json'
  112. }
  113. requests.request("POST", url, headers=headers, data=payload)
  114. @classmethod
  115. def get_pd_id(cls, video_id: str):
  116. """获取封面id"""
  117. url = "https://admin.piaoquantv.com/manager/video/multiTitleV2/listV2?muid=999"
  118. payload = json.dumps({
  119. "videoId": video_id,
  120. "range": "4h"
  121. })
  122. headers = {
  123. 'accept': 'application/json',
  124. 'accept-language': 'zh-CN,zh;q=0.9',
  125. 'cache-control': 'no-cache',
  126. 'content-type': 'application/json',
  127. 'cookie': 'SESSION=YjVlOTI0ZWMtN2JkMy00MWIyLTk1NWItNmY5NTFlYjgxNjAy',
  128. 'origin': 'https://admin.piaoquantv.com',
  129. 'pragma': 'no-cache',
  130. 'priority': 'u=1, i',
  131. 'sec-ch-ua-mobile': '?0',
  132. 'sec-ch-ua-platform': '"macOS"',
  133. 'sec-fetch-dest': 'empty',
  134. 'sec-fetch-mode': 'cors',
  135. 'sec-fetch-site': 'same-origin'
  136. }
  137. response = requests.request("POST", url, headers=headers, data=payload)
  138. response = response.json()
  139. code = response['code']
  140. if code != 0:
  141. return None
  142. pq_id = response['content'][0]['id']
  143. return pq_id
  144. @classmethod
  145. def update_pq_title(cls ,video_id: str, new_title: str):
  146. pq_id = cls.get_pd_id(video_id)
  147. if not pq_id:
  148. return
  149. url = "https://admin.piaoquantv.com/manager/video/multiTitleV2/update?muid=999"
  150. payload = json.dumps([
  151. {
  152. "id": pq_id,
  153. "title": new_title,
  154. "videoId": video_id,
  155. "distributionWeight": 1000,
  156. "shareWeight": 1000
  157. }
  158. ])
  159. headers = {
  160. 'accept': 'application/json',
  161. 'accept-language': 'zh-CN,zh;q=0.9',
  162. 'content-type': 'application/json',
  163. 'cookie': 'SESSION=YjVlOTI0ZWMtN2JkMy00MWIyLTk1NWItNmY5NTFlYjgxNjAy',
  164. 'origin': 'https://admin.piaoquantv.com',
  165. 'priority': 'u=1, i',
  166. 'sec-ch-ua-mobile': '?0',
  167. 'sec-ch-ua-platform': '"macOS"',
  168. 'sec-fetch-dest': 'empty',
  169. 'sec-fetch-mode': 'cors',
  170. 'sec-fetch-site': 'same-origin',
  171. }
  172. response = requests.request("POST", url, headers=headers, data=payload)
  173. response = response.json()
  174. code = response['code']
  175. return code
  176. if __name__ == '__main__':
  177. PQ.get_pq_oss(47377130)