mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-09 23:00:48 +08:00
fix(route): Odaily星球日报 (#8707)
This commit is contained in:
@@ -773,11 +773,11 @@ IPFS 网关有可能失效,那时候换成其他网关。
|
||||
|
||||
### 文章
|
||||
|
||||
<Route author="ncziztk" example="/odaily" path="/odaily/:id?" :paramsDesc="['id,见下表,默认为新品']">
|
||||
<Route author="ncziztk" example="/odaily" path="/odaily/:id?" :paramsDesc="['id,见下表,默认为最新']">
|
||||
|
||||
| 新品 | DeFi | NFT | 存储 | 波卡 | 行情 | 活动 |
|
||||
| ---- | ---- | --- | ---- | ---- | ---- | ---- |
|
||||
| 333 | 331 | 334 | 332 | 330 | 297 | 296 |
|
||||
| 最新 | 新品 | DeFi | NFT | 存储 | 波卡 | 行情 | 活动 |
|
||||
| ---- | ---- | ---- | --- | ---- | ---- | ---- | ---- |
|
||||
| 280 | 333 | 331 | 334 | 332 | 330 | 297 | 296 |
|
||||
|
||||
</Route>
|
||||
|
||||
|
||||
@@ -4230,10 +4230,10 @@ router.get('/questmobile/report/:category?/:label?', lazyloadRouteHandler('./rou
|
||||
router.get('/rss3/blog', lazyloadRouteHandler('./routes/rss3/blog'));
|
||||
|
||||
// 星球日报
|
||||
router.get('/odaily/activity', lazyloadRouteHandler('./routes/odaily/activity'));
|
||||
router.get('/odaily/newsflash', lazyloadRouteHandler('./routes/odaily/newsflash'));
|
||||
router.get('/odaily/user/:id', lazyloadRouteHandler('./routes/odaily/user'));
|
||||
router.get('/odaily/:id?', lazyloadRouteHandler('./routes/odaily/post'));
|
||||
// router.get('/odaily/activity', lazyloadRouteHandler('./routes/odaily/activity'));
|
||||
// router.get('/odaily/newsflash', lazyloadRouteHandler('./routes/odaily/newsflash'));
|
||||
// router.get('/odaily/user/:id', lazyloadRouteHandler('./routes/odaily/user'));
|
||||
// router.get('/odaily/:id?', lazyloadRouteHandler('./routes/odaily/post'));
|
||||
|
||||
// Fashion Network
|
||||
router.get('/fashionnetwork/news/:sectors?/:categories?/:language?', lazyloadRouteHandler('./routes/fashionnetwork/news.js'));
|
||||
|
||||
@@ -1,24 +1,25 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const timezone = require('@/utils/timezone');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const { rootUrl } = require('./utils');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const rootUrl = 'https://www.odaily.com';
|
||||
const currentUrl = `${rootUrl}/service/scheme/group/8?page=1&per_page=10`;
|
||||
const currentUrl = `${rootUrl}/service/scheme/group/8?page=1&per_page=${ctx.query.limit ?? 25}`;
|
||||
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: currentUrl,
|
||||
});
|
||||
|
||||
const list = response.data.data.items.data.map((item) => ({
|
||||
let items = response.data.data.items.data.map((item) => ({
|
||||
title: item.title,
|
||||
link: `${rootUrl}/activity/${item.id}`,
|
||||
pubDate: timezone(new Date(item.published_at), +8),
|
||||
pubDate: timezone(parseDate(item.published_at), +8),
|
||||
}));
|
||||
|
||||
const items = await Promise.all(
|
||||
list.map(
|
||||
items = await Promise.all(
|
||||
items.map(
|
||||
async (item) =>
|
||||
await ctx.cache.tryGet(item.link, async () => {
|
||||
const detailResponse = await got({
|
||||
6
lib/v2/odaily/maintainer.js
Normal file
6
lib/v2/odaily/maintainer.js
Normal file
@@ -0,0 +1,6 @@
|
||||
module.exports = {
|
||||
'/activity': ['nczitzk'],
|
||||
'/newsflash': ['nczitzk'],
|
||||
'/user/:id': ['nczitzk'],
|
||||
'/:id?': ['nczitzk'],
|
||||
};
|
||||
@@ -1,9 +1,10 @@
|
||||
const got = require('@/utils/got');
|
||||
const timezone = require('@/utils/timezone');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const { rootUrl } = require('./utils');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const rootUrl = 'https://www.odaily.com';
|
||||
const currentUrl = `${rootUrl}/api/pp/api/info-flow/newsflash_columns/newsflashes?b_id=&per_page=30`;
|
||||
const currentUrl = `${rootUrl}/api/pp/api/info-flow/newsflash_columns/newsflashes?b_id=&per_page=${ctx.query.limit ?? 100}`;
|
||||
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
@@ -13,7 +14,7 @@ module.exports = async (ctx) => {
|
||||
const items = response.data.data.items.map((item) => ({
|
||||
title: item.title,
|
||||
link: item.news_url,
|
||||
pubDate: timezone(new Date(item.published_at), +8),
|
||||
pubDate: timezone(parseDate(item.published_at), +8),
|
||||
description: `<p>${item.description}</p>`,
|
||||
}));
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const timezone = require('@/utils/timezone');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const { rootUrl } = require('./utils');
|
||||
|
||||
const titles = {
|
||||
280: '最新',
|
||||
333: '新品',
|
||||
331: 'DeFi',
|
||||
334: 'NFT',
|
||||
@@ -13,24 +16,26 @@ const titles = {
|
||||
};
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const id = ctx.params.id || '333';
|
||||
const id = ctx.params.id ?? '280';
|
||||
|
||||
const rootUrl = 'https://www.odaily.com';
|
||||
const currentUrl = `${rootUrl}/api/pp/api/app-front/feed-stream?feed_id=${id}&b_id=&per_page=10`;
|
||||
const currentUrl = `${rootUrl}/api/pp/api/app-front/feed-stream?feed_id=${id}&b_id=&per_page=${ctx.query.limit ?? 25}`;
|
||||
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: currentUrl,
|
||||
});
|
||||
|
||||
const list = response.data.data.items.map((item) => ({
|
||||
let items = response.data.data.items.map((item) => ({
|
||||
title: item.title,
|
||||
link: `${rootUrl}/post/${item.entity_id}`,
|
||||
pubDate: timezone(new Date(item.published_at), +8),
|
||||
author: item.user.name,
|
||||
type: item.entity_type,
|
||||
description: `<p>${item.summary}</p>`,
|
||||
link: `${rootUrl}/${item.entity_type}/${item.entity_id}`,
|
||||
pubDate: timezone(parseDate(item.published_at), +8),
|
||||
}));
|
||||
|
||||
const items = await Promise.all(
|
||||
list.map(
|
||||
items = await Promise.all(
|
||||
items.map(
|
||||
async (item) =>
|
||||
await ctx.cache.tryGet(item.link, async () => {
|
||||
const detailResponse = await got({
|
||||
@@ -38,14 +43,15 @@ module.exports = async (ctx) => {
|
||||
url: item.link,
|
||||
});
|
||||
|
||||
const content = cheerio.load(detailResponse.data.match(/"content":"(.*)","extraction_tags":/)[1]);
|
||||
const content = cheerio.load(detailResponse.data.match(item.type === 'post' ? /"content":"(.*)","extraction_tags":/ : /"description":"(.*?)","cover":/)[1]);
|
||||
|
||||
content('img').each(function () {
|
||||
content(this).attr('src', content(this).attr('src').replace(/\\"/g, ''));
|
||||
});
|
||||
|
||||
item.description = content.html();
|
||||
item.author = detailResponse.data.match(/"name":"(.*)","avatar_url"/)[1];
|
||||
|
||||
delete item.type;
|
||||
|
||||
return item;
|
||||
})
|
||||
60
lib/v2/odaily/radar.js
Normal file
60
lib/v2/odaily/radar.js
Normal file
@@ -0,0 +1,60 @@
|
||||
module.exports = {
|
||||
'odaily.news': {
|
||||
_name: 'Odaily 星球日报',
|
||||
'.': [
|
||||
{
|
||||
title: '快讯',
|
||||
docs: 'https://docs.rsshub.app/new-media.html#odaily-xing-qiu-ri-bao-kuai-xun',
|
||||
source: ['/newsflash', '/'],
|
||||
target: '/odaily/newsflash',
|
||||
},
|
||||
{
|
||||
title: '文章',
|
||||
docs: 'https://docs.rsshub.app/new-media.html#odaily-xing-qiu-ri-bao-wen-zhang',
|
||||
source: ['/'],
|
||||
target: '/odaily/:id?',
|
||||
},
|
||||
{
|
||||
title: '用户文章',
|
||||
docs: 'https://docs.rsshub.app/new-media.html#odaily-xing-qiu-ri-bao-yong-hu-wen-zhang',
|
||||
source: ['/user/:id', '/'],
|
||||
target: '/odaily/user/:id',
|
||||
},
|
||||
{
|
||||
title: '活动',
|
||||
docs: 'https://docs.rsshub.app/new-media.html#odaily-xing-qiu-ri-bao-huo-dong',
|
||||
source: ['/activityPage', '/'],
|
||||
target: '/odaily/activity',
|
||||
},
|
||||
],
|
||||
},
|
||||
'0daily.com': {
|
||||
_name: 'Odaily 星球日报',
|
||||
'.': [
|
||||
{
|
||||
title: '快讯',
|
||||
docs: 'https://docs.rsshub.app/new-media.html#odaily-xing-qiu-ri-bao-kuai-xun',
|
||||
source: ['/newsflash', '/'],
|
||||
target: '/odaily/newsflash',
|
||||
},
|
||||
{
|
||||
title: '文章',
|
||||
docs: 'https://docs.rsshub.app/new-media.html#odaily-xing-qiu-ri-bao-wen-zhang',
|
||||
source: ['/'],
|
||||
target: '/odaily/:id?',
|
||||
},
|
||||
{
|
||||
title: '用户文章',
|
||||
docs: 'https://docs.rsshub.app/new-media.html#odaily-xing-qiu-ri-bao-yong-hu-wen-zhang',
|
||||
source: ['/user/:id', '/'],
|
||||
target: '/odaily/user/:id',
|
||||
},
|
||||
{
|
||||
title: '活动',
|
||||
docs: 'https://docs.rsshub.app/new-media.html#odaily-xing-qiu-ri-bao-huo-dong',
|
||||
source: ['/activityPage', '/'],
|
||||
target: '/odaily/activity',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
6
lib/v2/odaily/router.js
Normal file
6
lib/v2/odaily/router.js
Normal file
@@ -0,0 +1,6 @@
|
||||
module.exports = function (router) {
|
||||
router.get('/activity', require('./activity'));
|
||||
router.get('/newsflash', require('./newsflash'));
|
||||
router.get('/user/:id', require('./user'));
|
||||
router.get('/:id?', require('./post'));
|
||||
};
|
||||
@@ -1,12 +1,13 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const timezone = require('@/utils/timezone');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const { rootUrl } = require('./utils');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const id = ctx.params.id;
|
||||
|
||||
const rootUrl = 'https://www.odaily.com';
|
||||
const currentUrl = `${rootUrl}/service/feed_stream/user/${id}?b_id=10&per_page=10`;
|
||||
const currentUrl = `${rootUrl}/service/feed_stream/user/${id}?b_id=10&per_page=${ctx.query.limit ?? 25}`;
|
||||
|
||||
let author = '';
|
||||
|
||||
@@ -15,15 +16,15 @@ module.exports = async (ctx) => {
|
||||
url: currentUrl,
|
||||
});
|
||||
|
||||
const list = response.data.data.items.data.map((item) => ({
|
||||
let items = response.data.data.items.data.map((item) => ({
|
||||
title: item.title,
|
||||
summary: item.summary,
|
||||
link: `${rootUrl}/post/${item.entity_id}`,
|
||||
pubDate: timezone(new Date(item.published_at), +8),
|
||||
pubDate: timezone(parseDate(item.published_at), +8),
|
||||
}));
|
||||
|
||||
const items = await Promise.all(
|
||||
list.map(
|
||||
items = await Promise.all(
|
||||
items.map(
|
||||
async (item) =>
|
||||
await ctx.cache.tryGet(item.link, async () => {
|
||||
const detailResponse = await got({
|
||||
@@ -38,7 +39,7 @@ module.exports = async (ctx) => {
|
||||
});
|
||||
|
||||
item.description = content.html();
|
||||
item.author = author = detailResponse.data.match(/"name":"(.*)","avatar_url"/)[1];
|
||||
item.author = author = detailResponse.data.match(/"name":"(.*)","role_id/)[1];
|
||||
|
||||
return item;
|
||||
})
|
||||
3
lib/v2/odaily/utils.js
Normal file
3
lib/v2/odaily/utils.js
Normal file
@@ -0,0 +1,3 @@
|
||||
module.exports = {
|
||||
rootUrl: 'https://www.odaily.news',
|
||||
};
|
||||
Reference in New Issue
Block a user