From 5df4050a8c34aef8674eb6dce16cccb84c5ba2e1 Mon Sep 17 00:00:00 2001 From: Arracc <33948217+Arracc@users.noreply.github.com> Date: Thu, 14 Jan 2021 05:14:43 +0800 Subject: [PATCH] fix: /gamer/gnn/ (#6689) * On branch master Your branch is up to date with 'origin/master'. Changes to be committed: modified: docs/traditional-media.md modified: lib/router.js new file: lib/routes/yomiuri/national.js new file: lib/routes/yomiuri/top.js * On branch master Your branch is ahead of 'origin/master' by 1 commit. Changes to be committed: modified: docs/game.md modified: lib/router.js new file: lib/routes/gamer/index.js * On branch master Your branch is ahead of 'origin/master' by 3 commits. (use "git push" to publish your local commits) Changes to be committed: new file: lib/router.js * On branch master Your branch is ahead of 'origin/master' by 4 commits. (use "git push" to publish your local commits) Changes to be committed: modified: lib/router.js * On branch master Your branch is up to date with 'origin/master'. Changes to be committed: modified: lib/routes/gamer/index.js * On branch master Your branch is up to date with 'origin/master'. Changes to be committed: new file: New Text Document.txt modified: lib/routes/gamer/index.js * On branch master Your branch is up to date with 'origin/master'. Changes to be committed: modified: lib/routes/gamer/index.js * On branch master Your branch is up to date with 'origin/master'. Changes to be committed: modified: lib/routes/gamer/index.js * On branch master Your branch is up to date with 'origin/master'. Changes to be committed: modified: lib/routes/gamer/index.js * On branch master Your branch is ahead of 'origin/master' by 1 commit. (use "git push" to publish your local commits) Changes to be committed: modified: docs/game.md modified: docs/traditional-media.md modified: lib/router.js new file: lib/routes/gamer/gnn_index.js deleted: lib/routes/gamer/index.js new file: lib/routes/yomiuri/news.js eleted: lib/routes/yomiuri/top.js * On branch master Your branch is up to date with 'origin/master'. Changes to be committed: modified: lib/routes/gamer/gnn_index.js * On branch master Your branch is up to date with 'origin/master'. Changes to be committed: modified: docs/game.md modified: lib/routes/gamer/gnn_index.js * On branch master Your branch is up to date with 'origin/master'. Changes to be committed: new file: docs/game.md new file: docs/traditional-media.md new file: lib/router.js * On branch master Your branch is up to date with 'origin/master'. Changes to be committed: deleted: lib/routes/yomiuri/national.js * On branch master Your branch is up to date with 'origin/master'. Changes to be committed: modified: lib/routes/gamer/gnn_index.js modified: lib/routes/yomiuri/news.js * [CodeFactor] Apply fixes to commit 9679b09 [ci skip] [skip ci] * On branch master Your branch is up to date with 'origin/master'. Changes to be committed: modified: lib/routes/gamer/gnn_index.js modified: lib/routes/yomiuri/news.js * On branch master Your branch is ahead of 'origin/master' by 2 commits. (use "git push" to publish your local commits) Changes to be committed: modified: lib/routes/gamer/gnn_index.js * [CodeFactor] Apply fixes [ci skip] [skip ci] * On branch master Your branch is behind 'origin/master' by 1 commit, and can be fast-forwarded. (use "git pull" to update your local branch) Changes to be committed: modified: lib/routes/gamer/gnn_index.js modified: lib/routes/yomiuri/news.js * On branch master Your branch is ahead of 'origin/master' by 2 commits. (use "git push" to publish your local commits) Changes to be committed: modified: lib/routes/yomiuri/news.js * On branch master Your branch is up to date with 'origin/master'. Changes to be committed: modified: lib/routes/gamer/gnn_index.js modified: lib/routes/yomiuri/news.js * On branch master Your branch is up to date with 'origin/master'. Changes to be committed: modified: lib/routes/gamer/gnn_index.js * On branch master Your branch is up to date with 'origin/master'. Changes to be committed: modified: lib/routes/gamer/gnn_index.js * On branch master Your branch is up to date with 'origin/master'. Changes to be committed: modified: docs/game.md modified: docs/traditional-media.md * On branch master Your branch is up to date with 'origin/master'. Changes to be committed: modified: docs/game.md modified: lib/routes/gamer/gnn_index.js modified: lib/routes/yomiuri/news.js * On branch master Your branch is up to date with 'origin/master'. Changes to be committed: modified: lib/router.js * fix gnn.gamer.com.tw image display error * support more category, fix article form home.gamer * merge upstream * add nikkei * add free article filter * fetch upstream * fix text fetching error from home.gamer.com.tw * merge upstream/master * fix nikkei/news * fix article dumplicate error, fix author grabbing error Co-authored-by: codefactor-io --- lib/routes/gamer/gnn_index.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/routes/gamer/gnn_index.js b/lib/routes/gamer/gnn_index.js index 5bc8dbf99..f77f843af 100644 --- a/lib/routes/gamer/gnn_index.js +++ b/lib/routes/gamer/gnn_index.js @@ -84,30 +84,28 @@ module.exports = async (ctx) => { const items = await Promise.all( list.map(async (item) => { - let author = ''; item.description = await ctx.cache.tryGet(item.link, async () => { const response = await got.get(item.link); let component = ''; const urlReg = /window.location.replace\('.*'/g; if (response.body.search(urlReg) < 0) { const $ = cheerio.load(response.data); + item.author = $('span.GN-lbox3C').text().split(')')[0].split(' 報導')[0].split(' 提供')[0].split(' 同意授權轉載')[0].replace('(', ''); component = $('div.GN-lbox3B').html(); - author = $('span.GN-lbox3C').text().split(')')[0].split(' 報導')[0].split(' 提供')[0].split(' 同意授權轉載')[0].replace('(', ''); } else { const newUrl = response.body.match(urlReg)[0].split('(')[1].replace(/'/g, ''); const _response = await got.get(newUrl); const _$ = cheerio.load(_response.data); + item.author = _$('span.ST1').text().split('│', 2)[0].split('作者:')[1]; component = _$('div.MSG-list8C').html(); if (!component) { + item.author = _$('a.caption-text.primary').text(); component = _$('div.text-paragraph').html(); } - item.link = newUrl; - author = _$('span.ST1').text().split('│', 2)[0].split('作者:')[1]; } component = component.replace(/\b(data-src)\b/g, 'src'); return component; }); - item.author = author; return item; }) );