stnh70 commited on
Commit
a2f8239
·
verified ·
1 Parent(s): ef22198

Update deno.ts

Browse files
Files changed (1) hide show
  1. deno.ts +3 -97
deno.ts CHANGED
@@ -18,14 +18,14 @@ async function handle(request, connInfo) {
18
  let proxy = "";
19
  let proxy_enc = "";
20
  let enc = "";
21
- let ip = "no";
22
  let redirect = request.method === "POST" ? "manual" : "follow";
23
  let get_cookie = false;
24
  let cookie_plus = false;
25
  let get_redirect = false;
26
  let remove_compression = false;
27
  let params = [];
28
- let cdn_info = "cdn_c8Bc9aMo";
29
  let 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";
30
 
31
  if (api === "headers") {
@@ -35,7 +35,7 @@ async function handle(request, connInfo) {
35
  body += "connInfo" + " = " + JSON.stringify(connInfo.remoteAddr) + "\n";
36
  }
37
  body += "request_url" + " = " + request.url + "\n";
38
- body += "apn_version = 1.12\n";
39
  return new Response(body, corsHeaders);
40
  }
41
 
@@ -153,22 +153,6 @@ async function handle(request, connInfo) {
153
  const apiUrl = new URL(api);
154
  let apiBase = apiUrl.href.substring(0, apiUrl.href.lastIndexOf("/") + 1);
155
 
156
- let clientUserAgent = request.headers.get("User-Agent") || '';
157
- let clientOrigin = request.headers.get("Origin") || '';
158
- if(
159
- (/\blampishe\b|\bprisma_client\b/).test(clientUserAgent) ||
160
- clientOrigin.endsWith("lampishe.cc") ||
161
- clientOrigin.endsWith("prisma.ws") ||
162
- clientOrigin.endsWith("bylampa.online")
163
- ) {
164
- let error = "Malformed URL";
165
- return new Response(error + ": " + api, {
166
- ...corsHeaders,
167
- status: 404,
168
- statusText: error,
169
- });
170
- }
171
-
172
  // Rewrite request to point to API URL. This also makes the request mutable
173
  // so you can add the correct Origin header to make the API server think
174
  // that this request is not cross-site.
@@ -244,10 +228,6 @@ async function handle(request, connInfo) {
244
  if (apiUrl.hostname === "kinoplay.site" || apiUrl.hostname === "kinoplay1.site" || apiUrl.hostname === "kinoplay2.site") {
245
  request.headers.set("Cookie", "invite=a246a3f46c82fe439a45c3dbbbb24ad5");
246
  }
247
- 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")) {
248
- request.headers.delete("Range");
249
- remove_compression = true;
250
- }
251
  if (remove_compression) {
252
  let encoding = (request.headers.get("Accept-Encoding") || "");
253
  if (encoding.includes("zstd") || encoding.includes("deflate")) {
@@ -315,20 +295,6 @@ async function handle(request, connInfo) {
315
  },
316
  });
317
  }
318
- if (["application/x-mpegurl", "application/vnd.apple.mpegurl"].indexOf(ctype) !== -1) {
319
- let body = edit_m3u8(await response.text(), apiUrl, apiBase, proxy, proxy_enc, enc);
320
- response.headers.delete("Content-Length");
321
- response.headers.delete("Content-Range");
322
- response.headers.set("Accept-Ranges", "none");
323
- return new Response(body, response);
324
- }
325
- if (["application/dash+xml"].indexOf(ctype) !== -1) {
326
- let body = edit_mpd(await response.text(), apiUrl, apiBase, proxy, proxy_enc, enc);
327
- response.headers.delete("Content-Length");
328
- response.headers.delete("Content-Range");
329
- response.headers.set("Accept-Ranges", "none");
330
- return new Response(body, response);
331
- }
332
  }
333
 
334
  // Fix redirect URL
@@ -384,66 +350,6 @@ async function handle(request, connInfo) {
384
  return link;
385
  }
386
 
