buzzk 1.8.4 โ†’ 1.9.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.
package/README.md CHANGED
@@ -17,6 +17,14 @@
17
17
 
18
18
  ## ๐Ÿ“– ์—…๋ฐ์ดํŠธ ๋‚ด์—ญ
19
19
 
20
+ - ์ฑ„ํŒ… ์ฑ„๋„ ์—ฐ๊ฒฐ์„ ์œ ์ง€ํ•˜์ง€ ๋ชปํ•˜๋Š” ๋ฌธ์ œ ์™„๋ฒฝ ํ•ด๊ฒฐ
21
+
22
+ >
23
+
24
+ - video ํ•จ์ˆ˜ ์ถ”๊ฐ€
25
+
26
+ >
27
+
20
28
  - ์ฑ„ํŒ… ์ฑ„๋„ ์—ฐ๊ฒฐ์„ ์œ ์ง€ํ•˜์ง€ ๋ชปํ•˜๋Š” ๋ฌธ์ œ ํ•ด๊ฒฐ
21
29
 
22
30
  >
@@ -41,10 +49,6 @@
41
49
 
42
50
  - User-Agent ์ถ”๊ฐ€ (API ํ˜ธ์ถœ์— ์‹คํŒจํ•˜๋Š” ๋ฌธ์ œ ํ•ด๊ฒฐ)
43
51
 
44
- >
45
-
46
- - chat ์˜ ๋ฉ”์„ธ์ง€๋ฅผ ํ•ธ๋“ค๋งํ•˜๋˜ ์ค‘ ์˜๋„์น˜ ์•Š๊ฒŒ ์˜ค๋ฅ˜๊ฐ€ ๋‚˜๋Š” ๋ฌธ์ œ ํ•ด๊ฒฐ
47
-
48
52
  ## โœ’๏ธ ๋งˆ์ด๊ทธ๋ ˆ์ด์…˜ ๊ฐ€์ด๋“œ (v.1.2.x -> v.1.3.0)
49
53
 
50
54
  <details>
@@ -371,3 +375,53 @@ dotenv์™€ ํ•จ๊ป˜ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์„ ๋งค์šฐ ๊ถŒ์žฅํ•ฉ๋‹ˆ๋‹ค.
371
375
  </details>
372
376
 
373
377
  await chat.disconnect(); //์ฑ„ํŒ…์ฐฝ ์—ฐ๊ฒฐ ๋Š๊ธฐ
