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