merge upstream

This commit is contained in:
Indexyz
2018-09-03 02:38:04 +08:00
12 changed files with 146 additions and 91 deletions

View File

@@ -1278,15 +1278,15 @@ GitHub 官方也提供了一些 RSS:
### 直播开播 <Author uid="Qixingchen"/>
<#哔哩哔哩直播>
[#哔哩哔哩直播](#哔哩哔哩直播)
### 直播搜索 <Author uid="Qixingchen"/>
<#哔哩哔哩直播>
[#哔哩哔哩直播](#哔哩哔哩直播)
### 直播分区 <Author uid="Qixingchen"/>
<#哔哩哔哩直播>
[#哔哩哔哩直播](#哔哩哔哩直播)
### 主站话题列表 <Author uid="Qixingchen"/>
@@ -1506,6 +1506,14 @@ GitHub 官方也提供了一些 RSS:
- id, 用户 id, 可在即刻 web 端用户页 URL 中找到
### 即刻小报 <Author uid="Andiedie"/>
举例: <https://rsshub.app/jike/daily>
路由: `/jike/daily`
参数: 无
## 微信
::: tip 提示
@@ -2587,7 +2595,7 @@ GitHub 官方也提供了一些 RSS:
### App Store/Mac App Store
<#app-store-mac-app-store>
[#app-store-mac-app-store](#app-store-mac-app-store)
## Minecraft CurseForge

View File

@@ -15,16 +15,9 @@ RSSHub is a lightweight and extensible RSS feed aggregator, it's able to generat
### Special Sponsors
<p>
<a href="https://rixcloud.app/rsshub" target="_blank">
<img width="200px" src="https://i.imgur.com/PpcSVCZ.png">
</a>
</p>
<p>
<a href="https://werss.app?utm_source=rsshub" target="_blank">
<img width="150px" src="https://cdn.weapp.design/werss/werss-logo.png">
</a>
</p>
| <a href="https://rixcloud.app/rsshub" target="_blank"><img width="240px" src="https://i.imgur.com/qRP0eMg.png"></a> | <a href="https://werss.app?utm_source=rsshub" target="_blank"><img width="170px" src="https://cdn.weapp.design/werss/werss-logo.png"></a> | <a href="https://j.youzan.com/ccPcrY" target="_blank"><img width="180px" src="https://i.imgur.com/FZtFAGz.png"></a> |
| :-----------------------------------------------------------------------------------------------------------------: | :---------------------------------------------------------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------------------------: |
### Sponsors

View File

@@ -96,7 +96,7 @@ ctx.state.data = {
itunes_item_image: '', // The item image
enclosure_url: '', // The item's audio link
enclosure_length: '', // The audio length, the unit is seconds.
enclosure_type: '', // 'audio/mpeg' or 'audio/m4a' or others
enclosure_type: '', // 'audio/mpeg' or 'audio/x-m4a' or others
itunes_duration: '', // Covert the 'enclosure_length' to hh:mm:ss (1:33:52)
},
],

View File

@@ -96,7 +96,7 @@ ctx.state.data = {
itunes_item_image: '', // 图像
enclosure_url: '', // 音频链接
enclosure_length: '', // 时间戳 (播放长度) , 一般是秒数
enclosure_type: '', // [.mp3就填'audio/mpeg'] [.m4a就填'audio/m4a'], 或其他类型.
enclosure_type: '', // [.mp3就填'audio/mpeg'] [.m4a就填'audio/x-m4a'], 或其他类型.
itunes_duration: '', // 由enclosure_length转换为 时:分:秒
},
],

View File

@@ -233,6 +233,7 @@ if (config.youtube && config.youtube.key) {
router.get('/jike/topic/:id', require('./routes/jike/topic'));
router.get('/jike/topic/square/:id', require('./routes/jike/topicSquare'));
router.get('/jike/user/:id', require('./routes/jike/user'));
router.get('/jike/daily', require('./routes/jike/daily'));
// 极客时间
router.get('/geektime/column/:cid', require('./routes/geektime/column'));

View File

@@ -40,7 +40,7 @@ module.exports = async (ctx) => {
item = {
title: `${item.title} - ${item.author}`,
description: `${item.description}<img referrerpolicy="no-referrer" src="${item.pic}"></br>Tags:${item.tag}`,
description: `${item.description}<img referrerpolicy="no-referrer" src="${item.pic}"><br/>Tags:${item.tag}`,
pubDate: new Date(item.pubdate).toUTCString(),
link: item.arcurl,
};

19
routes/jike/daily.js Normal file
View File

@@ -0,0 +1,19 @@
const axios = require('../../utils/axios');
module.exports = async (ctx) => {
const {
data: { data },
} = await axios.get('https://app.jike.ruguoapp.com/1.0/dailies/list');
ctx.state.data = {
title: '即刻小报',
link: 'https://jike.app/',
description: '不定期呈现的即刻内容精选',
item: data.map((item) => ({
title: item.title,
description: `<img referrerpolicy="no-referrer" src="${item.picture}">`,
pubDate: new Date(item.date).toUTCString(),
link: `https://m.okjike.com/dailies/${item.id}`,
})),
};
};

View File

@@ -21,23 +21,34 @@ module.exports = async (ctx) => {
});
const $ = cheerio.load(response.data);
const list = $('.content')
const urlList = $('.content')
.find('a')
.slice(0, 10)
.map((i, e) => $(e).attr('href'))
.get();
const titleList = $('.content')
.find('a')
.slice(0, 10)
.map((i, e) => $(e).attr('title'))
.get();
const dateList = $('.content tr')
.find('div')
.slice(0, 10)
.map((i, e) => $(e).text())
.get();
const out = await Promise.all(
list.map(async (itemUrl) => {
urlList.map(async (itemUrl, index) => {
itemUrl = url.resolve(host, itemUrl);
if (itemUrl.indexOf('.htm') !== -1) {
const cache = await ctx.cache.get(itemUrl);
if (cache) {
return Promise.resolve(JSON.parse(cache));
}
const response = await axios.get(itemUrl);
const $ = cheerio.load(response.data);
const single = {
title: $('.Article_Title').text(),
link: itemUrl,
@@ -54,6 +65,15 @@ module.exports = async (ctx) => {
};
ctx.cache.set(itemUrl, JSON.stringify(single), 24 * 60 * 60);
return Promise.resolve(single);
} else {
const single = {
title: titleList[index],
link: itemUrl,
description: '该通知为文件,请点击原文链接↑下载',
pubDate: dateList,
};
return Promise.resolve(single);
}
})
);
let info = '通知公告';

View File

@@ -21,7 +21,7 @@ module.exports = async (ctx) => {
const text = $('.hvr-shutter-out-vertical');
ctx.state.data = {
title: '',
title: '北大信科通知',
link: host + 'Survey/Notice/?Mtitle=' + type,
description: '北大信科 公告通知',
item:
@@ -31,7 +31,7 @@ module.exports = async (ctx) => {
item = $(item);
return {
title: item.find('p').text(),
link: host + item.attr('href'),
link: host + 'Survey/Notice/' + item.attr('href'),
description: item.find('p').text(),
pubDate: item.find('em').text(),
};

View File

@@ -1,67 +1,77 @@
const axios = require('../../utils/axios');
const baseUrl = 'http://www.ximalaya.com';
const axios_ins = axios.create({
responseType: 'json',
});
const axios_ins = axios.create({});
module.exports = async (ctx) => {
const id = ctx.params.id; // 专辑id
const AlbumInfoApi = `http://www.ximalaya.com/revision/album?albumId=${id}`; // 专辑数据的API
const TrackInfoApi = 'http://mobile.ximalaya.com/v1/track/baseInfo?device=android&trackId=';
const AlbumInfoApi = `https://www.ximalaya.com/revision/album?albumId=${id}`; // 专辑数据的API
const AlbumInfoResponse = await axios_ins.get(AlbumInfoApi);
const albuminfo = AlbumInfoResponse.data.data.mainInfo; // 专辑数据
const authorinfo = AlbumInfoResponse.data.data.anchorInfo; // 作者数据
const trackinfo = AlbumInfoResponse.data.data.tracksInfo; // tracks数据
const author = authorinfo.anchorName;
const author_intro = authorinfo.personalIntroduction;
const classify = albuminfo.crumbs.categoryPinyin; // 专辑分类的拼音
const album_category = albuminfo.crumbs.categoryTitle; // 专辑分类
const albuminfo = AlbumInfoResponse.data.data.mainInfo; // 专辑数据
const album_title = albuminfo.albumTitle; // 专辑标题
const album_cover = albuminfo.cover.split('&')[0];
const classify = albuminfo.crumbs.categoryPinyin; // 专辑分类
const album_category = albuminfo.crumbs.categoryTitle; // 专辑分类名字
const album_intro = albuminfo.richIntro; // 专辑介绍
const album_desc = author_intro + ' <br/>' + album_intro;
const albumUrl = '/' + classify + '/' + id + '/'; // 某分类的链接
const ispaid = albuminfo.isPaid; // 是否需要付费
const album_title = albuminfo.albumTitle; // 专辑标题
const album_url = baseUrl + albumUrl; // 专辑链接
const album_desc = authorinfo.anchorName + ' ' + authorinfo.personalIntroduction + ' </br>' + albuminfo.detailRichIntro;
const album_cover_url = albuminfo.cover.split('&')[0];
const album_author = authorinfo.anchorName;
const tracks_count = trackinfo.trackTotalCount;
const PlayInfoApi = `http://mobile.ximalaya.com/mobile/v1/album/track?albumId=${id}&pageSize=${tracks_count}`; // 声音播放数据
const PlayInfoResponse = await axios_ins.get(PlayInfoApi);
const playList = PlayInfoResponse.data.data.list;
const tracksinfo = AlbumInfoResponse.data.data.tracksInfo; // 专辑数据
const playList = tracksinfo.tracks;
const resultItems = await Promise.all(
playList.map(async (item) => {
const title = item.title;
let desc = title + '</br>查看收听提示: </br>' + baseUrl + albumUrl + item.trackId;
if (ispaid) {
desc = title + '</br> [付费内容无法收听] 原文链接: </br>' + baseUrl + albumUrl + item.trackId;
}
const enclosure_length = item.duration; // 时间长度:单位(秒)
// itunes_duration格式<itunes:duration>32:46</itunes:duration>
const itunes_duration = Math.floor(enclosure_length / 3600) + ':' + Math.floor((enclosure_length % 3600) / 60) + ':' + (((enclosure_length % 3600) % 60) / 100).toFixed(2).slice(-2);
const trackId = item.trackId;
const trackUrl = item.url;
const link = baseUrl + trackUrl;
const resultItem = {
let resultItem = {};
const value = await ctx.cache.get(link);
if (value) {
resultItem = JSON.parse(value);
} else {
const track = await axios_ins.get(TrackInfoApi + trackId);
const track_item = track.data;
const enclosure_length = track_item.duration; // 时间长度:单位(秒)
const itunes_duration = Math.floor(enclosure_length / 3600) + ':' + Math.floor((enclosure_length % 3600) / 60) + ':' + (((enclosure_length % 3600) % 60) / 100).toFixed(2).slice(-2);
let desc = track_item.intro;
if (ispaid) {
desc = '<br/> [付费内容无法收听]<br/>' + track_item.intro;
}
resultItem = {
title: title,
link: baseUrl + albumUrl + item.trackId,
link: link,
description: desc,
pubDate: new Date(item.createdAt).toUTCString(),
itunes_item_image: item.coverLarge,
enclosure_url: item.playPathAacv224,
pubDate: new Date(track_item.createdAt).toUTCString(),
itunes_item_image: track_item.coverLarge.split('&')[0],
enclosure_url: track_item.downloadUrl,
enclosure_length: enclosure_length,
enclosure_type: 'audio/m4a',
enclosure_type: 'audio/aac',
itunes_duration: itunes_duration,
};
ctx.cache.set(link, JSON.stringify(resultItem), 24 * 60 * 60);
}
return Promise.resolve(resultItem);
})
);
ctx.state.data = {
title: `${album_title}`,
link: `${album_url}`,
link: `${baseUrl + albumUrl}`,
description: album_desc,
image: album_cover_url,
itunes_author: album_author,
image: album_cover,
itunes_author: author,
itunes_category: album_category,
item: resultItems,
};

View File

@@ -12,21 +12,25 @@ module.exports = async (ctx) => {
const type = ctx.params.type || 'china';
let info = '中港台';
let word = 'div#CN.list-sect-sub';
let word = '/realtime/china';
let div = 'div#CN.list-sect-sub';
if (type === '2') {
info = 'singapore';
word = 'div#SG.list-sect-sub';
word = '/realtime/singapore';
div = 'div#SG.list-sect-sub';
} else if (type === 'world') {
info = '国际';
word = 'div#Global.list-sect-sub';
word = '/realtime/world';
div = 'div#Global.list-sect-sub';
} else if (type === 'zfinance') {
info = '财经';
word = 'div#Finance.list-sect-sub';
word = '/zfinance/realtime';
div = 'div#Finance.list-sect-sub';
}
const response = await axios_ins.get(host);
const $ = cheerio.load(response.data);
const data = $('li', word).find('div');
const data = $('li', div).find('div');
// .attr('about')
const resultItems = await Promise.all(
data.toArray().map(async (item) => {
@@ -59,7 +63,7 @@ module.exports = async (ctx) => {
.replace(/(.{2})/, '$1:');
let description = '';
$1('p', '.article-content-container').each(function() {
description = description + $(this).html() + '<br/>';
description = description + '<p>' + $(this).html() + '</p>';
});
resultItem = {
@@ -78,7 +82,7 @@ module.exports = async (ctx) => {
ctx.state.data = {
title: `《联合早报》${info} 即时`,
link: host,
link: baseUrl + word,
description: '《联合早报》被公认是一份素质高、负责任、报道客观、言论公正、可信度高的报纸,对中国的发展采取积极的态度,在华人世界中享有崇高的信誉。',
item: resultItems,
};

View File

@@ -55,7 +55,7 @@ module.exports = async (ctx) => {
const date = res.replace('发布/', '').toString();
let description = '';
$1('p', '.article-content-container').each(function() {
description = description + $(this).html() + '<br/>';
description = description + '<p>' + $(this).html() + '</p>';
});
resultItem = {