fix: modified fc2Detected
This commit is contained in:
1 parent
e146b59aae
commit
c2aae0b9ed
3 files changed
+12
-9
No files matched your search
@@ -71,7 +71,7 @@ program
|
||||
const spinner = ora(`${t.searching} ${id.toUpperCase()} ...`).start();
|
||||
|
||||
try {
|
||||
const result = await search(id.toUpperCase());
|
||||
const result = await search(id.toUpperCase(), lang);
|
||||
spinner.stop();
|
||||
|
||||
if (!result) {
|
||||
|
||||
+8
-5
@@ -2,6 +2,7 @@ import { execSync } from 'child_process';
|
||||
import * as cheerio from 'cheerio';
|
||||
import { getCache, setCache, getConfig } from './cache.js';
|
||||
import chalk from 'chalk';
|
||||
import {getLang} from "./i18n.js";
|
||||
|
||||
// ─── 通用请求函数(JAVBUS / JavLibrary 使用)────────────
|
||||
function fetchHtml(url, cookie = '') {
|
||||
@@ -322,13 +323,15 @@ function parseJavdb(html, queryId) {
|
||||
return result.title ? result : null;
|
||||
}
|
||||
|
||||
// ─── 主入口:依次尝试三个数据源 ─────────────────────────
|
||||
export async function search(id) {
|
||||
// FC2 格式识别:031926-100 → 031926_100(JAVDB 存储格式)
|
||||
// ─── 主入口:依次尝试数据源 ─────────────────────────
|
||||
export async function search(id, lang = 'zh') {
|
||||
const t = getLang(lang);
|
||||
|
||||
// FC2 格式识别:031926-100 → 031926_100
|
||||
let searchId = id;
|
||||
if (/^\d{5,6}-\d+$/.test(id)) {
|
||||
searchId = id.replace(/-/g, '_'); // 全局替换,更安全
|
||||
console.log(chalk.gray(` 识别为FC2格式的车牌号: ${id}`));
|
||||
searchId = id.replace(/-/g, '_');
|
||||
console.log(chalk.gray(` ${t.fc2Detected}: ${id} → ${searchId}`));
|
||||
}
|
||||
|
||||
const cached = getCache(id);
|
||||
|
||||
+3
-3
@@ -19,7 +19,7 @@ export const messages = {
|
||||
cacheCleared: '缓存已清空',
|
||||
cacheClearFailed: '清空缓存失败',
|
||||
cachePath: '缓存路径',
|
||||
fc2Detected: 'FC2番号已转换为',
|
||||
fc2Detected: '识别为FC2格式的车牌号',
|
||||
windowsHint: '温馨提示: 此番号需要JAVDB数据源,Windows暂不支持~',
|
||||
setupTitle: '配置 JAVDB Cookie(可选)',
|
||||
setupDesc: '不配置也可以正常使用,配置后覆盖率更高。',
|
||||
@@ -87,7 +87,7 @@ export const messages = {
|
||||
cacheCleared: 'キャッシュを削除しました',
|
||||
cacheClearFailed: 'キャッシュの削除に失敗しました',
|
||||
cachePath: 'キャッシュパス',
|
||||
fc2Detected: 'FC2番号を変換しました',
|
||||
fc2Detected: 'FC2番号を検出しました',
|
||||
windowsHint: '注意: この番号はJAVDBが必要ですが、WindowsではJAVDBが利用できません。',
|
||||
setupTitle: 'JAVDB Cookieの設定(オプション)',
|
||||
setupDesc: '設定しなくても使用できますが、設定すると検索範囲が広がります。',
|
||||
@@ -121,7 +121,7 @@ export const messages = {
|
||||
cacheCleared: '캐시가 삭제되었습니다',
|
||||
cacheClearFailed: '캐시 삭제 실패',
|
||||
cachePath: '캐시 경로',
|
||||
fc2Detected: 'FC2 번호 변환됨',
|
||||
fc2Detected: 'FC2 형식 감지됨',
|
||||
windowsHint: '알림: 이 번호는 JAVDB가 필요하지만 Windows에서는 사용할 수 없습니다.',
|
||||
setupTitle: 'JAVDB Cookie 설정 (선택사항)',
|
||||
setupDesc: '설정하지 않아도 사용할 수 있지만, 설정하면 검색 범위가 넓어집니다.',
|
||||
|
||||
Reference in new issue
Block a user