from utils.DataSearchUtils import MysqlSearchUtils from utils import ResultDictUtils import datetime import time from utils.DateUtils import DateUtils mysqlUtils = MysqlSearchUtils() dateUtils = DateUtils() class AiAutoCreateCreativeJob(): def auto_create_job(self,account_id): response_dict = ResultDictUtils.common_success_dict # 查询需要自动创建创意的模板信息 templates = mysqlUtils.get_all_ai_account_target_template_by_params(1,account_id) if len(templates): for item in templates: self.create_creative(item) return response_dict else: return ResultDictUtils.ai_account_template_not_exist_dict def create_creative(self,item): # 查询当前时间段内的视频数据 accountId= item["account_id"] timestamp = time.time() enddate= dateUtils.get_datetime_str_add_sencend(timestamp,-5*60) startdate= dateUtils.get_datetime_str_add_sencend(timestamp,-10*60) list = mysqlUtils.get_kuaishou_video_list_by_params(accountId,startdate,enddate) if len(list): return None else: return ResultDictUtils.ai_account_template_not_exist_dict if __name__ == '__main__': timestamp = time.time() endtimestamp = timestamp - 5*60 datetime_struct = datetime.datetime.fromtimestamp(timestamp) enddatetime_struct = datetime.datetime.fromtimestamp(endtimestamp) print(timestamp) print(datetime_struct.strftime('%Y-%m-%d %H:%M:%S')) print(endtimestamp) print(enddatetime_struct.strftime('%Y-%m-%d %H:%M:%S'))