-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
63 lines (58 loc) · 1.59 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
const target = require('target-menu');
const RL = require('readline-sync');
const fs = require("fs");
const prepareDownload = require('./src/prepareToDownload');
const readURLsFromFile = require('./src/readFromFile');
const input = require('./src/inputLinks');
const Nightmare = require('Nightmare');
const {
resolve
} = require('path');
nightmare = new Nightmare({
show: false,
webPreferences: {
images: false
}
});
var src = new String;
var urls = [];
const [, , ...args] = process.argv;
var menu = ['single image', 'multiple images', 'exit']
var control = new target.Controls();
async function startMenu() {
return new Promise(async () => {
while (control.pos1 >= 0) {
target.menu(control, 'white', menu);
switch (control.pos1) {
case -1:
await nightmare.end();
console.clear();
break;
case 0:
await prepareDownload([input.inputLink()]);
break;
case 1:
await prepareDownload(input.inputMultipleLinks());
break;
case 2:
process.exit()
}
}
})
}
async function main(args) {
switch (args[0]) {
case '-f':
await prepareDownload(readURLsFromFile(args[1]));
process.exit()
break;
case '-c':
await startMenu()
break;
default:
await prepareDownload([args[0]])
process.exit()
break;
}
}
main(args);