floating-live 0.14.9 → 0.14.11
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/package.json
CHANGED
package/plugin/bilibili/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export declare function getCookie(headers: Headers): string;
|
|
1
2
|
export declare function parseCookieString(str: string): Record<string, string>;
|
|
2
3
|
/** 获取登录用户的uid */
|
|
3
4
|
export declare function getLoginUid(cookie?: string): Promise<any>;
|
|
@@ -13,4 +14,4 @@ export declare function generateLoginQRcode(): Promise<{
|
|
|
13
14
|
/** 在终端打印登录二维码 */
|
|
14
15
|
export declare function printQRcode(url: string): void;
|
|
15
16
|
/** 检测登录二维码 */
|
|
16
|
-
export declare function checkLoginQRcode(key: string): Promise<(string | number
|
|
17
|
+
export declare function checkLoginQRcode(key: string): Promise<(string | number)[]>;
|
package/plugin/bilibili/utils.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.checkLoginQRcode = exports.printQRcode = exports.generateLoginQRcode = exports.getKey = exports.getBuvid = exports.getLoginUid = exports.parseCookieString = void 0;
|
|
6
|
+
exports.checkLoginQRcode = exports.printQRcode = exports.generateLoginQRcode = exports.getKey = exports.getBuvid = exports.getLoginUid = exports.parseCookieString = exports.getCookie = void 0;
|
|
7
7
|
const qrcode_1 = __importDefault(require("qrcode"));
|
|
8
8
|
const USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36 Edg/117.0.2045.36";
|
|
9
9
|
/** API-当前登录用户信息 */
|
|
@@ -12,6 +12,18 @@ const UID_INIT_URL = "https://api.bilibili.com/x/web-interface/nav";
|
|
|
12
12
|
const BUVID_INIT_URL = "https://data.bilibili.com/v/";
|
|
13
13
|
const ROOM_INIT_URL = "https://api.live.bilibili.com/xlive/web-room/v1/index/getInfoByRoom";
|
|
14
14
|
const DANMAKU_SERVER_CONF_URL = "https://api.live.bilibili.com/xlive/web-room/v1/index/getDanmuInfo";
|
|
15
|
+
function getCookie(headers) {
|
|
16
|
+
const cookies = [];
|
|
17
|
+
headers.forEach((val, key) => {
|
|
18
|
+
if (key == "set-cookie") {
|
|
19
|
+
const [c] = val.split(";");
|
|
20
|
+
cookies.push(c);
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
const cookie = cookies.join("; ");
|
|
24
|
+
return cookie;
|
|
25
|
+
}
|
|
26
|
+
exports.getCookie = getCookie;
|
|
15
27
|
function parseCookieString(str) {
|
|
16
28
|
const cookie = {};
|
|
17
29
|
str.split(";").forEach((item) => {
|
|
@@ -54,7 +66,7 @@ async function getBuvid(cookie = "") {
|
|
|
54
66
|
"User-Agent": USER_AGENT,
|
|
55
67
|
},
|
|
56
68
|
});
|
|
57
|
-
const resCookie = res.headers
|
|
69
|
+
const resCookie = getCookie(res.headers);
|
|
58
70
|
if (!resCookie)
|
|
59
71
|
return;
|
|
60
72
|
return parseCookieString(resCookie)["buvid2"];
|
|
@@ -108,8 +120,8 @@ async function checkLoginQRcode(key) {
|
|
|
108
120
|
return [2];
|
|
109
121
|
}
|
|
110
122
|
else if (code == 0) {
|
|
111
|
-
|
|
112
|
-
|
|
123
|
+
const cookie = getCookie(res.headers);
|
|
124
|
+
console.log(cookie);
|
|
113
125
|
return [0, cookie];
|
|
114
126
|
}
|
|
115
127
|
else if (code == 86038) {
|