diff --git a/README.md b/README.md index b287fa2..9921592 100644 --- a/README.md +++ b/README.md @@ -44,16 +44,16 @@ Styled to match the existing `gate.php` / `index.php` dark theme exactly. │ └── layout.php ← Shared HTML head, topbar, footer, pagination ├── admin/ │ ├── index.php ← Video list with search + pagination -│ ├── add.php ← Add new media with uploaded or external URL sources -│ ├── edit.php ← Edit media metadata + manage local/remote sources +│ ├── add.php ← Add new video with uploaded or external URL sources +│ ├── edit.php ← Edit video metadata + manage local/remote sources │ ├── youtube_import.php ← Scrape a YouTube channel and import videos │ ├── settings.php ← Site settings, per-page count, password │ ├── login.php ← Admin login │ ├── logout.php ← Session destroy + redirect │ └── auth.php ← Session auth helpers ├── media/ ← All media files (created automatically) -│ ├── videos/ ← Uploaded media files -│ └── thumbs/ ← Uploaded thumbnails and generated waveforms +│ ├── videos/ ← Uploaded video files +│ └── thumbs/ ← Uploaded thumbnail images └── data/ └── media.db ← SQLite database (auto-created) ``` @@ -62,19 +62,18 @@ Styled to match the existing `gate.php` / `index.php` dark theme exactly. ## Usage -### Adding Media (Admin) +### Adding Videos (Admin) 1. Go to `admin/add.php` 2. Fill in title, description, duration, sort order, or paste an external URL and click **Fetch Info** to auto-fill readable metadata 3. Upload a thumbnail (JPG/PNG/WebP) -4. Add one or more media sources. Each source can be either: - - an uploaded local video or audio file, stored under `media/videos/` +4. Add one or more video sources. Each source can be either: + - an uploaded local video file, stored under `media/videos/` - an external URL, stored in SQLite and played as a direct media source or provider embed 5. For uploaded files, supported formats include: - **MP4** (H.264) — widest compatibility - **WebM** (VP9) — smaller size, modern browsers - **OGV** — Firefox fallback (legacy) - - **MP3 / M4A / AAC / WAV / FLAC / OGG / OPUS** — common audio formats 6. Set quality labels (1080p, 720p, 480p, etc.) 7. Save — Video.js will use the stored source location and auto-select the best format the browser supports @@ -82,7 +81,7 @@ External URLs must use `http://` or `https://`. Uploaded files and remote URLs c When adding an external URL, the admin form can fetch title, description, duration, thumbnail metadata, and readable provider view counts through oEmbed, page metadata, and JSON-LD. The save action repeats the metadata lookup as a fallback, so blank titles can be filled from supported external pages even if the browser autofill was not used. -If no thumbnail image is uploaded, the add/edit forms can auto-grab one from the first supported source. YouTube and Dailymotion use direct thumbnail URLs; Vimeo, Wistia, TikTok, SoundCloud, and Spotify use oEmbed when available. Local uploaded videos can generate a first-frame thumbnail when `ffmpeg` is installed on the server, and local uploaded audio can generate a waveform poster image. +If no thumbnail image is uploaded, the add/edit forms can auto-grab one from the first supported source. YouTube and Dailymotion use direct thumbnail URLs; Vimeo, Wistia, TikTok, SoundCloud, and Spotify use oEmbed when available. Local uploaded videos can generate a first-frame thumbnail when `ffmpeg` is installed on the server. ### Live Homepage Option @@ -143,8 +142,6 @@ Use the **Sort Order** field — lower numbers appear first. Default is 0. The * - Playback rate controls: 0.5×, 1×, 1.25×, 1.5×, 2× - Multiple source fallback — browser picks best format automatically - Local uploaded sources and remote URL sources -- Audio playback for uploaded or direct linked audio sources -- Generated waveform poster images for uploaded audio when `ffmpeg` is available - Provider embeds for popular video and audio platforms - Thumbnail posters - Per-video view counts and optional public library statistics diff --git a/admin/add.php b/admin/add.php index bacd49a..24aed78 100644 --- a/admin/add.php +++ b/admin/add.php @@ -88,7 +88,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { $inserted_sources = 0; $moved_files = []; - $allowed_media = media_allowed_upload_extensions(); + $allowed_video = ['mp4','webm','ogv','ogg','mov','mkv','avi']; for ($i = 0; $i < $source_count; $i++) { $type = ($source_types[$i] ?? 'local') === 'remote' ? 'remote' : 'local'; @@ -99,7 +99,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { if ($type === 'remote') { $url = normalize_media_url($source_urls[$i] ?? ''); if ($url === '') { - if (trim($source_urls[$i] ?? '') !== '') $error = 'External media URLs must start with http:// or https://.'; + if (trim($source_urls[$i] ?? '') !== '') $error = 'External video URLs must start with http:// or https://.'; continue; } $metadata = $source_metadata[$url] ?? []; @@ -119,19 +119,15 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { if (empty($tmp) || !is_uploaded_file($tmp)) continue; $orig_name = $source_files['name'][$i] ?? ''; $ext = strtolower(pathinfo($orig_name, PATHINFO_EXTENSION)); - if (!in_array($ext, $allowed_media, true)) { - $error = 'Uploaded media files must be one of: ' . media_upload_format_summary() . '.'; - break; - } + if (!in_array($ext, $allowed_video, true)) continue; $fname = $slug . '_' . ($i+1) . '_' . time() . '.' . $ext; if (move_uploaded_file($tmp, $videos_dir . $fname)) { - $target = $videos_dir . $fname; - $moved_files[] = $target; + $moved_files[] = $videos_dir . $fname; $db->prepare(" INSERT INTO video_sources (video_id, label, source_type, file_path, source_url, mime_type, quality, sort_order) VALUES (?,?,?,?,?,?,?,?) - ")->execute([$video_id, $label, 'local', 'videos/' . $fname, '', media_mime_from_local_file($target, $fname), $quality, $sort]); + ")->execute([$video_id, $label, 'local', 'videos/' . $fname, '', mime_from_ext($fname), $quality, $sort]); $inserted_sources++; } } @@ -158,7 +154,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { } } -render_head('Add Media — Admin', ' +render_head('Add Video — Admin', ' .form-grid { display:grid; grid-template-columns:1fr; gap:1.2rem; } @media(min-width:700px) { .form-grid { grid-template-columns:1fr 1fr; } } .form-grid .span2 { grid-column:1/-1; } @@ -210,7 +206,7 @@ render_head('Add Media — Admin', '
Ty Clifford
-
admin / add media
+
admin / add video