123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199 |
- import requests
- from urllib.parse import urlencode
- import json
- class PQ:
- @classmethod
- def install_tj_pq(cls, video_id, new_video_path, new_title, n_id, cover_path):
- url = "https://longvideoapi.piaoquantv.com/longvideoapi/crawler/video/send?muid=999"
- payload = {
- 'loginUid': n_id,
- 'oldVideoReRecommendVideoId': video_id,
- 'videoPath': new_video_path,
- 'coverImgPath': cover_path,
- 'appType': 999000,
- 'viewStatus': 1,
- 'versionCode': 100,
- 'fileExtensions': 'mp4',
- 'videoFromScene': 1,
- 'title': new_title,
- 'descr': "",
- 'copyType': 2
- }
- headers = {
- 'User-Agent': 'PQSpeed/486 CFNetwork/1410.1 Darwin/22.6.0',
- 'cookie': 'JSESSIONID=4DEA2B5173BB9A9E82DB772C0ACDBC9F; JSESSIONID=D02C334150025222A0B824A98B539B78; JSESSIONID=3538C8F690744960BC2B4F02B4A3B1E4',
- 'referer': 'http://appspeed.piaoquantv.com',
- 'token': '524a8bc871dbb0f4d4717895083172ab37c02d2f',
- 'accept-language': 'zh-CN,zh-Hans;q=0.9',
- 'Content-Type': 'application/x-www-form-urlencoded'
- }
- response = requests.request("POST", url, headers=headers, data=payload, timeout=30)
- data = response.json()
- code = data["code"]
- if code == 0:
- new_video_id = data["data"]["id"]
- print(new_video_id)
- return new_video_id
- """
- 新生成视频上传到对应账号下
- """
- @classmethod
- def insert_piaoquantv(cls, new_video_path, new_title, n_id, cover_path):
- url = "https://videopre.piaoquantv.com/longvideoapi/crawler/video/send?muid=999"
- headers = {
- 'User-Agent': 'PQSpeed/486 CFNetwork/1410.1 Darwin/22.6.0',
- 'cookie': 'JSESSIONID=4DEA2B5173BB9A9E82DB772C0ACDBC9F; JSESSIONID=D02C334150025222A0B824A98B539B78',
- 'referer': 'http://appspeed.piaoquantv.com',
- 'token': '524a8bc871dbb0f4d4717895083172ab37c02d2f',
- 'accept-language': 'zh-CN,zh-Hans;q=0.9',
- 'Content-Type': 'application/x-www-form-urlencoded'
- }
- payload = {
- 'deviceToken': '9ef064f2f7869b3fd67d6141f8a899175dddc91240971172f1f2a662ef891408',
- 'fileExtensions': 'MP4',
- 'loginUid': n_id,
- 'networkType': 'Wi-Fi',
- 'platform': 'iOS',
- 'requestId': 'fb972cbd4f390afcfd3da1869cd7d001',
- 'sessionId': '362290597725ce1fa870d7be4f46dcc2',
- 'subSessionId': '362290597725ce1fa870d7be4f46dcc2',
- 'title': new_title,
- 'token': '524a8bc871dbb0f4d4717895083172ab37c02d2f',
- 'uid': n_id,
- 'versionCode': '486',
- 'versionName': '3.4.12',
- 'videoFromScene': '1',
- 'videoPath': new_video_path,
- 'viewStatus': '1',
- 'coverImgPath' : cover_path
- }
- encoded_payload = urlencode(payload)
- response = requests.request("POST", url, headers=headers, data=encoded_payload, timeout=30)
- data = response.json()
- code = data["code"]
- if code == 0:
- new_video_id = data["data"]["id"]
- print(new_video_id)
- return new_video_id
- return None
- @classmethod
- def get_pq_oss(cls,video_id):
- try:
- url = "https://longvideoapi.piaoquantv.com/longvideoapi/openapi/video/getBaseInfo"
- payload = json.dumps({
- "videoId": int(video_id)
- })
- headers = {
- 'Content-Type': 'application/json',
- 'Cookie': 'JSESSIONID=658158EABFCF6AC9B9BB0D8B61897A88'
- }
- for i in range(3):
- response = requests.request("POST", url, headers=headers, data=payload, timeout=30)
- response = response.json()
- code = response['code']
- if code == 0:
- data = response['data']
- video_path = data["videoPath"]
- cover_path = data["coverImgPath"]
- title = data["title"]
- return video_path, cover_path, title
- return None, None, None
- except Exception as e:
- return None, None, None
- @classmethod
- def video_tag(cls, pq_id: str, tag: str):
- url = "https://admin.piaoquantv.com/manager/video/tag/addVideoTags"
- payload = json.dumps({
- "videoId": pq_id,
- "tagNames": tag
- })
- headers = {
- 'Content-Type': 'application/json'
- }
- requests.request("POST", url, headers=headers, data=payload)
- @classmethod
- def get_pd_id(cls, video_id: str):
- """获取封面id"""
- url = "https://admin.piaoquantv.com/manager/video/multiTitleV2/listV2?muid=999"
- payload = json.dumps({
- "videoId": video_id,
- "range": "4h"
- })
- headers = {
- 'accept': 'application/json',
- 'accept-language': 'zh-CN,zh;q=0.9',
- 'cache-control': 'no-cache',
- 'content-type': 'application/json',
- 'cookie': 'SESSION=YjVlOTI0ZWMtN2JkMy00MWIyLTk1NWItNmY5NTFlYjgxNjAy',
- 'origin': 'https://admin.piaoquantv.com',
- 'pragma': 'no-cache',
- 'priority': 'u=1, i',
- 'sec-ch-ua-mobile': '?0',
- 'sec-ch-ua-platform': '"macOS"',
- 'sec-fetch-dest': 'empty',
- 'sec-fetch-mode': 'cors',
- 'sec-fetch-site': 'same-origin'
- }
- response = requests.request("POST", url, headers=headers, data=payload)
- response = response.json()
- code = response['code']
- if code != 0:
- return None
- pq_id = response['content'][0]['id']
- return pq_id
- @classmethod
- def update_pq_title(cls ,video_id: str, new_title: str):
- pq_id = cls.get_pd_id(video_id)
- if not pq_id:
- return
- url = "https://admin.piaoquantv.com/manager/video/multiTitleV2/update?muid=999"
- payload = json.dumps([
- {
- "id": pq_id,
- "title": new_title,
- "videoId": video_id,
- "distributionWeight": 1000,
- "shareWeight": 1000
- }
- ])
- headers = {
- 'accept': 'application/json',
- 'accept-language': 'zh-CN,zh;q=0.9',
- 'content-type': 'application/json',
- 'cookie': 'SESSION=YjVlOTI0ZWMtN2JkMy00MWIyLTk1NWItNmY5NTFlYjgxNjAy',
- 'origin': 'https://admin.piaoquantv.com',
- 'priority': 'u=1, i',
- 'sec-ch-ua-mobile': '?0',
- 'sec-ch-ua-platform': '"macOS"',
- 'sec-fetch-dest': 'empty',
- 'sec-fetch-mode': 'cors',
- 'sec-fetch-site': 'same-origin',
- }
- response = requests.request("POST", url, headers=headers, data=payload)
- response = response.json()
- code = response['code']
- return code
- if __name__ == '__main__':
- PQ.get_pq_oss(47377130)
|