Skip to content

Commit

Permalink
feat(route): add 时光网 (#9443)
Browse files Browse the repository at this point in the history
* Create 1.txt

* Add files via upload

* Delete lib/v2/mtime directory

* Add files via upload

* Update multimedia.md

* Update multimedia.md

* Update and rename lib/v2/mtime/news.js to 自由/版本 2/mtime/news.js

* Delete news.js

* Add files via upload

* Update multimedia.md

* Update news.js

* Update news.js

* Update news.js

* Update news.js

* Update radar.js

* Update radar.js

* Update radar.js

* Update news.js

* Update news.js

* Update news.js
  • Loading branch information
TsSmartTT authored Apr 2, 2022
1 parent 5b35471 commit 577541f
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 0 deletions.
6 changes: 6 additions & 0 deletions docs/multimedia.md
Original file line number Diff line number Diff line change
Expand Up @@ -1496,3 +1496,9 @@ Tiny Tiny RSS 会给所有 iframe 元素添加 `sandbox="allow-scripts"` 属性
### 综艺

<Route author="pharaoh2012" example="/zyshow/chongchongchong" path="/zyshow/:name" :paramsDesc="['综艺 name,对应综艺的 URL 中找到']" radar="1" rssbud="1"/>

## 时光网

### 资讯

<Route author="TsSmartTT" example="/mtime/news" path="/mtime/news" radar="1" rssbud="1"/>
3 changes: 3 additions & 0 deletions lib/v2/mtime/maintainer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
'/mtime/news': ['TsSmartTT'],
};
48 changes: 48 additions & 0 deletions lib/v2/mtime/news.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const timezone = require('@/utils/timezone');
const { parseDate } = require('@/utils/parse-date');

module.exports = async (ctx) => {
const link = 'http://news.mtime.com/';
const response = await got({
method: 'get',
url: link,
});
const $ = cheerio.load(response.data);
const list = $('ul.left-cont.fix li')
.map((_, item) => {
item = $(item);
return {
title: item.find('h4 a').text(),
link: item.find('h4 a').attr('href'),
};
})
.get();

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

content('.DRE-subject-wrapper').remove();

item.author = content('.editor').text().replace('编辑:', '');
item.description = content('.body').first().html();
item.pubDate = timezone(parseDate(content('.userCreateTime').text()), 8);

return item;
})
)
);

ctx.state.data = {
title: 'Mtime时光网 - 资讯',
link,
item: items,
};
};
13 changes: 13 additions & 0 deletions lib/v2/mtime/radar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module.exports = {
'mtime.com': {
_name: '时光网',
'news': [
{
title: '资讯',
docs: 'https://docs.rsshub.app/multimedia.html#shi-guang-wang',
source: '/',
target: '/mtime/news',
},
],
},
};
3 changes: 3 additions & 0 deletions lib/v2/mtime/router.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = function (router) {
router.get('/news', require('./news'));
};

0 comments on commit 577541f

Please sign in to comment.