|
@@ -10,6 +10,9 @@ from datetime import datetime
|
|
|
import requests
|
|
|
|
|
|
from application.common import Feishu
|
|
|
+from application.common.feishu import FsData
|
|
|
+from application.common.feishu.feishu_utils import FeishuUtils
|
|
|
+from application.common.gpt import GPT4oMini
|
|
|
|
|
|
sys.path.append(os.getcwd())
|
|
|
|
|
@@ -62,6 +65,8 @@ class TTJFFQRecommend(object):
|
|
|
'referer': 'https://servicewechat.com/wxa12a841184757478/7/page-frame.html',
|
|
|
'accept-language': 'zh-CN,zh;q=0.9'
|
|
|
}
|
|
|
+ data_rule = FsData()
|
|
|
+ title_rule = data_rule.get_title_rule()
|
|
|
while True:
|
|
|
time.sleep(random.randint(1, 10))
|
|
|
url = "https://api.xinghetime.com/luckvideo/video/getRecommendVideos"
|
|
@@ -82,7 +87,7 @@ class TTJFFQRecommend(object):
|
|
|
self.aliyun_log.logging(
|
|
|
code="1001", message="扫描到一条视频", data=video_obj
|
|
|
)
|
|
|
- self.process_video_obj(video_obj)
|
|
|
+ self.process_video_obj(video_obj,title_rule)
|
|
|
except Exception as e:
|
|
|
self.aliyun_log.logging(
|
|
|
code="3000",
|
|
@@ -94,7 +99,7 @@ class TTJFFQRecommend(object):
|
|
|
return
|
|
|
time.sleep(random.randint(5, 10))
|
|
|
|
|
|
- def process_video_obj(self, video_obj):
|
|
|
+ def process_video_obj(self, video_obj, title_rule):
|
|
|
"""
|
|
|
处理视频
|
|
|
:param video_obj:
|
|
@@ -143,6 +148,27 @@ class TTJFFQRecommend(object):
|
|
|
trace_id=trace_id,
|
|
|
)
|
|
|
if pipeline.process_item():
|
|
|
+ title_list = title_rule.split(",")
|
|
|
+ title = video_obj["title"]
|
|
|
+ contains_keyword = any(keyword in title for keyword in title_list)
|
|
|
+ if contains_keyword:
|
|
|
+ new_title = GPT4oMini.get_ai_mini_title(title)
|
|
|
+ if new_title:
|
|
|
+ item.add_video_info("video_title", new_title)
|
|
|
+ current_time = datetime.now()
|
|
|
+ formatted_time = current_time.strftime("%Y-%m-%d %H:%M:%S")
|
|
|
+ values = [
|
|
|
+ [
|
|
|
+ video_obj["videoPath"],
|
|
|
+ video_obj["coverImagePath"],
|
|
|
+ title,
|
|
|
+ new_title,
|
|
|
+ formatted_time,
|
|
|
+ ]
|
|
|
+ ]
|
|
|
+ FeishuUtils.insert_columns("U5dXsSlPOhiNNCtEfgqcm1iYnpf", "ftQdRy", "ROWS", 1, 2)
|
|
|
+ time.sleep(0.5)
|
|
|
+ FeishuUtils.update_values("U5dXsSlPOhiNNCtEfgqcm1iYnpf", "ftQdRy", "A2:Z2", values)
|
|
|
self.download_cnt += 1
|
|
|
self.mq.send_msg(mq_obj)
|
|
|
self.aliyun_log.logging(code="1002", message="成功发送至 ETL", data=mq_obj)
|