Skip to content

Commit

Permalink
Update index.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
swartie800 authored Oct 3, 2023
1 parent fab6aef commit a795f70
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
}
Expand All @@ -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");
}
Expand All @@ -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) {
Expand Down

0 comments on commit a795f70

Please sign in to comment.