-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
73 lines (63 loc) · 2.53 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
const puppeteer = require('puppeteer');
const Downloader = require("nodejs-file-downloader");
const os = require('os');
const path = require('path');
const fetchedFiles = [];
(async () => {
console.log("-----------------------------")
console.log(" Lookeeloo Downloader ")
console.log(" (c) 2023 Qrodex Innovations ")
console.log("-----------------------------")
const browser = await puppeteer.launch({ headless: 'new' });
const page = await browser.newPage();
await page.setRequestInterception(true);
page.on('request', (interceptedRequest) => {
const url = interceptedRequest.url();
fetchedFiles.push(url);
interceptedRequest.continue();
});
async function downloadFile(URL) {
var homeDir = os.homedir();
var videosFolderPath = path.join(homeDir, 'Videos');
videosFolderPath = path.join(videosFolderPath, 'Lookeeloo Downloader');
const downloader = new Downloader({
url: URL,
directory: videosFolderPath,
onProgress: function (percentage, chunks, remainingSize) {
process.stdout.write(parseInt(percentage) + "% Downloaded, " + parseInt(remainingSize) + " Bytes remaining. \r");
},
});
try {
await downloader.download();
console.log('\nVideo saved to: "' + videosFolderPath + '"')
} catch (error) {
console.log("\nDownload failed: ", error);
}
}
async function getMP4URL() {
setTimeout(async () => {
const pageTitle = await page.title();
const videoURL = fetchedFiles.find(
(element) => element.includes('.mp4') || element.includes('.webm')
)
console.log('Title:', pageTitle);
console.log("Video URL: " + videoURL)
console.log('\nPreparing to download...\n')
await browser.close();
setTimeout(async () => {
await downloadFile(videoURL)
var stdintoo = process.openStdin();
process.stdout.write('\nPress any key to exit...');
stdintoo.on('data', function () {
process.exit()
});
}, 2500);
}, 5000);
}
var stdin = process.openStdin();
process.stdout.write('Video ID: ');
stdin.on('data', async function (line) {
await page.goto('https://lookeeloo-canary.web.app/player/' + line.toString());
getMP4URL()
});
})();