Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(route): iqiyi album #11753

Merged
merged 1 commit into from
Feb 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions docs/multimedia.md
Original file line number Diff line number Diff line change
Expand Up @@ -1211,11 +1211,17 @@ JavDB 有多个备用域名,本路由默认使用永久域名 <https://javdb.c

### 用户视频

<Route author="talengu" example="/iqiyi/user/video/2289191062" path="/iqiyi/user/video/:uid" :paramsDesc="['用户名']" />
<Route author="talengu" example="/iqiyi/user/video/2289191062" path="/iqiyi/user/video/:uid" :paramsDesc="['用户名']" radar="1"/>

### 动漫
### 剧集

<Route author="TonyRL" example="/iqiyi/album/神武天尊-2020-1b4lufwxd7h" path="/iqiyi/album/:id" :paramsDesc="['剧集 id, 可在该主页 URL 中找到']" radar="1">

::: tip 提示
可抓取內容根据服务器所在地区而定
:::

<Route author="ranpox" example="/iqiyi/dongman/a_19rrh1sifx" path="/iqiyi/dongman/:id" :paramsDesc="['动漫 id, 可在该动漫主页 URL 中找到(不包括`.html`)']"/>
</Route>

## 哔嘀影视

Expand Down
4 changes: 2 additions & 2 deletions lib/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,8 @@ router.get('/geektime/news', lazyloadRouteHandler('./routes/geektime/news'));
router.get('/qdaily/:type/:id', lazyloadRouteHandler('./routes/qdaily/index'));

// 爱奇艺
router.get('/iqiyi/dongman/:id', lazyloadRouteHandler('./routes/iqiyi/dongman'));
router.get('/iqiyi/user/video/:uid', lazyloadRouteHandler('./routes/iqiyi/video'));
// router.get('/iqiyi/dongman/:id', lazyloadRouteHandler('./routes/iqiyi/dongman'));
// router.get('/iqiyi/user/video/:uid', lazyloadRouteHandler('./routes/iqiyi/video'));

// 南方周末
router.get('/infzm/:id', lazyloadRouteHandler('./routes/infzm/news'));
Expand Down
42 changes: 0 additions & 42 deletions lib/routes/iqiyi/dongman.js

This file was deleted.

62 changes: 62 additions & 0 deletions lib/v2/iqiyi/album.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const { parseDate } = require('@/utils/parse-date');
const { art } = require('@/utils/render');
const path = require('path');

module.exports = async (ctx) => {
const { id } = ctx.params;

const { data: response } = await got(`https://www.iq.com/album/${id}`);

const $ = cheerio.load(response);
const nextData = JSON.parse($('#__NEXT_DATA__').text());
const { album } = nextData.props.initialState;

const {
data: { data: baseInfo },
} = await got(`https://pcw-api.iqiyi.com/album/album/baseinfo/${album.videoAlbumInfo.albumId}`);

if (Object.keys(album.cacheAlbumList).length === 0) {
throw Error(`${baseInfo.name} is not available in this server region.`);
}

let pos = 1;
let hasMore = false;
let epgs = [];
do {
const {
data: { data },
// eslint-disable-next-line no-await-in-loop
} = await got(`https://pcw-api.iq.com/api/v2/episodeListSource/${album.videoAlbumInfo.albumId}`, {
searchParams: {
platformId: 3,
modeCode: 'intl',
langCode: 'zh_cn',
endOrder: album.videoAlbumInfo.maxOrder,
startOrder: pos,
},
});
epgs = [...epgs, ...data.epg];
pos = data.pos;
hasMore = data.hasMore;
} while (hasMore);

const items = epgs.map((item) => ({
title: item.name,
description: art(path.join(__dirname, 'templates/album.art'), {
item,
}),
link: `https://www.iq.com/play/${item.playLocSuffix}`,
pubDate: parseDate(item.initIssueTime),
}));

ctx.state.data = {
title: baseInfo.name,
description: baseInfo.description,
image: album.videoAlbumInfo.albumFocus1024,
link: `https://www.iq.com/album/${album.videoAlbumInfo.albumLocSuffix}`,
item: items,
allowEmpty: true,
};
};
4 changes: 4 additions & 0 deletions lib/v2/iqiyi/maintainer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
'/album/:id': ['TonyRL'],
'/user/video/:uid': ['talengu'],
};
24 changes: 24 additions & 0 deletions lib/v2/iqiyi/radar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
module.exports = {
'iq.com': {
_name: '爱奇艺',
'.': [
{
title: '剧集',
docs: 'https://docs.rsshub.app/multimedia.html#ai-qi-yi',
source: ['/album/:id'],
target: '/iqiyi/:category/:id',
},
],
},
'iqiyi.com': {
_name: '爱奇艺',
'.': [
{
title: '用户视频',
docs: 'https://docs.rsshub.app/multimedia.html#ai-qi-yi',
source: ['/u/:uid/*'],
target: '/iqiyi/user/video/:uid',
},
],
},
};
4 changes: 4 additions & 0 deletions lib/v2/iqiyi/router.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = (router) => {
router.get('/album/:id', require('./album'));
router.get('/user/video/:uid', require('./video'));
};
1 change: 1 addition & 0 deletions lib/v2/iqiyi/templates/album.art
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<img src="https:{{ item.pic.replace('http:', 'https:') }}">
File renamed without changes.