From 7328f5184057b361ecbf5e2dd43d14403d52938e Mon Sep 17 00:00:00 2001 From: Henry Wang Date: Sat, 29 Feb 2020 12:09:55 +0000 Subject: [PATCH] =?UTF-8?q?feat:=20=E7=A7=BB=E9=99=A4=E5=A5=BD=E5=A5=87?= =?UTF-8?q?=E6=80=AA=E8=B7=AF=E7=94=B1=20(#4114)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/router.js | 2 - lib/routes/qdaily/notch/explore.js | 65 ------------------------------ lib/routes/qdaily/notch/index.js | 56 ------------------------- 3 files changed, 123 deletions(-) delete mode 100644 lib/routes/qdaily/notch/explore.js delete mode 100644 lib/routes/qdaily/notch/index.js diff --git a/lib/router.js b/lib/router.js index b939ed6f7..9bf80ec23 100644 --- a/lib/router.js +++ b/lib/router.js @@ -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')); // 爱奇艺 diff --git a/lib/routes/qdaily/notch/explore.js b/lib/routes/qdaily/notch/explore.js deleted file mode 100644 index 4c8af1698..000000000 --- a/lib/routes/qdaily/notch/explore.js +++ /dev/null @@ -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 = '
'; - pics.forEach((pic) => { - description += `
下载原图

`; - }); - - description += '
'; - return description; - }; - - switch (type) { - case 'lab': - return `

${item.post.description}
参与讨论
`; - 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, - }; -}; diff --git a/lib/routes/qdaily/notch/index.js b/lib/routes/qdaily/notch/index.js deleted file mode 100644 index b39c5989b..000000000 --- a/lib/routes/qdaily/notch/index.js +++ /dev/null @@ -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, - }; -};