feat(route): add Mobilism (#8949)
* Add(route): add Mobilism * 去除注释 去除登录 * Revert "去除注释" This reverts commit 8b1409aee2f44335bca39efdab8d524e749ccb3e. * 尝试修复重复推送问题 * 修复部分情况下时间获取错误 * 去除时间获取(重复推送BUG无法解决) 增加全文获取 * 添加参数判断是否获取全文 * 修改 * 2022年1月30日14:22:40 * fix: remove login, use built-in `toTitleCase` * docs: add missing docs * fix: radar * fix: typo Co-authored-by: Nite07 <nmy1207@outlook.com> Co-authored-by: TonyRL <TonyRL@users.noreply.github.com>
This commit is contained in:
+26
@@ -208,6 +208,32 @@ pageClass: routes
|
||||
|
||||
<Route author="cssxsh" example="/mcbbs/post/915861/3038" path="/mcbbs/post/:tid/:authorid?" :paramsDesc="['贴子id,可在帖子 URL 找到', '用户id,此参数不为空时,只看此作者']"/>
|
||||
|
||||
## Mobilism
|
||||
|
||||
### 论坛
|
||||
|
||||
<Route author="nitezs" example="/mobilism/forums/android/apps" path="/mobilism/forums/:category/:type/:fulltext?" :paramsDesc="['分类', '种类', '是否获取全文,如需获取全文参数传入 `y`']">
|
||||
|
||||
| 安卓 | iPhone | iPad |
|
||||
| ------- | ------ | ---- |
|
||||
| android | iphone | ipad |
|
||||
|
||||
| 应用 | 游戏 |
|
||||
| ---- | ----- |
|
||||
| apps | games |
|
||||
|
||||
</Route>
|
||||
|
||||
### 门户
|
||||
|
||||
<Route author="nitezs" example="/mobilism/portal/androidapps" path="/mobilism/portal/:type/:fulltext?" :paramsDesc="['种类', '是否获取全文,如需获取全文参数传入 `y`']">
|
||||
|
||||
| 安卓应用 | 安卓游戏 | 图书 | iPad 应用 | iPad 游戏 | iPhone 应用 | iPhone 游戏 |
|
||||
| ---- | ----- | ----- | ------- | ------- | --------- | --------- |
|
||||
| aapp | agame | ebook | ipapp | ipgame | iapp | igame |
|
||||
|
||||
</Route>
|
||||
|
||||
## NGA
|
||||
|
||||
### 分区帖子
|
||||
|
||||
@@ -36,6 +36,32 @@ pageClass: routes
|
||||
|
||||
<RouteEn author="nczitzk" example="/lowendtalk/discussion/168480" path="/lowendtalk/discussion/:id?" :paramsDesc="['Discussion id']"/>
|
||||
|
||||
## Mobilism
|
||||
|
||||
### Forums
|
||||
|
||||
<RouteEn author="nitezs" example="/mobilism/forums/android/apps" path="/mobilism/forums/:category/:type/:fulltext?" :paramsDesc="['Category', 'subcategory','Retrieve fulltext, specify `y` to enable']">
|
||||
|
||||
| Android | iPhone | iPad |
|
||||
| ------- | ------ | ---- |
|
||||
| android | iphone | ipad |
|
||||
|
||||
| Apps | games |
|
||||
| ---- | ----- |
|
||||
| apps | games |
|
||||
|
||||
</RouteEn>
|
||||
|
||||
### Portal
|
||||
|
||||
<RouteEn author="nitezs" example="/mobilism/portal/androidapps" path="/mobilism/portal/:type/:fulltext?" :paramsDesc="['Sections', 'Retrieve fulltext, specify `y` to enable']">
|
||||
|
||||
| Android Apps | Android Games | ebook | iPad Apps | iPad Games | iPhone Apps | iPhone Games |
|
||||
| ------------ | ------------- | ----- | --------- | ---------- | ----------- | ------------ |
|
||||
| aapp | agame | ebook | ipapp | ipgame | iapp | igame |
|
||||
|
||||
</RouteEn>
|
||||
|
||||
## SCBOY forum
|
||||
|
||||
### Thread
|
||||
|
||||
+18
-1
@@ -38,7 +38,24 @@ Eg:<https://kakuyomu.jp/works/1177354054883783581>
|
||||
|
||||
### Category
|
||||
|
||||
<RouteEn author="nczitzk" example="/literotica/category/anal-sex-stories" path="/literotica/category/:category?" :paramsDesc="['Categor, can be found in URL']"/>
|
||||
<RouteEn author="nczitzk" example="/literotica/category/anal-sex-stories" path="/literotica/category/:category?" :paramsDesc="['Category, can be found in URL']"/>
|
||||
|
||||
## Mobilism
|
||||
|
||||
### eBook Releases
|
||||
|
||||
<RouteEn author="nitezs" example="/mobilism/forums/books/romance" path="/mobilism/forums/books/:type/:fulltext?" :paramsDesc="['Category', 'Retrieve fulltext, specify `y` to enable']">
|
||||
|
||||
| Category | Parameter |
|
||||
| ------------------------ | ---------- |
|
||||
| Romance | romance |
|
||||
| Sci-Fi/Fantasy/Horror | scifi |
|
||||
| General Fiction/Classics | classics |
|
||||
| Magazines & Newspapers | magazines |
|
||||
| Audiobooks | audioBooks |
|
||||
| Comics | comics |
|
||||
|
||||
</RouteEn>
|
||||
|
||||
## syosetu
|
||||
|
||||
|
||||
+13
-2
@@ -54,9 +54,20 @@ pageClass: routes
|
||||
|
||||
## Mobilism
|
||||
|
||||
### eBook Releases
|
||||
### 电子书
|
||||
|
||||
<Route author="nczitzk" example="/mobilism/release" path="/mobilism/release" />
|
||||
<Route author="nitezs" example="/mobilism/forums/books/romance" path="/mobilism/forums/books/:type/:fulltext?" :paramsDesc="['分类','是否获取全文,如需获取全文参数传入 `y`']">
|
||||
|
||||
| 分类名 | 参数 |
|
||||
| -------- | ---------- |
|
||||
| 浪漫 | romance |
|
||||
| 科幻、幻想、恐怖 | scifi |
|
||||
| 普通小说、经典 | classics |
|
||||
| 杂志、报纸 | magazines |
|
||||
| 有声读物 | audioBooks |
|
||||
| 漫画 | comics |
|
||||
|
||||
</Route>
|
||||
|
||||
## SoBooks
|
||||
|
||||
|
||||
@@ -2862,9 +2862,6 @@ router.get('/law/dh', lazyloadRouteHandler('./routes/law/dh'));
|
||||
// 金诚同达律师事务所文章
|
||||
router.get('/law/jctd', lazyloadRouteHandler('./routes/law/jctd'));
|
||||
|
||||
// Mobilism
|
||||
router.get('/mobilism/release', lazyloadRouteHandler('./routes/mobilism/release'));
|
||||
|
||||
// 三星盖乐世社区
|
||||
router.get('/samsungmembers/latest', lazyloadRouteHandler('./routes/samsungmembers/latest'));
|
||||
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
const url = require('url');
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const currentUrl = `https://forum.mobilism.org/viewforum.php?f=19`;
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: currentUrl,
|
||||
});
|
||||
const $ = cheerio.load(response.data);
|
||||
const list = $('tbody')
|
||||
.eq(1)
|
||||
.find('tr')
|
||||
.map((_, item) => {
|
||||
item = $(item);
|
||||
const a = item.find('a');
|
||||
return {
|
||||
title: a.text(),
|
||||
link: url.resolve(`https://forum.mobilism.org`, a.attr('href')),
|
||||
};
|
||||
})
|
||||
.get();
|
||||
|
||||
const items = await Promise.all(
|
||||
list.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const res = await got({ method: 'get', url: item.link });
|
||||
const content = cheerio.load(res.data);
|
||||
|
||||
item.description = content('div.content').html();
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: 'Mobilism - eBook Releases',
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,75 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { toTitleCase } = require('@/utils/common-utils');
|
||||
const { parseDate, parseRelativeDate } = require('@/utils/parse-date');
|
||||
const rootUrl = `https://forum.mobilism.org/viewforum.php?f=`;
|
||||
const categeoryMap = {
|
||||
books: {
|
||||
romance: 1292,
|
||||
scifi: 1293,
|
||||
classics: 121,
|
||||
magazines: 123,
|
||||
audioBooks: 124,
|
||||
comics: 311,
|
||||
},
|
||||
android: {
|
||||
apps: 399,
|
||||
games: 408,
|
||||
},
|
||||
iphone: {
|
||||
apps: 316,
|
||||
games: 320,
|
||||
},
|
||||
ipad: {
|
||||
apps: 951,
|
||||
games: 988,
|
||||
},
|
||||
};
|
||||
module.exports = async (ctx) => {
|
||||
const { category, type, fulltext } = ctx.params;
|
||||
const currentUrl = rootUrl + categeoryMap[category][type];
|
||||
const response = await got(currentUrl);
|
||||
const $ = cheerio.load(cheerio.load(response.data)('tbody')[1]);
|
||||
const lists = $('tbody > tr');
|
||||
const list = lists
|
||||
.map((index, item) => {
|
||||
item = $(item);
|
||||
const title = item.find('td').first().find('a[title]').text();
|
||||
const link = new URL(item.find('td').first().find('a[title]').attr('href'), 'https://forum.mobilism.org');
|
||||
const author = item.find('td').first().find('a.username-coloured').text();
|
||||
const pubDate = item.find('td').first().find('small').text();
|
||||
link.searchParams.delete('sid');
|
||||
return {
|
||||
title,
|
||||
link: link.toString(),
|
||||
author,
|
||||
pubDate: /ago|day/.test(pubDate) ? parseRelativeDate(pubDate) : parseDate(pubDate, 'MMM D, YYYY, h:mm a'),
|
||||
};
|
||||
})
|
||||
.get()
|
||||
.sort((a, b) => b.pubDate - a.pubDate)
|
||||
.slice(0, ctx.query.limit ? parseInt(ctx.query.limit) : 35);
|
||||
// server will return 520 if concurrency > 37 when fulltext is used
|
||||
let items;
|
||||
if (fulltext === 'y') {
|
||||
items = await Promise.all(
|
||||
list.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const detailResponse = await got(item.link);
|
||||
const content = cheerio.load(detailResponse.data);
|
||||
item.description = content('div.content').html();
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
} else {
|
||||
items = list;
|
||||
}
|
||||
|
||||
ctx.state.data = {
|
||||
title: `Mobilism Forums ${toTitleCase(category)} ${toTitleCase(type)} Release`,
|
||||
link: currentUrl,
|
||||
description: `Mobilism Forums ${toTitleCase(category)} ${toTitleCase(type)} RSS`,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,4 @@
|
||||
module.exports = {
|
||||
'/forums/:category/:type/:fulltext?': ['nitezs'],
|
||||
'/portal/:type/:fulltext?': ['nitezs'],
|
||||
};
|
||||
@@ -0,0 +1,54 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { toTitleCase } = require('@/utils/common-utils');
|
||||
const { parseDate, parseRelativeDate } = require('@/utils/parse-date');
|
||||
|
||||
const get = (data) => {
|
||||
const $ = cheerio.load(data);
|
||||
const posts = $('div.span9 > section');
|
||||
const items = posts
|
||||
.map((index, item) => {
|
||||
item = $(item);
|
||||
const link = new URL(item.find('div.well > a').attr('href'), 'https://forum.mobilism.org');
|
||||
const pubDate = item.find('div.well > span.muted > em').text().replace(item.find('div.well > span.muted > em > strong').text(), '').replace(' at ', '').split(' in ')[0];
|
||||
link.searchParams.delete('sid');
|
||||
return {
|
||||
title: item.find('div.page-header > h3').text(),
|
||||
link: link.toString(),
|
||||
author: item.find('div.well > span.muted > em > strong').text().replace('Posted by: ', ''),
|
||||
description: item.find('div.well > div.postbody').text(),
|
||||
pubDate: /ago|day/.test(pubDate) ? parseRelativeDate(pubDate) : parseDate(pubDate, 'MMM D, YYYY, h:mm a'),
|
||||
};
|
||||
})
|
||||
.get();
|
||||
return items;
|
||||
};
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const { type, fulltext } = ctx.params;
|
||||
const url = `https://forum.mobilism.org/portal.php?mode=articles&block=${type}&sk=t&sd=d&start=0`;
|
||||
const response = await got(url);
|
||||
const list = get(response.data);
|
||||
let items;
|
||||
if (fulltext === 'y') {
|
||||
items = await Promise.all(
|
||||
list.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const detailResponse = await got(item.link);
|
||||
const content = cheerio.load(detailResponse.data);
|
||||
item.description = content('div.content').html();
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
} else {
|
||||
items = list;
|
||||
}
|
||||
|
||||
ctx.state.data = {
|
||||
title: `Mobilism Portal ${toTitleCase(type)} Release`,
|
||||
link: url,
|
||||
description: `Mobilism Portal ${toTitleCase(type)} RSS`,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,23 @@
|
||||
module.exports = {
|
||||
'mobilism.org': {
|
||||
_name: 'Mobilism',
|
||||
'.': [
|
||||
{
|
||||
title: '论坛',
|
||||
docs: 'https://docs.rsshub.app/bbs.html#mobilism',
|
||||
source: '/',
|
||||
},
|
||||
{
|
||||
title: '门户',
|
||||
docs: 'https://docs.rsshub.app/bbs.html#mobilism',
|
||||
source: '/portal.php',
|
||||
target: (_params, url) => `/mobilism/portal/${new URL(url).searchParams.get('block')}`,
|
||||
},
|
||||
{
|
||||
title: '电子书',
|
||||
docs: 'https://docs.rsshub.app/reading.html#mobilism',
|
||||
source: '/',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,4 @@
|
||||
module.exports = function (router) {
|
||||
router.get('/forums/:category/:type/:fulltext?', require('./forums'));
|
||||
router.get('/portal/:type/:fulltext?', require('./portal'));
|
||||
};
|
||||
Reference in New Issue
Block a user