Auto-proxy emit sound URLs using radio proxy rules

This commit is contained in:
Jage9
2026-02-22 03:06:31 -05:00
parent f56d89e22e
commit 45039194e1
3 changed files with 15 additions and 5 deletions

View File

@@ -1,5 +1,5 @@
// Maintainer-controlled web client version. // Maintainer-controlled web client version.
// Format: YYYY.MM.DD Rn (example: 2026.02.20 R2) // 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. // Optional display timezone for timestamps. Falls back to America/Detroit if unset/invalid.
window.CHGRID_TIME_ZONE = "America/Detroit"; window.CHGRID_TIME_ZONE = "America/Detroit";

View File

@@ -114,7 +114,7 @@ function isDropboxHost(hostname: string): boolean {
return host.endsWith('dropbox.com') || host.endsWith('dropboxusercontent.com'); return host.endsWith('dropbox.com') || host.endsWith('dropboxusercontent.com');
} }
function shouldProxyStreamUrl(streamUrl: string): boolean { export function shouldProxyStreamUrl(streamUrl: string): boolean {
try { try {
const parsed = new URL(streamUrl); const parsed = new URL(streamUrl);
if ( if (
@@ -131,7 +131,7 @@ function shouldProxyStreamUrl(streamUrl: string): boolean {
return false; 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 normalizedBase = APP_BASE_PATH.endsWith('/') ? APP_BASE_PATH : `${APP_BASE_PATH}/`;
const proxy = new URL(`${normalizedBase}media_proxy.php`, window.location.origin); const proxy = new URL(`${normalizedBase}media_proxy.php`, window.location.origin);
proxy.searchParams.set('url', streamUrl); proxy.searchParams.set('url', streamUrl);

View File

@@ -6,7 +6,14 @@ import {
clampEffectLevel, clampEffectLevel,
type EffectId, type EffectId,
} from './audio/effects'; } 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 { ItemEmitRuntime } from './audio/itemEmitRuntime';
import { normalizeDegrees } from './audio/spatial'; import { normalizeDegrees } from './audio/spatial';
import { import {
@@ -466,7 +473,10 @@ function classifySystemMessageSound(message: string): keyof typeof SYSTEM_SOUND_
function resolveIncomingSoundUrl(url: string): string { function resolveIncomingSoundUrl(url: string): string {
const raw = String(url || '').trim(); const raw = String(url || '').trim();
if (!raw) return ''; 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/')) { if (raw.startsWith('/sounds/')) {
return withBase(raw.slice(1)); return withBase(raw.slice(1));
} }