From f97d7d6453e8ead3bb2edecd2a2db91aa72f0fd2 Mon Sep 17 00:00:00 2001 From: WardPearce Date: Mon, 23 Feb 2026 19:30:16 +1300 Subject: [PATCH] Removed API-Extended --- docs/DOCKER-FULL.md | 34 -------- docs/DOCKER.md | 29 +------ materialious/Dockerfile | 4 - materialious/replace_env_vars.sh | 4 - materialious/src/lib/api/apiExtended.ts | 83 +++++++++---------- materialious/src/lib/api/index.ts | 62 +------------- materialious/src/lib/api/model.ts | 9 -- .../src/lib/components/player/Player.svelte | 66 +++++---------- .../components/settings/ApiExtended.svelte | 42 ---------- .../lib/components/settings/Settings.svelte | 2 - .../thumbnail/VideoThumbnail.svelte | 14 +--- .../src/lib/externalSettings/settings.ts | 12 --- materialious/src/lib/store.ts | 12 --- .../routes/api/proxy/[urlToProxy]/+server.ts | 1 - 14 files changed, 63 insertions(+), 311 deletions(-) delete mode 100644 materialious/src/lib/components/settings/ApiExtended.svelte diff --git a/docs/DOCKER-FULL.md b/docs/DOCKER-FULL.md index 76c9bc07..328bfd4d 100644 --- a/docs/DOCKER-FULL.md +++ b/docs/DOCKER-FULL.md @@ -136,37 +136,3 @@ ryd-proxy: ``` Modify/add `VITE_DEFAULT_RETURNYTDISLIKES_INSTANCE` for Materialious to be the reverse proxied URL of RYD-Proxy. - -## Step 3 (Optional, but recommended): Self-host Invidious API extended -```yaml -services: - api_extended: - image: wardpearce/invidious_api_extended:latest - restart: unless-stopped - ports: - - 3004:80 - environment: - api_extended_postgre: '{"host": "invidious-db", "port": 5432, "database": "invidious", "user": "kemal", "password": "kemal"}' - api_extended_allowed_origins: '["https://materialious.example.com"]' - api_extended_debug: false - - # No trailing backslashes! - api_extended_invidious_instance: "https://invidious.example.com" - api_extended_production_instance: "https://syncious.example.com" -``` - -Add these additional environment variables to Materialious. -```yaml -VITE_DEFAULT_API_EXTENDED_INSTANCE: "https://syncious.example.com" -``` - -## Step 4 (Optional): Self-host PeerJS -[Read the official guide.](https://github.com/peers/peerjs-server?tab=readme-ov-file#docker) - -Add these additional environment variables to Materialious. -```yaml -# Will differ depending on how you self-host peerjs. -VITE_DEFAULT_PEERJS_HOST: "peerjs.example.com" -VITE_DEFAULT_PEERJS_PATH: "/" -VITE_DEFAULT_PEERJS_PORT: 443 -``` diff --git a/docs/DOCKER.md b/docs/DOCKER.md index ae04b025..e1ee4757 100644 --- a/docs/DOCKER.md +++ b/docs/DOCKER.md @@ -278,34 +278,7 @@ http: ### Step 3: Modify/add `VITE_DEFAULT_RETURNYTDISLIKES_INSTANCE` for Materialious to be the reverse proxied URL of RYD-Proxy. -## Step 5 (Optional, but recommended): Self-host Invidious API extended - -### Step 1: Docker compose -Add the following to your docker compose - -```yaml -services: - api_extended: - image: wardpearce/invidious_api_extended:latest - restart: unless-stopped - ports: - - 3004:80 - environment: - api_extended_postgre: '{"host": "invidious-db", "port": 5432, "database": "invidious", "user": "kemal", "password": "kemal"}' - api_extended_allowed_origins: '["https://materialious.example.com"]' - api_extended_debug: false - - # No trailing backslashes! - api_extended_invidious_instance: "https://invidious.example.com" - api_extended_production_instance: "https://syncious.example.com" -``` - -Add these additional environment variables to Materialious. -```yaml -VITE_DEFAULT_API_EXTENDED_INSTANCE: "https://syncious.example.com" -``` - -## Step 6 (Optional): Self-host PeerJS +## Step 5 (Optional): Self-host PeerJS [Read the official guide.](https://github.com/peers/peerjs-server?tab=readme-ov-file#docker) Add these additional environment variables to Materialious. diff --git a/materialious/Dockerfile b/materialious/Dockerfile index 35595a05..198e5109 100644 --- a/materialious/Dockerfile +++ b/materialious/Dockerfile @@ -20,10 +20,6 @@ RUN echo "VITE_DEFAULT_INVIDIOUS_INSTANCE=VITE_DEFAULT_INVIDIOUS_INSTANCE_PLACEH echo "VITE_DEFAULT_PEERJS_HOST=VITE_DEFAULT_PEERJS_HOST_PLACEHOLDER" >> .env && \ echo "VITE_DEFAULT_PEERJS_PATH=VITE_DEFAULT_PEERJS_PATH_PLACEHOLDER" >> .env && \ echo "VITE_DEFAULT_PEERJS_PORT=VITE_DEFAULT_PEERJS_PORT_PLACEHOLDER" >> .env && \ - echo "VITE_DEFAULT_DOWNLOAD_ENABLED=VITE_DEFAULT_DOWNLOAD_ENABLED_PLACEHOLDER" >> .env && \ - echo "VITE_DEFAULT_SYNCIOUS_INSTANCE=VITE_DEFAULT_SYNCIOUS_INSTANCE_PLACEHOLDER" >> .env && \ - echo "VITE_DEFAULT_API_EXTENDED_INSTANCE=VITE_DEFAULT_API_EXTENDED_INSTANCE_PLACEHOLDER" >> .env && \ - echo "VITE_DEFAULT_DASH_BITRATE=VITE_DEFAULT_DASH_BITRATE_PLACEHOLDER" >> .env && \ echo "VITE_DEFAULT_SETTINGS='\"VITE_DEFAULT_SETTINGS_PLACEHOLDER\"'" >> .env && \ echo "VITE_DEFAULT_RETURNYTDISLIKES_INSTANCE=VITE_DEFAULT_RETURNYTDISLIKES_INSTANCE_PLACEHOLDER" >> .env diff --git a/materialious/replace_env_vars.sh b/materialious/replace_env_vars.sh index 18f71f88..a2fcbbe3 100644 --- a/materialious/replace_env_vars.sh +++ b/materialious/replace_env_vars.sh @@ -11,8 +11,4 @@ find "$ROOT_DIR" -type f \( -name "*.js" -o -name "*.html" \) -exec sed -i 's|VI find "$ROOT_DIR" -type f \( -name "*.js" -o -name "*.html" \) -exec sed -i 's|VITE_DEFAULT_PEERJS_HOST_PLACEHOLDER|'"$VITE_DEFAULT_PEERJS_HOST"'|g' {} + find "$ROOT_DIR" -type f \( -name "*.js" -o -name "*.html" \) -exec sed -i 's|VITE_DEFAULT_PEERJS_PATH_PLACEHOLDER|'"$VITE_DEFAULT_PEERJS_PATH"'|g' {} + find "$ROOT_DIR" -type f \( -name "*.js" -o -name "*.html" \) -exec sed -i 's|VITE_DEFAULT_PEERJS_PORT_PLACEHOLDER|'"$VITE_DEFAULT_PEERJS_PORT"'|g' {} + -find "$ROOT_DIR" -type f \( -name "*.js" -o -name "*.html" \) -exec sed -i 's|VITE_DEFAULT_DOWNLOAD_ENABLED_PLACEHOLDER|'"$VITE_DEFAULT_DOWNLOAD_ENABLED"'|g' {} + -find "$ROOT_DIR" -type f \( -name "*.js" -o -name "*.html" \) -exec sed -i 's|VITE_DEFAULT_SYNCIOUS_INSTANCE_PLACEHOLDER|'"$VITE_DEFAULT_SYNCIOUS_INSTANCE"'|g' {} + -find "$ROOT_DIR" -type f \( -name "*.js" -o -name "*.html" \) -exec sed -i 's|VITE_DEFAULT_DASH_BITRATE_PLACEHOLDER|'"$VITE_DEFAULT_DASH_BITRATE"'|g' {} + -find "$ROOT_DIR" -type f \( -name "*.js" -o -name "*.html" \) -exec sed -i 's|VITE_DEFAULT_API_EXTENDED_INSTANCE_PLACEHOLDER|'"$VITE_DEFAULT_API_EXTENDED_INSTANCE"'|g' {} + find "$ROOT_DIR" -type f \( -name "*.js" -o -name "*.html" \) -exec sed -i 's|VITE_DEFAULT_SETTINGS_PLACEHOLDER|'"$VITE_DEFAULT_SETTINGS"'|g' {} + diff --git a/materialious/src/lib/api/apiExtended.ts b/materialious/src/lib/api/apiExtended.ts index 77d73063..5d0e1035 100644 --- a/materialious/src/lib/api/apiExtended.ts +++ b/materialious/src/lib/api/apiExtended.ts @@ -1,53 +1,50 @@ -import type { ApiExntendedProgressModel } from './model'; -import { getVideoProgress } from '.'; +// const videoIds: string[] = []; +// const pendingResolves = new Map void>(); -const videoIds: string[] = []; -const pendingResolves = new Map void>(); +// let timeout: ReturnType | null = null; +// const DEBOUNCE_MS = 1000; +// const BATCH_SIZE = 100; -let timeout: ReturnType | null = null; -const DEBOUNCE_MS = 1000; -const BATCH_SIZE = 100; +// async function processBatches(): Promise { +// const batches: string[][] = []; -async function processBatches(): Promise { - const batches: string[][] = []; +// while (videoIds.length > 0) { +// batches.push(videoIds.splice(0, BATCH_SIZE)); +// } - while (videoIds.length > 0) { - batches.push(videoIds.splice(0, BATCH_SIZE)); - } +// const results: ApiExntendedProgressModel[] = []; - const results: ApiExntendedProgressModel[] = []; +// for (const batch of batches) { +// const res: ApiExntendedProgressModel[] = await getVideoProgress(batch.join(',')); +// results.push(...res); - for (const batch of batches) { - const res: ApiExntendedProgressModel[] = await getVideoProgress(batch.join(',')); - results.push(...res); +// // Resolve pending promises for this batch +// for (const videoId of batch) { +// const match = res.find((item) => item.video_id === videoId); +// const resolve = pendingResolves.get(videoId); +// if (resolve) { +// resolve(match); +// pendingResolves.delete(videoId); +// } +// } +// } +// } - // Resolve pending promises for this batch - for (const videoId of batch) { - const match = res.find((item) => item.video_id === videoId); - const resolve = pendingResolves.get(videoId); - if (resolve) { - resolve(match); - pendingResolves.delete(videoId); - } - } - } -} +// export function queueGetWatchProgress( +// videoId: string +// ): Promise { +// videoIds.push(videoId); -export function queueGetWatchProgress( - videoId: string -): Promise { - videoIds.push(videoId); +// const promise = new Promise((resolve) => { +// pendingResolves.set(videoId, resolve); +// }); - const promise = new Promise((resolve) => { - pendingResolves.set(videoId, resolve); - }); +// if (timeout) clearTimeout(timeout); +// timeout = setTimeout(() => { +// processBatches().catch((e) => { +// console.error('Failed to process batches:', e); +// }); +// }, DEBOUNCE_MS); - if (timeout) clearTimeout(timeout); - timeout = setTimeout(() => { - processBatches().catch((e) => { - console.error('Failed to process batches:', e); - }); - }, DEBOUNCE_MS); - - return promise; -} +// return promise; +// } diff --git a/materialious/src/lib/api/index.ts b/materialious/src/lib/api/index.ts index 928d0d9a..3b567109 100644 --- a/materialious/src/lib/api/index.ts +++ b/materialious/src/lib/api/index.ts @@ -9,8 +9,7 @@ import { playerYouTubeJsAlways, playerYouTubeJsFallback, rawMasterKeyStore, - returnYTDislikesInstanceStore, - synciousInstanceStore + returnYTDislikesInstanceStore } from '../store'; import type { ChannelPage, @@ -597,62 +596,3 @@ export async function getThumbnail( ); return URL.createObjectURL(await resp.blob()); } - -function buildApiExtendedAuthHeaders(): Record> { - const authToken = get(invidiousAuthStore)?.token ?? ''; - return { headers: { Authorization: `Bearer ${authToken.replace('SID=', '')}` } }; -} - -export async function getVideoProgress( - videoId: string, - fetchOptions: RequestInit = {} -): Promise { - const resp = await fetchErrorHandle( - await fetch(`${get(synciousInstanceStore)}/video/${encodeURIComponent(videoId)}`, { - ...buildApiExtendedAuthHeaders(), - ...fetchOptions - }) - ); - - return resp.json(); -} - -export async function saveVideoProgress( - videoId: string, - time: number, - fetchOptions: RequestInit = {} -) { - const headers: Record> = buildApiExtendedAuthHeaders(); - headers['headers']['Content-type'] = 'application/json'; - - await fetchErrorHandle( - await fetch(`${get(synciousInstanceStore)}/video/${encodeURIComponent(videoId)}`, { - ...headers, - method: 'POST', - body: JSON.stringify({ - time: time - }), - ...fetchOptions - }) - ); -} - -export async function deleteVideoProgress(videoId: string, fetchOptions: RequestInit = {}) { - await fetchErrorHandle( - await fetch(`${get(synciousInstanceStore)}/video/${videoId}`, { - method: 'DELETE', - ...buildApiExtendedAuthHeaders(), - ...fetchOptions - }) - ); -} - -export async function deleteAllVideoProgress(fetchOptions: RequestInit = {}) { - await fetchErrorHandle( - await fetch(`${get(synciousInstanceStore)}/videos`, { - method: 'DELETE', - ...buildApiExtendedAuthHeaders(), - ...fetchOptions - }) - ); -} diff --git a/materialious/src/lib/api/model.ts b/materialious/src/lib/api/model.ts index 793e795c..5523be05 100644 --- a/materialious/src/lib/api/model.ts +++ b/materialious/src/lib/api/model.ts @@ -302,15 +302,6 @@ export interface DeArrow { videoDuration: number; } -export interface ApiExntendedProgressModel { - time: number; - video_id: string; -} - -export interface SynciousSaveProgressModel { - time: number; -} - export type SearchResults = (Channel | Video | Playlist | HashTag)[] & { getContinuation?: () => Promise; }; diff --git a/materialious/src/lib/components/player/Player.svelte b/materialious/src/lib/components/player/Player.svelte index 4285041e..2493a33f 100644 --- a/materialious/src/lib/components/player/Player.svelte +++ b/materialious/src/lib/components/player/Player.svelte @@ -13,7 +13,6 @@ import { _ } from '$lib/i18n'; import { get } from 'svelte/store'; import { Slider } from 'melt/builders'; - import { deleteVideoProgress, getVideoProgress, saveVideoProgress } from '$lib/api'; import type { VideoPlay } from '$lib/api/model'; import { invidiousAuthStore, @@ -34,9 +33,7 @@ sponsorBlockCategoriesStore, sponsorBlockDisplayToastStore, sponsorBlockStore, - sponsorBlockUrlStore, - synciousInstanceStore, - synciousStore + sponsorBlockUrlStore } from '$lib/store'; import { setStatusBarColor } from '$lib/theme'; import { getVideoYTjs } from '$lib/api/youtubejs/video'; @@ -257,7 +254,7 @@ clearInterval(watchProgressInterval); } // Auto save watch progress every minute. - watchProgressInterval = setInterval(() => savePlayerPos(), 60000); + watchProgressInterval = setInterval(() => savePlayerbackHistory(), 60000); let dashUrl: string; @@ -284,9 +281,9 @@ !data.video.fallbackPatch ) { const manifest = await manifestDomainInclusion(dashUrl); - await player.load(manifest, await getLastPlayPos()); + await player.load(manifest, await getPlaybackHistory()); } else { - await player.load(dashUrl, await getLastPlayPos()); + await player.load(dashUrl, await getPlaybackHistory()); } if (data.content.timestamps) { @@ -675,7 +672,7 @@ playerElement?.addEventListener('pause', async () => { playerCurrentPlaybackState = false; playerIsBuffering = false; - savePlayerPos(); + savePlayerbackHistory(); showPlayerUI(); }); @@ -739,7 +736,7 @@ updateVideoPlayerHeight(); }); - async function getLastPlayPos(): Promise { + async function getPlaybackHistory(): Promise { if (loadTimeFromUrl($page) || !$playerSavePlaybackPositionStore) return 0; let toSetTime = 0; @@ -753,46 +750,23 @@ // Continue regardless of error } - if ($synciousStore && $synciousInstanceStore && $invidiousAuthStore) { - try { - toSetTime = (await getVideoProgress(data.video.videoId))[0].time; - } catch { - // Continue regardless of error - } - } - return toSetTime; } - function savePlayerPos() { - if (data.video.liveNow) return; + function savePlayerbackHistory() { + if (data.video.liveNow || !$playerSavePlaybackPositionStore || !playerElement) return; - const synciousEnabled = $synciousStore && $synciousInstanceStore && $invidiousAuthStore; - - if ($playerSavePlaybackPositionStore && playerElement) { - if ( - playerElement.currentTime < playerElement.duration - 10 && - playerElement.currentTime > 10 - ) { - try { - localStorage.setItem(`v_${data.video.videoId}`, playerElement.currentTime.toString()); - } catch { - // Continue regardless of error - } - - if (synciousEnabled) { - saveVideoProgress(data.video.videoId, playerElement.currentTime); - } - } else { - try { - localStorage.removeItem(`v_${data.video.videoId}`); - } catch { - // Continue regardless of error - } - - if (synciousEnabled) { - deleteVideoProgress(data.video.videoId); - } + if (playerElement.currentTime < playerElement.duration - 10 && playerElement.currentTime > 10) { + try { + localStorage.setItem(`v_${data.video.videoId}`, playerElement.currentTime.toString()); + } catch { + // Continue regardless of error + } + } else { + try { + localStorage.removeItem(`v_${data.video.videoId}`); + } catch { + // Continue regardless of error } } } @@ -814,7 +788,7 @@ } try { - savePlayerPos(); + savePlayerbackHistory(); } catch { // Continue regardless of error } diff --git a/materialious/src/lib/components/settings/ApiExtended.svelte b/materialious/src/lib/components/settings/ApiExtended.svelte deleted file mode 100644 index 903f1c44..00000000 --- a/materialious/src/lib/components/settings/ApiExtended.svelte +++ /dev/null @@ -1,42 +0,0 @@ - - -
- synciousInstanceStore.set(ensureNoTrailingSlash(synciousInstance)) - )} -> - -
- - diff --git a/materialious/src/lib/components/settings/Settings.svelte b/materialious/src/lib/components/settings/Settings.svelte index 3d645904..e8038828 100644 --- a/materialious/src/lib/components/settings/Settings.svelte +++ b/materialious/src/lib/components/settings/Settings.svelte @@ -1,7 +1,6 @@