Additional inputs for Describe functionality

This commit is contained in:
hbrain 2026-06-05 01:38:40 +02:00
parent efaa5c4306
commit ad184d778d
5 changed files with 239 additions and 38 deletions

View file

@ -9,6 +9,7 @@ header('Content-Type: application/json; charset=utf-8');
$job = $_POST['job'] ?? '';
$max_frames = isset($_POST['max_frames']) ? intval($_POST['max_frames']) : 16;
$additional_prompt = trim((string)($_POST['additional_prompt'] ?? ''));
if (!preg_match('/^[0-9]{8}[-_][A-Za-z0-9._-]+$/', $job)) {
http_response_code(400);
@ -23,6 +24,14 @@ if (!is_dir($jobdir)) {
exit;
}
$describe_prompt_file = $jobdir . '/.mvlog-describe-prompt.txt';
if ($additional_prompt !== '') {
@file_put_contents($describe_prompt_file, $additional_prompt . PHP_EOL);
@chmod($describe_prompt_file, 0664);
@chown($describe_prompt_file, 'www-data');
@chgrp($describe_prompt_file, 'www-data');
}
// Read existing data.txt for Title and Location (case-insensitive aliases)
$data_file = $jobdir . '/data.txt';
$title = '';
@ -135,7 +144,11 @@ if (!is_file($script)) {
$log = $jobdir . '/generate_data.log';
$bash = '/bin/bash';
$cmd = escapeshellcmd($bash) . ' ' . escapeshellarg($script) . ' ' . escapeshellarg($jobdir) . ' ' . escapeshellarg($title) . ' ' . escapeshellarg($location) . ' ' . escapeshellarg((string)$max_frames) . ' >> ' . escapeshellarg($log) . ' 2>&1 & echo $!';
if ($additional_prompt !== '') {
$cmd = escapeshellcmd($bash) . ' ' . escapeshellarg($script) . ' ' . escapeshellarg($jobdir) . ' ' . escapeshellarg($title) . ' ' . escapeshellarg($location) . ' ' . escapeshellarg((string)$max_frames) . ' ' . escapeshellarg($additional_prompt) . ' >> ' . escapeshellarg($log) . ' 2>&1 & echo $!';
} else {
$cmd = escapeshellcmd($bash) . ' ' . escapeshellarg($script) . ' ' . escapeshellarg($jobdir) . ' ' . escapeshellarg($title) . ' ' . escapeshellarg($location) . ' ' . escapeshellarg((string)$max_frames) . ' ' . escapeshellarg('no-append') . ' >> ' . escapeshellarg($log) . ' 2>&1 & echo $!';
}
$pid = trim(@shell_exec($cmd));