Skip to content

Commit

Permalink
Merge pull request #58 from DIYgod/master
Browse files Browse the repository at this point in the history
[pull] master from diygod:master
  • Loading branch information
pull[bot] authored Sep 16, 2023
2 parents 71abaab + ad99b02 commit 732622d
Show file tree
Hide file tree
Showing 17 changed files with 320 additions and 92 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/docker-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ on:
- '!lib/v2/test/**'
- '!test/**'
- 'Dockerfile'
- 'package.json'
- 'pnpm-lock.yaml'
workflow_dispatch: ~

jobs:
Expand Down
3 changes: 3 additions & 0 deletions lib/v2/gamegene/maintainer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
'/news': ['lone1y-51'],
};
50 changes: 50 additions & 0 deletions lib/v2/gamegene/news.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const { parseDate } = require('@/utils/parse-date');

module.exports = async (ctx) => {
const url = 'https://gamegene.cn/news';
const { data: response } = await got({
method: 'get',
url,
});
const $ = cheerio.load(response);
const list = $('div.mr245')
.toArray()
.map((item) => {
item = $(item);
const aEle = item.find('a').first();
const href = aEle.attr('href');
const title = aEle.find('h3').first().text();
const author = item.find('a.namenode').text();
const category = item.find('span.r').text();
return {
title,
link: href,
author,
category,
};
});
const items = await Promise.all(
list.map((item) =>
ctx.cache.tryGet(item.link, async () => {
const { data: response } = await got({
method: 'get',
url: item.link,
});
const $ = cheerio.load(response);
const dateTime = $('div.meta').find('time').first().text();
item.pubDate = parseDate(dateTime);
item.description = $('div.content').first().html();
return item;
})
)
);

ctx.state.data = {
// 在此处输出您的 RSS
item: items,
link: url,
title: '游戏基因 GameGene',
};
};
13 changes: 13 additions & 0 deletions lib/v2/gamegene/radar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module.exports = {
'gamegene.cn': {
_name: '游戏基因',
news: [
{
title: '资讯',
docs: 'https://docs.rsshub.app/routes/game#you-xi-ji-yin',
source: ['/news'],
target: '/gamegene/news',
},
],
},
};
3 changes: 3 additions & 0 deletions lib/v2/gamegene/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'));
};
52 changes: 52 additions & 0 deletions lib/v2/lsnu/jiaowc/tzgg.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');

module.exports = async (ctx) => {
const category = ctx.params.category;
const url = category ? `https://jiaowc.lsnu.edu.cn/tzgg/${category}.htm` : 'https://jiaowc.lsnu.edu.cn/tzgg.htm';

const response = await got({
method: 'get',
url,
});

const data = response.data;

const $ = cheerio.load(data);
const list = $('tr[id^="line_u5_"]').get();

const out = await Promise.all(
list.map(async (item) => {
const $ = cheerio.load(item);
const title = $('a').attr('title');
const link = `https://jiaowc.lsnu.edu.cn/${$('a').attr('href')}`;
const date = $('td[width="80"]').text();

const single = await ctx.cache.tryGet(link, async () => {
const response = await got({
method: 'get',
url: link,
});

const articleData = response.data;
const article$ = cheerio.load(articleData);
const description = article$('.v_news_content').html();

return {
title,
link,
description,
pubDate: new Date(date).toUTCString(),
};
});

return single;
})
);

ctx.state.data = {
title: '乐山师范学院教学部通知公告',
link: 'https://jiaowc.lsnu.edu.cn/tzgg.htm',
item: out,
};
};
3 changes: 3 additions & 0 deletions lib/v2/lsnu/maintainer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
'/jiaowc/tzgg/:category?': ['nyaShine'],
};
13 changes: 13 additions & 0 deletions lib/v2/lsnu/radar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module.exports = {
'lsnu.edu.cn': {
_name: '乐山师范学院',
'.': [
{
title: '教学部通知公告',
docs: 'https://docs.rsshub.app/university.html#le-shan-shi-fan-xue-yuan',
source: ['/'],
target: '/lsnu/jiaowc/tzgg',
},
],
},
};
3 changes: 3 additions & 0 deletions lib/v2/lsnu/router.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = (router) => {
router.get('/jiaowc/tzgg/:category?', require('./jiaowc/tzgg'));
};
1 change: 1 addition & 0 deletions lib/v2/rsshub/maintainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ module.exports = {
'/rsshub/sponsors': ['DIYgod'],
'/transform/html/:url/:routeParams': ['ttttmr'],
'/transform/json/:url/:routeParams': ['ttttmr'],
'/transform/sitemap/:url/:routeParams?': ['flrngel'],
};
1 change: 1 addition & 0 deletions lib/v2/rsshub/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ module.exports = (router) => {
router.get('/sponsors', require('./sponsors'));
router.get('/transform/html/:url/:routeParams', require('./transform/html'));
router.get('/transform/json/:url/:routeParams', require('./transform/json'));
router.get('/transform/sitemap/:url/:routeParams?', require('./transform/sitemap'));
};
52 changes: 52 additions & 0 deletions lib/v2/rsshub/transform/sitemap.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const config = require('@/config').value;

module.exports = async (ctx) => {
if (!config.feature.allow_user_supply_unsafe_domain) {
ctx.throw(403, `This RSS is disabled unless 'ALLOW_USER_SUPPLY_UNSAFE_DOMAIN' is set to 'true'.`);
}
const { url } = ctx.params;
const response = await got({
method: 'get',
url,
});

const routeParams = new URLSearchParams(ctx.params.routeParams);
const $ = cheerio.load(response.data, { xmlMode: true });

const rssTitle = routeParams.get('title') ? routeParams.get('title') : $('urlset url').length && $('urlset url').first().find('loc').text() ? $('urlset url').first().find('loc').text() : 'Sitemap';

let items;
const urls = $('urlset url').toArray();
if (urls && urls.length) {
items = urls
.map((item) => {
try {
const title = $(item).find('loc').text() || '';
const link = $(item).find('loc').text() || '';
const description = $(item).find('loc').text() || '';
const pubDate = $(item).find('lastmod').text() || undefined;

return {
title,
link,
description,
pubDate,
};
} catch (e) {
return null;
}
})
.filter(Boolean);
} else {
items = [];
}

ctx.state.data = {
title: rssTitle,
link: url,
description: `Proxy ${url}`,
item: items,
};
};
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -154,17 +154,17 @@
"@types/eslint": "8.44.2",
"@types/eslint-config-prettier": "6.11.0",
"@types/etag": "1.8.1",
"@types/fs-extra": "11.0.1",
"@types/fs-extra": "11.0.2",
"@types/git-rev-sync": "2.0.0",
"@types/imapflow": "1.0.13",
"@types/jsdom": "21.1.2",
"@types/json-bigint": "1.0.1",
"@types/koa": "2.13.8",
"@types/koa": "2.13.9",
"@types/koa-basic-auth": "2.0.4",
"@types/koa-favicon": "2.0.21",
"@types/koa-mount": "4.0.2",
"@types/koa-favicon": "2.0.22",
"@types/koa-mount": "4.0.3",
"@types/koa-static": "4.0.2",
"@types/koa__router": "12.0.0",
"@types/koa__router": "12.0.1",
"@types/lint-staged": "13.2.0",
"@types/mailparser": "3.4.0",
"@types/markdown-it": "13.0.1",
Expand Down
54 changes: 27 additions & 27 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 732622d

Please sign in to comment.