mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-09-01 14:57:14 +08:00
feat: update 3dm download rss (#496)
This commit is contained in:
@@ -11,3 +11,4 @@ docs/.vuepress/dist
|
||||
config/app.json
|
||||
config/config.js
|
||||
|
||||
yarn-error.log
|
||||
|
||||
@@ -160,6 +160,7 @@ RSSHub 是一个轻量、易于扩展的 RSS 生成器,可以给任何奇奇
|
||||
- 新闻中心
|
||||
- 新闻
|
||||
- 攻略
|
||||
- 下载
|
||||
- 喜马拉雅
|
||||
- 专辑
|
||||
- EZTV
|
||||
|
||||
@@ -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"/>
|
||||
|
||||
@@ -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'));
|
||||
|
||||
|
||||
@@ -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,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user