forked from inirey/API-REST
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathig.js
More file actions
78 lines (74 loc) · 2.16 KB
/
Copy pathig.js
File metadata and controls
78 lines (74 loc) · 2.16 KB
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
74
75
76
77
78
const ig = require("instatouch");
const dotenv = require('dotenv').config()
const sID = process.env.sID;
const options = {
count: 0,
mediaType: "all",
timeout: 0,
session: "sessionid=" + sID
};
async function igStalk(username = 'instagram') {
return new Promise((resolve, reject) => {
try {
ig.getUserMeta(username, options)
.then((data) => {
resolve({
result: {
profile: data.graphql.user.profile_pic_url,
profilehd: data.graphql.user.profile_pic_url_hd,
fullname: data.graphql.user.full_name,
private: data.graphql.user.is_private,
verified: data.graphql.user.is_verified,
bio: data.graphql.user.biography,
follower: data.graphql.user.edge_followed_by.count,
following: data.graphql.user.edge_follow.count,
conneted_fb: data.graphql.user.connected_fb_page,
videotimeline: data.graphql.user.edge_felix_video_timeline.count,
timeline: data.graphql.user.edge_owner_to_timeline_media.count,
savedmedia: data.graphql.user.edge_saved_media.count,
collections: data.graphql.user.edge_media_collections.count
}
});
})
.catch((err) =>
reject({
message: "akun tidak di temukan atau username tidak valid"
})
);
} catch (err) {
reject(err);
}
});
}
async function igDownload(url) {
return new Promise((resolve, reject) => {
if (url === 'undefined') {
reject({
msg: 'Masukkan URL nya.'
})
}
url = url.split('?')[0];
try {
ig.getPostMeta(url, options)
.then(data =>
resolve({
id: data.graphql.shortcode_media.id,
shortCode: data.graphql.shortcode_media.shortcode,
caption: data.graphql.shortcode_media.edge_media_to_caption.edges[0].node.text,
url: data.graphql.shortcode_media.display_url
})
)
}
catch(err) {
reject({
status: 406,
creator: 'Reyganz',
msg: "Link Tidak Valid"
})
}
})
}
module.exports = {
igStalk,
igDownload
};