Skip to content

Commit

Permalink
Merge pull request #2307 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 Dec 8, 2023
2 parents 9f75903 + aea213e commit 01af97c
Show file tree
Hide file tree
Showing 43 changed files with 420 additions and 38 deletions.
4 changes: 2 additions & 2 deletions lib/v2/1point3acres/maintainer.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
module.exports = {
'/blog/:category?': ['nczitzk'],
'/category/:id?/:type?/:order?': ['nczitzk'],
'/offer/:year?/:major?/:school?': ['NavePnow'],
'/post/:type?/:order?': ['NavePnow', 'DIYgod', 'nczitzk'],
'/offer/:year?/:major?/:school?': ['EthanWng97'],
'/post/:type?/:order?': ['EthanWng97', 'DIYgod', 'nczitzk'],
'/section/:id?/:type?/:order?': ['nczitzk'],
'/user/:id/posts': ['Maecenas'],
'/user/:id/threads': ['Maecenas'],
Expand Down
2 changes: 1 addition & 1 deletion lib/v2/amazon/maintainer.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = {
'/awsblogs/:locale?': ['HankChow'],
'/kindle/software-updates': ['NavePnow'],
'/kindle/software-updates': ['EthanWng97'],
};
6 changes: 3 additions & 3 deletions lib/v2/arcteryx/maintainer.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = {
'/new-arrivals/:country/:gender': ['NavePnow'],
'/outlet/:country/:gender': ['NavePnow'],
'/regear/new-arrivals': ['NavePnow'],
'/new-arrivals/:country/:gender': ['EthanWng97'],
'/outlet/:country/:gender': ['EthanWng97'],
'/regear/new-arrivals': ['EthanWng97'],
};
2 changes: 1 addition & 1 deletion lib/v2/bellroy/maintainer.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = {
'/new-releases': ['NavePnow'],
'/new-releases': ['EthanWng97'],
};
2 changes: 2 additions & 0 deletions lib/v2/gov/maintainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ module.exports = {
'/pbc/tradeAnnouncement': ['nczitzk'],
'/pbc/zcyj': ['Fatpandac'],
'/samr/xgzlyhd/:category?/:department?': ['nczitzk'],
'/safe/bussiness/:site?': ['nczitzk'],
'/safe/complaint/:site?': ['nczitzk'],
'/sasac/:path+': ['TonyRL'],
'/stats/:path+': ['bigfei', 'nczitzk'],
'/zhengce/govall/:advance?': ['ciaranchen'],
Expand Down
25 changes: 25 additions & 0 deletions lib/v2/gov/radar.js
Original file line number Diff line number Diff line change
Expand Up @@ -1185,6 +1185,31 @@ module.exports = {
},
],
},
'safe.gov.cn': {
_name: '国家外汇管理局',
'.': [
{
title: '业务咨询',
docs: 'https://docs.rsshub.app/routes/government#guo-jia-wai-hui-guan-li-ju-ye-wu-zi-xun',
source: ['/:site/ywzx/index.html'],
target: (params) => {
const site = params.site;

return `/gov/safe/business/${site}`;
},
},
{
title: '投诉建议',
docs: 'https://docs.rsshub.app/routes/government#guo-jia-wai-hui-guan-li-ju-tou-su-jian-yi',
source: ['/:site/tsjy/index.html'],
target: (params) => {
const site = params.site;

return `/gov/safe/complaint/${site}`;
},
},
],
},
'sasac.gov.cn': {
_name: '国务院国有资产监督管理委员会',
'.': [
Expand Down
2 changes: 2 additions & 0 deletions lib/v2/gov/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ module.exports = function (router) {
router.get('/pbc/gzlw', require('./pbc/gzlw'));
router.get('/pbc/tradeAnnouncement', require('./pbc/tradeAnnouncement'));
router.get('/pbc/zcyj', require('./pbc/zcyj'));
router.get('/safe/business/:site?', require('./safe/business'));
router.get('/safe/complaint/:site?', require('./safe/complaint'));
router.get('/samr/xgzlyhd/:category?/:department?', require('./samr/xgzlyhd'));
router.get('/sasac/:path+', require('./sasac/generic'));
router.get(/stats(\/[\w/-]+)?/, require('./stats'));
Expand Down
8 changes: 8 additions & 0 deletions lib/v2/gov/safe/business.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const { processZxfkItems } = require('./util');

module.exports = async (ctx) => {
const { site = 'beijing' } = ctx.params;
const limit = ctx.query.limit ? parseInt(ctx.query.limit, 10) : 3;

ctx.state.data = await processZxfkItems(site, 'ywzx', limit);
};
8 changes: 8 additions & 0 deletions lib/v2/gov/safe/complaint.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const { processZxfkItems } = require('./util');

module.exports = async (ctx) => {
const { site = 'beijing' } = ctx.params;
const limit = ctx.query.limit ? parseInt(ctx.query.limit, 10) : 5;

ctx.state.data = await processZxfkItems(site, 'tsjy', limit);
};
25 changes: 25 additions & 0 deletions lib/v2/gov/safe/templates/message.art
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<table>
<tbody>
<tr>
<th>留言人</th>
<th>留言内容</th>
<th>留言时间</th>
</tr>
{{ if message }}
{{ set object = message }}
<tr>
<td>{{ object.author }}</td>
<td>{{ object.content }}</td>
<td>{{ object.date }}</td>
</tr>
{{ /if }}
{{ if reply }}
{{ set object = reply }}
<tr style="color: #0069ae;">
<td>{{ object.author }}</td>
<td>{{ object.content }}</td>
<td>{{ object.date }}</td>
</tr>
{{ /if }}
</tbody>
</table>
87 changes: 87 additions & 0 deletions lib/v2/gov/safe/util.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const { parseDate } = require('@/utils/parse-date');
const { art } = require('@/utils/render');
const path = require('path');

const rootUrl = 'https://www.safe.gov.cn';

const zxfkCategoryApis = {
// 业务咨询 https://www.safe.gov.cn/<site>/ywzx/index.html
ywzx: 'www/busines/businessQuery?siteid=',

// 投诉建议 https://www.safe.gov.cn/<site>/tsjy/index.html
tsjy: 'www/complaint/complaintQuery?siteid=',
};

const processZxfkItems = async (site = 'beijing', category = 'ywzx', limit = '3') => {
const apiUrl = new URL(`${zxfkCategoryApis[category]}${site}`, rootUrl).href;
const currentUrl = new URL(`${site}/${category}/index.html`, rootUrl).href;

const { data: response } = await got(apiUrl);

const $ = cheerio.load(response);

const items = $('#complaint')
.slice(0, limit)
.toArray()
.map((item) => {
item = $(item);

const spans = item.find('span[objid]');

const message = {
author: spans.first().text().replace(/:$/, ''),
content: spans.eq(1).text(),
date: spans.eq(2).text(),
};

const reply = {
author: spans.eq(3).text().replace(/:$/, ''),
content: spans.eq(4).text(),
date: spans.eq(5).text(),
};

return {
title: `${message.author}: ${message.content}`,
link: new URL(item.find('.title').prop('href'), rootUrl).href,
description: art(path.join(__dirname, 'templates/message.art'), {
message,
reply,
}),
author: `${message.author}/${reply.author}`,
guid: item.find('.id').text(),
pubDate: parseDate(message.date),
updated: parseDate(reply.date),
};
});

const { data: currentResponse } = await got(currentUrl);

const content = cheerio.load(currentResponse);

const author = content('meta[name="ColumnName"]').prop('content');
const subtitle = content('meta[name="ColumnType"]').prop('content');

const imagePath = 'safe/templateresource/372b1dfdab204181b9b4f943a8e926a6';
const image = new URL(`${imagePath}/logo_06.png`, rootUrl).href;
const icon = new URL(`${imagePath}/safe.ico`, rootUrl).href;

return {
item: items,
title: `${author} - ${subtitle}`,
link: currentUrl,
description: content('meta[name="ColumnDescription"]').prop('content'),
language: 'zh',
image,
icon,
logo: icon,
subtitle,
author,
allowEmpty: true,
};
};

module.exports = {
processZxfkItems,
};
2 changes: 1 addition & 1 deletion lib/v2/ifi-audio/maintainer.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = {
'/download/:val/:id': ['NavePnow'],
'/download/:val/:id': ['EthanWng97'],
};
2 changes: 1 addition & 1 deletion lib/v2/inoreader/maintainer.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = {
'/html_clip/:user/:tag/:num?': ['BeautyyuYanli'],
'/rss/:user/:tag': ['NavePnow'],
'/rss/:user/:tag': ['EthanWng97'],
};
2 changes: 1 addition & 1 deletion lib/v2/leetcode/maintainer.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = {
'/articles': ['LogicJake'],
'/dailyquestion/:lang': ['NavePnow'],
'/dailyquestion/:lang': ['EthanWng97'],
'/dailyquestion/solution/:lang': ['woaidouya123'],
'/submission/:country/:user': ['NathanDai'],
};
2 changes: 1 addition & 1 deletion lib/v2/magazinelib/maintainer.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = {
'/latest-magazine/:query?': ['NavePnow'],
'/latest-magazine/:query?': ['EthanWng97'],
};
3 changes: 3 additions & 0 deletions lib/v2/missav/maintainer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
'/new': ['TonyRL'],
};
36 changes: 36 additions & 0 deletions lib/v2/missav/new.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const { art } = require('@/utils/render');
const { join } = require('path');

module.exports = async (ctx) => {
const baseUrl = 'https://missav.com';
const { data: response } = await got(`${baseUrl}/dm397/new`);
const $ = cheerio.load(response);

const items = $('.grid .group')
.toArray()
.map((item) => {
item = $(item);
const title = item.find('.text-secondary');
const poster = new URL(item.find('img').data('src'));
poster.searchParams.set('class', 'normal');
const video = item.find('video').data('src');
return {
title: title.text().trim(),
link: title.attr('href'),
description: art(join(__dirname, 'templates/preview.art'), {
poster: poster.href,
video,
type: video.split('.').pop(),
}),
};
});

ctx.state.data = {
title: $('head title').text(),
description: $('head meta[name="description"]').attr('content'),
link: baseUrl,
item: items,
};
};
13 changes: 13 additions & 0 deletions lib/v2/missav/radar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module.exports = {
'missav.com': {
_name: 'MissAV.com',
'.': [
{
title: '最近更新',
docs: 'https://docs.rsshub.app/multimedia#missav-com',
source: ['/dm397/new', '/new', '/'],
target: '/missav/new',
},
],
},
};
3 changes: 3 additions & 0 deletions lib/v2/missav/router.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = (router) => {
router.get('/new', require('./new'));
};
3 changes: 3 additions & 0 deletions lib/v2/missav/templates/preview.art
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<video controls preload="none" poster="{{ poster }}">
<source src="{{ video }}" type="{{ type }}">
</video>
2 changes: 1 addition & 1 deletion lib/v2/ncu/radar.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module.exports = {
'ncu.edu.cn': {
_name: '南昌大学',
'.': [
jwc: [
{
title: '教务通知',
docs: 'https://docs.rsshub.app/routes/university#nan-chang-da-xue',
Expand Down
2 changes: 1 addition & 1 deletion lib/v2/patagonia/maintainer.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = {
'/patagonia/new-arrivals/:category': ['NavePnow'],
'/patagonia/new-arrivals/:category': ['EthanWng97'],
};
78 changes: 78 additions & 0 deletions lib/v2/routledge/book-series.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const { parseDate } = require('@/utils/parse-date');
const { art } = require('@/utils/render');
const { join } = require('path');

module.exports = async (ctx) => {
const { bookName, bookId } = ctx.params;
const baseUrl = 'https://www.routledge.com';
const pageUrl = `${baseUrl}/${bookName}/book-series/${bookId}`;
const { data: response } = await got(pageUrl, {
headers: {
accept: 'text/html, */*; q=0.01',
},
searchParams: {
publishedFilter: 'alltitles',
pd: 'published,forthcoming',
pg: 1,
pp: 12,
so: 'pub',
view: 'list',
},
});
const $ = cheerio.load(response);

const list = $('.row.book')
.toArray()
.map((item) => {
item = $(item);
const title = item.find('h3 a');
const description = item.find('p.description');
const meta = item.find('p.description').prev().text().split('\n');
return {
title: title.text(),
link: title.attr('href'),
description: description.text(),
pubDate: parseDate(meta.pop().trim(), 'MMMM DD, YYYY'),
author: meta
.map((i) => i.trim())
.filter((i) => i)
.join(', '),
};
});

const items = await Promise.all(
list.map((item) =>
ctx.cache.tryGet(item.link, async () => {
const { data } = await got(item.link);
const $ = cheerio.load(data);
const isbn = $('meta[property="books:isbn"]').attr('content');
const { data: image } = await got('https://productimages.routledge.com', {
searchParams: {
isbn,
size: 'amazon',
ext: 'jpg',
},
});

const description = $('.sticky-div');
description.find('button.accordion-button').contents().unwrap();
description.find('.fa-shopping-cart').parent().parent().remove();

item.description = art(join(__dirname, 'templates/description.art'), {
image,
description: description.html(),
});
return item;
})
)
);

ctx.state.data = {
title: $('head title').text(),
description: $('head meta[name="description"]').attr('content'),
link: pageUrl,
item: items,
};
};
3 changes: 3 additions & 0 deletions lib/v2/routledge/maintainer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
'/:bookName/book-series/:bookId': ['TonyRL'],
};
Loading

0 comments on commit 01af97c

Please sign in to comment.