feat: add search result parser for javlib
This commit is contained in:
@@ -17,7 +17,7 @@ export interface DomQuery_parser {
|
||||
/** 检测有无字幕的方法
|
||||
* 点名:Jable
|
||||
*/
|
||||
checkFn?: (arg: any) => boolean;
|
||||
checkTextFn?: (arg: any) => boolean;
|
||||
}
|
||||
|
||||
export interface DomQuery_get {
|
||||
@@ -76,7 +76,7 @@ export const siteList: SiteItem[] = [
|
||||
domQuery: {
|
||||
linkQuery: `.container .detail>.title>a`,
|
||||
titleQuery: `.container .detail>.title>a`,
|
||||
checkFn: (linkResult: string) => /-c\/$/.test(linkResult),
|
||||
checkTextFn: (linkResult: string) => /-c\/$/.test(linkResult),
|
||||
},
|
||||
method: print,
|
||||
},
|
||||
@@ -285,8 +285,11 @@ export const siteList: SiteItem[] = [
|
||||
disable: false,
|
||||
hostname: "javlibrary.com",
|
||||
url: "https://www.javlibrary.com/cn/vl_searchbyid.php?keyword={{code}}",
|
||||
fetcher: "get",
|
||||
domQuery: {},
|
||||
fetcher: "parser",
|
||||
domQuery: {
|
||||
linkQuery: ".videothumblist .video[id]:first-child>a",
|
||||
titleQuery: ".videothumblist .video[id]:first-child>a>div.id",
|
||||
},
|
||||
method: print,
|
||||
},
|
||||
];
|
||||
|
||||
@@ -33,13 +33,7 @@ function videoPageParser(responseText: string, { subQuery, leakQuery, videoQuery
|
||||
*/
|
||||
function serachPageParser(
|
||||
responseText: string,
|
||||
{
|
||||
linkQuery,
|
||||
titleQuery,
|
||||
listIndex = 0,
|
||||
spaceCode = false,
|
||||
checkFn: checkTextFn,
|
||||
}: DomQuery_parser,
|
||||
{ linkQuery, titleQuery, listIndex = 0, checkTextFn }: DomQuery_parser,
|
||||
siteHostName: string,
|
||||
CODE: string,
|
||||
) {
|
||||
@@ -50,12 +44,13 @@ function serachPageParser(
|
||||
const titleNodeText = titleNode ? titleNode?.outerHTML : "";
|
||||
|
||||
/** 空格版本的 code */
|
||||
const formatCode = spaceCode ? CODE.replace("-", " ") : CODE;
|
||||
// const formatCode = spaceCode ? CODE.replace("-", " ") : CODE;
|
||||
|
||||
const isSuccess = linkNode && titleNode && titleNodeText.includes(formatCode);
|
||||
const isSuccess = linkNode && titleNode && titleNodeText.includes(CODE);
|
||||
|
||||
if (isSuccess) {
|
||||
const targetLinkText = linkNode.href.replace(linkNode.hostname, siteHostName);
|
||||
|
||||
const checkResult = checkTextFn ? checkTextFn(targetLinkText) : false;
|
||||
const hasSubtitle =
|
||||
titleNodeText.includes("字幕") || titleNodeText.includes("subtitle") || checkResult;
|
||||
|
||||
Reference in New Issue
Block a user