@soga/baidu-ua 0.1.13 → 0.1.16
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 +1 -0
- package/dist/main.d.ts +2 -1
- package/dist/main.js +13 -3
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
### @soga/baidu-ua
|
package/dist/main.d.ts
CHANGED
|
@@ -2,4 +2,5 @@ export declare const getBaiduUA: (host_id: number, is_large_file: boolean) => Pr
|
|
|
2
2
|
ua: string;
|
|
3
3
|
finishBaiduUA: () => void;
|
|
4
4
|
}>;
|
|
5
|
-
export declare const resetBaiduUA: (app_ua_list: string[], web_ua_list: string[]) =>
|
|
5
|
+
export declare const resetBaiduUA: (app_ua_list: string[], web_ua_list: string[]) => void;
|
|
6
|
+
export declare const removeBaiduUA: (host_id: number) => void;
|
package/dist/main.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resetBaiduUA = exports.getBaiduUA = void 0;
|
|
3
|
+
exports.removeBaiduUA = exports.resetBaiduUA = exports.getBaiduUA = void 0;
|
|
4
4
|
const userAgents = {
|
|
5
5
|
app: [
|
|
6
6
|
'netdisk;4.46.6;PC;PC-Mac',
|
|
@@ -39,7 +39,12 @@ class BaiduUA {
|
|
|
39
39
|
};
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
|
+
getting = false;
|
|
42
43
|
async getBest(is_large_file) {
|
|
44
|
+
while (this.getting) {
|
|
45
|
+
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
46
|
+
}
|
|
47
|
+
this.getting = true;
|
|
43
48
|
const list = is_large_file
|
|
44
49
|
? Object.values(this.ua_map).filter((item) => !item.is_web)
|
|
45
50
|
: Object.values(this.ua_map);
|
|
@@ -70,7 +75,8 @@ class BaiduUA {
|
|
|
70
75
|
});
|
|
71
76
|
}
|
|
72
77
|
item.start_time = Date.now();
|
|
73
|
-
console.log('get best ua: ', item.ua.slice(0, 24));
|
|
78
|
+
console.log('get best ua : ', item.ua.slice(0, 24));
|
|
79
|
+
this.getting = false;
|
|
74
80
|
return item;
|
|
75
81
|
}
|
|
76
82
|
finishUA(ua) {
|
|
@@ -98,7 +104,7 @@ const getBaiduUA = async (host_id, is_large_file) => {
|
|
|
98
104
|
};
|
|
99
105
|
};
|
|
100
106
|
exports.getBaiduUA = getBaiduUA;
|
|
101
|
-
const resetBaiduUA =
|
|
107
|
+
const resetBaiduUA = (app_ua_list, web_ua_list) => {
|
|
102
108
|
userAgents.app = app_ua_list;
|
|
103
109
|
userAgents.web = web_ua_list;
|
|
104
110
|
instanceMap.forEach((ins) => {
|
|
@@ -106,3 +112,7 @@ const resetBaiduUA = async (app_ua_list, web_ua_list) => {
|
|
|
106
112
|
});
|
|
107
113
|
};
|
|
108
114
|
exports.resetBaiduUA = resetBaiduUA;
|
|
115
|
+
const removeBaiduUA = (host_id) => {
|
|
116
|
+
instanceMap.delete(host_id);
|
|
117
|
+
};
|
|
118
|
+
exports.removeBaiduUA = removeBaiduUA;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@soga/baidu-ua",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.16",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -31,5 +31,5 @@
|
|
|
31
31
|
"keywords": [],
|
|
32
32
|
"author": "",
|
|
33
33
|
"license": "ISC",
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "1f22188c2926f8657c17bafeac7fa6bbcd66a599"
|
|
35
35
|
}
|