gj-boomlings-api 0.5.0 → 1.0.1

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.
@@ -18,9 +18,11 @@ module.exports = {
18
18
 
19
19
  let r = await axios.post(server + "getGJUsers20.php", data, {
20
20
  headers: headers
21
+ }).catch(e => {
22
+ if(e.response.data == -1) throw new Error("-1 This user is not found.");
23
+ throw new Error(e.response.data);
21
24
  })
22
25
 
23
- if(r.data == -1) throw new Error("-1 This user is not found.")
24
26
  let id = r.data.split(":16:")[1].split(":3:")[0];
25
27
  if(Number(id) < 71 || id.includes(":")) id = r.data.split(":16:")[2].split(":3:")[0];
26
28
 
@@ -44,9 +46,8 @@ module.exports = {
44
46
  headers: headers
45
47
  }).catch(e => {
46
48
  if(e.response.status == 500) throw new Error("500 Error: couldn't post!");
49
+ throw new Error(e.response.data);
47
50
  })
48
-
49
- if(res.data.toString().toLowerCase() == "error code: 1005") throw new Error("1005 error: Your IP address has been blocked from sending requests to a server. It's recommended to use locally (directly from a PC).")
50
51
 
51
52
  return 1;
52
53
  }
@@ -27,9 +27,11 @@ module.exports = {
27
27
 
28
28
  let r = await axios.post(server + "getGJUsers20.php", data, {
29
29
  headers: headers
30
+ }).catch(e => {
31
+ if(r.data == -1) throw new Error("-1 This user is not found.")
32
+ throw new Error(e.response.data)
30
33
  })
31
34
 
32
- if(r.data == -1) throw new Error("-1 This user is not found.")
33
35
  let username = r.data.split("1:")[1].split(":2:")[0];
34
36
  let accID = r.data.split(":16:")[1].split(":3:")[0];
35
37
  if(Number(accID) < 71 || accID.includes(":")) accID = r.data.split(":16:")[2].split(":3:")[0];
@@ -58,6 +60,8 @@ module.exports = {
58
60
  if(edata == '') edata = "Whoops, the servers have rejected your request!"
59
61
  throw new Error(edata)
60
62
  })
63
+
64
+ if(res.data.toLowerCase() == "error code: 1020") throw new Error("1020 error: Request denied.");
61
65
 
62
66
  return 1;
63
67
  }
package/index.js CHANGED
@@ -14,15 +14,23 @@ const { getAccountPosts } = require("./functions/getAccountPosts.js");
14
14
  const { uploadAccountPost } = require("./functions/uploadAccountPost.js");
15
15
  const { uploadComment } = require("./functions/uploadComment.js");
16
16
  const { getMapPacks } = require("./functions/getMapPacks.js");
17
+ const { blockUser } = require("./functions/blockUser.js");
18
+ const { getLevelByID } = require("./functions/getLevelByID.js");
19
+ const { getTop100 } = require("./functions/getTop100.js");
20
+ const { getCreatorScores } = require("./functions/getCreatorScores.js");
21
+ const { updateLevelDesc } = require("./functions/updateLevelDesc.js");
22
+ const { deleteAccountPost } = require("./functions/deleteAccountPost.js");
23
+ const { getUserLevels } = require("./functions/getUserLevels.js");
24
+ const { searchLevels } = require("./functions/searchLevels.js");
17
25
 
18
- module.exports.dlLevel = dlLevel;
26
+ module.exports.dlLevel = dlLevel; // to fix
19
27
  module.exports.getSongInfo = getSongInfo;
20
28
  module.exports.getOfficialSongInfo = getOfficialSongInfo;
21
29
  module.exports.decURLSafeBase64 = decURLSafeBase64;
22
30
  module.exports.encURLSafeBase64 = encURLSafeBase64;
23
31
  module.exports.getDailyLevel = getDailyLevel;
24
32
  module.exports.getWeeklyDemon = getWeeklyDemon;
25
- module.exports.getProfile = getProfile;
33
+ module.exports.getProfile = getProfile; // to fix
26
34
  module.exports.reportLevel = reportLevel;
27
35
  module.exports.getComments = getComments;
28
36
  module.exports.getCommentHistory = getCommentHistory;
@@ -30,4 +38,12 @@ module.exports.getGauntlets = getGauntlets;
30
38
  module.exports.getAccountPosts = getAccountPosts;
