buzzk 2.1.8 โ†’ 2.2.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/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2023 Emin-G
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Emin-G
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
21
  SOFTWARE.
package/README.md CHANGED
@@ -14,6 +14,10 @@
14
14
 
15
15
  ## ๐Ÿ“– ์—…๋ฐ์ดํŠธ ๋‚ด์—ญ
16
16
 
17
+ ### ๐ŸŽ‰ 2.2 ์—…๋ฐ์ดํŠธ
18
+ - ์ด์ œ Axios๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ API๋ฅผ ๋ถˆ๋Ÿฌ์˜ต๋‹ˆ๋‹ค!
19
+ - ๋”์šฑ ์•ˆ์ •์ ์ด๊ณ  ๋น ๋ฅธ ์„ฑ๋Šฅ์„ ๋ณด์ผ ๊ฒƒ์œผ๋กœ ๊ธฐ๋Œ€๋ฉ๋‹ˆ๋‹ค!
20
+
17
21
  ### ๐ŸŽ‰ 2.1 ์—…๋ฐ์ดํŠธ
18
22
  - ๊ณต์‹ API๋กœ ๊ฑฐ์˜ ๋Œ€๋ถ€๋ถ„์˜ ์ž‘์—…์„ ๋Œ€์ฒดํ–ˆ์–ด์š”!
19
23
 
