Pārlūkot izejas kodu

刷新快手视频信息,移动到账户层级

liyuyi@c-top.com.cn 4 gadi atpakaļ
vecāks
revīzija
52819c51ef
2 mainītis faili ar 23 papildinājumiem un 11 dzēšanām
  1. 6 1
      ai_time_task_creative_handler.py
  2. 17 10
      utils/CommonFunction.py

+ 6 - 1
ai_time_task_creative_handler.py

@@ -9,7 +9,9 @@ from concurrent_log import ConcurrentTimedRotatingFileHandler
 from utils.ConstantConfig import *
 from utils.DataBaseConfig import *
 from utils.CommonFunction import get_history_video_info, get_new_video_info, get_missing_video_info, \
-                                 get_top_video_info, get_campaign_and_group_name_rule, get_app_detail, get_request_data
+                                 get_top_video_info, get_campaign_and_group_name_rule, get_app_detail, get_request_data,\
+                                 refresh_video
+
 from ai_strategy_request_func import ai_strategy_request_parse
 
 log_formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s', '%m/%d/%Y %I:%M:%S %p')
@@ -158,6 +160,9 @@ class AiAutoCreative(tornado.web.RequestHandler):
                     (account_id, os.getpid(), os.getppid(), data))
 
         try:
+            # 刷新快手视频信息
+            refresh_video(account_id=account_id, url=refresh_video_url)
+
             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

+ 17 - 10
utils/CommonFunction.py

@@ -1,5 +1,5 @@
 import requests
-from utils.UrlConfig import headers, refresh_video_url
+from utils.UrlConfig import headers
 import json
 import pandas as pd
 import datetime
@@ -109,23 +109,30 @@ def get_history_video_info(account_id, url, start_time, end_time, video_cnt, rel
     return request_json
 
 
+def refresh_video(account_id, url):
+    """
+    需要调用刷新快手素材的接口 http://192.168.1.8:8080/jeecg-boot/kuaishou/material/getKuaiShouVideoList
+            (请求方式 POST 入参:accountId 返回结果:成功或失败)
+    remark: 自动上新之前,需要调用该接口,注意是账户层级的调用,不是app_id层级的调用
+    """
+    try:
+        request = requests.post(url=url, headers=headers,
+                                data=json.JSONEncoder().encode({"accountId": account_id})).text
+        request_json = json.loads(request)
+        logger.info('account_id=%s,  the res of getKuaiShouVideoList is %s' % (account_id, request_json))
+    except Exception:
+        logger.error('account_id=%s,  the res of getKuaiShouVideoList is %s, traceback is %s ' %
+                     (account_id, request, traceback.format_exc()))
+
+
 def get_new_video_info(account_id, url, app_version=None):
     """
     url:http://192.168.1.8:8080/jeecg-boot/kuaishou/material/getNewVideoList
     请求方式:POST
     remark:
         1、返回 upload_time 在上次调用时间到本次调用时间内的素材(第一次调用返回5分钟前到本次调用时间的素材)
-        2、需要调用刷新快手素材的接口 http://192.168.1.8:8080/jeecg-boot/kuaishou/material/getKuaiShouVideoList
-            (请求方式 POST 入参:accountId 返回结果:成功或失败)
     入参:accountId
     """
-    try:
-        request = requests.post(url=refresh_video_url, headers=headers,
-                                data=json.JSONEncoder().encode({"accountId": account_id})).text
-        _ = json.loads(request)
-    except Exception:
-        logger.error('account_id=%s, app_version=%s, the res of getKuaiShouVideoList is %s, traceback is %s ' %
-                     (account_id, app_version, request, traceback.format_exc()))
 
     if not app_version:
         request_data = {"accountId": account_id}