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 +58 -4
- package/lib/chat.js +5 -9
- package/lib/index.js +1 -0
- package/lib/tool.js +18 -2
- package/lib/val.js +2 -0
- package/lib/video.js +118 -0
- package/package.json +1 -1
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
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.
|
|
4
|
+
"version": "1.9.1",
|
|
5
5
|
"description": "๋ฟ์ง์ง (BUZZK) - ์น์ง์ง(CHZZK) ์ฑ๋ด์ ๋์ฑ ์ฝ๊ฒ ๊ฐ๋ฐํ ์ ์๋๋ก ๋๋ ๋น๊ณต์ ๋ผ์ด๋ธ๋ฌ๋ฆฌ.",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"type": "commonjs",
|