@@ -775,6 +775,10 @@ GitHub 官方也提供了一些 RSS:
|
||||
|
||||
<route name="新片精品" author="imgss" example="/dytt" path="/dytt/index"/>
|
||||
|
||||
### 优酷
|
||||
|
||||
<route name="频道" author="xyqfer" example="/youku/channel/UNTg3MTM3OTcy" path="/youku/channel/:channelId/:embed?" :paramsDesc="['频道 id', '默认为开启内嵌视频, 任意值为关闭']"/>
|
||||
|
||||
## 图片
|
||||
|
||||
### 妹子图
|
||||
|
||||
@@ -689,6 +689,9 @@ router.get('/chouti/:subject?', require('./routes/chouti'));
|
||||
// 西安电子科技大学
|
||||
router.get('/xidian/jwc/:category?', require('./routes/xidian/jwc'));
|
||||
|
||||
// 优酷
|
||||
router.get('/youku/channel/:channelId/:embed?', require('./routes/youku/channel'));
|
||||
|
||||
// 油价
|
||||
router.get('/oilprice/:area', require('./routes/oilprice'));
|
||||
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
const axios = require('../../utils/axios');
|
||||
const cheerio = require('cheerio');
|
||||
const path = require('path');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const channelId = ctx.params.channelId;
|
||||
const embed = !ctx.params.embed;
|
||||
|
||||
const response = await axios({
|
||||
method: 'get',
|
||||
url: `http://i.youku.com/i/${channelId}/videos`,
|
||||
headers: {
|
||||
Host: 'i.youku.com',
|
||||
Referer: `http://i.youku.com/i/${channelId}`,
|
||||
},
|
||||
});
|
||||
|
||||
const data = response.data;
|
||||
const $ = cheerio.load(data);
|
||||
const list = $('.items > .v');
|
||||
|
||||
ctx.state.data = {
|
||||
title: $('.username').text(),
|
||||
link: `http://i.youku.com/i/${channelId}`,
|
||||
description: $('.desc').text(),
|
||||
item:
|
||||
list &&
|
||||
list
|
||||
.map((index, item) => {
|
||||
item = $(item);
|
||||
const cover = item.find('.v-thumb img').attr('src');
|
||||
const title = item.find('.v-link a').attr('title');
|
||||
const $link = item.find('.v-meta-title > a');
|
||||
const link = $link.length > 0 ? `https:${$link.attr('href')}` : null;
|
||||
|
||||
if (link) {
|
||||
const videoId = path.parse(link).name.replace(/^id_/g, '');
|
||||
const iframe = `<iframe height=498 width=510 src='https://player.youku.com/embed/${videoId}' frameborder=0 'allowfullscreen'></iframe>`;
|
||||
|
||||
return {
|
||||
title,
|
||||
description: `
|
||||
${embed ? iframe : ''}
|
||||
<br>
|
||||
<img referrerpolicy="no-referrer" src="${cover}">
|
||||
`,
|
||||
link,
|
||||
};
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
})
|
||||
.get()
|
||||
.filter((item) => item),
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user