Skip to content

Commit 71d5ded

Browse files
authored
feat(route): add maoyan (猫眼电影) routes (#20956)
* feat(route): add LinuxDo RSS routes - Add /linux-do/posts route for latest posts - Add /linux-do/top/:period route for trending topics with period filter - Optimize /linux-do/latest route - Update namespace documentation with descriptions - Handle Zstandard compression by using Accept-Encoding: identity * revert: remove linux-do routes (PR rejected) * feat(route): add codefather (编程导航) routes - Add posts route with hot/new/recommend sorting and category filter - Add questions route with new/hot sorting - Support for 编程导航 programming community * fix: address all PR review comments - Reorder path params: category before sort - Remove config.trueUA (not needed) - Use upvotes/comments fields instead of description - Remove title slicing - Change default sort to 'new' - Remove title from description - Remove content truncation * feat(route): add maoyan (猫眼电影) routes Add three new routes for Maoyan: - /maoyan/box - Real-time box office ranking - /maoyan/hot - Currently showing movies - /maoyan/coming - Upcoming movies * fix: address PR review comments - Remove author field from box.ts (releaseInfo is not author) - Remove unnecessary mobile User-Agent from coming.ts and hot.ts
1 parent 417b943 commit 71d5ded

File tree

4 files changed

+231
-0
lines changed

4 files changed

+231
-0
lines changed

lib/routes/maoyan/box.ts

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
import type { Route } from '@/types';
2+
import ofetch from '@/utils/ofetch';
3+
4+
export const route: Route = {
5+
path: '/box',
6+
categories: ['multimedia'],
7+
example: '/maoyan/box',
8+
parameters: {},
9+
features: {
10+
requireConfig: false,
11+
requirePuppeteer: false,
12+
antiCrawler: false,
13+
supportBT: false,
14+
supportPodcast: false,
15+
supportScihub: false,
16+
},
17+
radar: [
18+
{
19+
source: ['piaofang.maoyan.com/dashboard'],
20+
target: '/box',
21+
},
22+
],
23+
name: '实时票房榜',
24+
maintainers: ['JackyST0'],
25+
handler,
26+
};
27+
28+
interface MovieItem {
29+
movieInfo: {
30+
movieId: number;
31+
movieName: string;
32+
releaseInfo: string;
33+
};
34+
boxRate: string;
35+
sumBoxDesc: string;
36+
showCount: number;
37+
showCountRate: string;
38+
avgSeatView: string;
39+
avgShowView: string;
40+
splitBoxRate: string;
41+
}
42+
43+
interface BoxResponse {
44+
movieList: {
45+
status: boolean;
46+
data: {
47+
list: MovieItem[];
48+
};
49+
};
50+
}
51+
52+
async function handler() {
53+
const apiUrl = 'https://piaofang.maoyan.com/dashboard-ajax';
54+
55+
const response = await ofetch<BoxResponse>(apiUrl, {
56+
headers: {
57+
Referer: 'https://piaofang.maoyan.com/dashboard',
58+
},
59+
});
60+
61+
const movies = response.movieList?.data?.list || [];
62+
63+
const items = movies.map((movie, index) => ({
64+
title: `${index + 1}. ${movie.movieInfo.movieName} - ${movie.sumBoxDesc}`,
65+
link: `https://www.maoyan.com/films/${movie.movieInfo.movieId}`,
66+
description: `
67+
<p><strong>${movie.movieInfo.movieName}</strong></p>
68+
<p>上映状态:${movie.movieInfo.releaseInfo}</p>
69+
<p>累计票房:${movie.sumBoxDesc}</p>
70+
<p>票房占比:${movie.boxRate}</p>
71+
<p>排片场次:${movie.showCount} 场 (${movie.showCountRate})</p>
72+
<p>上座率:${movie.avgSeatView}</p>
73+
<p>场均人次:${movie.avgShowView}</p>
74+
`,
75+
}));
76+
77+
return {
78+
title: '猫眼实时票房榜',
79+
link: 'https://piaofang.maoyan.com/dashboard',
80+
description: '猫眼电影实时票房排行榜',
81+
item: items,
82+
};
83+
}

lib/routes/maoyan/coming.ts

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
import type { Route } from '@/types';
2+
import ofetch from '@/utils/ofetch';
3+
4+
interface MovieItem {
5+
id: number;
6+
nm: string;
7+
img: string;
8+
sc: number;
9+
star: string;
10+
rt: string;
11+
showInfo?: string;
12+
wish: number;
13+
comingTitle: string;
14+
}
15+
16+
interface ComingResponse {
17+
coming: MovieItem[];
18+
}
19+
20+
export const route: Route = {
21+
path: '/coming',
22+
categories: ['multimedia'],
23+
example: '/maoyan/coming',
24+
parameters: {},
25+
features: {
26+
requireConfig: false,
27+
requirePuppeteer: false,
28+
antiCrawler: false,
29+
supportBT: false,
30+
supportPodcast: false,
31+
supportScihub: false,
32+
},
33+
radar: [
34+
{
35+
source: ['www.maoyan.com/films?showType=2', 'www.maoyan.com/films'],
36+
target: '/coming',
37+
},
38+
],
39+
name: '即将上映',
40+
maintainers: ['JackyST0'],
41+
handler,
42+
};
43+
44+
async function handler() {
45+
const apiUrl = 'https://m.maoyan.com/ajax/comingList?ci=1&limit=30&movieIds=&token=';
46+
47+
const response = await ofetch<ComingResponse>(apiUrl);
48+
49+
const movies = response.coming || [];
50+
51+
const items = movies.map((movie) => ({
52+
title: `[${movie.comingTitle}] ${movie.nm}`,
53+
link: `https://www.maoyan.com/films/${movie.id}`,
54+
description: `
55+
<img src="${movie.img}" />
56+
<p><strong>${movie.nm}</strong></p>
57+
<p>上映时间:${movie.rt}</p>
58+
<p>主演:${movie.star}</p>
59+
<p>想看人数:${movie.wish}</p>
60+
${movie.showInfo ? `<p>${movie.showInfo}</p>` : ''}
61+
`,
62+
}));
63+
64+
return {
65+
title: '猫眼电影 - 即将上映',
66+
link: 'https://www.maoyan.com/films?showType=2',
67+
description: '猫眼电影即将上映列表',
68+
item: items,
69+
};
70+
}

lib/routes/maoyan/hot.ts

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
import type { Route } from '@/types';
2+
import ofetch from '@/utils/ofetch';
3+
4+
interface MovieItem {
5+
id: number;
6+
nm: string;
7+
img: string;
8+
sc: number;
9+
star: string;
10+
rt: string;
11+
showInfo: string;
12+
wish: number;
13+
version?: string;
14+
}
15+
16+
interface HotResponse {
17+
movieList: MovieItem[];
18+
}
19+
20+
export const route: Route = {
21+
path: '/hot',
22+
categories: ['multimedia'],
23+
example: '/maoyan/hot',
24+
parameters: {},
25+
features: {
26+
requireConfig: false,
27+
requirePuppeteer: false,
28+
antiCrawler: false,
29+
supportBT: false,
30+
supportPodcast: false,
31+
supportScihub: false,
32+
},
33+
radar: [
34+
{
35+
source: ['www.maoyan.com/films?showType=1'],
36+
target: '/hot',
37+
},
38+
],
39+
name: '正在热映',
40+
maintainers: ['JackyST0'],
41+
handler,
42+
};
43+
44+
async function handler() {
45+
const apiUrl = 'https://m.maoyan.com/ajax/movieOnInfoList';
46+
47+
const response = await ofetch<HotResponse>(apiUrl);
48+
49+
const movies = response.movieList || [];
50+
51+
const items = movies.map((movie) => ({
52+
title: `${movie.sc ? `[${movie.sc}分] ` : ''}${movie.nm}`,
53+
link: `https://www.maoyan.com/films/${movie.id}`,
54+
description: `
55+
<img src="${movie.img}" />
56+
<p><strong>${movie.nm}</strong></p>
57+
${movie.sc ? `<p>评分:${movie.sc}</p>` : ''}
58+
<p>上映时间:${movie.rt}</p>
59+
<p>主演:${movie.star}</p>
60+
<p>想看人数:${movie.wish}</p>
61+
<p>${movie.showInfo}</p>
62+
`,
63+
}));
64+
65+
return {
66+
title: '猫眼电影 - 正在热映',
67+
link: 'https://www.maoyan.com/films?showType=1',
68+
description: '猫眼电影正在热映列表',
69+
item: items,
70+
};
71+
}

lib/routes/maoyan/namespace.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import type { Namespace } from '@/types';
2+
3+
export const namespace: Namespace = {
4+
name: '猫眼电影',
5+
url: 'maoyan.com',
6+
lang: 'zh-CN',
7+
};

0 commit comments

Comments
 (0)