From dbaa1742a6246afa5650d66bdb9649187c4e8193 Mon Sep 17 00:00:00 2001 From: UesleiDev <63914812+uesleibros@users.noreply.github.com> Date: Sun, 1 Sep 2024 22:34:37 -0300 Subject: [PATCH] novos controles pro player --- package-lock.json | 113 +++++++++++++++++++++++++++- package.json | 2 + src/app/api/imagens/anroll/route.js | 79 ++++++++++++------- 3 files changed, 164 insertions(+), 30 deletions(-) diff --git a/package-lock.json b/package-lock.json index b5ee652..b0fe408 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,8 +12,10 @@ "chart.js": "^2.9.3", "disqus-react": "^1.1.5", "framer-motion": "^11.3.28", + "https-proxy-agent": "^7.0.5", "next": "14.2.5", "nextjs-toploader": "^3.6.15", + "node-fetch": "^3.3.2", "react": "^18", "react-dom": "^18", "react-icons": "^5.3.0", @@ -3825,6 +3827,17 @@ "npm": ">=5" } }, + "node_modules/agent-base": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.1.tgz", + "integrity": "sha512-H0TSyFNDMomMNJQBn8wFV5YC/2eJ+VXECwOadZJT554xP6cODZHPX3H9QMQECxvrgiSOP1pHjy1sMWQVYJOUOA==", + "dependencies": { + "debug": "^4.3.4" + }, + "engines": { + "node": ">= 14" + } + }, "node_modules/ajv": { "version": "6.12.6", "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", @@ -4399,6 +4412,14 @@ "integrity": "sha512-sdQSFB7+llfUcQHUQO3+B8ERRj0Oa4w9POWMI/puGtuf7gFywGmkaLCElnudfTiKZV+NvHqL0ifzdrI8Ro7ESA==", "dev": true }, + "node_modules/data-uri-to-buffer": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-4.0.1.tgz", + "integrity": "sha512-0R9ikRb668HB7QDxT1vkpuUBtqc53YyAwMwGeUFKRojY/NWKvdZ+9UYtRfGmhqNbRkTSVpMbmyhXipFFv2cb/A==", + "engines": { + "node": ">= 12" + } + }, "node_modules/data-view-buffer": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/data-view-buffer/-/data-view-buffer-1.0.1.tgz", @@ -4454,7 +4475,6 @@ "version": "4.3.6", "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.6.tgz", "integrity": "sha512-O/09Bd4Z1fBrU4VzkhFqVgpPzaGbw6Sm9FEkBT1A/YBXQFGuuSxa1dN2nxgxS34JmKXqYx8CZAwEVoJFImUXIg==", - "dev": true, "dependencies": { "ms": "2.1.2" }, @@ -5282,6 +5302,28 @@ "reusify": "^1.0.4" } }, + "node_modules/fetch-blob": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/fetch-blob/-/fetch-blob-3.2.0.tgz", + "integrity": "sha512-7yAQpD2UMJzLi1Dqv7qFYnPbaPx7ZfFK6PiIxQ4PfkGPyNyl2Ugx+a/umUonmKqjhM4DnfbMvdX6otXq83soQQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/jimmywarting" + }, + { + "type": "paypal", + "url": "https://paypal.me/jimmywarting" + } + ], + "dependencies": { + "node-domexception": "^1.0.0", + "web-streams-polyfill": "^3.0.3" + }, + "engines": { + "node": "^12.20 || >= 14.13" + } + }, "node_modules/file-entry-cache": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-6.0.1.tgz", @@ -5373,6 +5415,17 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/formdata-polyfill": { + "version": "4.0.10", + "resolved": "https://registry.npmjs.org/formdata-polyfill/-/formdata-polyfill-4.0.10.tgz", + "integrity": "sha512-buewHzMvYL29jdeQTVILecSaZKnt/RJWjoZCF5OW60Z67/GmSLBkOFM7qh1PI3zFNtJbaZL5eQu1vLfazOwj4g==", + "dependencies": { + "fetch-blob": "^3.1.2" + }, + "engines": { + "node": ">=12.20.0" + } + }, "node_modules/framer-motion": { "version": "11.3.28", "resolved": "https://registry.npmjs.org/framer-motion/-/framer-motion-11.3.28.tgz", @@ -5724,6 +5777,18 @@ "node": ">= 0.4" } }, + "node_modules/https-proxy-agent": { + "version": "7.0.5", + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-7.0.5.tgz", + "integrity": "sha512-1e4Wqeblerz+tMKPIq2EMGiiWW1dIjZOksyHWSUm1rmuvw/how9hBHZ38lAGj5ID4Ik6EdkOw7NmWPy6LAwalw==", + "dependencies": { + "agent-base": "^7.0.2", + "debug": "4" + }, + "engines": { + "node": ">= 14" + } + }, "node_modules/ignore": { "version": "5.3.2", "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.2.tgz", @@ -6553,8 +6618,7 @@ "node_modules/ms": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", - "dev": true + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" }, "node_modules/mux.js": { "version": "7.0.3", @@ -6698,6 +6762,41 @@ "react-dom": ">= 16.0.0" } }, + "node_modules/node-domexception": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/node-domexception/-/node-domexception-1.0.0.tgz", + "integrity": "sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/jimmywarting" + }, + { + "type": "github", + "url": "https://paypal.me/jimmywarting" + } + ], + "engines": { + "node": ">=10.5.0" + } + }, + "node_modules/node-fetch": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-3.3.2.tgz", + "integrity": "sha512-dRB78srN/l6gqWulah9SrxeYnxeddIG30+GOqK/9OlLVyLg3HPnr6SqOWTWOXKRwC2eGYCkZ59NNuSgvSrpgOA==", + "dependencies": { + "data-uri-to-buffer": "^4.0.0", + "fetch-blob": "^3.1.4", + "formdata-polyfill": "^4.0.10" + }, + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/node-fetch" + } + }, "node_modules/normalize-path": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", @@ -8419,6 +8518,14 @@ "global": "^4.3.1" } }, + "node_modules/web-streams-polyfill": { + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-3.3.3.tgz", + "integrity": "sha512-d2JWLCivmZYTSIoge9MsgFCZrt571BikcWGYkjC1khllbTeDlGqZ2D8vD8E/lJa8WGWbb7Plm8/XJYV7IJHZZw==", + "engines": { + "node": ">= 8" + } + }, "node_modules/which": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", diff --git a/package.json b/package.json index 3b82d9b..8685e61 100644 --- a/package.json +++ b/package.json @@ -13,8 +13,10 @@ "chart.js": "^2.9.3", "disqus-react": "^1.1.5", "framer-motion": "^11.3.28", + "https-proxy-agent": "^7.0.5", "next": "14.2.5", "nextjs-toploader": "^3.6.15", + "node-fetch": "^3.3.2", "react": "^18", "react-dom": "^18", "react-icons": "^5.3.0", diff --git a/src/app/api/imagens/anroll/route.js b/src/app/api/imagens/anroll/route.js index 31c7dd1..f90cbc1 100644 --- a/src/app/api/imagens/anroll/route.js +++ b/src/app/api/imagens/anroll/route.js @@ -1,33 +1,58 @@ +import fetch from "node-fetch"; +import { HttpsProxyAgent } from "https-proxy-agent"; + +const proxy = "http://118.68.249.51:1005"; +const agent = new HttpsProxyAgent(proxy); + export async function GET(request) { - const query = request.nextUrl.searchParams.get("q"); + const query = request.nextUrl.searchParams.get("q"); - if (!query) - return Response.json({ error: "missing query." }, { status: 401 }); + if (!query) + return new Response( + JSON.stringify({ error: "missing query." }), + { status: 401, headers: { "Content-Type": "application/json" } } + ); - const res = await fetch(decodeURIComponent(query), { - headers: { - "Authority": decodeURIComponent(query).replace("https://").split('/')[0], - "Host": "anroll.net", - "Origin": "https://www.anroll.net", - "Referer": "https://www.anroll.net/", - "Cf-Ray": "8bc942b6981b5210-GRU", - "Nel": '{"success_fraction":0,"report_to":"cf-nel","max_age":604800}', - "Report-To": '{"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v4?s=5cULeDVZhT2XGTomTHZHBNgkCWrDOMuKCY1imqjyaln4eueUt%2F3W0VHTYV1s0iZ1k%2B5LO%2B5olLC2L5Iw6CJeWk8Z8gMU85aMIummLJ9WoV6QWYxn45cJuguTZD3tF8sZ8pLcjz8e1j6afRMPppvv"}],"group":"cf-nel","max_age":604800}', - "Server": "cloudflare", - "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" - }, - cache: "no-store" - }); + try { + const url = decodeURIComponent(query); + const res = await fetch(url, { + agent, + headers: { + "Authority": new URL(url).host, + "Host": "anroll.net", + "Origin": "https://www.anroll.net", + "Referer": "https://www.anroll.net/", + "Cf-Ray": "8bc942b6981b5210-GRU", + "Nel": '{"success_fraction":0,"report_to":"cf-nel","max_age":604800}', + "Report-To": '{"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v4?s=5cULeDVZhT2XGTomTHZHBNgkCWrDOMuKCY1imqjyaln4eueUt%2F3W0VHTYV1s0iZ1k%2B5LO%2B5olLC2L5Iw6CJeWk8Z8gMU85aMIummLJ9WoV6QWYxn45cJuguTZD3tF8sZ8pLcjz8e1j6afRMPppvv"}],"group":"cf-nel","max_age":604800}', + "Server": "cloudflare", + "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", + }, + cache: "no-store", + }); + if (!res.ok) { + return new Response( + JSON.stringify({ error: "Failed to fetch the image." }), + { status: res.status, headers: { "Content-Type": "application/json" } } + ); + } - const imageBuffer = await res.arrayBuffer(); - const contentLength = imageBuffer.byteLength; + const imageBuffer = await res.arrayBuffer(); + const contentLength = imageBuffer.byteLength; - return new Response(imageBuffer, { - status: 200, - headers: { - "Content-Type": "image/webp", - "Content-Length": contentLength - }, - }); -} \ No newline at end of file + return new Response(imageBuffer, { + status: 200, + headers: { + "Content-Type": "image/webp", + "Content-Length": contentLength.toString(), + }, + }); + } catch (error) { + return new Response( + JSON.stringify({ error: error.message }), + { status: 500, headers: { "Content-Type": "application/json" } } + ); + } +}