Skip to content

Commit

Permalink
feat: recover shuiguopai (#14248)
Browse files Browse the repository at this point in the history
  • Loading branch information
TonyRL authored Jan 15, 2024
1 parent 450bdb3 commit 39c6720
Show file tree
Hide file tree
Showing 6 changed files with 119 additions and 0 deletions.
86 changes: 86 additions & 0 deletions lib/v2/shuiguopai/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const timezone = require('@/utils/timezone');
const { parseDate } = require('@/utils/parse-date');
const { art } = require('@/utils/render');
const path = require('path');

module.exports = async (ctx) => {
const rootUrl = 'https://sgptv.vip';
const apiRootUrl = 'https://api.cbbee0.com';
const listUrl = `${apiRootUrl}/v1_2/homePage`;
const filmUrl = `${apiRootUrl}/v1_2/filmInfo`;

const limit = ctx.query.limit ? parseInt(ctx.query.limit) : 50;

const response = await got({
method: 'post',
url: listUrl,
json: {
device_id: '',
hm: '008-api',
last_page: 0,
length: limit,
ltype: 1,
page: 1,
userToken: '',
},
});

let items = response.data.data.list.map((item) => ({
title: item.title,
guid: item.library_id,
link: `${rootUrl}/play-details/${item.library_id}`,
pubDate: timezone(parseDate(item.show_time_origin, 'YYYY-MM-DD HH:mm:ss'), +8),
category: item.tags.map((t) => t.tag_title),
}));

items = await Promise.all(
items.map((item) =>
ctx.cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
});

const content = cheerio.load(detailResponse.data);
content('iframe').remove();

let videos;
const filmId = detailResponse.data.match(/film_id:"([\d,]+)",/)?.[1];
if (filmId) {
const infoResponse = await got({
method: 'post',
url: filmUrl,
json: {
device_id: '',
film_id: filmId,
hm: '008-api',
userToken: '',
},
});

const data = infoResponse.data.data;

videos = data.map((d) => d.download_url);

item.category = data.flatMap((d) => d.tags.map((t) => t.tag_title));
item.author = data.map((d) => d.actor).join(' ');
}

item.description = art(path.join(__dirname, 'templates/description.art'), {
videos,
description: content('.content').html(),
});

return item;
})
)
);

ctx.state.data = {
title: '水果派',
link: rootUrl,
item: items,
};
};
3 changes: 3 additions & 0 deletions lib/v2/shuiguopai/maintainer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
'/': ['nczitzk'],
};
13 changes: 13 additions & 0 deletions lib/v2/shuiguopai/radar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module.exports = {
'shuiguopai.com': {
_name: '水果派',
'.': [
{
title: '首页',
docs: 'https://docs.rsshub.app/routes/new-media#shui-guo-pai-shou-ye',
source: ['/'],
target: '/shuiguopai',
},
],
},
};
3 changes: 3 additions & 0 deletions lib/v2/shuiguopai/router.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = function (router) {
router.get('/', require('./index'));
};
8 changes: 8 additions & 0 deletions lib/v2/shuiguopai/templates/description.art
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{{ if videos }}
{{ each videos video }}
<video controls>
<source src="{{ video }}" type="video/mp4">
</video>
{{ /each }}
{{ /if }}
{{@ description }}
6 changes: 6 additions & 0 deletions website/docs/routes/new-media.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4340,6 +4340,12 @@
| all | weekly | monthly | international | hot | favorite |
</Route>

## 水果派 {#shui-guo-pai}

### 首页 {#shui-guo-pai-shou-ye}

<Route author="nczitzk" example="/shuiguopai" path="/shuiguopai" radar="1" />

## 搜狐号 {#sou-hu-hao}

### 更新 {#sou-hu-hao-geng-xin}
Expand Down

0 comments on commit 39c6720

Please sign in to comment.