update CAT

This commit is contained in:
qist
2024-04-19 15:36:29 +08:00
parent 7f7c284e35
commit 711c6061ec
10 changed files with 717 additions and 520 deletions

181
cat/tjs/js/mhdq.js Normal file
View File

@@ -0,0 +1,181 @@
/*
* @File : mhdq.js
* @Author : jade
* @Date : 2024/1/24 9:15
* @Email : jadehh@1ive.com
* @Software : Samples
* @Desc : 18+韩漫
*/
import {Spider} from "./spider.js";
import {BookDetail, BookShort} from "../lib/book.js";
class MHDQSpider extends Spider {
constructor() {
super();
this.siteUrl = 'https://www.18hanman.com';
}
getName() {
return "🖌︎|韩漫18|🖌︎"
}
getAppName() {
return "韩漫18"
}
getJSName() {
return "mhdq"
}
getType() {
return 20
}
async setClasses() {
this.classes = []
let $ = await this.getHtml(this.siteUrl + "/category/")
for (const a of $('div.classopen ul.duzhe a[href!="/"]')) {
this.classes.push({
type_id: a.attribs.href,
type_name: a.children[0].data.trim()
});
}
}
async parseVodShortListFromDocByCategory($) {
const list = eval($('div[class="row exemptComic-box"]')[0].attribs.list);
let books = [];
for (const book of list) {
let bookShort = this.parseVodShortFromJson(book)
books.push(bookShort)
}
return books
}
parseVodShortFromElement($, element) {
let bookShort = new BookShort()
const a = $(element).find('a:first')[0];
const img = $(element).find('img:first-child')[0];
bookShort.book_id = a.attribs.href
bookShort.book_name = $($(element).find("a").slice(-1)[0]).html()
bookShort.book_pic = img.attribs.src
bookShort.book_remarks = $($(element).find("span")).text()
return bookShort
}
async parseVodShortListFromDoc($) {
let vodElements = $('ul.catagory-list li')
let books = []
for (const vodElement of vodElements) {
let bookShort = await this.parseVodShortFromElement($, vodElement)
books.push(bookShort)
}
return books
}
async parseVodShortListFromDocBySearch($) {
let vodElements = $('ul.u_list')
let books = []
for (const vodElement of vodElements) {
let bookShort = await this.parseVodShortFromElement($, vodElement)
books.push(bookShort)
}
return books
}
async parseVodDetailFromDoc($, id) {
let html = $.html()
let bookDetail = new BookDetail()
bookDetail.book_id = id
bookDetail.book_name = $('div.title:first').text().trim()
bookDetail.pic = $($('div.img:first-child')).find("img")[0].attribs.src
let contentElements = $('div.info ').find("p")
for (const contentElelent of contentElements) {
if ($(contentElelent).text().indexOf("更新至")) {
bookDetail.book_remarks = $(contentElelent).text().replaceAll("更新至:","")
}
if ($(contentElelent).text().indexOf("作者")) {
bookDetail.book_director = $(contentElelent).text().replaceAll("作者:","")
}
}
bookDetail.book_content = $("[class=\"text\"]").text()
let urls = [];
const links = $('ul.list a[href!="/"]');
for (const l of links) {
let name = l.children[0].data;
let link = l.attribs.href;
urls.push(name + '$' + link);
}
bookDetail.volumes = '全卷';
bookDetail.urls = urls.join('#');
return bookDetail
}
async setCategory(tid, pg, filter, extend) {
const $ = await this.getHtml(this.siteUrl + `${tid}/page/${pg}`)
this.vodList = await this.parseVodShortListFromDoc($)
}
async setDetail(id) {
let $ = await this.getHtml(this.siteUrl + `${id}`)
this.vodDetail = await this.parseVodDetailFromDoc($, id)
}
async setPlay(flag, id, flags) {
const $ = await this.getHtml(this.siteUrl + id);
let content = [];
for (const l of $('div.chapterbox img')) {
const img = $(l).attr('src');
content.push(img);
}
this.playUrl = {
"content": content,
}
}
async setSearch(wd, quick) {
const $ = await this.getHtml(this.siteUrl + `/index.php/search?key=${wd}`);
this.vodList = await this.parseVodShortListFromDocBySearch($)
}
}
let spider = new MHDQSpider()
async function init(cfg) {
await spider.init(cfg)
}
async function home(filter) {
return await spider.home(filter)
}
async function homeVod() {
return await spider.homeVod()
}
async function category(tid, pg, filter, extend) {
return await spider.category(tid, pg, filter, extend)
}
async function detail(id) {
return await spider.detail(id)
}
async function play(flag, id, flags) {
return await spider.play(flag, id, flags)
}
async function search(wd, quick) {
return await spider.search(wd, quick)
}
export function __jsEvalReturn() {
return {
init: init, home: home, homeVod: homeVod, category: category, detail: detail, play: play, search: search,
};
}
export {spider}