31
39
  module.exports.uploadAccountPost = uploadAccountPost;
32
40
  module.exports.uploadComment = uploadComment;
33
- module.exports.getMapPacks = getMapPacks;
41
+ module.exports.getMapPacks = getMapPacks;
42
+ module.exports.blockUser = blockUser;
43
+ module.exports.getLevelByID = getLevelByID;
44
+ module.exports.getTop100 = getTop100;
45
+ module.exports.getCreatorScores = getCreatorScores;
46
+ module.exports.updateLevelDesc = updateLevelDesc;
47
+ module.exports.deleteAccountPost = deleteAccountPost;
48
+ module.exports.getUserLevels = getUserLevels;
49
+ module.exports.searchLevels = searchLevels;
@@ -6,11 +6,16 @@ module.exports = {
6
6
  let postContent = post.split("2~")[1].split("~4~")[0];
7
7
  let likes = post.split("~4~")[1].split("~9~")[0];
8
8
  let age = post.split("~9~")[1].split("~6~")[0];
9
+ let id = post.split("~6~")[1];
10
+
11
+ if(id.includes("~")) id = post.split("~6~")[2];
12
+ if(id.includes("#")) id = id.split("#")[0];
9
13
 
10
14
  const result = {
11
15
  content: bs.decode(postContent.replace(/_/g, '/').replace(/-/g, '+')).trim(),
12
16
  likes: Number(likes),
13
- age: age
17
+ age: age,
18
+ id: Number(id)
14
19
  }
15
20
 
16
21
  return result;
@@ -0,0 +1,166 @@
1
+ module.exports = {
2
+ decodeLevel:
3
+ function(level){
4
+ const bs = require("js-base64");
5
+
6
+ let spl = level.split(':');
7
+ let levelInfo = [];
8
+ for(let i =0;i<spl.length;i++) {
9
+ if(i%2!=0) {
10
+ levelInfo.push(spl[i-1]+`:`+spl[i]);
11
+ }
12
+ }
13
+
14
+ let id = levelInfo[0].split("1:")[1];
15
+ let name = levelInfo[1].split("2:")[1];
16
+ let version = levelInfo[2].split("5:")[1];
17
+ let difficulty = levelInfo[5].split("9:")[1];
18
+ let downloads = levelInfo[6].split("10:")[1];
19
+ let officialSong = levelInfo[7].split("12:")[1];
20
+ let gameVersion = levelInfo[8].split("13:")[1];
21
+ let likes = levelInfo[9].split("14:")[1];
22
+ let demonBool = levelInfo[10].split("17:")[1];
23
+ let stars = levelInfo[13].split("18:")[1];
24
+ let ftrd = levelInfo[14].split("19:")[1];
25
+ let epic = levelInfo[15].split("42:")[1];
26
+ let objs = levelInfo[16].split("45:")[1];
27
+ let desc = levelInfo[17].split("3:")[1];
28
+ let length = levelInfo[18].split("15:")[1];
29
+ let copiedID = levelInfo[19].split("30:")[1];
30
+ let twoPlayer = levelInfo[20].split("31:")[1];
31
+ let coins = levelInfo[21].split("37:")[1];
32
+ let verifiedCoins = levelInfo[22].split("38:")[1];
33
+ let starsRequested = levelInfo[23].split("39:")[1];
34
+ let customSong = levelInfo[26].split("35:")[1].split("#")[0];
35
+ let author = "-";
36
+
37
+ if(levelInfo.length == 29) {
38
+ author = levelInfo[27].split(":")[0];
39
+ }
40
+
41
+ let disliked = false;
42
+ if(likes.includes("-")) disliked = true;
43
+
44
+ if(verifiedCoins == "0") verifiedCoins = false;
45
+ if(verifiedCoins == "1") verifiedCoins = true;
46
+
47
+ let demonBoolDecoding = {
48
+ '1': true,
49
+ '': false,
50
+ '0': false
51
+ }
52
+
53
+ let featuredDecoding = {
54
+ "0": false,
55
+ "1": true,
56
+ undefined: true
57
+ }
58
+
59
+ let featured = featuredDecoding[ftrd];
60
+ if(featured == undefined) featured = true;
61
+
62
+ let difficultyDecoding = {
63
+ "-10": "Auto",
64
+ "0": "Unrated",
65
+ "10": "Easy",
66
+ "20": "Normal",
67
+ "30": "Hard",
68
+ "40": "Harder",
69
+ "50": "Insane"
70
+ }
71
+
72
+ if(demonBoolDecoding[demonBool] == true) {
73
+ difficultyDecoding = {
74
+ "10": "Easy Demon",
75
+ "20": "Medium Demon",
76
+ "30": "Hard Demon",
77
+ "40": "Insane Demon",
78
+ "50": "Extreme Demon"
79
+ }
80
+ }
81
+
82
+ const lengthDecoding = {
83
+ "0": "Tiny",
84
+ "1": "Short",
85
+ "2": "Medium",
86
+ "3": "Long",
87
+ "4": "XL"
88
+ }
89
+
90
+ if(lengthDecoding[length] == undefined) length = level.split(":15:")[2].split(":30")[0];
91
+
92
+ const decodeGameVersion = {
93
+ "1": "Pre-1.7",
94
+ "2": "Pre-1.7",
95
+ "3": "Pre-1.7",
96
+ "4": "Pre-1.7",
97
+ "5": "Pre-1.7",
98
+ "6": "Pre-1.7",
99
+ "7": "Pre-1.7",
100
+ "10": "1.7",
101
+ "18": "1.8",
102
+ "19": "1.9",
103
+ "20": "2.0",
104
+ "21": "2.1"
105
+ }
106
+
107
+ const { getOfficialSongInfo } = require("../functions/getOfficialSongInfo.js");
108
+
109
+ let song;
110
+
111
+ if(Number(officialSong) > 0) {
112
+ song = getOfficialSongInfo(Number(officialSong) + 1);
113
+ }
114
+
115
+ if(Number(officialSong) == 0 && Number(customSong) == 0) {
116
+ song = getOfficialSongInfo(1);
117
+ }
118
+
119
+ if(Number(customSong) > 0) {
120
+ let songName = level.split("~|~2~|~")[1].split("~|~3~|~")[0]
121
+ let songId = Number(level.split("#1~|~")[1].split("~|~2~|~")[0])
122
+ let artist = level.split("~|~4~|~")[1].split("~|~5~|~")[0]
123
+ let artistId = Number(level.split("~|~3~|~")[1].split("~|~4~|~")[0])
124
+ let size = `${level.split("~|~5~|~")[1].split("~|~6~|~")[0]} MB`
125
+ let link = decodeURIComponent(level.split("~|~10~|~")[1].split("~|~7~|~")[0])
126
+
127
+ let songinfo = {
128
+ "name": songName,
129
+ "id": songId,
130
+ "artist": artist,
131
+ "artistId": artistId,
132
+ "fileSize": size,
133
+ "link": link
134
+ }
135
+
136
+ song = songinfo;
137
+ }
138
+
139
+ const result = {
140
+ id: Number(id),
141
+ name: name,
142
+ description: bs.decode(desc), //.replace(/-/g, "+").replace(/_/g, "/")
143
+ creator: author,
144
+ level_version: Number(version),
145
+ difficulty: difficultyDecoding[difficulty],
146
+ stars: Number(stars),
147
+ downloads: Number(downloads),
148
+ likes: Number(likes),
149
+ disliked: disliked,
150
+ length: lengthDecoding[length],
151
+ demon: demonBoolDecoding[demonBool],
152
+ featured: featured,
153
+ epic: demonBoolDecoding[epic],
154
+ objects: Number(objs),
155
+ stars_requested: Number(starsRequested),
156
+ game_version: decodeGameVersion[gameVersion],
157
+ copied: Number(copiedID),
158
+ two_p: demonBoolDecoding[twoPlayer],
159
+ coins: Number(coins),
160
+ verified_coins: verifiedCoins,
161
+ song: song,
162
+ }
163
+
164
+ return result;
165
+ }
166
+ }
@@ -0,0 +1,53 @@
1
+ module.exports = {
2
+ decodeUserResult:
3
+ function(user) {
4
+ let sec = user.split(":16:")[1]
5
+ if(user.split(":16:")[2] != undefined) sec = user.split(":16:")[2]
6
+ let userWoSkins = `${user.split(":9:")[0]}:16:${sec}`
7
+
8
+ let name = userWoSkins.split(":")[1].split(":2:")[0];
9
+ let playerID = userWoSkins.split(":2:")[1].split(":13:")[0];
10
+ let coins = userWoSkins.split(":13:")[1].split(":17:")[0];
11
+ let userCoins = userWoSkins.split(":17:")[1].split(":6:")[0];
12
+ let rank = userWoSkins.split(":6:")[1].split(":9:")[0];
13
+ let accID = userWoSkins.split(":16:")[1].split(":3:")[0];
14
+ let stars = userWoSkins.split(":3:")[1].split(":8:")[0];
15
+ let cp = userWoSkins.split(":8:")[1].split(":46:")[0];
16
+ let diamonds = userWoSkins.split(":46:")[1].split(":4:")[0];
17
+ let demons = userWoSkins.split(":4:")[1]
18
+
19
+ if(userWoSkins.split(":3:")[1] != undefined) {
20
+ if(userWoSkins.split(":3:")[1].split(":").length < 6) stars = userWoSkins.split(":2:")[1].split(":8:")[0];
21
+ }
22
+ if(rank.includes(":16:")) rank = rank.split(":16:")[0];
23
+ if(userWoSkins.split(":6:")[2] != undefined) {
24
+ if(rank.includes(":")) rank = userWoSkins.split(":6:")[2].split(":9:")[0];
25
+ }
26
+
27
+ if(demons.includes(":")) demons = userWoSkins.split(":4:")[2]
28
+ if(userCoins.includes(":6")) userCoins = userCoins.split(":6")[0];
29
+ if(accID.startsWith("16:")) accID = accID.split("16:")[1];
30
+ if(stars.includes(":3:")) stars = stars.split(":3:")[1];
31
+ if(stars.includes("16:")) stars = userWoSkins.split(":3:")[2].split(":8:")[0];
32
+ if(diamonds.includes(":")) diamonds = userWoSkins.split(":46:")[2].split(":4:")[0];
33
+ if(cp.includes(":")) cp = userWoSkins.split(":8:")[2].split(":46:")[0];
34
+ if(rank.startsWith("16:")) rank = "9"
35
+ if(rank.includes(":16:")) rank = rank.split(":16:")[0];
36
+ if(accID.includes(":")) accID = userWoSkins.split(":16:")[2].split(":3:")[0];
37
+
38
+ const result = {
39
+ username: name.trim(),
40
+ playerID: Number(playerID),
41
+ accountID: Number(accID),
42
+ rank: Number(rank),
43
+ stars: Number(stars),
44
+ diamonds: Number(diamonds),
45
+ secretCoins: Number(coins),
46
+ userCoins: Number(userCoins),
47
+ demons: Number(demons),
48
+ creatorPoints: Number(cp)
49
+ }
50
+
51
+ return result;
52
+ }
53
+ }
@@ -207,24 +207,6 @@
207
207
  "artist": "F-777",
208
208
  "link": "https://www.youtube.com/watch?v=B8YkwDbGBr8"
209
209
  },
