-Implemented YouTube timestamp correction and added the admin Upkeeping section.

What changed:
Added shared YouTube publish-date scraping helpers in 
[includes/db.php](/Users/tyemeclifford/Documents/GH/mediaplayer/includes/db.php).
New YouTube imports now set videos.created_at to the original YouTube 
publish date when available.
Manual Add/Edit saves now also try to correct timestamps for 
YouTube-backed videos.
Added Admin Dashboard → Upkeeping → Correct YouTube timestamps in 
[admin/index.php](/Users/tyemeclifford/Documents/GH/mediaplayer/admin/index.php), 
with batch size control for backfilling existing records.
Renamed the admin table column from Added to Date, since it may now 
reflect original publish date.
Documented the behavior in 
[README.md](/Users/tyemeclifford/Documents/GH/mediaplayer/README.md).
This commit is contained in:
Ty Clifford
2026-06-24 13:40:03 -04:00
parent 99492287e7
commit dc71d26c2a
6 changed files with 205 additions and 8 deletions
+15 -5
View File
@@ -486,10 +486,8 @@ function yt_import_videos(PDO $db, array $videos, array $selected_ids, bool $pub
try {
$slug = make_slug($video['title']);
$thumbnail = yt_download_thumbnail($video['thumbnail_url'], $slug);
$db->prepare("
INSERT INTO videos (title, description, slug, thumbnail, duration, sort_order, published)
VALUES (?, ?, ?, ?, ?, ?, ?)
")->execute([
$published_at = media_youtube_publish_datetime($video['watch_url']);
$video_params = [
$video['title'],
$video['description'],
$slug,
@@ -497,7 +495,19 @@ function yt_import_videos(PDO $db, array $videos, array $selected_ids, bool $pub
(int)$video['duration'],
0,
$published ? 1 : 0,
]);
];
if ($published_at !== '') {
$video_params[] = $published_at;
$db->prepare("
INSERT INTO videos (title, description, slug, thumbnail, duration, sort_order, published, created_at, updated_at)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, datetime('now'))
")->execute($video_params);
} else {
$db->prepare("
INSERT INTO videos (title, description, slug, thumbnail, duration, sort_order, published)
VALUES (?, ?, ?, ?, ?, ?, ?)
")->execute($video_params);
}
$video_id = (int)$db->lastInsertId();
$db->prepare("
INSERT INTO video_sources (video_id, label, source_type, file_path, source_url, mime_type, quality, sort_order)