feat: v3 migration - 9/n
This commit is contained in:
parent
ac7cb259fc
commit
46701c20de
|
|
@ -48,8 +48,8 @@ function getStationInfo(stationName) {
|
|||
|
||||
module.exports = async (ctx) => {
|
||||
const date = ctx.req.param('date');
|
||||
const fromStationInfo = await getStationInfo(ctx.req.param('from'), ctx);
|
||||
const toStationInfo = await getStationInfo(ctx.req.param('to'), ctx);
|
||||
const fromStationInfo = await getStationInfo(ctx.req.param('from'));
|
||||
const toStationInfo = await getStationInfo(ctx.req.param('to'));
|
||||
const type = ctx.req.param('type') ?? 'ADULT';
|
||||
|
||||
const apiUrl = `${rootUrl}/otn/leftTicket/queryA?leftTicketDTO.train_date=${date}&leftTicketDTO.from_station=${fromStationInfo.code}&leftTicketDTO.to_station=${toStationInfo.code}&purpose_codes=${type}`;
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ module.exports = async (ctx) => {
|
|||
const resp = channel_url_resp.data;
|
||||
const list = resp.data.rows;
|
||||
|
||||
const items = await Promise.all(list.filter((item) => item?.url?.startsWith('/a/') || item?.object?.url.startsWith('/a/')).map((item) => utils.parseArticle(item, ctx)));
|
||||
const items = await Promise.all(list.filter((item) => item?.url?.startsWith('/a/') || item?.object?.url.startsWith('/a/')).map((item) => utils.parseArticle(item)));
|
||||
|
||||
ctx.set('data', {
|
||||
title: title.split(' - ').slice(0, 2).join(' - '),
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ module.exports = async (ctx) => {
|
|||
list = (await rssParser.parseURL(`${link}.rss`)).items;
|
||||
}
|
||||
|
||||
const item = await asyncPoolAll(1, list, (item) => parseArticle(item, ctx));
|
||||
const item = await asyncPoolAll(1, list, (item) => parseArticle(item));
|
||||
const authorName = item.find((i) => i.author)?.author ?? 'Unknown';
|
||||
|
||||
ctx.set('data', {
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ module.exports = async (ctx) => {
|
|||
const currentUrl = site ? `${rootUrl}/${site}/sitemap_news.xml` : `${rootUrl}/sitemap_news.xml`;
|
||||
|
||||
const list = await parseNewsList(currentUrl, ctx);
|
||||
const items = await asyncPoolAll(1, list, (item) => parseArticle(item, ctx));
|
||||
const items = await asyncPoolAll(1, list, (item) => parseArticle(item));
|
||||
ctx.set('data', {
|
||||
title: `Bloomberg - ${site_title_mapping[site ?? '/']}`,
|
||||
link: currentUrl,
|
||||
|
|
|
|||
|
|
@ -9,11 +9,11 @@ module.exports = async (ctx) => {
|
|||
} else if (category === 'xinwen1j1') {
|
||||
// 新闻1+1
|
||||
const xinwen1j1 = require('./utils/xinwen1j1');
|
||||
responseData = await xinwen1j1(ctx);
|
||||
responseData = await xinwen1j1();
|
||||
} else {
|
||||
// 央视新闻
|
||||
const getNews = require('./utils/news');
|
||||
responseData = await getNews(category, ctx);
|
||||
responseData = await getNews(category);
|
||||
}
|
||||
|
||||
ctx.set('data', responseData);
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ const ProcessFeed = (data) =>
|
|||
return { ...single, ...other };
|
||||
})
|
||||
);
|
||||
module.exports = async (ctx) => {
|
||||
module.exports = async () => {
|
||||
const baseUrl = 'https://api.cntv.cn/NewVideo/getVideoListByColumn?id=TOPC1451559066181661&n=20&sort=desc&p=1&mode=0&serviceId=tvcctv';
|
||||
// 获取要处理的页面
|
||||
const res = await got({
|
||||
|
|
@ -70,7 +70,7 @@ module.exports = async (ctx) => {
|
|||
// $('div.image').slice(0,3).find('a').attr('href').split('?')[0]
|
||||
|
||||
// 处理所有的页面
|
||||
const result = await ProcessFeed(data, ctx);
|
||||
const result = await ProcessFeed(data);
|
||||
|
||||
return {
|
||||
title: '《新闻1+1》- 中央电视台新闻频道',
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ module.exports = async (ctx) => {
|
|||
targetTitle = item.targetRow.title;
|
||||
}
|
||||
|
||||
return utils.parseDynamic(item, ctx);
|
||||
return utils.parseDynamic(item);
|
||||
})
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ module.exports = async (ctx) => {
|
|||
}
|
||||
}
|
||||
|
||||
let out = await Promise.all(t.map((item) => utils.parseDynamic(item, ctx)));
|
||||
let out = await Promise.all(t.map((item) => utils.parseDynamic(item)));
|
||||
|
||||
out = out.filter(Boolean);
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ module.exports = async (ctx) => {
|
|||
});
|
||||
const data = response.data.data;
|
||||
|
||||
let out = await Promise.all(data.map((item) => utils.parseDynamic(item, ctx)));
|
||||
let out = await Promise.all(data.map((item) => utils.parseDynamic(item)));
|
||||
|
||||
out = out.filter(Boolean); // 去除空值
|
||||
if (out.length === 0) {
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ module.exports = async (ctx) => {
|
|||
});
|
||||
const data = response.data.data;
|
||||
|
||||
const out = await Promise.all(data.map((item) => utils.parseDynamic(item, ctx)));
|
||||
const out = await Promise.all(data.map((item) => utils.parseDynamic(item)));
|
||||
|
||||
ctx.set('data', {
|
||||
title: urls[type].title,
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ module.exports = async (ctx) => {
|
|||
});
|
||||
const data = response.data.data;
|
||||
|
||||
const out = await Promise.all(data.map((item) => utils.parseDynamic(item, ctx)));
|
||||
const out = await Promise.all(data.map((item) => utils.parseDynamic(item)));
|
||||
|
||||
ctx.set('data', {
|
||||
title: feedTitle,
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ module.exports = async (ctx) => {
|
|||
username = item.username;
|
||||
}
|
||||
|
||||
return utils.parseDynamic(item, ctx);
|
||||
return utils.parseDynamic(item);
|
||||
})
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
const utils = require('./utils');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
ctx.set('data', await utils.parseFeed({ subjectid: ctx.req.param('id') }, ctx));
|
||||
ctx.set('data', await utils.parseFeed({ subjectid: ctx.req.param('id') }));
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
const utils = require('./utils');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
ctx.set('data', await utils.parseFeed({ subjectid: 70 }, ctx));
|
||||
ctx.set('data', await utils.parseFeed({ subjectid: 70 }));
|
||||
};
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ module.exports = async (ctx) => {
|
|||
const pageData = await cache.tryGet(
|
||||
`douyin:user:${uid}`,
|
||||
async () => {
|
||||
const renderData = await universalGet(pageUrl, 'user', ctx);
|
||||
const renderData = await universalGet(pageUrl, 'user');
|
||||
const dataKey = Object.keys(renderData).find((key) => renderData[key].user && renderData[key].post);
|
||||
return renderData[dataKey];
|
||||
},
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ module.exports = async (ctx) => {
|
|||
feed.items.slice(0, ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit'), 10) : 30).map(async (item) => {
|
||||
const path = item.link.slice(item.link.lastIndexOf('/') + 1);
|
||||
const isNotCollection = !/^\d{4}-\d{2}-\d{2}$/.test(path);
|
||||
const itemDetails = isNotCollection ? await getArticleDetail(item.link, ctx) : null;
|
||||
const itemDetails = isNotCollection ? await getArticleDetail(item.link) : null;
|
||||
return {
|
||||
title: item.title,
|
||||
description: isNotCollection ? itemDetails.article : item.content,
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ module.exports = async (ctx) => {
|
|||
const items = await Promise.all(
|
||||
response.data.articles.new.slice(0, ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit')) : 10).map(async (item) => ({
|
||||
title: parseTitle(item.body.title, [main_language]),
|
||||
description: await getArticleDetail(item.article_id, language, ctx),
|
||||
description: await getArticleDetail(item.article_id, language),
|
||||
category: parseTitle(item.body.fly_title, [main_language]),
|
||||
link: `https://www.businessreview.global/latest/${item.article_id}`,
|
||||
pubDate: item.publication_date,
|
||||
|
|
|
|||
|
|
@ -7,9 +7,9 @@ module.exports = async (ctx) => {
|
|||
const topicId = Number(ctx.req.param('id'));
|
||||
const { type = 'all' } = ctx.params;
|
||||
|
||||
const forumMeta = await getForumMeta(topicId, ctx);
|
||||
const forumMeta = await getForumMeta(topicId);
|
||||
const topicMeta = forumMeta.dataList.find((data) => data.topicId === topicId);
|
||||
const threads = (await getThreads(topicId, type, ctx)).data.dataList.map((data) => ({
|
||||
const threads = (await getThreads(topicId, type)).data.dataList.map((data) => ({
|
||||
title: data.title,
|
||||
pubDate: parseDate(data.dateline * 1000),
|
||||
author: data.userBaseInfo.userName,
|
||||
|
|
@ -19,7 +19,7 @@ module.exports = async (ctx) => {
|
|||
|
||||
const posts = await Promise.all(
|
||||
threads.map(async (item) => {
|
||||
const thread = await getThread(item.tid, topicId, ctx);
|
||||
const thread = await getThread(item.tid, topicId);
|
||||
if (thread.status.code === 0) {
|
||||
const img = art(path.join(__dirname, 'templates/img.art'), {
|
||||
images: thread.data.thread.fengTalkImage.length ? thread.data.thread.fengTalkImage : undefined,
|
||||
|
|
|
|||
|
|
@ -37,8 +37,8 @@ const getCategory = (topicId) => {
|
|||
);
|
||||
};
|
||||
|
||||
const getForumMeta = async (topicId, ctx) => {
|
||||
const categoryData = await getCategory(topicId, ctx);
|
||||
const getForumMeta = async (topicId) => {
|
||||
const categoryData = await getCategory(topicId);
|
||||
return Object.values(categoryData.data.dataList).find((item) => item.dataList.find((i) => i.topicId === topicId));
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ module.exports = async (ctx) => {
|
|||
const currentUrl = `${rootUrl}${pathname}`;
|
||||
|
||||
const { list, title } = await parseNewsList(currentUrl, '.list_news_dl2 li', ctx);
|
||||
const items = await Promise.all(list.map((item) => parseArticle(item, ctx)));
|
||||
const items = await Promise.all(list.map((item) => parseArticle(item)));
|
||||
|
||||
ctx.set('data', {
|
||||
title,
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ module.exports = async (ctx) => {
|
|||
}))
|
||||
.get();
|
||||
|
||||
const items = await processItems(list, ctx);
|
||||
const items = await processItems(list);
|
||||
|
||||
ctx.set('data', {
|
||||
title: '中国人民银行 工作论文',
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ module.exports = async (ctx) => {
|
|||
const items = await Promise.all(
|
||||
list.map(async (item) => ({
|
||||
title: item.Title,
|
||||
description: await processReport(item, ctx),
|
||||
description: await processReport(item),
|
||||
pubDate: timezone(parseDate(item.Uptime), +8),
|
||||
link: item.VisitUrl,
|
||||
}))
|
||||
|
|
|
|||
|
|
@ -177,21 +177,21 @@ module.exports = {
|
|||
);
|
||||
|
||||
if (data.length === 0) {
|
||||
ctx.state.data = {
|
||||
ctx.set('data', {
|
||||
title: '主题 ID 不存在,或该主题暂无内容',
|
||||
};
|
||||
});
|
||||
return null;
|
||||
}
|
||||
|
||||
const topic = data.topic;
|
||||
|
||||
ctx.state.data = {
|
||||
ctx.set('data', {
|
||||
title: `${topic.content} - 即刻圈子`,
|
||||
link: url,
|
||||
description: topic.briefIntro,
|
||||
image: topic.squarePicture.picUrl || topic.squarePicture.middlePicUrl || topic.squarePicture.thumbnailUrl,
|
||||
// item: topicDataHanding(data),
|
||||
};
|
||||
});
|
||||
|
||||
return data;
|
||||
},
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ module.exports = async (ctx) => {
|
|||
const acct = ctx.req.param('acct');
|
||||
const only_media = ctx.req.param('only_media') ? 'true' : 'false';
|
||||
|
||||
const { site, account_id } = await utils.getAccountIdByAcct(acct, ctx);
|
||||
const { site, account_id } = await utils.getAccountIdByAcct(acct);
|
||||
|
||||
const { account_data, data } = await utils.getAccountStatuses(site, account_id, only_media);
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ module.exports = async (ctx) => {
|
|||
|
||||
let items = getArticleList($);
|
||||
|
||||
items = await Promise.all(items.map((item) => getArticle(item, ctx)));
|
||||
items = await Promise.all(items.map((item) => getArticle(item)));
|
||||
|
||||
ctx.set('data', {
|
||||
title: $('title').text().trim(),
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ module.exports = async (ctx) => {
|
|||
|
||||
let items = getArticleList(pageCapture);
|
||||
|
||||
items = await Promise.all(items.map((item) => getArticle(item, ctx)));
|
||||
items = await Promise.all(items.map((item) => getArticle(item)));
|
||||
|
||||
ctx.set('data', {
|
||||
title: pageCapture('title').text(),
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ module.exports = async (ctx) => {
|
|||
};
|
||||
});
|
||||
|
||||
items = await Promise.all(items.map((item) => cache.tryGet(item.link, () => getArticle(item, ctx))));
|
||||
items = await Promise.all(items.map((item) => cache.tryGet(item.link, () => getArticle(item))));
|
||||
|
||||
ctx.set('data', {
|
||||
title: 'Nature | Latest News',
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ module.exports = async (ctx) => {
|
|||
|
||||
let items = getArticleList(pageCapture);
|
||||
|
||||
items = await Promise.all(items.map((item) => getArticle(item, ctx)));
|
||||
items = await Promise.all(items.map((item) => getArticle(item)));
|
||||
|
||||
ctx.set('data', {
|
||||
title: `Nature (${pageTitle}) | Latest Research`,
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ module.exports = async (ctx) => {
|
|||
guid: itemUrl,
|
||||
pubDate: new Date(time).toUTCString(),
|
||||
};
|
||||
const other = await loadContent(String(itemUrl), ctx);
|
||||
const other = await loadContent(String(itemUrl));
|
||||
return Object.assign({}, single, other);
|
||||
})
|
||||
);
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ module.exports = async (ctx) => {
|
|||
const items = (
|
||||
await Promise.all(
|
||||
feed.items.map(async (item) => {
|
||||
const itemDetails = await getArticleDetail(item.link, ctx);
|
||||
const itemDetails = await getArticleDetail(item.link);
|
||||
if (itemDetails === null) {
|
||||
return null;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ module.exports = async (ctx) => {
|
|||
}
|
||||
|
||||
const items = await util.ProcessList(baseUrl, baseUrl, listName, listDate, webPageName);
|
||||
const results = await util.ProcessFeed(items[0], artiContent, ctx);
|
||||
const results = await util.ProcessFeed(items[0], artiContent);
|
||||
|
||||
ctx.set('data', {
|
||||
title: 'NUA-设计学院-' + items[1],
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ module.exports = async (ctx) => {
|
|||
const webPageName = '.col_title';
|
||||
|
||||
const items = await util.ProcessList(newsUrl, baseUrl, listName, listDate, webPageName);
|
||||
const results = await util.ProcessFeed(items[0], artiContent, ctx);
|
||||
const results = await util.ProcessFeed(items[0], artiContent);
|
||||
|
||||
ctx.set('data', {
|
||||
title: 'NUA-研究生处-' + items[1],
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ module.exports = async (ctx) => {
|
|||
|
||||
const artiContent = '.read';
|
||||
const items = await util.ProcessList(newsUrl, baseUrl, listName, listDate, webPageName);
|
||||
const results = await util.ProcessFeed(items[0], artiContent, ctx);
|
||||
const results = await util.ProcessFeed(items[0], artiContent);
|
||||
|
||||
ctx.set('data', {
|
||||
title: 'NUA-' + items[1],
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ module.exports = async (ctx) => {
|
|||
const listDate = '.news_date';
|
||||
|
||||
const items = await util.ProcessList(newsUrl, baseUrl, listName, listDate, webPageName);
|
||||
const results = await util.ProcessFeed(items[0], artiContent, ctx);
|
||||
const results = await util.ProcessFeed(items[0], artiContent);
|
||||
|
||||
ctx.set('data', {
|
||||
title: 'NUA-图书馆-' + items[1],
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ module.exports = async (ctx) => {
|
|||
|
||||
const artiContent = '.read';
|
||||
const items = await util.ProcessList(newsUrl, baseUrl, listName, listDate, webPageName);
|
||||
const results = await util.ProcessFeed(items[0], artiContent, ctx);
|
||||
const results = await util.ProcessFeed(items[0], artiContent);
|
||||
|
||||
ctx.set('data', {
|
||||
title: 'NUA-双馨网-' + items[1],
|
||||
|
|
|
|||
|
|
@ -1,15 +1,15 @@
|
|||
module.exports = (link, ctx) => {
|
||||
module.exports = (link) => {
|
||||
if (link.startsWith('https://xinwen.wh.sdu.edu.cn/')) {
|
||||
return require('./wh/news')(link, ctx);
|
||||
return require('./wh/news')(link);
|
||||
}
|
||||
if (link.startsWith('https://www.view.sdu.edu.cn/')) {
|
||||
return require('./view')(link, ctx);
|
||||
return require('./view')(link);
|
||||
}
|
||||
if (link.startsWith('https://www.sdrj.sdu.edu.cn/')) {
|
||||
return require('./sdrj')(link, ctx);
|
||||
return require('./sdrj')(link);
|
||||
}
|
||||
if (link.startsWith('https://jwc.wh.sdu.edu.cn/')) {
|
||||
return require('./wh/jwc')(link, ctx);
|
||||
return require('./wh/jwc')(link);
|
||||
}
|
||||
return {};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ module.exports = async (ctx) => {
|
|||
const href = anchor.attr('href');
|
||||
const link = href.startsWith('http') ? href : baseUrl + href;
|
||||
const title = item.text();
|
||||
const { description, author: exactAuthor, exactDate } = await cache.tryGet(link, () => extractor(link, ctx));
|
||||
const { description, author: exactAuthor, exactDate } = await cache.tryGet(link, () => extractor(link));
|
||||
const author = exactAuthor ?? '教务处';
|
||||
const pubDate = exactDate ?? timezone(parseDate(dateText.slice(1, -1), 'YYYY-MM-DD'), +8);
|
||||
return {
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ module.exports = async (ctx) => {
|
|||
const title = anchor.attr('title');
|
||||
const href = anchor.attr('href');
|
||||
const link = href.startsWith('http') ? href : baseUrl + href;
|
||||
const { description, author, exactDate } = await cache.tryGet(link, () => extractor(link, ctx));
|
||||
const { description, author, exactDate } = await cache.tryGet(link, () => extractor(link));
|
||||
const span = item.find('span');
|
||||
const pubDate = exactDate ?? parseDate(span.text(), 'YYYY/MM/DD');
|
||||
return {
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ module.exports = async (ctx) => {
|
|||
data.pubDate = item.node.datePublished;
|
||||
return data;
|
||||
});
|
||||
const items = await getArticleDetails(list, ctx);
|
||||
const items = await getArticleDetails(list);
|
||||
|
||||
ctx.set('data', {
|
||||
title: `The Atlantic - ${category.toUpperCase()}`,
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ module.exports = async (ctx) => {
|
|||
item.test = key;
|
||||
return item;
|
||||
});
|
||||
const items = await asyncPoolAll(10, list, (item) => parseArticle(item, ctx));
|
||||
const items = await asyncPoolAll(10, list, (item) => parseArticle(item));
|
||||
|
||||
ctx.set('data', {
|
||||
title: `WSJ${subTitle}`,
|
||||
|
|
|
|||
Loading…
Reference in New Issue