gj-boomlings-api 1.0.1 → 1.0.3

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/docs/dlLevel.md CHANGED
@@ -21,8 +21,8 @@ gd.dlLevel(58825144).then(console.log);
21
21
  level_version: 2,
22
22
  difficulty: 'Extreme Demon',
23
23
  stars: 10,
24
- downloads: 2587512,
25
- likes: 106611,
24
+ downloads: 2640560,
25
+ likes: 107918,
26
26
  disliked: false,
27
27
  length: 'XL',
28
28
  password: '000007',
@@ -30,8 +30,8 @@ gd.dlLevel(58825144).then(console.log);
30
30
  featured: false,
31
31
  epic: false,
32
32
  objects: 37838,
33
- uploaded: '2 years',
34
- updated: '2 years',
33
+ uploaded: '3 years',
34
+ updated: '3 years',
35
35
  stars_requested: 10,
36
36
  game_version: '2.1',
37
37
  ldm: false,
@@ -1,6 +1,6 @@
1
1
  # Level object
2
2
 
3
- Used by ```dlLevel()```.
3
+ Used by `dlLevel()`, `getLevelByID()` and `getUserLevels()`.
4
4
 
5
5
  ## Example
6
6
  ```
@@ -12,8 +12,8 @@ Used by ```dlLevel()```.
12
12
  level_version: 2,
13
13
  difficulty: 'Extreme Demon',
14
14
  stars: 10,
15
- downloads: 2587512,
16
- likes: 106611,
15
+ downloads: 2640560,
16
+ likes: 107918,
17
17
  disliked: false,
18
18
  length: 'XL',
19
19
  password: '000007',
@@ -21,8 +21,8 @@ Used by ```dlLevel()```.
21
21
  featured: false,
22
22
  epic: false,
23
23
  objects: 37838,
24
- uploaded: '2 years',
25
- updated: '2 years',
24
+ uploaded: '3 years',
25
+ updated: '3 years',
26
26
  stars_requested: 10,
27
27
  game_version: '2.1',
28
28
  ldm: false,
@@ -60,11 +60,11 @@ Used by ```dlLevel()```.
60
60
 
61
61
  ```likes``` - the amount of level likes.
62
62
 
63
- ```disliked``` - a boolean that shows if the level is disliked. Returns ```true``` if the like amount is negative, otherwise it's ```false```.
63
+ ```disliked``` - a boolean that shows if the level is disliked. Returns `true` if the like amount is negative, otherwise it's `false`.
64
64
 
65
65
  ```length``` - the level length.
66
66
 
67
- ```password``` - the level password. It may return ```'Non-copyable'``` if the level is not copyable, or ```'1'``` if the level is free to copy.
67
+ ```password``` - the level password. It may return `''` (an empty string) if the level is not copyable, or `'1'` if the level is free to copy.
68
68
 
69
69
  ```demon``` - a boolean that shows if the level is demon.
70
70
 
@@ -78,13 +78,13 @@ Used by ```dlLevel()```.
78
78
 
79
79
  ```updated``` - when the level has been last updated.
80
80
 
81
- ```stars_requested``` - basically how many stars the creator has requested. Returns ```0``` if no stars have been requested.
81
+ ```stars_requested``` - basically how many stars the creator has requested. Returns`0` if no stars have been requested.
82
82
 
83
83
  ```game_version``` - the version required to play the level. Returns `Pre-1.7` if the level has been uploaded or last updated earlier, than 1.7 came out.
84
84
 
85
85
  ```ldm``` - a boolean that shows if the level has a "Low Detail Mode" checkbox.
86
86
 
87
- ```copied``` - the original level ID, that got copied. Returns ```0``` if the level is already original.
87
+ ```copied``` - the original level ID, that got copied. Returns `0` if the level is already original.
88
88
 
89
89
  ```two_p``` - a boolean that shows if the level is in the 2-player mode.
90
90
 
@@ -4,6 +4,7 @@ module.exports = {
4
4
  const bs = require("js-base64")
5
5
  if(!level || level == "") throw new Error("Please provide a level ID.");
6
6
  if(isNaN(level)) throw new Error("The level parameter should be a number.");
7
+
7
8
  const axios = require("axios");
8
9
  const { headers, server } = require("../config.json");
9
10
 
@@ -22,40 +23,63 @@ module.exports = {
22
23
  headers: headers
23
24
  })
24
25
 
25
- if(res.data == -1) throw new Error("-1 Not found.");
26
- if(res.data.toLowerCase() == "error code: 1020") throw new Error("1020 error: Request denied.");
27
- if(res.data.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).");
28
- let split1 = res.data.split("1:")[1]; // id
29
- let split2 = res.data.split(":2:")[1]; // name
30
- let split3 = res.data.split(":3:")[1]; // description
31
- let split4 = res.data.split(":5:")[1]; // level version
32
- let split5 = res.data.split(":9:")[1]; // difficulty
33
- let split6 = res.data.split(":18:")[1]; // stars
34
- let split7 = res.data.split("0:10:")[1]; // downloads
35
- let split8 = res.data.split(":14:")[1]; // likes
36
- let split9 = res.data.split(":15:")[1]; // length
37
- let split10 = res.data.split(":27:")[1]; // password
38
- let split11 = res.data.split(":17:")[1]; // demon or not
39
- let split12 = res.data.split(":19:")[1]; // featured
40
- let split13 = res.data.split(":42:")[1]; // epic
41
- let split14 = res.data.split(":45:")[1]; // objects
42
- let split15 = res.data.split(":28:")[1]; // uploaded
43
- let split16 = res.data.split(":29:")[1]; // updated
44
- let split17 = res.data.split(":39:")[1]; // stars requested
45
- let split18 = res.data.split(":40:")[1]; // ldm
46
- let split19 = res.data.split(":30:")[1]; // copied from
47
- let split20 = res.data.split(":31:")[1]; // two player
48
- let split21 = res.data.split(":37:")[1]; // coins
49
- let split22 = res.data.split(":38:")[1]; // verified coins
50
- let split23 = res.data.split(":6:")[1]; // player id
51
- let split24 = res.data.split(":13:")[1]; // game version
52
- let split25 = res.data.split(":12:")[1]; // official song id
53
- let split26 = res.data.split(":35:")[1]; // custom song id
54
-
55
- if(split25.split(":13:")[0].includes(":")) split25 = res.data.split(":12:")[2];
56
- if(split26.split(":36:")[0].includes(":")) split26 = res.data.split(":35:")[2];
26
+ let spl = res.data.split(":");
27
+ let levelInfo = [];
28
+ for(let i =0;i<spl.length;i++) {
29
+ if(i%2!=0) {
30
+ levelInfo.push(spl[i-1]+`:`+spl[i]);
31
+ }
32
+ }
33
+
34
+ let id = levelInfo[0].split("1:")[1];
35
+ let name = levelInfo[1].split("2:")[1];
36
+ let description = bs.decode(levelInfo[2].split("3:")[1])
37
+ let version = levelInfo[4].split("5:")[1];
38
+ let difficulty = levelInfo[7].split("9:")[1];
39
+ let downloads = levelInfo[8].split("10:")[1];
40
+ let officialSong = levelInfo[9].split("12:")[1];
41
+ let gameVersion = levelInfo[10].split("13:")[1];
42
+ let likes = levelInfo[11].split("14:")[1];
43
+ let demonBool = levelInfo[12].split("17:")[1];
44
+ let stars = levelInfo[15].split("18:")[1];
45
+ let ftrd = levelInfo[16].split("19:")[1];
46
+ let epic = levelInfo[17].split("42:")[1];
47
+ let objects = levelInfo[18].split("45:")[1];
48
+ let length = levelInfo[19].split("15:")[1];
49
+ let copiedID = levelInfo[20].split("30:")[1];
50
+ let twoPlayer = levelInfo[21].split("31:")[1];
51
+ let uploaded = levelInfo[22].split("28:")[1];
52
+ let updated = levelInfo[23].split("29:")[1];
53
+ let customSong = levelInfo[24].split("35:")[1];
54
+ let coins = levelInfo[26].split("37:")[1];
55
+ let verifiedCoins = levelInfo[27].split("38:")[1];
56
+ let starsRequested = levelInfo[28].split("39:")[1];
57
+ let ldm = levelInfo[31].split("40:")[1];
58
+ let password = xor.decrypt(levelInfo[32].split("27:")[1].split("#")[0], 26364);
59
+
60
+ let disliked = false;
61
+ if(likes.includes("-")) disliked = true;
62
+
63
+ if(verifiedCoins == "0") verifiedCoins = false;
64
+ if(verifiedCoins == "1") verifiedCoins = true;
65
+
66
+ let demonBoolDecoding = {
67
+ '1': true,
68
+ '': false,
69
+ '0': false
70
+ }
71
+
72
+ let featuredDecoding = {
73
+ "0": false,
74
+ "1": true,
75
+ undefined: true
76
+ }
77
+
78
+ let featured = featuredDecoding[ftrd];
79
+ if(featured == undefined) featured = true;
57
80
 
58
81
  let difficultyDecoding = {
82
+ "-10": "Auto",
59
83
  "0": "Unrated",
60
84
  "10": "Easy",
61
85
  "20": "Normal",
@@ -64,7 +88,7 @@ module.exports = {
64
88
  "50": "Insane"
65
89
  }
66
90
 
67
- if(split11.split(":43:")[0] == "1") {
91
+ if(demonBoolDecoding[demonBool] == true) {
68
92
  difficultyDecoding = {
69
93
  "10": "Easy Demon",
70
94
  "20": "Medium Demon",
@@ -73,28 +97,7 @@ module.exports = {
73
97
  "50": "Extreme Demon"
74
98
  }
75
99
  }
76
-
77
- const binaryBool = {
78
- undefined: false,
79
- "0": false,
80
- "1": true
81
- };
82
-
83
- const featuredDecoding = {
84
- undefined: true,
85
- "0": false,
86
- "1": true
87
- }
88
-
89
- let featured = featuredDecoding[split12.split(":42:")[0]];
90
- if(featured == undefined) featured = true;
91
-
92
- let demonBool = binaryBool[split11.split(":43:")[0]];
93
- if(split11.split(":43:")[0] == "") demonBool = false;
94
-
95
- let ldm = binaryBool[split18.split(":27")[0]]
96
- if(ldm == undefined) ldm = false;
97
-
100
+
98
101
  const lengthDecoding = {
99
102
  "0": "Tiny",
100
103
  "1": "Short",
@@ -102,59 +105,15 @@ module.exports = {
102
105
  "3": "Long",
103
106
  "4": "XL"
104
107
  }
105
- if(lengthDecoding[split9.split(":30:")[0]] == undefined) split9 = res.data.split(":15:")[2];
106
-
107
- let desc = bs.decode(split3.split(":4:")[0].replace(/_/g, '/').replace(/-/g, '+'));
108
- if(desc == "") desc = "(No description provided)"
109
-
110
- let likes = split8.split(":17:")[0];
111
- let dislikedBool;
112
- if(likes.includes("-")) {
113
- dislikedBool = true;
114
- } else {
115
- dislikedBool = false;
116
- }
117
-
118
- const decryptedPass = xor.decrypt(split10, 26364);
119
- if (decryptedPass.length > 1) split10 = decryptedPass.slice(1);
120
- else split10 = decryptedPass;
121
- if (decryptedPass.length > 7) split10 = "Non-copyable";
122
-
123
- const authData = {
124
- gameVersion: 21,
125
- binaryVersion: 35,
126
- gdw: 0,
127
- str: split23.split(":8:")[0],
128
- secret: "Wmfd2893gb7"
129
- }
130
- let auth = await axios.post(server + "getGJUsers20.php", authData, {
131
- headers: headers
132
- })
133
- let authname;
134
- if(auth.data == "-1") {
135
- authname = "-"
136
- } else if(!auth.data.startsWith("-")) {
137
- authname = auth.data.split("1:")[1].split(":2:")[0];
138
- }
139
-
140
- const { getSongInfo } = require("./getSongInfo.js");
141
- const { getOfficialSongInfo } = require("./getOfficialSongInfo.js");
142
- let song;
143
-
144
- let copiedId = split19.split(":31:")[0];
145
- if(copiedId.includes(":")) split19 = res.data.split(":30:")[2];
146
-
147
- let starsCount = split6.split(":19:")[0];
148
- if(starsCount.includes(":")) split6 = res.data.split(":18:")[2];
149
108
 
150
109
  const decodeGameVersion = {
151
- "1": "1.0",
152
- "2": "1.1",
153
- "3": "1.2",
154
- "4": "1.3",
155
- "5": "1.4",
156
- "6": "1.5",
157
- "7": "1.6",
110
+ "1": "Pre-1.7",
111
+ "2": "Pre-1.7",
112
+ "3": "Pre-1.7",
113
+ "4": "Pre-1.7",
114
+ "5": "Pre-1.7",
115
+ "6": "Pre-1.7",
116
+ "7": "Pre-1.7",
158
117
  "10": "1.7",
159
118
  "18": "1.8",
160
119
  "19": "1.9",
@@ -162,79 +121,40 @@ module.exports = {
162
121
  "21": "2.1"
163
122
  }
164
123
 
165
- let objs = split14.split(":15:")[0];
166
- if(Number(objs) == NaN) objs = split14.split(":15:")[1];
167
-
168
- let offSongID = Number(split25.split(":13:")[0]) + 1;
169
- if(split25.split(":13:")[0] == "0" && split26.split(":36:")[0] != "0") {
170
- try {
171
- song = await getSongInfo(split26.split(":36:")[0]);
172
- } catch(err) {
173
- let songReq = await axios.post(server + 'getGJLevels21.php', {
174
- gameVersion: 21,
175
- binaryVersion: 35,
176
- gdw: 0,
177
- type: 0,
178
- str: level,
179
- secret: "Wmfd2893gb7"
180
- }, {
181
- headers: headers
182
- })
183
- if(!songReq.data.includes("~|~")) {
184
- song = {
185
- "name": "Unknown",
186
- "id": Number(split26.split(":36:")[0]),
187
- "artist": "Unknown",
188
- "artistId": null,
189
- "fileSize": "0MB",
190
- "link": null
191
- }
192
- } else {
193
- song = {
194
- "name": songReq.data.split("|~2~|~")[1].split("~|~3~|~")[0],
195
- "id": Number(songReq.data.split("1~|~")[1].split("~|~2~|")[0]),
196
- "artist": songReq.data.split("~|~4~|~")[1].split("~|~5~|~")[0],
197
- "artistId": Number(songReq.data.split("~|~3~|~")[1].split("~|~4~|~")[0]),
198
- "fileSize": `${songReq.data.split("~|~5~|~")[1].split("~|~6~|~")[0]} MB`,
199
- "link": decodeURIComponent(songReq.data.split("~|~10~|~")[1].split("~|~7~|~")[0])
200
- }
201
- }
202
- }
203
- } else if(split25.split(":13:")[0] != "0" && split26.split(":36:")[0] == "0") {
204
- song = getOfficialSongInfo(offSongID);
205
- } else if(split25.split(":13:")[0] == "0" && split26.split(":36:")[0] == "0") {
206
- song = getOfficialSongInfo(1);
207
- }
208
-
209
- const result = {
210
- "id": Number(split1.split(":2:")[0]),
211
- "name": split2.split(":3:")[0].toString(),
212
- "description": desc.trim(),
213
- "creator": authname,
214
- "level_version": Number(split4.split(":6:")[0]),
215
- "difficulty": difficultyDecoding[split5.split(":10:")[0]].toString(),
216
- "stars": Number(split6.split(":19:")[0]),
217
- "downloads": Number(split7.split(":12:")[0]),
218
- "likes": Number(likes),
219
- "disliked": dislikedBool,
220
- "length": lengthDecoding[split9.split(":30:")[0]],
221
- "password": split10,
222
- "demon": demonBool,
223
- "featured": featured,
224
- "epic": featuredDecoding[split13.split(":45:")[0]],
225
- "objects": Number(objs),
226
- "uploaded": split15.split(":29:")[0],
227
- "updated": split16.split(":35:")[0],
228
- "stars_requested": Number(split17.split(":46:")[0]),
229
- "game_version": decodeGameVersion[split24.split(":14:")[0]],
230
- "ldm": ldm,
231
- "copied": Number(split19.split(":31:")[0]),
232
- "two_p": binaryBool[split20.split(":28:")[0]],
233
- "coins": Number(split21.split(":38:")[0]),
234
- "verified_coins": binaryBool[split22.split(":39:")[0]],
235
- "song": song
236
- }
237
-
238
- return result;
124
+ if(description == '') description = "(No description provided)";
125
+
126
+ const { getLevelByID } = require("./getLevelByID.js");
127
+ let basicInfoAboutLevel = await getLevelByID(id);
128
+
129
+ const result = {
130
+ id: Number(id),
131
+ name: name,
132
+ description: description,
133
+ creator: basicInfoAboutLevel.creator,
134
+ level_version: Number(version),
135
+ difficulty: difficultyDecoding[difficulty],
136
+ stars: Number(stars),
137
+ downloads: Number(downloads),
138
+ likes: Number(likes),
139
+ disliked: disliked,
140
+ length: lengthDecoding[length],
141
+ password: password.replace("1", ""),
142
+ demon: demonBoolDecoding[demonBool],
143
+ featured: featured,
144
+ epic: demonBoolDecoding[epic],
145
+ objects: Number(objects),
146
+ uploaded: uploaded,
147
+ updated: updated,
148
+ stars_requested: Number(starsRequested),
149
+ game_version: decodeGameVersion[gameVersion],
150
+ ldm: demonBoolDecoding[ldm],
151
+ copied: Number(copiedID),
152
+ two_p: demonBoolDecoding[twoPlayer],
153
+ coins: Number(coins),
154
+ verified_coins: verifiedCoins,
155
+ song: basicInfoAboutLevel.song,
156
+ }
157
+
158
+ return result;
239
159
  }
240
160
  }
@@ -36,52 +36,33 @@ module.exports = {
36
36
  if(res.data.toLowerCase() == "error code: 1020") throw new Error("1020 error: Request denied.");
37
37
  if(res.data.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).")
38
38
 
39
- let dataWoSkins = `${res.data.split("21:")[0]}${res.data.split(":48:")[1]}`;
40
-
41
- let username = dataWoSkins.split("1:")[1].split(":2:")[0];
42
- let playerID = dataWoSkins.split(":2:")[1].split(":13:")[0];
43
- let goldCoins = dataWoSkins.split(":13:")[1].split(":17:")[0];
44
- let silverCoins = dataWoSkins.split(":17:")[1].split(":10:")[0];
45
- let stars = dataWoSkins.split(":3:")[1].split(":46:")[0];
46
- let diamonds = dataWoSkins.split(":46:")[1].split(":4:")[0];
47
- let demons = dataWoSkins.split(":4:")[1].split(":8:")[0];
48
- let cps = dataWoSkins.split(":8:")[1].split(":18:")[0]; // clicks per second lmao
49
- let msgState = dataWoSkins.split(":18:")[1].split(":19:")[0];
50
- let friendsState = dataWoSkins.split(":19:")[1].split(":50:")[0];
51
- let commentHistoryState = dataWoSkins.split(":50:")[1].split(":20:")[0];
52
- let youtube = dataWoSkins.split(":20:")[1].split(":")[0];
53
- let rank = dataWoSkins.split(":30:")[1].split(":16:")[0];
54
- let accountID = dataWoSkins.split(":16:")[1].split(":31:")[0];
55
- let twitter = dataWoSkins.split(":44:")[1].split(":45:")[0];
56
- let twitch = dataWoSkins.split(":45:")[1].split(":49:")[0];
57
- let modState = dataWoSkins.split(":49:")[1].split(":29:")[0];
58
-
59
- if(youtube.includes(":")) youtube = dataWoSkins.split(":20:")[1].split(":")[0];
60
- if(twitter.includes(":")) twitter = dataWoSkins.split(":44:")[2].split(":45:")[0];
61
- if(twitch.includes(":")) twitch = dataWoSkins.split(":45:")[2].split(":49:")[0];
62
- if(goldCoins.includes(":")) goldCoins = dataWoSkins.split(":13:")[2].split(":17:")[0];
63
- if(goldCoins == "") goldCoins = dataWoSkins.split(":13:")[1].split(":17:")[1];
64
- if(silverCoins.includes(":")) silverCoins = dataWoSkins.split("17:")[2].split(":10:")[0];
65
- if(rank.includes(":")) rank = dataWoSkins.split(":30:")[2].split(":16:")[0];
66
- if(accountID.includes(":")) accountID = dataWoSkins.split(":16:")[2].split(":31:")[0];
67
- if(demons.includes(":")) demons = dataWoSkins.split(":4:")[2].split(":8:")[0];
68
- if(msgState.includes(":")) msgState = dataWoSkins.split(":18:")[2].split(":19:")[0];
69
- if(stars.includes(":")) stars = dataWoSkins.split("3:")[2].split(":46:")[0];
70
- if(modState.includes(":")) modState = dataWoSkins.split(":49:")[2].split(":29:")[0];
71
- if(dataWoSkins.split(":3:")[1].split(":46:")[0].startsWith("3:")) stars = dataWoSkins.split(":3:")[1].split("3:")[1].split(":46:")[0];
72
- if(dataWoSkins.split("3:")[2].split(":46:")[0].includes(":")) {
73
- stars = dataWoSkins.split("3:")[3].split(":46:")[0];
74
- } else {
75
- stars = stars;
39
+ let spl = res.data.split(':');
40
+ let userInfo = [];
41
+ for(let i =0;i<spl.length;i++) {
42
+ if(i%2!=0) {
43
+ userInfo.push(spl[i-1]+`:`+spl[i]);
44
+ }
76
45
  }
77
46
 
78
- if(dataWoSkins.split("3:")[3] !== undefined) {
79
- if(dataWoSkins.split("3:")[3].split(":46:")[0] == "") {
80
- stars = dataWoSkins.split("3:")[4].split(":46:")[0];
81
- } else {
82
- stars = stars;
83
- }
84
- }
47
+ let username = userInfo[0].split("1:")[1];
48
+ let playerID = userInfo[1].split("2:")[1];
49
+ let goldCoins = userInfo[2].split("13:")[1];
50
+ let silverCoins = userInfo[3].split("17:")[1];
51
+ let p1col = userInfo[4].split("10:")[1];
52
+ let p2col = userInfo[5].split("11:")[1];
53
+ let stars = userInfo[6].split("3:")[1];
54
+ let diamonds = userInfo[7].split("46:")[1];
55
+ let demons = userInfo[8].split("4:")[1];
56
+ let cps = userInfo[9].split("8:")[1]; // clicks per second lmao
57
+ let msgState = userInfo[10].split("18:")[1];
58
+ let friendsState = userInfo[11].split("19:")[1];
59
+ let commentHistoryState = userInfo[12].split("50:")[1];
60
+ let youtube = userInfo[13].split("20:")[1];
61
+ let rank = userInfo[23].split("30:")[1];
62
+ let accountID = userInfo[24].split("16:")[1];
63
+ let twitter = userInfo[26].split("44:")[1];
64
+ let twitch = userInfo[27].split("45:")[1];
65
+ let modState = userInfo[28].split("49:")[1];
85
66
 
86
67
  let ytLnk = `htps://youtube.com/channel/${youtube}`;
