From f84ecb5ae9783ac9993809e9eedbe05f65769ed7 Mon Sep 17 00:00:00 2001 From: Jonathan Sykes Date: Sun, 11 Oct 2026 03:26:04 +0800 Subject: [PATCH 1/2] Auto-save every video you play for offline, with a Settings switch --- frontend/app.js | 15 +++++++++++++++ frontend/views-core.js | 11 +++++++++++ perf/autosave.mjs | 2 +- 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/frontend/app.js b/frontend/app.js index e05ee6b..7d30e8b 100755 --- a/frontend/app.js +++ b/frontend/app.js @@ -655,6 +655,7 @@ const DEFAULT_SETTINGS = { quality: 'auto', volume: 1, audioOnly: false, autoPreload: true, p2pShare: true, // P2P (docs/p2p-architecture.md): share my saved videos with other devices — ON by default p2pReceive: true, // fetch from other devices when YouTube and the server can't — ON by default + autoSavePlayed: true, // keep every video you play for offline (background save once playback starts) saveBeforePlay: false, // download (server-muxed single file) before playing instead of streaming repeatMode: 'off', // 'off' | 'all' — repeat the playing list when it ends loopOne: false, // repeat the single current video @@ -1977,6 +1978,20 @@ function markCardCacheState(id, state) { }); } +// Auto-save what you play: once a video starts playing, save it in the +// background (never delays playback). One attempt per video per page session. +const autoSaveTried = new Set(); +document.addEventListener('play', () => { + const m = current && current.meta; + if (!m || !m.id || m.custom || current.localUrl) return; + if (data.settings.autoSavePlayed === false) return; + if (!WEB) return; + if (cachedIds.has(m.id) || downloading.has(m.id) || autoSaveTried.has(m.id)) return; + autoSaveTried.add(m.id); + preload(m, { quiet: true }); +}, true); + + // ============================================================================ // Video editor — cut parts out of a video and save a custom offline copy // diff --git a/frontend/views-core.js b/frontend/views-core.js index cf8cad5..53f04b4 100644 --- a/frontend/views-core.js +++ b/frontend/views-core.js @@ -844,6 +844,13 @@ async function renderSettings() {
Offline cache
App & featuresChecking offline readiness…
+
+