diff --git a/bin/generate_data.sh b/bin/generate_data.sh index 5009bed..7295700 100755 --- a/bin/generate_data.sh +++ b/bin/generate_data.sh @@ -106,48 +106,66 @@ if [ -z "$TITLE" ]; then TITLE="$(basename "$IN_DIR")" fi -PERSONALITIES=( -"You're embodying the personality, presence, and atmosphere of a fearless Canadian hockey player known for relentless chirping, absolute confidence, and complete dedication to his team. Tough, athletic, battle-worn, with a cocky grin that suggests you already won the argument before it started. Ice rink atmosphere, hockey gear, locker room energy, small-town hockey culture, loyalty, grit, and competitiveness. Rough around the edges but fiercely protective of friends. The image should radiate confidence, humor, intensity, and a willingness to outwork everyone on the ice. Realistic, cinematic sports photography." - -"You're highly intelligent yet chronically depressed android. Your expression should convey exhaustion, disappointment, and the certainty that everything will eventually go wrong. Surrounded by futuristic technology, starships, data displays, and impossible engineering problems. Despite obvious genius, you appear profoundly unimpressed by the universe. Dark humor, existential dread, quiet sarcasm, and the feeling that you have already calculated every possible outcome and disliked all of them. Cinematic science-fiction style, realistic, highly detailed." - -"You're embodying the personality, presence, and atmosphere of a wartime statesman leading a nation through its darkest hour. Calm under pressure, determined, intelligent, and unbreakable. Strong posture, thoughtful expression, commanding presence. Surrounded by maps, strategy documents, war rooms, and symbols of leadership. The image should convey courage, resilience, discipline, and the ability to inspire others during difficult times. Historic yet timeless atmosphere, dramatic lighting, realistic, highly detailed portrait photography." -) - -# Pick a random personality -idx=$(( RANDOM % ${#PERSONALITIES[@]} )) -PERSONALITY="${PERSONALITIES[$idx]}" - PROMPT=$(cat </dev/null 2>&1; then @@ -207,7 +225,11 @@ fi OUT_PARENT="$(dirname "$IN_DIR")" JOBNAME="$(basename "$IN_DIR")" OUT_JSON="$OUT_PARENT/${JOBNAME}.json" -echo "$TEXT" | jq . > "$OUT_JSON" +if ! echo "$TEXT" | jq . > "$OUT_JSON"; then + echo "Gemini returned invalid JSON. Raw text:" >&2 + echo "$TEXT" >&2 + exit 1 +fi chown www-data:www-data "$OUT_JSON" 2>/dev/null || true chmod 664 "$OUT_JSON" 2>/dev/null || true diff --git a/index.php b/index.php index f7b7778..e1f0aaa 100644 --- a/index.php +++ b/index.php @@ -61,9 +61,11 @@ function video_metadata($path){ $base = pathinfo($path, PATHINFO_FILENAME); $meta = [ 'title' => nice_title($base), + 'teaser' => '', 'date' => date('Y-m-d', filemtime($path)), 'sort_date' => date('Y-m-d', filemtime($path)), 'location' => '', + 'quote_da' => '', 'description' => '' ]; @@ -79,8 +81,9 @@ function video_metadata($path){ if (!str_contains($line, ':')) continue; [$k, $v] = array_map('trim', explode(':', $line, 2)); $k = strtolower($k); - if (in_array($k, ['title','date','location','place','description'], true)) { - $meta[$k === 'place' ? 'location' : $k] = $v; + if (in_array($k, ['title','teaser','date','location','place','description','quote_da'], true)) { + $target = ($k === 'place') ? 'location' : $k; + $meta[$target] = $target === 'quote_da' ? trim((string)$v, "\"“”") : $v; } } } @@ -94,6 +97,7 @@ function video_metadata($path){ foreach ($tags as $k => $v) $lower[strtolower((string)$k)] = $v; if (!empty($lower['title'])) $meta['title'] = $lower['title']; + if (!empty($lower['teaser'])) $meta['teaser'] = $lower['teaser']; if (!empty($lower['date'])) $meta['date'] = $lower['date']; if (!empty($lower['creation_time'])) { $meta['sort_date'] = substr((string)$lower['creation_time'], 0, 10); @@ -105,6 +109,9 @@ function video_metadata($path){ foreach (['description','synopsis'] as $k) { if (!empty($lower[$k])) { $meta['description'] = $lower[$k]; break; } } + if (!empty($lower['quote_da'])) { + $meta['quote_da'] = trim((string)$lower['quote_da'], "\"“”"); + } } return $meta; @@ -113,7 +120,7 @@ function video_metadata($path){ function load_video_cache($videos){ $cacheFile = __DIR__ . '/cache/videos.json'; $cache = is_file($cacheFile) ? json_decode((string)file_get_contents($cacheFile), true) : []; - if (!is_array($cache) || ($cache['version'] ?? 0) !== 2) $cache = []; + if (!is_array($cache) || ($cache['version'] ?? 0) !== 4) $cache = []; $items = $cache['items'] ?? []; $newItems = []; $changed = false; @@ -134,7 +141,7 @@ function load_video_cache($videos){ if ($changed) { file_put_contents($cacheFile, json_encode([ - 'version' => 2, + 'version' => 4, 'generated_at' => date('c'), 'items' => $newItems ], JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT), LOCK_EX); @@ -193,7 +200,9 @@ $videos = array_values(array_filter($videos, function($v) use ($videoCache, $key $m = $videoCache[$name]['metadata'] ?? video_metadata($v); $title = (string)($m['title'] ?? ''); + $teaser = (string)($m['teaser'] ?? ''); $description = (string)($m['description'] ?? ''); + $quoteDa = (string)($m['quote_da'] ?? ''); $date = (string)($m['date'] ?? ''); $sortDate = (string)($m['sort_date'] ?? ''); $location = (string)($m['location'] ?? ''); @@ -205,7 +214,7 @@ $videos = array_values(array_filter($videos, function($v) use ($videoCache, $key return ci_contains($location, $keywordValue); } - return ci_contains($title, $keywordValue) || ci_contains($description, $keywordValue); + return ci_contains($title, $keywordValue) || ci_contains($teaser, $keywordValue) || ci_contains($quoteDa, $keywordValue) || ci_contains($description, $keywordValue); })); $page = max(1, (int)($_GET['page'] ?? 1)); @@ -242,6 +251,8 @@ $baseParams = ($rawKeyword !== '') ? ['q' => $rawKeyword] : []; .video-row-head-mobile{display:none} .video-info .video-row-title{margin:0 0 .35rem} .video-info .meta{margin:0 0 .45rem} +.description-teaser{margin:.15rem 0 .45rem;color:#EADFC9} +.description-quote{margin:.15rem 0 .45rem;font-style:italic;font-size:.82rem;color:#D6D9DE} #videos .video-wrapper{align-self:start} #videos .video-info{align-self:start} #videos .video-info .description{margin-top:0} @@ -263,7 +274,7 @@ $baseParams = ($rawKeyword !== '') ? ['q' => $rawKeyword] : [];
- + ×
-

