diff --git a/docs/game.md b/docs/game.md index 67c783d920..a4a07771ea 100644 --- a/docs/game.md +++ b/docs/game.md @@ -253,6 +253,12 @@ Example: `https://store.steampowered.com/search/?specials=1&term=atelier` 中的 +## 掌上英雄联盟 + +### 推荐 + + + ## きららファンタジア|奇拉拉幻想曲 ### 公告 diff --git a/lib/router.js b/lib/router.js index 72a8edf65c..8a64bf6292 100644 --- a/lib/router.js +++ b/lib/router.js @@ -1449,4 +1449,7 @@ router.get('/lwn/alerts/:distributor', require('./routes/lwn/alerts')); // 唱吧 router.get('/changba/:userid', require('./routes/changba/user')); +// 掌上英雄联盟 +router.get('/lolapp/recommend', require('./routes/lolapp/recommend')); + module.exports = router; diff --git a/lib/routes/lolapp/recommend.js b/lib/routes/lolapp/recommend.js new file mode 100644 index 0000000000..15b7687d68 --- /dev/null +++ b/lib/routes/lolapp/recommend.js @@ -0,0 +1,48 @@ +const got = require('@/utils/got'); + +const sourceTimezoneOffset = -8; +module.exports = async (ctx) => { + const cid = 12; + const areaid = 2; + + const url = 'http://qt.qq.com/lua/lol_news/recommend_refresh?cid=' + cid + '&plat=ios&version=9880&areaid=' + areaid; + const res = await got.get(url); + const articles = (res.data || {}).update_list || []; + const out = await Promise.all( + articles.map(async (article) => { + const link = article.article_url; + const cache = await ctx.cache.get(link); + if (cache) { + return JSON.parse(cache); + } + + const guid = article.content_id; + const title = article.title; + const time = new Date(article.publication_date); + time.setTime(time.getTime() + (sourceTimezoneOffset - time.getTimezoneOffset() / 60) * 60 * 60 * 1000); + const pubDate = time.toUTCString(); + + // const detailJsonLink = article.detail_json; + // const detailRes = await got.get(detailJsonLink); + const description = article.image_url_big; + + const item = { + title, + description, + pubDate, + link, + guid, + }; + + ctx.cache.set(link, JSON.stringify(item)); + + return item; + }) + ); + + ctx.state.data = { + title: '掌上英雄联盟 - 推荐', + link: 'http://lol.qq.com/app/index.html', + item: out, + }; +};