|
@@ -12,6 +12,7 @@ from datetime import datetime, timedelta
|
|
|
|
|
|
from applications.functions.ask_kimi import ask_kimi
|
|
from applications.functions.ask_kimi import ask_kimi
|
|
from applications.functions.calculate import title_mix
|
|
from applications.functions.calculate import title_mix
|
|
|
|
+from applications.functions.auto_white import auto_white
|
|
|
|
|
|
|
|
|
|
class ProcessParams(object):
|
|
class ProcessParams(object):
|
|
@@ -58,6 +59,8 @@ class ProcessParams(object):
|
|
"""
|
|
"""
|
|
root_share_id = str(uuid.uuid4())
|
|
root_share_id = str(uuid.uuid4())
|
|
url = f"pages/user-videos?id={video_id}&su={shared_uid}&fromGzh=1&rootShareId={root_share_id}&shareId={root_share_id}"
|
|
url = f"pages/user-videos?id={video_id}&su={shared_uid}&fromGzh=1&rootShareId={root_share_id}&shareId={root_share_id}"
|
|
|
|
+ # 自动把 root_share_id 加入到白名单
|
|
|
|
+ auto_white(root_share_id)
|
|
return root_share_id, f"pages/category?jumpPage={urllib.parse.quote(url)}"
|
|
return root_share_id, f"pages/category?jumpPage={urllib.parse.quote(url)}"
|
|
|
|
|
|
@classmethod
|
|
@classmethod
|
|
@@ -77,6 +80,23 @@ class ProcessParams(object):
|
|
response = requests.post(url, headers=header, data=json.dumps(data))
|
|
response = requests.post(url, headers=header, data=json.dumps(data))
|
|
return response.json()
|
|
return response.json()
|
|
|
|
|
|
|
|
+ @classmethod
|
|
|
|
+ def choose_video(cls, result):
|
|
|
|
+ """
|
|
|
|
+ :param result: 计算出来的结果
|
|
|
|
+ :return: uid, video_id
|
|
|
|
+ """
|
|
|
|
+ # 判断 score
|
|
|
|
+ score1, score2 = result['s1_score'], result['s2_score']
|
|
|
|
+ if score1 == 0 and score2 == 0:
|
|
|
|
+ return None, None
|
|
|
|
+ elif score1 == 0 and score2 > 0:
|
|
|
|
+ return result['s2_uid'], result['s2_vid']
|
|
|
|
+ elif score1 > 0 and score2 == 0:
|
|
|
|
+ return result['s1_uid'], result['s1_vid']
|
|
|
|
+ elif score1 > 0 and score2 > 0:
|
|
|
|
+ return result['s1_uid'], result['s1_vid']
|
|
|
|
+
|
|
@classmethod
|
|
@classmethod
|
|
def process(cls, data):
|
|
def process(cls, data):
|
|
"""执行代码"""
|
|
"""执行代码"""
|
|
@@ -90,23 +110,35 @@ class ProcessParams(object):
|
|
else:
|
|
else:
|
|
cls.ask_kimi_and_save_to_local(title)
|
|
cls.ask_kimi_and_save_to_local(title)
|
|
result = title_mix(title_p=title_p, dt=yesterday_str)
|
|
result = title_mix(title_p=title_p, dt=yesterday_str)
|
|
- uid, video_id = result['s1_uid'], result['s1_vid']
|
|
|
|
- root_share_id, productionPath = cls.create_gzh_path(uid, video_id)
|
|
|
|
- response = cls.request_for_info(video_id)
|
|
|
|
- productionCover = response['data'][0]['shareImgPath']
|
|
|
|
- productionName = response["data"][0]['title']
|
|
|
|
- programAvatar = "/static/logo.png"
|
|
|
|
- programId = "wx89e7eb06478361d7"
|
|
|
|
- programName = "票圈vlog"
|
|
|
|
- source = "Web"
|
|
|
|
- result = {
|
|
|
|
- "productionCover": productionCover,
|
|
|
|
- "productionName": productionName,
|
|
|
|
- "programAvatar": programAvatar,
|
|
|
|
- "programId": programId,
|
|
|
|
- "programName": programName,
|
|
|
|
- "source": source,
|
|
|
|
- "rootShareId": root_share_id,
|
|
|
|
- "productionPath": productionPath
|
|
|
|
- }
|
|
|
|
|
|
+ uid, video_id = cls.choose_video(result)
|
|
|
|
+ if video_id and uid:
|
|
|
|
+ root_share_id, productionPath = cls.create_gzh_path(uid, video_id)
|
|
|
|
+ response = cls.request_for_info(video_id)
|
|
|
|
+ productionCover = response['data'][0]['shareImgPath']
|
|
|
|
+ productionName = response["data"][0]['title']
|
|
|
|
+ programAvatar = "/static/logo.png"
|
|
|
|
+ programId = "wx89e7eb06478361d7"
|
|
|
|
+ programName = "票圈vlog"
|
|
|
|
+ source = "Web"
|
|
|
|
+ result = {
|
|
|
|
+ "productionCover": productionCover,
|
|
|
|
+ "productionName": productionName,
|
|
|
|
+ "programAvatar": programAvatar,
|
|
|
|
+ "programId": programId,
|
|
|
|
+ "programName": programName,
|
|
|
|
+ "source": source,
|
|
|
|
+ "rootShareId": root_share_id,
|
|
|
|
+ "productionPath": productionPath
|
|
|
|
+ }
|
|
|
|
+ else:
|
|
|
|
+ result = {
|
|
|
|
+ "productionCover": None,
|
|
|
|
+ "productionName": None,
|
|
|
|
+ "programAvatar": None,
|
|
|
|
+ "programId": None,
|
|
|
|
+ "programName": None,
|
|
|
|
+ "source": None,
|
|
|
|
+ "rootShareId": None,
|
|
|
|
+ "productionPath": None
|
|
|
|
+ }
|
|
return result
|
|
return result
|