87
68
  let twitterLnk = `https://twitter.com/${twitter}`;
@@ -116,6 +97,8 @@ module.exports = {
116
97
  playerID: Number(playerID),
117
98
  accountID: Number(accountID),
118
99
  rank: Number(rank),
100
+ color1: Number(p1col),
101
+ color2: Number(p2col),
119
102
  stars: Number(stars),
120
103
  diamonds: Number(diamonds),
121
104
  secretCoins: Number(goldCoins),
package/index.js CHANGED
@@ -1,3 +1,6 @@
1
+ console.log('\x1b[32m%s\x1b[40m', 'Thanks for using gj-boomlings-api!\nhttps://github.com/shikoshib/gj-boomlings-api');
2
+ console.log('\x1b[37m%s\x1b[0m', '');
3
+
1
4
  const { dlLevel } = require("./functions/dlLevel.js");
2
5
  const { getSongInfo } = require("./functions/getSongInfo.js");
3
6
  const { getOfficialSongInfo } = require("./functions/getOfficialSongInfo.js");
@@ -23,7 +26,7 @@ const { deleteAccountPost } = require("./functions/deleteAccountPost.js");
23
26
  const { getUserLevels } = require("./functions/getUserLevels.js");
24
27
  const { searchLevels } = require("./functions/searchLevels.js");
25
28
 
26
- module.exports.dlLevel = dlLevel; // to fix
29
+ module.exports.dlLevel = dlLevel;
27
30
  module.exports.getSongInfo = getSongInfo;
28
31
  module.exports.getOfficialSongInfo = getOfficialSongInfo;
29
32
  module.exports.decURLSafeBase64 = decURLSafeBase64;
@@ -87,8 +87,6 @@ module.exports = {
87
87
  "4": "XL"
88
88
  }
89
89
 
90
- if(lengthDecoding[length] == undefined) length = level.split(":15:")[2].split(":30")[0];
91
-
92
90
  const decodeGameVersion = {
93
91
  "1": "Pre-1.7",
94
92
  "2": "Pre-1.7",
@@ -1,20 +1,28 @@
1
1
  module.exports = {
2
2
  decodeMapPack:
3
3
  function(mp) {
4
- let name = mp.split(":2:")[1].split(":3:")[0];
5
- let unarrayedList = mp.split(":3:")[1].split(":4:")[0].split(":4")[0];
6
- let stars = mp.split(":4:")[1].split(":5:")[0];
7
- let coins = mp.split(":5:")[1].split(":6:")[0];
8
- let difficulty = mp.split(":6:")[1].split(":7:")[0];
9
4
 
10
- if(unarrayedList.includes(":")) unarrayedList = mp.split(":3:")[2].split(":4:")[0]
5
+ let spl = mp.split(':');
6
+ let mpInfo = [];
7
+ for(let i =0;i<spl.length;i++) {
8
+ if(i%2!=0) {
9
+ mpInfo.push(spl[i-1]+`:`+spl[i]);
10
+ }
11
+ }
11
12
 
13
+ let mappackID = mpInfo[0].split("1:")[1];
14
+ let name = mpInfo[1].split("2:")[1];
15
+ let unarrayedList = mpInfo[2].split("3:")[1];
16
+ let stars = mpInfo[3].split("4:")[1];
17
+ let coins = mpInfo[4].split("5:")[1];
18
+ let difficulty = mpInfo[5].split("6:")[1];
19
+ let txtCol = mpInfo[6].split("7:")[1];
20
+ let barCol = mpInfo[7].split("8:")[1];
21
+
12
22
  let firstLvl = unarrayedList.split(",")[0];
13
23
  let secondLvl = unarrayedList.split(",")[1].split(",")[0];
14
24
  let thirdLvl = unarrayedList.split(",")[2].split(",")[0];
15
25
 
16
- if(name.includes(":")) name = name.split("2:")[1]
17
-
18
26
  let difficultyDecoder = {
19
27
  "0": "Auto",
20
28
  "1": "Easy",
@@ -29,25 +37,29 @@ module.exports = {
29
37
  "10": "Extreme Demon",
30
38
  }
31
39
 
32
- if(coins.startsWith("5:")) {
33
- coins = coins.split("5:")[1];
34
- }
40
+ function rgbToHEX(color) {
41
+ let r = color.split(",")[0];
42
+ let g = color.split(",")[1].split(",")[0];
43
+ let b = color.split(",")[2];
35
44
 
36
- if(mp.split(":5:")[2] !== undefined) {
37
- if(coins.includes(":")) {
38
- coins = mp.split(":5:")[2].split(":6:")[0];
39
- }
40
- }
45
+ if(b.includes("#")) b = b.split("#")[0]
41
46
 
42
- if(coins.startsWith("5:")) coins = coins.split("5:")[1];
43
- if(coins.startsWith("7:")) coins = mp.split(":5:")[1].split(":6:")[0];
44
- if(coins.endsWith(":6")) coins = coins.split(":6")[0];
47
+ let rHex = Number(r).toString(16);
48
+ let gHex = Number(g).toString(16);
49
+ let bHex = Number(b).toString(16);
50
+
51
+ return `#${rHex.length == 1 ? "0" + rHex : rHex}${gHex.length == 1 ? "0" + gHex : gHex}${bHex.length == 1 ? "0" + bHex : bHex}`.toUpperCase();
52
+ }
45
53
 
46
54
  const result = {
47
55
  name: name,
56
+ id: Number(mappackID),
48
57
  levels: [Number(firstLvl),Number(secondLvl),Number(thirdLvl)],
49
58
  stars: Number(stars),
50
- coins: Number(coins)
59
+ coins: Number(coins),
60
+ difficulty: difficultyDecoder[difficulty],
61
+ textColor: rgbToHEX(txtCol),
62
+ barColor: rgbToHEX(barCol)
51
63
  }
52
64
 
53
65
  return result;
@@ -1,45 +1,34 @@
1
1
  module.exports = {
2
2
  decodeUserResult:
3
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];
4
+ let spl = user.split(':');
5
+ let userInfo = [];
6
+ for(let i =0;i<spl.length;i++) {
7
+ if(i%2!=0) {
8
+ userInfo.push(spl[i-1]+`:`+spl[i]);
9
+ }
25
10
  }
26
11
 
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];
12
+ let name = userInfo[0].split("1:")[1];
13
+ let playerID = userInfo[1].split("2:")[1];
14
+ let coins = userInfo[2].split("13:")[1];
15
+ let userCoins = userInfo[3].split("17:")[1];
16
+ let p1col = userInfo[6].split("10:")[1];
17
+ let p2col = userInfo[7].split("11:")[1];
18
+ let rank = userInfo[4].split("6:")[1];
19
+ let accID = userInfo[10].split("16:")[1];
20
+ let stars = userInfo[11].split("3:")[1];
21
+ let cp = userInfo[12].split("8:")[1];
22
+ let diamonds = userInfo[13].split("46:")[1];
23
+ let demons = userInfo[14].split("4:")[1];
37
24
 
38
25
  const result = {
39
26
  username: name.trim(),
40
27
  playerID: Number(playerID),
41
28
  accountID: Number(accID),
42
29
  rank: Number(rank),
30
+ color1: Number(p1col),
31
+ color2: Number(p2col),
43
32
  stars: Number(stars),
44
33
  diamonds: Number(diamonds),
45
34
  secretCoins: Number(coins),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gj-boomlings-api",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "A Node.js module that allows you to fetch boomlings.com easily",
5
5
  "main": "index.js",
6
6
  "scripts": {