387
- function edit_m3u8(m3u8, url, base, proxy, proxy_enc, enc) {
388
- try {
389
- return m3u8.split("\n").map(org_line => {
390
- let line = org_line.trim();
391
- if (line.charAt(0) === "#") {
392
- return org_line.replace(/\bURI="([^"]*)"/g, (str, link) => {
393
- link = link.trim();
394
- if (link) {
395
- return 'URI="' + proxyLink(fixLink(link, url, base), proxy, proxy_enc, enc) + '"';
396
- }
397
- return str;
398
- });
399
- } else if(line) {
400
- return proxyLink(fixLink(line, url, base), proxy, proxy_enc, enc);
401
- }
402
- return org_line;
403
- }).join("\n");
404
- } catch (err) {
405
- return m3u8;
406
- }
407
- }
408
-
409
- function unescapeXml(str) {
410
- return str.replace(/<|>|&|'|"/g, function (c) {
411
- switch (c) {
412
- case "&lt;": return "<";
413
- case "&gt;": return ">";
414
- case "&amp;": return "&";
415
- case "&apos;": return "'";
416
- case "&quot;": return '"';
417
- }
418
- });
419
- }
420
-
421
- function escapeXml(str) {
422
- return str.replace(/[<>&'"]/g, function (c) {
423
- switch (c) {
424
- case "<": return "&lt;";
425
- case ">": return "&gt;";
426
- case "&": return "&amp;";
427
- case "'": return "&apos;";
428
- case '"': return "&quot;";
429
- }
430
- });
431
- }
432
-
433
- function edit_mpd(mpd, url, base, proxy, proxy_enc, enc) {
434
- try {
435
- return mpd.replace(/<BaseURL>([^<]*)/g, (str, link) => {
436
- link = link.trim();
437
- if (link) {
438
- return "<BaseURL>" + escapeXml(proxyLink(fixLink(unescapeXml(link), url, base), proxy, proxy_enc, (enc === "enc2" ? "enc1" : enc)));
439
- }
440
- return str;
441
- });
442
- } catch (err) {
443
- return mpd;
444
- }
445
- }
446
-
447
  async function handleOptions(request, connInfo) {
448
  if (
449
  request.headers.get("Origin") !== null &&
 
18
  let proxy = "";
19
  let proxy_enc = "";
20
  let enc = "";
21
+ let ip = "";
22
  let redirect = request.method === "POST" ? "manual" : "follow";
23
  let get_cookie = false;
24
  let cookie_plus = false;
25
  let get_redirect = false;
26
  let remove_compression = false;
27
  let params = [];
28
+ let cdn_info = "cdn_pDvQc7ZT";
29
  let 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";
30
 
31
  if (api === "headers") {
 
35
  body += "connInfo" + " = " + JSON.stringify(connInfo.remoteAddr) + "\n";
36
  }
37
  body += "request_url" + " = " + request.url + "\n";
38
+ body += "worker_version = 1.12\n";
39
  return new Response(body, corsHeaders);
40
  }
41
 
 
153
  const apiUrl = new URL(api);
154
  let apiBase = apiUrl.href.substring(0, apiUrl.href.lastIndexOf("/") + 1);
155
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
156
  // Rewrite request to point to API URL. This also makes the request mutable
157
  // so you can add the correct Origin header to make the API server think
158
  // that this request is not cross-site.
 
228
  if (apiUrl.hostname === "kinoplay.site" || apiUrl.hostname === "kinoplay1.site" || apiUrl.hostname === "kinoplay2.site") {
229
  request.headers.set("Cookie", "invite=a246a3f46c82fe439a45c3dbbbb24ad5");
230
  }
 
 
 
 
231
  if (remove_compression) {
232
  let encoding = (request.headers.get("Accept-Encoding") || "");
233
  if (encoding.includes("zstd") || encoding.includes("deflate")) {
 
295
  },
296
  });
297
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
298
  }
299
 
300
  // Fix redirect URL
 
350
  return link;
351
  }
352
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
353
  async function handleOptions(request, connInfo) {
354
  if (
355
  request.headers.get("Origin") !== null &&