forked from DIYgod/RSSHub
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #755 from DIYgod/master
[pull] master from diygod:master
- Loading branch information
Showing
7 changed files
with
85 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
'/:site/:grouping/:name': ['hoilc'], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}`, | ||
}, | ||
], | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = (router) => { | ||
router.get('/:site/:grouping/:name', require('./index')); | ||
}; |
10f2985
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
rsshub-master – ./
rsshub-master.vercel.app
rsshub-master-auto-bot-ty.vercel.app
rsshub-master-git-master-auto-bot-ty.vercel.app