zhangyong пре 7 месеци
родитељ
комит
0b6730ecbd
3 измењених фајлова са 40 додато и 3 уклоњено
  1. 25 0
      common/tag_video.py
  2. 3 2
      data_channel/ks_keyword.py
  3. 12 1
      video_rewriting/video_processor.py

+ 25 - 0
common/tag_video.py

@@ -0,0 +1,25 @@
+import requests
+import json
+
+class Tag:
+    @classmethod
+    def video_tag(cls, pq_id: str, tag: str):
+        try:
+            url = "https://admin.piaoquantv.com/manager/video/tag/addVideoAiTags"
+
+            payload = json.dumps({
+                "videoId": pq_id,
+                "tagNames": tag
+            })
+            headers = {
+                'Content-Type': 'application/json'
+            }
+
+            response = requests.request("POST", url, headers=headers, data=payload)
+            response = response.json()
+            code = response['code']
+            return code
+        except:
+            return 1
+
+

+ 3 - 2
data_channel/ks_keyword.py

@@ -53,8 +53,9 @@ class KsKeyword:
             code = response['code']
             if code != 0:
                 if code == 27006 and response['msg'] == '快手内容已被删除或无法访问':
-                    keyword_principal = task["keyword_name"]
-                    Feishu.bot(keyword_principal, '机器自动改造消息通知', f'品类关键词搜索-快手搜索,无法搜索出内容,请及时更换搜索词,搜索词为:{keyword}', keyword_principal)
+                    Feishu.finish_bot(f"kuai_shou/keyword {response['msg']},cookie 过期需要更换",
+                                      "https://open.feishu.cn/open-apis/bot/v2/hook/575ca6a1-84b4-4a2f-983b-1d178e7b16eb",
+                                      "【快手搜索接口使用提示】")
                     Common.logger("ks-key-word").info(f"快手搜索词数据获取失败,{response['msg']}\n")
                     return list
                 Common.logger("ks-key-word").info(f"快手搜索词数据获取失败,接口为kuai_shou/keyword\n")

+ 12 - 1
video_rewriting/video_processor.py

@@ -8,6 +8,7 @@ import time
 from datetime import datetime
 
 from common.redis import get_data, get_first_value_with_prefix, increment_key
+from common.tag_video import Tag
 from common.tts_help import TTS
 from common import Material, Feishu, Common, Oss, AliyunLogger
 from common.ffmpeg import FFmpeg
@@ -223,7 +224,17 @@ class VideoProcessor:
                         first_category = task["first_category"]
                         secondary_category = task["secondary_category"]
                         keyword_principal = task["keyword_name"]
-                        log_data = f"user:{url},,video_id:{v_id},,video_url:{video_url},,ai_title:{new_title},,voice:{voice},,first_category:{first_category},,secondary_category:{secondary_category},,keyword_principal:{keyword_principal}"
+                        tag_first = f"一级品类_{first_category}"
+                        tag_keyword = f"关键词_{url}"
+                        if channel_id == "抖音搜索":
+                            tag_channel = "来源_抖音关键词"
+                        elif channel_id == "快手搜索":
+                            tag_channel = "来源_快手关键词"
+                        tag = f"{tag_first},{tag_keyword},{tag_channel}"
+                        tag_status = Tag.video_tag(code, tag)
+                        if tag_status == 0:
+                            Common.logger(mark).info(f"{name}的{task_mark}下的ID{url}下的票圈视频{code},写入标签成功")
+                        log_data = f"user:{url},,video_id:{v_id},,video_url:{video_url},,ai_title:{new_title},,voice:{voice},,first_category:{first_category},,secondary_category:{secondary_category},,keyword_principal:{keyword_principal},,tag:{tag}"
                         values = [
                             [
                                 name,