- Implemented:

Added view_count database migration/defaults and shared helpers in 
[includes/db.php](/Users/tyemeclifford/Documents/GH/mediaplayer/includes/db.php).
Public player and embed.php now increment views.
Homepage and catalogue can display per-video views, total views, and 
public stats based on admin settings.
Added Admin → Settings toggles for public view/stat display.
Added Admin → Upkeeping action to restore external view counts from 
readable provider pages, with YouTube scraping support first.
Added manual per-video view-count editing in 
[admin/edit.php](/Users/tyemeclifford/Documents/GH/mediaplayer/admin/edit.php) 
for older local uploads or corrections.
Updated 
[README.md](/Users/tyemeclifford/Documents/GH/mediaplayer/README.md) 
with the new behavior.
This commit is contained in:
Ty Clifford
2026-06-25 04:16:34 -04:00
parent dc71d26c2a
commit 86d1fedcb3
8 changed files with 472 additions and 29 deletions
+47 -2
View File
@@ -25,6 +25,15 @@ if (url_rewrite_enabled()) {
$per_page = (int)setting('catalogue_per_page', '10');
$page = max(1, (int)($_GET['page'] ?? 1));
$paged = get_videos_paginated($page, $per_page, true, $search);
$show_video_views = setting_bool('public_show_video_views', true);
$show_total_views = setting_bool('public_show_total_views', true);
$show_page_stats = setting_bool('public_show_page_stats', true);
$total_public_views = total_video_views(true);
$public_stats = $show_page_stats ? public_page_stats() : [
'videos' => (int)$paged['total'],
'sources' => 0,
'views' => $total_public_views,
];
render_head('Videos — TyClifford.com', '
.cat-grid {
@@ -72,6 +81,14 @@ render_head('Videos — TyClifford.com', '
.public-search { display:flex; gap:.5rem; width:100%; max-width:460px; }
.public-search input { flex:1; min-width:0; }
@media(max-width:560px) { .public-search { max-width:none; } }
.stats-panel {
background:var(--surface); border:1px solid var(--border);
border-radius:calc(var(--r)+2px); padding:1rem 1.1rem;
display:grid; grid-template-columns:repeat(auto-fit,minmax(130px,1fr)); gap:.75rem;
}
.stats-item { display:flex; flex-direction:column; gap:.25rem; }
.stats-label { font-family:"Share Tech Mono",monospace; font-size:.6rem; letter-spacing:.12em; text-transform:uppercase; color:var(--text-3); }
.stats-value { font-family:"Share Tech Mono",monospace; font-size:1rem; color:var(--text); }
.cat-footer { display:flex; align-items:center; justify-content:space-between; gap:1rem; flex-wrap:wrap; margin-top:.5rem; }
.cat-count { font-family:"Share Tech Mono",monospace; font-size:.65rem; color:var(--text-3); letter-spacing:.06em; }
@@ -91,8 +108,14 @@ render_head('Videos — TyClifford.com', '
<p class="eyebrow eyebrow-purple" style="margin-bottom:.3rem">Library</p>
<h1 style="font-size:1.1rem;font-weight:700;color:var(--text);">Video Catalogue</h1>
</div>
<?php
$header_parts = [
$paged['total'] . ' ' . ($search ? 'result' : 'video') . ($paged['total'] != 1 ? 's' : ''),
];
if ($show_total_views) $header_parts[] = view_count_label($total_public_views) . ' total';
?>
<span class="cat-count">
<?= $paged['total'] ?> <?= $search ? 'result' : 'video' ?><?= $paged['total'] != 1 ? 's' : '' ?>
<?= h(implode(' · ', $header_parts)) ?>
</span>
</div>
<form class="public-search" method="get" action="<?= h(public_catalogue_url()) ?>" role="search">
@@ -107,6 +130,25 @@ render_head('Videos — TyClifford.com', '
</form>
</div>
<?php if ($show_page_stats): ?>
<section class="stats-panel" aria-label="Public catalogue statistics">
<div class="stats-item">
<span class="stats-label">Public Videos</span>
<strong class="stats-value"><?= h(format_count((int)$public_stats['videos'])) ?></strong>
</div>
<?php if ($show_total_views): ?>
<div class="stats-item">
<span class="stats-label">Total Views</span>
<strong class="stats-value"><?= h(format_count((int)$public_stats['views'])) ?></strong>
</div>
<?php endif; ?>
<div class="stats-item">
<span class="stats-label">Sources</span>
<strong class="stats-value"><?= h(format_count((int)$public_stats['sources'])) ?></strong>
</div>
</section>
<?php endif; ?>
<?php if (empty($paged['videos'])): ?>
<div class="card">
<div class="empty-state">
@@ -123,6 +165,9 @@ render_head('Videos — TyClifford.com', '
$vthumb = $v['thumbnail'];
$vdur = (int)$v['duration'];
$created = substr($v['created_at'], 0, 10);
$meta_parts = [$created];
if ($vdur) $meta_parts[] = format_duration($vdur);
if ($show_video_views) $meta_parts[] = view_count_label((int)$v['view_count']);
?>
<a class="cat-thumb" href="<?= h(public_video_url($vslug)) ?>" title="<?= h($vtitle) ?>">
<div class="cat-thumb-img">
@@ -143,7 +188,7 @@ render_head('Videos — TyClifford.com', '
<?php if ($vdesc): ?>
<span class="cat-thumb-desc"><?= h($vdesc) ?></span>
<?php endif; ?>
<span class="cat-thumb-meta"><?= h($created) ?><?= $vdur ? ' · ' . format_duration($vdur) : '' ?></span>
<span class="cat-thumb-meta"><?= h(implode(' · ', $meta_parts)) ?></span>
</div>
</a>
<?php endforeach; ?>