Skip to content

Commit

Permalink
Merge pull request #755 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 Jan 25, 2023
2 parents eddc0da + 3883948 commit 10f2985
Show file tree
Hide file tree
Showing 7 changed files with 85 additions and 78 deletions.
2 changes: 1 addition & 1 deletion docs/other.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ pageClass: routes

### 文章

<Route author="hoilc" example="/clickme/default/category/beauty" path="/clickme/:site/:grouping/:name" :paramsDesc="['站点, `default`为普通站, `r18`为成人站, 其它值默认为普通站','分组方式, `category`为分类, `tag`为标签, 其他值默认为分类','分类名或标签名, 分类名为英文, 可以在分类 URL 中找到']" />
<Route author="hoilc" example="/clickme/default/category/beauty" path="/clickme/:site/:grouping/:name" :paramsDesc="['站点`default`为普通站`r18`为成人站其它值默认为普通站','分组方式`category`为分类`tag`为标签其他值默认为分类','分类名或标签名分类名为英文可以在分类 URL 中找到']" radar="1"/>

## Darwin Awards

Expand Down
2 changes: 1 addition & 1 deletion lib/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -2223,7 +2223,7 @@ router.get('/gov/cnca/hydt', lazyloadRouteHandler('./routes/gov/cnca/hydt'));
router.get('/gov/cnca/zxtz', lazyloadRouteHandler('./routes/gov/cnca/zxtz'));

// clickme
router.get('/clickme/:site/:grouping/:name', lazyloadRouteHandler('./routes/clickme'));
// router.get('/clickme/:site/:grouping/:name', lazyloadRouteHandler('./routes/clickme'));

// 文汇报
router.get('/whb/:category', lazyloadRouteHandler('./routes/whb/zhuzhan'));
Expand Down
76 changes: 0 additions & 76 deletions lib/routes/clickme/index.js

This file was deleted.

56 changes: 56 additions & 0 deletions lib/v2/clickme/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const { parseDate } = require('@/utils/parse-date');

module.exports = async (ctx) => {
const site = ctx.params.site === 'r18' ? 'r18' : '';
const grouping = ctx.params.grouping === 'tag' ? 'tag' : 'category';
const name = ctx.params.name;

const url = `https://${site ? 'r18.' : ''}clickme.net/${grouping.substring(0, 1)}/${encodeURIComponent(name)}`;

const { data: response } = await got.post('https://api.clickme.net/article/list', {
headers: {
Referer: url,
},
searchParams: {
key: 'clickme',
},
form: {
articleType: site ? 'r18' : 'article',
subtype: grouping,
subtypeSlug: name,
device: '',
limit: 18,
page: 1,
},
});

const category_name = name === 'new' ? '最新' : response.data.items[0].categoryName[0].name;
const displayed_name = grouping === 'tag' ? name : category_name;

const list = response.data.items.map((item) => ({
title: item.title,
link: item.url.replace('http://', 'https://'),
author: item.userNick,
pubDate: parseDate(item.date, 'X'),
category: [...item.categoryName.map((item) => item.name), ...item.tags],
}));

const out = await Promise.all(
list.map((item) =>
ctx.cache.tryGet(item.link, async () => {
const { data } = await got.get(item.link);
const $ = cheerio.load(data);
item.description = $('.article-detail-content').html();
return item;
})
)
);

ctx.state.data = {
title: `ClickMe ${site ? 'R18 ' : ''}- ${displayed_name}`,
link: url,
item: out,
};
};
3 changes: 3 additions & 0 deletions lib/v2/clickme/maintainer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
'/:site/:grouping/:name': ['hoilc'],
};
21 changes: 21 additions & 0 deletions lib/v2/clickme/radar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
module.exports = {
'clickme.net': {
_name: 'ClickMe',
'.': [
{
title: '文章',
docs: 'https://docs.rsshub.app/other.html#clickme',
source: ['/:grouping/:name'],
target: (params) => `/clickme/default/${params.grouping === 't' ? 'tag' : 'category'}/${params.name}`,
},
],
r18: [
{
title: '文章',
docs: 'https://docs.rsshub.app/other.html#clickme',
source: ['/:grouping/:name'],
target: (params) => `/clickme/r18/${params.grouping === 't' ? 'tag' : 'category'}/${params.name}`,
},
],
},
};
3 changes: 3 additions & 0 deletions lib/v2/clickme/router.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = (router) => {
router.get('/:site/:grouping/:name', require('./index'));
};

1 comment on commit 10f2985

@vercel
Copy link

@vercel vercel bot commented on 10f2985 Jan 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.