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 +54 -4
- 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,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
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.0",
|
|
5
5
|
"description": "λΏμ§μ§ (BUZZK) - μΉμ§μ§(CHZZK) μ±λ΄μ λμ± μ½κ² κ°λ°ν μ μλλ‘ λλ λΉκ³΅μ λΌμ΄λΈλ¬λ¦¬.",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"type": "commonjs",
|