From e49d331ed6c2a9faace18fdf913c9f47f1513ea3 Mon Sep 17 00:00:00 2001 From: gratenes <69170374+Gratenes@users.noreply.github.com> Date: Wed, 4 Sep 2024 12:39:23 -0400 Subject: [PATCH] add more content types of m3u8 files :smile: --- src/logic/v2.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/logic/v2.ts b/src/logic/v2.ts index 1180d2a..2be5869 100644 --- a/src/logic/v2.ts +++ b/src/logic/v2.ts @@ -1,5 +1,19 @@ import {getUrl} from "../utils"; +const m3u8ContentTypes: string[] = [ + 'application/vnd.', + 'video/MP2T', + 'application/x-mpegURL', + 'application/mpegURL', + 'application/x-mpegurl', + 'application/vnd.apple.mpegurl', + 'audio/mpegurl', + 'audio/x-mpegURL', + 'video/x-mpegurl', + 'application/vnd.apple.mpegurl.audio', + 'application/vnd.apple.mpegurl.video' +]; + export const M3u8ProxyV2 = async (request: Request): Promise => { const url = new URL(request.url) @@ -48,7 +62,7 @@ export const M3u8ProxyV2 = async (request: Request): Promise const responseContentType = response.headers.get('Content-Type') let responseBody: BodyInit | null = response.body - if (responseContentType && (responseContentType.includes("application/vnd.") || responseContentType.includes("video/MP2T"))) { + if (responseContentType && m3u8ContentTypes.some(name => responseContentType.includes(name))) { const m3u8File = await response.text() const m3u8FileChunks = m3u8File.split("\n") const m3u8AdjustedChunks: string[] = []