From 5b7b2f449a61ed8c8f4bfbc174c75dc90bdb4757 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sat, 2 Apr 2022 15:41:31 +0000 Subject: [PATCH] style: auto format --- docs/multimedia.md | 12 +++--- lib/v2/mtime/news.js | 96 +++++++++++++++++++++---------------------- lib/v2/mtime/radar.js | 2 +- 3 files changed, 55 insertions(+), 55 deletions(-) diff --git a/docs/multimedia.md b/docs/multimedia.md index 2377082dd..cecbc5403 100644 --- a/docs/multimedia.md +++ b/docs/multimedia.md @@ -1328,6 +1328,12 @@ JavDB 有多个备用域名,本路由默认使用永久域名 +## 时光网 + +### 资讯 + + + ## 腾讯视频 ### 播放列表 @@ -1496,9 +1502,3 @@ Tiny Tiny RSS 会给所有 iframe 元素添加 `sandbox="allow-scripts"` 属性 ### 综艺 - -## 时光网 - -### 资讯 - - diff --git a/lib/v2/mtime/news.js b/lib/v2/mtime/news.js index f241736f5..e939db6b8 100644 --- a/lib/v2/mtime/news.js +++ b/lib/v2/mtime/news.js @@ -1,48 +1,48 @@ -const got = require('@/utils/got'); -const cheerio = require('cheerio'); -const timezone = require('@/utils/timezone'); -const { parseDate } = require('@/utils/parse-date'); - -module.exports = async (ctx) => { - const link = 'http://news.mtime.com/'; - const response = await got({ - method: 'get', - url: link, - }); - const $ = cheerio.load(response.data); - const list = $('ul.left-cont.fix li') - .map((_, item) => { - item = $(item); - return { - title: item.find('h4 a').text(), - link: item.find('h4 a').attr('href'), - }; - }) - .get(); - - const items = await Promise.all( - list.map((item) => - ctx.cache.tryGet(item.link, async () => { - const detailResponse = await got({ - method: 'get', - url: item.link, - }); - const content = cheerio.load(detailResponse.data); - - content('.DRE-subject-wrapper').remove(); - - item.author = content('.editor').text().replace('编辑:', ''); - item.description = content('.body').first().html(); - item.pubDate = timezone(parseDate(content('.userCreateTime').text()), 8); - - return item; - }) - ) - ); - - ctx.state.data = { - title: 'Mtime时光网 - 资讯', - link, - item: items, - }; -}; +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const timezone = require('@/utils/timezone'); +const { parseDate } = require('@/utils/parse-date'); + +module.exports = async (ctx) => { + const link = 'http://news.mtime.com/'; + const response = await got({ + method: 'get', + url: link, + }); + const $ = cheerio.load(response.data); + const list = $('ul.left-cont.fix li') + .map((_, item) => { + item = $(item); + return { + title: item.find('h4 a').text(), + link: item.find('h4 a').attr('href'), + }; + }) + .get(); + + const items = await Promise.all( + list.map((item) => + ctx.cache.tryGet(item.link, async () => { + const detailResponse = await got({ + method: 'get', + url: item.link, + }); + const content = cheerio.load(detailResponse.data); + + content('.DRE-subject-wrapper').remove(); + + item.author = content('.editor').text().replace('编辑:', ''); + item.description = content('.body').first().html(); + item.pubDate = timezone(parseDate(content('.userCreateTime').text()), 8); + + return item; + }) + ) + ); + + ctx.state.data = { + title: 'Mtime时光网 - 资讯', + link, + item: items, + }; +}; diff --git a/lib/v2/mtime/radar.js b/lib/v2/mtime/radar.js index 988825ee9..113c4feff 100644 --- a/lib/v2/mtime/radar.js +++ b/lib/v2/mtime/radar.js @@ -1,7 +1,7 @@ module.exports = { 'mtime.com': { _name: '时光网', - 'news': [ + news: [ { title: '资讯', docs: 'https://docs.rsshub.app/multimedia.html#shi-guang-wang',