378
+
379
+ ---
380
+
381
+ ### video
382
+
383
+ const videoList = await buzzk.video.getList("channelID ๊ฐ’", 24); //channelID ๊ฐ’, ๊ฐ€์ ธ์˜ฌ ๊ฐฏ์ˆ˜
384
+ console.log(videoList);
385
+
386
+ <details>
387
+ <summary>return</summary>
388
+
389
+ - Return
390
+ - 0
391
+ - no
392
+ - id
393
+ - title
394
+ - category
395
+ - duration
396
+ - uploadOn
397
+ - imageURL
398
+ - trailerURL
399
+ - 1
400
+ - 2
401
+ - 3
402
+ - ...
403
+
404
+ </details>
405
+
406
+ const video = await buzzk.video.get("no ๊ฐ’"); //videoList ์—์„œ return ๋œ no ๊ฐ’
407
+ console.log(video);
408
+ console.log(video.videoURL[720]);
409
+
410
+ <details>
411
+ <summary>return</summary>
412
+
413
+ - Return
414
+ - id
415
+ - title
416
+ - category
417
+ - duration
418
+ - uploadOn
419
+ - startOn
420
+ - imageURL
421
+ - trailerURL
422
+ - videoURL
423
+ - 144
424
+ - 720
425
+ - 1080
426
+
427
+ </details>
package/lib/chat.js CHANGED
@@ -35,6 +35,10 @@ class chzzkChat {
35
35
  if (myInfo.code != 200) return resolve(null);
36
36
  this.#uid = myInfo.content.userIdHash;
37
37
 
38
+ //SetPolling
39
+ if (!this.#pollingStatus) this.#polling();
40
+ //SetPolling
41
+
38
42
  //Get ChatID
39
43
  let cidRes = await getStatus(this.channelID);
40
44
  if (!cidRes) return resolve(null);
@@ -56,10 +60,6 @@ class chzzkChat {
56
60
  this.#ws = new WebSocket("wss://kr-ss" + this.#ssID + ".chat.naver.com/chat");
57
61
  //Connect Web Socket
58
62
 
59
- //SetPolling
60
- if (!this.#pollingStatus) this.#polling();
61
- //SetPolling
62
-
63
63
  //WS Open
64
64
  this.#ws.on("open", () => {
65
65
  console.log("[WS] Connected!");
@@ -194,8 +194,6 @@ class chzzkChat {
194
194
  * @param {function(chzzkMessages)} callback
195
195
  */
196
196
  onMessage(callback) {
197
- if (!this.#ws) return callback(null);
198
-
199
197
  this.#callbacks[Object.keys(this.#callbacks).length] = {
200
198
  type: "message",
201
199
  callback: callback
@@ -266,8 +264,6 @@ class chzzkChat {
266
264
  }
267
265
 
268
266
  onDonation(callback) {
269
- if (!this.#ws) return callback(null);
270
-
271
267
  this.#callbacks[Object.keys(this.#callbacks).length] = {
272
268
  type: "donation",
273
269
  callback: callback
@@ -473,7 +469,7 @@ class chzzkChat {
473
469
  }
474
470
 
475
471
  async #polling () {
476
- if (!this.#ws) return this.#pollingStatus = false;
472
+ //if (!this.#ws) return this.#pollingStatus = false;
477
473
  this.#pollingStatus = true;
478
474
 
479
475
  //Get ChatID
package/lib/index.js CHANGED
@@ -4,6 +4,7 @@ module.exports = {
4
4
  channel: require("./channel.js"),
5
5
  chat: require("./chat.js").chzzkChat,
6
6
  live: require("./live.js"),
7
+ video: require("./video.js"),
7
8
 
8
9
  login: require("./val.js").login
9
10
  }
package/lib/tool.js CHANGED
@@ -1,4 +1,4 @@
1
- const { chzzkBaseURL, gameBaseURL, NID } = require("./val.js");
1
+ const { chzzkBaseURL, gameBaseURL, naverBaseURL, NID } = require("./val.js");
2
2
  const vm = require("./vm.js");
3
3
 
4
4
  function reqChzzk (path) {
@@ -48,8 +48,24 @@ function reqGame (path) {
48
48
  });
49
49
  }
50
50
 
51
+ function reqNaver (path) {
52
+ return new Promise(async (resolve, reject) => {
53
+
54
+ fetch(naverBaseURL + path, {
55
+ method: "GET",
56
+ headers: {
57
+ "Cookie": "NID_AUT=" + NID.AUT + ";NID_SES=" + NID.SES
58
+ }
59
+ })
60
+
61
+ .then((response) => resolve(response.json())).catch((error) => resolve(null));
62
+
63
+ });
64
+ }
65
+
51
66
  module.exports = {
52
67
  reqChzzk: reqChzzk,
53
68
  exChzzk: exChzzk,
54
- reqGame: reqGame
69
+ reqGame: reqGame,
70
+ reqNaver: reqNaver
55
71
  }
package/lib/val.js CHANGED
@@ -1,5 +1,6 @@
1
1
  const chzzkBaseURL = "https://api.chzzk.naver.com/";
2
2
  const gameBaseURL = "https://comm-api.game.naver.com/";
3
+ const naverBaseURL = "https://apis.naver.com/";
3
4
 
4
5
  let NID = {
5
6
  AUT: null,
@@ -18,6 +19,7 @@ function login (NID_AUT, NID_SES) {
18
19
  module.exports = {
19
20
  chzzkBaseURL: chzzkBaseURL,
20
21
  gameBaseURL: gameBaseURL,
22
+ naverBaseURL: naverBaseURL,
21
23
  NID: NID,
22
24
  login: login
23
25
  }
package/lib/video.js ADDED
@@ -0,0 +1,118 @@
1
+ const { reqChzzk, reqNaver } = require("./tool.js");
2
+
3
+ /**
4
+ * @typedef {Object.<number, chzzkVideo>} chzzkVideos
5
+ */
6
+
7
+ /**
8
+ * @typedef {Object} chzzkVideo
9
+ * @property {number} no
10
+ * @property {string} id
11
+ * @property {string} title
12
+ * @property {string} category
13
+ * @property {number} duration
14
+ * @property {string} uploadOn
15
+ * @property {string} imageURL
16
+ * @property {string} trailerURL
17
+ */
18
+
19
+ /**
20
+ * @param {string} channelID
21
+ * @param {?number} size
22
+ * @returns {Promise<chzzkVideos>}
23
+ */
24
+ async function getList (channelID, size) {
25
+ return new Promise(async (resolve, reject) => {
26
+ let res = await reqChzzk("service/v1/channels/" + channelID + "/videos?sortType=LATEST&pagingType=PAGE&page=0&size=" + size || 24);
27
+ if (res.code != 200 || !res.content) return resolve(null);
28
+ let videos = res.content.data;
29
+ let data = new Map();
30
+
31
+ try {
32
+ for (let o in videos) {
33
+ let vdDetail = {
34
+ no: videos[o].videoNo,
35
+ id: videos[o].videoId,
36
+ title: videos[o].videoTitle,
37
+ category: videos[o].videoCategoryValue,
38
+ duration: videos[o].duration,
39
+ uploadOn: videos[o].publishDate,
40
+ imageURL: videos[o].thumbnailImageUrl,
41
+ trailerURL: videos[o].trailerUrl
42
+ }
43
+
44
+ data[Object.keys(data).length] = vdDetail;
45
+ }
46
+
47
+ return resolve(data);
48
+ }
49
+
50
+ catch(error) {
51
+ return resolve(null);
52
+ }
53
+
54
+ });
55
+ }
56
+
57
+ /**
58
+ * @typedef {Object} chzzkVideoDetail
59
+ * @property {string} id
60
+ * @property {string} title
61
+ * @property {string} category
62
+ * @property {number} duration
63
+ * @property {string} uploadOn
64
+ * @property {string} startOn
65
+ * @property {string} imageURL
66
+ * @property {string} trailerURL
67
+ * @property {chzzkVideoURL} videoURL
68
+ */
69
+
70
+ /**
71
+ * @typedef {Object.<number, string>} chzzkVideoURL
72
+ */
73
+
74
+ /**
75
+ * @param {number} no
76
+ * @returns {Promise<chzzkVideoDetail>}
77
+ */
78
+ async function get (no) {
79
+ return new Promise(async (resolve, reject) => {
80
+
81
+ let res = await reqChzzk("service/v2/videos/" + no);
82
+ if (res.code != 200 || !res.content) return resolve(null);
83
+ res = res.content;
84
+
85
+ try {
86
+ let vdDetail = {
87
+ id: res.videoId,
88
+ title: res.videoTitle,
89
+ category: res.videoCategoryValue,
90
+ duration: res.duration,
91
+ uploadOn: res.publishDate,
92
+ startOn: res.liveOpenDate,
93
+ imageURL: res.thumbnailImageUrl,
94
+ trailerURL: res.trailerUrl,
95
+ videoURL: {}
96
+ }
97
+
98
+ let videoURL = await reqNaver("neonplayer/vodplay/v1/playback/" + res.videoId + "?key=" + res.inKey);
99
+ videoURL = videoURL.period[0].adaptationSet[0].representation;
100
+
101
+ for (let o in videoURL) {
102
+ vdDetail.videoURL[videoURL[o].height] = videoURL[o].baseURL[0].value;
103
+ }
104
+
105
+ return resolve(vdDetail);
106
+ }
107
+
108
+ catch(error) {
109
+ return resolve(null);
110
+ }
111
+
112
+ });
113
+ }
114
+
115
+ module.exports = {
116
+ getList: getList,
117
+ get: get
118
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "buzzk",
3
3
  "displayName": "BUZZK",
4
- "version": "1.8.4",
4
+ "version": "1.9.1",
5
5
  "description": "๋ฟŒ์ง€์ง (BUZZK) - ์น˜์ง€์ง(CHZZK) ์ฑ—๋ด‡์„ ๋”์šฑ ์‰ฝ๊ฒŒ ๊ฐœ๋ฐœํ•  ์ˆ˜ ์žˆ๋„๋ก ๋•๋Š” ๋น„๊ณต์‹ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ.",
6
6
  "main": "lib/index.js",
7
7
  "type": "commonjs",