add 猫眼电影正在热播完整列表 (#8587)

Co-authored-by: GitHub Action <action@github.com>
This commit is contained in:
song-zhou 2021-11-27 17:13:01 +08:00 committed by GitHub
parent 6883b446f5
commit 02fda1c910
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 94 additions and 0 deletions

View File

@ -1034,6 +1034,10 @@ JavDB 有多个备用域名,本路由以 <https://javdb7.com> 为默认域名
<Route author="HenryQW" example="/maoyan/upcoming" path="/maoyan/upcoming" />
### 正在热映 - 完整版
<Route author="song-zhou" example="/maoyan/hotComplete" path="/maoyan/hotComplete/:orderby?/:ascOrDesc?/:top?" :paramsDesc="['排序条件,(score: 评分,pubDate: 发布时间),', '正序或倒序 (asc: 正序, desc: 倒序) 默认倒序', '取前多少条,默认取所有']"/>
## 奈菲影视
### 分区

View File

@ -1821,6 +1821,9 @@ router.get('/aqicn/:city/:pollution?', lazyloadRouteHandler('./routes/aqicn/inde
// 猫眼电影
router.get('/maoyan/hot', lazyloadRouteHandler('./routes/maoyan/hot'));
router.get('/maoyan/upcoming', lazyloadRouteHandler('./routes/maoyan/upcoming'));
router.get('/maoyan/hot', require('./routes/maoyan/hot'));
router.get('/maoyan/upcoming', require('./routes/maoyan/upcoming'));
router.get('/maoyan/hotComplete/:orderby?/:ascOrDesc?/:top?', require('./routes/maoyan/hotComplete'));
// cnBeta
router.get('/cnbeta', lazyloadRouteHandler('./routes/cnbeta/home'));

View File

@ -0,0 +1,87 @@
const got = require('@/utils/got');
function sleep(time) {
return new Promise((resolve) => setTimeout(resolve, time));
}
module.exports = async (ctx) => {
const orderby = ctx.params.orderby;
const ascOrDesc = ctx.params.ascOrDesc;
const top = ctx.params.top;
const response = await got({
method: 'get',
url: 'https://m.maoyan.com/ajax/movieOnInfoList',
headers: {
Referer: 'https://m.maoyan.com/',
},
});
let data = response.data.movieList;
const movieIds = response.data.movieIds;
const movieIdsArr = [];
for (let i = data.length; i < movieIds.length; i += 10) {
const movieIdsTemp = movieIds.slice(i, i + 10);
movieIdsArr.push(movieIdsTemp);
}
const dataArrs = await Promise.all(
movieIdsArr.map(async (idsTemp) => {
await sleep(500);
const responseTemp = await got({
method: 'get',
url: 'https://m.maoyan.com/ajax/moreComingList',
searchParams: {
movieIds: idsTemp.toString(),
token: '',
},
headers: {
Referer: 'https://m.maoyan.com/',
},
});
const dataTemp = responseTemp.data.coming;
if (dataTemp && dataTemp.length > 0) {
return dataTemp;
} else {
return [];
}
})
);
for (let i = 0; i < dataArrs.length; i++) {
data.push(...dataArrs[i]);
}
if (orderby) {
data.sort((a, b) => {
if (orderby === 'pubDate') {
return ascOrDesc === 'asc' ? new Date(a.rt).getTime() - new Date(b.rt).getTime() : new Date(b.rt).getTime() - new Date(a.rt).getTime();
} else {
return ascOrDesc === 'asc' ? a.sc - b.sc : b.sc - a.sc;
}
});
}
if (top && top > 0 && top < data.length) {
data = data.slice(0, top - 1);
}
const items = await Promise.all(
data.map((item) => {
const rating = item.sc > 0 ? `评分:${item.sc}` : '';
return {
title: `${item.nm} ${rating}`,
description: `<img src="${item.img.replace('w.h', '1000.1000')}"> <br> ${rating} <br> 演员:${item.star} <br> 上映信息:${item.showInfo}`,
link: `https://maoyan.com/films/${item.id}`,
pubDate: new Date(item.rt).toUTCString(),
};
})
);
ctx.state.data = {
title: `猫眼电影 - 正在热映 - 完整版`,
link: `https://maoyan.com/films`,
description: `猫眼电影 - 正在热映`,
item: items,
};
};