Explorar o código

调用获取视频的函数时,入参优化为Key=Value的形式

liyuyi@c-top.com.cn %!s(int64=4) %!d(string=hai) anos
pai
achega
b203ef8d0f
Modificáronse 1 ficheiros con 27 adicións e 23 borrados
  1. 27 23
      ai_time_task_creative_handler.py

+ 27 - 23
ai_time_task_creative_handler.py

@@ -109,11 +109,11 @@ class AiHistoricalMissingMaterial(tornado.web.RequestHandler):
                 self.write(json.dumps({"message": "account_id=%s, 多应用的补充遗漏素材请求已走完!" % account_id}))
                 self.flush()
             else:
-                video_info = get_missing_video_info(account_id,
-                                                    missing_video_cnt,
-                                                    get_missing_video_url,
-                                                    missing_video_start_time,
-                                                    missing_video_end_time)
+                video_info = get_missing_video_info(account_id=account_id,
+                                                    cnt=missing_video_cnt,
+                                                    url=get_missing_video_url,
+                                                    start_time=missing_video_start_time,
+                                                    end_time=missing_video_end_time)
                 if video_info['code'] != 0:
                     logger.info("account_id = %s,补充历史遗漏素材,没有获取到视频,不发送ai策略请求!" % account_id)
                     self.write(json.dumps({"account_id": account_id,
@@ -239,7 +239,8 @@ class AiAutoCreative(tornado.web.RequestHandler):
                         campaign_id = getattr(row, 'campaign_id')
                         break
 
-                video_info = get_new_video_info(account_id, get_new_video_url)
+                video_info = get_new_video_info(account_id=account_id,
+                                                url=get_new_video_url)
                 if video_info['code'] != 0:
                     self.write(json.dumps({"account_id": account_id, "message": "素材自动上新没有获取到视频,不发送ai策略请求!"}))
                     self.flush()
@@ -359,11 +360,13 @@ class AiHighQualityMaterial(tornado.web.RequestHandler):
                 self.write(json.dumps({"message": "account_id=%s, 多应用的高质量素材复建请求已走完!" % account_id}))
                 self.flush()
             else:
-                video_info = get_top_video_info(account_id, high_quality_video_cnt,
-                                                (datetime.datetime.now() + datetime.timedelta(
-                                                    days=-high_quality_video_days)).strftime("%Y-%m-%d %H:%M:%S"),
-                                                datetime.date.today().strftime("%Y-%m-%d %H:%M:%S"),
-                                                get_high_quality_video_url)
+                video_info = get_top_video_info(account_id=account_id,
+                                                cnt=high_quality_video_cnt,
+                                                start_time=(datetime.datetime.now() +
+                                                            datetime.timedelta(days=-high_quality_video_days)).
+                                                strftime("%Y-%m-%d %H:%M:%S"),
+                                                end_time=datetime.date.today().strftime("%Y-%m-%d %H:%M:%S"),
+                                                url=get_high_quality_video_url)
                 if video_info['code'] != 0:
                     logger.info("account_id = %s, 高质量素材复建,没有获取到视频,不发送ai策略请求!" % account_id)
                     self.write(json.dumps({"account_id": account_id,
@@ -443,11 +446,11 @@ class AiCheckAndUpTOFullCreative(tornado.web.RequestHandler):
 
             # 3-1 获取视频信息
             if video_cnt == 0:
-                logger.info("创意已经建满,不需要补充素材!")
-                self.write(json.dumps("message: 创意已经建满,不需要补充素材!"))
+                logger.info("account_id = %s, 创意已经建满,不需要补充素材!" % account_id)
+                self.write(json.dumps({"account_id": account_id, "message": "创意已经建满,不需要补充素材!"}))
                 self.flush()
             else:
-                logger.info("需要补充的视频数量:%s" % video_cnt)
+                logger.info("account_id = %s, 需要补充的视频数量 = %s" % (account_id, video_cnt))
 
                 sql = """select account_id, single_appid, app_id_array, general_track from ctop_ai_kuaishou_advertiser_strategy
                                  where account_id=%s order by create_time desc limit 1
@@ -522,11 +525,11 @@ class AiCheckAndUpTOFullCreative(tornado.web.RequestHandler):
                             campaign_id = getattr(row, 'campaign_id')
                             break
 
-                    video_info = get_top_video_info(account_id,
-                                                    video_cnt,
-                                                    (now + datetime.timedelta(days=-2*high_quality_video_days)).strftime("%Y-%m-%d %H:%M:%S"),
-                                                    (now + datetime.timedelta(days=-high_quality_video_days)).strftime("%Y-%m-%d %H:%M:%S"),
-                                                    get_high_quality_video_url)
+                    video_info = get_top_video_info(account_id=account_id,
+                                                    cnt=video_cnt,
+                                                    start_time=(now + datetime.timedelta(days=-2*high_quality_video_days)).strftime("%Y-%m-%d %H:%M:%S"),
+                                                    end_time=(now + datetime.timedelta(days=-high_quality_video_days)).strftime("%Y-%m-%d %H:%M:%S"),
+                                                    url=get_high_quality_video_url)
                     if video_info['code'] != 0:
                         logger.info("account_id = %s, 历史高质量素材填满, 没有获取到视频,不发送ai策略请求!" % account_id)
                         self.write(json.dumps({"account_id": account_id,
@@ -651,11 +654,12 @@ class AiProgramCreativeHighQualityMaterial(tornado.web.RequestHandler):
                 self.write(json.dumps({"message": "account_id=%s, 多应用的高质量素材程序化创意的请求已走完!" % account_id}))
                 self.flush()
             else:
-                video_info = get_top_video_info(account_id, programme_high_quality_video_cnt,
-                                                (datetime.datetime.now() + datetime.timedelta(
+                video_info = get_top_video_info(account_id=account_id,
+                                                cnt=programme_high_quality_video_cnt,
+                                                start_time=(datetime.datetime.now() + datetime.timedelta(
                                                  days=-high_quality_video_days)).strftime("%Y-%m-%d %H:%M:%S"),
-                                                datetime.date.today().strftime("%Y-%m-%d %H:%M:%S"),
-                                                get_high_quality_video_url)
+                                                end_time=datetime.date.today().strftime("%Y-%m-%d %H:%M:%S"),
+                                                url=get_high_quality_video_url)
                 if video_info['code'] != 0:
                     logger.info("account_id = %s, 程序化高质量素材,没有获取到视频,不发送ai策略请求!" % account_id)
                     self.write(json.dumps({"account_id": account_id,