From 24534ccb3e18906f565f319f1ad766cc27de4e16 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Fri, 3 Apr 2026 15:35:49 +0900 Subject: [PATCH] =?UTF-8?q?=EC=9D=B4=EB=AF=B8=EC=A7=80=20=EB=B6=80?= =?UTF-8?q?=EC=A1=B1=20=EC=8B=9C=20duplicate=20=EA=B8=B0=EB=8A=A5=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/utils/creatomate.py | 14 ++++++++++++++ app/video/api/routers/v1/video.py | 8 +++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/app/utils/creatomate.py b/app/utils/creatomate.py index 1e0a9a0..468944a 100644 --- a/app/utils/creatomate.py +++ b/app/utils/creatomate.py @@ -435,6 +435,20 @@ class CreatomateService: return tag_list + + def counting_component( + self, + template : dict, + target_template_type : str + ) -> list: + source_elements = template["source"]["elements"] + template_component_data = self.parse_template_component_name(source_elements) + count = 0 + + for _, (_, template_type) in enumerate(template_component_data.items()): + if template_type == target_template_type: + count += 1 + return count def template_matching_taged_image( self, diff --git a/app/video/api/routers/v1/video.py b/app/video/api/routers/v1/video.py index 31ec704..181e1f8 100644 --- a/app/video/api/routers/v1/video.py +++ b/app/video/api/routers/v1/video.py @@ -350,12 +350,18 @@ async def generate_video( # music_url=music_url, # address=store_address taged_image_list = await get_image_tags_by_task_id(task_id) + min_image_num = creatomate_service.counting_component( + template = template, + target_template_type = "image" + ) + duplicate = bool(len(taged_image_list) < min_image_num) + logger.info(f"[generate_video] Duplicate : {duplicate} | length of taged_image {len(taged_image_list)}, min_len {min_image_num},- task_id: {task_id}") modifications = creatomate_service.template_matching_taged_image( template = template, taged_image_list = taged_image_list, music_url = music_url, address = store_address, - duplicate = False, + duplicate = duplicate, ) logger.debug(f"[generate_video] Modifications created - task_id: {task_id}")