Update index.js
Browse files
index.js
CHANGED
|
@@ -53,22 +53,19 @@ function formatSize(num) {
|
|
| 53 |
return bytes(+num || 0, { unitSeparator: ' ' })
|
| 54 |
}
|
| 55 |
|
| 56 |
-
async function xbuddy(url
|
| 57 |
const browser = await chromium.launch({
|
| 58 |
headless: true,
|
| 59 |
executablePath: '/usr/bin/chromium',
|
| 60 |
args: ['--no-sandbox']
|
| 61 |
})
|
| 62 |
-
|
| 63 |
-
const context = await browser.newContext()
|
| 64 |
-
const page = await context.newPage()
|
| 65 |
|
| 66 |
await page.goto(`https://9xbuddy.in/process?url=${url}`)
|
| 67 |
-
if (log) console.log(await page.content())
|
| 68 |
|
|
|
|
| 69 |
const response = await page.waitForResponse(res =>
|
| 70 |
res.url().includes('extract') && res.request().method() === 'POST')
|
| 71 |
-
|
| 72 |
const json = await response.json()
|
| 73 |
|
| 74 |
if (json.status && json.response.type !== 'list') {
|
|
@@ -83,6 +80,7 @@ async function xbuddy(url, log = false) {
|
|
| 83 |
})).filter(c => /^http/.test(c.url))
|
| 84 |
|
| 85 |
json.response.formats = result
|
|
|
|
| 86 |
}
|
| 87 |
|
| 88 |
await browser.close()
|
|
|
|
| 53 |
return bytes(+num || 0, { unitSeparator: ' ' })
|
| 54 |
}
|
| 55 |
|
| 56 |
+
async function xbuddy(url) {
|
| 57 |
const browser = await chromium.launch({
|
| 58 |
headless: true,
|
| 59 |
executablePath: '/usr/bin/chromium',
|
| 60 |
args: ['--no-sandbox']
|
| 61 |
})
|
| 62 |
+
const page = await browser.newPage()
|
|
|
|
|
|
|
| 63 |
|
| 64 |
await page.goto(`https://9xbuddy.in/process?url=${url}`)
|
|
|
|
| 65 |
|
| 66 |
+
const request = await page.waitForRequest(req => req.url().includes('extract'))
|
| 67 |
const response = await page.waitForResponse(res =>
|
| 68 |
res.url().includes('extract') && res.request().method() === 'POST')
|
|
|
|
| 69 |
const json = await response.json()
|
| 70 |
|
| 71 |
if (json.status && json.response.type !== 'list') {
|
|
|
|
| 80 |
})).filter(c => /^http/.test(c.url))
|
| 81 |
|
| 82 |
json.response.formats = result
|
| 83 |
+
json.response.headers = request.headers()
|
| 84 |
}
|
| 85 |
|
| 86 |
await browser.close()
|