buzzk 1.8.4 β†’ 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,10 @@
17
17
 
18
18
  ## πŸ“– μ—…λ°μ΄νŠΈ λ‚΄μ—­
19
19
 
20
+ - video ν•¨μˆ˜ μΆ”κ°€
21
+
22
+ >
23
+
20
24
  - μ±„νŒ… 채널 연결을 μœ μ§€ν•˜μ§€ λͺ»ν•˜λŠ” 문제 ν•΄κ²°
21
25
 
22
26
  >
@@ -41,10 +45,6 @@
41
45
 
42
46
  - User-Agent μΆ”κ°€ (API ν˜ΈμΆœμ— μ‹€νŒ¨ν•˜λŠ” 문제 ν•΄κ²°)
43
47
 
44
- >
45
-
46
- - chat 의 λ©”μ„Έμ§€λ₯Ό ν•Έλ“€λ§ν•˜λ˜ 쀑 μ˜λ„μΉ˜ μ•Šκ²Œ 였λ₯˜κ°€ λ‚˜λŠ” 문제 ν•΄κ²°
47
-
48
48
  ## βœ’οΈ λ§ˆμ΄κ·Έλ ˆμ΄μ…˜ κ°€μ΄λ“œ (v.1.2.x -> v.1.3.0)
49
49
 
50
50
  <details>
@@ -371,3 +371,53 @@ dotenv와 ν•¨κ»˜ μ‚¬μš©ν•˜λŠ” 것을 맀우 ꢌμž₯ν•©λ‹ˆλ‹€.
371
371
  </details>
372
372
 
373
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/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.0",
5
5
  "description": "λΏŒμ§€μ§ (BUZZK) - μΉ˜μ§€μ§(CHZZK) 챗봇을 λ”μš± μ‰½κ²Œ κ°œλ°œν•  수 μžˆλ„λ‘ λ•λŠ” 비곡식 라이브러리.",
6
6
  "main": "lib/index.js",
7
7
  "type": "commonjs",