Ver código fonte

2024-07-04
两个账号返回新小程序

罗俊辉 10 meses atrás
pai
commit
798e63ab13

+ 24 - 0
applications/functions/common.py

@@ -85,6 +85,30 @@ def create_gzh_path(video_id, shared_uid):
     return root_share_id, source_id, f"pages/category?jumpPage={urllib.parse.quote(url, safe='')}"
 
 
+def create_gzh_path_v2(video_id, shared_uid):
+    """
+    :param video_id: 视频 id
+    :param shared_uid: 分享 id
+    """
+
+    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 = "touliu_tencentGzhArticle_" + 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, source_id, f"pages/category?jumpPage={urllib.parse.quote(url, safe='')}"
+
+
 def request_for_info(video_id):
     """
     请求数据

+ 1 - 1
applications/schedule/__init__.py

@@ -3,4 +3,4 @@
 """
 from .process_schedule import recall_videos
 from .search_schedule import search_videos, re_search_videos
-from .process_schedule import return_info_v2
+# from .process_schedule import return_info_v2

+ 39 - 30
applications/schedule/process_schedule.py

@@ -4,7 +4,7 @@
 """
 import json
 
-from applications.functions.common import request_for_info, create_gzh_path
+from applications.functions.common import request_for_info, create_gzh_path, create_gzh_path_v2
 from applications.functions.log import logging
 from applications.static.config import db_article
 
@@ -70,9 +70,10 @@ async def return_info_v2(video_id, trace_id, mysql_client):
     return result
 
 
-async def return_info(video_id, kimi_title, trace_id, mysql_client, index):
+async def return_info(video_id, kimi_title, trace_id, mysql_client, index, gh_id):
     """
 
+    :param gh_id: 公众号账号id
     :param index:
     :param mysql_client:
     :param trace_id:
@@ -85,11 +86,18 @@ async def return_info(video_id, kimi_title, trace_id, mysql_client, index):
     productionName = kimi_title
     videoUrl = response['data'][0]['videoPath']
     user_id = response['data'][0]['user']['uid']
-    programAvatar = "https://rescdn.yishihui.com/0temp/ssyqsh.png"
-    programId = "wx59d9e2c05f00f880"
-    programName = "刷刷有趣生活"
+    if gh_id in ['gh_93e00e187787', 'gh_ac43e43b253b']:
+        # 投流的两个账号
+        programAvatar = "https://rescdn.yishihui.com/0temp/zfyfyc.jpeg"
+        programId = "wxcddf231abd0dabdc"
+        programName = "祝福有福有财"
+        root_share_id, source_id, productionPath = create_gzh_path_v2(video_id=video_id, shared_uid=user_id)
+    else:
+        programAvatar = "https://rescdn.yishihui.com/0temp/ssyqsh.png"
+        programId = "wx59d9e2c05f00f880"
+        programName = "刷刷有趣生活"
+        root_share_id, source_id, productionPath = create_gzh_path(video_id=video_id, shared_uid=user_id)
     source = "Web"
-    root_share_id, source_id, productionPath = create_gzh_path(video_id=video_id, shared_uid=user_id)
     logging(
         code="1002",
         info="root_share_id --{}, productionPath -- {}".format(root_share_id, productionPath),
@@ -142,12 +150,12 @@ async def recall_videos(trace_id, mysql_client):
     :return:
     """
     select_sql = f"""
-        SELECT recall_video_id1, recall_video_id2, recall_video_id3, kimi_title, content_status, process_times
+        SELECT gh_id, recall_video_id1, recall_video_id2, recall_video_id3, kimi_title, content_status, process_times
         FROM {db_article}
         WHERE trace_id = '{trace_id}';
     """
     info_tuple = await mysql_client.async_select(select_sql)
-    vid1, vid2, vid3, kimi_title, content_status, process_times = info_tuple[0]
+    gh_id, vid1, vid2, vid3, kimi_title, content_status, process_times = info_tuple[0]
     vid_list = [vid1, vid2, vid3]
     unEmptyList = [i for i in vid_list if i]
     L = []
@@ -156,7 +164,7 @@ async def recall_videos(trace_id, mysql_client):
             result = {
                 "traceId": trace_id,
                 "code": 0,
-                "error": "匹配失败,检查原因"
+                "error": "匹配失败,处理超过五次,文章敏感"
             }
         else:
             result = {
@@ -178,26 +186,27 @@ async def recall_videos(trace_id, mysql_client):
             trace_id=trace_id
         )
         for index, best_video_id in enumerate(unEmptyList, 1):
-            if kimi_title:
-                temp = await return_info(
-                    video_id=best_video_id,
-                    kimi_title=kimi_title,
-                    trace_id=trace_id,
-                    mysql_client=mysql_client,
-                    index=index
-                )
-                L.append(temp)
-            else:
-                temp = await return_info_v2(
-                    video_id=best_video_id,
-                    trace_id=trace_id,
-                    mysql_client=mysql_client
-                )
-                L.append(temp)
-                temp['paragraphPosition'] = 0.5
-                L.append(temp)
-                temp['paragraphPosition'] = 0.75
-                L.append(temp)
+            # if kimi_title:
+            temp = await return_info(
+                video_id=best_video_id,
+                kimi_title=kimi_title,
+                trace_id=trace_id,
+                mysql_client=mysql_client,
+                index=index,
+                gh_id=gh_id
+            )
+            L.append(temp)
+            # else:
+            #     temp = await return_info_v2(
+            #         video_id=best_video_id,
+            #         trace_id=trace_id,
+            #         mysql_client=mysql_client
+            #     )
+            #     L.append(temp)
+            #     temp['paragraphPosition'] = 0.5
+            #     L.append(temp)
+            #     temp['paragraphPosition'] = 0.75
+            #     L.append(temp)
         result = {
             "traceId": trace_id,
             "miniprogramList": L
@@ -206,7 +215,7 @@ async def recall_videos(trace_id, mysql_client):
         result = {
             "traceId": trace_id,
             "code": 0,
-            "error": "匹配失败,检查原因"
+            "error": "匹配失败,处理超过五次,文章敏感"
         }
     else:
         result = {

+ 1 - 7
dev/task_test.py

@@ -1,9 +1,3 @@
 """
 @author: luojunhui
-"""
-import requests
-
-url = "http://{}:8111/task".format("localhost")
-
-w = requests.get(url)
-print(w)
+"""