feat: 移除好奇怪路由 (#4114)

This commit is contained in:
Henry Wang
2020-02-29 12:09:55 +00:00
committed by GitHub
parent 0d9d1c774a
commit 7328f51840
3 changed files with 0 additions and 123 deletions

View File

@@ -221,8 +221,6 @@ router.get('/geektime/news', require('./routes/geektime/news'));
router.get('/jiemian/list/:cid', require('./routes/jiemian/list.js'));
// 好奇心日报
router.get('/qdaily/notch/posts', require('./routes/qdaily/notch/index'));
router.get('/qdaily/notch/explore/:id', require('./routes/qdaily/notch/explore'));
router.get('/qdaily/:type/:id', require('./routes/qdaily/index'));
// 爱奇艺

View File

@@ -1,65 +0,0 @@
const got = require('@/utils/got');
const headers = {
'User-Agent': 'QdailyNotch/3.2.3 (iPhone; iOS 12.3.1; Scale/3.00)',
Host: 'notch.qdaily.com',
};
const ProcessFeed = async (type, item) => {
const processPhoto = (pics) => {
let description = '<div style="text-align: center">';
pics.forEach((pic) => {
description += `<img src='${pic.preview_pic}'> <br> <a href='${pic.original_pic.split('?imageMogr2/')[0]}'>下载原图</a> <br> <br>`;
});
description += '</div>';
return description;
};
switch (type) {
case 'lab':
return `<div style="text-align: center"><img src='${item.index_info.index_pic}'> <br> ${item.post.description} <br> <a href='${item.post.share.url}'>参与讨论</a></div>`;
case 'long_photo':
return processPhoto(item.long_photos);
case 'photo':
return processPhoto(item.photos);
}
};
module.exports = async (ctx) => {
const meta = await got({
method: 'get',
url: `http://notch.qdaily.com/api/v3/tags/${ctx.params.id}`,
headers,
});
const data = meta.data.response.tag;
const post = await got({
method: 'get',
url: `http://notch.qdaily.com/api/v3/tags/post_index?id=${ctx.params.id}`,
headers,
});
const posts = post.data.response.feeds;
const items = await Promise.all(
posts.map(async (item) => {
const post = item.post;
return {
title: post.title,
description: await ProcessFeed(data.index_type, item),
link: post.share.url,
pubDate: new Date(post.published_at * 1000).toUTCString(),
author: data.title,
};
})
);
ctx.state.data = {
title: `好奇怪 - ${data.title}`,
link: `http://notch.qdaily.com/`,
description: data.description,
item: items,
};
};

View File

@@ -1,56 +0,0 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const headers = {
'User-Agent': 'QdailyNotch/3.2.3 (iPhone; iOS 12.3.1; Scale/3.00)',
Host: 'notch.qdaily.com',
};
const ProcessFeed = async (id) => {
const response = await got({
method: 'get',
url: `http://notch.qdaily.com/api/v3/posts/${id}?platform=ios`,
headers,
});
const $ = cheerio.load(response.data.response.show_info.body);
const description = $('.article-detail-bd');
$('.article-banner > img').insertBefore(description[0].firstChild);
description.find('.lazyload').each((i, e) => {
$(e).attr('src', $(e).attr('data-src'));
});
return description.html();
};
module.exports = async (ctx) => {
const response = await got({
method: 'get',
url: 'http://notch.qdaily.com/api/v3/posts',
headers,
});
const data = response.data.response.feeds;
const items = await Promise.all(
data.map(async (item) => {
const post = item.post;
return {
title: post.title,
description: await ProcessFeed(post.id),
link: post.share.url,
pubDate: new Date(post.published_at * 1000).toUTCString(),
author: post.author_info ? post.author_info.username : '',
};
})
);
ctx.state.data = {
title: `好奇怪 - 首页`,
link: `http://notch.qdaily.com/`,
description: `好奇怪,开启你的脑洞世界。好奇心日报旗下产品。`,
item: items,
};
};