|
@@ -11,13 +11,15 @@ from pymysql.cursors import DictCursor
|
|
|
|
|
|
from applications import log
|
|
from applications import log
|
|
from applications import PQAPI
|
|
from applications import PQAPI
|
|
-from applications.const import WeixinVideoCrawlerConst
|
|
|
|
|
|
+from applications.api import AigcSystemApi
|
|
from applications.api import fetch_moon_shot_response
|
|
from applications.api import fetch_moon_shot_response
|
|
|
|
+from applications.const import WeixinVideoCrawlerConst
|
|
from applications.db import DatabaseConnector
|
|
from applications.db import DatabaseConnector
|
|
from config import long_articles_config
|
|
from config import long_articles_config
|
|
|
|
|
|
const = WeixinVideoCrawlerConst()
|
|
const = WeixinVideoCrawlerConst()
|
|
pq_functions = PQAPI()
|
|
pq_functions = PQAPI()
|
|
|
|
+aigc = AigcSystemApi()
|
|
|
|
|
|
|
|
|
|
class PublishVideosForAudit(object):
|
|
class PublishVideosForAudit(object):
|
|
@@ -142,7 +144,11 @@ class PublishVideosForAudit(object):
|
|
获取需要检查的视频列表
|
|
获取需要检查的视频列表
|
|
:return:
|
|
:return:
|
|
"""
|
|
"""
|
|
- sql = f"""SELECT audit_video_id FROM publish_single_video_source WHERE audit_status = {const.VIDEO_AUDIT_PROCESSING_STATUS};"""
|
|
|
|
|
|
+ sql = f"""
|
|
|
|
+ select content_trace_id, audit_video_id, score, platform
|
|
|
|
+ from publish_single_video_source
|
|
|
|
+ where audit_status = {const.VIDEO_AUDIT_PROCESSING_STATUS};
|
|
|
|
+ """
|
|
response = self.db_client.fetch(sql, cursor_type=DictCursor)
|
|
response = self.db_client.fetch(sql, cursor_type=DictCursor)
|
|
return response
|
|
return response
|
|
|
|
|
|
@@ -197,12 +203,30 @@ class PublishVideosForAudit(object):
|
|
)
|
|
)
|
|
return False
|
|
return False
|
|
|
|
|
|
- def check_video_status(self, video_id: int) -> Dict:
|
|
|
|
|
|
+ def insert_into_task_queue(self, video) -> int:
|
|
|
|
+ """
|
|
|
|
+ enqueue
|
|
|
|
+ """
|
|
|
|
+ insert_query = f"""
|
|
|
|
+ insert into single_video_transform_queue
|
|
|
|
+ (content_trace_id, pq_vid, score, platform)
|
|
|
|
+ values (%s, %s, %s, %s);
|
|
|
|
+ """
|
|
|
|
+ affected_rows = self.db_client.save(
|
|
|
|
+ query=insert_query,
|
|
|
|
+ params=(
|
|
|
|
+ video['content_trace_id'], video['audit_video_id'], video['score'], video['platform']
|
|
|
|
+ )
|
|
|
|
+ )
|
|
|
|
+ return affected_rows
|
|
|
|
+
|
|
|
|
+ def check_video_status(self, video_obj: dict) -> Dict:
|
|
"""
|
|
"""
|
|
检查视频的状态,若视频审核通过or不通过,修改记录状态
|
|
检查视频的状态,若视频审核通过or不通过,修改记录状态
|
|
- :param video_id:
|
|
|
|
|
|
+ :param video_obj:
|
|
:return:
|
|
:return:
|
|
"""
|
|
"""
|
|
|
|
+ video_id = video_obj['audit_video_id']
|
|
response = pq_functions.getPQVideoListDetail([video_id])
|
|
response = pq_functions.getPQVideoListDetail([video_id])
|
|
audit_status = response.get("data")[0].get("auditStatus")
|
|
audit_status = response.get("data")[0].get("auditStatus")
|
|
# 请求成功
|
|
# 请求成功
|
|
@@ -216,6 +240,18 @@ class PublishVideosForAudit(object):
|
|
ori_audit_status=const.VIDEO_AUDIT_PROCESSING_STATUS,
|
|
ori_audit_status=const.VIDEO_AUDIT_PROCESSING_STATUS,
|
|
new_audit_status=const.VIDEO_AUDIT_SUCCESS_STATUS
|
|
new_audit_status=const.VIDEO_AUDIT_SUCCESS_STATUS
|
|
)
|
|
)
|
|
|
|
+ # 将视频存储到任务队列
|
|
|
|
+ self.insert_into_task_queue(video_obj)
|
|
|
|
+
|
|
|
|
+ # 将视频存储到 aigc 表
|
|
|
|
+ aigc.insert_crawler_relation_to_aigc_system(
|
|
|
|
+ relation_list=[
|
|
|
|
+ {
|
|
|
|
+ "videoPoolTraceId": video_obj['content_trace_id'],
|
|
|
|
+ "channelContentId": str(video_id)
|
|
|
|
+ }
|
|
|
|
+ ]
|
|
|
|
+ )
|
|
else:
|
|
else:
|
|
# 修改小程序标题失败,修改审核状态为4
|
|
# 修改小程序标题失败,修改审核状态为4
|
|
affected_rows = self.update_audit_status(
|
|
affected_rows = self.update_audit_status(
|
|
@@ -295,7 +331,7 @@ class PublishVideosForAudit(object):
|
|
for video_obj in tqdm(video_list, desc="视频检查"):
|
|
for video_obj in tqdm(video_list, desc="视频检查"):
|
|
video_id = video_obj.get("audit_video_id")
|
|
video_id = video_obj.get("audit_video_id")
|
|
try:
|
|
try:
|
|
- response = self.check_video_status(video_id)
|
|
|
|
|
|
+ response = self.check_video_status(video_obj)
|
|
if response.get("affected_rows"):
|
|
if response.get("affected_rows"):
|
|
continue
|
|
continue
|
|
else:
|
|
else:
|