Browse Source

自动上新,检查是否已经有自动上新的计划

liyuyi@c-top.com.cn 4 years ago
parent
commit
c98575a41e
1 changed files with 16 additions and 0 deletions
  1. 16 0
      ai_time_task_creative_handler.py

+ 16 - 0
ai_time_task_creative_handler.py

@@ -73,6 +73,22 @@ class AiAutoCreative(tornado.web.RequestHandler):
         account_id = data.get('account_id')
         campaign_id = data.get('campaign_id')
         try:
+            start_time = (datetime.date.today()).strftime('%Y-%m-%d %H:%M:%S')
+            end_time = (datetime.datetime.now()).strftime('%Y-%m-%d %H:%M:%S')
+
+            # 1-1 获取当天计划中包含“自动上新”计划的,计划id
+            sql = """
+                                select campaign_id, campaign_name from ctop_kuaishou_campaign 
+                                where account_id = %s
+                                and put_create_time >= '%s'
+                                and put_create_time <= '%s'
+                                """ % (account_id, start_time, end_time)
+            df = pd.read_sql(sql, engine)
+            for row in df.itertuples():
+                if '自动上新' in getattr(row, 'campaign_name'):
+                    campaign_id = getattr(row, 'campaign_id')
+                    break
+
             video_info = get_new_video_info(account_id, get_new_video_url)
             if video_info is None:
                 logger.info("没有获取到视频,不发送ai策略请求!")