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, can_search: bool = True): 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, new_user_id = data["data"]["id"], data["data"]["user"]["uid"] if not can_search: cls.change_recommend_status(pq_vid=str(new_video_id), pq_uid=str(new_user_id), can_search=can_search) return new_video_id, new_user_id return None, 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 @classmethod def change_recommend_status(cls, pq_vid: str, pq_uid: str, can_search: bool = False): # 小程序推荐状态 url = "https://admin.piaoquantv.com/manager/video/updateVideoRecommendStatus" headers = { 'accept': 'application/json, text/plain, */*', 'accept-language': 'zh-CN,zh;q=0.9', 'cache-control': 'no-cache', 'cookie': 'SESSION=M2FlYTM0MTctN2I2MS00NzFlLWEzZjItZjE4YzVhNmZjYTM3', 'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 ' '(KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36', } query = { 'id': pq_vid, 'uid': pq_uid, 'recommendStatus': '-7' if can_search else '0', 'muid': '999', } requests.request("GET", url, headers=headers, params=query, timeout=30) url = "https://admin.piaoquantv.com/manager/video/measure/delete" query = { 'videoId': pq_vid, 'muid': '999', } requests.request("GET", url, headers=headers, params=query, timeout=30) # App推荐状态 url = "https://admin.piaoquantv.com/manager/video/updateAppVideoRecommendStatus" query = { 'id': pq_vid, 'uid': pq_uid, 'appRecommendStatus': '-7' if can_search else '0', 'muid': '999', } requests.request("GET", url, headers=headers, params=query, timeout=30) if __name__ == '__main__': rg_pw = "47969744,47969804,47969813,47969815,47969816" PQ.get_pq_oss(rg_pw)