package/lib/channel.js CHANGED
@@ -32,7 +32,7 @@ async function search (keyword) {
32
32
  if (chSearch.code != 200) return resolve(null);
33
33
  chSearch = chSearch.content.data;
34
34
 
35
- if (!chSearch) return resolve(null);
35
+ if (!chSearch || Object.keys(chSearch).length < 1) return resolve(null);
36
36
 
37
37
  let chRes = new Map();
38
38
 
@@ -58,6 +58,7 @@ async function get (channelID) {
58
58
  if (chGet.code != 200) return resolve(null);
59
59
 
60
60
  chGet = chGet.content.data[0];
61
+ if (!chGet) return resolve(null);
61
62
 
62
63
  let chRes = new chzzkChannel(chGet.channelId, chGet.channelName, chGet.followerCount, chGet.channelImageUrl);
63
64
 
package/lib/chat.js CHANGED
@@ -114,6 +114,7 @@ class chzzkChat {
114
114
  if (data.profile.badges[o].imageUrl == "https://ssl.pstatic.net/static/nng/glive/icon/manager.png") hasMod = true;
115
115
  }
116
116
  }
117
+ else return;
117
118
 
118
119
  let chatData = new chzzkChatData(data.senderChannelId, data.profile.nickname, hasMod, data.content, data.emojis, data.messageTime);
119
120
  return this.#callbacks.message(chatData);
package/lib/live.js CHANGED
@@ -38,7 +38,6 @@ async function getDetail (channelID) {
38
38
  return new Promise(async (resolve, reject) => {
39
39
 
40
40
  let res = await reqChzzk("service/v3/channels/" + channelID + "/live-detail");
41
- console.log(res);
42
41
  if (res.code != 200 || !res.content) return resolve(null);
43
42
  res = res.content;
44
43
 
package/lib/tool.js CHANGED
@@ -1,11 +1,14 @@
1
1
  const { chzzkAPIURL, chzzkBaseURL, gameBaseURL, naverBaseURL, NID, AUTH } = require("./val.js");
2
2
  const vm = require("./vm.js");
3
3
 
4
+ const axios = require("axios");
5
+
4
6
  function clientGet (path) {
5
7
  return new Promise(async (resolve, reject) => {
6
8
 
7
- fetch(chzzkAPIURL + path, {
9
+ axios({
8
10
  method: "GET",
11
+ url: chzzkAPIURL + path,
9
12
  headers: {
10
13
  "Client-Id": AUTH.id,
11
14
  "Client-Secret": AUTH.secret,
@@ -14,17 +17,12 @@ function clientGet (path) {
14
17
  }
15
18
  })
16
19
 
17
- .then(async (response) => {
18
- let json;
19
- try {
20
- json = await response.json();
21
- }
22
-
23
- catch(error) {
24
- return resolve({"code": 500});
25
- }
26
-
27
- return resolve(json);
20
+ .then((response) => {
21
+ return resolve(response.data);
22
+ })
23
+
24
+ .catch((error) => {
25
+ return resolve({"code": 500});
28
26
  });
29
27
 
30
28
  });
@@ -33,8 +31,9 @@ function clientGet (path) {
33
31
  function clientPost (path, body) {
34
32
  return new Promise(async (resolve, reject) => {
35
33
 
36
- fetch(chzzkAPIURL + path, {
34
+ axios({
37
35
  method: "POST",
36
+ url: chzzkAPIURL + path,
38
37
  headers: {
39
38
  "Client-Id": AUTH.id,
40
39
  "Client-Secret": AUTH.secret,
@@ -44,17 +43,12 @@ function clientPost (path, body) {
44
43
  body: body
45
44
  })
46
45
 
47
- .then(async (response) => {
48
- let json;
49
- try {
50
- json = await response.json();
51
- }
52
-
53
- catch(error) {
54
- return resolve({"code": 500});
55
- }
56
-
57
- return resolve(json);
46
+ .then((response) => {
47
+ return resolve(response.data);
48
+ })
49
+
50
+ .catch((error) => {
51
+ return resolve({"code": 500});
58
52
  });
59
53
 
60
54
  });
@@ -63,8 +57,9 @@ function clientPost (path, body) {
63
57
  function userGet (token, path) {
64
58
  return new Promise(async (resolve, reject) => {
65
59
 
66
- fetch(chzzkAPIURL + path, {
60
+ axios({
67
61
  method: "GET",
62
+ url: chzzkAPIURL + path,
68
63
  headers: {
69
64
  "Authorization": "Bearer " + token,
70
65
  "Content-Type": "application/json",
@@ -72,17 +67,12 @@ function userGet (token, path) {
72
67
  }
73
68
  })
74
69
 
75
- .then(async (response) => {
76
- let json;
77
- try {
78
- json = await response.json();
79
- }
80
-
81
- catch(error) {
82
- return resolve({"code": 500});
83
- }
84
-
85
- return resolve(json);
70
+ .then((response) => {
71
+ return resolve(response.data);
72
+ })
73
+
74
+ .catch((error) => {
75
+ return resolve({"code": 500});
86
76
  });
87
77
 
88
78
  });
@@ -91,8 +81,9 @@ function userGet (token, path) {
91
81
  function userPost (token, path, body) {
92
82
  return new Promise(async (resolve, reject) => {
93
83
 
94
- fetch(chzzkAPIURL + path, {
84
+ axios({
95
85
  method: "POST",
86
+ url: chzzkAPIURL + path,
96
87
  headers: {
97
88
  "Authorization": "Bearer " + token,
98
89
  "Content-Type": "application/json",
@@ -101,17 +92,12 @@ function userPost (token, path, body) {
101
92
  body: body
102
93
  })
103
94
 
104
- .then(async (response) => {
105
- let json;
106
- try {
107
- json = await response.json();
108
- }
109
-
110
- catch(error) {
111
- return resolve({"code": 500});
112
- }
113
-
114
- return resolve(json);
95
+ .then((response) => {
96
+ return resolve(response.data);
97
+ })
98
+
99
+ .catch((error) => {
100
+ return resolve({"code": 500});
115
101
  });
116
102
 
117
103
  });
@@ -120,101 +106,90 @@ function userPost (token, path, body) {
120
106
  function reqChzzk (path) {
121
107
  return new Promise(async (resolve, reject) => {
122
108
 
123
- fetch(chzzkBaseURL + path, {
109
+ axios({
124
110
  method: "GET",
111
+ url: chzzkBaseURL + path,
125
112
  headers: {
126
113
  "User-Agent": "BuzzkLib/" + vm.getVersion() + " (Node)"
127
114
  }
128
115
  })
129
116
 
130
- .then(async (response) => {
131
- let json;
132
- try {
133
- json = await response.json();
134
- }
135
-
136
- catch(error) {
137
- return resolve({"code": 500});
138
- }
139
-
140
- return resolve(json);
117
+ .then((response) => {
118
+ return resolve(response.data);
119
+ })
120
+
121
+ .catch((error) => {
122
+ return resolve({"code": 500});
141
123
  });
124
+
142
125
  });
143
126
  }
144
127
 
145
128
  function exChzzk (method, path) {
146
129
  return new Promise(async (resolve, reject) => {
147
130
 
148
- fetch(chzzkBaseURL + path, {
131
+ axios({
149
132
  method: method,
133
+ url: chzzkBaseURL + path,
150
134
  headers: {
151
135
  "Cookie": "NID_AUT=" + NID.AUT + ";NID_SES=" + NID.SES,
152
136
  "User-Agent": "BuzzkLib/" + vm.getVersion() + " (Node)"
153
137
  }
154
138
  })
155
139
 
156
- .then(async (response) => {
157
- let json;
158
- try {
159
- json = await response.json();
160
- }
161
-
162
- catch(error) {
163
- return resolve({"code": 500});
164
- }
165
-
166
- return resolve(json);
140
+ .then((response) => {
141
+ return resolve(response.data);
142
+ })
143
+
144
+ .catch((error) => {
145
+ console.log(error);
146
+ return resolve({"code": 500});
167
147
  });
148
+
168
149
  });
169
150
  }
170
151
 
171
152
  function reqGame (path) {
172
153
  return new Promise(async (resolve, reject) => {
173
154
 
174
- fetch(gameBaseURL + path, {
155
+ axios({
175
156
  method: "GET",
157
+ url: gameBaseURL + path,
176
158
  headers: {
177
159
  "User-Agent": "BuzzkLib/" + vm.getVersion() + " (Node)"
178
160
  }
179
161
  })
180
162
 
181
- .then(async (response) => {
182
- let json;
183
- try {
184
- json = await response.json();
185
- }
186
-
187
- catch(error) {
188
- return resolve({"code": 500});
189
- }
190
-
191
- return resolve(json);
163
+ .then((response) => {
164
+ return resolve(response.data);
165
+ })
166
+
167
+ .catch((error) => {
168
+ return resolve({"code": 500});
192
169
  });
170
+
193
171
  });
194
172
  }
195
173
 
196
174
  function reqNaver (path) {
197
175
  return new Promise(async (resolve, reject) => {
198
176
 
199
- fetch(naverBaseURL + path, {
177
+ axios({
200
178
  method: "GET",
179
+ url: naverBaseURL + path,
201
180
  headers: {
202
181
  "User-Agent": "BuzzkLib/" + vm.getVersion() + " (Node)"
203
182
  }
204
183
  })
205
184
 
206
- .then(async (response) => {
207
- let json;
208
- try {
209
- json = await response.json();
210
- }
211
-
212
- catch(error) {
213
- return resolve(null);
214
- }
215
-
216
- return resolve(json);
185
+ .then((response) => {
186
+ return resolve(response.data);
187
+ })
188
+
189
+ .catch((error) => {
190
+ return resolve({"code": 500});
217
191
  });
192
+
218
193
  });
219
194
  }
220
195
 
package/lib/video.js CHANGED
@@ -26,6 +26,8 @@ async function getList (channelID, size) {
26
26
  let res = await reqChzzk("service/v1/channels/" + channelID + "/videos?sortType=LATEST&pagingType=PAGE&page=0&size=" + size || 24);
27
27
  if (res.code != 200 || !res.content) return resolve(null);
28
28
  let videos = res.content.data;
29
+ if (Object.keys(videos).length < 1) return resolve(null);
30
+
29
31
  let data = new Map();
30
32
 
31
33
  try {
package/lib/vm.js CHANGED
@@ -1,3 +1,5 @@
1
+ const axios = require("axios");
2
+
1
3
  function getVersion () {
2
4
  let localPkg = require("../package.json");
3
5
  return localPkg.version;
@@ -5,11 +7,10 @@ function getVersion () {
5
7
 
6
8
  async function check () {
7
9
  let localPkg = require("../package.json");
8
- let remotePkg = await fetch("https://raw.githubusercontent.com/Emin-G/buzzk/master/package.json");
9
-
10
+ let remotePkg = await axios.get("https://raw.githubusercontent.com/Emin-G/buzzk/master/package.json");
10
11
  if (remotePkg.status != 200) return console.log("[BUZZK] ์ตœ์‹  ๋ฒ„์ „์— ๋Œ€ํ•œ ์ •๋ณด๋ฅผ ๋ถˆ๋Ÿฌ์˜ค์ง€ ๋ชปํ–ˆ์Šต๋‹ˆ๋‹ค.");
11
12
 
12
- remotePkg = await remotePkg.json();
13
+ remotePkg = remotePkg.data;
13
14
 
14
15
  localPkg = String(localPkg.version).split(".");
15
16
  remotePkg = String(remotePkg.version).split(".");
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "buzzk",
3
3
  "displayName": "BUZZK",
4
- "version": "2.1.8",
4
+ "version": "2.2.0",
5
5
  "description": "๋ฟŒ์ง€์ง (BUZZK) - ์น˜์ง€์ง(CHZZK) ์ฑ—๋ด‡์„ ๋”์šฑ ์‰ฝ๊ฒŒ ๊ฐœ๋ฐœํ•  ์ˆ˜ ์žˆ๋„๋ก ๋•๋Š” ๋น„๊ณต์‹ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ.",
6
6
  "main": "lib/index.js",
7
7
  "type": "commonjs",
@@ -31,6 +31,7 @@
31
31
  "๋ฟŒ์ง€์ง"
32
32
  ],
33
33
  "dependencies": {
34
+ "axios": "^1.9.0",
34
35
  "socket.io-client": "^2.0.3"
35
36
  }
36
37
  }