210
- "ps": {
211
- "name": "Press Start",
212
- "id": "Level 1 (Geometry Dash: SubZero)",
213
- "artist": "MDK",
214
- "link": "https://www.youtube.com/watch?v=XoLouT7TqZY"
215
- },
216
- "ne": {
217
- "name": "Nock Em",
218
- "id": "Level 2 (Geometry Dash: SubZero)",
219
- "artist": "Bossfight",
220
- "link": "https://www.youtube.com/watch?v=ePv2X_CCaGg"
221
- },
222
- "pt": {
223
- "name": "Power Trip",
224
- "id": "Level 3 (Geometry Dash: SubZero)",
225
- "artist": "Boom Kitty",
226
- "link": "https://www.youtube.com/watch?v=l6OsF7RlQb4"
227
- },
228
210
  "unknown": {
229
211
  "name": "Unknown",
230
212
  "id": "This song is not defined by RobTop. In game it returns \"Back on Track\".",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gj-boomlings-api",
3
- "version": "0.5.0",
3
+ "version": "1.0.1",
4
4
  "description": "A Node.js module that allows you to fetch boomlings.com easily",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -15,7 +15,7 @@
15
15
  "bugs": {
16
16
  "url": "https://github.com/shikoshib/gj-boomlings-api/issues"
17
17
  },
18
- "homepage": "https://github.com/shikoshib/gj-boomlings-api",
18
+ "homepage": "https://github.com/shikoshib/gj-boomlings-api#readme",
19
19
  "keywords": [
20
20
  "geometrydash",
21
21
  "gd",