View File

@@ -1,4 +1,4 @@
import {__jsEvalReturn} from './bilibili.js';
import {__jsEvalReturn} from './mhdq.js';
import * as Utils from "../lib/utils.js";
@@ -50,14 +50,14 @@ async function testMusicPlay(vodDetail) {
}
async function test() {
let siteKey = 'bilibili';
let siteKey = 'mhdq';
let siteType = 0;
await spider.init({
skey: siteKey, stype: siteType, ext: {
"token": "6827db23e5474d02a07fd7431d3d5a5a",
"box": "TV",
"code": "1",
"from": "bilibili",
"from": "mhdq",
"danmu": true,
"cookie": "buvid3=02675249-8ED3-C418-87F5-59E18316459714816infoc; b_nut=1704421014; _uuid=5D435F74-F574-D9AB-62C1-B9294DE465D913102infoc; buvid_fp=e8c5650c749398e9b5cad3f3ddb5081e; buvid4=007E85D1-52C1-7E6E-07CF-837FFBC9349516677-024010502-J5vTDSZDCw4fNnXRejbSVg%3D%3D; rpdid=|()kYJmulRu0J'u~|RRJl)JR; PVID=1; SESSDATA=3be091d3%2C1720332009%2C699ed%2A11CjAcCdwXG5kY1umhCOpQHOn_WP7L9xFBfWO7KKd4BPweodpR6VyIfeNyPiRmkr5jCqsSVjg0R0dZOVVHRUo3RnhPRTZFc3JPbGdiUjFCdHpiRDhiTkticmdKTjVyS1VhbDdvNjFMSDJlbUJydUlRdjFUNGFBNkJlV2ZTa0N1Q1BEVi1QYTQzTUh3IIEC; bili_jct=b0ee7b5d3f27df893545d811d95506d4; DedeUserID=78014638; DedeUserID__ckMd5=4c8c5d65065e468a; enable_web_push=DISABLE; header_theme_version=CLOSE; home_feed_column=5; CURRENT_BLACKGAP=0; CURRENT_FNVAL=4048; b_lsid=75E916AA_18EA1A8D995; bsource=search_baidu; FEED_LIVE_VERSION=V_HEADER_LIVE_NO_POP; browser_resolution=1507-691; bili_ticket=eyJhbGciOiJIUzI1NiIsImtpZCI6InMwMyIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3MTIzNjk5MTMsImlhdCI6MTcxMjExMDY1MywicGx0IjotMX0.8zQW_fNTCSBlK_JkHnzu3gDw62wuTK1qgKcbGec3swM; bili_ticket_expires=171236985"
}
@@ -69,28 +69,30 @@ async function test() {
// 测试详情
let detail1 = JSON.parse(await spider.detail("/1874.html"))
await testPlay(detail1)
// //测试首页列表
let homeVod = JSON.parse(await spider.homeVod())
console.debug(JSON.stringify(homeVod));
let catePage = JSON.parse(await spider.category("/category/list/1", "1", undefined, {}));
console.debug(JSON.stringify(catePage));
// 测试搜索
let search_page = JSON.parse(await spider.search("王牌",false,2))
let search_page = JSON.parse(await spider.search("12",false,1))
console.debug(JSON.stringify(search_page))
// 测试详情
let detail1 = JSON.parse(await spider.detail("86534"))
await testPlay(detail1)
;
let catePage = JSON.parse(await spider.category("2", "1", undefined, {}));
console.debug(JSON.stringify(catePage));