@neoxr/wb 2.3.7 → 2.4.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/system/functions.js +43 -37
package/package.json
CHANGED
package/system/functions.js
CHANGED
|
@@ -362,55 +362,61 @@ module.exports = class Function {
|
|
|
362
362
|
return resolve(data)
|
|
363
363
|
})
|
|
364
364
|
} else {
|
|
365
|
-
return new Promise(resolve => {
|
|
366
|
-
const
|
|
365
|
+
return new Promise(async resolve => {
|
|
366
|
+
const cf = await cloudscraper({
|
|
367
|
+
method: 'GET',
|
|
368
|
+
url: source,
|
|
367
369
|
headers: {
|
|
368
370
|
"Accept": "*/*",
|
|
369
|
-
"
|
|
371
|
+
"Cache-Control": "no-cache",
|
|
372
|
+
"Connection": "Keep-Alive",
|
|
373
|
+
"Dnt": "1",
|
|
370
374
|
"Referrer-Policy": "strict-origin-when-cross-origin",
|
|
371
375
|
"sec-ch-ua": '"Chromium";v="107", "Not=A?Brand";v="24"',
|
|
372
376
|
"sec-ch-ua-platform": "Android",
|
|
373
377
|
"sec-fetch-dest": "empty",
|
|
374
378
|
"sec-fetch-mode": "cors",
|
|
375
379
|
"sec-fetch-site": "same-origin",
|
|
380
|
+
"Pragma": "no-cache",
|
|
381
|
+
"Priority": "u=1, i",
|
|
382
|
+
"User-Agent": "Mozilla/5.0 (X11; CrOS x86_64 14541.0.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36",
|
|
383
|
+
"Upgrade-Insecure-Requests": "1",
|
|
384
|
+
"X-Requested-With": "XMLHttpRequest",
|
|
376
385
|
...options
|
|
386
|
+
},
|
|
387
|
+
encoding: null,
|
|
388
|
+
resolveWithFullResponse: true
|
|
389
|
+
})
|
|
390
|
+
if (cf.statusCode !== 200) return resolve({
|
|
391
|
+
status: false,
|
|
392
|
+
msg: `[${cf.statusCode}] : Error while getting file!`
|
|
393
|
+
})
|
|
394
|
+
const extension = filename ? filename.split`.` [filename.split`.`.length - 1] : mime.extension(cf.headers['content-type'])
|
|
395
|
+
const file = fs.createWriteStream(`temp/${this.uuid() + '.' + extension}`)
|
|
396
|
+
const name = filename || path.basename(file.path)
|
|
397
|
+
const transformStream = new stream.Transform({
|
|
398
|
+
transform(chunk, encoding, callback) {
|
|
399
|
+
callback(null, chunk)
|
|
377
400
|
}
|
|
378
401
|
})
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
402
|
+
cf.pipe(transformStream).pipe(file)
|
|
403
|
+
file.on('finish', () => {
|
|
404
|
+
const data = {
|
|
405
|
+
status: true,
|
|
406
|
+
file: file.path,
|
|
407
|
+
filename: name,
|
|
408
|
+
mime: mime.lookup(file.path),
|
|
409
|
+
extension: extension,
|
|
410
|
+
size: this.formatSize(cf.headers['content-length'] ? cf.headers['content-length'] : 0),
|
|
411
|
+
bytes: cf.headers['content-length'] ? parseInt(cf.headers['content-length']) : 0,
|
|
412
|
+
headers: cf.headers
|
|
386
413
|
}
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
}
|
|
394
|
-
})
|
|
395
|
-
mg.pipe(transformStream).pipe(file)
|
|
396
|
-
file.on('finish', () => {
|
|
397
|
-
const data = {
|
|
398
|
-
status: true,
|
|
399
|
-
file: file.path,
|
|
400
|
-
filename: name,
|
|
401
|
-
mime: mime.lookup(file.path),
|
|
402
|
-
extension: extension,
|
|
403
|
-
size: this.formatSize(response.headers['content-length'] ? response.headers['content-length'] : 0),
|
|
404
|
-
bytes: response.headers['content-length'] ? parseInt(response.headers['content-length']) : 0,
|
|
405
|
-
headers: response.headers
|
|
406
|
-
}
|
|
407
|
-
resolve(data)
|
|
408
|
-
})
|
|
409
|
-
.on('error', (error) => {
|
|
410
|
-
resolve({
|
|
411
|
-
status: false,
|
|
412
|
-
msg: `Error when getting the file`
|
|
413
|
-
})
|
|
414
|
+
resolve(data)
|
|
415
|
+
})
|
|
416
|
+
.on('error', (error) => {
|
|
417
|
+
resolve({
|
|
418
|
+
status: false,
|
|
419
|
+
msg: `Error when getting the file`
|
|
414
420
|
})
|
|
415
421
|
})
|
|
416
422
|
})
|