instauto 9.2.0 → 9.4.0
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/README.md +9 -0
- package/dist/db.d.ts +34 -0
- package/dist/db.d.ts.map +1 -0
- package/dist/db.js +99 -0
- package/dist/index.d.ts +146 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1108 -0
- package/package.json +40 -14
- package/src/db.js +0 -122
- package/src/index.js +0 -1212
package/package.json
CHANGED
|
@@ -1,31 +1,57 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "instauto",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.4.0",
|
|
4
4
|
"description": "Instagram automation library written in Node.js",
|
|
5
|
-
"
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
6
8
|
"scripts": {
|
|
7
9
|
"lint": "eslint .",
|
|
8
|
-
"test": "exit 0"
|
|
10
|
+
"test": "exit 0",
|
|
11
|
+
"check": "tsc && yarn lint && yarn test",
|
|
12
|
+
"build": "tsc -p tsconfig.build.json",
|
|
13
|
+
"prepare": "yarn build"
|
|
9
14
|
},
|
|
10
15
|
"files": [
|
|
11
|
-
"
|
|
16
|
+
"dist"
|
|
12
17
|
],
|
|
18
|
+
"publishConfig": {
|
|
19
|
+
"access": "public"
|
|
20
|
+
},
|
|
13
21
|
"author": "Mikael Finstad <finstaden@gmail.com>",
|
|
14
22
|
"repository": "mifi/instauto",
|
|
15
23
|
"license": "MIT",
|
|
16
24
|
"engines": {
|
|
17
|
-
"node": ">=
|
|
25
|
+
"node": ">=22"
|
|
18
26
|
},
|
|
19
27
|
"dependencies": {
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
"user-agents": "^1.0.559"
|
|
28
|
+
"lodash": "^4.17.23",
|
|
29
|
+
"user-agents": "^1.1.669"
|
|
23
30
|
},
|
|
24
31
|
"devDependencies": {
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"eslint-
|
|
28
|
-
"
|
|
29
|
-
"
|
|
32
|
+
"@tsconfig/node22": "^22.0.5",
|
|
33
|
+
"@tsconfig/strictest": "^2.0.8",
|
|
34
|
+
"@types/eslint-plugin-jsx-a11y": "^6",
|
|
35
|
+
"@types/lodash": "^4.17.23",
|
|
36
|
+
"@types/node": "22",
|
|
37
|
+
"@types/user-agents": "^1.0.4",
|
|
38
|
+
"@typescript-eslint/eslint-plugin": "^8.51.0",
|
|
39
|
+
"@typescript-eslint/parser": "^8.51.0",
|
|
40
|
+
"dotenv": "^17.2.3",
|
|
41
|
+
"eslint": "^8.57.1",
|
|
42
|
+
"eslint-config-mifi": "^0.1.0",
|
|
43
|
+
"eslint-plugin-import": "^2.32.0",
|
|
44
|
+
"eslint-plugin-jsx-a11y": "^6.10.2",
|
|
45
|
+
"eslint-plugin-react": "^7.37.5",
|
|
46
|
+
"eslint-plugin-react-hooks": "^7.0.1",
|
|
47
|
+
"eslint-plugin-unicorn": "56",
|
|
48
|
+
"puppeteer": "^24.36.1",
|
|
49
|
+
"typescript": "~5.9.3"
|
|
50
|
+
},
|
|
51
|
+
"packageManager": "yarn@4.12.0",
|
|
52
|
+
"exports": {
|
|
53
|
+
".": {
|
|
54
|
+
"import": "./dist/index.js"
|
|
55
|
+
}
|
|
30
56
|
}
|
|
31
|
-
}
|
|
57
|
+
}
|
package/src/db.js
DELETED
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const fs = require('fs-extra');
|
|
4
|
-
const keyBy = require('lodash/keyBy');
|
|
5
|
-
|
|
6
|
-
module.exports = async ({
|
|
7
|
-
followedDbPath,
|
|
8
|
-
unfollowedDbPath,
|
|
9
|
-
likedPhotosDbPath,
|
|
10
|
-
|
|
11
|
-
logger = console,
|
|
12
|
-
}) => {
|
|
13
|
-
let prevFollowedUsers = {};
|
|
14
|
-
let prevUnfollowedUsers = {};
|
|
15
|
-
let prevLikedPhotos = [];
|
|
16
|
-
|
|
17
|
-
async function trySaveDb() {
|
|
18
|
-
try {
|
|
19
|
-
await fs.writeFile(followedDbPath, JSON.stringify(Object.values(prevFollowedUsers)));
|
|
20
|
-
await fs.writeFile(unfollowedDbPath, JSON.stringify(Object.values(prevUnfollowedUsers)));
|
|
21
|
-
await fs.writeFile(likedPhotosDbPath, JSON.stringify(prevLikedPhotos));
|
|
22
|
-
} catch (err) {
|
|
23
|
-
logger.error('Failed to save database');
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
async function tryLoadDb() {
|
|
28
|
-
try {
|
|
29
|
-
prevFollowedUsers = keyBy(JSON.parse(await fs.readFile(followedDbPath)), 'username');
|
|
30
|
-
} catch (err) {
|
|
31
|
-
logger.warn('No followed database found');
|
|
32
|
-
}
|
|
33
|
-
try {
|
|
34
|
-
prevUnfollowedUsers = keyBy(JSON.parse(await fs.readFile(unfollowedDbPath)), 'username');
|
|
35
|
-
} catch (err) {
|
|
36
|
-
logger.warn('No unfollowed database found');
|
|
37
|
-
}
|
|
38
|
-
try {
|
|
39
|
-
prevLikedPhotos = JSON.parse(await fs.readFile(likedPhotosDbPath));
|
|
40
|
-
} catch (err) {
|
|
41
|
-
logger.warn('No likes database found');
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
function getPrevLikedPhotos() {
|
|
46
|
-
return prevLikedPhotos;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
function getTotalLikedPhotos() {
|
|
50
|
-
return getPrevLikedPhotos().length; // TODO performance
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
function getLikedPhotosLastTimeUnit(timeUnit) {
|
|
54
|
-
const now = new Date().getTime();
|
|
55
|
-
return getPrevLikedPhotos().filter(u => now - u.time < timeUnit);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
async function addLikedPhoto({ username, href, time }) {
|
|
59
|
-
prevLikedPhotos.push({ username, href, time });
|
|
60
|
-
await trySaveDb();
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
function getPrevFollowedUsers() {
|
|
64
|
-
return Object.values(prevFollowedUsers);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
function getTotalFollowedUsers() {
|
|
68
|
-
return getPrevFollowedUsers().length; // TODO performance
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
function getFollowedLastTimeUnit(timeUnit) {
|
|
73
|
-
const now = new Date().getTime();
|
|
74
|
-
return getPrevFollowedUsers().filter(u => now - u.time < timeUnit);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
function getPrevFollowedUser(username) {
|
|
78
|
-
return prevFollowedUsers[username];
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
async function addPrevFollowedUser(user) {
|
|
82
|
-
prevFollowedUsers[user.username] = user;
|
|
83
|
-
await trySaveDb();
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
function getPrevUnfollowedUsers() {
|
|
87
|
-
return Object.values(prevUnfollowedUsers);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
function getTotalUnfollowedUsers() {
|
|
91
|
-
return getPrevUnfollowedUsers().length; // TODO performance
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
function getUnfollowedLastTimeUnit(timeUnit) {
|
|
95
|
-
const now = new Date().getTime();
|
|
96
|
-
return getPrevUnfollowedUsers().filter(u => now - u.time < timeUnit);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
async function addPrevUnfollowedUser(user) {
|
|
100
|
-
prevUnfollowedUsers[user.username] = user;
|
|
101
|
-
await trySaveDb();
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
await tryLoadDb();
|
|
105
|
-
|
|
106
|
-
return {
|
|
107
|
-
save: trySaveDb,
|
|
108
|
-
addPrevFollowedUser,
|
|
109
|
-
getPrevFollowedUser,
|
|
110
|
-
addPrevUnfollowedUser,
|
|
111
|
-
getPrevFollowedUsers,
|
|
112
|
-
getFollowedLastTimeUnit,
|
|
113
|
-
getPrevUnfollowedUsers,
|
|
114
|
-
getUnfollowedLastTimeUnit,
|
|
115
|
-
getPrevLikedPhotos,
|
|
116
|
-
getLikedPhotosLastTimeUnit,
|
|
117
|
-
addLikedPhoto,
|
|
118
|
-
getTotalFollowedUsers,
|
|
119
|
-
getTotalUnfollowedUsers,
|
|
120
|
-
getTotalLikedPhotos,
|
|
121
|
-
};
|
|
122
|
-
};
|