From a795f707d1e993510bcb84d7c703df84bfbc681b Mon Sep 17 00:00:00 2001 From: swartie800 <146176789+swartie800@users.noreply.github.com> Date: Tue, 3 Oct 2023 07:19:54 +0700 Subject: [PATCH] Update index.ts --- src/index.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/index.ts b/src/index.ts index 562df68..4cd95f6 100644 --- a/src/index.ts +++ b/src/index.ts @@ -9,7 +9,7 @@ async function respondfetch(request) { const targetUrl = decodeURIComponent(url.searchParams.get("url") || ""); const originUrl = decodeURIComponent(url.searchParams.get("origin") || ""); const proxyAll = decodeURIComponent(url.searchParams.get("all") || ""); - + if (!targetUrl) { return new Response("Invalid URL", { status: 400 }); } @@ -33,14 +33,14 @@ async function respondfetch(request) { const encodedUrl = encodeURIComponent(refererUrl); const encodedOrigin = encodeURIComponent(originUrl); modifiedM3u8 = modifiedM3u8.split("\n").map((line) => { - if (line.startsWith("#") || line.trim() == '') { + if (line.startsWith("#") || line.trim() == "") { return line; - } - else if(proxyAll == 'yes' && line.startsWith('http')){ //https://yourproxy.com/?url=https://somevideo.m3u8&all=yes + } else if (proxyAll == 'yes' && line.startsWith('http')) { + // https://yourproxy.com/?url=https://somevideo.m3u8&all=yes return `${url.origin}?url=${line}`; } return `?url=${targetUrlTrimmed}${line}${originUrl ? `&origin=${encodedOrigin}` : "" - }${refererUrl ? `&referer=${encodedUrl}` : "" + }${refererUrl ? `&referer=${encodedUrl}` : "" }`; }).join("\n"); } @@ -53,6 +53,7 @@ async function respondfetch(request) { "Content-Type": response.headers?.get("Content-Type") || "application/vnd.apple.mpegurl", + "Content-Disposition": `attachment; filename="output.m3u8"`, // Set the desired filename }, }); } catch (e) {