|
@@ -1,21 +1,15 @@
|
|
-from typing import Optional, Awaitable
|
|
|
|
-import pandas as pd
|
|
|
|
-import numpy as np
|
|
|
|
import datetime
|
|
import datetime
|
|
-import pymysql
|
|
|
|
-from sqlalchemy import create_engine
|
|
|
|
-import simplejson
|
|
|
|
-import requests
|
|
|
|
-import tornado.web
|
|
|
|
-import pandas as pd
|
|
|
|
import json
|
|
import json
|
|
-import numpy as np
|
|
|
|
-import datetime
|
|
|
|
-from sqlalchemy import create_engine
|
|
|
|
-from db_config import *
|
|
|
|
import traceback
|
|
import traceback
|
|
import uuid
|
|
import uuid
|
|
|
|
|
|
|
|
+import pandas as pd
|
|
|
|
+import requests
|
|
|
|
+import simplejson
|
|
|
|
+import tornado.web
|
|
|
|
+
|
|
|
|
+from db_config import *
|
|
|
|
+
|
|
|
|
|
|
class AiStrategyRequestParse(tornado.web.RequestHandler):
|
|
class AiStrategyRequestParse(tornado.web.RequestHandler):
|
|
def initialize(self, logger):
|
|
def initialize(self, logger):
|
|
@@ -48,9 +42,10 @@ class AiStrategyRequestParse(tornado.web.RequestHandler):
|
|
headers=headers,
|
|
headers=headers,
|
|
data=json.JSONEncoder().encode(create_group_and_creative_res)
|
|
data=json.JSONEncoder().encode(create_group_and_creative_res)
|
|
)
|
|
)
|
|
- create_group_and_creative_response_data = simplejson.loads(request.text)
|
|
|
|
|
|
+ create_group_and_creative_response_data = json.loads(request.text)
|
|
self.logger.info("请求返回:%s" % create_group_and_creative_response_data)
|
|
self.logger.info("请求返回:%s" % create_group_and_creative_response_data)
|
|
- self.write(json.dumps({'account_id': inst.account_id, 'ai_strategy_id': inst.ai_strategy_uuid,
|
|
|
|
|
|
+ self.write(json.dumps({'account_id': inst.account_id,
|
|
|
|
+ 'ai_strategy_id': inst.ai_strategy_uuid,
|
|
'message': create_group_and_creative_response_data}))
|
|
'message': create_group_and_creative_response_data}))
|
|
self.flush()
|
|
self.flush()
|
|
else:
|
|
else:
|
|
@@ -61,6 +56,7 @@ class AiStrategyRequestParse(tornado.web.RequestHandler):
|
|
self.write(json.dumps(traceback.format_exc()))
|
|
self.write(json.dumps(traceback.format_exc()))
|
|
self.flush()
|
|
self.flush()
|
|
|
|
|
|
|
|
+
|
|
# 该类解析的是 手动请求的新增广告计划或者新增广告组的数据
|
|
# 该类解析的是 手动请求的新增广告计划或者新增广告组的数据
|
|
class ParseAddCampaignOrAddGroupRequest(object):
|
|
class ParseAddCampaignOrAddGroupRequest(object):
|
|
def __init__(self, request_data, logger):
|
|
def __init__(self, request_data, logger):
|
|
@@ -264,13 +260,13 @@ class ParseAddCampaignOrAddGroupRequest(object):
|
|
group_cnt += 1
|
|
group_cnt += 1
|
|
|
|
|
|
creative_cnt = 1
|
|
creative_cnt = 1
|
|
- for image in video['imageList']:
|
|
|
|
|
|
+ for image in video['imageList'][:image_cnt]:
|
|
single_creative_info = {
|
|
single_creative_info = {
|
|
'creative_uuid': str(uuid.uuid4()),
|
|
'creative_uuid': str(uuid.uuid4()),
|
|
'is_sticky': 0,
|
|
'is_sticky': 0,
|
|
'creative_name': self.creative_info['creative_name'] + '_' + str(creative_cnt),
|
|
'creative_name': self.creative_info['creative_name'] + '_' + str(creative_cnt),
|
|
'photo_id': video['photo_id'],
|
|
'photo_id': video['photo_id'],
|
|
- 'image_md5': image, # TODO 需要和蒙蒙确认字段名称
|
|
|
|
|
|
+ 'image_md5': image,
|
|
'image_tokens': self.creative_info.get('image_tokens'),
|
|
'image_tokens': self.creative_info.get('image_tokens'),
|
|
'action_bar_text': self.creative_info['action_bar_text'],
|
|
'action_bar_text': self.creative_info['action_bar_text'],
|
|
'description': self.creative_info['description'],
|
|
'description': self.creative_info['description'],
|