-
Notifications
You must be signed in to change notification settings - Fork 1
/
indexapp.js
30 lines (30 loc) · 930 Bytes
/
indexapp.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
const dotenv = require("dotenv");
const instagram = require("./src/sd-services/instagramapp");
const parseArgs = require("minimist");
dotenv.config();
const username = process.env.INSTAGRAM_USERNAME;
const password = process.env.INSTAGRAM_PASSWORD;
(async () => {
const args = parseArgs(process.argv.slice(2));
await instagram.initialize();
await instagram.initializeLogin(username, password);
await instagram.skipConfirmationWindow();
switch (Object.keys(args)[1]) {
case "post":
await instagram.getPostData();
break;
case "hashtag":
await instagram.getPostByTag("gadgets");
break;
default:
console.log("invalid option");
}
process.on("beforeExit", async () => {
console.log("beforeExit event")
await instagram.close();
});
process.on("exit", async () => {
console.log("exit event")
await instagram.close();
});
})().catch(err => console.error(err));