feat: update 3dm download rss (#496)

This commit is contained in:
Jeff Wen
2018-08-20 14:20:46 +08:00
committed by DIYgod
parent 29673882dc
commit 9f42bbfbba
5 changed files with 63 additions and 0 deletions
+1
View File
@@ -11,3 +11,4 @@ docs/.vuepress/dist
config/app.json
config/config.js
yarn-error.log
+1
View File
@@ -160,6 +160,7 @@ RSSHub 是一个轻量、易于扩展的 RSS 生成器,可以给任何奇奇
- 新闻中心
- 新闻
- 攻略
- 下载
- 喜马拉雅
- 专辑
- EZTV
+8
View File
@@ -1322,6 +1322,14 @@ language,语言,可在 [Trending 页](https://github.com/trending/javascript
参数: name,游戏的编号可以在专题页的 url 中找到
### 下载 <Author uid="sinchang"/>
举例: [https://rsshub.app/3dm/detroitbecomehuman/download](https://rsshub.app/3dm/detroitbecomehuman/download)
路由: `/3dm/:name/download`
参数: name,游戏的编号可以在专题页的 url 中找到
## 喜马拉雅
### 专辑 <Author uid="jjeejj"/>
+1
View File
@@ -285,6 +285,7 @@ router.get('/nytimes/morning_post', require('./routes/nytimes/morning_post'));
router.get('/uukanshu/chapter/:uid', require('./routes/uukanshu/chapter'));
// 3dm
router.get('/3dm/:name/download', require('./routes/3dm/download'));
router.get('/3dm/:name/:type', require('./routes/3dm/news'));
router.get('/3dm/news', require('./routes/3dm/news_center'));
+52
View File
@@ -0,0 +1,52 @@
const axios = require('../../utils/axios');
const cheerio = require('cheerio');
const config = require('../../config');
module.exports = async (ctx) => {
const name = ctx.params.name;
const type = 'download';
const url = `http://www.3dmgame.com/games/${name}/${type}`;
const response = await axios({
method: 'get',
url: url,
headers: {
'User-Agent': config.ua,
},
});
const data = response.data;
const $ = cheerio.load(data);
const list = $('.ZQ_Left .Llis_4 li');
const items = [];
for (let i = 0; i < list.length; i++) {
let item = $(list[i]);
const url = item.find('.bt').attr('href');
const value = await ctx.cache.get(url);
if (value) {
item = JSON.parse(value);
} else {
item = {
title: item.find('.bt').text(),
pubDate: item.find('p').text(),
link: url,
guid: url,
};
ctx.cache.set(url, JSON.stringify(item), 24 * 60 * 60);
}
items.push(item);
}
ctx.state.data = {
title: $('title')
.text()
.split('_')[0],
link: url,
item: items,
};
};