Sort videos by metadata date
This commit is contained in:
parent
ae4fb2f87c
commit
dfeee1c187
1 changed files with 7 additions and 1 deletions
|
|
@ -72,8 +72,14 @@ function load_video_cache($videos){
|
||||||
return $newItems;
|
return $newItems;
|
||||||
}
|
}
|
||||||
$videos = glob($config['videos_dir'].'/*.{mp4,webm,mov,m4v}', GLOB_BRACE) ?: [];
|
$videos = glob($config['videos_dir'].'/*.{mp4,webm,mov,m4v}', GLOB_BRACE) ?: [];
|
||||||
usort($videos, fn($a,$b)=>filemtime($b)<=>filemtime($a));
|
|
||||||
$videoCache = load_video_cache($videos);
|
$videoCache = load_video_cache($videos);
|
||||||
|
usort($videos, function($a, $b) use ($videoCache) {
|
||||||
|
$am = $videoCache[basename($a)] ?? [];
|
||||||
|
$bm = $videoCache[basename($b)] ?? [];
|
||||||
|
$ad = strtotime($am['metadata']['date'] ?? '') ?: filemtime($a);
|
||||||
|
$bd = strtotime($bm['metadata']['date'] ?? '') ?: filemtime($b);
|
||||||
|
return $bd <=> $ad;
|
||||||
|
});
|
||||||
$page=max(1,(int)($_GET['page']??1)); $per=$config['items_per_page']; $total=count($videos); $pages=max(1,(int)ceil($total/$per)); $page=min($page,$pages); $slice=array_slice($videos,($page-1)*$per,$per);
|
$page=max(1,(int)($_GET['page']??1)); $per=$config['items_per_page']; $total=count($videos); $pages=max(1,(int)ceil($total/$per)); $page=min($page,$pages); $slice=array_slice($videos,($page-1)*$per,$per);
|
||||||
?>
|
?>
|
||||||
<!doctype html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>MVLog</title><link rel="stylesheet" href="style.css"></head><body>
|
<!doctype html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>MVLog</title><link rel="stylesheet" href="style.css"></head><body>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue