Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
nb557 committed Nov 16, 2024
1 parent 23d31ac commit 48e7114
Show file tree
Hide file tree
Showing 4 changed files with 241 additions and 54 deletions.
46 changes: 41 additions & 5 deletions cloudflare_worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,16 @@ export default {
let ip = "";
let redirect = request.method === "POST" ? "manual" : "follow";
let get_cookie = false;
let cookie_plus = false;
let remove_zstd = false;
let params = [];
let cdn_info = "cdn_X8v8IbU8";

if (api === "headers") {
let body = "";
request.headers.forEach((value, key) => body += key + " = " + value + "\n");
body += "request_url" + " = " + request.url + "\n";
body += "worker_version = 1.07\n";
body += "worker_version = 1.08\n";
return new Response(body, corsHeaders);
}

Expand Down Expand Up @@ -62,6 +64,11 @@ export default {
get_cookie = true;
api_pos += 11;
api = api.substring(11);
} else if (api.startsWith("cookie_plus/")) {
cookie_plus = true;
remove_zstd = true;
api_pos += 12;
api = api.substring(12);
} else if (api.startsWith("param?") || api.startsWith("param/")) {
api_pos += 6;
api = api.substring(6);
Expand Down Expand Up @@ -91,7 +98,7 @@ export default {

let forwarded_proto = request.headers.get("X-Forwarded-Proto");
if (forwarded_proto) forwarded_proto = forwarded_proto.split(",")[0].trim();
if (forwarded_proto === "https") proxy = proxy.replace('http://', 'https://');
if (forwarded_proto === "https") proxy = proxy.replace("http://", "https://");

if (!ip) {
let forwarded_for = request.headers.get("X-Forwarded-For");
Expand Down Expand Up @@ -156,18 +163,25 @@ export default {
request.headers.set("cf-connecting-ip", ip);
}
if (apiUrl.hostname === "rezka.ag" || apiUrl.hostname === "hdrezka.ag" || apiUrl.hostname === "hdrezka.me" || apiUrl.hostname === "hdrezka.sh" || apiUrl.hostname === "hdrezka.cm" || apiUrl.hostname === "hdrezka.kim" || apiUrl.hostname === "hdrezka.la" || apiUrl.hostname === "rezka.pub" || apiUrl.hostname === "kinopub.me") {
request.headers.set("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36");
request.headers.set("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36");
}
if (apiUrl.hostname.endsWith(".svetacdn.in")) {
request.headers.set("Origin", "https://videocdn.tv");
request.headers.set("Referer", "https://videocdn.tv/");
}
if (apiUrl.hostname === "api.lumex.pw") {
request.headers.set("Origin", "https://p.lumex.pw");
request.headers.set("Referer", "https://p.lumex.pw/");
request.headers.set("Sec-Fetch-Dest", "empty");
request.headers.set("Sec-Fetch-Mode", "cors");
request.headers.set("Sec-Fetch-Site", "same-site");
}
if (apiUrl.hostname.endsWith("cdnmovies-stream.online") || apiUrl.hostname.endsWith("cdnmovies-hls-stream.online") || apiUrl.hostname.endsWith(".sarnage.cc")) {
request.headers.set("Origin", "https://cdnmovies.net");
request.headers.set("Referer", "https://cdnmovies.net/");
}
if (apiUrl.hostname.endsWith(".bazon.site")) {
request.headers.set("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36");
request.headers.set("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36");
request.headers.set("Origin", "https://bazon.cc");
request.headers.set("Referer", "https://bazon.cc/");
}
Expand All @@ -178,6 +192,13 @@ export default {
if (apiUrl.hostname === "kinoplay.site" || apiUrl.hostname === "kinoplay1.site" || apiUrl.hostname === "kinoplay2.site") {
request.headers.set("Cookie", "invite=a246a3f46c82fe439a45c3dbbbb24ad5");
}
if (remove_zstd) {
let encoding = (request.headers.get("Accept-Encoding") || "");
if (encoding.includes("zstd")) {
encoding = encoding.split(",").filter(enc=>!enc.includes("zstd")).join(",") || "identity";
request.headers.set("Accept-Encoding", encoding);
}
}
params.forEach(param => {
if (param[0]) {
if (param[1]) {
Expand All @@ -201,9 +222,24 @@ export default {
response.headers.append("Vary", "Origin");

if (response.status >= 200 && response.status < 300) {
if (get_cookie) {
let ctype = (response.headers.get("Content-Type") || "").split(";")[0].toLowerCase();
if (get_cookie || cookie_plus) {
let json = {};
json.cookie = response.headers.getSetCookie();
if (cookie_plus) {
let headers = {};
for (let key of response.headers.keys()) {
if (key === 'set-cookie') {
headers[key] = json.cookie;
} else {
headers[key] = response.headers.get(key);
}
}
json.headers = headers;
if (ctype.startsWith("text/") || ["application/json", "application/xml", "application/x-mpegurl", "application/vnd.apple.mpegurl", "application/dash+xml"].indexOf(ctype) !== -1) {
json.body = await response.text();
}
}
return new Response(JSON.stringify(json), {
headers: {
"Access-Control-Allow-Origin": "*",
Expand Down
48 changes: 42 additions & 6 deletions deno_apn.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ async function handle(request, connInfo) {
let ip = "no";
let redirect = request.method === "POST" ? "manual" : "follow";
let get_cookie = false;
let cookie_plus = false;
let remove_zstd = false;
let params = [];
let cdn_info = "cdn_c8Bc9aMo";

Expand All @@ -27,7 +29,7 @@ async function handle(request, connInfo) {
body += "connInfo" + " = " + JSON.stringify(connInfo.remoteAddr) + "\n";
}
body += "request_url" + " = " + request.url + "\n";
body += "apn_version = 1.07\n";
body += "apn_version = 1.08\n";
return new Response(body, corsHeaders);
}

Expand Down Expand Up @@ -64,6 +66,11 @@ async function handle(request, connInfo) {
get_cookie = true;
api_pos += 11;
api = api.substring(11);
} else if (api.startsWith("cookie_plus/")) {
cookie_plus = true;
remove_zstd = true;
api_pos += 12;
api = api.substring(12);
} else if (api.startsWith("param?") || api.startsWith("param/")) {
api_pos += 6;
api = api.substring(6);
Expand Down Expand Up @@ -93,7 +100,7 @@ async function handle(request, connInfo) {

let forwarded_proto = request.headers.get("X-Forwarded-Proto");
if (forwarded_proto) forwarded_proto = forwarded_proto.split(",")[0].trim();
if (forwarded_proto === "https") proxy = proxy.replace('http://', 'https://');
if (forwarded_proto === "https") proxy = proxy.replace("http://", "https://");

if (!ip) {
let forwarded_for = request.headers.get("X-Forwarded-For");
Expand Down Expand Up @@ -159,18 +166,25 @@ async function handle(request, connInfo) {
request.headers.set("cf-connecting-ip", ip);
}
if (apiUrl.hostname === "rezka.ag" || apiUrl.hostname === "hdrezka.ag" || apiUrl.hostname === "hdrezka.me" || apiUrl.hostname === "hdrezka.sh" || apiUrl.hostname === "hdrezka.cm" || apiUrl.hostname === "hdrezka.kim" || apiUrl.hostname === "hdrezka.la" || apiUrl.hostname === "rezka.pub" || apiUrl.hostname === "kinopub.me") {
request.headers.set("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36");
request.headers.set("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36");
}
if (apiUrl.hostname.endsWith(".svetacdn.in")) {
request.headers.set("Origin", "https://videocdn.tv");
request.headers.set("Referer", "https://videocdn.tv/");
}
if (apiUrl.hostname === "api.lumex.pw") {
request.headers.set("Origin", "https://p.lumex.pw");
request.headers.set("Referer", "https://p.lumex.pw/");
request.headers.set("Sec-Fetch-Dest", "empty");
request.headers.set("Sec-Fetch-Mode", "cors");
request.headers.set("Sec-Fetch-Site", "same-site");
}
if (apiUrl.hostname.endsWith("cdnmovies-stream.online") || apiUrl.hostname.endsWith("cdnmovies-hls-stream.online") || apiUrl.hostname.endsWith(".sarnage.cc")) {
request.headers.set("Origin", "https://cdnmovies.net");
request.headers.set("Referer", "https://cdnmovies.net/");
}
if (apiUrl.hostname.endsWith(".bazon.site")) {
request.headers.set("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36");
request.headers.set("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36");
request.headers.set("Origin", "https://bazon.cc");
request.headers.set("Referer", "https://bazon.cc/");
}
Expand All @@ -183,6 +197,14 @@ async function handle(request, connInfo) {
}
if (apiUrl.pathname.endsWith(".m3u8") || apiUrl.pathname.endsWith(".m3u") || apiUrl.pathname.endsWith(".M3U8") || apiUrl.pathname.endsWith(".M3U") || apiUrl.pathname.endsWith(".mpd") || apiUrl.pathname.endsWith(".MPD")) {
request.headers.delete("Range");
remove_zstd = true;
}
if (remove_zstd) {
let encoding = (request.headers.get("Accept-Encoding") || "");
if (encoding.includes("zstd")) {
encoding = encoding.split(",").filter(enc=>!enc.includes("zstd")).join(",") || "identity";
request.headers.set("Accept-Encoding", encoding);
}
}
params.forEach(param => {
if (param[0]) {
Expand All @@ -207,9 +229,24 @@ async function handle(request, connInfo) {
response.headers.append("Vary", "Origin");

if (response.status >= 200 && response.status < 300) {
if (get_cookie) {
let ctype = (response.headers.get("Content-Type") || "").split(";")[0].toLowerCase();
if (get_cookie || cookie_plus) {
let json = {};
json.cookie = response.headers.getSetCookie();
if (cookie_plus) {
let headers = {};
for (let key of response.headers.keys()) {
if (key === 'set-cookie') {
headers[key] = json.cookie;
} else {
headers[key] = response.headers.get(key);
}
}
json.headers = headers;
if (ctype.startsWith("text/") || ["application/json", "application/xml", "application/x-mpegurl", "application/vnd.apple.mpegurl", "application/dash+xml"].indexOf(ctype) !== -1) {
json.body = await response.text();
}
}
return new Response(JSON.stringify(json), {
headers: {
"Access-Control-Allow-Origin": "*",
Expand All @@ -218,7 +255,6 @@ async function handle(request, connInfo) {
},
});
}
let ctype = (response.headers.get("Content-Type") || '').toLowerCase();
if (["application/x-mpegurl", "application/vnd.apple.mpegurl"].indexOf(ctype) !== -1) {
let body = edit_m3u8(await response.text(), proxy, apiUrl, apiBase);
response.headers.delete("Content-Length");
Expand Down
46 changes: 41 additions & 5 deletions deno_worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ async function handle(request, connInfo) {
let ip = "";
let redirect = request.method === "POST" ? "manual" : "follow";
let get_cookie = false;
let cookie_plus = false;
let remove_zstd = false;
let params = [];
let cdn_info = "cdn_pDvQc7ZT";

Expand All @@ -27,7 +29,7 @@ async function handle(request, connInfo) {
body += "connInfo" + " = " + JSON.stringify(connInfo.remoteAddr) + "\n";
}
body += "request_url" + " = " + request.url + "\n";
body += "worker_version = 1.07\n";
body += "worker_version = 1.08\n";
return new Response(body, corsHeaders);
}

Expand Down Expand Up @@ -64,6 +66,11 @@ async function handle(request, connInfo) {
get_cookie = true;
api_pos += 11;
api = api.substring(11);
} else if (api.startsWith("cookie_plus/")) {
cookie_plus = true;
remove_zstd = true;
api_pos += 12;
api = api.substring(12);
} else if (api.startsWith("param?") || api.startsWith("param/")) {
api_pos += 6;
api = api.substring(6);
Expand Down Expand Up @@ -93,7 +100,7 @@ async function handle(request, connInfo) {

let forwarded_proto = request.headers.get("X-Forwarded-Proto");
if (forwarded_proto) forwarded_proto = forwarded_proto.split(",")[0].trim();
if (forwarded_proto === "https") proxy = proxy.replace('http://', 'https://');
if (forwarded_proto === "https") proxy = proxy.replace("http://", "https://");

if (!ip) {
let forwarded_for = request.headers.get("X-Forwarded-For");
Expand Down Expand Up @@ -159,18 +166,25 @@ async function handle(request, connInfo) {
request.headers.set("cf-connecting-ip", ip);
}
if (apiUrl.hostname === "rezka.ag" || apiUrl.hostname === "hdrezka.ag" || apiUrl.hostname === "hdrezka.me" || apiUrl.hostname === "hdrezka.sh" || apiUrl.hostname === "hdrezka.cm" || apiUrl.hostname === "hdrezka.kim" || apiUrl.hostname === "hdrezka.la" || apiUrl.hostname === "rezka.pub" || apiUrl.hostname === "kinopub.me") {
request.headers.set("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36");
request.headers.set("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36");
}
if (apiUrl.hostname.endsWith(".svetacdn.in")) {
request.headers.set("Origin", "https://videocdn.tv");
request.headers.set("Referer", "https://videocdn.tv/");
}
if (apiUrl.hostname === "api.lumex.pw") {
request.headers.set("Origin", "https://p.lumex.pw");
request.headers.set("Referer", "https://p.lumex.pw/");
request.headers.set("Sec-Fetch-Dest", "empty");
request.headers.set("Sec-Fetch-Mode", "cors");
request.headers.set("Sec-Fetch-Site", "same-site");
}
if (apiUrl.hostname.endsWith("cdnmovies-stream.online") || apiUrl.hostname.endsWith("cdnmovies-hls-stream.online") || apiUrl.hostname.endsWith(".sarnage.cc")) {
request.headers.set("Origin", "https://cdnmovies.net");
request.headers.set("Referer", "https://cdnmovies.net/");
}
if (apiUrl.hostname.endsWith(".bazon.site")) {
request.headers.set("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36");
request.headers.set("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36");
request.headers.set("Origin", "https://bazon.cc");
request.headers.set("Referer", "https://bazon.cc/");
}
Expand All @@ -181,6 +195,13 @@ async function handle(request, connInfo) {
if (apiUrl.hostname === "kinoplay.site" || apiUrl.hostname === "kinoplay1.site" || apiUrl.hostname === "kinoplay2.site") {
request.headers.set("Cookie", "invite=a246a3f46c82fe439a45c3dbbbb24ad5");
}
if (remove_zstd) {
let encoding = (request.headers.get("Accept-Encoding") || "");
if (encoding.includes("zstd")) {
encoding = encoding.split(",").filter(enc=>!enc.includes("zstd")).join(",") || "identity";
request.headers.set("Accept-Encoding", encoding);
}
}
params.forEach(param => {
if (param[0]) {
if (param[1]) {
Expand All @@ -204,9 +225,24 @@ async function handle(request, connInfo) {
response.headers.append("Vary", "Origin");

if (response.status >= 200 && response.status < 300) {
if (get_cookie) {
let ctype = (response.headers.get("Content-Type") || "").split(";")[0].toLowerCase();
if (get_cookie || cookie_plus) {
let json = {};
json.cookie = response.headers.getSetCookie();
if (cookie_plus) {
let headers = {};
for (let key of response.headers.keys()) {
if (key === 'set-cookie') {
headers[key] = json.cookie;
} else {
headers[key] = response.headers.get(key);
}
}
json.headers = headers;
if (ctype.startsWith("text/") || ["application/json", "application/xml", "application/x-mpegurl", "application/vnd.apple.mpegurl", "application/dash+xml"].indexOf(ctype) !== -1) {
json.body = await response.text();
}
}
return new Response(JSON.stringify(json), {
headers: {
"Access-Control-Allow-Origin": "*",
Expand Down
Loading

0 comments on commit 48e7114

Please sign in to comment.