|
@@ -4,6 +4,8 @@
|
|
|
import json
|
|
|
import time
|
|
|
|
|
|
+from applications.log import logging
|
|
|
+
|
|
|
|
|
|
class GetOffVideos(object):
|
|
|
"""
|
|
@@ -44,29 +46,40 @@ class GetOffVideos(object):
|
|
|
result = await self.mysql_client.async_select(sql=select_sql)
|
|
|
if result:
|
|
|
video_list = json.loads(result[0][0])
|
|
|
- for video in video_list:
|
|
|
- video_id = video['videoId']
|
|
|
- try:
|
|
|
- update_sql = f"""
|
|
|
+ info_list = [
|
|
|
+ (
|
|
|
+ item['videoId'],
|
|
|
+ int(time.time()),
|
|
|
+ 1,
|
|
|
+ self.trace_id
|
|
|
+ )
|
|
|
+ for item in video_list
|
|
|
+ ]
|
|
|
+ try:
|
|
|
+ insert_sql = f"""
|
|
|
INSERT INTO {self.get_off_videos}
|
|
|
(video_id, publish_time, video_status, trace_id)
|
|
|
values
|
|
|
- (%s, %s, %s, %s);
|
|
|
- """
|
|
|
- await self.mysql_client.async_insert(
|
|
|
- sql=update_sql,
|
|
|
- params=(video_id, int(time.time()), 1, self.trace_id)
|
|
|
- )
|
|
|
- return {
|
|
|
- "status": "success",
|
|
|
- "traceId": self.trace_id
|
|
|
- }
|
|
|
- except Exception as e:
|
|
|
- return {
|
|
|
- "status": "fail",
|
|
|
- "traceId": self.trace_id,
|
|
|
- "msg": "insert fail---{}".format(e)
|
|
|
- }
|
|
|
+ (%s, %s, %s, %s);"""
|
|
|
+ await self.mysql_client.async_insert_many(
|
|
|
+ sql=insert_sql,
|
|
|
+ params_list=info_list
|
|
|
+ )
|
|
|
+ return {
|
|
|
+ "status": "success",
|
|
|
+ "traceId": self.trace_id
|
|
|
+ }
|
|
|
+ except Exception as e:
|
|
|
+ logging(
|
|
|
+ code="4123",
|
|
|
+ info="自动下架视频处理失败: {}".format(e),
|
|
|
+ function="get_off_videos"
|
|
|
+ )
|
|
|
+ return {
|
|
|
+ "status": "fail",
|
|
|
+ "traceId": self.trace_id,
|
|
|
+ "msg": "insert fails, {}".format(e)
|
|
|
+ }
|
|
|
else:
|
|
|
return {
|
|
|
"status": "fail",
|