GUI-STUDIO commited on
Commit ·
34f686f
1
Parent(s): 658280e
Refactor proxy handling and add generic scraper router
Browse filesMultiple improvements to the scraping infrastructure:
- Replace direct fetch() calls with custom proxy() function in portal routers for better request handling
- Clone responses using new Response(body, original) pattern to allow header manipulation
- Add title tracking to transcoding jobs for better status reporting
- Create generic scraper router supporting multiple portals (111movies, flixer, ythd, etc.)
- Improve post-processing validation with guards and empty object checks
- Add ythd portal headers and enhance cache error tracking
- Fix export naming (NS_flickystream_scraper -> NS_generic_scraper)
- Add optional parameters to BQL runner (resource, status, operator) and include 'origin' header
src/sub-router/proxima.ts
CHANGED
|
@@ -129,7 +129,7 @@ sub_router.get(
|
|
| 129 |
// 1. fetch upstream
|
| 130 |
const upstream_v1 = async () => {
|
| 131 |
try {
|
| 132 |
-
return await
|
| 133 |
headers: send_headers,
|
| 134 |
method: decoded_proxy_commands?.method || "GET",
|
| 135 |
body: decoded_proxy_commands?.upstream_payload
|
|
@@ -158,7 +158,7 @@ sub_router.get(
|
|
| 158 |
|
| 159 |
console.log({ ECONNREFUSED_fallback }, { send_headers });
|
| 160 |
|
| 161 |
-
return await
|
| 162 |
headers: send_headers,
|
| 163 |
method: decoded_proxy_commands?.method || "GET",
|
| 164 |
body: decoded_proxy_commands?.upstream_payload
|
|
@@ -170,7 +170,7 @@ sub_router.get(
|
|
| 170 |
};
|
| 171 |
|
| 172 |
const upstream_v2 = async () => {
|
| 173 |
-
const _1 = await
|
| 174 |
headers: send_headers,
|
| 175 |
method: decoded_proxy_commands?.method || "GET",
|
| 176 |
body: decoded_proxy_commands?.upstream_payload
|
|
@@ -201,13 +201,13 @@ sub_router.get(
|
|
| 201 |
// const _u = new URL(fallback_proxy);
|
| 202 |
// _u.searchParams.set("ops", "raw-ch");
|
| 203 |
|
| 204 |
-
// const _2 = await
|
| 205 |
|
| 206 |
// return _2;
|
| 207 |
};
|
| 208 |
|
| 209 |
// const upstream = await upstream_v1();
|
| 210 |
-
|
| 211 |
|
| 212 |
// 2. short-circuit
|
| 213 |
if (!upstream) {
|
|
@@ -250,6 +250,8 @@ sub_router.get(
|
|
| 250 |
// }
|
| 251 |
}
|
| 252 |
|
|
|
|
|
|
|
| 253 |
// 3. strip security headers
|
| 254 |
upstream.headers.delete("content-security-policy");
|
| 255 |
upstream.headers.delete("x-frame-options");
|
|
|
|
| 129 |
// 1. fetch upstream
|
| 130 |
const upstream_v1 = async () => {
|
| 131 |
try {
|
| 132 |
+
return await proxy(upstream_url, {
|
| 133 |
headers: send_headers,
|
| 134 |
method: decoded_proxy_commands?.method || "GET",
|
| 135 |
body: decoded_proxy_commands?.upstream_payload
|
|
|
|
| 158 |
|
| 159 |
console.log({ ECONNREFUSED_fallback }, { send_headers });
|
| 160 |
|
| 161 |
+
return await proxy(ECONNREFUSED_fallback.toString(), {
|
| 162 |
headers: send_headers,
|
| 163 |
method: decoded_proxy_commands?.method || "GET",
|
| 164 |
body: decoded_proxy_commands?.upstream_payload
|
|
|
|
| 170 |
};
|
| 171 |
|
| 172 |
const upstream_v2 = async () => {
|
| 173 |
+
const _1 = await proxy(upstream_url, {
|
| 174 |
headers: send_headers,
|
| 175 |
method: decoded_proxy_commands?.method || "GET",
|
| 176 |
body: decoded_proxy_commands?.upstream_payload
|
|
|
|
| 201 |
// const _u = new URL(fallback_proxy);
|
| 202 |
// _u.searchParams.set("ops", "raw-ch");
|
| 203 |
|
| 204 |
+
// const _2 = await proxy(_u.toString());
|
| 205 |
|
| 206 |
// return _2;
|
| 207 |
};
|
| 208 |
|
| 209 |
// const upstream = await upstream_v1();
|
| 210 |
+
let upstream = await upstream_v2();
|
| 211 |
|
| 212 |
// 2. short-circuit
|
| 213 |
if (!upstream) {
|
|
|
|
| 250 |
// }
|
| 251 |
}
|
| 252 |
|
| 253 |
+
upstream = new Response(upstream.body, upstream);
|
| 254 |
+
|
| 255 |
// 3. strip security headers
|
| 256 |
upstream.headers.delete("content-security-policy");
|
| 257 |
upstream.headers.delete("x-frame-options");
|