gj-boomlings-api 1.5.6 → 1.5.7

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.
@@ -7,6 +7,156 @@ module.exports = {
7
7
  * By the way, GD uses this for search results.
8
8
  * @param {*} id - The level ID.
9
9
  */
10
- getLevelByID:
11
- async function (id){if(!id)throw new Error("Please provide a level ID!");if(isNaN(id))throw new Error("The level ID should be a number!");const{gjReq}=require("../misc/gjReq.js");const{gjWReq}=require("../misc/gjWReq.js");const{secret}=require("../config.json");const{decB64}=require("../misc/decB64.js");const data={secret:secret,str:id,type:0};let res=await gjReq("getGJLevels21",data);if(res.data==-1)throw new Error("-1 Not found.");if(res.data=="error code: 1005"){res=await gjWReq("getLevelByID",id);if(res.status==403)throw new Error(res.data.error);return res.data}async function decodeLevel(l){let spl=l.split(":");let lInfo=[];for(let i=0;i<spl.length;i++){if(i%2!=0){lInfo.push(spl[i-1]+`:`+spl[i])}}let id=lInfo[0].split("1:")[1];let name=lInfo[1].split("2:")[1];let version=lInfo[2].split("5:")[1];let difficulty=lInfo[5].split("9:")[1];let downloads=lInfo[6].split("10:")[1];let officialSong=lInfo[7].split("12:")[1];let gameVersion=lInfo[8].split("13:")[1];let likes=lInfo[9].split("14:")[1];let demonBool=lInfo[10].split("17:")[1];let stars=lInfo[13].split("18:")[1];let ftrd=lInfo[14].split("19:")[1];let epic=lInfo[15].split("42:")[1];let objs=lInfo[16].split("45:")[1];let desc=lInfo[17].split("3:")[1];let length=lInfo[18].split("15:")[1];let copiedID=lInfo[19].split("30:")[1];let twoPlayer=lInfo[20].split("31:")[1];let coins=lInfo[21].split("37:")[1];let verifiedCoins=lInfo[22].split("38:")[1];let starsRequested=lInfo[23].split("39:")[1];let customSong=lInfo[26].split("35:")[1].split("#")[0];let author=lInfo.length==29?lInfo[27].split(":")[0]:"-";let disliked=likes.includes("-")?true:false;if(desc.includes("/"))desc=desc.split("/")[0];if(decB64(desc)=="")desc="KE5vIGRlc2NyaXB0aW9uIHByb3ZpZGVkKQ==";let featured=Boolean(Number(ftrd));let difficultyDecoding={"-10":"Auto",0:"Unrated",10:"Easy",20:"Normal",30:"Hard",40:"Harder",50:"Insane"};if(Boolean(Number(demonBool))){difficultyDecoding={10:"Easy Demon",20:"Medium Demon",30:"Hard Demon",40:"Insane Demon",50:"Extreme Demon"}}const lengthDecoding={0:"Tiny",1:"Short",2:"Medium",3:"Long",4:"XL"};const decodeGameVersion={10:"1.7",18:"1.8",19:"1.9",20:"2.0",21:"2.1",undefined:"Pre-1.7"};const{getOfficialSongInfo}=require("../functions/getOfficialSongInfo.js");let song;if(Number(officialSong)>0)song=getOfficialSongInfo(Number(officialSong)+1);if(Number(officialSong)==0&&Number(customSong)==0)song=getOfficialSongInfo(1);if(Number(customSong)>0){let songName=l.split("~|~2~|~")[1].split("~|~3~|~")[0];let songId=Number(l.split("#1~|~")[1].split("~|~2~|~")[0]);let artist=l.split("~|~4~|~")[1].split("~|~5~|~")[0];let artistId=Number(l.split("~|~3~|~")[1].split("~|~4~|~")[0]);let size=`${l.split("~|~5~|~")[1].split("~|~6~|~")[0]} MB`;let link=decodeURIComponent(l.split("~|~10~|~")[1].split("~|~7~|~")[0]);song={name:songName,id:songId,artist:artist,artistId:artistId,fileSize:size,link:link}}let result={id:Number(id),name:name,description:decB64(desc),creator:author,level_version:Number(version),difficulty:difficultyDecoding[difficulty],stars:Number(stars),downloads:Number(downloads),likes:Number(likes),disliked:disliked,length:lengthDecoding[length],demon:Boolean(Number(demonBool)),featured:featured,epic:Boolean(Number(epic)),objects:Number(objs),stars_requested:Number(starsRequested),game_version:decodeGameVersion[gameVersion],copied:Number(copiedID),large:Number(objs)>4e4?true:false,two_p:Boolean(Number(twoPlayer)),coins:Number(coins),verified_coins:Boolean(Number(verifiedCoins)),song:song};if(["Extreme Demon","Insane Demon"].includes(difficultyDecoding[difficulty])){const{demonlist}=require("../misc/demonlist.js");const dlist=await demonlist(name.trim());if(dlist!=null)result.pointercrate=dlist}return result}return await decodeLevel(res.data)}
10
+ getLevelByID: async function (id) {
11
+ if (!id) throw new Error("Please provide a level ID!");
12
+ if (isNaN(id)) throw new Error("The level ID should be a number!");
13
+ const {
14
+ gjReq
15
+ } = require("../misc/gjReq.js");
16
+ const {
17
+ gjWReq
18
+ } = require("../misc/gjWReq.js");
19
+ const {
20
+ secret
21
+ } = require("../config.json");
22
+ const {
23
+ decB64
24
+ } = require("../misc/decB64.js");
25
+ const data = {
26
+ secret: secret,
27
+ str: id,
28
+ type: 0
29
+ };
30
+ let res = await gjReq("getGJLevels21", data);
31
+ if (res.data == -1) throw new Error("-1 Not found.");
32
+ if (res.data == "error code: 1005") {
33
+ res = await gjWReq("getLevelByID", id);
34
+ if (res.status == 403) throw new Error(res.data.error);
35
+ return res.data
36
+ }
37
+ async function decodeLevel(l) {
38
+ let spl = l.split(":");
39
+ let lInfo = [];
40
+ for (let i = 0; i < spl.length; i++) {
41
+ if (i % 2 != 0) {
42
+ lInfo.push(spl[i - 1] + `:` + spl[i])
43
+ }
44
+ }
45
+ let id = lInfo[0].split("1:")[1];
46
+ let name = lInfo[1].split("2:")[1];
47
+ let version = lInfo[2].split("5:")[1];
48
+ let difficulty = lInfo[5].split("9:")[1];
49
+ let downloads = lInfo[6].split("10:")[1];
50
+ let officialSong = lInfo[7].split("12:")[1];
51
+ let gameVersion = lInfo[8].split("13:")[1];
52
+ let likes = lInfo[9].split("14:")[1];
53
+ let demonBool = lInfo[10].split("17:")[1];
54
+ let stars = lInfo[13].split("18:")[1];
55
+ let ftrd = lInfo[14].split("19:")[1];
56
+ let epic = lInfo[15].split("42:")[1];
57
+ let objs = lInfo[16].split("45:")[1];
58
+ let desc = lInfo[17].split("3:")[1];
59
+ let length = lInfo[18].split("15:")[1];
60
+ let copiedID = lInfo[19].split("30:")[1];
61
+ let twoPlayer = lInfo[20].split("31:")[1];
62
+ let coins = lInfo[21].split("37:")[1];
63
+ let verifiedCoins = lInfo[22].split("38:")[1];
64
+ let starsRequested = lInfo[23].split("39:")[1];
65
+ let customSong = lInfo[26].split("35:")[1].split("#")[0];
66
+ let author = res.data.split("#")[1].includes(":") ? res.data.split("#")[1].split(":")[1] : "-";
67
+ let disliked = likes.includes("-") ? true : false;
68
+ if (desc.includes("/")) desc = desc.split("/")[0];
69
+ if (decB64(desc) == "") desc = "KE5vIGRlc2NyaXB0aW9uIHByb3ZpZGVkKQ==";
70
+ let featured = Boolean(Number(ftrd));
71
+ let difficultyDecoding = {
72
+ "-10": "Auto",
73
+ 0: "Unrated",
74
+ 10: "Easy",
75
+ 20: "Normal",
76
+ 30: "Hard",
77
+ 40: "Harder",
78
+ 50: "Insane"
79
+ };
80
+ if (Boolean(Number(demonBool))) {
81
+ difficultyDecoding = {
82
+ 10: "Easy Demon",
83
+ 20: "Medium Demon",
84
+ 30: "Hard Demon",
85
+ 40: "Insane Demon",
86
+ 50: "Extreme Demon"
87
+ }
88
+ }
89
+ const lengthDecoding = {
90
+ 0: "Tiny",
91
+ 1: "Short",
92
+ 2: "Medium",
93
+ 3: "Long",
94
+ 4: "XL"
95
+ };
96
+ const decodeGameVersion = {
97
+ 10: "1.7",
98
+ 18: "1.8",
99
+ 19: "1.9",
100
+ 20: "2.0",
101
+ 21: "2.1",
102
+ undefined: "Pre-1.7"
103
+ };
104
+ const {
105
+ getOfficialSongInfo
106
+ } = require("../functions/getOfficialSongInfo.js");
107
+ let song;
108
+ if (Number(officialSong) > 0) song = getOfficialSongInfo(Number(officialSong) + 1);
109
+ if (Number(officialSong) == 0 && Number(customSong) == 0) song = getOfficialSongInfo(1);
110
+ if (Number(customSong) > 0) {
111
+ let songName = l.split("~|~2~|~")[1].split("~|~3~|~")[0];
112
+ let songId = Number(l.split("#1~|~")[1].split("~|~2~|~")[0]);
113
+ let artist = l.split("~|~4~|~")[1].split("~|~5~|~")[0];
114
+ let artistId = Number(l.split("~|~3~|~")[1].split("~|~4~|~")[0]);
115
+ let size = `${l.split("~|~5~|~")[1].split("~|~6~|~")[0]} MB`;
116
+ let link = decodeURIComponent(l.split("~|~10~|~")[1].split("~|~7~|~")[0]);
117
+ song = {
118
+ name: songName,
119
+ id: songId,
120
+ artist: artist,
121
+ artistId: artistId,
122
+ fileSize: size,
123
+ link: link
124
+ }
125
+ }
126
+ let result = {
127
+ id: Number(id),
128
+ name: name,
129
+ description: decB64(desc),
130
+ creator: author,
131
+ level_version: Number(version),
132
+ difficulty: difficultyDecoding[difficulty],
133
+ stars: Number(stars),
134
+ downloads: Number(downloads),
135
+ likes: Number(likes),
136
+ disliked: disliked,
137
+ length: lengthDecoding[length],
138
+ demon: Boolean(Number(demonBool)),
139
+ featured: featured,
140
+ epic: Boolean(Number(epic)),
141
+ objects: Number(objs),
142
+ stars_requested: Number(starsRequested),
143
+ game_version: decodeGameVersion[gameVersion],
144
+ copied: Number(copiedID),
145
+ large: Number(objs) > 4e4 ? true : false,
146
+ two_p: Boolean(Number(twoPlayer)),
147
+ coins: Number(coins),
148
+ verified_coins: Boolean(Number(verifiedCoins)),
149
+ song: song
150
+ };
151
+ if (["Extreme Demon", "Insane Demon"].includes(difficultyDecoding[difficulty])) {
152
+ const {
153
+ demonlist
154
+ } = require("../misc/demonlist.js");
155
+ const dlist = await demonlist(name.trim());
156
+ if (dlist != null) result.pointercrate = dlist
157
+ }
158
+ return result
159
+ }
160
+ return await decodeLevel(res.data)
161
+ }
12
162
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gj-boomlings-api",
3
- "version": "1.5.6",
3
+ "version": "1.5.7",
4
4
  "description": "A light-weight Geometry Dash API wrapper",
5
5
  "main": "index.js",
6
6
  "scripts": {