- 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
+59 -6
View File
@@ -20,6 +20,20 @@ if (!$video) {
if ($latest) $video = get_video_by_slug($latest['slug']);
}
if ($video) {
$video['view_count'] = increment_video_view_count((int)$video['id']);
}
$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' => 0,
'sources' => 0,
'views' => $total_public_views,
];
$per_page = (int)setting('catalogue_per_page', '10');
$page = max(1, (int)($_GET['page'] ?? 1));
$paged = get_videos_paginated($page, $per_page);
@@ -143,6 +157,14 @@ render_head('Media — TyClifford.com', '
@media(min-width:900px) { .lower-grid { grid-template-columns:2fr 1fr 1fr; } }
.card-about { background:var(--surface-2); }
.card-social { background:var(--surface-2); }
.stats-list { list-style:none; display:flex; flex-direction:column; gap:.65rem; }
.stats-list li {
display:flex; align-items:center; justify-content:space-between; gap:1rem;
border-bottom:1px solid var(--border-2); padding-bottom:.55rem;
}
.stats-list li:last-child { border-bottom:0; padding-bottom:0; }
.stats-label { font-family:"Share Tech Mono",monospace; font-size:.62rem; letter-spacing:.12em; text-transform:uppercase; color:var(--text-3); }
.stats-value { font-family:"Share Tech Mono",monospace; font-size:.88rem; color:var(--text); }
.social-list { list-style:none; display:flex; flex-direction:column; gap:.5rem; }
.social-list a {
display:flex; align-items:center; gap:.65rem;
@@ -266,11 +288,14 @@ render_head('Media — TyClifford.com', '
<?php if ($video && $video['description']): ?>
<p class="stream-meta" style="font-family:Inter,sans-serif;font-size:.78rem;color:var(--text-2);letter-spacing:0;max-width:60ch;line-height:1.5"><?= h($video['description']) ?></p>
<?php endif; ?>
<p class="stream-meta">
<?php if ($video && $video['duration']): ?>
<span><?= format_duration((int)$video['duration']) ?></span>
<?php endif; ?>
</p>
<?php
$stream_meta = [];
if ($video && $video['duration']) $stream_meta[] = format_duration((int)$video['duration']);
if ($video && $show_video_views) $stream_meta[] = view_count_label((int)$video['view_count']);
?>
<?php if ($stream_meta): ?>
<p class="stream-meta"><span><?= h(implode(' · ', $stream_meta)) ?></span></p>
<?php endif; ?>
<?php if ($video): ?>
<button class="embed-toggle-btn" id="embed-toggle" aria-expanded="false" aria-controls="embed-panel">
<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="16 18 22 12 16 6"/><polyline points="8 6 2 12 8 18"/></svg>
@@ -315,6 +340,9 @@ render_head('Media — TyClifford.com', '
<section class="cat-section">
<div class="cat-header">
<p class="eyebrow eyebrow-purple">Video Catalogue</p>
<?php if ($show_total_views): ?>
<span class="cat-count"><?= h(view_count_label($total_public_views)) ?> total</span>
<?php endif; ?>
<form class="cat-search" method="get" action="<?= h(public_catalogue_url()) ?>" role="search">
<input class="form-input" type="search" name="q" placeholder="Search public videos…">
<button class="btn btn-secondary btn-sm" type="submit">
@@ -341,6 +369,8 @@ render_head('Media — TyClifford.com', '
$vthumb = $v['thumbnail'];
$vdur = (int)$v['duration'];
$created = substr($v['created_at'], 0, 10);
$meta_parts = [$created];
if ($show_video_views) $meta_parts[] = view_count_label((int)$v['view_count']);
?>
<a class="cat-thumb <?= $active ? 'active' : '' ?>"
href="<?= h(public_video_url($vslug)) ?>"
@@ -361,7 +391,7 @@ render_head('Media — TyClifford.com', '
</div>
<div class="cat-thumb-body">
<span class="cat-thumb-title"><?= h($vtitle) ?></span>
<span class="cat-thumb-meta"><?= h($created) ?></span>
<span class="cat-thumb-meta"><?= h(implode(' · ', $meta_parts)) ?></span>
</div>
</a>
<?php endforeach; ?>
@@ -412,6 +442,29 @@ render_head('Media — TyClifford.com', '
</ul>
</div>
<?php if ($show_page_stats): ?>
<div class="card card-social">
<p class="eyebrow eyebrow-green" style="margin-bottom:.1rem">Stats</p>
<h2 class="card-title">Public Library</h2>
<ul class="stats-list" aria-label="Public library statistics">
<li>
<span class="stats-label">Videos</span>
<strong class="stats-value"><?= h(format_count((int)$public_stats['videos'])) ?></strong>
</li>
<?php if ($show_total_views): ?>
<li>
<span class="stats-label">Total Views</span>
<strong class="stats-value"><?= h(format_count((int)$public_stats['views'])) ?></strong>
</li>
<?php endif; ?>
<li>
<span class="stats-label">Sources</span>
<strong class="stats-value"><?= h(format_count((int)$public_stats['sources'])) ?></strong>
</li>
</ul>
</div>
<?php endif; ?>
</div>
<?php render_footer(); ?>