نسخة كاملة من مستودع سيرو عند ecfe7568 لتكون أساس تطبيق «انطلق». نُسخ المتعقَّب في git فقط (12,509 ملفاً / 302 م.ب) بـ git archive، لا `cp -r` — فاستُثنيت تلقائياً مخلفات البناء (build · node_modules · .dart_tool · .gradle · Pods ≈ 10.7 غ.ب) وكل ما يستثنيه .gitignore. هذا الكوميت **بلا أي تعديل عمداً** حتى يكون كل ما يليه فرقاً مقروءاً مقابل سيرو الأصلي. سيرو نفسه لم يُمسّ. ⚠️ لا يبني بعد: `.env` و`lib/env/env.g.dart` غير متعقَّبين في سيرو (وهذا صحيح — أسرار لكل مستأجر). كل تطبيق فلاتر هنا يحتاج .env خاصاً بانطلق ثم توليد env.g.dart عبر build_runner. لا تُنسخ أسرار سيرو. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
106 lines
4.0 KiB
PHP
106 lines
4.0 KiB
PHP
<?php
|
|
// ============================================================
|
|
// marketing_engine/services/ContentWorkflow.php
|
|
// Orchestrates the entire content generation pipeline
|
|
// ============================================================
|
|
|
|
require_once __DIR__ . '/AIVideoGenerator.php';
|
|
require_once __DIR__ . '/../../core/bootstrap.php';
|
|
|
|
class ContentWorkflow {
|
|
private $generator;
|
|
private $con;
|
|
|
|
public function __construct() {
|
|
$this->generator = new AIVideoGenerator();
|
|
$this->con = Database::get('main');
|
|
}
|
|
|
|
/**
|
|
* Executes the next pending step in the content pipeline
|
|
*/
|
|
public function processPipeline() {
|
|
// 1. Check for pending topics to generate scripts
|
|
$this->processPendingScripts();
|
|
|
|
// 2. Check for generated scripts to create voice
|
|
$this->processPendingVoices();
|
|
|
|
// 3. Check for generated voices to render video
|
|
$this->processPendingVideos();
|
|
|
|
// 4. Check for rendered videos to queue marketing tasks
|
|
$this->queueUploadTasks();
|
|
}
|
|
|
|
private function processPendingScripts() {
|
|
$stmt = $this->con->prepare("SELECT * FROM content_pipeline WHERE status = 'pending' LIMIT 1");
|
|
$stmt->execute();
|
|
$job = $stmt->fetch(PDO::FETCH_ASSOC);
|
|
|
|
if ($job) {
|
|
$result = $this->generator->generateScript($job['topic']);
|
|
if ($result['status'] === 'success') {
|
|
$update = $this->con->prepare("UPDATE content_pipeline SET script_text = ?, status = 'script_generated' WHERE id = ?");
|
|
$update->execute([$result['script'], $job['id']]);
|
|
}
|
|
}
|
|
}
|
|
|
|
private function processPendingVoices() {
|
|
$stmt = $this->con->prepare("SELECT * FROM content_pipeline WHERE status = 'script_generated' LIMIT 1");
|
|
$stmt->execute();
|
|
$job = $stmt->fetch(PDO::FETCH_ASSOC);
|
|
|
|
if ($job) {
|
|
$result = $this->generator->generateVoice($job['script_text']);
|
|
if ($result['status'] === 'success') {
|
|
$update = $this->con->prepare("UPDATE content_pipeline SET voice_url = ?, status = 'voice_generated' WHERE id = ?");
|
|
$update->execute([$result['audio_url'], $job['id']]);
|
|
}
|
|
}
|
|
}
|
|
|
|
private function processPendingVideos() {
|
|
$stmt = $this->con->prepare("SELECT * FROM content_pipeline WHERE status = 'voice_generated' LIMIT 1");
|
|
$stmt->execute();
|
|
$job = $stmt->fetch(PDO::FETCH_ASSOC);
|
|
|
|
if ($job) {
|
|
$result = $this->generator->renderVideo($job['script_text'], $job['voice_url']);
|
|
if ($result['status'] === 'success') {
|
|
$update = $this->con->prepare("UPDATE content_pipeline SET video_url = ?, status = 'video_rendered' WHERE id = ?");
|
|
$update->execute([$result['video_url'], $job['id']]);
|
|
}
|
|
}
|
|
}
|
|
|
|
private function queueUploadTasks() {
|
|
$stmt = $this->con->prepare("SELECT * FROM content_pipeline WHERE status = 'video_rendered' LIMIT 1");
|
|
$stmt->execute();
|
|
$job = $stmt->fetch(PDO::FETCH_ASSOC);
|
|
|
|
if ($job) {
|
|
// Create upload tasks for TikTok and YouTube Shorts
|
|
$insert = $this->con->prepare("
|
|
INSERT INTO marketing_tasks (platform, type, content_text, media_url, status)
|
|
VALUES
|
|
('tiktok', 'upload_video', ?, ?, 'pending'),
|
|
('youtube', 'upload_video', ?, ?, 'pending')
|
|
");
|
|
|
|
// Provide a short caption based on the script
|
|
$caption = substr($job['script_text'], 0, 100) . "... #Siro #RideHailing";
|
|
|
|
$insert->execute([
|
|
$caption, $job['video_url'],
|
|
$caption, $job['video_url']
|
|
]);
|
|
|
|
// Mark job as published (or handed off to bots)
|
|
$update = $this->con->prepare("UPDATE content_pipeline SET status = 'published' WHERE id = ?");
|
|
$update->execute([$job['id']]);
|
|
}
|
|
}
|
|
}
|