From cd4c872161054890a32dc4438b05d15678a83ee0 Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Tue, 2 Mar 2021 05:19:55 +0000 Subject: [PATCH] style: auto format --- assets/radar-rules.js | 2 +- docs/multimedia.md | 12 +++--- docs/university.md | 4 +- lib/routes/bookscomtw/newbooks.js | 49 ++++++++++++------------ lib/routes/trakt/collection.js | 6 +-- lib/routes/universities/bjtu/gs/index.js | 35 +++++++++-------- lib/routes/zhihu/zhuanlan.js | 5 +-- 7 files changed, 56 insertions(+), 57 deletions(-) diff --git a/assets/radar-rules.js b/assets/radar-rules.js index 1ea768fe9d..15f7be52e0 100644 --- a/assets/radar-rules.js +++ b/assets/radar-rules.js @@ -2746,7 +2746,7 @@ source: ['/users/:username/collection/:type/added', '/users/:username/collection'], target: (params) => `/trakt/collection/${params.username}/${params.type || 'all'}`, }, - ], + ], }, 'eagle.cool': { _name: 'Eagle', diff --git a/docs/multimedia.md b/docs/multimedia.md index 5b786a11aa..99e28b6cc5 100644 --- a/docs/multimedia.md +++ b/docs/multimedia.md @@ -623,18 +623,18 @@ pageClass: routes ## subHD.tv - 最新字幕 -## Yahoo! テレビ - -### 番組検索 - - - ## Trakt.tv ### 用户收藏 +## Yahoo! テレビ + +### 番組検索 + + + ## YouTube 见 [#youtube](/social-media.html#youtube) diff --git a/docs/university.md b/docs/university.md index b7b7707c63..0e69dbb12c 100644 --- a/docs/university.md +++ b/docs/university.md @@ -155,8 +155,8 @@ pageClass: routes | 所有文章 | 通知公告 | 新闻动态 | 招生宣传 | 培养 | 学位 | 招生 | 硕士招生 | 博士招生 | 招生简章 | 招生政策法规 | 研工部通知公告 | 研工部新闻动态 | -| ---- | -------- | -------- | ------------ | ------------ | -------- | -------- | ------ | ---------- | ------ | ------ | ------ | ------ | -| all | noti | news | zsxc | py | xw | zs | sszs | bszs | zsjz | zcfg | ygbtzgg | ygbnews | +| -------- | -------- | -------- | -------- | ---- | ---- | ---- | -------- | -------- | -------- | ------------ | -------------- | -------------- | +| all | noti | news | zsxc | py | xw | zs | sszs | bszs | zsjz | zcfg | ygbtzgg | ygbnews | diff --git a/lib/routes/bookscomtw/newbooks.js b/lib/routes/bookscomtw/newbooks.js index 8ec4dd6e8c..cf09a419ed 100644 --- a/lib/routes/bookscomtw/newbooks.js +++ b/lib/routes/bookscomtw/newbooks.js @@ -2,37 +2,36 @@ const got = require('@/utils/got'); const cheerio = require('cheerio'); module.exports = async (ctx) => { const URL = `https://www.books.com.tw/web/${ctx.params.category}/`; - const {data} = await got({ + const { data } = await got({ method: 'get', - url: URL + url: URL, }); const $ = cheerio.load(data); const list = $('div.mod_a div.wrap div.item'); - const items = list.map((i, item) => { - item = $(item); - const title = item.find('h4').text().trim(); - let imgLink = item.find('a img.cover').attr('src').trim(); - imgLink = imgLink.slice(imgLink.indexOf('https', 1), imgLink.indexOf('.jpg') + 4); - const link = item.find('a').attr('href'); - const desc = item.find('div.txt_cont p').text().trim(); - const author = item.find('li.info>a').text(); - const publisher = item.find('li.info span>a').text(); - const pubInfo = item.find('li.info').text(); - let price = item.find('ul.price li.set2 strong'); - price = price.length === 1 ? parseInt(price.text().trim()) : - parseInt(price.eq(0).text() > 10 ? (price.eq(1).text() * 100 / price.eq(0).text()).toFixed() : - (price.eq(1).text() * 10 / price.eq(0).text()).toFixed()); - return { - title, - description: `${desc}
${title}
NT$${price}元
${pubInfo}`, - link: link.slice(0, link.indexOf('?')), - author: `${author} / ${publisher}`, - }; - }).get(); + const items = list + .map((i, item) => { + item = $(item); + const title = item.find('h4').text().trim(); + let imgLink = item.find('a img.cover').attr('src').trim(); + imgLink = imgLink.slice(imgLink.indexOf('https', 1), imgLink.indexOf('.jpg') + 4); + const link = item.find('a').attr('href'); + const desc = item.find('div.txt_cont p').text().trim(); + const author = item.find('li.info>a').text(); + const publisher = item.find('li.info span>a').text(); + const pubInfo = item.find('li.info').text(); + let price = item.find('ul.price li.set2 strong'); + price = price.length === 1 ? parseInt(price.text().trim()) : parseInt(price.eq(0).text() > 10 ? ((price.eq(1).text() * 100) / price.eq(0).text()).toFixed() : ((price.eq(1).text() * 10) / price.eq(0).text()).toFixed()); + return { + title, + description: `${desc}
${title}
NT$${price}元
${pubInfo}`, + link: link.slice(0, link.indexOf('?')), + author: `${author} / ${publisher}`, + }; + }) + .get(); ctx.state.data = { title: $('title').text(), link: URL, - item: items + item: items, }; }; - diff --git a/lib/routes/trakt/collection.js b/lib/routes/trakt/collection.js index a97eaaa165..dffd195df3 100644 --- a/lib/routes/trakt/collection.js +++ b/lib/routes/trakt/collection.js @@ -2,7 +2,7 @@ const got = require('@/utils/got'); const cheerio = require('cheerio'); module.exports = async (ctx) => { - const url = `https://trakt.tv/users/${ctx.params.username}/collection/${ctx.params.type || 'all'}/added`; + const url = `https://trakt.tv/users/${ctx.params.username}/collection/${ctx.params.type || 'all'}/added`; const response = await got(url); const $ = cheerio.load(response.data); @@ -17,9 +17,7 @@ module.exports = async (ctx) => { const item = $(single); const title = item.find('.titles > h3').text(); const link = item.find('meta[itemprop="url"]').attr('content'); - const poster = item - .find('.poster > meta') - .attr('content'); + const poster = item.find('.poster > meta').attr('content'); const pubDate = new Date(item.find('.titles .format-date').attr('data-date')); return { title, diff --git a/lib/routes/universities/bjtu/gs/index.js b/lib/routes/universities/bjtu/gs/index.js index 717f9a8a6d..548ebddba5 100644 --- a/lib/routes/universities/bjtu/gs/index.js +++ b/lib/routes/universities/bjtu/gs/index.js @@ -9,91 +9,91 @@ module.exports = async (ctx) => { list: '.mainleft_box li', }, url: 'https://gs.bjtu.edu.cn/cms/zszt/item/?tag=1', - name: '招生 - 北京交通大学研究生院' + name: '招生 - 北京交通大学研究生院', }, noti: { selector: { list: '.tab-content li', }, url: 'https://gs.bjtu.edu.cn/cms/item/?tag=2', - name: '通知公告 - 北京交通大学研究生院' + name: '通知公告 - 北京交通大学研究生院', }, news: { selector: { list: '.tab-content li', }, url: 'https://gs.bjtu.edu.cn/cms/item/?tag=3', - name: '新闻动态 - 北京交通大学研究生院' + name: '新闻动态 - 北京交通大学研究生院', }, zsxc: { selector: { list: '.tab-content li', }, url: 'https://gs.bjtu.edu.cn/cms/item/?tag=4', - name: '招生宣传 - 北京交通大学研究生院' + name: '招生宣传 - 北京交通大学研究生院', }, py: { selector: { list: '.tab-content li', }, url: 'https://gs.bjtu.edu.cn/cms/item/?tag=5', - name: '培养 - 北京交通大学研究生院' + name: '培养 - 北京交通大学研究生院', }, xw: { selector: { list: '.tab-content li', }, url: 'https://gs.bjtu.edu.cn/cms/item/?tag=7', - name: '学位 - 北京交通大学研究生院' + name: '学位 - 北京交通大学研究生院', }, ygbtzgg: { selector: { list: '.tab-content li', }, url: 'https://gs.bjtu.edu.cn/cms/item/?tag=9', - name: '通知公告 - 研工部 - 北京交通大学研究生院' + name: '通知公告 - 研工部 - 北京交通大学研究生院', }, ygbnews: { selector: { list: '.tab-content li', }, url: 'https://gs.bjtu.edu.cn/cms/item/?tag=10', - name: '新闻动态 - 研工部 - 北京交通大学研究生院' + name: '新闻动态 - 研工部 - 北京交通大学研究生院', }, all: { selector: { list: '.tab-content li', }, url: 'https://gs.bjtu.edu.cn/cms/item/?tag=12', - name: '所有文章 - 北京交通大学研究生院' + name: '所有文章 - 北京交通大学研究生院', }, bszs: { selector: { list: '.mainleft_box li', }, url: 'https://gs.bjtu.edu.cn/cms/zszt/item/?cat=2', - name: '博士招生 - 北京交通大学研究生院' + name: '博士招生 - 北京交通大学研究生院', }, sszs: { selector: { list: '.mainleft_box li', }, url: 'https://gs.bjtu.edu.cn/cms/zszt/item/?cat=3', - name: '硕士招生 - 北京交通大学研究生院' + name: '硕士招生 - 北京交通大学研究生院', }, zsjz: { selector: { list: '.mainleft_box li', }, url: 'https://gs.bjtu.edu.cn/cms/zszt/item/?cat=4', - name: '招生简章 - 北京交通大学研究生院' + name: '招生简章 - 北京交通大学研究生院', }, zcfg: { selector: { list: '.mainleft_box li', }, url: 'https://gs.bjtu.edu.cn/cms/zszt/item/?cat=5', - name: '政策法规 - 北京交通大学研究生院' + name: '政策法规 - 北京交通大学研究生院', }, }; @@ -117,11 +117,14 @@ module.exports = async (ctx) => { list .map((index, item) => { item = $(item); - const date = new Date(Date.parse(item.find('li span').text().slice(1, 11).replace(/-/g, "/"))); + const date = new Date(Date.parse(item.find('li span').text().slice(1, 11).replace(/-/g, '/'))); const bj_date = date.getTime() / 1000 + 8 * 60 * 60; - const title = item.find('li a').text().replace(/\[.*?\]/g, ''); + const title = item + .find('li a') + .text() + .replace(/\[.*?\]/g, ''); return { title: title, description: title, link: item.find('li a').attr('href'), pubDate: new Date(parseInt(bj_date) * 1000) }; }) .get(), }; -}; \ No newline at end of file +}; diff --git a/lib/routes/zhihu/zhuanlan.js b/lib/routes/zhihu/zhuanlan.js index cf7e009771..9deb1e7adf 100644 --- a/lib/routes/zhihu/zhuanlan.js +++ b/lib/routes/zhihu/zhuanlan.js @@ -16,7 +16,7 @@ module.exports = async (ctx) => { // 知乎专栏链接存在两种格式, 一种以 'zhuanlan.' 开头, 另一种新增的以 'c_' 结尾 let url = `https://zhuanlan.zhihu.com/${id}`; - if (id.search("c_") === 0) { + if (id.search('c_') === 0) { url = `https://www.zhihu.com/column/${id}`; } @@ -58,8 +58,7 @@ module.exports = async (ctx) => { // 判断是否存在视频简介 if (item.description) { description = `${item.description}

视频内容请跳转至原页面观看`; - } - else { + } else { description = `视频内容请跳转至原页面观看`; } }