UNPKG

comic-book-dl

Version:
73 lines (72 loc) 1.85 kB
import { Dmzj } from '../../lib/parse/dmzj/index.js'; import { Baozi } from '../../lib/parse/baozi/index.js'; import { Baimangu } from '../../lib/parse/baimangu/index.js'; import { Godamanga } from '../../lib/parse/godamanga/index.js'; import { Ikuku } from '../../lib/parse/ikuku/index.js'; const ruleMap = [ { hostRule: /(.*?)baozi(.*)\.(?!one)|(.*?)(fzmanga|webmota|kukuc|czmanga|dinnerku)(.*?)/, parse: { getInstance(url) { return new Baozi(url); }, preHandleUrl(url) { return url.replace(/tw\.|www\./, 'cn.'); }, } }, { hostRule: /(.*?)dmzj(.*?)/, parse: { getInstance(url) { return new Dmzj(url); }, } }, { hostRule: /(.*?)godamanga(.*?)|(.*?)baozimh\.one(.*?)/, parse: { getInstance(url) { return new Godamanga(url); }, } }, { hostRule: /(.*?)darpou(.*?)/, parse: { getInstance(url) { return new Baimangu(url); } } }, { hostArr: [ 'mh123.dypro.xyz', 'm.ikuku.cc', 'wap.ikuku.cc', 'm.ikukudm.cc' ], parse: { getInstance(url) { return new Ikuku(url); } } } ]; export function matchParse(url) { if (!url) return false; const { host } = new URL(url); const ruleItem = ruleMap.find((item) => { if (item.hostRule) { return item.hostRule.test(host); } else if (item.hostArr) { return item.hostArr.includes(host); } return false; }); if (!ruleItem) return false; return ruleItem.parse; }