Additional inputs for Describe functionality
This commit is contained in:
parent
efaa5c4306
commit
ad184d778d
5 changed files with 239 additions and 38 deletions
|
|
@ -10,6 +10,7 @@ header('Content-Type: application/json; charset=utf-8');
|
|||
$id = strtolower(trim((string)($_POST['id'] ?? '')));
|
||||
$job = trim((string)($_POST['job'] ?? ''));
|
||||
$max_frames = isset($_POST['max_frames']) ? intval($_POST['max_frames']) : 16;
|
||||
$additional_prompt = trim((string)($_POST['additional_prompt'] ?? ''));
|
||||
|
||||
function mvlog_article_id_is_valid(string $id): bool {
|
||||
return (bool)preg_match('/^[0-9]{14}[a-f0-9]{16}$/', $id);
|
||||
|
|
@ -63,6 +64,14 @@ if ($jobdir === null || !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 = '';
|
||||
|
|
@ -101,8 +110,12 @@ if (!is_file($script)) {
|
|||
exit;
|
||||
}
|
||||
|
||||
// Build command and execute. Use no-append flag as last argument.
|
||||
$cmd = escapeshellcmd($script) . ' ' . escapeshellarg($jobdir) . ' ' . escapeshellarg($title) . ' ' . escapeshellarg($location) . ' ' . escapeshellarg((string)$max_frames) . ' ' . escapeshellarg('no-append') . ' 2>&1';
|
||||
// Build command and execute. Pass optional additional prompt as the last argument.
|
||||
if ($additional_prompt !== '') {
|
||||
$cmd = escapeshellcmd($script) . ' ' . escapeshellarg($jobdir) . ' ' . escapeshellarg($title) . ' ' . escapeshellarg($location) . ' ' . escapeshellarg((string)$max_frames) . ' ' . escapeshellarg($additional_prompt) . ' 2>&1';
|
||||
} else {
|
||||
$cmd = escapeshellcmd($script) . ' ' . escapeshellarg($jobdir) . ' ' . escapeshellarg($title) . ' ' . escapeshellarg($location) . ' ' . escapeshellarg((string)$max_frames) . ' ' . escapeshellarg('no-append') . ' 2>&1';
|
||||
}
|
||||
|
||||
// Allow long-running
|
||||
@set_time_limit(0);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue