feat: add 片源网 (#3516)

This commit is contained in:
codeeer 2019-12-02 15:12:00 +08:00 committed by DIYgod
parent 6f1cb70e40
commit fae8a4306e
4 changed files with 72 additions and 0 deletions

View File

@ -480,6 +480,16 @@
},
],
},
'pianyuan.la': {
_name: '片源网',
'.': [
{
title: '电影和剧集',
description: 'https://docs.rsshub.app/multimedia.html#pian-yuan',
source: '/',
},
],
},
'sspai.com': {
_name: '少数派',
'.': [

View File

@ -276,6 +276,12 @@ pageClass: routes
<Route author="dearrrfish" example="/ningmeng/song" path="/ningmeng/song" />
## 片源网
### 最新资源
<Route author="greatcodeeer" example="/mv" path="/mv" supportBT="1"/>
## 色花堂中文论坛
### 原创 BT 电影

View File

@ -2007,4 +2007,7 @@ router.get('/transferwise/pair/:source/:target', require('./routes/transferwise/
// chocolatey
router.get('/chocolatey/software/:name?', require('./routes/chocolatey/software'));
// 片源网
router.get('/pianyuan/:media?', require('./routes/pianyuan/app'));
module.exports = router;

View File

@ -0,0 +1,53 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
module.exports = async (ctx) => {
const media = ctx.params.media || -1;
const link_base = 'http://pianyuan.la/';
let description = '电影和剧集';
let link = link_base;
if (media !== -1) {
link = link_base + `?cat=${media}`;
if (media === 'mv') {
description = '电影';
} else if (media === 'tv') {
description = '剧集';
} else {
link = link_base;
}
}
const response = await got.get(link);
const data = response.data;
const $ = cheerio.load(data);
const items = [];
$('#main-container > div > div.col-md-10 > table > tbody > tr').each(function(i, item) {
const link = $(item)
.find('td.dt.prel.nobr > a')
.attr('href');
const text = $(item)
.find('td.dt.prel.nobr > a')
.text();
const description = $(item)
.find('td.dt.prel.nobr')
.text()
.replace(/^\s+|\s+$/g, '');
const size = $(item)
.find('td:nth-child(2)')
.text();
items.push({
title: `[${size}] ${text}`,
description: description,
link: link_base + link,
});
});
ctx.state.data = {
title: `片源网`,
description: description,
link: link_base,
item: items,
};
};