buzzk 1.8.2 โ†’ 1.9.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/README.md CHANGED
@@ -17,6 +17,14 @@
17
17
 
18
18
  ## ๐Ÿ“– ์—…๋ฐ์ดํŠธ ๋‚ด์—ญ
19
19
 
20
+ - video ํ•จ์ˆ˜ ์ถ”๊ฐ€
21
+
22
+ >
23
+
24
+ - ์ฑ„ํŒ… ์ฑ„๋„ ์—ฐ๊ฒฐ์„ ์œ ์ง€ํ•˜์ง€ ๋ชปํ•˜๋Š” ๋ฌธ์ œ ํ•ด๊ฒฐ
25
+
26
+ >
27
+
20
28
  - ์ฑ„ํŒ… ์ฑ„๋„์ด ์—†์„ ๋•Œ ์˜ค๋ฅ˜๊ฐ€ ์ƒ๊ธฐ๋Š” ๋ฌธ์ œ ํ•ด๊ฒฐ
21
29
 
22
30
  >
@@ -37,18 +45,6 @@
37
45
 
38
46
  - User-Agent ์ถ”๊ฐ€ (API ํ˜ธ์ถœ์— ์‹คํŒจํ•˜๋Š” ๋ฌธ์ œ ํ•ด๊ฒฐ)
39
47
 
40
- >
41
-
42
- - chat ์˜ ๋ฉ”์„ธ์ง€๋ฅผ ํ•ธ๋“ค๋งํ•˜๋˜ ์ค‘ ์˜๋„์น˜ ์•Š๊ฒŒ ์˜ค๋ฅ˜๊ฐ€ ๋‚˜๋Š” ๋ฌธ์ œ ํ•ด๊ฒฐ
43
-
44
- >
45
-
46
- - WebSocket is not open ๋ฌธ์ œ ํ•ด๊ฒฐ
47
-
48
- >
49
-
50
- - chat.getUserInfo ํ•จ์ˆ˜ ์ถ”๊ฐ€
51
-
52
48
  ## โœ’๏ธ ๋งˆ์ด๊ทธ๋ ˆ์ด์…˜ ๊ฐ€์ด๋“œ (v.1.2.x -> v.1.3.0)
53
49
 
54
50
  <details>
@@ -375,3 +371,53 @@ dotenv์™€ ํ•จ๊ป˜ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์„ ๋งค์šฐ ๊ถŒ์žฅํ•ฉ๋‹ˆ๋‹ค.
375
371
  </details>
376
372
 
377
373
  await chat.disconnect(); //์ฑ„ํŒ…์ฐฝ ์—ฐ๊ฒฐ ๋Š๊ธฐ
374
+
375
+ ---
376
+
377
+ ### video
378
+
379
+ const videoList = await buzzk.video.getList("channelID ๊ฐ’");
380
+ console.log(videoList);
381
+
382
+ <details>
383
+ <summary>return</summary>
384
+
385
+ - Return
386
+ - 0
387
+ - no
388
+ - id
389
+ - title
390
+ - category
391
+ - duration
392
+ - uploadOn
393
+ - imageURL
394
+ - trailerURL
395
+ - 1
396
+ - 2
397
+ - 3
398
+ - ...
399
+
400
+ </details>
401
+
402
+ const video = await buzzk.video.get("no ๊ฐ’"); //videoList ์—์„œ return ๋œ no ๊ฐ’
403
+ console.log(video);
404
+ console.log(video.videoURL[720]);
405
+
406
+ <details>
407
+ <summary>return</summary>
408
+
409
+ - Return
410
+ - id
411
+ - title
412
+ - category
413
+ - duration
414
+ - uploadOn
415
+ - startOn
416
+ - imageURL
417
+ - trailerURL
418
+ - videoURL
419
+ - 144
420
+ - 720
421
+ - 1080
422
+
423
+ </details>
package/lib/chat.js CHANGED
@@ -484,19 +484,21 @@ class chzzkChat {
484
484
  //Reconnect
485
485
  this.#pollingStatus = false;
486
486
  await this.disconnect();
487
- await this.connect();
488
- for (let o in this.#callbacks) {
489
- if (this.#callbacks[o].type === "message") this.#onMessageHandler(this.#callbacks[o].callback);
490
- else if (this.#callbacks[o].type === "donation") this.#onDonationHandler(this.#callbacks[o].callback);
487
+ let connectRes = await this.connect();
488
+ if (connectRes) {
489
+ for (let o in this.#callbacks) {
490
+ if (this.#callbacks[o].type === "message") this.#onMessageHandler(this.#callbacks[o].callback);
491
+ else if (this.#callbacks[o].type === "donation") this.#onDonationHandler(this.#callbacks[o].callback);
492
+ }
493
+ return;
491
494
  }
492
- return;
493
495
  //Reconnect
494
496
  }
495
497
  //Get ChatID
496
498
 
497
499
  let interval;
498
500
  if (cidRes && cidRes.polling && cidRes.polling.callPeriodMilliSecond) interval = cidRes.polling.callPeriodMilliSecond;
499
- else interval = 10000;
501
+ else interval = 30000;
500
502
 
501
503
  setTimeout(() => {
502
504
  return this.#polling();
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/live.js CHANGED
@@ -58,7 +58,7 @@ async function getDetail (channelID) {
58
58
  }
59
59
 
60
60
  catch(error) {
61
- return;
61
+ return resolve(null);
62
62
  }
63
63
 
64
64
  });
@@ -100,7 +100,7 @@ async function getStatus (channelID) {
100
100
  }
101
101
 
102
102
  catch(error) {
103
- return;
103
+ return resolve(null);
104
104
  }
105
105
 
106
106
  });
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.2",
4
+ "version": "1.9.0",
5
5
  "description": "๋ฟŒ์ง€์ง (BUZZK) - ์น˜์ง€์ง(CHZZK) ์ฑ—๋ด‡์„ ๋”์šฑ ์‰ฝ๊ฒŒ ๊ฐœ๋ฐœํ•  ์ˆ˜ ์žˆ๋„๋ก ๋•๋Š” ๋น„๊ณต์‹ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ.",
6
6
  "main": "lib/index.js",
7
7
  "type": "commonjs",