* fix: MP4Ba源站内容获取错误 (#2432) fix: MP4Ba源站内容获取错误 (#2432) * docs: 同步MP4BA说明文档 docs: 同步MP4BA说明文档
This commit is contained in:
parent
c14ae4dfed
commit
30d24998fa
|
|
@ -89,22 +89,30 @@ pageClass: routes
|
|||
|
||||
## Mp4Ba
|
||||
|
||||
### 影视分类
|
||||
|
||||
<Route author="SettingDust wolfyu1991" example="/mp4ba/6" path="/mp4ba/:param" :paramsDesc="['类型']" supportBT="1"/>
|
||||
|
||||
**类型参考这里**
|
||||
| 1 | 2 | 3 | 4 |
|
||||
| - | - | - | - |
|
||||
| 电影 | 连续剧 | 综艺 | 动画 |
|
||||
| 电影 | 连续剧 | 动画 | 综艺 | 纪录片 |
|
||||
| - | - | - | - | - |
|
||||
| 6 | 7 | 15 | 20 | 24 |
|
||||
|
||||
| 5 | 6 | 7 | 8 | 9 |
|
||||
| ------ | ------ | ------ | ------ | ------ |
|
||||
| 动作片 | 喜剧片 | 爱情片 | 科幻片 | 恐怖片 |
|
||||
| ------ | ------ | ------ | ------ | ------ |
|
||||
| 8 | 9 | 10 | 11 | 12 |
|
||||
|
||||
| 10 | 11 | 12 | 13 | 14 | 15 |
|
||||
| ------ | ------ | ------ | ------ | ------ | ------ |
|
||||
| 剧情片 | 战争片 | 国产剧 | 港台剧 | 日韩剧 | 欧美剧 |
|
||||
| ------ | ------ | ------ | ------ | ------ | ------ |
|
||||
| 13 | 14 | 16 | 17 | 18 | 19 |
|
||||
|
||||
### 资源
|
||||
</Route>
|
||||
|
||||
<Route author="SettingDust" example="/mp4ba/1" path="/mp4ba/:param" :paramsDesc="['类型/关键字']" supportBT="1"/>
|
||||
### 影视搜索
|
||||
|
||||
<Route author="wolfyu1991" example="/mp4ba/复仇者联盟" path="/mp4ba/:keyword" :paramsDesc="['搜索关键字']" supportBT="1"/>
|
||||
|
||||
</Route>
|
||||
|
||||
## rs05 人生 05 电影
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
const baseUrl = 'http://ww.mp4ba.com';
|
||||
const baseUrl = 'http://www.mp4ba.com';
|
||||
|
||||
class ParamType {
|
||||
static get paramType() {
|
||||
|
|
@ -31,10 +31,10 @@ class ParamType {
|
|||
if (!this._url) {
|
||||
switch (this._type) {
|
||||
case ParamType.paramType.type:
|
||||
url = `${baseUrl}/?m=vod-type-id-${this._param}.html`;
|
||||
url = `${baseUrl}/index/index/lists/catid/${this._param}/`;
|
||||
break;
|
||||
case ParamType.paramType.search:
|
||||
url = `${baseUrl}/index.php?m=vod-search&wd=${this._param}`;
|
||||
url = `${baseUrl}/index.php?m=search&q=${this._param}`;
|
||||
break;
|
||||
}
|
||||
this._url = url;
|
||||
|
|
@ -44,18 +44,24 @@ class ParamType {
|
|||
}
|
||||
|
||||
async function buildRss($, paramType, ctx) {
|
||||
const $list = (selector) => $('#data_list').find(selector); // 列表对象
|
||||
const $list = (selector) => $('.content').find(selector); // 列表对象
|
||||
const title = $('title').text();
|
||||
const typeString = title.substring(0, title.indexOf('-'));
|
||||
const typeString = title.substring(0, title.indexOf('_'));
|
||||
let selectorPath1,
|
||||
selectorPath2 = null;
|
||||
|
||||
function buildDesc() {
|
||||
let desc = '';
|
||||
switch (paramType.type) {
|
||||
case ParamType.paramType.type:
|
||||
desc = `${typeString}类型`;
|
||||
selectorPath1 = '.detail .list ul li';
|
||||
selectorPath2 = 'a';
|
||||
break;
|
||||
case ParamType.paramType.search:
|
||||
desc = `${typeString}的搜索结果`;
|
||||
desc = `${typeString}`;
|
||||
selectorPath1 = '.search .search_content .sousuo';
|
||||
selectorPath2 = 'b a';
|
||||
break;
|
||||
}
|
||||
return desc;
|
||||
|
|
@ -63,23 +69,26 @@ async function buildRss($, paramType, ctx) {
|
|||
|
||||
async function buildItem($) {
|
||||
return await Promise.all(
|
||||
$('.alt1')
|
||||
$(selectorPath1)
|
||||
.map(async (_, result) => {
|
||||
const $ = cheerio.load(result);
|
||||
const $a = $('td')
|
||||
.eq(2)
|
||||
.children('a');
|
||||
const pageUrl = `${baseUrl}${$a.attr('href')}`;
|
||||
const pubDate = new Date(
|
||||
$('span')
|
||||
.text()
|
||||
.match(/\d{4}-\d{1,2}-\d{1,2}/)
|
||||
).toUTCString();
|
||||
const $a = $(selectorPath2);
|
||||
const pageUrl = $a.attr('href');
|
||||
const { cache } = ctx;
|
||||
const title = $a.text().replace('.Mp4Ba', '');
|
||||
const title = $a.text();
|
||||
const link = pageUrl;
|
||||
const guid = pageUrl.match(/id-(\d+?).html/);
|
||||
const guid = pageUrl.match(/(\d+?).html/);
|
||||
let description = null;
|
||||
const enclosure_type = 'application/x-bittorrent';
|
||||
let $magnet = null;
|
||||
|
||||
async function getDescription() {
|
||||
const key = `Mp4Ba${pageUrl.match(/\d+/)}`;
|
||||
const key = `Mp4Ba${pageUrl}`;
|
||||
const value = await ctx.cache.get(key);
|
||||
if (value) {
|
||||
description = value;
|
||||
|
|
@ -88,11 +97,11 @@ async function buildRss($, paramType, ctx) {
|
|||
} else {
|
||||
const pageData = (await got.get(pageUrl)).data;
|
||||
const $page = cheerio.load(pageData);
|
||||
$magnet = $page('.main')
|
||||
.find('.down_list')
|
||||
$magnet = $page('.content .article .box')
|
||||
.find('.download')
|
||||
.find('a[href^="magnet:?xt=urn:btih:"]');
|
||||
description = $page('.main')
|
||||
.find('.intro')
|
||||
description = $page('.content .article .box')
|
||||
.find('.info_con')
|
||||
.html();
|
||||
cache.set(key, description);
|
||||
}
|
||||
|
|
@ -100,7 +109,7 @@ async function buildRss($, paramType, ctx) {
|
|||
|
||||
await getDescription();
|
||||
const enclosure_url = $magnet.attr('href');
|
||||
return { title, link, description, enclosure_url, enclosure_type, guid };
|
||||
return { title, link, description, enclosure_url, enclosure_type, guid, pubDate };
|
||||
})
|
||||
.get()
|
||||
);
|
||||
|
|
|
|||
Loading…
Reference in New Issue