mirror of
https://github.com/fireinrain/JHS-enhance.git
synced 2026-10-12 20:56:36 +08:00
修复不规则vr作品名字无法匹配
This commit is contained in:
Vendored
+44
-19
@@ -12146,8 +12146,9 @@ ${err.stack}` : "");
|
|||||||
const res = await gmHttp.get("https://webapi.115.com/offine/downpath");
|
const res = await gmHttp.get("https://webapi.115.com/offine/downpath");
|
||||||
return "object" == typeof res ? res.data : null;
|
return "object" == typeof res ? res.data : null;
|
||||||
};
|
};
|
||||||
const searchFiles = async (search_value, offset = 0, limit = 30) => {
|
const searchFiles = async (search_value, offset = 0, limit = 30, params = {}) => {
|
||||||
const url = `https://webapi.115.com/files/search?search_value=${encodeURIComponent(search_value)}&offset=${offset}&limit=${limit}`;
|
const queryParams = new URLSearchParams({search_value, offset, limit, ...params});
|
||||||
|
const url = `https://webapi.115.com/files/search?${queryParams}`;
|
||||||
return await gmHttp.get(url);
|
return await gmHttp.get(url);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -12873,8 +12874,8 @@ ${err.stack}` : "");
|
|||||||
onProgress && onProgress(i + 1, selectedItems.length, item, "未匹配到115文件");
|
onProgress && onProgress(i + 1, selectedItems.length, item, "未匹配到115文件");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const upperCarNum = item.carNum.toUpperCase();
|
const {regex: safeRegex} = codeParse(item.carNum);
|
||||||
const safeMatchList = matchList.filter((m) => m.name.toUpperCase().includes(upperCarNum));
|
const safeMatchList = matchList.filter((m) => safeRegex.test(m.name));
|
||||||
if (safeMatchList.length === 0) {
|
if (safeMatchList.length === 0) {
|
||||||
failedCount++;
|
failedCount++;
|
||||||
onProgress && onProgress(i + 1, selectedItems.length, item, "无安全可删除目录");
|
onProgress && onProgress(i + 1, selectedItems.length, item, "无安全可删除目录");
|
||||||
@@ -12973,8 +12974,8 @@ ${err.stack}` : "");
|
|||||||
}
|
}
|
||||||
|
|
||||||
showDeleteDialog(carNum2, matchList, afterDelete) {
|
showDeleteDialog(carNum2, matchList, afterDelete) {
|
||||||
const upperCarNum = carNum2.toUpperCase();
|
const {regex: safeRegex} = codeParse(carNum2);
|
||||||
const safeMatchList = matchList.filter((m) => m.name.toUpperCase().includes(upperCarNum));
|
const safeMatchList = matchList.filter((m) => safeRegex.test(m.name));
|
||||||
const unsafeCount = matchList.length - safeMatchList.length;
|
const unsafeCount = matchList.length - safeMatchList.length;
|
||||||
if (safeMatchList.length === 0) {
|
if (safeMatchList.length === 0) {
|
||||||
show.error(`作品 "${carNum2}" 匹配到的 ${matchList.length} 个项目均不含番号,无法安全删除。请手动在115中删除。`);
|
show.error(`作品 "${carNum2}" 匹配到的 ${matchList.length} 个项目均不含番号,无法安全删除。请手动在115中删除。`);
|
||||||
@@ -13085,20 +13086,27 @@ ${err.stack}` : "");
|
|||||||
}
|
}
|
||||||
|
|
||||||
async searchFiles(carNum2) {
|
async searchFiles(carNum2) {
|
||||||
|
const {regex} = codeParse(carNum2);
|
||||||
|
const searchKeyword = carNum2.toLowerCase().replace("fc2-", "");
|
||||||
|
const mapAndFilter = (rawData) => {
|
||||||
|
return rawData.map(((data) => ({
|
||||||
|
folderId: data.fid,
|
||||||
|
dirId: data.cid,
|
||||||
|
videoId: data.pc,
|
||||||
|
name: data.n,
|
||||||
|
createTime: utils.formatDate(new Date(1e3 * data.te)),
|
||||||
|
size: data.s,
|
||||||
|
isVideo: true
|
||||||
|
}))).filter(((x) => x.folderId && regex.test(x.name)));
|
||||||
|
};
|
||||||
var _a2;
|
var _a2;
|
||||||
let searchKeyword = carNum2.toLowerCase().replace("fc2-", "");
|
const preciseData = (null == (_a2 = (await searchFiles(searchKeyword, 0, 30, {type: 4})).data) ? void 0 : _a2) || [];
|
||||||
return (null == (_a2 = (await searchFiles(searchKeyword)).data) ? void 0 : _a2.map(((data) => ({
|
const preciseResults = mapAndFilter(preciseData);
|
||||||
folderId: data.fid,
|
if (preciseResults.length > 0) return preciseResults;
|
||||||
dirId: data.cid,
|
const numberPart = extractNumberPart(carNum2);
|
||||||
videoId: data.pc,
|
if (numberPart === searchKeyword) return preciseResults;
|
||||||
name: data.n,
|
const fuzzyData = (null == (_a2 = (await searchFiles(numberPart, 0, 30, {type: 4})).data) ? void 0 : _a2) || [];
|
||||||
createTime: utils.formatDate(new Date(1e3 * data.te)),
|
return mapAndFilter(fuzzyData);
|
||||||
size: data.s,
|
|
||||||
isVideo: [".mp4", ".avi", ".mov", ".mkv", ".flv", ".wmv"].some(((ext) => {
|
|
||||||
var _a3;
|
|
||||||
return null == (_a3 = data.n) ? void 0 : _a3.toLowerCase().endsWith(ext);
|
|
||||||
}))
|
|
||||||
}))).filter(((x) => x.folderId && x.isVideo && x.name.toLowerCase().includes(searchKeyword)))) || [];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
showMatchError($box2, carNum2, error) {
|
showMatchError($box2, carNum2, error) {
|
||||||
@@ -13176,6 +13184,23 @@ ${err.stack}` : "");
|
|||||||
LOGGED_IN: 1
|
LOGGED_IN: 1
|
||||||
});
|
});
|
||||||
let WangPan115MatchPlugin = _WangPan115MatchPlugin;
|
let WangPan115MatchPlugin = _WangPan115MatchPlugin;
|
||||||
|
const extractNumberPart = (carNum2) => {
|
||||||
|
let cleaned = carNum2.replace(/^fc2[-_]?(ppv[-_])?/i, "");
|
||||||
|
const match = cleaned.match(/(\d+)$/);
|
||||||
|
return match ? match[1] : cleaned;
|
||||||
|
};
|
||||||
|
const codeParse = (code) => {
|
||||||
|
const codes = code.split(/-|_/);
|
||||||
|
const sep = "\\s?(0|-|_){0,2}\\s?";
|
||||||
|
let pattern = codes.join(sep);
|
||||||
|
if (/^fc2/i.test(code)) pattern = `${codes[0]}${sep}(ppv)?${sep}${codes.at(-1)}`;
|
||||||
|
return {
|
||||||
|
code,
|
||||||
|
codes,
|
||||||
|
prefix: codes[0],
|
||||||
|
regex: new RegExp(`(?<![a-z])${pattern}(?!\\d)`, "i")
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
class FavoriteActressesPlugin extends BasePlugin {
|
class FavoriteActressesPlugin extends BasePlugin {
|
||||||
getName() {
|
getName() {
|
||||||
|
|||||||
@@ -6,8 +6,9 @@ const getDownPathList = async () => {
|
|||||||
return "object" == typeof res ? res.data : null;
|
return "object" == typeof res ? res.data : null;
|
||||||
};
|
};
|
||||||
|
|
||||||
const searchFiles = async (search_value, offset = 0, limit = 30) => {
|
const searchFiles = async (search_value, offset = 0, limit = 30, params = {}) => {
|
||||||
const url = `https://webapi.115.com/files/search?search_value=${encodeURIComponent(search_value)}&offset=${offset}&limit=${limit}`;
|
const queryParams = new URLSearchParams({search_value, offset, limit, ...params});
|
||||||
|
const url = `https://webapi.115.com/files/search?${queryParams}`;
|
||||||
return await gmHttp.get(url);
|
return await gmHttp.get(url);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
+48
-17
@@ -406,8 +406,8 @@ const _WangPan115MatchPlugin = class _WangPan115MatchPlugin extends BasePlugin {
|
|||||||
onProgress && onProgress(i + 1, selectedItems.length, item, "未匹配到115文件");
|
onProgress && onProgress(i + 1, selectedItems.length, item, "未匹配到115文件");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const upperCarNum = item.carNum.toUpperCase();
|
const {regex: safeRegex} = codeParse(item.carNum);
|
||||||
const safeMatchList = matchList.filter(m => m.name.toUpperCase().includes(upperCarNum));
|
const safeMatchList = matchList.filter(m => safeRegex.test(m.name));
|
||||||
if (safeMatchList.length === 0) {
|
if (safeMatchList.length === 0) {
|
||||||
failedCount++;
|
failedCount++;
|
||||||
onProgress && onProgress(i + 1, selectedItems.length, item, "无安全可删除目录");
|
onProgress && onProgress(i + 1, selectedItems.length, item, "无安全可删除目录");
|
||||||
@@ -507,8 +507,8 @@ const _WangPan115MatchPlugin = class _WangPan115MatchPlugin extends BasePlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
showDeleteDialog(carNum2, matchList, afterDelete) {
|
showDeleteDialog(carNum2, matchList, afterDelete) {
|
||||||
const upperCarNum = carNum2.toUpperCase();
|
const {regex: safeRegex} = codeParse(carNum2);
|
||||||
const safeMatchList = matchList.filter(m => m.name.toUpperCase().includes(upperCarNum));
|
const safeMatchList = matchList.filter(m => safeRegex.test(m.name));
|
||||||
const unsafeCount = matchList.length - safeMatchList.length;
|
const unsafeCount = matchList.length - safeMatchList.length;
|
||||||
if (safeMatchList.length === 0) {
|
if (safeMatchList.length === 0) {
|
||||||
show.error(`作品 "${carNum2}" 匹配到的 ${matchList.length} 个项目均不含番号,无法安全删除。请手动在115中删除。`);
|
show.error(`作品 "${carNum2}" 匹配到的 ${matchList.length} 个项目均不含番号,无法安全删除。请手动在115中删除。`);
|
||||||
@@ -616,20 +616,31 @@ const _WangPan115MatchPlugin = class _WangPan115MatchPlugin extends BasePlugin {
|
|||||||
window.open("https://115.com");
|
window.open("https://115.com");
|
||||||
}
|
}
|
||||||
async searchFiles(carNum2) {
|
async searchFiles(carNum2) {
|
||||||
|
const {regex} = codeParse(carNum2);
|
||||||
|
const searchKeyword = carNum2.toLowerCase().replace("fc2-", "");
|
||||||
|
|
||||||
|
const mapAndFilter = (rawData) => {
|
||||||
|
return rawData.map((data => ({
|
||||||
|
folderId: data.fid,
|
||||||
|
dirId: data.cid,
|
||||||
|
videoId: data.pc,
|
||||||
|
name: data.n,
|
||||||
|
createTime: utils.formatDate(new Date(1e3 * data.te)),
|
||||||
|
size: data.s,
|
||||||
|
isVideo: true
|
||||||
|
}))).filter((x => x.folderId && regex.test(x.name)));
|
||||||
|
};
|
||||||
|
|
||||||
var _a2;
|
var _a2;
|
||||||
let searchKeyword = carNum2.toLowerCase().replace("fc2-", "");
|
const preciseData = (null == (_a2 = (await searchFiles(searchKeyword, 0, 30, {type: 4})).data) ? void 0 : _a2) || [];
|
||||||
return (null == (_a2 = (await searchFiles(searchKeyword)).data) ? void 0 : _a2.map((data => ({
|
const preciseResults = mapAndFilter(preciseData);
|
||||||
folderId: data.fid,
|
if (preciseResults.length > 0) return preciseResults;
|
||||||
dirId: data.cid,
|
|
||||||
videoId: data.pc,
|
const numberPart = extractNumberPart(carNum2);
|
||||||
name: data.n,
|
if (numberPart === searchKeyword) return preciseResults;
|
||||||
createTime: utils.formatDate(new Date(1e3 * data.te)),
|
|
||||||
size: data.s,
|
const fuzzyData = (null == (_a2 = (await searchFiles(numberPart, 0, 30, {type: 4})).data) ? void 0 : _a2) || [];
|
||||||
isVideo: [ ".mp4", ".avi", ".mov", ".mkv", ".flv", ".wmv" ].some((ext => {
|
return mapAndFilter(fuzzyData);
|
||||||
var _a3;
|
|
||||||
return null == (_a3 = data.n) ? void 0 : _a3.toLowerCase().endsWith(ext);
|
|
||||||
}))
|
|
||||||
}))).filter((x => x.folderId && x.isVideo && x.name.toLowerCase().includes(searchKeyword)))) || [];
|
|
||||||
}
|
}
|
||||||
showMatchError($box2, carNum2, error) {
|
showMatchError($box2, carNum2, error) {
|
||||||
$box2.find(".jhs-match-btn").replaceWith(`<a class='jhs-match-error-btn' data-keyword="${carNum2}" \n title="匹配失败,点击重试">匹配失败</a>`);
|
$box2.find(".jhs-match-btn").replaceWith(`<a class='jhs-match-error-btn' data-keyword="${carNum2}" \n title="匹配失败,点击重试">匹配失败</a>`);
|
||||||
@@ -694,5 +705,25 @@ __publicField(_WangPan115MatchPlugin, "LoginStatus", {
|
|||||||
|
|
||||||
let WangPan115MatchPlugin = _WangPan115MatchPlugin;
|
let WangPan115MatchPlugin = _WangPan115MatchPlugin;
|
||||||
|
|
||||||
|
const extractNumberPart = (carNum) => {
|
||||||
|
let cleaned = carNum.replace(/^fc2[-_]?(ppv[-_])?/i, "");
|
||||||
|
const match = cleaned.match(/(\d+)$/);
|
||||||
|
return match ? match[1] : cleaned;
|
||||||
|
};
|
||||||
|
|
||||||
|
const codeParse = (code) => {
|
||||||
|
const codes = code.split(/-|_/);
|
||||||
|
const sep = "\\s?(0|-|_){0,2}\\s?";
|
||||||
|
|
||||||
|
let pattern = codes.join(sep);
|
||||||
|
if (/^fc2/i.test(code)) pattern = `${codes[0]}${sep}(ppv)?${sep}${codes.at(-1)}`;
|
||||||
|
|
||||||
|
return {
|
||||||
|
code,
|
||||||
|
codes,
|
||||||
|
prefix: codes[0],
|
||||||
|
regex: new RegExp(`(?<![a-z])${pattern}(?!\\d)`, "i"),
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
export { WangPan115Plugin, WangPan115MatchPlugin };
|
export { WangPan115Plugin, WangPan115MatchPlugin };
|
||||||
Reference in New Issue
Block a user