From 45039194e1a1d58ba2e2783f38cbe176fa06458c Mon Sep 17 00:00:00 2001 From: Jage9 Date: Sun, 22 Feb 2026 03:06:31 -0500 Subject: [PATCH] Auto-proxy emit sound URLs using radio proxy rules --- client/public/version.js | 2 +- client/src/audio/radioStationRuntime.ts | 4 ++-- client/src/main.ts | 14 ++++++++++++-- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/client/public/version.js b/client/public/version.js index 215cccd..ce9d3cb 100644 --- a/client/public/version.js +++ b/client/public/version.js @@ -1,5 +1,5 @@ // Maintainer-controlled web client version. // Format: YYYY.MM.DD Rn (example: 2026.02.20 R2) -window.CHGRID_WEB_VERSION = "2026.02.22 R140"; +window.CHGRID_WEB_VERSION = "2026.02.22 R141"; // Optional display timezone for timestamps. Falls back to America/Detroit if unset/invalid. window.CHGRID_TIME_ZONE = "America/Detroit"; diff --git a/client/src/audio/radioStationRuntime.ts b/client/src/audio/radioStationRuntime.ts index 05f3efe..80c9c5d 100644 --- a/client/src/audio/radioStationRuntime.ts +++ b/client/src/audio/radioStationRuntime.ts @@ -114,7 +114,7 @@ function isDropboxHost(hostname: string): boolean { return host.endsWith('dropbox.com') || host.endsWith('dropboxusercontent.com'); } -function shouldProxyStreamUrl(streamUrl: string): boolean { +export function shouldProxyStreamUrl(streamUrl: string): boolean { try { const parsed = new URL(streamUrl); if ( @@ -131,7 +131,7 @@ function shouldProxyStreamUrl(streamUrl: string): boolean { return false; } -function getProxyUrlForStream(streamUrl: string): string { +export function getProxyUrlForStream(streamUrl: string): string { const normalizedBase = APP_BASE_PATH.endsWith('/') ? APP_BASE_PATH : `${APP_BASE_PATH}/`; const proxy = new URL(`${normalizedBase}media_proxy.php`, window.location.origin); proxy.searchParams.set('url', streamUrl); diff --git a/client/src/main.ts b/client/src/main.ts index 34312f4..eeda521 100644 --- a/client/src/main.ts +++ b/client/src/main.ts @@ -6,7 +6,14 @@ import { clampEffectLevel, type EffectId, } from './audio/effects'; -import { RadioStationRuntime, normalizeRadioChannel, normalizeRadioEffect, normalizeRadioEffectValue } from './audio/radioStationRuntime'; +import { + RadioStationRuntime, + getProxyUrlForStream, + normalizeRadioChannel, + normalizeRadioEffect, + normalizeRadioEffectValue, + shouldProxyStreamUrl, +} from './audio/radioStationRuntime'; import { ItemEmitRuntime } from './audio/itemEmitRuntime'; import { normalizeDegrees } from './audio/spatial'; import { @@ -466,7 +473,10 @@ function classifySystemMessageSound(message: string): keyof typeof SYSTEM_SOUND_ function resolveIncomingSoundUrl(url: string): string { const raw = String(url || '').trim(); if (!raw) return ''; - if (/^(https?:|data:|blob:)/i.test(raw)) return raw; + if (/^https?:/i.test(raw)) { + return shouldProxyStreamUrl(raw) ? getProxyUrlForStream(raw) : raw; + } + if (/^(data:|blob:)/i.test(raw)) return raw; if (raw.startsWith('/sounds/')) { return withBase(raw.slice(1)); }