
    )i
                         d dl Z d dlZd dlmZ d dlZd dlZd dlmZ d dlm	Z	m
Z
mZ d dlmZ  e         ej                  d      d        Zd
d	Zy)    N)Path)load_dotenv)chaingroupchord)celeryzvideo_main.merge)namec                    | \  }}|j                  d      }|j                  d      }|j                  d      xs |j                  d      }|st        d      |r|st        d      t        d|        t        d|        |||dS )	z"Merge results from previous tasks.pdf_pathaudio_mapping_fileidzQBoth ppt_result and audio_result must include 'id' key for session identificationzUppt_result must include 'ppt_path' and audio_result must include 'audio_mapping_file'u   📁 PPT Path: u   📁 Audio Mapping File: )r   r   r   )get
ValueErrorprint)results
pdf_resultaudio_resultr   r   
session_ids         6C:\xampp\htdocs\eduruby\Video_generation\video_main.pymerger      s      'J~~j)H%))*>?%?)9)9$)?Jlmm-pqq	OH:
&'	%&8%9
:; 8JR\]]    c                    ddl m} ddlm} ddlm} ddlm}m}  ||       }	||	| d}
d}|j                  |
      j                  |      }|j                         j                  |      }|j                  |	      j                  |      }t        j                         j                  |      }|j                  |
      j                  |      }t        |t        ||g|      |      j                         }|S )zRun the full pipeline from PDF to final video, but route everything to the
    'video_serial' queue so jobs execute one-by-one when the worker is started
    with concurrency=1 and listening on that queue.
    r   )pdf_audio_map_to_video)create_ppt_from_data) generate_audio_from_presentation)generate_presentation_jsonload_text_from_pdf)r   textr   video_serial)queue)voice_id)avatar_path)Video_generation.Video_syncr   Video_generation.ppt_pror   !Video_generation.audio_conversionr    Video_generation.Content_creatorr   r   ssetr   r   r   apply_async)r   r"   r   r!   r   r   r   r   r   r   dataSERIAL_QUEUEgen_json_taskppt_task
audio_task
merge_task
video_task
work_chains                     r   run_full_pipeliner2   #   s    
 C=R_ h'DD "L /006:::NM#%%'++,+?H133X3FJJQ]J^J\2J'))k)BFF\FZJ x$j1 km	  r   )N)argparsejsonpathlibr   ossysdotenvr   r   r   r   r   
celery_apptaskr   r2    r   r   <module>r<      sN       	 
  ' &  $%^ &^$$r   