Add shared synced lyrics, chapters and personal bookmarks with revision history, API tokens and an admin page

This commit is contained in:
Jonathan Sykes
2026-09-18 18:10:10 +08:00
parent a20dd0a3a6
commit 524db986d2
14 changed files with 2493 additions and 11 deletions

View File

@@ -39,6 +39,9 @@ import { createHash } from 'node:crypto';
import { initDb, upsertUser, recordVideoAccess, getUserData, createProfile, getProfile, saveProfile, createSharedPlaylist, getSharedPlaylist, queueInboxPlaylist, listInbox, deleteInboxItem, countInbox,
getMedia, upsertMedia, deleteMedia, listMedia, listMediaLru, touchMedia, mediaStats } from './db.js';
import { createMediaCache, HIGH, LOW } from './media-cache.js';
import * as notesDb from './db.js';
import { registerNoteRoutes } from './notes.js';
import { dirname, join as pathJoin } from 'node:path';
// A media proxy must not die because one client's stream hit an edge case
// (see /api/play cancel()): log and keep serving instead of crash-looping.
@@ -1554,6 +1557,19 @@ app.get('/api/user/data', async (c) => {
}
});
// ============================================================================
// Shared lyrics + chapters, API tokens, admin page — see notes.js
// ============================================================================
const notes = registerNoteRoutes(app, {
db: notesDb,
getProfile,
profileNameRe: PROFILE_NAME_RE,
runYtdlp: runYtdlpResilient,
adminPassword: process.env.ADMIN_PASSWORD || '',
backupDir: pathJoin(dirname(process.env.DB_PATH || './data/ytplayer.db'), 'backups'),
adminHtmlPath: './public/admin.html',
});
// ============================================================================
// GET /sw.js — serve the service worker with BUILD_TAG injected
//
@@ -1623,6 +1639,7 @@ async function main() {
await initDb();
console.log(`[ytplayer] DB ready`);
await media.init();
notes.startBackups();
console.log(`[ytplayer] Starting on port ${PORT}`);
// Bun.serve is the native Bun HTTP server