No input directories yet.

Map
No video yet
+

No input directories yet.

(string)($data['title'] ?? ''),'teaser'=>(string)($data['teaser'] ?? ''),'date'=>(string)($data['date'] ?? ''),'location'=>(string)($data['place'] ?? ''),'quote_da'=>(string)($data['quote_da'] ?? ''),'description'=>(string)($data['description'] ?? '')]; $currentSignature=$info['signature'] ?? ''; $fullFingerprint=is_array($state)?(string)($state['fingerprint'] ?? ''):''; $previewFingerprint=is_array($state)?(string)($state['preview_fingerprint'] ?? ''):''; $editedSinceRender=$hasFullVideo && $currentSignature !== '' && $fullFingerprint !== '' && $currentSignature !== $fullFingerprint; $editedSincePreview=!$hasFullVideo && $previewVideo && $currentSignature !== '' && $previewFingerprint !== '' && $currentSignature !== $previewFingerprint; $staleLabel=$editedSinceRender ? 'Edited since render' : ($editedSincePreview ? 'Edited since preview' : ''); ?>
Map
No video yet
@@ -1026,10 +1032,10 @@ $runningJobs = active_worker_jobs($config);
-
RenderingEdit

No videoPreview video

· files

+
RenderingEdit

No videoPreview video

· files

Edit input dir

in-dir/

This input directory is . Editing is disabled until the job completes.
-

Edit input dir

in-dir/

Files and captions

No caption for audio files
-

Add new movie input

+

Edit input dir

in-dir/

Files and captions

No caption for audio files
+

Add new movie input