tt-help-cli-ycl 1.3.84 → 1.3.86
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 +1 -1
- package/scripts/test-refill-order.mjs +218 -0
- package/src/cli/tag.js +736 -0
- package/src/lib/args.js +182 -6
- package/src/lib/constants.js +43 -0
- package/src/lib/parse-ssr.mjs +1 -0
- package/src/lib/tag-discover.js +150 -0
- package/src/lib/tag-fetcher.js +296 -0
- package/src/lib/target-locations.js +18 -0
- package/src/main.js +14 -0
- package/src/npm-main.js +14 -0
- package/src/scraper/explore-core.js +6 -6
- package/src/watch/data-store.js +344 -49
- package/src/watch/server.js +178 -1
- package/src/watch/tag-service.js +339 -0
|
@@ -51,10 +51,28 @@ function findFirstMatchingLocation(
|
|
|
51
51
|
);
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
+
/**
|
|
55
|
+
* 从按频率排序的 entries 中,找第一个属于目标国家的。
|
|
56
|
+
* @param {Array<[string, number]>} entries - 已按频率降序排列的 [国家, 次数] 数组
|
|
57
|
+
* @param {string[]} targetLocations - 目标国家列表
|
|
58
|
+
* @returns {string|null} 频率最高的目标国家,如都不匹配则返回 null
|
|
59
|
+
*/
|
|
60
|
+
function findBestMatchingLocation(
|
|
61
|
+
entries,
|
|
62
|
+
targetLocations = DEFAULT_TARGET_LOCATIONS,
|
|
63
|
+
) {
|
|
64
|
+
const normalizedTarget = normalizeLocationList(targetLocations);
|
|
65
|
+
for (const [loc] of entries) {
|
|
66
|
+
if (normalizedTarget.includes(loc)) return loc;
|
|
67
|
+
}
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
|
|
54
71
|
export {
|
|
55
72
|
DEFAULT_TARGET_LOCATIONS,
|
|
56
73
|
DEFAULT_TARGET_LOCATIONS_CSV,
|
|
57
74
|
findFirstMatchingLocation,
|
|
75
|
+
findBestMatchingLocation,
|
|
58
76
|
isLocationInList,
|
|
59
77
|
normalizeLocation,
|
|
60
78
|
normalizeLocationList,
|
package/src/main.js
CHANGED
|
@@ -11,6 +11,12 @@ import { handleVideoStats } from "./cli/videostats.js";
|
|
|
11
11
|
import { handleDbImport } from "./cli/db-import.js";
|
|
12
12
|
import { handleWebserver } from "./cli/webserver.js";
|
|
13
13
|
import { handleRefresh } from "./cli/refresh.js";
|
|
14
|
+
import {
|
|
15
|
+
handleTag,
|
|
16
|
+
handleDiscover,
|
|
17
|
+
handleScore,
|
|
18
|
+
handleScoreAll,
|
|
19
|
+
} from "./cli/tag.js";
|
|
14
20
|
|
|
15
21
|
async function main() {
|
|
16
22
|
const parsed = parseArgs();
|
|
@@ -36,6 +42,14 @@ async function main() {
|
|
|
36
42
|
return handleDbImport(parsed);
|
|
37
43
|
case "refresh":
|
|
38
44
|
return handleRefresh(parsed);
|
|
45
|
+
case "tag":
|
|
46
|
+
return handleTag(parsed);
|
|
47
|
+
case "tag-discover":
|
|
48
|
+
return handleDiscover(parsed);
|
|
49
|
+
case "tag-score":
|
|
50
|
+
return handleScore(parsed);
|
|
51
|
+
case "tag-score-all":
|
|
52
|
+
return handleScoreAll(parsed);
|
|
39
53
|
}
|
|
40
54
|
|
|
41
55
|
const {
|
package/src/npm-main.js
CHANGED
|
@@ -7,6 +7,12 @@ import { handleConfig, showConfig, showUsage, version } from "./cli/config.js";
|
|
|
7
7
|
import { handleOpen } from "./cli/open.js";
|
|
8
8
|
import { handleComments } from "./cli/comments.js";
|
|
9
9
|
import { handleRefresh } from "./cli/refresh.js";
|
|
10
|
+
import {
|
|
11
|
+
handleTag,
|
|
12
|
+
handleDiscover,
|
|
13
|
+
handleScore,
|
|
14
|
+
handleScoreAll,
|
|
15
|
+
} from "./cli/tag.js";
|
|
10
16
|
|
|
11
17
|
function exitUnsupportedCommand(command) {
|
|
12
18
|
console.error(
|
|
@@ -36,6 +42,14 @@ async function main() {
|
|
|
36
42
|
return handleComments(parsed);
|
|
37
43
|
case "refresh":
|
|
38
44
|
return handleRefresh(parsed);
|
|
45
|
+
case "tag":
|
|
46
|
+
return handleTag(parsed);
|
|
47
|
+
case "tag-discover":
|
|
48
|
+
return handleDiscover(parsed);
|
|
49
|
+
case "tag-score":
|
|
50
|
+
return handleScore(parsed);
|
|
51
|
+
case "tag-score-all":
|
|
52
|
+
return handleScoreAll(parsed);
|
|
39
53
|
}
|
|
40
54
|
|
|
41
55
|
const {
|
|
@@ -6,7 +6,7 @@ import { extractFollowAndFollowers } from "./modules/follow-extractor.js";
|
|
|
6
6
|
import { extractVideoLocation, setScraperProxy } from "../lib/scrape.js";
|
|
7
7
|
import {
|
|
8
8
|
DEFAULT_TARGET_LOCATIONS_CSV,
|
|
9
|
-
|
|
9
|
+
findBestMatchingLocation,
|
|
10
10
|
isLocationInList,
|
|
11
11
|
normalizeLocation,
|
|
12
12
|
normalizeLocationList,
|
|
@@ -152,13 +152,13 @@ async function processExplore(page, username, options, log) {
|
|
|
152
152
|
locationDecision = `众数 (${entries[0][1]}次)`;
|
|
153
153
|
}
|
|
154
154
|
} else {
|
|
155
|
-
// explore
|
|
156
|
-
const
|
|
157
|
-
|
|
155
|
+
// explore 模式:取频率最高的目标国家,不匹配则回退众数
|
|
156
|
+
const bestTargetLocation = findBestMatchingLocation(
|
|
157
|
+
entries,
|
|
158
158
|
locationList,
|
|
159
159
|
);
|
|
160
|
-
if (
|
|
161
|
-
locationCreated =
|
|
160
|
+
if (bestTargetLocation) {
|
|
161
|
+
locationCreated = bestTargetLocation;
|
|
162
162
|
locationDecision = "命中目标国家";
|
|
163
163
|
} else if (entries.length > 0) {
|
|
164
164
|
locationCreated = entries[0][0];
|