Spaces:
Paused
Paused
Update index.js
Browse files
index.js
CHANGED
|
@@ -127,9 +127,20 @@ app.get("/api/direct", async (req, res) => {
|
|
| 127 |
return res.status(404).json({ status: false, error: "Download link not found" });
|
| 128 |
}
|
| 129 |
|
| 130 |
-
// Step 3:
|
| 131 |
-
|
| 132 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 133 |
|
| 134 |
res.json({
|
| 135 |
status: true,
|
|
@@ -143,8 +154,6 @@ app.get("/api/direct", async (req, res) => {
|
|
| 143 |
}
|
| 144 |
});
|
| 145 |
|
| 146 |
-
|
| 147 |
-
|
| 148 |
app.get('/moddl', async (req, res) => {
|
| 149 |
const apkUrl = req.query.url
|
| 150 |
|
|
|
|
| 127 |
return res.status(404).json({ status: false, error: "Download link not found" });
|
| 128 |
}
|
| 129 |
|
| 130 |
+
// Step 3: capture final URL from redirect
|
| 131 |
+
let finalUrl = null;
|
| 132 |
+
page.on("response", (response) => {
|
| 133 |
+
if (response.status() === 302 || response.status() === 200) {
|
| 134 |
+
const url = response.headers()['location'] || response.url();
|
| 135 |
+
if (url.includes("dlws")) finalUrl = url;
|
| 136 |
+
}
|
| 137 |
+
});
|
| 138 |
+
|
| 139 |
+
await page.goto(intermediate, { waitUntil: "networkidle2" });
|
| 140 |
+
|
| 141 |
+
if (!finalUrl) {
|
| 142 |
+
return res.status(500).json({ status: false, error: "Final URL not found" });
|
| 143 |
+
}
|
| 144 |
|
| 145 |
res.json({
|
| 146 |
status: true,
|
|
|
|
| 154 |
}
|
| 155 |
});
|
| 156 |
|
|
|
|
|
|
|
| 157 |
app.get('/moddl', async (req, res) => {
|
| 158 |
const apkUrl = req.query.url
|
| 159 |
|