From bf4675a5e37fd2084482068eb60974e39d7d7023 Mon Sep 17 00:00:00 2001 From: jj Date: Mon, 16 Dec 2024 11:29:13 +0000 Subject: [PATCH] api/stream: move bsky override into isHlsResponse --- api/src/stream/internal-hls.js | 7 +++++-- api/src/stream/internal.js | 5 +---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/api/src/stream/internal-hls.js b/api/src/stream/internal-hls.js index 55634c71..61f3d361 100644 --- a/api/src/stream/internal-hls.js +++ b/api/src/stream/internal-hls.js @@ -55,8 +55,11 @@ function transformMediaPlaylist(streamInfo, hlsPlaylist) { const HLS_MIME_TYPES = ["application/vnd.apple.mpegurl", "audio/mpegurl", "application/x-mpegURL"]; -export function isHlsResponse (req) { - return HLS_MIME_TYPES.includes(req.headers['content-type']); +export function isHlsResponse(req, streamInfo) { + return HLS_MIME_TYPES.includes(req.headers['content-type']) + // bluesky's cdn responds with wrong content-type for the hls playlist, + // so we enforce it here until they fix it + || (streamInfo.service === 'bsky' && streamInfo.url.endsWith('.m3u8')); } export async function handleHlsPlaylist(streamInfo, req, res) { diff --git a/api/src/stream/internal.js b/api/src/stream/internal.js index 7d8bf4c9..c32a3692 100644 --- a/api/src/stream/internal.js +++ b/api/src/stream/internal.js @@ -96,10 +96,7 @@ async function handleGenericStream(streamInfo, res) { res.status(fileResponse.statusCode); fileResponse.body.on('error', () => {}); - // bluesky's cdn responds with wrong content-type for the hls playlist, - // so we enforce it here until they fix it - const isHls = isHlsResponse(fileResponse) - || (streamInfo.service === "bsky" && streamInfo.url.endsWith('.m3u8')); + const isHls = isHlsResponse(fileResponse, streamInfo); for (const [ name, value ] of Object.entries(fileResponse.headers)) { if (!isHls || name.toLowerCase() !== 'content-length') {