import json import time import requests from urllib.parse import urlencode class PQ: """ 新生成视频上传到对应账号下 """ @classmethod def insert_piaoquantv(cls, new_video_path, new_title, n_id, cover): url = "https://vlogapi.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' } if cover: payload['coverImgPath'] = cover 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"] return new_video_id return None @classmethod def get_pq_oss_path(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 get_pq_oss(cls, video_id_list): url_list = [] for video_id in video_id_list: 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' } response = requests.request("POST", url, headers=headers, data=payload, timeout=10) response = response.json() code = response['code'] if code == 0: data = response['data'] video_path = data["videoPath"] url_list.append(f"http://rescdn.yishihui.com/{video_path}") time.sleep(1) continue except Exception as e: time.sleep(1) continue return url_list if __name__ == '__main__': rg_pw = "47969744,47969804,47969813,47969815,47969816" PQ.get_pq_oss(rg_pw)