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.
feat(route): add 虎嗅频道 & 源流 (DIYgod#13945)
* feat(route): add 虎嗅频道 & 源流 * fix: limit to 20 * docs: remove rssbud
- Loading branch information
Showing
21 changed files
with
745 additions
and
426 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,41 +1,29 @@ | ||
const got = require('@/utils/got'); | ||
const { parseDate } = require('@/utils/parse-date'); | ||
const { baseUrl, briefApi, ProcessFeed } = require('./utils'); | ||
|
||
const { apiBriefRootUrl, processItems, fetchBriefColumnData } = require('./util'); | ||
|
||
module.exports = async (ctx) => { | ||
const { id } = ctx.params; | ||
const link = `${briefApi}/briefColumn/getContentListByCategoryId`; | ||
const { data: response } = await got | ||
.post(link, { | ||
form: { | ||
platform: 'www', | ||
brief_column_id: id, | ||
}, | ||
}) | ||
.json(); | ||
const { | ||
data: { data: briefDetail }, | ||
} = await got.post(`${briefApi}/briefColumn/detail`, { | ||
const limit = ctx.query.limit ? parseInt(ctx.query.limit, 10) : 20; | ||
|
||
const apiUrl = new URL('briefColumn/getContentListByCategoryId', apiBriefRootUrl).href; | ||
|
||
const { data: response } = await got.post(apiUrl, { | ||
form: { | ||
platform: 'www', | ||
brief_column_id: id, | ||
pagesize: limit, | ||
}, | ||
}); | ||
|
||
const list = response.datalist.map((item) => ({ | ||
title: item.title, | ||
link: `${baseUrl}/brief/${item.brief_id}`, | ||
description: item.preface, | ||
pubDate: parseDate(item.publish_time, 'X'), | ||
})); | ||
ctx.state.json = response.data.datalist; | ||
|
||
const items = await processItems(response.data.datalist, limit, ctx.cache.tryGet); | ||
|
||
const items = await ProcessFeed(list, ctx.cache); | ||
const data = await fetchBriefColumnData(id); | ||
|
||
ctx.state.data = { | ||
title: `虎嗅 - ${briefDetail.name}`, | ||
description: briefDetail.summary, | ||
image: briefDetail.head_img, | ||
link: `${baseUrl}/briefColumn/${id}.html`, | ||
item: items, | ||
...data, | ||
}; | ||
}; |
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,28 @@ | ||
const got = require('@/utils/got'); | ||
|
||
const { rootUrl, apiArticleRootUrl, processItems, fetchData } = require('./util'); | ||
|
||
module.exports = async (ctx) => { | ||
const { id } = ctx.params; | ||
const limit = ctx.query.limit ? parseInt(ctx.query.limit, 10) : 20; | ||
|
||
const apiUrl = new URL(`web/${id ? 'channel' : 'article'}/articleList`, apiArticleRootUrl).href; | ||
const currentUrl = new URL(id ? `channel/${id}.html` : 'article', rootUrl).href; | ||
|
||
const { data: response } = await got.post(apiUrl, { | ||
form: { | ||
platform: 'www', | ||
channel_id: id, | ||
pagesize: limit, | ||
}, | ||
}); | ||
|
||
const items = await processItems(response.data?.dataList ?? response.data.datalist, limit, ctx.cache.tryGet); | ||
|
||
const data = await fetchData(currentUrl); | ||
|
||
ctx.state.data = { | ||
item: items, | ||
...data, | ||
}; | ||
}; |
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,30 @@ | ||
const got = require('@/utils/got'); | ||
|
||
const { apiBriefRootUrl, processItems, fetchClubData } = require('./util'); | ||
|
||
module.exports = async (ctx) => { | ||
const { id } = ctx.params; | ||
const limit = ctx.query.limit ? parseInt(ctx.query.limit, 10) : 20; | ||
|
||
const apiUrl = new URL('club/briefList', apiBriefRootUrl).href; | ||
|
||
const { data, briefColumnId } = await fetchClubData(id); | ||
|
||
const { data: response } = await got.post(apiUrl, { | ||
form: { | ||
platform: 'www', | ||
club_id: id, | ||
brief_column_id: briefColumnId, | ||
pagesize: limit, | ||
}, | ||
}); | ||
|
||
ctx.state.json = response.data.datalist; | ||
|
||
const items = await processItems(response.data.datalist, limit, ctx.cache.tryGet); | ||
|
||
ctx.state.data = { | ||
item: items, | ||
...data, | ||
}; | ||
}; |
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 |
---|---|---|
@@ -1,39 +1,27 @@ | ||
const got = require('@/utils/got'); | ||
const cheerio = require('cheerio'); | ||
const utils = require('./utils'); | ||
const { parseDate } = require('@/utils/parse-date'); | ||
|
||
const { rootUrl, apiArticleRootUrl, processItems, fetchData } = require('./util'); | ||
|
||
module.exports = async (ctx) => { | ||
const { id } = ctx.params; | ||
const link = `${utils.baseUrl}/collection/${id}.html`; | ||
const { data: response } = await got(link, { | ||
https: { | ||
rejectUnauthorized: false, | ||
}, | ||
}); | ||
const limit = ctx.query.limit ? parseInt(ctx.query.limit, 10) : 10; | ||
|
||
const $ = cheerio.load(response); | ||
const apiUrl = new URL('web/collection/articleList', apiArticleRootUrl).href; | ||
const currentUrl = new URL(`collection/${id}.html`, rootUrl).href; | ||
|
||
const initialState = utils.parseInitialState($); | ||
|
||
const { collectionDetail } = initialState.collectionDetail; | ||
const list = collectionDetail.article_list.datalist.map((e) => ({ | ||
title: e.title, | ||
link: `${utils.baseUrl}/article/${e.aid}.html`, | ||
description: e.summary, | ||
pubDate: parseDate(e.dateline, 'X'), | ||
author: e.user_info.username, | ||
})); | ||
const { data: response } = await got.post(apiUrl, { | ||
form: { | ||
platform: 'www', | ||
collection_id: id, | ||
}, | ||
}); | ||
|
||
const items = await utils.ProcessFeed(list, ctx.cache); | ||
const items = await processItems(response.data.datalist, limit, ctx.cache.tryGet); | ||
|
||
const info = `虎嗅 - ${collectionDetail.name}`; | ||
const data = await fetchData(currentUrl); | ||
|
||
ctx.state.data = { | ||
title: info, | ||
description: collectionDetail.summary, | ||
image: collectionDetail.icon, | ||
link, | ||
item: items, | ||
...data, | ||
}; | ||
}; |
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 |
---|---|---|
@@ -1,8 +1,11 @@ | ||
module.exports = { | ||
'/article': ['HenryQW'], | ||
'/author/:id': ['HenryQW'], | ||
'/collection/:id': ['AlexdanerZe'], | ||
'/article': ['HenryQW', 'nczitzk'], | ||
'/briefcolumn/:id': ['Fatpandac', 'nczitzk'], | ||
'/channel/:id?': ['nczitzk'], | ||
'/club/:id': ['nczitzk'], | ||
'/collection/:id': ['AlexdanerZe', 'nczitzk'], | ||
'/member/:id/:type?': ['HenryQW', 'nczitzk'], | ||
'/moment': ['nczitzk'], | ||
'/tag/:id': ['xyqfer', 'HenryQW'], | ||
'/search/:keyword': ['xyqfer', 'HenryQW'], | ||
'/search/:keyword': ['xyqfer', 'HenryQW', 'nczitzk'], | ||
'/tag/:id': ['xyqfer', 'HenryQW', 'nczitzk'], | ||
}; |
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,27 @@ | ||
const got = require('@/utils/got'); | ||
|
||
const { rootUrl, apiMemberRootUrl, processItems, fetchData } = require('./util'); | ||
|
||
module.exports = async (ctx) => { | ||
const { id, type = 'article' } = ctx.params; | ||
const limit = ctx.query.limit ? parseInt(ctx.query.limit, 10) : 10; | ||
|
||
const apiUrl = new URL(`web/${type}/${type}List`, apiMemberRootUrl).href; | ||
const currentUrl = new URL(`member/${id}${type === 'article' ? '' : `/${type}`}.html`, rootUrl).href; | ||
|
||
const { data: response } = await got.post(apiUrl, { | ||
form: { | ||
platform: 'www', | ||
uid: id, | ||
}, | ||
}); | ||
|
||
const items = await processItems(response.data.datalist, limit, ctx.cache.tryGet); | ||
|
||
const data = await fetchData(currentUrl); | ||
|
||
ctx.state.data = { | ||
item: items, | ||
...data, | ||
}; | ||
}; |
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 |
---|---|---|
@@ -1,39 +1,25 @@ | ||
const got = require('@/utils/got'); | ||
const { parseDate } = require('@/utils/parse-date'); | ||
const { art } = require('@/utils/render'); | ||
const path = require('path'); | ||
const { baseUrl: rootUrl, momentApi: apiRootUrl } = require('./utils'); | ||
|
||
const { rootUrl, apiMomentRootUrl, processItems, fetchData } = require('./util'); | ||
|
||
module.exports = async (ctx) => { | ||
const currentUrl = `${rootUrl}/moment`; | ||
const apiUrl = `${apiRootUrl}/web-v2/moment/feed`; | ||
const limit = ctx.query.limit ? parseInt(ctx.query.limit, 10) : 20; | ||
|
||
const apiUrl = new URL('web-v2/moment/feed', apiMomentRootUrl).href; | ||
const currentUrl = new URL('moment', rootUrl).href; | ||
|
||
const response = await got({ | ||
method: 'post', | ||
url: apiUrl, | ||
const { data: response } = await got.post(apiUrl, { | ||
form: { | ||
last_dateline: parseInt(new Date().getTime() / 1000), | ||
platform: 'www', | ||
is_ai: 0, | ||
}, | ||
}); | ||
|
||
const items = response.data.data.moment_list.datalist[0].datalist.map((item) => ({ | ||
title: item.content, | ||
link: item.share_url, | ||
author: item.user_info.username, | ||
pubDate: parseDate(item.publish_time * 1000), | ||
description: art(path.join(__dirname, 'templates/moment.art'), { | ||
description: item.content, | ||
images: item.img_urls, | ||
video: item.video, | ||
comments: item.comment, | ||
}), | ||
})); | ||
const items = await processItems(response.data.moment_list.datalist[0].datalist, limit, ctx.cache.tryGet); | ||
|
||
const data = await fetchData(currentUrl); | ||
|
||
ctx.state.data = { | ||
title: '虎嗅 - 24小时', | ||
link: currentUrl, | ||
item: items, | ||
...data, | ||
}; | ||
}; |
Oops, something went wrong.