fix: mp4kan 网页改版问题 (#12645)
This commit is contained in:
parent
a47d1b6810
commit
352cba2fdd
|
|
@ -2,10 +2,36 @@ const cheerio = require('cheerio');
|
|||
const got = require('@/utils/got');
|
||||
const { baseUrl, decodeCipherText, composeMagnetUrl, getUrlType } = require('./utils');
|
||||
|
||||
// 兼容没有 script 标签的情况,直接解析 dom
|
||||
function getDomList($, detailUrl) {
|
||||
const list = $('.down-list li')
|
||||
.toArray()
|
||||
.map((item) => {
|
||||
item = $(item);
|
||||
const title = item.find('a').attr('title');
|
||||
const downurl = item.find('a').attr('href');
|
||||
const urlType = getUrlType(downurl);
|
||||
const enclosureUrl = urlType === 'magnet' ? composeMagnetUrl(downurl) : downurl;
|
||||
return {
|
||||
enclosure_url: enclosureUrl,
|
||||
enclosure_length: '',
|
||||
enclosure_type: 'application/x-bittorrent',
|
||||
title,
|
||||
link: detailUrl,
|
||||
guid: `${title}-${urlType}`,
|
||||
};
|
||||
});
|
||||
return list;
|
||||
}
|
||||
|
||||
function getItemList($, detailUrl) {
|
||||
const encoded = $('.article script[type]')
|
||||
.text()
|
||||
.match(/return p}\('(.*)',(\d+),(\d+),'(.*)'.split\(/);
|
||||
// 若 script 标签没有内容,直接解析 dom
|
||||
if (!encoded) {
|
||||
return getDomList($, detailUrl);
|
||||
}
|
||||
const data = JSON.parse(
|
||||
decodeCipherText(encoded[1], encoded[2], encoded[3], encoded[4].split('|'), 0, {})
|
||||
.match(/var down_urls=\\'(.*)\\'/)[1]
|
||||
|
|
|
|||
Loading…
Reference in New Issue