Files
weval-consulting/api/l99-videos-fix.php

23 lines
704 B
PHP

<?php
header('Content-Type: application/json');
$dirs = ['/opt/weval-l99/videos'];
$all = [];
foreach ($dirs as $dir) {
foreach (glob("$dir/*.webm") as $f) $all[] = $f;
foreach (glob("$dir/*.mp4") as $f) $all[] = $f;
}
usort($all, function($a,$b){ return filemtime($b)-filemtime($a); });
$out = [];
foreach ($all as $fn) {
$n = basename($fn);
$base = pathinfo($n, PATHINFO_FILENAME);
$sz = filesize($fn);
$out[] = [
'url' => '/api/l99-videos/' . $n,
'name' => substr($base, 0, 12) . '...',
'size_h' => round($sz/1048576, 1) . 'MB',
'date' => date('Y-m-d H:i', filemtime($fn)),
];
}
echo json_encode(['videos' => $out, 'total' => count($all)]);