pstream is dead; long live pstream taciturnaxolotl.github.io/pstream-ng/
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

update chromecast to use new proxy

also it was using the wrong proxy before :skull:

Pas af2c2b8a e658d13e

+27 -25
+21 -24
src/components/player/display/chromecast.ts
··· 9 9 DisplayInterfaceEvents, 10 10 DisplayMeta, 11 11 } from "@/components/player/display/displayInterface"; 12 - import { conf } from "@/setup/config"; 12 + import { 13 + createM3U8ProxyUrl, 14 + createMP4ProxyUrl, 15 + isUrlAlreadyProxied, 16 + } from "@/components/player/utils/proxy"; 13 17 import { LoadableSource } from "@/stores/player/utils/qualities"; 14 18 import { processCdnLink } from "@/utils/cdn"; 15 19 import { canFullscreen, canFullscreenAnyElement } from "@/utils/detectFeatures"; ··· 113 117 114 118 let contentUrl = processCdnLink(source.url); 115 119 116 - // When casting HLS, use an enabled M3U8 proxy so the Chromecast device can fetch the manifest 120 + // Only proxy streams if they need it: 121 + // 1. Not already proxied AND 122 + // 2. Has headers (either preferredHeaders or headers) 123 + const allHeaders = { 124 + ...source.preferredHeaders, 125 + ...source.headers, 126 + }; 127 + const hasHeaders = Object.keys(allHeaders).length > 0; 128 + 129 + // Handle HLS streams 117 130 if (source.type === "hls") { 118 - try { 119 - const all = conf().M3U8_PROXY_URLS; 120 - let enabledMap: Record<string, boolean> = {}; 121 - const enabledRaw = localStorage.getItem("m3u8-proxy-enabled"); 122 - if (enabledRaw) { 123 - try { 124 - enabledMap = JSON.parse(enabledRaw) as Record<string, boolean>; 125 - } catch { 126 - enabledMap = {}; 127 - } 128 - } 129 - const enabled = all.filter( 130 - (_url, idx) => enabledMap[idx.toString()] !== false, 131 - ); 132 - const list = enabled.length > 0 ? enabled : all; 133 - if (list.length > 0) { 134 - const base = list[Math.floor(Math.random() * list.length)]; 135 - const trimmed = base.endsWith("/") ? base.slice(0, -1) : base; 136 - contentUrl = `${trimmed}/?destination=${encodeURIComponent(contentUrl)}`; 137 - } 138 - } catch { 139 - // If anything goes wrong, fall back to direct URL 131 + if (!isUrlAlreadyProxied(source.url) && hasHeaders) { 132 + contentUrl = createM3U8ProxyUrl(source.url, allHeaders); 140 133 } 134 + } 135 + // Handle MP4 streams with headers 136 + else if (source.type === "mp4" && hasHeaders) { 137 + contentUrl = createMP4ProxyUrl(source.url, source.headers || {}); 141 138 } 142 139 143 140 const mediaInfo = new chrome.cast.media.MediaInfo(contentUrl, type);
+6 -1
src/components/player/utils/proxy.ts
··· 47 47 * @returns True if the URL is already proxied, false otherwise 48 48 */ 49 49 export function isUrlAlreadyProxied(url: string): boolean { 50 - // Check if URL contains the m3u8-proxy pattern 50 + // Check if URL contains the m3u8-proxy pattern (Airplay format) 51 51 if (url.includes("/m3u8-proxy?url=")) { 52 + return true; 53 + } 54 + 55 + // Check if URL contains the destination pattern (Chromecast format) 56 + if (url.includes("/?destination=")) { 52 57 return true; 53 58 } 54 59