- What changed:
Added external_view_count so provider totals from YouTube/Vimeo/etc are added to the site’s total without double-counting local plays. Updated public totals and per-video public view displays to use site views + external views. Changed Upkeeping action to Correct external view counts with a Correct Views button. Expanded provider scraping beyond YouTube with generic page/JSON-LD/oEmbed patterns for readable Vimeo, Dailymotion, and similar pages. Improved Add Video:Title no longer has to be manually entered first. External URL rows now have Fetch Info. Metadata can fill title, description, duration, source label, and external view count. Save also retries metadata extraction server-side. Added authenticated metadata endpoint: [admin/media_info.php](/Users/tyemeclifford/Documents/GH/mediaplayer/admin/media_info.php). Updated docs in [README.md](/Users/tyemeclifford/Documents/GH/mediaplayer/README.md).
This commit is contained in:
+12
-9
@@ -50,11 +50,11 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$msg .= '.';
|
||||
}
|
||||
|
||||
if ($action === 'restore_external_view_counts') {
|
||||
if ($action === 'restore_external_view_counts' || $action === 'correct_external_view_counts') {
|
||||
$limit = max(1, min(100, (int)($_POST['external_view_limit'] ?? 25)));
|
||||
$result = media_restore_external_view_counts($limit);
|
||||
$result = media_correct_external_view_counts($limit);
|
||||
$msg = 'Upkeeping checked ' . $result['checked'] . ' external video' . ($result['checked'] === 1 ? '' : 's') . ': ';
|
||||
$msg .= $result['restored'] . ' restored';
|
||||
$msg .= $result['corrected'] . ' corrected';
|
||||
if ($result['already_current']) $msg .= ', ' . $result['already_current'] . ' already current';
|
||||
if ($result['not_found']) $msg .= ', ' . $result['not_found'] . ' without a readable external count';
|
||||
$msg .= '.';
|
||||
@@ -78,7 +78,7 @@ $offset = ($page - 1) * $per_page;
|
||||
|
||||
$list_stmt = $db->prepare("
|
||||
SELECT v.id, v.title, v.slug, v.thumbnail, v.duration, v.published, v.sort_order,
|
||||
v.created_at, v.view_count,
|
||||
v.created_at, v.view_count, v.external_view_count,
|
||||
COUNT(vs.id) AS source_count,
|
||||
SUM(CASE WHEN vs.source_type='remote' THEN 1 ELSE 0 END) AS remote_count
|
||||
FROM videos v
|
||||
@@ -238,21 +238,21 @@ render_head('Admin — TyClifford.com', '
|
||||
</div>
|
||||
<div class="upkeep-row">
|
||||
<div class="upkeep-copy">
|
||||
<h2 class="card-title">Restore external view counts</h2>
|
||||
<h2 class="card-title">Correct external view counts</h2>
|
||||
<p class="hint">
|
||||
Scrapes readable counts from supported external providers and stores the higher value between the provider and local database.
|
||||
Scrapes readable counts from supported providers and adds them to the media-site totals alongside local plays.
|
||||
<?= $external_view_candidates ?> external video<?= $external_view_candidates === 1 ? '' : 's' ?> can be checked.
|
||||
Current database total: <?= h(view_count_label((int)$admin_total_views)) ?>.
|
||||
</p>
|
||||
</div>
|
||||
<form class="upkeep-form" method="post" action="index.php">
|
||||
<input type="hidden" name="action" value="restore_external_view_counts">
|
||||
<input type="hidden" name="action" value="correct_external_view_counts">
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="external_view_limit">Batch Size</label>
|
||||
<input class="form-input" type="number" id="external_view_limit" name="external_view_limit" value="25" min="1" max="100">
|
||||
</div>
|
||||
<button class="btn btn-secondary btn-sm" type="submit">
|
||||
Restore Views
|
||||
Correct Views
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
@@ -324,7 +324,10 @@ render_head('Admin — TyClifford.com', '
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td style="font-family:'Share Tech Mono',monospace;font-size:.7rem;color:var(--text-2);">
|
||||
<?= h(format_count((int)$v['view_count'])) ?>
|
||||
<?= h(format_count(video_total_views($v))) ?>
|
||||
<?php if ((int)$v['external_view_count'] > 0): ?>
|
||||
<span style="color:var(--text-3);"> · <?= h(format_count((int)$v['external_view_count'])) ?> external</span>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td>
|
||||
<span class="badge <?= $v['published'] ? 'badge-green' : 'badge-gray' ?>">
|
||||
|
||||
Reference in New Issue
Block a user