|
@@ -0,0 +1,99 @@
|
|
|
+"""
|
|
|
+@author: luojunhui
|
|
|
+"""
|
|
|
+"""
|
|
|
+@author: luojunhui
|
|
|
+"""
|
|
|
+import time
|
|
|
+import json
|
|
|
+import uuid
|
|
|
+import random
|
|
|
+import hashlib
|
|
|
+import requests
|
|
|
+import urllib.parse
|
|
|
+
|
|
|
+
|
|
|
+def create_gzh_path(video_id, shared_uid):
|
|
|
+ """
|
|
|
+ :param video_id: 视频 id
|
|
|
+ :param shared_uid: 分享 id
|
|
|
+ """
|
|
|
+
|
|
|
+ def auto_white(root_share_id_):
|
|
|
+ """
|
|
|
+ 自动加入白名单, 保证公众号百分百出广告
|
|
|
+ :param root_share_id_:
|
|
|
+ :return:
|
|
|
+ """
|
|
|
+
|
|
|
+ def get_cookie():
|
|
|
+ """
|
|
|
+ 获取 cookie
|
|
|
+ :return:
|
|
|
+ """
|
|
|
+ url = "https://admin.piaoquantv.com/manager/login?account=luojunhui&passWd=e10adc3949ba59abbe56e057f20f883e&muid=7"
|
|
|
+ payload = {}
|
|
|
+ headers = {
|
|
|
+ 'accept': 'application/json, text/plain, */*',
|
|
|
+ 'accept-language': 'en',
|
|
|
+ 'priority': 'u=1, i',
|
|
|
+ 'sec-ch-ua': '"Chromium";v="124", "Google Chrome";v="124", "Not-A.Brand";v="99"',
|
|
|
+ 'sec-ch-ua-mobile': '?0',
|
|
|
+ 'sec-ch-ua-platform': '"macOS"',
|
|
|
+ 'sec-fetch-dest': 'empty',
|
|
|
+ 'sec-fetch-mode': 'cors',
|
|
|
+ 'sec-fetch-site': 'same-origin',
|
|
|
+ 'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36'
|
|
|
+ }
|
|
|
+ response = requests.request("GET", url, headers=headers, data=payload)
|
|
|
+ return response.cookies.values()[0]
|
|
|
+
|
|
|
+ url = "https://admin.piaoquantv.com/manager/ad/own/white/rootShare/save"
|
|
|
+ dd = {
|
|
|
+ "rootShareId": root_share_id_,
|
|
|
+ "commit": "算法自动加入白名单--"
|
|
|
+ }
|
|
|
+ payload = json.dumps(dd)
|
|
|
+ cookie = get_cookie()
|
|
|
+ headers = {
|
|
|
+ 'accept': 'application/json',
|
|
|
+ 'accept-language': 'en',
|
|
|
+ 'content-type': 'application/json;',
|
|
|
+ 'cookie': "SESSION=" + cookie,
|
|
|
+ 'origin': 'https://admin.piaoquantv.com',
|
|
|
+ 'priority': 'u=1, i',
|
|
|
+ 'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36'
|
|
|
+ }
|
|
|
+ response = requests.request("POST", url, headers=headers, data=payload)
|
|
|
+ return response.json()['content']
|
|
|
+
|
|
|
+ def generate_source_id():
|
|
|
+ """
|
|
|
+ generate_source_id
|
|
|
+ :return:
|
|
|
+ """
|
|
|
+ timestamp = str(int(time.time() * 1000))
|
|
|
+ random_str = str(random.randint(1000, 9999))
|
|
|
+ hash_input = f"{timestamp}-{random_str}"
|
|
|
+ return hashlib.md5(hash_input.encode()).hexdigest()
|
|
|
+
|
|
|
+ root_share_id = str(uuid.uuid4())
|
|
|
+ source_id = "longArticles_" + generate_source_id()
|
|
|
+ url = f"pages/user-videos?id={video_id}&su={shared_uid}&fromGzh=1&rootShareId={root_share_id}&shareId={root_share_id}&rootSourceId={source_id}"
|
|
|
+ # 自动把 root_share_id 加入到白名单
|
|
|
+ auto_white(root_share_id)
|
|
|
+ return root_share_id, f"pages/category?jumpPage={urllib.parse.quote(url, safe='')}"
|
|
|
+
|
|
|
+
|
|
|
+obj = {"productionCover": "http://rescdn.yishihui.com/d3dba68c-0ab3-4f0c-858d-7248121833da?x-oss-process=image/resize,m_fill,w_600,h_480,limit_0/format,jpg/watermark,image_eXNoL3BpYy93YXRlcm1hcmtlci9pY29uX3BsYXlfd2hpdGUucG5nP3gtb3NzLXByb2Nlc3M9aW1hZ2UvcmVzaXplLHdfMTQ0,g_center", "productionName": "【揭秘】中国与该国无冤无仇,为何处处作对?专家:罪有应得🔥", "programAvatar": "https://rescdn.yishihui.com/0temp/lehuo.png", "programId": "wxe8f8f0e23cecad0f", "programName": "票圈乐活", "source": "Web", "rootShareId": "3b249e9e-dcdc-412b-9079-cb0df947128c", "productionPath": "pages/category?jumpPage=pages%2Fuser-videos%3Fid%3D20857581%26su%3D69637493%26fromGzh%3D1%26rootShareId%3D3b249e9e-dcdc-412b-9079-cb0df947128c%26shareId%3D3b249e9e-dcdc-412b-9079-cb0df947128c", "videoUrl": "http://rescdn.yishihui.com/7f0f3e2d-3006-4f40-9004-5ab871dd885f.mp4"}
|
|
|
+
|
|
|
+video_id = "20857581"
|
|
|
+share_uid = "69637493"
|
|
|
+root_id, path = create_gzh_path(video_id, share_uid)
|
|
|
+cover = obj["productionCover"]
|
|
|
+title = obj['productionName']
|
|
|
+
|
|
|
+print("封面:\t", cover)
|
|
|
+print("标题:\t", title)
|
|
|
+print("root_share_id:\t", root_id)
|
|
|
+print("SharePath: \t", path)
|