Skip to content

Commit

Permalink
Merge pull request #52 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 9, 2023
2 parents 3bde843 + 71269cd commit e36e1c8
Show file tree
Hide file tree
Showing 21 changed files with 279 additions and 278 deletions.
4 changes: 2 additions & 2 deletions lib/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ const app = new Koa();
app.proxy = true;

// favicon
app.use(favicon(__dirname + '/favicon.png'));
app.use(serve(__dirname + '/static'));
app.use(favicon(__dirname + '/favicon.png', { maxAge: 31536000000 }));
app.use(serve(__dirname + '/static', { maxage: 31536000000 }));

// global error handing
app.use(onerror);
Expand Down
2 changes: 1 addition & 1 deletion lib/radar.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const toSource = require('tosource');
const { join } = require('path');

// Namespaces that do not require radar.js
const allowNamespace = ['discourse', 'ehentai', 'test'];
const allowNamespace = ['discourse', 'discuz', 'ehentai', 'test'];
// Check if a radar.js file is exist under each folder of dirname
for (const dir of fs.readdirSync(dirname)) {
const dirPath = join(dirname, dir);
Expand Down
6 changes: 3 additions & 3 deletions lib/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -1446,9 +1446,9 @@ router.get('/gbcc/trust', lazyloadRouteHandler('./routes/gbcc/trust'));
router.get('/cbc/topics/:topic?', lazyloadRouteHandler('./routes/cbc/topics'));

// discuz
router.get('/discuz/:ver([7|x])/:cid([0-9]{2})/:link(.*)', lazyloadRouteHandler('./routes/discuz/discuz'));
router.get('/discuz/:ver([7|x])/:link(.*)', lazyloadRouteHandler('./routes/discuz/discuz'));
router.get('/discuz/:link(.*)', lazyloadRouteHandler('./routes/discuz/discuz'));
// router.get('/discuz/:ver([7|x])/:cid([0-9]{2})/:link(.*)', lazyloadRouteHandler('./routes/discuz/discuz'));
// router.get('/discuz/:ver([7|x])/:link(.*)', lazyloadRouteHandler('./routes/discuz/discuz'));
// router.get('/discuz/:link(.*)', lazyloadRouteHandler('./routes/discuz/discuz'));

// China Dialogue 中外对话
router.get('/chinadialogue/topics/:topic', lazyloadRouteHandler('./routes/chinadialogue/topics'));
Expand Down
148 changes: 0 additions & 148 deletions lib/routes/discuz/discuz.js

This file was deleted.

52 changes: 21 additions & 31 deletions lib/v2/abskoop/index.js
Original file line number Diff line number Diff line change
@@ -1,55 +1,45 @@
const path = require('path');
const got = require('@/utils/got');
const cheerio = require('cheerio');
const { art } = require('@/utils/render');
const { parseDate } = require('@/utils/parse-date');

module.exports = async (ctx) => {
const response = await got({
method: 'get',
url: 'https://www.abskoop.com/page/1/',
url: 'https://www.ahhhhfs.com/wp-json/wp/v2/posts',
searchParams: {
per_page: ctx.query.limit ? parseInt(ctx.query.limit) : 10,
_embed: '',
},
});

const $list = cheerio.load(response.data);
const list = $list('.rizhuti_v2-widget-lastpost .scroll article')
.map(function () {
const link = $list(this).find('.entry-wrapper .entry-header a');
return {
title: link.attr('title'),
link: link.attr('href'),
};
})
.get();
const list = response.data.map((item) => ({
title: item.title.rendered,
link: item.link,
pubDate: parseDate(item.date_gmt),
updated: parseDate(item.modified_gmt),
author: item._embedded.author[0].name,
category: [...new Set(item._embedded['wp:term'].flatMap((i) => i.map((j) => j.name)))],
}));

const items = await Promise.all(
list.reverse().map((item) =>
list.map((item) =>
ctx.cache.tryGet(item.link, async () => {
const detailResponse = await got({ method: 'get', url: item.link });
const $detail = cheerio.load(detailResponse.data);
$detail('article .entry-content').find('#related_posts').remove();
$detail('article .entry-content').find('#jp-relatedposts').remove();
$detail('article .entry-content').find('.post-note').remove();
$detail('article .entry-content').find('.entry-tags').remove();
$detail('article .entry-content').find('.entry-share').remove();
$detail('article .entry-content a').each(function () {
if ($detail(this).find('img').length > 0) {
$detail(this).replaceWith(`<img src=${$detail(this).attr('href')}>`);
}
});
const desc = [];
$detail('article .entry-content > *').each(function () {
desc.push($detail(this).html());
$detail('article.post-content').find('.lwptoc').remove();
$detail('article.post-content').find('#related_posts').remove();
$detail('article.post-content').find('.entry-copyright').remove();
$detail('article.post-content img').each(function () {
$detail(this).replaceWith(`<img src=https:${$detail(this).attr('src')}>`);
});
item.description = art(path.join(__dirname, 'templates/description.art'), { desc });
item.pubDate = parseDate($detail('meta[property="article:published_time"]').attr('content'));
item.description = $detail('article.post-content').html();
return item;
})
)
);

ctx.state.data = {
title: 'ahhhhfs-A姐分享',
link: 'https://www.abskoop.com',
link: 'https://www.ahhhhfs.com',
description:
'A姐分享,分享各种网络云盘资源、BT种子、高清电影电视剧和羊毛福利,收集各种有趣实用的软件和APP的下载、安装、使用方法,发现一些稀奇古怪的的网站,折腾一些有趣实用的教程,关注谷歌苹果等互联网最新的资讯动态,探索新领域,发现新美好,分享小快乐。',
item: items,
Expand Down
53 changes: 16 additions & 37 deletions lib/v2/abskoop/nsfw.js
Original file line number Diff line number Diff line change
@@ -1,52 +1,31 @@
const path = require('path');
const got = require('@/utils/got');
const cheerio = require('cheerio');
const { art } = require('@/utils/render');
const { parseDate } = require('@/utils/parse-date');

module.exports = async (ctx) => {
const response = await got({
method: 'get',
url: 'https://nsfw.ahhhhfs.com/articles-archive/',
url: 'https://nsfw.abskoop.com/wp-json/wp/v2/posts',
searchParams: {
per_page: ctx.query.limit ? parseInt(ctx.query.limit) : 10,
_embed: '',
},
});

const $list = cheerio.load(response.data);
const list = $list('article li')
.slice(0, 20)
.map(function () {
return {
link: $list(this).find('a').attr('href'),
};
})
.get();

const items = await Promise.all(
list.map((item) =>
ctx.cache.tryGet(item.link, async () => {
const detailResponse = await got({ method: 'get', url: item.link });
const $detail = cheerio.load(detailResponse.data);
$detail('article .entry-content a').each(function () {
if ($detail(this).find('img').length > 0) {
$detail(this).replaceWith(`<img src=${$detail(this).attr('href')}>`);
}
});
const desc = [];
$detail('article .entry-content > p').each(function () {
desc.push($detail(this).html());
});
item.title = $detail('article h1.entry-title').text();
item.description = art(path.join(__dirname, 'templates/description.art'), { desc });
item.pubDate = parseDate($detail('meta[property="article:published_time"]').attr('content'));
return item;
})
)
);
const list = response.data.map((item) => ({
title: item.title.rendered,
description: item.content.rendered,
link: item.link,
pubDate: parseDate(item.date_gmt),
updated: parseDate(item.modified_gmt),
author: item._embedded.author[0].name,
category: [...new Set(item._embedded['wp:term'].flatMap((i) => i.map((j) => j.name)))],
}));

ctx.state.data = {
title: 'ahhhhfs-A姐分享NSFW',
link: 'https://nsfw.ahhhhfs.com',
link: 'https://nsfw.ahhhhfs.com/articles-archive',
description:
'A姐分享NSFW,分享各种网络云盘资源、BT种子、磁力链接、高清电影电视剧和羊毛福利,收集各种有趣实用的软件和APP的下载、安装、使用方法,发现一些稀奇古怪的的网站,折腾一些有趣实用的教程,关注谷歌苹果等互联网最新的资讯动态,探索新领域,发现新美好,分享小快乐。',
item: items,
item: list,
};
};
15 changes: 13 additions & 2 deletions lib/v2/abskoop/radar.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
module.exports = {
'abskoop.com': {
_name: 'A姐分享',
nsfw: [
{
title: 'NSFW 存档列表',
docs: 'https://docs.rsshub.app/routes/multimedia#a-jie-fen-xiang',
source: ['/articles-archive', '/'],
target: '/abskoop',
},
],
},
'ahhhhfs.com': {
_name: 'A姐分享',
'.': [
{
title: '存档列表',
docs: 'https://docs.rsshub.app/routes/multimedia#abskoop',
source: ['/archives'],
docs: 'https://docs.rsshub.app/routes/multimedia#a-jie-fen-xiang',
source: ['/'],
target: '/abskoop',
},
],
Expand Down
3 changes: 0 additions & 3 deletions lib/v2/abskoop/templates/description.art

This file was deleted.

2 changes: 1 addition & 1 deletion lib/v2/bilibili/followings_dynamic.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ module.exports = async (ctx) => {
});
}
// 作者信息
let author = '哔哩哔哩番剧';
let author = '';
if (item.desc?.user_profile) {
author = item.desc.user_profile.info.uname;
}
Expand Down
Loading

0 comments on commit e36e1c8

Please sign in to comment.