hash
stringlengths
40
40
date
stringdate
2018-04-19 20:42:56
2025-03-25 18:01:26
author
stringlengths
1
23
commit_message
stringlengths
9
121
is_merge
bool
1 class
masked_commit_message
stringlengths
3
111
type
stringclasses
10 values
git_diff
stringlengths
108
2.8M
064dbd3e072a7a6bf453a495f2b6250ff7b3bf90
2020-09-21 01:46:39
GitHub Action
style: auto format
false
auto format
style
diff --git a/docs/game.md b/docs/game.md index fcbc1d0f92cb1e..7314c8d2ef2cb3 100644 --- a/docs/game.md +++ b/docs/game.md @@ -15,7 +15,7 @@ pageClass: routes <Route author="sinchang jacky2001114 HenryQW" example="/3dm/detroitbecomehuman/news" path="/3dm/:name/:type" :paramsDesc="['游戏的名字, 可以在专题页的 url 中找到', '资讯类型']"> | 新闻 | 攻略 | 下载资源 | 区块链快讯 | -|------|------|----------|------------| +| ---- | ---- | -------- | ---------- | | news | gl | resource | blockchain | </Route> @@ -85,19 +85,19 @@ pageClass: routes 支持的主机平台: | PS 4 | Xbox One | Switch | PC | Wii U | 3DS | PS Vita | iOS | -|------|----------|--------|----|-------|-----|---------|-----| +| ---- | -------- | ------ | -- | ----- | --- | ------- | --- | | ps4 | xboxone | switch | pc | wii-u | 3ds | vita | ios | 发行类型,默认为 `new`: | 新游发行 | 即将发行 | 全部 | -|----------|----------|------| +| -------- | -------- | ---- | | new | coming | all | 排序类型,默认为`date`: | 日期 | Metacritic 评分 | 用户评分 | -|------|-----------------|-----------| +| ---- | --------------- | --------- | | date | metascore | userscore | </Route> @@ -190,7 +190,7 @@ pageClass: routes <Route author="kookxiang" example="/socialclub/events/GTAV" path="/socialclub/events/:game?" :paramsDesc="['游戏代码(默认所有)']"> | 游戏代码 | 游戏名称 | -|----------|----------| +| -------- | ------------ | | GTAV | 侠盗猎车手 5 | | RDR2 | 荒野大镖客 2 | @@ -237,7 +237,7 @@ Example: `https://store.steampowered.com/search/?specials=1&term=atelier` 中的 <Route author="hoilc" example="/taptap/topic/142793/official" path="/taptap/topic/:id/:label?" :paramsDesc="['游戏ID, 游戏主页URL中获取', '论坛版块ID, 默认显示所有帖子, 论坛版块URL中`group_label_id`参数,特别的有']"/> | 全部 | 精华 | 官方 | -|------|-------|----------| +| ---- | ----- | -------- | | all | elite | official | ### 游戏更新 @@ -249,7 +249,7 @@ Example: `https://store.steampowered.com/search/?specials=1&term=atelier` 中的 <Route author="hoilc" example="/taptap/review/142793/hot" path="/taptap/review/:id/:order?" :paramsDesc="['游戏ID, 游戏主页URL中获取', '排序方式, 空为默认排序, 可选如下']"/> | 最新 | 最热 | 游戏时长 | -|--------|------|----------| +| ------ | ---- | -------- | | update | hot | spent | ## 二柄 APP @@ -279,7 +279,7 @@ Example: `https://store.steampowered.com/search/?specials=1&term=atelier` 中的 <Route author="sintak" example="/gouhuo/news/switch" path="/gouhuo/news/:category" :paramsDesc="['资讯类型']"> | 精选 | 海外 | 原创 | PS4 | Xboxone | PC | Switch | 掌机 | 手游 | 新闻 | 评测 | 文化 | 视频 | 音频 | 折扣 | -|------------|----------|---------|-----|---------|----|--------|----------|------------|------|--------|---------|-------|-------|----------| +| ---------- | -------- | ------- | --- | ------- | -- | ------ | -------- | ---------- | ---- | ------ | ------- | ----- | ----- | -------- | | choiceness | overseas | orignal | ps4 | xboxone | pc | switch | handheld | mobilegame | news | review | culture | video | audio | discount | </Route> @@ -305,11 +305,11 @@ Example: `https://store.steampowered.com/search/?specials=1&term=atelier` 中的 <Route author="qwertyuiop6" example="/lfsyd/1" path="/lfsyd/:typecode" :paramsDesc="['订阅分区类型']"> | 主页资讯 | 炉石传说 | 万智牌 | 昆特牌 | 游戏王 | 电子游戏 | 手机游戏 | 桌面游戏 | -|----------|----------|--------|--------|--------|----------|----------|----------| +| -------- | -------- | ------ | ------ | ------ | -------- | -------- | -------- | | 1 | 2 | 3 | 14 | 16 | 4 | 22 | 9 | | 影之诗 | Artifact | 玩家杂谈 | 营地电台 | 2047 | 魂武 | -|--------|----------|----------|----------|------|------| +| ------ | -------- | -------- | -------- | ---- | ---- | | 17 | 67 | 21 | 5 | 62 | 68 | </Route> @@ -321,7 +321,7 @@ Example: `https://store.steampowered.com/search/?specials=1&term=atelier` 中的 <Route author="deepred5" example="/mihoyo/bh2/gach" path="/mihoyo/bh2/:type" :paramsDesc="['公告种类']"> | 最新公告 | 版本信息 | 祈愿信息 | 活动介绍 | -|----------|----------|----------|----------| +| -------- | -------- | -------- | -------- | | new | version | gach | event | </Route> @@ -331,7 +331,7 @@ Example: `https://store.steampowered.com/search/?specials=1&term=atelier` 中的 <Route author="deepred5 nczitzk" example="/mihoyo/bh3/latest" path="/mihoyo/bh3/:type" :paramsDesc="['公告种类']"> | 最新 | 动态 | 公告 | 活动 | 补给 | -|--------|------|--------|----------|----------| +| ------ | ---- | ------ | -------- | -------- | | latest | news | notice | activity | strategy | </Route> @@ -375,7 +375,7 @@ Example: `https://store.steampowered.com/search/?specials=1&term=atelier` 中的 <Route author="MyFaith" example="/xiaoheihe/discount/pc" path="xiaoheihe/discount/:platform?" :paramsDesc="['平台, 默认为Steam']"> | Steam | PlatStation4 | Switch | -|-------|--------------|--------| +| ----- | ------------ | ------ | | pc | ps4 | switch | </Route> @@ -397,7 +397,7 @@ Example: `https://store.steampowered.com/search/?specials=1&term=atelier` 中的 <Route author="LogicJake" example="/gamersky/ent/ymfl" path="/gamersky/ent/:category" :paramsDesc="['分类类型']"> | 趣囧时间 | 游民影院 | 游观天下 | 壁纸图库 | 游民盘点 | 游民福利 | -|----------|----------|----------|----------|----------|----------| +| -------- | -------- | -------- | -------- | -------- | -------- | | qysj | ymyy | ygtx | bztk | ympd | ymfl | </Route> @@ -409,7 +409,7 @@ Example: `https://store.steampowered.com/search/?specials=1&term=atelier` 中的 <Route author="LogicJake" example="/yxdzqb/hot_chinese" path="/yxdzqb/:type" :paramsDesc="['折扣类型']"> | Steam 最新折扣 | Steam 热门游戏折扣 | Steam 热门中文游戏折扣 | Steam 历史低价 | Steam 中文游戏历史低价 | -|----------------|--------------------|------------------------|----------------|------------------------| +| -------------- | ------------------ | ---------------------- | -------------- | ---------------------- | | new | hot | hot_chinese | low | low_chinese | </Route> @@ -435,7 +435,7 @@ Example: `https://store.steampowered.com/search/?specials=1&term=atelier` 中的 <Route author="LightStrawberry" example="/yystv/category/recommend" path="/yystv/category/:category" :paramsDesc="['专栏类型']"> | 推游 | 游戏史 | 大事件 | 文化 | 趣闻 | 经典回顾 | -|-----------|---------|--------|---------|------|----------| +| --------- | ------- | ------ | ------- | ---- | -------- | | recommend | history | big | culture | news | retro | </Route> @@ -453,7 +453,7 @@ Example: `https://store.steampowered.com/search/?specials=1&term=atelier` 中的 <Route author="Kiotlin" example="/ff14/ff14_zh/news" path="/ff14/ff14_zh/:type" :paramsDesc="['分类名']"/> | 新闻 | 公告 | 活动 | 广告 | 所有 | -|------|----------|--------|-----------|------| +| ---- | -------- | ------ | --------- | ---- | | news | announce | events | advertise | all | ## きららファンタジア|奇拉拉幻想曲
5a3222081d3aa2a48399ea7538e336a1f2097970
2019-06-05 11:50:17
junfengP
fix: say花火路由时间错误 (#2327)
false
say花火路由时间错误 (#2327)
fix
diff --git a/lib/routes/galgame/sayhuahuo.js b/lib/routes/galgame/sayhuahuo.js index 9c960287ede099..6acd7cd87e0e76 100644 --- a/lib/routes/galgame/sayhuahuo.js +++ b/lib/routes/galgame/sayhuahuo.js @@ -6,7 +6,7 @@ module.exports = async (ctx) => { url: 'https://index.say-huahuo.com/vn.json', }); - const data = eval(res.body).reverse(); + const data = JSON.parse(res.body).reverse(); ctx.state.data = { title: 'galgame汉化硬盘galgame资源下载-花火学园论坛', @@ -15,7 +15,7 @@ module.exports = async (ctx) => { item: data.map((item) => ({ title: item.title, description: `<img referrerpolicy="no-referrer" src="${item.img}">`, - pubDate: new Date(item.date * 1000).toUTCString(), + pubDate: new Date(parseInt(item.date.substr(0, 4)), parseInt(item.date.substr(4, 2)), parseInt(item.date.substr(6, 2))).toUTCString(), link: item.url, })), };
49703b3513ed9e1fea09d112f07754045f805576
2019-11-25 12:05:41
dependabot-preview[bot]
chore(deps-dev): bump eslint from 6.7.0 to 6.7.1
false
bump eslint from 6.7.0 to 6.7.1
chore
diff --git a/package.json b/package.json index f53cf7d5d26baf..f0a63c491d8bd7 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "@vuepress/plugin-pwa": "1.2.0", "cross-env": "6.0.3", "entities": "2.0.0", - "eslint": "6.7.0", + "eslint": "6.7.1", "eslint-config-prettier": "6.7.0", "eslint-plugin-prettier": "3.1.1", "jest": "24.9.0", diff --git a/yarn.lock b/yarn.lock index 6e1770f751e575..3348443e6645cb 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4131,10 +4131,10 @@ eslint-visitor-keys@^1.1.0: resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-1.1.0.tgz#e2a82cea84ff246ad6fb57f9bde5b46621459ec2" integrity sha512-8y9YjtM1JBJU/A9Kc+SbaOV4y29sSWckBwMHa+FGtVj5gN/sbnKDf6xJUl+8g7FAij9LVaP8C24DUiH/f/2Z9A== [email protected]: - version "6.7.0" - resolved "https://registry.yarnpkg.com/eslint/-/eslint-6.7.0.tgz#766162e383b236e61d873697f82c3a3e41392020" - integrity sha512-dQpj+PaHKHfXHQ2Imcw5d853PTvkUGbHk/MR68KQUl98EgKDCdh4vLRH1ZxhqeQjQFJeg8fgN0UwmNhN3l8dDQ== [email protected]: + version "6.7.1" + resolved "https://registry.yarnpkg.com/eslint/-/eslint-6.7.1.tgz#269ccccec3ef60ab32358a44d147ac209154b919" + integrity sha512-UWzBS79pNcsDSxgxbdjkmzn/B6BhsXMfUaOHnNwyE8nD+Q6pyT96ow2MccVayUTV4yMid4qLhMiQaywctRkBLA== dependencies: "@babel/code-frame" "^7.0.0" ajv "^6.10.0"
b7df26724ec2fbf814f109a5fbac5803a944d42e
2022-03-10 22:20:57
Ethan Shen
feat(route): add Foresight News article (#9295)
false
add Foresight News article (#9295)
feat
diff --git a/docs/new-media.md b/docs/new-media.md index 1a40ad9460ff9e..e3eb2909461eb3 100644 --- a/docs/new-media.md +++ b/docs/new-media.md @@ -473,6 +473,18 @@ Country <Route author="nczitzk" example="/foresightnews" path="/foresightnews"/> +### 文章 + +<Route author="nczitzk" example="/foresightnews/article" path="/foresightnews/article"> + +::: tip 提示 + +**文章** 来自 **首页** 时间流,并筛除 **首页** 时间流中的 **快讯** 获得,所以 `limit` 参数不能按预期返回指定数目的文章。 + +::: + +</Route> + ### 快讯 <Route author="nczitzk" example="/foresightnews/news" path="/foresightnews/news"/> diff --git a/lib/v2/foresightnews/index.js b/lib/v2/foresightnews/index.js index 10a5cc4c12e90e..d1d7826247d39d 100644 --- a/lib/v2/foresightnews/index.js +++ b/lib/v2/foresightnews/index.js @@ -3,10 +3,14 @@ const cheerio = require('cheerio'); const { parseDate } = require('@/utils/parse-date'); const categories = { - article: { + '': { id: 'feed', title: '首页', }, + article: { + id: 'feed', + title: '文章', + }, news: { id: 'news', title: '快讯', @@ -18,7 +22,7 @@ const categories = { }; module.exports = async (ctx) => { - const category = ctx.params.category ?? 'article'; + const category = ctx.params.category ?? ''; const id = ctx.params.id ?? '1'; const rootUrl = 'https://foresightnews.pro'; @@ -51,6 +55,10 @@ module.exports = async (ctx) => { } ); + if (category === 'article') { + items = items.filter((item) => item.type === 'article'); + } + items = await Promise.all( items.map((item) => ctx.cache.tryGet(item.link, async () => { diff --git a/lib/v2/foresightnews/maintainer.js b/lib/v2/foresightnews/maintainer.js index 45a92931be219a..41ccd63927bffe 100644 --- a/lib/v2/foresightnews/maintainer.js +++ b/lib/v2/foresightnews/maintainer.js @@ -1,4 +1,5 @@ module.exports = { + '/': ['nczitzk'], '/article': ['nczitzk'], '/column/:id': ['nczitzk'], '/news': ['nczitzk'], diff --git a/lib/v2/foresightnews/radar.js b/lib/v2/foresightnews/radar.js index 49f0da12519c72..0c52649508b35e 100644 --- a/lib/v2/foresightnews/radar.js +++ b/lib/v2/foresightnews/radar.js @@ -6,6 +6,12 @@ module.exports = { title: '首页', docs: 'https://docs.rsshub.app/new-media.html#foresight-news-shou-ye', source: ['/article', '/'], + target: '/foresightnews', + }, + { + title: '文章', + docs: 'https://docs.rsshub.app/new-media.html#foresight-news-wen-zhang', + source: ['/article', '/'], target: '/foresightnews/article', }, {
e000ae81eb88476e5f2f4ecf8dc07f9636d37c33
2023-10-17 21:36:32
AtlanCI
fix(route/gocn): 修复Gocn站点RSS记录 (#13524)
false
修复Gocn站点RSS记录 (#13524)
fix
diff --git a/lib/v2/gocn/jobs.js b/lib/v2/gocn/jobs.js index 4faeeb68c1f43e..8f9b384b3410fa 100644 --- a/lib/v2/gocn/jobs.js +++ b/lib/v2/gocn/jobs.js @@ -1,23 +1,28 @@ const got = require('@/utils/got'); -const util = require('./util'); +const { parseDate } = require('@/utils/parse-date'); +const { renderHTML } = require('./utils'); module.exports = async (ctx) => { - const base_url = 'https://gocn.vip/topics'; - const api_url = 'https://gocn.vip/apiv3/topic/jobs?currentPage=1&grade=new'; + const api_url = 'https://gocn.vip/api/files?spaceGuid=Gd7OHl&currentPage=1&sort=1'; + const base_url = 'https://gocn.vip/c/3lQ6GbD5ny/s/Gd7OHl'; + const job_url = 'https://gocn.vip/c/3lQ6GbD5ny'; const response = await got({ url: api_url, - headers: { - Referer: base_url, - }, }); - const list = response.data.data.list; + const items = response.data.data.list.map((item) => ({ + title: item.name, + link: `${job_url}/s/${item.spaceGuid}/d/${item.guid}`, + description: renderHTML(JSON.parse(item.content)), + pubDate: parseDate(item.ctime, 'X'), + author: item.nickname, + })); ctx.state.data = { title: `GoCN社区-招聘`, link: base_url, - description: `获取GoCN站点最新招聘`, - item: await Promise.all(list.map((item) => ctx.cache.tryGet(`${base_url}/${item.guid}`, () => util.getFeedItem(item)))), + description: `获取GoCN站点招聘`, + item: items, }; }; diff --git a/lib/v2/gocn/maintainer.js b/lib/v2/gocn/maintainer.js index 37b10046a4a6fb..514f5e5e330bcd 100644 --- a/lib/v2/gocn/maintainer.js +++ b/lib/v2/gocn/maintainer.js @@ -1,4 +1,6 @@ module.exports = { '/': ['AtlanCI', 'CcccFz'], - '/jobs': ['CcccFz'], + '/jobs': ['AtlanCI', 'CcccFz'], + '/news': ['AtlanCI'], + '/topics': ['AtlanCI', 'CcccFz'], }; diff --git a/lib/v2/gocn/news.js b/lib/v2/gocn/news.js new file mode 100644 index 00000000000000..79b0e25ea3a6a3 --- /dev/null +++ b/lib/v2/gocn/news.js @@ -0,0 +1,31 @@ +const got = require('@/utils/got'); +const { parseDate } = require('@/utils/parse-date'); +const { renderHTML } = require('./utils'); + +module.exports = async (ctx) => { + const base_url = 'https://gocn.vip/c/3lQ6GbD5ny/home'; + const article_url = 'https://gocn.vip/c/3lQ6GbD5ny'; + const api_url = 'https://gocn.vip/api/home/page'; + + const response = await got({ + url: api_url, + headers: { + Referer: base_url, + }, + }); + + const items = response.data.data.articlePageList.list.map((item) => ({ + title: item.name, + link: `${article_url}/s/${item.spaceGuid}/d/${item.guid}`, + description: renderHTML(JSON.parse(item.content)), + pubDate: parseDate(item.ctime, 'X'), + author: item.nickname, + })); + + ctx.state.data = { + title: `GoCN社区-最新动态`, + link: base_url, + description: `获取GoCN站点最新动态`, + item: items, + }; +}; diff --git a/lib/v2/gocn/radar.js b/lib/v2/gocn/radar.js index b06f033aa48d9a..3c625d107c6ea3 100644 --- a/lib/v2/gocn/radar.js +++ b/lib/v2/gocn/radar.js @@ -3,10 +3,16 @@ module.exports = { _name: 'GoCN', '.': [ { - title: '文章', + title: '最新动态', docs: 'https://docs.rsshub.app/routes/programming#GoCN', source: ['/'], - target: '/gocn', + target: '/gocn/news', + }, + { + title: '每日新闻', + docs: 'https://docs.rsshub.app/routes/programming#GoCN', + source: ['/'], + target: '/gocn/topics', }, { title: '招聘', diff --git a/lib/v2/gocn/router.js b/lib/v2/gocn/router.js index 3574e546ada605..20228ac683bba5 100644 --- a/lib/v2/gocn/router.js +++ b/lib/v2/gocn/router.js @@ -1,4 +1,6 @@ module.exports = function (router) { - router.get('/', require('./topics')); + router.get('/', require('./news')); router.get('/jobs', require('./jobs')); + router.get('/news', require('./news')); + router.get('/topics', require('./topics')); }; diff --git a/lib/v2/gocn/topics.js b/lib/v2/gocn/topics.js index 713e7b2d28e12b..85d9050d634817 100644 --- a/lib/v2/gocn/topics.js +++ b/lib/v2/gocn/topics.js @@ -1,9 +1,11 @@ const got = require('@/utils/got'); -const util = require('./util'); +const { parseDate } = require('@/utils/parse-date'); +const { renderHTML } = require('./utils'); module.exports = async (ctx) => { - const base_url = 'https://gocn.vip/topics'; - const api_url = 'https://gocn.vip/apiv3/topic/list?currentPage=1&cate2Id=0&grade=new'; + const base_url = 'https://gocn.vip/c/3lQ6GbD5ny/home'; + const article_url = 'https://gocn.vip/c/3lQ6GbD5ny'; + const api_url = 'https://gocn.vip/api/files?spaceGuid=Gd7BTB&currentPage=1&sort=1'; const response = await got({ url: api_url, @@ -12,12 +14,18 @@ module.exports = async (ctx) => { }, }); - const list = response.data.data.list; + const items = response.data.data.list.map((item) => ({ + title: item.name, + link: `${article_url}/s/${item.spaceGuid}/d/${item.guid}`, + description: renderHTML(JSON.parse(item.content)), + pubDate: parseDate(item.ctime, 'X'), + author: item.nickname, + })); ctx.state.data = { - title: `GoCN社区-文章`, + title: `GoCN社区-每日新闻`, link: base_url, - description: `获取GoCN站点最新文章`, - item: await Promise.all(list.map((item) => ctx.cache.tryGet(`${base_url}/${item.guid}`, () => util.getFeedItem(item)))), + description: `获取GoCN站点每日新闻`, + item: items, }; }; diff --git a/lib/v2/gocn/util.js b/lib/v2/gocn/util.js deleted file mode 100644 index 88ed672244d646..00000000000000 --- a/lib/v2/gocn/util.js +++ /dev/null @@ -1,17 +0,0 @@ -const got = require('@/utils/got'); -const { parseDate } = require('@/utils/parse-date'); - -async function getFeedItem(item) { - const response = await got(`https://gocn.vip/apiv3/topic/${item.guid}/info`); - - return { - link: `https://gocn.vip/topics/${item.guid}`, - title: item.title, - description: response.data.data.topic.contentHtml, - pubDate: parseDate(item.ctime, 'X'), - }; -} - -module.exports = { - getFeedItem, -}; diff --git a/lib/v2/gocn/utils.js b/lib/v2/gocn/utils.js new file mode 100644 index 00000000000000..a42d2f83599a07 --- /dev/null +++ b/lib/v2/gocn/utils.js @@ -0,0 +1,38 @@ +const elementMap = { + code_block: (element) => `<pre><code class="${element.language}">${element.children[0].text}</code></pre>`, + a: (element) => `<a href="${element.url}">${renderHTML(element.children)}</a>`, + blockquote: (element) => `<blockquote>${renderHTML(element.children)}</blockquote>`, + br: () => '<br>', + h1: (element) => `<h1>${element.children[0].text}</h1>`, + h2: (element) => `<h2>${element.children[0].text}</h2>`, + h3: (element) => `<h3>${element.children[0].text}</h3>`, + h4: (element) => `<h4>${element.children[0].text}</h4>`, + h5: (element) => `<h5>${element.children[0].text}</h5>`, + h6: (element) => `<h6>${element.children[0].text}</h6>`, + img: (element) => `<img src="${element.url}">`, + p: (element) => `<p>${renderHTML(element.children)}</p>`, + strong: (element) => `<strong>${renderHTML(element.children)}</strong>`, + ol: (element) => `<ol>${renderHTML(element.children)}</ol>`, + ul: (element) => `<ul>${renderHTML(element.children)}</ul>`, + li: (element) => `<li>${renderHTML(element.children)}</li>`, + lic: (element) => element.children[0].text, +}; + +function renderHTML(json) { + return json + .map((element) => { + const handler = elementMap[element.type]; + if (handler) { + return handler(element); + } else if (element.hasOwnProperty('text')) { + return element.text; + } else { + throw new Error(`Unknown handled type: ${element.type}, ${JSON.stringify(element)}`); + } + }) + .join(''); +} + +module.exports = { + renderHTML, +}; diff --git a/website/docs/routes/programming.md b/website/docs/routes/programming.md index f9d3bd88663b8c..e974846c2fc401 100644 --- a/website/docs/routes/programming.md +++ b/website/docs/routes/programming.md @@ -12,51 +12,51 @@ You have the option to utilize the main heading or use individual categories as topics for the path. -| **Code** | _code_ | -|-------------------------|-------------------------| +| **Code** | _code_ | +| --------------------------- | ------------------------- | | **Application Development** | _application-development_ | -| **Browsers** | _browsers_ | -| **CSS** | _css_ | -| **HTML** | _html_ | -| **JavaScript** | _javascript_ | -| **The Server Side** | _the-server-side_ | - -| **Content** | _content_ | -|-------------------------|-------------------------| -| **Community** | _community_ | -| **Content Strategy** | _content-strategy_ | -| **Writing** | _writing_ | - -| **Design** | _design_ | -|-------------------------|-------------------------| -| **Brand Identity** | _brand-identity_ | -| **Graphic Design** | _graphic-design_ | -| **Layout & Grids** | _layout-grids_ | -| **Mobile/Multidevice** | _mobile-multidevice_ | -| **Responsive Design** | _responsive-design_ | +| **Browsers** | _browsers_ | +| **CSS** | _css_ | +| **HTML** | _html_ | +| **JavaScript** | _javascript_ | +| **The Server Side** | _the-server-side_ | + +| **Content** | _content_ | +| -------------------- | ------------------ | +| **Community** | _community_ | +| **Content Strategy** | _content-strategy_ | +| **Writing** | _writing_ | + +| **Design** | _design_ | +| -------------------------- | ---------------------- | +| **Brand Identity** | _brand-identity_ | +| **Graphic Design** | _graphic-design_ | +| **Layout & Grids** | _layout-grids_ | +| **Mobile/Multidevice** | _mobile-multidevice_ | +| **Responsive Design** | _responsive-design_ | | **Typography & Web Fonts** | _typography-web-fonts_ | -| **Industry & Business** | _industry-business_ | -|-------------------------|-------------------------| -| **Business** | _business_ | -| **Career** | _career_ | -| **Industry** | _industry_ | -| **State of the Web** | _state-of-the-web_ | - -| **Process** | _process_ | -|-------------------------|-------------------------| -| **Creativity** | _creativity_ | -| **Project Management** | _project-management_ | -| **Web Strategy** | _web-strategy_ | -| **Workflow & Tools** | _workflow-tools_ | - -| **User Experience** | _user-experience_ | -|-------------------------|-------------------------| -| **Accessibility** | _accessibility_ | +| **Industry & Business** | _industry-business_ | +| ----------------------- | ------------------- | +| **Business** | _business_ | +| **Career** | _career_ | +| **Industry** | _industry_ | +| **State of the Web** | _state-of-the-web_ | + +| **Process** | _process_ | +| ---------------------- | -------------------- | +| **Creativity** | _creativity_ | +| **Project Management** | _project-management_ | +| **Web Strategy** | _web-strategy_ | +| **Workflow & Tools** | _workflow-tools_ | + +| **User Experience** | _user-experience_ | +| ---------------------------- | -------------------------- | +| **Accessibility** | _accessibility_ | | **Information Architecture** | _information-architecture_ | -| **Interaction Design** | _interaction-design_ | -| **Usability** | _usability_ | -| **User Research** | _user-research_ | +| **Interaction Design** | _interaction-design_ | +| **Usability** | _usability_ | +| **User Research** | _user-research_ | </Route> @@ -173,7 +173,7 @@ Category <Route author="Fatpandac" example="/cncf" path="/cncf/:cate?" radar="1" rssbud="1" paramsDesc={['blog by default']}> | Blog | News | Announcements | Reports | -|------|------|---------------|---------| +| ---- | ---- | ------------- | ------- | | blog | news | announcements | reports | </Route> @@ -451,13 +451,18 @@ For instance, the `/github/topics/framework/l=php&o=desc&s=stars` route will gen ## GoCN {#gocn} -### 文章 {#gocn-wen-zhang} +### 最新动态 {#gocn-zui-xin-dong-tai} -<Route author="AtlanCI CcccFz" example="/gocn" path="/gocn" radar="1" rssbud="1"/> +<Route author="AtlanCI" example="/gocn/news" path="/gocn/news" radar="1" rssbud="1"/> + +### 每日新闻 {#gocn-mei-ri-xin-wen} + +<Route author="AtlanCI CcccFz" example="/gocn/topics" path="/gocn/topics" radar="1" rssbud="1"/> ### 招聘 {#gocn-zhao-pin} -<Route author="CcccFz" example="/gocn/jobs" path="/gocn/jobs" radar="1" rssbud="1"/> +<Route author="AtlanCI CcccFz" example="/gocn/jobs" path="/gocn/jobs" radar="1" rssbud="1"/> + ## Hacker News {#hacker-news} @@ -845,41 +850,41 @@ Subscribe to the updates (threads and submission) from a paritcular Hacker News <Route author="Rjnishant530" example="/smashingmagazine/react" path="/smashingmagazine/:category?" paramsDesc={['Find in URL or Table below']} radar="1"> -| **Category** | | -|----------------------|-----------------------| -| Accessibility | accessibility | -| Best practices | best-practices | -| Business | business | -| Career | career | -| Checklists | checklists | -| CSS | css | -| Data Visualization | data-visualization | -| Design | design | -| Design Patterns | design-patterns | -| Design Systems | design-systems | -| E-Commerce | e-commerce | -| Figma | figma | -| Freebies | freebies | -| HTML | html | -| Illustrator | illustrator | -| Inspiration | inspiration | -| JavaScript | javascript | -| Mobile | mobile | -| Performance | performance | -| Privacy | privacy | -| React | react | -| Responsive Design | responsive-design | -| Round-Ups | round-ups | -| SEO | seo | -| Typography | typography | -| Tools | tools | -| UI | ui | -| Usability | usability | -| UX | ux | -| Vue | vue | -| Wallpapers | wallpapers | -| Web Design | web-design | -| Workflow | workflow | +| **Category** | | +| ------------------ | ------------------ | +| Accessibility | accessibility | +| Best practices | best-practices | +| Business | business | +| Career | career | +| Checklists | checklists | +| CSS | css | +| Data Visualization | data-visualization | +| Design | design | +| Design Patterns | design-patterns | +| Design Systems | design-systems | +| E-Commerce | e-commerce | +| Figma | figma | +| Freebies | freebies | +| HTML | html | +| Illustrator | illustrator | +| Inspiration | inspiration | +| JavaScript | javascript | +| Mobile | mobile | +| Performance | performance | +| Privacy | privacy | +| React | react | +| Responsive Design | responsive-design | +| Round-Ups | round-ups | +| SEO | seo | +| Typography | typography | +| Tools | tools | +| UI | ui | +| Usability | usability | +| UX | ux | +| Vue | vue | +| Wallpapers | wallpapers | +| Web Design | web-design | +| Workflow | workflow | </Route> @@ -1246,48 +1251,48 @@ Stay up to date on the latest React news, tutorials, resources, and more. Delive <Route author="nczitzk" example="/lianxh" path="/lianxh/:category?" paramsDesc={['分类 id,可在对应分类页 URL 中找到,默认为空,即全部']}> -| 分类 | id | -| -------------------- | -- | -| 全部 | | -| Stata 入门 | 16 | -| Stata 教程 | 17 | -| 计量专题 | 18 | -| 内生性 - 因果推断 | 19 | -| 面板数据 | 20 | -| 交乘项 - 调节 - 中介 | 21 | -| 结果输出 | 22 | -| 工具软件 | 23 | -| Stata 绘图 | 24 | -| 数据处理 | 25 | -| Stata 程序 | 26 | -| Probit-Logit | 27 | -| 时间序列 | 28 | -| 空间计量 - 网络分析 | 29 | -| Markdown-LaTeX | 30 | -| 论文写作 | 31 | -| 回归分析 | 32 | -| 其它 | 33 | -| 数据分享 | 34 | -| Stata 资源 | 35 | -| 文本分析 - 爬虫 | 36 | -| Python-R-Matlab | 37 | -| IV-GMM | 38 | -| 倍分法 DID | 39 | -| 断点回归 RDD | 40 | -| PSM-Matching | 41 | -| 合成控制法 | 42 | -| Stata 命令 | 43 | -| 专题课程 | 44 | -| 风险管理 | 45 | -| 生存分析 | 46 | -| 机器学习 | 47 | -| 分位数回归 | 48 | -| SFA-DEA - 效率分析 | 49 | -| 答疑 - 板书 | 50 | -| 论文重现 | 51 | -| 最新课程 | 52 | -| 公开课 | 53 | -| Stata33 讲 | 54 | +| 分类 | id | +| -------------------- | --- | +| 全部 | | +| Stata 入门 | 16 | +| Stata 教程 | 17 | +| 计量专题 | 18 | +| 内生性 - 因果推断 | 19 | +| 面板数据 | 20 | +| 交乘项 - 调节 - 中介 | 21 | +| 结果输出 | 22 | +| 工具软件 | 23 | +| Stata 绘图 | 24 | +| 数据处理 | 25 | +| Stata 程序 | 26 | +| Probit-Logit | 27 | +| 时间序列 | 28 | +| 空间计量 - 网络分析 | 29 | +| Markdown-LaTeX | 30 | +| 论文写作 | 31 | +| 回归分析 | 32 | +| 其它 | 33 | +| 数据分享 | 34 | +| Stata 资源 | 35 | +| 文本分析 - 爬虫 | 36 | +| Python-R-Matlab | 37 | +| IV-GMM | 38 | +| 倍分法 DID | 39 | +| 断点回归 RDD | 40 | +| PSM-Matching | 41 | +| 合成控制法 | 42 | +| Stata 命令 | 43 | +| 专题课程 | 44 | +| 风险管理 | 45 | +| 生存分析 | 46 | +| 机器学习 | 47 | +| 分位数回归 | 48 | +| SFA-DEA - 效率分析 | 49 | +| 答疑 - 板书 | 50 | +| 论文重现 | 51 | +| 最新课程 | 52 | +| 公开课 | 53 | +| Stata33 讲 | 54 | </Route>
57a44636227b53dd6c496f42fcfba0bbbb0cfc23
2020-02-20 15:44:18
dependabot-preview[bot]
chore(deps-dev): bump @vuepress/plugin-pwa from 1.3.0 to 1.3.1
false
bump @vuepress/plugin-pwa from 1.3.0 to 1.3.1
chore
diff --git a/package.json b/package.json index 092ac5cd5a83f5..7a9af0025d059a 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "@types/koa": "2.11.1", "@vuepress/plugin-back-to-top": "1.3.0", "@vuepress/plugin-google-analytics": "1.3.0", - "@vuepress/plugin-pwa": "1.3.0", + "@vuepress/plugin-pwa": "1.3.1", "cross-env": "7.0.0", "entities": "2.0.0", "eslint": "6.8.0", diff --git a/yarn.lock b/yarn.lock index c0c8147a7426e3..4188adc5a63860 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1635,12 +1635,12 @@ dependencies: nprogress "^0.2.0" -"@vuepress/[email protected]": - version "1.3.0" - resolved "https://registry.yarnpkg.com/@vuepress/plugin-pwa/-/plugin-pwa-1.3.0.tgz#83427432cb2dcfd6bbd3e09c10657fc9d2b7fa27" - integrity sha512-IUXCwXYJMnoM4hXqeB4JapFoH/eRDdis4UMx2GR3ahWPTjISgUbE3XF0FgUKre8PU2i/h4pOyKorLmN881TDnQ== +"@vuepress/[email protected]": + version "1.3.1" + resolved "https://registry.yarnpkg.com/@vuepress/plugin-pwa/-/plugin-pwa-1.3.1.tgz#4049273bb9161e15546ce8a2843eda1089614daa" + integrity sha512-ExudmW8w4jY+lNjTteYeEFNajLPr5dhiSyokYIcF3mX64xHwLJqqgHDUXZKh6ELTAZ6tUmuAMdFj76fjRaqJDw== dependencies: - "@vuepress/shared-utils" "^1.3.0" + "@vuepress/shared-utils" "^1.3.1" register-service-worker "^1.5.2" workbox-build "^4.3.1" @@ -1656,10 +1656,10 @@ resolved "https://registry.yarnpkg.com/@vuepress/plugin-search/-/plugin-search-1.3.0.tgz#ec3619a2d70696f7f91575121f4b7409ba229d07" integrity sha512-buoQ6gQ2MLbLQ7Nhg5KJWPzKo7NtvdK/e6Fo1ig/kbOG5HyYKHCyqLjbQ/ZqT+fGbaSeEjH3DaVYTNx55GRX5A== -"@vuepress/shared-utils@^1.3.0": - version "1.3.0" - resolved "https://registry.yarnpkg.com/@vuepress/shared-utils/-/shared-utils-1.3.0.tgz#2c9afccaed0bcdf4ceb1c02becdeac61da6dbec2" - integrity sha512-n1AFgt8SiMDdc5aIj5yOqS3E6+dAZ+9tPw6qf1mBiqvdZzwaUtlydvXqVkskrwUo18znLrUr55VYwubMOaxFnQ== +"@vuepress/shared-utils@^1.3.0", "@vuepress/shared-utils@^1.3.1": + version "1.3.1" + resolved "https://registry.yarnpkg.com/@vuepress/shared-utils/-/shared-utils-1.3.1.tgz#930038dfadf28f39147e6cb781e9930259995a7e" + integrity sha512-MlIAlnptjDC9+l0SJKW6BpkuwtxfKDzq4Rmag75RdyIqkkNv4EsCXZ8Y3HSuzENWFBwoD31jLC+nCZ3hULcvSg== dependencies: chalk "^2.3.2" diacritics "^1.3.0"
ea6568c329c4779eb689386029c78718eb5bdd87
2021-11-27 12:41:57
Ethan Shen
feat(route): add fashion network news (#7602)
false
add fashion network news (#7602)
feat
diff --git a/docs/en/new-media.md b/docs/en/new-media.md index c6edf15c299867..e16ae2b774a3e4 100644 --- a/docs/en/new-media.md +++ b/docs/en/new-media.md @@ -221,6 +221,74 @@ Compared to the official one, the RSS feed generated by RSSHub not only has more </RouteEn> +## Fashion Network + +### News + +<RouteEn author="nczitzk" example="/fashionnetwork/news/5,6/15,112" path="/fashionnetwork/news/:sectors?/:categories?/:country?" :paramsDesc="['Sectors, see below, `all` by default', 'Categories, see below, `all` by default', 'Country, see below, `ww` as Worldwide by default']"> + +Sectoies + +Fashion 1 + +| Ready-to-wear | Accessories | Footwear | Sports | Denim | Lingerie | Swimwear | Eyewear | Bridal wear | Textile | Miscellaneous | +| ------------- | ----------- | -------- | ------ | ----- | -------- | -------- | ------- | ----------- | ------- | ------------- | +| 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 31 | + +Luxury 2 + +| Ready-to-wear | Accessories | Footwear | Watches | Jewellery | Miscellaneous | +| ------------- | ----------- | -------- | ------- | --------- | ------------- | +| 15 | 16 | 17 | 18 | 19 | 32 | + +Beauty 3 + +| Perfume | Cosmetics | Aesthetics | Wellness | Hair | Miscellaneous | +| ------- | --------- | ---------- | -------- | ---- | ------------- | +| 21 | 22 | 23 | 24 | 33 | | + +Lifestyle 4 + +| Home decor | Tableware | Hospitality | Fine foods | Tourism | Miscellaneous | +| ---------- | --------- | ----------- | ---------- | ------- | ------------- | +| 25 | 26 | 27 | 28 | 29 | 34 | + +Others 30 + +Category + +| Retail | Business | Industry | Trade shows | +| ------ | -------- | -------- | ----------- | +| 15 | 112 | 5 | 12 | + +| Innovations | Collection | Catwalks | Design | +| ----------- | ---------- | -------- | ------ | +| 113 | 114 | 60 | 70 | + +| Media | Campaigns | People | Events | Appointments | +| ----- | --------- | ------ | ------ | ------------ | +| 50 | 115 | 80 | 90 | 95 | + +Country + +| Latin America | Brazil | China | France | +| ------------- | ------ | ----- | ------ | +| pe | br | cn | fr | + +| Germany | India | Italy | Japan | +| ------- | ----- | ----- | ----- | +| de | in | it | jp | + +| Mexico | Portugal | Russia | Spain | +| ------ | -------- | ------ | ----- | +| mx | pt | ru | es | + +| Turkey | United Kingdom | USA | Worldwide | +| ------ | -------------- | --- | --------- | +| tr | uk | us | ww | + +</RouteEn> + ## Fermilab ### News diff --git a/docs/new-media.md b/docs/new-media.md index b2e1034807ef1e..0dc10836c4d0a9 100644 --- a/docs/new-media.md +++ b/docs/new-media.md @@ -306,6 +306,74 @@ pageClass: routes </Route> +## Fashion Network + +### News + +<Route author="nczitzk" example="/fashionnetwork/news/5,6/15,112" path="/fashionnetwork/news/:sectors?/:categories?/:country?" :paramsDesc="['分区,见下表,默认为 `all`', '分类,见下表,默认为 `all`', '国家,见下表,默认为 `ww`']"> + +Sectoies + +Fashion 1 + +| Ready-to-wear | Accessories | Footwear | Sports | Denim | Lingerie | Swimwear | Eyewear | Bridal wear | Textile | Miscellaneous | +| ------------- | ----------- | -------- | ------ | ----- | -------- | -------- | ------- | ----------- | ------- | ------------- | +| 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 31 | + +Luxury 2 + +| Ready-to-wear | Accessories | Footwear | Watches | Jewellery | Miscellaneous | +| ------------- | ----------- | -------- | ------- | --------- | ------------- | +| 15 | 16 | 17 | 18 | 19 | 32 | + +Beauty 3 + +| Perfume | Cosmetics | Aesthetics | Wellness | Hair | Miscellaneous | +| ------- | --------- | ---------- | -------- | ---- | ------------- | +| 21 | 22 | 23 | 24 | 33 | | + +Lifestyle 4 + +| Home decor | Tableware | Hospitality | Fine foods | Tourism | Miscellaneous | +| ---------- | --------- | ----------- | ---------- | ------- | ------------- | +| 25 | 26 | 27 | 28 | 29 | 34 | + +Others 30 + +Category + +| Retail | Business | Industry | Trade shows | +| ------ | -------- | -------- | ----------- | +| 15 | 112 | 5 | 12 | + +| Innovations | Collection | Catwalks | Design | +| ----------- | ---------- | -------- | ------ | +| 113 | 114 | 60 | 70 | + +| Media | Campaigns | People | Events | Appointments | +| ----- | --------- | ------ | ------ | ------------ | +| 50 | 115 | 80 | 90 | 95 | + +Country + +| Latin America | Brazil | China | France | +| ------------- | ------ | ----- | ------ | +| pe | br | cn | fr | + +| Germany | India | Italy | Japan | +| ------- | ----- | ----- | ----- | +| de | in | it | jp | + +| Mexico | Portugal | Russia | Spain | +| ------ | -------- | ------ | ----- | +| mx | pt | ru | es | + +| Turkey | United Kingdom | USA | Worldwide | +| ------ | -------------- | --- | --------- | +| tr | uk | us | ww | + +</Route> + ## Focus Taiwan ### Category diff --git a/lib/router.js b/lib/router.js index 02bbb17da2b40a..125bfe61ab86a8 100644 --- a/lib/router.js +++ b/lib/router.js @@ -4220,4 +4220,7 @@ router.get('/rss3/blog', require('./routes/rss3/blog')); // 星球日报 router.get('/odaily/activity', require('./routes/odaily/activity')); +// Fashion Network +router.get('/fashionnetwork/news/:sectors?/:categories?/:language?', require('./routes/fashionnetwork/news.js')); + module.exports = router; diff --git a/lib/routes/fashionnetwork/news.js b/lib/routes/fashionnetwork/news.js new file mode 100644 index 00000000000000..c26bc54c9a525b --- /dev/null +++ b/lib/routes/fashionnetwork/news.js @@ -0,0 +1,70 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + +module.exports = async (ctx) => { + const country = ctx.params.country || 'ww'; + let sectors = ctx.params.sectors || ''; + let categories = ctx.params.categories || ''; + + sectors = sectors === 'all' ? '' : sectors; + categories = categories === 'all' ? '' : categories; + + const sectorsUrl = sectors ? 'sectors%5B%5D=' + sectors.split(',').join('&sectors%5B%5D=') : ''; + const categoriesUrl = categories ? 'categs%5B%5D=' + categories.split(',').join('&categs%5B%5D=') : ''; + + const rootUrl = `https://${country}.fashionnetwork.com`; + const currentUrl = `${rootUrl}/news/s.jsonp?${sectorsUrl}&${categoriesUrl}`; + const response = await got({ + method: 'get', + url: currentUrl, + }); + + const $ = cheerio.load( + unescape(response.data.match(/"html":"(.*)","relatedUrl"/)[1].replace(/\\(u[0-9a-fA-F]{4})/gm, '%$1')) + .replace(/\\n/g, '') + .replace(/\\\//g, '/') + ); + + const list = $('.list-ui__title') + .slice(0, 10) + .map((_, item) => { + item = $(item); + return { + title: item.text(), + link: item.attr('href'), + pubDate: Date.parse(item.parent().find('time').attr('datetime')), + }; + }) + .get(); + + const items = await Promise.all( + list.map( + async (item) => + await ctx.cache.tryGet(item.link, async () => { + const detailResponse = await got({ + method: 'get', + url: item.link, + }); + const content = cheerio.load(detailResponse.data); + + content('.newsTitle, .ads').remove(); + + item.description = content('div[itemprop="text"]').html(); + + return item; + }) + ) + ); + + const labels = []; + + $('.filter__label').each(function () { + labels.push($(this).text()); + }); + + ctx.state.data = { + title: `${labels.join(',') || 'All'} - FashionNetwork`, + link: `${rootUrl}/news/s?${sectorsUrl}&${categoriesUrl}`, + item: items, + }; +};
e66df707f93d15b3e246f08a805e9ead13fc28cb
2023-04-08 18:46:22
Willy (Yang Wentao)
fix(route): 修复 newrank 列举公众号文章的 URL; 增加缺少的 n-token 参数; (#12262)
false
修复 newrank 列举公众号文章的 URL; 增加缺少的 n-token 参数; (#12262)
fix
diff --git a/docs/social-media.md b/docs/social-media.md index 233c96d116eff1..a174ba4e50683b 100644 --- a/docs/social-media.md +++ b/docs/social-media.md @@ -1615,11 +1615,11 @@ rule ### 微信公众号 -<Route author="lessmoe" example="/newrank/wechat/chijiread" path="/newrank/wechat/:wxid" :paramsDesc="['微信号,若微信号与新榜信息不一致,以新榜为准']" anticrawler="1"/> +<Route author="lessmoe" example="/newrank/wechat/chijiread" path="/newrank/wechat/:wxid" :paramsDesc="['微信号,若微信号与新榜信息不一致,以新榜为准']" anticrawler="1" selfhost="1"/> ### 抖音短视频 -<Route author="lessmoe" example="/newrank/douyin/110266463747" path="/newrank/douyin/:dyid" :paramsDesc="['抖音ID,可在新榜账号详情 URL 中找到']" anticrawler="1"/> +<Route author="lessmoe" example="/newrank/douyin/110266463747" path="/newrank/douyin/:dyid" :paramsDesc="['抖音ID,可在新榜账号详情 URL 中找到']" anticrawler="1" selfhost="1"/> ::: warning 注意 免费版账户抖音每天查询次数 20 次,如需增加次数可购买新榜会员或等待未来多账户支持 diff --git a/lib/router.js b/lib/router.js index 7e1abb41e40390..e5388b0a884772 100644 --- a/lib/router.js +++ b/lib/router.js @@ -3005,8 +3005,8 @@ router.get('/liequtv/room/:id', lazyloadRouteHandler('./routes/liequtv/room')); router.get('/bwu/news', lazyloadRouteHandler('./routes/universities/bwu/news')); // 新榜 -router.get('/newrank/wechat/:wxid', lazyloadRouteHandler('./routes/newrank/wechat')); -router.get('/newrank/douyin/:dyid', lazyloadRouteHandler('./routes/newrank/douyin')); +// router.get('/newrank/wechat/:wxid', lazyloadRouteHandler('./routes/newrank/wechat')); +// router.get('/newrank/douyin/:dyid', lazyloadRouteHandler('./routes/newrank/douyin')); // 漫小肆 router.get('/manxiaosi/book/:id', lazyloadRouteHandler('./routes/manxiaosi/book')); diff --git a/lib/routes/newrank/wechat.js b/lib/routes/newrank/wechat.js deleted file mode 100644 index 5ee1a3de101a87..00000000000000 --- a/lib/routes/newrank/wechat.js +++ /dev/null @@ -1,37 +0,0 @@ -const got = require('@/utils/got'); -const utils = require('./utils'); -const config = require('@/config').value; - -module.exports = async (ctx) => { - const uid = ctx.params.wxid; - const nonce = utils.random_nonce(9); - const response = await got({ - method: 'post', - url: 'https://www.newrank.cn/xdnphb/detail/v1/rank/article/lists', - headers: { - Connection: 'keep-alive', - Cookie: String(config.newrank.cookie), - }, - form: { - account: uid, - nonce, - xyz: utils.decrypt_wechat_detail_xyz(uid, nonce), - }, - }); - const name = response.data.value.user.name; - const realTimeArticles = utils.flatten(response.data.value.realTimeArticles); - const articles = utils.flatten(response.data.value.articles); - const newArticles = realTimeArticles.concat(articles); - const items = newArticles.map((item) => ({ - title: item.title, - description: '', - link: item.url, - pubDate: item.publicTime, - })); - - ctx.state.data = { - title: name + ' - 微信公众号', - link: 'https://www.newrank.cn/new/readDetial?account=' + uid, - item: items, - }; -}; diff --git a/lib/routes/newrank/douyin.js b/lib/v2/newrank/douyin.js similarity index 87% rename from lib/routes/newrank/douyin.js rename to lib/v2/newrank/douyin.js index 55dc86f46bb2a9..01a291ce847a94 100644 --- a/lib/routes/newrank/douyin.js +++ b/lib/v2/newrank/douyin.js @@ -3,10 +3,13 @@ const utils = require('./utils'); const config = require('@/config').value; module.exports = async (ctx) => { + if (!config.newrank || !config.newrank.cookie) { + throw Error('newrank RSS is disabled due to the lack of <a href="https://docs.rsshub.app/install/#pei-zhi-bu-fen-rss-mo-kuai-pei-zhi">relevant config</a>'); + } const uid = ctx.params.dyid; const nonce = utils.random_nonce(9); const url_detail = 'https://xd.newrank.cn/xdnphb/nr/cloud/douyin/detail/aweme?xyz=' + utils.decrypt_douyin_detail_xyz(nonce) + '&nonce=' + nonce; - const cookie = String(config.newrank.cookie); + const cookie = config.newrank.cookie; const response_detail = await got({ method: 'post', url: url_detail, diff --git a/lib/v2/newrank/maintainer.js b/lib/v2/newrank/maintainer.js new file mode 100644 index 00000000000000..421e3f1f259e34 --- /dev/null +++ b/lib/v2/newrank/maintainer.js @@ -0,0 +1,4 @@ +module.exports = { + '/douyin/:dyid': ['lessmoe'], + '/wechat/:wxid': ['lessmoe'], +}; diff --git a/lib/v2/newrank/radar.js b/lib/v2/newrank/radar.js new file mode 100644 index 00000000000000..04c00473c1253a --- /dev/null +++ b/lib/v2/newrank/radar.js @@ -0,0 +1,15 @@ +module.exports = { + 'newrank.cn': { + _name: '新榜', + '.': [ + { + title: '微信公众号', + docs: 'https://docs.rsshub.app/social-media.html#xin-bang', + }, + { + title: '抖音短视频', + docs: 'https://docs.rsshub.app/social-media.html#xin-bang', + }, + ], + }, +}; diff --git a/lib/v2/newrank/router.js b/lib/v2/newrank/router.js new file mode 100644 index 00000000000000..5b65992d39afbc --- /dev/null +++ b/lib/v2/newrank/router.js @@ -0,0 +1,4 @@ +module.exports = (router) => { + router.get('/douyin/:dyid', require('./douyin')); + router.get('/wechat/:wxid', require('./wechat')); +}; diff --git a/lib/routes/newrank/utils.js b/lib/v2/newrank/utils.js similarity index 100% rename from lib/routes/newrank/utils.js rename to lib/v2/newrank/utils.js diff --git a/lib/v2/newrank/wechat.js b/lib/v2/newrank/wechat.js new file mode 100644 index 00000000000000..f92b6a08097925 --- /dev/null +++ b/lib/v2/newrank/wechat.js @@ -0,0 +1,65 @@ +const got = require('@/utils/got'); +const { finishArticleItem } = require('@/utils/wechat-mp'); +const cheerio = require('cheerio'); +const utils = require('./utils'); +const config = require('@/config').value; + +module.exports = async (ctx) => { + if (!config.newrank || !config.newrank.cookie) { + throw Error('newrank RSS is disabled due to the lack of <a href="https://docs.rsshub.app/install/#pei-zhi-bu-fen-rss-mo-kuai-pei-zhi">relevant config</a>'); + } + const uid = ctx.params.wxid; + const nonce = utils.random_nonce(9); + const { data: summaryHTML } = await got({ + method: 'get', + url: `https://www.newrank.cn/new/readDetial?account=${uid}`, + headers: { + Connection: 'keep-alive', + Cookie: config.newrank.cookie, + }, + }); + const summary$ = cheerio.load(summaryHTML); + const mainsrc = summary$('script') + .toArray() + .find((item) => (item.attribs.src || '').startsWith('/new/static/js/main.')).attribs.src; + const { data: mainScript } = await got({ + method: 'get', + url: `https://www.newrank.cn${mainsrc}`, + }); + const N_TOKEN_match = mainScript.match(/"N-Token":"([^"]+)/); + if (!N_TOKEN_match) { + throw Error('Cannot find n-token'); + } + const N_TOKEN = N_TOKEN_match[1]; + const response = await got({ + method: 'post', + url: 'https://gw.newrank.cn/api/wechat/xdnphb/detail/v1/rank/article/lists', + headers: { + Connection: 'keep-alive', + Cookie: config.newrank.cookie, + 'n-token': N_TOKEN, + }, + form: { + account: uid, + nonce, + xyz: utils.decrypt_wechat_detail_xyz(uid, nonce), + }, + }); + const name = response.data.value.user.name; + const realTimeArticles = utils.flatten(response.data.value.realTimeArticles); + const articles = utils.flatten(response.data.value.articles); + const newArticles = realTimeArticles.concat(articles); + const items = newArticles.map((item) => ({ + title: item.title, + description: '', + link: item.url, + pubDate: item.publicTime, + })); + await Promise.all(items.map((item) => finishArticleItem(ctx, item))); + + ctx.state.data = { + title: name + ' - 微信公众号', + link: `https://www.newrank.cn/new/readDetial?account=${uid}`, + item: items, + }; +};
71567ba62b1b20e81cb4e5ee50c6a5663a957dc6
2020-10-29 23:46:27
johan456789
docs: replace aggregator with generator (#6043)
false
replace aggregator with generator (#6043)
docs
diff --git a/README.md b/README.md index 83855352e3e773..d2cbb851f307fa 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ ## Introduction -RSSHub is an open source, easy to use, and extensible RSS feed aggregator, it's capable of generating RSS feeds from pretty much everything. +RSSHub is an open source, easy to use, and extensible RSS feed generator. It's capable of generating RSS feeds from pretty much everything. RSSHub delivers millions of contents aggregated from all kinds of sources, our vibrant open source community is ensuring the deliver of RSSHub's new routes, new features and bug fixes.
dd82c1da0e1bce5d0e5b6213136c447d5b71450a
2023-03-24 16:03:57
Fatpandac
feat(route): add wanqu (#12166)
false
add wanqu (#12166)
feat
diff --git a/docs/new-media.md b/docs/new-media.md index a693406444ae61..59eae60a674d9c 100644 --- a/docs/new-media.md +++ b/docs/new-media.md @@ -3812,6 +3812,12 @@ column 为 third 时可选的 category: <Route author="shuiRong" example="/wainao-reads/all-articles" path="/wainao-reads/all-articles" /> +## 湾区日报 + +### 最新推荐 + +<Route author="Fatpandac" example="/wanqu/news" path="/wanqu/news" radar="1" /> + ## 晚点 LatePost ### 报道 diff --git a/lib/v2/wanqu/maintainer.js b/lib/v2/wanqu/maintainer.js new file mode 100644 index 00000000000000..89c40d4d50048c --- /dev/null +++ b/lib/v2/wanqu/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/news': ['Fatpandac'], +}; diff --git a/lib/v2/wanqu/news.js b/lib/v2/wanqu/news.js new file mode 100644 index 00000000000000..5052b39c5d6878 --- /dev/null +++ b/lib/v2/wanqu/news.js @@ -0,0 +1,26 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const { parseDate } = require('@/utils/parse-date'); + +module.exports = async (ctx) => { + const rootUrl = 'https://www.wanqu.co'; + const currentUrl = rootUrl; + + const response = await got(currentUrl); + + const $ = cheerio.load(response.data); + + const items = $('div.mb-4') + .toArray() + .map((item) => ({ + title: $(item).text(), + link: $(item).find('a').attr('href'), + pubDate: parseDate($(item).find('i.text-helper-color.mr-4').text()), + })); + + ctx.state.data = { + title: '湾区日报 - 最新推荐', + link: currentUrl, + item: items, + }; +}; diff --git a/lib/v2/wanqu/radar.js b/lib/v2/wanqu/radar.js new file mode 100644 index 00000000000000..86e507db6acfc8 --- /dev/null +++ b/lib/v2/wanqu/radar.js @@ -0,0 +1,13 @@ +module.exports = { + 'wanqu.co': { + _name: '湾区日报', + '.': [ + { + title: '最新推荐', + docs: 'https://docs.rsshub.app/new-media.html#wan-qu-ri-bao', + source: ['/'], + target: '/wanqu/news', + }, + ], + }, +}; diff --git a/lib/v2/wanqu/router.js b/lib/v2/wanqu/router.js new file mode 100644 index 00000000000000..69a5972f6a8112 --- /dev/null +++ b/lib/v2/wanqu/router.js @@ -0,0 +1,3 @@ +module.exports = function (router) { + router.get('/news', require('./news')); +};
d224d6782268f8aba09063e387d0ff251fb03988
2024-10-31 14:52:38
pseudoyu
refactor(route/dianping): add param desc for dianping
false
add param desc for dianping
refactor
diff --git a/lib/routes/dianping/user.ts b/lib/routes/dianping/user.ts index 8a0de081ec796e..09cbf1b8fc700f 100644 --- a/lib/routes/dianping/user.ts +++ b/lib/routes/dianping/user.ts @@ -2,24 +2,17 @@ import { Route } from '@/types'; import ofetch from '@/utils/ofetch'; import { config } from '@/config'; -function addPictureAndVideo(item: any) { - let content = ''; - content += item.pictureList ? item.pictureList.map((ele: any) => `<img src="${ele.picUrl}" />`).join('<br>') : ''; - content += item.videoUrl ? `<img src="${item.videoUrl}" />` : ''; - return content; -} - export const route: Route = { path: '/user/:id', categories: ['shopping'], example: '/dianping/user/808259118', - parameters: { id: 'User id' }, + parameters: { id: 'User id,打开网页端从 URL 中获取,在 `/member/:id` 中' }, features: { requireConfig: [ { name: 'DIANPING_COOKIE', optional: false, - description: 'Cookie for Dianping', + description: '大众点评的 Cookie', }, ], requirePuppeteer: false, @@ -30,16 +23,23 @@ export const route: Route = { }, radar: [ { - source: ['dianping.com/member/:id'], + source: ['dianping.com/member/:id', 'm.dianping.com/userprofile/:id'], target: '/dianping/user/:id', }, ], - name: 'User', + name: '用户动态', maintainers: ['pseudoyu'], handler, - description: 'Get user reviews, check-ins, guides.', + description: '获取用户点评、签到、攻略等动态。', }; +function addPictureAndVideo(item: any) { + let content = ''; + content += item.pictureList ? item.pictureList.map((ele: any) => `<img src="${ele.picUrl}" />`).join('<br>') : ''; + content += item.videoUrl ? `<img src="${item.videoUrl}" />` : ''; + return content; +} + const starMap: Record<number, string> = { 0: '无', 10: '一星',
6a1d5ad0a049917f9e4f43abb74bc657f9dbe1be
2022-10-11 23:18:50
Tony
fix(route): luogu (#11064)
false
luogu (#11064)
fix
diff --git a/docs/programming.md b/docs/programming.md index 326e5dbdc1cd9a..55e3dc2617fe8f 100644 --- a/docs/programming.md +++ b/docs/programming.md @@ -958,15 +958,15 @@ GitHub 官方也提供了一些 RSS: ### 日报 -<Route author="LogicJake prnake nczitzk" example="/luogu/daily" path="/luogu/daily/:id?" :paramsDesc="['年度日报所在帖子 id,可在 URL 中找到,不填默认为 2020 年日报']"/> +<Route author="LogicJake prnake nczitzk" example="/luogu/daily" path="/luogu/daily/:id?" :paramsDesc="['年度日报所在帖子 id,可在 URL 中找到,不填默认为 `47327`']" radar="1" rssbud="1"/> -### 近期比赛 +### 比赛列表 -<Route author="prnake" example="/luogu/contest" path="/luogu/contest"/> +<Route author="prnake" example="/luogu/contest" path="/luogu/contest" radar="1" rssbud="1"/> ### 用户动态 -<Route author="solstice23" example="/luogu/user/feed/1" path="/luogu/user/feed/:uid" :paramsDesc="['用户 UID']"/> +<Route author="solstice23" example="/luogu/user/feed/1" path="/luogu/user/feed/:uid" :paramsDesc="['用户 UID']" radar="1" rssbud="1"/> ## 码农俱乐部 diff --git a/lib/router.js b/lib/router.js index 80c448a5e6a7e6..cbec58fa1dbe14 100644 --- a/lib/router.js +++ b/lib/router.js @@ -1356,9 +1356,9 @@ router.get('/ui-cn/user/:id', lazyloadRouteHandler('./routes/ui-cn/user')); router.get('/bjp/apod', lazyloadRouteHandler('./routes/bjp/apod')); // 洛谷 -router.get('/luogu/daily/:id?', lazyloadRouteHandler('./routes/luogu/daily')); -router.get('/luogu/contest', lazyloadRouteHandler('./routes/luogu/contest')); -router.get('/luogu/user/feed/:uid', lazyloadRouteHandler('./routes/luogu/userFeed')); +// router.get('/luogu/daily/:id?', lazyloadRouteHandler('./routes/luogu/daily')); +// router.get('/luogu/contest', lazyloadRouteHandler('./routes/luogu/contest')); +// router.get('/luogu/user/feed/:uid', lazyloadRouteHandler('./routes/luogu/userFeed')); // 决胜网 router.get('/juesheng', lazyloadRouteHandler('./routes/juesheng')); diff --git a/lib/routes/luogu/contest.js b/lib/routes/luogu/contest.js deleted file mode 100644 index f6211e9a5e5112..00000000000000 --- a/lib/routes/luogu/contest.js +++ /dev/null @@ -1,28 +0,0 @@ -const got = require('@/utils/got'); -const cheerio = require('cheerio'); -const resolve_url = require('url').resolve; - -module.exports = async (ctx) => { - const link = 'https://www.luogu.com.cn/'; - const response = await got.get(link); - const $ = cheerio.load(response.data); - const title = '洛谷近期比赛'; - - const out = $('.am-panel-hd ') - .slice(0, 10) - .map(function () { - const info = { - title: $(this).find('a').text() || $(this).text(), - description: $(this).html() + $(this).parent().find('.am-panel-bd').html(), - link: resolve_url('https://www.luogu.com.cn', $(this).find('a').attr('href')), - }; - return info; - }) - .get(); - - ctx.state.data = { - title, - link, - item: out, - }; -}; diff --git a/lib/routes/luogu/daily.js b/lib/routes/luogu/daily.js deleted file mode 100644 index 8e0c7b1ebfb253..00000000000000 --- a/lib/routes/luogu/daily.js +++ /dev/null @@ -1,53 +0,0 @@ -const got = require('@/utils/got'); -const cheerio = require('cheerio'); - -module.exports = async (ctx) => { - const id = ctx.params.id || 179788; - const link = `https://www.luogu.org/discuss/show/${id}`; - const response = await got.get(link); - const $ = cheerio.load(response.data); - const title = $('title').text(); - - const out = $('div.am-comment-main > div > p') - .slice(0, 10) - .map(function () { - const info = { - title: $(this).find('strong').text() || $(this).text(), - link: $(this).find('a').attr('href'), - }; - return info; - }) - .get(); - - const items = await Promise.all( - out.map((item) => - ctx.cache.tryGet(item.link, async () => { - const detailResponse = await got({ - method: 'get', - url: item.link, - }); - const content = cheerio.load(detailResponse.data); - const timeRegExp = new RegExp(/(?<=([1-9]\d{3}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])\s+(20|21|22|23|[0-1]\d):[0-5]\d:[0-5]\d))/); - - item.description = content('#article-content').html(); - - content('#article-content').remove(); - - const line = content - .html() - .split('\n') - .find((line) => timeRegExp.test(line)); - - item.pubDate = new Date(line.match(timeRegExp)[1] + ' GMT+8').toUTCString(); - - return item; - }) - ) - ); - - ctx.state.data = { - title, - link, - item: items, - }; -}; diff --git a/lib/routes/luogu/userFeed.js b/lib/routes/luogu/userFeed.js deleted file mode 100644 index 17f944c203c133..00000000000000 --- a/lib/routes/luogu/userFeed.js +++ /dev/null @@ -1,38 +0,0 @@ -const got = require('@/utils/got'); - -module.exports = async (ctx) => { - const getUsernameFromUID = async (uid) => { - const key = 'luogu-username-from-uid-' + uid; - let name = await ctx.cache.get(key); - if (!name) { - const nameResponse = await got({ - method: 'get', - url: `https://www.luogu.com.cn/user/${uid}?_contentOnly=1`, - }); - name = nameResponse.data.currentData.user.name; - ctx.cache.set(key, name); - } - return name; - }; - - const uid = ctx.params.uid; - const name = await getUsernameFromUID(uid); - const response = await got({ - method: 'get', - url: `https://www.luogu.com.cn/api/feed/list?user=${uid}`, - }); - const data = response.data.feeds.result; - - ctx.state.data = { - title: `${name} 的洛谷动态`, - link: `https://www.luogu.com.cn/user/${uid}#activity`, - allowEmpty: true, - item: data.map((item) => ({ - title: item.content, - description: item.content, - pubDate: new Date(item.time * 1000).toUTCString(), - link: `https://www.luogu.com.cn/user/${uid}#activity`, - guid: item.id, - })), - }; -}; diff --git a/lib/v2/luogu/contest.js b/lib/v2/luogu/contest.js new file mode 100644 index 00000000000000..62ecbeb50d9d26 --- /dev/null +++ b/lib/v2/luogu/contest.js @@ -0,0 +1,72 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const md = require('markdown-it')(); +const { parseDate } = require('@/utils/parse-date'); +const asyncPool = require('tiny-async-pool'); + +const baseUrl = 'https://www.luogu.com.cn'; + +const typeMap = { + ruleType: { + 1: 'OI', + 2: 'ACM', + 3: '乐多', + 4: 'IOI', + }, + visibilityType: { + 1: '官方比赛', + 2: '团队公开赛', + 4: '个人公开赛', + }, + // invitationCodeType: { + // 1: '', + // 2: '', + // }, +}; + +module.exports = async (ctx) => { + const link = `${baseUrl}/contest/list`; + const { data: response } = await got(link); + const $ = cheerio.load(response); + + const data = JSON.parse( + decodeURIComponent( + $('script') + .text() + .match(/decodeURIComponent\("(.*)"\)/)[1] + ) + ); + + const result = []; + for await (const item of asyncPool(4, data.currentData.contests.result, (item) => + ctx.cache.tryGet(`${baseUrl}/contest/${item.id}`, async () => { + const { data: response } = await got(`${baseUrl}/contest/${item.id}`); + const $ = cheerio.load(response); + const data = JSON.parse( + decodeURIComponent( + $('script') + .text() + .match(/decodeURIComponent\("(.*)"\)/)[1] + ) + ); + + return { + title: item.name, + description: md.render(data.currentData.contest.description), + link: `${baseUrl}/contest/${item.id}`, + author: item.host.name, + pubDate: parseDate(item.startTime, 'X'), + category: [item.rated ? 'Rated' : null, typeMap.ruleType[item.ruleType], typeMap.visibilityType[item.visibilityType]].filter((i) => i), + }; + }) + )) { + result.push(item); + } + + ctx.state.data = { + title: $('head title').text(), + link, + image: 'https://www.luogu.com.cn/favicon.ico', + item: result, + }; +}; diff --git a/lib/v2/luogu/daily.js b/lib/v2/luogu/daily.js new file mode 100644 index 00000000000000..cd7de0f93222f1 --- /dev/null +++ b/lib/v2/luogu/daily.js @@ -0,0 +1,33 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const { parseDate } = require('@/utils/parse-date'); + +module.exports = async (ctx) => { + const id = ctx.params.id ?? 47327; + const link = `https://www.luogu.com.cn/discuss/${id}`; + const response = await got(link); + const $ = cheerio.load(response.data); + const title = $('head title').text(); + + const firstPost = $('.am-comment-main .am-comment-bd').first(); + const dailyLink = firstPost.find('a').first().attr('href'); + const issueHeading = firstPost.find('h1').text().trim(); + const { data: dailyResponse } = await got(dailyLink); + const $daily = cheerio.load(dailyResponse); + const item = [ + { + title, + description: $daily('#article-content').html(), + link, + author: firstPost.find('p').eq(1).text(), + guid: `${link}#${issueHeading}`, + pubDate: parseDate(issueHeading.match(/(\d{4} 年 \d{2} 月 \d{2} 日)/)[1], 'YYYY 年 MM 月 DD 日'), + }, + ]; + + ctx.state.data = { + title: '洛谷日报', + link, + item, + }; +}; diff --git a/lib/v2/luogu/maintainer.js b/lib/v2/luogu/maintainer.js new file mode 100644 index 00000000000000..8a7d98e90b1982 --- /dev/null +++ b/lib/v2/luogu/maintainer.js @@ -0,0 +1,5 @@ +module.exports = { + '/contest': ['prnake'], + '/daily/:id?': ['LogicJake ', 'prnake ', 'nczitzk'], + '/user/feed/:uid': ['solstice23'], +}; diff --git a/lib/v2/luogu/radar.js b/lib/v2/luogu/radar.js new file mode 100644 index 00000000000000..7b81729183b4f3 --- /dev/null +++ b/lib/v2/luogu/radar.js @@ -0,0 +1,25 @@ +module.exports = { + 'luogu.com.cn': { + _name: '洛谷', + '.': [ + { + title: '日报', + docs: 'https://docs.rsshub.app/programming.html#luo-gu', + source: ['/discuss/47327', '/'], + target: '/luogu/daily', + }, + { + title: '比赛列表', + docs: 'https://docs.rsshub.app/programming.html#luo-gu', + source: ['/contest/list', '/'], + target: '/luogu/contest', + }, + { + title: '用户动态', + docs: 'https://docs.rsshub.app/programming.html#luo-gu', + source: ['/user/:uid'], + target: '/luogu/user/feed/:uid', + }, + ], + }, +}; diff --git a/lib/v2/luogu/router.js b/lib/v2/luogu/router.js new file mode 100644 index 00000000000000..eb1e9da774ead0 --- /dev/null +++ b/lib/v2/luogu/router.js @@ -0,0 +1,5 @@ +module.exports = (router) => { + router.get('/contest', require('./contest')); + router.get('/daily/:id?', require('./daily')); + router.get('/user/feed/:uid', require('./userFeed')); +}; diff --git a/lib/v2/luogu/userFeed.js b/lib/v2/luogu/userFeed.js new file mode 100644 index 00000000000000..2b62fcf4f0af46 --- /dev/null +++ b/lib/v2/luogu/userFeed.js @@ -0,0 +1,30 @@ +const got = require('@/utils/got'); +const { parseDate } = require('@/utils/parse-date'); +const md = require('markdown-it')(); + +module.exports = async (ctx) => { + const getUsernameFromUID = (uid) => + ctx.cache.tryGet('luogu:username:' + uid, async () => { + const { data } = await got(`https://www.luogu.com.cn/user/${uid}?_contentOnly=1`); + return data.currentData.user.name; + }); + + const uid = ctx.params.uid; + const name = await getUsernameFromUID(uid); + const { data: response } = await got(`https://www.luogu.com.cn/api/feed/list?user=${uid}`); + + const data = response.feeds.result; + + ctx.state.data = { + title: `${name} 的洛谷动态`, + link: `https://www.luogu.com.cn/user/${uid}#activity`, + allowEmpty: true, + item: data.map((item) => ({ + title: item.content, + description: md.render(item.content), + pubDate: parseDate(item.time, 'X'), + author: name, + link: `https://www.luogu.com.cn/user/${uid}#activity`, + })), + }; +};
d8c5452bbc21421c4b7c9609c76601ca7610b1cb
2024-09-27 18:18:48
huanfei
fix: pornhub change rss image (#16950)
false
pornhub change rss image (#16950)
fix
diff --git a/lib/routes/pornhub/model.ts b/lib/routes/pornhub/model.ts index 3768a8e3edf67a..32296bc855b793 100644 --- a/lib/routes/pornhub/model.ts +++ b/lib/routes/pornhub/model.ts @@ -1,4 +1,4 @@ -import { Route, ViewType } from '@/types'; +import { Route, ViewType, Data } from '@/types'; import got from '@/utils/got'; import { load } from 'cheerio'; import { isValidHost } from '@/utils/valid-host'; @@ -30,7 +30,7 @@ export const route: Route = { handler, }; -async function handler(ctx) { +async function handler(ctx): Promise<Data> { const { language = 'www', username, sort = '' } = ctx.req.param(); const link = `https://${language}.pornhub.com/model/${username}/videos${sort ? `?o=${sort}` : ''}`; if (!isValidHost(language)) { @@ -47,9 +47,7 @@ async function handler(ctx) { title: $('h1').first().text(), description: $('section.aboutMeSection').text().trim(), link, - image: $('#coverPictureDefault').attr('src'), - logo: $('#getAvatar').attr('src'), - icon: $('#getAvatar').attr('src'), + image: $('#getAvatar').attr('src'), language: $('html').attr('lang'), item: items, }; diff --git a/lib/routes/pornhub/pornstar.ts b/lib/routes/pornhub/pornstar.ts index e4f5a260bec2fb..ea8fa0853742ba 100644 --- a/lib/routes/pornhub/pornstar.ts +++ b/lib/routes/pornhub/pornstar.ts @@ -1,4 +1,4 @@ -import { Route, ViewType } from '@/types'; +import { Route, ViewType, Data } from '@/types'; import got from '@/utils/got'; import { load } from 'cheerio'; import { isValidHost } from '@/utils/valid-host'; @@ -73,7 +73,7 @@ export const route: Route = { handler, }; -async function handler(ctx) { +async function handler(ctx): Promise<Data> { const { language = 'www', username, sort = 'mr' } = ctx.req.param(); let link = `https://${language}.pornhub.com/pornstar/${username}?o=${sort}`; if (!isValidHost(language)) { @@ -101,9 +101,7 @@ async function handler(ctx) { title: $('h1').first().text(), description: $('section.aboutMeSection').text().trim(), link, - image: $('#coverPictureDefault').attr('src'), - logo: $('#getAvatar').attr('src'), - icon: $('#getAvatar').attr('src'), + image: $('#getAvatar').attr('src'), language: $('html').attr('lang'), item: items, }; diff --git a/lib/routes/pornhub/users.ts b/lib/routes/pornhub/users.ts index 6e6e33b5df5d94..ade011d9a7d80c 100644 --- a/lib/routes/pornhub/users.ts +++ b/lib/routes/pornhub/users.ts @@ -1,4 +1,4 @@ -import { Route } from '@/types'; +import { Route, Data } from '@/types'; import got from '@/utils/got'; import { load } from 'cheerio'; import { isValidHost } from '@/utils/valid-host'; @@ -29,7 +29,7 @@ export const route: Route = { handler, }; -async function handler(ctx) { +async function handler(ctx): Promise<Data> { const { language = 'www', username } = ctx.req.param(); const link = `https://${language}.pornhub.com/users/${username}/videos`; if (!isValidHost(language)) { @@ -46,9 +46,7 @@ async function handler(ctx) { title: $('.profileUserName a').text(), description: $('.aboutMeText').text().trim(), link, - image: $('#coverPictureDefault').attr('src'), - logo: $('#getAvatar').attr('src'), - icon: $('#getAvatar').attr('src'), + image: $('#getAvatar').attr('src'), language: $('html').attr('lang'), allowEmpty: true, item: items,
3225415e9581c913490541cc791f7209fd2f0a1b
2019-06-28 10:30:46
Cloud
fix: konachan safe mode (#2509)
false
konachan safe mode (#2509)
fix
diff --git a/lib/routes/konachan/post_popular_recent.js b/lib/routes/konachan/post_popular_recent.js index a8a3be9c370607..f52848eb06d3fb 100644 --- a/lib/routes/konachan/post_popular_recent.js +++ b/lib/routes/konachan/post_popular_recent.js @@ -4,6 +4,7 @@ module.exports = async (ctx) => { const { period = '1d' } = ctx.params; const baseUrl = ctx.path.startsWith('/konachan.net') ? 'https://konachan.net' : 'https://konachan.com'; + const safemode = ctx.path.startsWith('/konachan.net'); const response = await got({ method: 'get', @@ -28,37 +29,39 @@ module.exports = async (ctx) => { ctx.state.data = { title: `${title} - Konachan Anime Wallpapers`, link: `${baseUrl}/post/popular_recent`, - item: posts.map((post) => { - const content = (url) => { - if (url.startsWith('//')) { - url = 'https:' + url; - } - let result = `<img referrerpolicy="no-referrer" src="${url}" />`; - if (post.source) { - result += `<a href="${post.source}">source</a>`; - } - if (post.parent_id) { - result += `<a href="${baseUrl}/post/show/${post.parent_id}">parent</a>`; - } - return result; - }; + item: posts + .filter((post) => !(safemode && post.rating != 's')) + .map((post) => { + const content = (url) => { + if (url.startsWith('//')) { + url = 'https:' + url; + } + let result = `<img referrerpolicy="no-referrer" src="${url}" />`; + if (post.source) { + result += `<a href="${post.source}">source</a>`; + } + if (post.parent_id) { + result += `<a href="${baseUrl}/post/show/${post.parent_id}">parent</a>`; + } + return result; + }; - const created_at = post.created_at * 1e3; + const created_at = post.created_at * 1e3; - return { - title: post.tags, - id: `${ctx.path}#${post.id}`, - guid: `${ctx.path}#${post.id}`, - link: `${baseUrl}/post/show/${post.id}`, - author: post.author, - published: new Date(created_at).toISOString(), - pubDate: new Date(created_at).toUTCString(), - description: content(post.sample_url), - summary: content(post.sample_url), - content: { html: content(post.file_url) }, - image: post.file_url, - category: post.tags.split(/\s+/), - }; - }), + return { + title: post.tags, + id: `${ctx.path}#${post.id}`, + guid: `${ctx.path}#${post.id}`, + link: `${baseUrl}/post/show/${post.id}`, + author: post.author, + published: new Date(created_at).toISOString(), + pubDate: new Date(created_at).toUTCString(), + description: content(post.sample_url), + summary: content(post.sample_url), + content: { html: content(post.file_url) }, + image: post.file_url, + category: post.tags.split(/\s+/), + }; + }), }; };
fbabf94c5e14c642d9a7a24b2ea7aec34dbecd63
2018-07-20 23:37:13
DIYgod
docs: update sponsor links
false
update sponsor links
docs
diff --git a/README.md b/README.md index 56dedba329bebd..381c9cf6b122c6 100644 --- a/README.md +++ b/README.md @@ -185,9 +185,15 @@ RSSHub 是一个轻量、易于扩展的 RSS 生成器,可以给任何奇奇 ## 鸣谢 -### Sponsors +### Special Sponsor + +<p> +<a href="https://rixcloud.app/rsshub" target="_blank"> + <img width="200px" src="https://i.imgur.com/PpcSVCZ.png"> +</a> +</p> -- [rixCloud](https://rixcloud.us) +### Sponsors - [Liuyang](https://github.com/lingllting) diff --git a/docs/README.md b/docs/README.md index 20eedd04a6d5ba..5f2baebe684ae3 100644 --- a/docs/README.md +++ b/docs/README.md @@ -11,9 +11,15 @@ RSSHub 是一个轻量、易于扩展的 RSS 生成器,可以给任何奇奇 ## 鸣谢 -### Sponsors +### Special Sponsor + +<p> +<a href="https://rixcloud.app/rsshub" target="_blank"> + <img width="200px" src="https://i.imgur.com/PpcSVCZ.png"> +</a> +</p> -- [rixCloud](https://rixcloud.us) +### Sponsors - [Liuyang](https://github.com/lingllting)
9b832f04f56d45556dfd1a19875c142769caadb1
2022-06-01 05:58:55
Tony
feat(route): tiktok (#9867)
false
tiktok (#9867)
feat
diff --git a/docs/en/social-media.md b/docs/en/social-media.md index 0dd47ed38e3930..fccc7da8ee0932 100644 --- a/docs/en/social-media.md +++ b/docs/en/social-media.md @@ -300,6 +300,12 @@ Due to Telegram restrictions, some channels involving pornography, copyright, an <RouteEn author="fengkx" example="/telegram/blog" path="/telegram/blog" /> +## TikTok + +### User + +<RouteEn author="TonyRL" example="/tiktok/user/@linustech" path="/tiktok/user/:user" :paramsDesc="['User ID, including @']" anticrawler="1" puppeteer="1" radar="1" rssbud="1"/> + ## Twitter ::: warning diff --git a/lib/v2/tiktok/router.js b/lib/v2/tiktok/router.js new file mode 100644 index 00000000000000..5aabfd0768414e --- /dev/null +++ b/lib/v2/tiktok/router.js @@ -0,0 +1,3 @@ +module.exports = (router) => { + router.get('/user/:user', require('./user')); +}; diff --git a/lib/v2/tiktok/templates/maintainer.js b/lib/v2/tiktok/templates/maintainer.js new file mode 100644 index 00000000000000..59dcb464e0fb46 --- /dev/null +++ b/lib/v2/tiktok/templates/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/user/:user': ['TonyRL'], +}; diff --git a/lib/v2/tiktok/templates/radar.js b/lib/v2/tiktok/templates/radar.js new file mode 100644 index 00000000000000..8bfb99d0cd45ec --- /dev/null +++ b/lib/v2/tiktok/templates/radar.js @@ -0,0 +1,13 @@ +module.exports = { + 'tiktok.com': { + _name: 'TikTok', + '.': [ + { + title: 'User', + docs: 'https://docs.rsshub.app/en/social-media.html#tiktok', + source: ['/:user'], + target: '/tiktok/user/:user', + }, + ], + }, +}; diff --git a/lib/v2/tiktok/templates/user.art b/lib/v2/tiktok/templates/user.art new file mode 100644 index 00000000000000..a8e2982d6e7f35 --- /dev/null +++ b/lib/v2/tiktok/templates/user.art @@ -0,0 +1,3 @@ +<video controls loop poster="{{ poster }}" preload="none"> +<source src="{{ source }}"> +</video> diff --git a/lib/v2/tiktok/user.js b/lib/v2/tiktok/user.js new file mode 100644 index 00000000000000..15dd52e237894b --- /dev/null +++ b/lib/v2/tiktok/user.js @@ -0,0 +1,66 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const config = require('@/config').value; +const { parseDate } = require('@/utils/parse-date'); +const { art } = require('@/utils/render'); +const path = require('path'); + +const baseUrl = 'https://www.tiktok.com'; + +module.exports = async (ctx) => { + const { user } = ctx.params; + + const html = await ctx.cache.tryGet( + `tiktok:user:${user}`, + async () => { + const browser = await require('@/utils/puppeteer')(); + const page = await browser.newPage(); + await page.goto(`${baseUrl}/${user}`, { + waitUntil: 'networkidle2', + }); + const html = await page.evaluate(() => document.documentElement.innerHTML); + browser.close(); + return html; + }, + config.cache.routeExpire, + false + ); + + const $ = cheerio.load(html); + + let items = $('[class*=-DivItemContainerV2]') + .toArray() + .map((item) => ({ link: $(item).find('[class*=-DivWrapper] a').attr('href') })); + + items = await Promise.all( + items.map((item) => + ctx.cache.tryGet(item.link, async () => { + const videoId = item.link.substring(item.link.lastIndexOf('/') + 1); + const api = ( + await got(`${baseUrl}/node/share/video/${user}/${videoId}`, { + headers: { + referer: `${baseUrl}/${user}`, + }, + }) + ).data; + + item.title = api.itemInfo.itemStruct.desc; + item.description = art(path.join(__dirname, 'templates/user.art'), { + poster: api.itemInfo.itemStruct.video.cover, + source: api.itemInfo.itemStruct.video.playAddr, + }); + item.author = api.itemInfo.itemStruct.author.nickname; + item.pubDate = parseDate(api.itemInfo.itemStruct.createTime * 1000); + + return item; + }) + ) + ); + + ctx.state.data = { + title: $('title').text(), + description: $('[data-e2e=user-bio]').text(), + link: `${baseUrl}/${user}`, + item: items, + }; +};
f2858083bbb7539ce40de2655aea7cae1211eba6
2022-01-23 00:47:04
DIYgod
docs: fix unexpected character error
false
fix unexpected character error
docs
diff --git a/docs/traditional-media.md b/docs/traditional-media.md index 43408ac08a8ed0..428bd7e51ad3a9 100644 --- a/docs/traditional-media.md +++ b/docs/traditional-media.md @@ -1167,7 +1167,7 @@ category 对应的关键词有 ### 新闻 -<Route author="nczitzk" example="/nikkei-cn" path="/nikkei-cn/:language?/:category?/:type?" :paramsDesc="['语言,可选 `zh` 即 繁体中文,`cn` 即 简体中文', '分类,默认为空,可在对应分类页 URL 中找到','子分类,默认为空,可在对应分类页 URL 中找到']" radar="1" rssbud="1"> +<Route author="nczitzk" example="/nikkei-cn" path="/nikkei-cn/:language?/:category?/:type?" :paramsDesc="['语言,可选 `zh` 即 繁体中文,`cn` 即 简体中文', '分类,默认为空,可在对应分类页 URL 中找到', '子分类,默认为空,可在对应分类页 URL 中找到']" radar="1" rssbud="1"> ::: tip 提示
9020861509dd1781df99f529fc7b925e0df89e87
2024-07-22 10:54:26
DIYgod
feat: update examples
false
update examples
feat
diff --git a/lib/routes/dockerhub/build.ts b/lib/routes/dockerhub/build.ts index d4565b64283c8a..84cee0105185f7 100644 --- a/lib/routes/dockerhub/build.ts +++ b/lib/routes/dockerhub/build.ts @@ -5,7 +5,7 @@ import { hash } from './utils'; export const route: Route = { path: '/build/:owner/:image/:tag?', categories: ['program-update', 'popular'], - example: '/dockerhub/build/wangqiru/ttrss', + example: '/dockerhub/build/diygod/rsshub', parameters: { owner: 'Image owner, the owner of the official image fills in the library, for example: /dockerhub/build/library/mysql', image: 'Image name', diff --git a/lib/routes/github/issue.ts b/lib/routes/github/issue.ts index 482ae11724e50b..e8079d45a1e9f5 100644 --- a/lib/routes/github/issue.ts +++ b/lib/routes/github/issue.ts @@ -12,7 +12,7 @@ import { parseDate } from '@/utils/parse-date'; export const route: Route = { path: '/issue/:user/:repo/:state?/:labels?', categories: ['programming', 'popular'], - example: '/github/issue/vuejs/core/all/wontfix', + example: '/github/issue/DIYgod/RSSHub/open', parameters: { user: 'GitHub username', repo: 'GitHub repo name', diff --git a/lib/routes/instagram/private-api/index.ts b/lib/routes/instagram/private-api/index.ts index 93c427ea6513bc..0b9e818254d6d0 100644 --- a/lib/routes/instagram/private-api/index.ts +++ b/lib/routes/instagram/private-api/index.ts @@ -60,7 +60,23 @@ export const route: Route = { path: '/:category/:key', categories: ['social-media', 'popular'], example: '/instagram/user/stefaniejoosten', - parameters: { category: 'Feed category, see table above', key: 'Username / Hashtag name' }, + parameters: { + category: { + description: 'Feed category', + default: 'user', + options: [ + { + label: 'User', + value: 'user', + }, + { + label: 'Tags', + value: 'tags', + }, + ], + }, + key: 'Username / Hashtag name', + }, features: { requireConfig: [ { diff --git a/lib/routes/rss3/index.ts b/lib/routes/rss3/index.ts index 38ee8907cca5da..f23f3aad0b9e56 100644 --- a/lib/routes/rss3/index.ts +++ b/lib/routes/rss3/index.ts @@ -5,7 +5,7 @@ import ofetch from '@/utils/ofetch'; export const route: Route = { path: '/:account/:network?/:tag?', categories: ['social-media'], - example: '/rss3/diygod.eth', + example: '/rss3/vitalik.eth', name: 'Account Activities', maintainers: ['DIYgod'], url: 'docs.rss3.io/api-reference#tag/decentralized/GET/decentralized/%7Baccount%7D', diff --git a/lib/routes/telegram/channel.ts b/lib/routes/telegram/channel.ts index c913d39ba7bcf1..6821068930edb6 100644 --- a/lib/routes/telegram/channel.ts +++ b/lib/routes/telegram/channel.ts @@ -58,7 +58,7 @@ const mediaTagDict = { export const route: Route = { path: '/channel/:username/:routeParams?', categories: ['social-media', 'popular'], - example: '/telegram/channel/awesomeDIYgod/searchQuery=twitter', + example: '/telegram/channel/awesomeRSSHub', parameters: { username: 'channel username', routeParams: `extra parameters, see the table below diff --git a/lib/routes/twitter/media.ts b/lib/routes/twitter/media.ts index d31180e15a5214..d2a155ea9fe242 100644 --- a/lib/routes/twitter/media.ts +++ b/lib/routes/twitter/media.ts @@ -5,7 +5,7 @@ import utils from './utils'; export const route: Route = { path: '/media/:id/:routeParams?', categories: ['social-media', 'popular'], - example: '/twitter/media/DIYgod', + example: '/twitter/media/_RSSHub', parameters: { id: 'username; in particular, if starts with `+`, it will be recognized as a [unique ID](https://github.com/DIYgod/RSSHub/issues/12221), e.g. `+44196397`', routeParams: 'extra parameters, see the table above.' }, features: { requireConfig: [ diff --git a/lib/routes/twitter/user.ts b/lib/routes/twitter/user.ts index 038220a2564ec6..d3422945955646 100644 --- a/lib/routes/twitter/user.ts +++ b/lib/routes/twitter/user.ts @@ -5,7 +5,7 @@ import api from './api'; export const route: Route = { path: '/user/:id/:routeParams?', categories: ['social-media', 'popular'], - example: '/twitter/user/DIYgod', + example: '/twitter/user/_RSSHub', parameters: { id: 'username; in particular, if starts with `+`, it will be recognized as a [unique ID](https://github.com/DIYgod/RSSHub/issues/12221), e.g. `+44196397`', routeParams: diff --git a/lib/routes/weibo/keyword.ts b/lib/routes/weibo/keyword.ts index 8eb2619c3bfae2..2f11268170fd4b 100644 --- a/lib/routes/weibo/keyword.ts +++ b/lib/routes/weibo/keyword.ts @@ -10,7 +10,7 @@ import { config } from '@/config'; export const route: Route = { path: '/keyword/:keyword/:routeParams?', categories: ['social-media', 'popular'], - example: '/weibo/keyword/DIYgod', + example: '/weibo/keyword/RSSHub', parameters: { keyword: '你想订阅的微博关键词', routeParams: '额外参数;请参阅上面的说明和表格' }, features: { requireConfig: false,
bbfdeec0e636a39f1e450ff826dfca82b180271a
2020-07-20 12:47:14
DIYgod
docs: remove sponsor lizhi
false
remove sponsor lizhi
docs
diff --git a/README.md b/README.md index f0770e4daf5365..fc631a953c0d99 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ RSSHub 是一个开源、简单易用、易于扩展的 RSS 生成器,可以 ### Special Sponsors <div> -<a href="https://rixcloud.app/rsshub" target="_blank"><img height="60px" src="https://i.imgur.com/TrgP3S1.png"></a>&nbsp;&nbsp;&nbsp;<a href="https://angelia.codeeer.com" target="_blank"><img height="60px" src="https://i.imgur.com/oQf2WJl.png"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="http://authing.cn" target="_blank"><img height="55px" src="https://i.imgur.com/n4RieVC.png"></a>&nbsp;&nbsp;&nbsp;<a href="https://store.lizhi.io/site/index/cid/lbqqzcg3" target="_blank"><img height="60px" src="https://i.imgur.com/1u6jJ6L.jpg"></a> +<a href="https://rixcloud.app/rsshub" target="_blank"><img height="60px" src="https://i.imgur.com/TrgP3S1.png"></a>&nbsp;&nbsp;&nbsp;<a href="https://angelia.codeeer.com" target="_blank"><img height="60px" src="https://i.imgur.com/oQf2WJl.png"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="http://authing.cn" target="_blank"><img height="55px" src="https://i.imgur.com/n4RieVC.png"></a> </div> ### Sponsors diff --git a/docs/README.md b/docs/README.md index 821b491908fb95..97ea97466b8ac8 100644 --- a/docs/README.md +++ b/docs/README.md @@ -28,7 +28,6 @@ RSSHub 是一个开源、简单易用、易于扩展的 RSS 生成器,可以 <a style="margin-right: 10px;" href="https://rixcloud.app/rsshub" target="_blank"><img alt="rixCloud" height="60px" src="https://cn-south-17-rsshub-16857749.oss.dogecdn.com/rixcloud.png"></a> <a style="margin-right: 10px;" href="https://angelia.codeeer.com" target="_blank"><img alt="期待" height="60px" src="https://cn-south-17-rsshub-16857749.oss.dogecdn.com/angelia.png"></a> <a style="margin-right: 10px;margin-left: 10px;" href="http://authing.cn" target="_blank"><img alt="Authing" height="55px" src="https://cn-south-17-rsshub-16857749.oss.dogecdn.com/authing.png"></a> -<a style="margin-right: 10px;" href="https://store.lizhi.io/site/index/cid/lbqqzcg3" target="_blank"><img alt="荔枝数码" height="60px" src="https://cn-south-17-rsshub-16857749.oss.dogecdn.com/lizhi.jpg"></a> ### Sponsors diff --git a/docs/en/README.md b/docs/en/README.md index 9e09a3ad651fe7..ee668f5bd5039e 100644 --- a/docs/en/README.md +++ b/docs/en/README.md @@ -26,7 +26,6 @@ RSSHub delivers millions of contents aggregated from all kinds of sources, our v <a style="margin-right: 10px;" href="https://rixcloud.app/rsshub" target="_blank"><img height="60px" src="https://i.imgur.com/TrgP3S1.png"></a> <a style="margin-right: 10px;" href="https://angelia.codeeer.com" target="_blank"><img height="60px" src="https://i.imgur.com/oQf2WJl.png"></a> <a style="margin-right: 10px;margin-left: 10px;" href="http://authing.cn" target="_blank"><img height="55px" src="https://i.imgur.com/n4RieVC.png"></a> -<a style="margin-right: 10px;" href="https://store.lizhi.io/site/index/cid/lbqqzcg3" target="_blank"><img height="60px" src="https://i.imgur.com/1u6jJ6L.jpg"></a> ### Sponsors
41daa4c2bcbf411c125a7df9c8f5c2f743db08fa
2019-12-08 00:09:09
codeeer
feat: 优化片源网 title 展示 (#3541)
false
优化片源网 title 展示 (#3541)
feat
diff --git a/lib/routes/pianyuan/app.js b/lib/routes/pianyuan/app.js index 9f4aec3cde73eb..e7cc2fef4a55cb 100644 --- a/lib/routes/pianyuan/app.js +++ b/lib/routes/pianyuan/app.js @@ -37,9 +37,11 @@ module.exports = async (ctx) => { .find('td:nth-child(2)') .text(); + const description_simple = description.substr(0, description.indexOf('主演')).replace(text, ''); + items.push({ - title: `[${size}] ${text}`, - description: description, + title: `[${size}] ${description_simple}`, + description: `${description}`, link: link_base + link, }); });
43f1d1813d298b796e492bebb989427df261ebe6
2022-03-13 18:41:12
Fatpandac
fix(route): sohu_mp can not get author's link and refactor to V2 (#9311)
false
sohu_mp can not get author's link and refactor to V2 (#9311)
fix
diff --git a/lib/router.js b/lib/router.js index e5bc0c12ab1d9d..a1a8cacadd6da7 100644 --- a/lib/router.js +++ b/lib/router.js @@ -2071,9 +2071,6 @@ router.get('/nciae/xsxx', lazyloadRouteHandler('./routes/universities/nciae/xsxx // cfan router.get('/cfan/news', lazyloadRouteHandler('./routes/cfan/news')); -// 搜狐 - 搜狐号 -router.get('/sohu/mp/:id', lazyloadRouteHandler('./routes/sohu/mp')); - // 腾讯企鹅号 router.get('/tencent/news/author/:mid', lazyloadRouteHandler('./routes/tencent/news/author')); diff --git a/lib/v2/sohu/maintainer.js b/lib/v2/sohu/maintainer.js new file mode 100644 index 00000000000000..da817c8d9571c9 --- /dev/null +++ b/lib/v2/sohu/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/mp/:id': ['HenryQW'], +}; diff --git a/lib/routes/sohu/mp.js b/lib/v2/sohu/mp.js similarity index 70% rename from lib/routes/sohu/mp.js rename to lib/v2/sohu/mp.js index 4f265dbc380dc7..ffa4dea4ddb799 100644 --- a/lib/routes/sohu/mp.js +++ b/lib/v2/sohu/mp.js @@ -1,12 +1,12 @@ const got = require('@/utils/got'); const cheerio = require('cheerio'); -const date = require('@/utils/date'); +const { parseDate } = require('@/utils/parse-date'); module.exports = async (ctx) => { const { id } = ctx.params; + const authorArticleAPI = `https://v2.sohu.com/author-page-api/author-articles/pc/${id}`; - const response = await got.get(`https://v2.sohu.com/author-page-api/author-articles/pc/${id}`); - + const response = await got.get(authorArticleAPI); const list = response.data.data.pcArticleVOS.splice(0, 10); let author, link; @@ -23,9 +23,10 @@ module.exports = async (ctx) => { const $ = cheerio.load(response); if (!author) { - const meta = $('#article-container h4 > a'); - author = meta.text(); - link = meta.attr('href').split('==')[0]; + const meta = $('span[data-role="original-link"]'); + author = meta.find('a').text(); + // can't get author's link on server, so use the RSSHub link + // link = meta.attr('href').split('==')[0]; } const article = $('#mp-editor'); @@ -38,11 +39,11 @@ module.exports = async (ctx) => { title: e.title, link: e.link, description: article.html(), - pubDate: date(e.publicTimeStr, 8), + pubDate: parseDate(e.publicTime), author, }; - return Promise.resolve(single); + return single; }) ); diff --git a/lib/v2/sohu/radar.js b/lib/v2/sohu/radar.js new file mode 100644 index 00000000000000..3ceba885fa734b --- /dev/null +++ b/lib/v2/sohu/radar.js @@ -0,0 +1,13 @@ +module.exports = { + 'sohu.com': { + _name: '搜狐', + '.': [ + { + title: '搜狐号', + docs: 'https://docs.rsshub.app/new-media.html#sou-hu-hao', + source: ['/a/:id'], + target: (params) => `/sohu/mp/${params.id.split('_')[1]}`, + }, + ], + }, +}; diff --git a/lib/v2/sohu/router.js b/lib/v2/sohu/router.js new file mode 100644 index 00000000000000..761175b49ec1d5 --- /dev/null +++ b/lib/v2/sohu/router.js @@ -0,0 +1,3 @@ +module.exports = function (router) { + router.get('/mp/:id', require('./mp')); +};
0c8fe12889e8d626095e003091108c3b0fe0c509
2022-02-18 20:33:39
Tony
chore: parallel test (#9139)
false
parallel test (#9139)
chore
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 61fae65ac3a3cd..11a33525e2cd04 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -3,20 +3,17 @@ name: test on: [push, pull_request] jobs: - build: + jest: runs-on: ubuntu-latest - services: redis: image: redis ports: - 6379/tcp options: --entrypoint redis-server - strategy: matrix: node-version: ['14', '16'] - name: Node ${{ matrix.node-version }} steps: - uses: actions/checkout@v2 @@ -28,8 +25,23 @@ jobs: - run: npm run jest env: REDIS_URL: redis://localhost:${{ job.services.redis.ports[6379] }}/ - - run: npm run docs:build - name: Upload coverage to Codecov uses: codecov/[email protected] with: token: ${{ secrets.CODECOV_TOKEN }} + + docs: + runs-on: ubuntu-latest + strategy: + matrix: + node-version: ['14', '16'] + name: Node ${{ matrix.node-version }} + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + with: + node-version: ${{ matrix.node-version }} + cache: 'yarn' + - run: yarn + - name: Build docs + run: npm run docs:build
276132cef17eec249a08512f260f9dcb493a9a92
2023-02-03 00:45:28
github-actions[bot]
style: auto format
false
auto format
style
diff --git a/yarn.lock b/yarn.lock index d913c3d89ac991..a16f9e70c8ba9f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3375,10 +3375,11 @@ brotli@^1.3.3: dependencies: base64-js "^1.1.2" -browser-request@*: - version "0.3.3" - resolved "https://registry.yarnpkg.com/browser-request/-/browser-request-0.3.3.tgz#9ece5b5aca89a29932242e18bf933def9876cc17" - integrity sha512-YyNI4qJJ+piQG6MMEuo7J3Bzaqssufx04zpEKYfSrl/1Op59HWali9zMtBpXnkmqMcOuWJPZvudrm9wISmnCbg== +"browser-request@github:postlight/browser-request#feat-add-headers-to-response": + version "0.3.2" + resolved "https://codeload.github.com/postlight/browser-request/tar.gz/38faa5b85741aabfca61aa37d1ef044d68969ddf" + dependencies: + http-headers "^3.0.1" browserify-aes@^1.0.0, browserify-aes@^1.0.4: version "1.2.0" @@ -7255,6 +7256,13 @@ http-errors@~1.6.2: setprototypeof "1.1.0" statuses ">= 1.4.0 < 2" +http-headers@^3.0.1: + version "3.0.2" + resolved "https://registry.yarnpkg.com/http-headers/-/http-headers-3.0.2.tgz#5147771292f0b39d6778d930a3a59a76fc7ef44d" + integrity sha512-87E1I+2Wg4dxxz4rcxElo3dxO/w1ZtgL1yA0Sb6vH3qU16vRKq1NjWQv9SCY3ly2OQROcoxHZOUpmelS+k6wOw== + dependencies: + next-line "^1.1.0" + http-incoming@^0.12.0: version "0.12.0" resolved "https://registry.yarnpkg.com/http-incoming/-/http-incoming-0.12.0.tgz#10783cd2b5deb8ca92ab3ff2ad171315d61b4ff6" @@ -8559,7 +8567,7 @@ [email protected]: import-local "^3.0.2" jest-cli "^29.4.1" -jquery@*: +jquery@^3.5.0: version "3.6.3" resolved "https://registry.yarnpkg.com/jquery/-/jquery-3.6.3.tgz#23ed2ffed8a19e048814f13391a19afcdba160e6" integrity sha512-bZ5Sy3YzKo9Fyc8wH2iIQK4JImJ6R0GWI9kL1/k7Z91ZBNgkRXE6U0JfHIizZbort8ZunhSI3jw9I6253ahKfg== @@ -9887,10 +9895,10 @@ [email protected]: resolved "https://registry.yarnpkg.com/moment-parseformat/-/moment-parseformat-3.0.0.tgz#3a1dc438b4bc073b7e93cc298cfb6c5daac26dba" integrity sha512-dVgXe6b6DLnv4CHG7a1zUe5mSXaIZ3c6lSHm/EKeVeQI2/4pwe0VRde8OyoCE1Ro2lKT5P6uT9JElF7KDLV+jw== -moment-timezone@*: - version "0.5.40" - resolved "https://registry.yarnpkg.com/moment-timezone/-/moment-timezone-0.5.40.tgz#c148f5149fd91dd3e29bf481abc8830ecba16b89" - integrity sha512-tWfmNkRYmBkPJz5mr9GVDn9vRlVZOTe6yqY92rFxiOdWXbjaR0+9LwQnZGGuNR63X456NqmEkbskte8tWL5ePg== [email protected]: + version "0.5.37" + resolved "https://registry.yarnpkg.com/moment-timezone/-/moment-timezone-0.5.37.tgz#adf97f719c4e458fdb12e2b4e87b8bec9f4eef1e" + integrity sha512-uEDzDNFhfaywRl+vwXxffjjq1q0Vzr+fcQpQ1bU0kbzorfS7zVtZnCnGc8mhWmF39d4g4YriF6kwA75mJKE/Zg== dependencies: moment ">= 2.9.0" @@ -10016,6 +10024,11 @@ netmask@^2.0.1: resolved "https://registry.yarnpkg.com/netmask/-/netmask-2.0.2.tgz#8b01a07644065d536383835823bc52004ebac5e7" integrity sha512-dBpDMdxv9Irdq66304OLfEmQ9tbNRFnFTuZiLo+bD+r332bBmMJ8GBLXklIXXgxd3+v9+KUnZaUR5PJMa75Gsg== +next-line@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/next-line/-/next-line-1.1.0.tgz#fcae57853052b6a9bae8208e40dd7d3c2d304603" + integrity sha512-+I10J3wKNoKddNxn0CNpoZ3eTZuqxjNM3b1GImVx22+ePI+Y15P8g/j3WsbP0fhzzrFzrtjOAoq5NCCucswXOQ== + nice-try@^1.0.4: version "1.0.5" resolved "https://registry.yarnpkg.com/nice-try/-/nice-try-1.0.5.tgz#a3378a7696ce7d223e88fc9b764bd7ef1089e366"
a4b0476788789d98853f2876be9ba78bab2bfbc5
2022-01-23 00:34:50
Ethan Shen
feat(route): add 日本经济新闻中文版 (#8802)
false
add 日本经济新闻中文版 (#8802)
feat
diff --git a/docs/traditional-media.md b/docs/traditional-media.md index 8025186cb7270f..43408ac08a8ed0 100644 --- a/docs/traditional-media.md +++ b/docs/traditional-media.md @@ -1163,6 +1163,24 @@ category 对应的关键词有 </Route> +## 日本经济新闻中文版 + +### 新闻 + +<Route author="nczitzk" example="/nikkei-cn" path="/nikkei-cn/:language?/:category?/:type?" :paramsDesc="['语言,可选 `zh` 即 繁体中文,`cn` 即 简体中文', '分类,默认为空,可在对应分类页 URL 中找到','子分类,默认为空,可在对应分类页 URL 中找到']" radar="1" rssbud="1"> + +::: tip 提示 + +如 [中国 经济 日经中文网](https://cn.nikkei.com/china/ceconomy.html) 的 URL 为 <https://cn.nikkei.com/china/ceconomy.html> 对应路由为 [`/nikkei-cn/cn/china/ceconomy`](https://rsshub.app/nikkei-cn/cn/china/ceconomy) + +如 [中國 經濟 日經中文網](https://zh.cn.nikkei.com/china/ceconomy.html) 的 URL 为 <https://zh.cn.nikkei.com/china/ceconomy.html> 对应路由为 [`/nikkei-cn/zh/china/ceconomy`](https://rsshub.app/nikkei-cn/zh/china/ceconomy) + +特别地,当 `category` 填入 `rss` 后(即路由为 [`/nikkei-cn/cn/rss`](https://rsshub.app/nikkei-cn/cn/rss)),此时返回的是 [官方 RSS 的内容](https://cn.nikkei.com/rss.html) + +::: + +</Route> + ## 日本経済新聞 ### ホームページ diff --git a/lib/v2/nikkei-cn/index.js b/lib/v2/nikkei-cn/index.js new file mode 100644 index 00000000000000..f9f73944bcba6f --- /dev/null +++ b/lib/v2/nikkei-cn/index.js @@ -0,0 +1,77 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const timezone = require('@/utils/timezone'); +const { parseDate } = require('@/utils/parse-date'); + +const cleanContent = (language, content) => { + switch (language) { + case 'cn': { + return content.replace(/<strong>版权声明:日本经济新闻社版权所有,未经授权不得转载或部分复制,违者必究。<\/strong>/g, ''); + } + case 'zh': { + return content.replace(/<strong>版權聲明:日本經濟新聞社版權所有,未經授權不得轉載或部分複製,違者必究。<\/strong>/g, ''); + } + } +}; + +module.exports = async (ctx) => { + const language = ctx.params.language ?? 'cn'; + const category = ctx.params.category ?? ''; + const type = ctx.params.type ?? ''; + + const rootUrl = `https://${language === 'zh' ? `zh.cn` : language}.nikkei.com`; + const currentUrl = `${rootUrl}/${category ? (category === 'rss' ? 'rss.html' : `${category}${type ? `/${type}` : ''}.html`) : ''}`; + + const response = await got({ + method: 'get', + url: currentUrl, + }); + + const $ = cheerio.load(response.data); + + let items = + category === 'rss' + ? response.data.match(/<link>(http:\/\/.*\.html)<\/link>/g).map((l) => ({ + link: l.replace(/<(\/)?link>/g, '').replace(/http:/g, 'https:'), + })) + : $('dt a') + .slice(0, ctx.query.limit ? parseInt(ctx.query.limit) : 25) + .toArray() + .map((item) => { + item = $(item); + + const link = item.attr('href'); + + return { + link: `${link.indexOf('http') === 0 ? '' : rootUrl}${link}`, + }; + }); + + items = await Promise.all( + items.map((item) => + ctx.cache.tryGet(item.link, async () => { + const detailResponse = await got({ + method: 'get', + url: `${item.link}?tmpl=component&print=1`, + }); + + const content = cheerio.load(detailResponse.data); + + content('#contentDiv div').first().remove(); + + item.author = content('meta[name="author"]').attr('content'); + item.title = content('meta[name="twitter:title"]').attr('content'); + item.description = cleanContent(language, content('#contentDiv').html()); + item.pubDate = timezone(parseDate(item.link.match(/(\d{4}-\d{2}-\d{2}-\d{2}-\d{2}-\d{2})/)[1], 'YYYY-MM-DD-HH-mm-ss'), +9); + + return item; + }) + ) + ); + + ctx.state.data = { + title: $('title').first().text(), + link: currentUrl, + item: items, + }; +}; diff --git a/lib/v2/nikkei-cn/maintainer.js b/lib/v2/nikkei-cn/maintainer.js new file mode 100644 index 00000000000000..99bc6b570a3eee --- /dev/null +++ b/lib/v2/nikkei-cn/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/:language?/:category?/:type?': ['nczitzk'], +}; diff --git a/lib/v2/nikkei-cn/radar.js b/lib/v2/nikkei-cn/radar.js new file mode 100644 index 00000000000000..23d6430a29e88a --- /dev/null +++ b/lib/v2/nikkei-cn/radar.js @@ -0,0 +1,21 @@ +module.exports = { + 'nikkei.com': { + _name: '日本经济新闻', + cn: [ + { + title: '新闻', + docs: 'https://docs.rsshub.app/traditional-media.html#ri-ben-jing-ji-xin-wen-zhong-wen-ban-xin-wen', + source: '/', + target: '/nikkei-cn/cn/:category?/:type?', + }, + ], + zh: [ + { + title: '新聞', + docs: 'https://docs.rsshub.app/traditional-media.html#ri-ben-jing-ji-xin-wen-zhong-wen-ban-xin-wen', + source: '/', + target: '/nikkei-cn/zh/:category?/:type?', + }, + ], + }, +}; diff --git a/lib/v2/nikkei-cn/router.js b/lib/v2/nikkei-cn/router.js new file mode 100644 index 00000000000000..e24b05124f4c37 --- /dev/null +++ b/lib/v2/nikkei-cn/router.js @@ -0,0 +1,3 @@ +module.exports = function (router) { + router.get('/:language?/:category?/:type?', require('./index')); +};
466e687c5aac6a7dc2a151b5d3ef76933d095c5d
2023-04-29 23:52:26
DIYgod
docs: update readme
false
update readme
docs
diff --git a/README.md b/README.md index ce9d5ee18528ef..1fb1589d62828f 100644 --- a/README.md +++ b/README.md @@ -33,14 +33,6 @@ RSSHub 是一个开源、简单易用、易于扩展的 RSS 生成器,可以 ## Special Thanks -### Special Sponsors - -<p> -<a href="https://rss3.io/" target="_blank"><img height="50px" src="https://i.imgur.com/vHtI4bz.png"></a> -</p> - -[![](https://opencollective.com/static/images/become_sponsor.svg)](https://docs.rsshub.app/en/support/) - ### Contributors [![](https://opencollective.com/RSSHub/contributors.svg?width=890)](https://github.com/DIYgod/RSSHub/graphs/contributors)
4ab64e9791e2d72b787c8cabaa2093e235f9757f
2020-05-14 22:59:07
dependabot-preview[bot]
chore(deps-dev): bump nodemon from 2.0.3 to 2.0.4
false
bump nodemon from 2.0.3 to 2.0.4
chore
diff --git a/package.json b/package.json index 14df7607a3dd5a..5a338c244331f9 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "mockdate": "2.0.5", "nock": "13.0.0-beta.4", "nodejieba": "2.4.1", - "nodemon": "2.0.3", + "nodemon": "2.0.4", "pinyin": "2.9.1", "prettier": "2.0.5", "prettier-check": "2.0.0", diff --git a/yarn.lock b/yarn.lock index 681c3f8cc0861b..af33bf61a4f070 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8671,10 +8671,10 @@ [email protected]: resolved "https://registry.yarnpkg.com/nodemailer/-/nodemailer-6.4.0.tgz#91482ebc09d39156d933eb9e6159642cd27bf02c" integrity sha512-UBqPOfQGD1cM3HnjhuQe+0u3DWx47WWK7lBjG5UtPnGOysr7oDK5lNCzcjK6zzeBSdTk4m1tGx1xNbWFZQmMNA== [email protected]: - version "2.0.3" - resolved "https://registry.yarnpkg.com/nodemon/-/nodemon-2.0.3.tgz#e9c64df8740ceaef1cb00e1f3da57c0a93ef3714" - integrity sha512-lLQLPS90Lqwc99IHe0U94rDgvjo+G9I4uEIxRG3evSLROcqQ9hwc0AxlSHKS4T1JW/IMj/7N5mthiN58NL/5kw== [email protected]: + version "2.0.4" + resolved "https://registry.yarnpkg.com/nodemon/-/nodemon-2.0.4.tgz#55b09319eb488d6394aa9818148c0c2d1c04c416" + integrity sha512-Ltced+hIfTmaS28Zjv1BM552oQ3dbwPqI4+zI0SLgq+wpJhSyqgYude/aZa/3i31VCQWMfXJVxvu86abcam3uQ== dependencies: chokidar "^3.2.2" debug "^3.2.6"
0b832b38d2833bdcbd593f82eba0239b6d2fe19d
2022-02-16 22:00:39
Fatpandac
fix(route): beijing/kw handling external links (#9123)
false
beijing/kw handling external links (#9123)
fix
diff --git a/lib/v2/gov/beijing/kw/index.js b/lib/v2/gov/beijing/kw/index.js index f6bb0143b8d448..935e31066362a3 100644 --- a/lib/v2/gov/beijing/kw/index.js +++ b/lib/v2/gov/beijing/kw/index.js @@ -19,7 +19,7 @@ module.exports = async (ctx) => { const result = item.match(/urls\[i]='(.*?)';headers\[i]="(.*?)";year\[i]='(\d+)';month\[i]='(\d+)';day\[i]='(\d+)';/); return { title: cheerio.load(result[2])('a').attr('title') || result[2], - link: `${rootUrl}${result[1]}`, + link: new URL(result[1], rootUrl).href, pubDate: parseDate(`${result[3]}-${result[4]}-${result[5]}`, 'YYYY-MM-DD'), }; });
9b73129d6d52e3a62e2bdd9c46318f8da3ac4f01
2022-02-25 03:39:40
dependabot[bot]
chore(deps): bump @sentry/node from 6.17.9 to 6.18.0 (#9193)
false
bump @sentry/node from 6.17.9 to 6.18.0 (#9193)
chore
diff --git a/package.json b/package.json index 26a1534290e8a8..89955cb3d8590e 100644 --- a/package.json +++ b/package.json @@ -78,7 +78,7 @@ "dependencies": { "@koa/router": "10.1.1", "@postlight/mercury-parser": "2.2.1", - "@sentry/node": "6.17.9", + "@sentry/node": "6.18.0", "aes-js": "3.1.2", "art-template": "4.13.2", "bbcodejs": "0.0.4", diff --git a/yarn.lock b/yarn.lock index a7c74e9ea5199e..d7ac99de884971 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1436,72 +1436,72 @@ domhandler "^4.2.0" selderee "^0.6.0" -"@sentry/[email protected]": - version "6.17.9" - resolved "https://registry.yarnpkg.com/@sentry/core/-/core-6.17.9.tgz#1c09f1f101207952566349a1921d46db670c8f62" - integrity sha512-14KalmTholGUtgdh9TklO+jUpyQ/D3OGkhlH1rnGQGoJgFy2eYm+s+MnUEMxFdGIUCz5kOteuNqYZxaDmFagpQ== - dependencies: - "@sentry/hub" "6.17.9" - "@sentry/minimal" "6.17.9" - "@sentry/types" "6.17.9" - "@sentry/utils" "6.17.9" +"@sentry/[email protected]": + version "6.18.0" + resolved "https://registry.yarnpkg.com/@sentry/core/-/core-6.18.0.tgz#9ebfff67265cbe1af29f1cce0f712d9bd36b331f" + integrity sha512-I3iQVfMWHXR/LtevJg83aD7UAiUBLz1xAW8y3gd5lJej96UNv/4TbCmKZumYnEJMXf8EcFlg8t48W0Bl1GxhEg== + dependencies: + "@sentry/hub" "6.18.0" + "@sentry/minimal" "6.18.0" + "@sentry/types" "6.18.0" + "@sentry/utils" "6.18.0" tslib "^1.9.3" -"@sentry/[email protected]": - version "6.17.9" - resolved "https://registry.yarnpkg.com/@sentry/hub/-/hub-6.17.9.tgz#f2c355088a49045e49feafb5356ca5d6e1e31d3c" - integrity sha512-34EdrweWDbBV9EzEFIXcO+JeoyQmKzQVJxpTKZoJA6PUwf2NrndaUdjlkDEtBEzjuLUTxhLxtOzEsYs1O6RVcg== +"@sentry/[email protected]": + version "6.18.0" + resolved "https://registry.yarnpkg.com/@sentry/hub/-/hub-6.18.0.tgz#8c425bc340b2792c5ac9c6feed2f444d9b7f5bb7" + integrity sha512-E2GrrNcidyT67ONU3btHO5vyS1bPQNdWqC09sUc1F3q/nQyvc7L2W09TKY2veaMZQtC9EU760fTG1hMmgGwPmw== dependencies: - "@sentry/types" "6.17.9" - "@sentry/utils" "6.17.9" + "@sentry/types" "6.18.0" + "@sentry/utils" "6.18.0" tslib "^1.9.3" -"@sentry/[email protected]": - version "6.17.9" - resolved "https://registry.yarnpkg.com/@sentry/minimal/-/minimal-6.17.9.tgz#0edca978097b3f56463ede028395d40adbf2ae84" - integrity sha512-T3PMCHcKk6lkZq6zKgANrYJJxXBXKOe+ousV1Fas1rVBMv7dtKfsa4itqQHszcW9shusPDiaQKIJ4zRLE5LKmg== +"@sentry/[email protected]": + version "6.18.0" + resolved "https://registry.yarnpkg.com/@sentry/minimal/-/minimal-6.18.0.tgz#03da29b45b62b3073fbd110e423608ada17ef52c" + integrity sha512-QkkWOhX3NMycUNLj96thMQ0BclmfxE2VdDf9ZqRkvdFzxI1FVY5NEArqD4wtlrCIoYN1ioAYrvdb48/BTuGung== dependencies: - "@sentry/hub" "6.17.9" - "@sentry/types" "6.17.9" + "@sentry/hub" "6.18.0" + "@sentry/types" "6.18.0" tslib "^1.9.3" -"@sentry/[email protected]": - version "6.17.9" - resolved "https://registry.yarnpkg.com/@sentry/node/-/node-6.17.9.tgz#9a13e2fa1739a6b334eb6aa9e1e022d2c4083cb3" - integrity sha512-jbn+q7qPGOh6D7nYoYGaAlmuvMDpQmyMwBtUVYybuZp2AALe43O3Z4LtoJ+1+F31XowpsIPZx1mwNs4ZrILskA== - dependencies: - "@sentry/core" "6.17.9" - "@sentry/hub" "6.17.9" - "@sentry/tracing" "6.17.9" - "@sentry/types" "6.17.9" - "@sentry/utils" "6.17.9" +"@sentry/[email protected]": + version "6.18.0" + resolved "https://registry.yarnpkg.com/@sentry/node/-/node-6.18.0.tgz#b1dbeb2a405597c119a56c621a7867d148efaaaa" + integrity sha512-gESzabgJSs3uuOpZQ4tdI3V0k1nl9fqToTHOJDMeOqusHYfY/wlRDtdvN0Qn+vdvkGI/Eh3u8RnFQXCzkbCAbQ== + dependencies: + "@sentry/core" "6.18.0" + "@sentry/hub" "6.18.0" + "@sentry/tracing" "6.18.0" + "@sentry/types" "6.18.0" + "@sentry/utils" "6.18.0" cookie "^0.4.1" https-proxy-agent "^5.0.0" lru_map "^0.3.3" tslib "^1.9.3" -"@sentry/[email protected]": - version "6.17.9" - resolved "https://registry.yarnpkg.com/@sentry/tracing/-/tracing-6.17.9.tgz#d4a6d96d88f10c9cd496e5b32f44d6e67d4c5dc7" - integrity sha512-5Rb/OS4ryNJLvz2nv6wyjwhifjy6veqaF9ffLrwFYij/WDy7m62ASBblxgeiI3fbPLX0aBRFWIJAq1vko26+AQ== +"@sentry/[email protected]": + version "6.18.0" + resolved "https://registry.yarnpkg.com/@sentry/tracing/-/tracing-6.18.0.tgz#c9678f1c095eb58abec4de5ffd33f00420d2cbbe" + integrity sha512-thwVrYT+ba58h6F6Im4t+JH9o+7H+75ribkeTgM7NRhNuiGajlXNmb37Dh9gP5Iy76jNV8GATy4cOcuVc7P1jA== dependencies: - "@sentry/hub" "6.17.9" - "@sentry/minimal" "6.17.9" - "@sentry/types" "6.17.9" - "@sentry/utils" "6.17.9" + "@sentry/hub" "6.18.0" + "@sentry/minimal" "6.18.0" + "@sentry/types" "6.18.0" + "@sentry/utils" "6.18.0" tslib "^1.9.3" -"@sentry/[email protected]": - version "6.17.9" - resolved "https://registry.yarnpkg.com/@sentry/types/-/types-6.17.9.tgz#d579c33cde0301adaf8ff4762479ad017bf0dffa" - integrity sha512-xuulX6qUCL14ayEOh/h6FUIvZtsi1Bx34dSOaWDrjXUOJHJAM7214uiqW1GZxPJ13YuaUIubjTSfDmSQ9CBzTw== +"@sentry/[email protected]": + version "6.18.0" + resolved "https://registry.yarnpkg.com/@sentry/types/-/types-6.18.0.tgz#89cee850d16c88621459d9f2a7f6cff9e9d3fb5f" + integrity sha512-SypDwXL1URE/XLkP4Ve+pFs41e+2OUYZ0lCimNreQQv46//pFXxP3LwU9Tc0Az4ZfxXnGiwofvt73XyBq9VpRQ== -"@sentry/[email protected]": - version "6.17.9" - resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-6.17.9.tgz#425fe9af4e2d6114c2e9aaede75ccb6ddf91fbda" - integrity sha512-4eo9Z3JlJCGlGrQRbtZWL+L9NnlUXgTbfK3Lk7oO8D1ev8R5b5+iE6tZHTvU5rQRcq6zu+POT+tK5u9oxc/rnQ== +"@sentry/[email protected]": + version "6.18.0" + resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-6.18.0.tgz#99ad577020a269e43629feb6305c121065c992d1" + integrity sha512-mKegOabkAjoUHfokjI5oi3CMez5GD3xXOrBFcLVc9GFDXCgNMdYnHyEn/mmy8PikFdGHxZ3oI/16ZGU22wi5aw== dependencies: - "@sentry/types" "6.17.9" + "@sentry/types" "6.18.0" tslib "^1.9.3" "@sindresorhus/is@^0.14.0":
6e26d8c8cda0d3d5cbaa97d8008602ecbd64aa89
2023-05-02 10:51:57
Raidou
feat(route): support limit parameter in bilibili channel & collection (#12421)
false
support limit parameter in bilibili channel & collection (#12421)
feat
diff --git a/lib/v2/bilibili/userChannel.js b/lib/v2/bilibili/userChannel.js index c082e6ba6fc6f3..4e1a0a813115dc 100644 --- a/lib/v2/bilibili/userChannel.js +++ b/lib/v2/bilibili/userChannel.js @@ -11,6 +11,7 @@ module.exports = async (ctx) => { const uid = parseInt(ctx.params.uid); const sid = parseInt(ctx.params.sid); const disableEmbed = ctx.params.disableEmbed; + const limit = ctx.query.limit ?? 25; const link = `https://space.bilibili.com/${uid}/channel/seriesdetail?sid=${sid}`; @@ -31,7 +32,7 @@ module.exports = async (ctx) => { return; } const [userName, face] = await cache.getUsernameAndFaceFromUID(ctx, uid); - const host = `https://api.bilibili.com/x/series/archives?mid=${uid}&series_id=${sid}&only_normal=true&sort=desc&pn=1&ps=10`; + const host = `https://api.bilibili.com/x/series/archives?mid=${uid}&series_id=${sid}&only_normal=true&sort=desc&pn=1&ps=${limit}`; const response = await got(host, { headers: { diff --git a/lib/v2/bilibili/userCollection.js b/lib/v2/bilibili/userCollection.js index f092c9de1a178e..f613d2677a3f1b 100644 --- a/lib/v2/bilibili/userCollection.js +++ b/lib/v2/bilibili/userCollection.js @@ -11,9 +11,11 @@ module.exports = async (ctx) => { const uid = parseInt(ctx.params.uid); const sid = parseInt(ctx.params.sid); const disableEmbed = ctx.params.disableEmbed; + const limit = ctx.query.limit ?? 25; + const link = `https://space.bilibili.com/${uid}/channel/collectiondetail?sid=${sid}`; const [userName, face] = await cache.getUsernameAndFaceFromUID(ctx, uid); - const host = `https://api.bilibili.com/x/polymer/space/seasons_archives_list?mid=${uid}&season_id=${sid}&sort_reverse=true&page_num=1&page_size=10`; + const host = `https://api.bilibili.com/x/polymer/space/seasons_archives_list?mid=${uid}&season_id=${sid}&sort_reverse=true&page_num=1&page_size=${limit}`; const response = await got(host, { headers: {
7c5fcaccc596135a5b400d46469a25612c67031a
2019-06-13 09:04:39
Chenyang Shi
fix: 在filter之前检查空数据 (#2392)
false
在filter之前检查空数据 (#2392)
fix
diff --git a/lib/middleware/parameter.js b/lib/middleware/parameter.js index 8dd288c5feff0e..044acd9f2c56f3 100644 --- a/lib/middleware/parameter.js +++ b/lib/middleware/parameter.js @@ -3,6 +3,10 @@ const he = require('he'); module.exports = async (ctx, next) => { await next(); + if (ctx.state.data && ctx.state.data.item.length === 0) { + throw Error('该路由目前获取内容为空,请检查源站情况或前往https://github.com/DIYgod/RSSHub/issues反馈该问题'); + } + // decode HTML entities if (ctx.state.data) { ctx.state.data.title && (ctx.state.data.title = he.decode(ctx.state.data.title + ''));
fd195401adc8bd33e70cb0c59144833c1dd1848c
2021-03-13 03:36:15
dependabot-preview[bot]
chore(deps-dev): bump eslint from 7.21.0 to 7.22.0
false
bump eslint from 7.21.0 to 7.22.0
chore
diff --git a/package.json b/package.json index 684a356f85171d..e48e8ff1addb29 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "@vuepress/plugin-google-analytics": "1.8.2", "@vuepress/plugin-pwa": "1.8.2", "cross-env": "7.0.3", - "eslint": "7.21.0", + "eslint": "7.22.0", "eslint-config-prettier": "8.1.0", "eslint-plugin-prettier": "3.3.1", "jest": "26.6.3", diff --git a/yarn.lock b/yarn.lock index 20c6302402cea2..786f1408691425 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5089,10 +5089,10 @@ eslint-visitor-keys@^2.0.0: resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-2.0.0.tgz#21fdc8fbcd9c795cc0321f0563702095751511a8" integrity sha512-QudtT6av5WXels9WjIM7qz1XD1cWGvX4gGXvp/zBn9nXG02D0utdU3Em2m/QjTnrsk6bBjmCygl3rmj118msQQ== [email protected]: - version "7.21.0" - resolved "https://registry.yarnpkg.com/eslint/-/eslint-7.21.0.tgz#4ecd5b8c5b44f5dedc9b8a110b01bbfeb15d1c83" - integrity sha512-W2aJbXpMNofUp0ztQaF40fveSsJBjlSCSWpy//gzfTvwC+USs/nceBrKmlJOiM8r1bLwP2EuYkCqArn/6QTIgg== [email protected]: + version "7.22.0" + resolved "https://registry.yarnpkg.com/eslint/-/eslint-7.22.0.tgz#07ecc61052fec63661a2cab6bd507127c07adc6f" + integrity sha512-3VawOtjSJUQiiqac8MQc+w457iGLfuNGLFn8JmF051tTKbh5/x/0vlcEj8OgDCaw7Ysa2Jn8paGshV7x2abKXg== dependencies: "@babel/code-frame" "7.12.11" "@eslint/eslintrc" "^0.4.0" @@ -5111,7 +5111,7 @@ [email protected]: file-entry-cache "^6.0.1" functional-red-black-tree "^1.0.1" glob-parent "^5.0.0" - globals "^12.1.0" + globals "^13.6.0" ignore "^4.0.6" import-fresh "^3.0.0" imurmurhash "^0.1.4" @@ -5119,7 +5119,7 @@ [email protected]: js-yaml "^3.13.1" json-stable-stringify-without-jsonify "^1.0.1" levn "^0.4.1" - lodash "^4.17.20" + lodash "^4.17.21" minimatch "^3.0.4" natural-compare "^1.4.0" optionator "^0.9.1" @@ -5983,6 +5983,13 @@ globals@^12.1.0: dependencies: type-fest "^0.8.1" +globals@^13.6.0: + version "13.6.0" + resolved "https://registry.yarnpkg.com/globals/-/globals-13.6.0.tgz#d77138e53738567bb96a3916ff6f6b487af20ef7" + integrity sha512-YFKCX0SiPg7l5oKYCJ2zZGxcXprVXHcSnVuvzrT3oSENQonVLqM5pf9fN5dLGZGyCjhw8TN8Btwe/jKnZ0pjvQ== + dependencies: + type-fest "^0.20.2" + globby@^6.1.0: version "6.1.0" resolved "https://registry.yarnpkg.com/globby/-/globby-6.1.0.tgz#f5a6d70e8395e21c858fb0489d64df02424d506c" @@ -8315,10 +8322,10 @@ lodash.uniq@^4.5.0: resolved "https://registry.yarnpkg.com/lodash.uniq/-/lodash.uniq-4.5.0.tgz#d0225373aeb652adc1bc82e4945339a842754773" integrity sha1-0CJTc662Uq3BvILklFM5qEJ1R3M= -lodash@^4.15.0, lodash@^4.17.11, lodash@^4.17.13, lodash@^4.17.15, lodash@^4.17.19, lodash@^4.17.20, lodash@^4.17.3, lodash@^4.17.5: - version "4.17.20" - resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.20.tgz#b44a9b6297bcb698f1c51a3545a2b3b368d59c52" - integrity sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA== +lodash@^4.15.0, lodash@^4.17.11, lodash@^4.17.13, lodash@^4.17.15, lodash@^4.17.19, lodash@^4.17.20, lodash@^4.17.21, lodash@^4.17.3, lodash@^4.17.5: + version "4.17.21" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c" + integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg== logform@^2.2.0: version "2.2.0" @@ -12680,6 +12687,11 @@ type-fest@^0.10.0: resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.10.0.tgz#7f06b2b9fbfc581068d1341ffabd0349ceafc642" integrity sha512-EUV9jo4sffrwlg8s0zDhP0T2WD3pru5Xi0+HTE3zTUmBaZNhfkite9PdSJwdXLwPVW0jnAHT56pZHIOYckPEiw== +type-fest@^0.20.2: + version "0.20.2" + resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.20.2.tgz#1bf207f4b28f91583666cb5fbd327887301cd5f4" + integrity sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ== + type-fest@^0.3.0: version "0.3.1" resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.3.1.tgz#63d00d204e059474fe5e1b7c011112bbd1dc29e1"
44c9853541657a5c0090e71be906bca8709593c3
2024-03-06 22:47:21
DIYgod
feat: replace require with import 7/n
false
replace require with import 7/n
feat
diff --git a/lib/routes/12306/zxdt.ts b/lib/routes/12306/zxdt.ts index cf27ba013dfacf..164159352f1da7 100644 --- a/lib/routes/12306/zxdt.ts +++ b/lib/routes/12306/zxdt.ts @@ -1,7 +1,7 @@ import cache from '@/utils/cache'; import got from '@/utils/got'; import { load } from 'cheerio'; -const url = require('url'); +import * as url from 'node:url'; export default async (ctx) => { const id = ctx.req.param('id') || -1; diff --git a/lib/routes/163/dy2.ts b/lib/routes/163/dy2.ts index f249afb5f7ed60..66ee621704e13f 100644 --- a/lib/routes/163/dy2.ts +++ b/lib/routes/163/dy2.ts @@ -1,7 +1,7 @@ import cache from '@/utils/cache'; import got from '@/utils/got'; import { load } from 'cheerio'; -const iconv = require('iconv-lite'); +import iconv from 'iconv-lite'; import { parseDate } from '@/utils/parse-date'; import timezone from '@/utils/timezone'; import { parseDyArticle } from './utils'; diff --git a/lib/routes/163/news/rank.ts b/lib/routes/163/news/rank.ts index 7db04339a54e66..6cc37f65a235c0 100644 --- a/lib/routes/163/news/rank.ts +++ b/lib/routes/163/news/rank.ts @@ -1,7 +1,7 @@ import cache from '@/utils/cache'; import got from '@/utils/got'; import { load } from 'cheerio'; -const iconv = require('iconv-lite'); +import iconv from 'iconv-lite'; import { parseDate } from '@/utils/parse-date'; const rootUrl = 'https://news.163.com'; diff --git a/lib/routes/163/renjian.ts b/lib/routes/163/renjian.ts index f097f950addc8a..a50a5d2f285f75 100644 --- a/lib/routes/163/renjian.ts +++ b/lib/routes/163/renjian.ts @@ -1,7 +1,7 @@ import cache from '@/utils/cache'; import got from '@/utils/got'; import { load } from 'cheerio'; -const iconv = require('iconv-lite'); +import iconv from 'iconv-lite'; import { parseDate } from '@/utils/parse-date'; import timezone from '@/utils/timezone'; diff --git a/lib/routes/163/utils.ts b/lib/routes/163/utils.ts index a1ab93de160ff3..61fa5beae9de9f 100644 --- a/lib/routes/163/utils.ts +++ b/lib/routes/163/utils.ts @@ -3,7 +3,7 @@ const __dirname = getCurrentPath(import.meta.url); import got from '@/utils/got'; import { load } from 'cheerio'; -const iconv = require('iconv-lite'); +import iconv from 'iconv-lite'; import { art } from '@/utils/render'; import * as path from 'node:path'; diff --git a/lib/routes/19lou/index.ts b/lib/routes/19lou/index.ts index 530fe4c846de79..97be42443bd46d 100644 --- a/lib/routes/19lou/index.ts +++ b/lib/routes/19lou/index.ts @@ -3,7 +3,7 @@ import got from '@/utils/got'; import { load } from 'cheerio'; import timezone from '@/utils/timezone'; import { parseDate } from '@/utils/parse-date'; -const iconv = require('iconv-lite'); +import iconv from 'iconv-lite'; import { isValidHost } from '@/utils/valid-host'; const setCookie = function (cookieName, cookieValue, seconds, path, domain, secure) { diff --git a/lib/routes/1point3acres/utils.ts b/lib/routes/1point3acres/utils.ts index 07054a9b347cd8..7c13fcaeac3f0f 100644 --- a/lib/routes/1point3acres/utils.ts +++ b/lib/routes/1point3acres/utils.ts @@ -5,7 +5,7 @@ import got from '@/utils/got'; import { parseDate } from '@/utils/parse-date'; import { art } from '@/utils/render'; import * as path from 'node:path'; -const bbcode = require('bbcodejs'); +import bbcode from 'bbcodejs'; const rootUrl = 'https://instant.1point3acres.com'; const apiRootUrl = 'https://api.1point3acres.com'; diff --git a/lib/routes/2cycd/index.ts b/lib/routes/2cycd/index.ts index 418ccc5d0bc0a3..d0d355ae7a8cab 100644 --- a/lib/routes/2cycd/index.ts +++ b/lib/routes/2cycd/index.ts @@ -3,7 +3,7 @@ import got from '@/utils/got'; import { load } from 'cheerio'; import { parseDate } from '@/utils/parse-date'; import timezone from '@/utils/timezone'; -const iconv = require('iconv-lite'); +import iconv from 'iconv-lite'; // http://www.2cycd.com/forum.php?mod=forumdisplay&fid=43&orderby=dateline diff --git a/lib/routes/36kr/utils.ts b/lib/routes/36kr/utils.ts index c17b8d6fe03c05..857713c0e60f13 100644 --- a/lib/routes/36kr/utils.ts +++ b/lib/routes/36kr/utils.ts @@ -1,6 +1,6 @@ import got from '@/utils/got'; import { load } from 'cheerio'; -const CryptoJS = require('crypto-js'); +import CryptoJS from 'crypto-js'; const rootUrl = 'https://www.36kr.com'; diff --git a/lib/routes/4ksj/forum.ts b/lib/routes/4ksj/forum.ts index 9003c5ea128a7a..a54ff7eebb68ab 100644 --- a/lib/routes/4ksj/forum.ts +++ b/lib/routes/4ksj/forum.ts @@ -8,7 +8,7 @@ import timezone from '@/utils/timezone'; import { parseDate } from '@/utils/parse-date'; import { art } from '@/utils/render'; import * as path from 'node:path'; -const iconv = require('iconv-lite'); +import iconv from 'iconv-lite'; export default async (ctx) => { const id = ctx.req.param('id') ?? '2-1'; diff --git a/lib/routes/56kog/util.ts b/lib/routes/56kog/util.ts index 16a2244a7a6a81..e37c0133da509f 100644 --- a/lib/routes/56kog/util.ts +++ b/lib/routes/56kog/util.ts @@ -3,7 +3,7 @@ const __dirname = getCurrentPath(import.meta.url); import got from '@/utils/got'; import { load } from 'cheerio'; -const iconv = require('iconv-lite'); +import iconv from 'iconv-lite'; import timezone from '@/utils/timezone'; import { parseDate } from '@/utils/parse-date'; import { art } from '@/utils/render'; diff --git a/lib/routes/591/list.ts b/lib/routes/591/list.ts index 337ede19a0ae25..d97b6836ff648a 100644 --- a/lib/routes/591/list.ts +++ b/lib/routes/591/list.ts @@ -3,7 +3,7 @@ const __dirname = getCurrentPath(import.meta.url); import * as path from 'node:path'; -const { CookieJar } = require('tough-cookie'); +import { CookieJar } from 'tough-cookie'; import { load } from 'cheerio'; import got from '@/utils/got'; diff --git a/lib/routes/5eplay/index.ts b/lib/routes/5eplay/index.ts index 144764f7abfa76..86e81b64074817 100644 --- a/lib/routes/5eplay/index.ts +++ b/lib/routes/5eplay/index.ts @@ -1,6 +1,6 @@ import cache from '@/utils/cache'; import { load } from 'cheerio'; -const zlib = require('zlib'); +import zlib from 'zlib'; import got from '@/utils/got'; import { parseDate } from '@/utils/parse-date'; import { config } from '@/config'; diff --git a/lib/routes/6v123/utils.ts b/lib/routes/6v123/utils.ts index 8bbc501c155641..72ccebc62b501c 100644 --- a/lib/routes/6v123/utils.ts +++ b/lib/routes/6v123/utils.ts @@ -1,6 +1,6 @@ import cache from '@/utils/cache'; import got from '@/utils/got'; -const iconv = require('iconv-lite'); +import iconv from 'iconv-lite'; import { load } from 'cheerio'; import timezone from '@/utils/timezone'; import { parseDate } from '@/utils/parse-date'; diff --git a/lib/routes/8264/list.ts b/lib/routes/8264/list.ts index fe9a949bb6bd16..339575922ac143 100644 --- a/lib/routes/8264/list.ts +++ b/lib/routes/8264/list.ts @@ -4,7 +4,7 @@ const __dirname = getCurrentPath(import.meta.url); import cache from '@/utils/cache'; import got from '@/utils/got'; import { load } from 'cheerio'; -const iconv = require('iconv-lite'); +import iconv from 'iconv-lite'; import timezone from '@/utils/timezone'; import { parseDate } from '@/utils/parse-date'; import { art } from '@/utils/render'; diff --git a/lib/routes/ainvest/utils.ts b/lib/routes/ainvest/utils.ts index cef8b611408ca1..9eb38ee53f1b8b 100644 --- a/lib/routes/ainvest/utils.ts +++ b/lib/routes/ainvest/utils.ts @@ -1,6 +1,6 @@ -const crypto = require('crypto'); -const CryptoJS = require('crypto-js'); -const { KJUR, KEYUTIL, hextob64 } = require('jsrsasign'); +import crypto from 'crypto'; +import CryptoJS from 'crypto-js'; +import { KJUR, KEYUTIL, hextob64 } from 'jsrsasign'; const publicKey = 'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCARnxLlrhTK28bEV7s2IROjT73KLSjfqpKIvV8L+Yhe4BrF0Ut4oOH728HZlbSF0C3N0vXZjLAFesoS4v1pYOjVCPXl920Lh2seCv82m0cK78WMGuqZTfA44Nv7JsQMHC3+J6IZm8YD53ft2d8mYBFgKektduucjx8sObe7eRyoQIDAQAB'; diff --git a/lib/routes/apiseven/blog.ts b/lib/routes/apiseven/blog.ts index 503b943cce3c75..4cdbed77a3b47c 100644 --- a/lib/routes/apiseven/blog.ts +++ b/lib/routes/apiseven/blog.ts @@ -3,7 +3,9 @@ import got from '@/utils/got'; import { load } from 'cheerio'; import { parseDate } from '@/utils/parse-date'; import timezone from '@/utils/timezone'; -const md = require('markdown-it')({ +import MarkdownIt from 'markdown-it'; + +const md = MarkdownIt({ html: true, }); diff --git a/lib/routes/app-center/release.ts b/lib/routes/app-center/release.ts index 2c7b6b3f8d94e4..d2b42376cceacc 100644 --- a/lib/routes/app-center/release.ts +++ b/lib/routes/app-center/release.ts @@ -6,7 +6,7 @@ import got from '@/utils/got'; import { parseDate } from '@/utils/parse-date'; import { art } from '@/utils/render'; import * as path from 'node:path'; -const MarkdownIt = require('markdown-it'); +import MarkdownIt from 'markdown-it'; export default async (ctx) => { const user = ctx.req.param('user'); diff --git a/lib/routes/appstore/in-app-purchase.ts b/lib/routes/appstore/in-app-purchase.ts index 411147141368d7..1a293ae9de172e 100644 --- a/lib/routes/appstore/in-app-purchase.ts +++ b/lib/routes/appstore/in-app-purchase.ts @@ -1,5 +1,5 @@ import got from '@/utils/got'; -const url = require('url'); +import * as url from 'node:url'; import { load } from 'cheerio'; export default async (ctx) => { diff --git a/lib/routes/appstore/price.ts b/lib/routes/appstore/price.ts index 518f9c4f4eeb40..785b5edc7e42df 100644 --- a/lib/routes/appstore/price.ts +++ b/lib/routes/appstore/price.ts @@ -1,5 +1,5 @@ import got from '@/utils/got'; -const currency = require('currency-symbol-map'); +import currency from 'currency-symbol-map'; export default async (ctx) => { const country = ctx.req.param('country'); const type = ctx.req.param('type').toLowerCase() === 'mac' ? 'macapps' : 'apps'; diff --git a/lib/routes/auto-stats/index.ts b/lib/routes/auto-stats/index.ts index edd7e1d8ce08f9..d94907eac3dd33 100644 --- a/lib/routes/auto-stats/index.ts +++ b/lib/routes/auto-stats/index.ts @@ -1,7 +1,7 @@ import cache from '@/utils/cache'; import got from '@/utils/got'; import { load } from 'cheerio'; -const iconv = require('iconv-lite'); +import iconv from 'iconv-lite'; import timezone from '@/utils/timezone'; import { parseDate } from '@/utils/parse-date'; diff --git a/lib/routes/baidu/tieba/search.ts b/lib/routes/baidu/tieba/search.ts index 147c30480b2298..93367486fce874 100644 --- a/lib/routes/baidu/tieba/search.ts +++ b/lib/routes/baidu/tieba/search.ts @@ -3,7 +3,7 @@ const __dirname = getCurrentPath(import.meta.url); import got from '@/utils/got'; import { load } from 'cheerio'; -const iconv = require('iconv-lite'); +import iconv from 'iconv-lite'; import timezone from '@/utils/timezone'; import { parseDate } from '@/utils/parse-date'; import { art } from '@/utils/render'; diff --git a/lib/routes/bdys/index.ts b/lib/routes/bdys/index.ts index b33d52a79c23d1..43fb13f447a78f 100644 --- a/lib/routes/bdys/index.ts +++ b/lib/routes/bdys/index.ts @@ -8,7 +8,7 @@ import { parseDate } from '@/utils/parse-date'; import timezone from '@/utils/timezone'; import { art } from '@/utils/render'; import * as path from 'node:path'; -const asyncPool = require('tiny-async-pool'); +import asyncPool from 'tiny-async-pool'; import { config } from '@/config'; // Visit https://www.bdys.me for the list of domains diff --git a/lib/routes/bigquant/collections.ts b/lib/routes/bigquant/collections.ts index e8f740afd8e3f3..304f50c8518324 100644 --- a/lib/routes/bigquant/collections.ts +++ b/lib/routes/bigquant/collections.ts @@ -1,6 +1,7 @@ import got from '@/utils/got'; import { parseDate } from '@/utils/parse-date'; -const md = require('markdown-it')({ +import MarkdownIt from 'markdown-it'; +const md = MarkdownIt({ html: true, }); diff --git a/lib/routes/bilibili/article.ts b/lib/routes/bilibili/article.ts index 26dcb3d56744c8..e9bd984b0f8803 100644 --- a/lib/routes/bilibili/article.ts +++ b/lib/routes/bilibili/article.ts @@ -4,7 +4,7 @@ import cache from './cache'; import { parseDate } from '@/utils/parse-date'; export default async (ctx) => { const uid = ctx.req.param('uid'); - const name = await cache.getUsernameFromUID(ctx, uid); + const name = await cache.getUsernameFromUID(uid); const response = await got({ method: 'get', url: `https://api.bilibili.com/x/space/article?mid=${uid}&pn=1&ps=10&sort=publish_time&jsonp=jsonp`, @@ -18,7 +18,7 @@ export default async (ctx) => { const description = `${name} 的 bilibili 专栏`; const item = await Promise.all( data.articles.map(async (item) => { - const { url: art_url, description: eDescription } = await cache.getArticleDataFromCvid(ctx, item.id, uid); + const { url: art_url, description: eDescription } = await cache.getArticleDataFromCvid(item.id, uid); const publishDate = parseDate(item.publish_time * 1000); const single = { title: item.title, diff --git a/lib/routes/bilibili/cache.ts b/lib/routes/bilibili/cache.ts index 65a3357319c5d2..c5ced0529e4274 100644 --- a/lib/routes/bilibili/cache.ts +++ b/lib/routes/bilibili/cache.ts @@ -5,253 +5,273 @@ import { load } from 'cheerio'; import { config } from '@/config'; import logger from '@/utils/logger'; -export default { - getCookie: () => { - if (Object.keys(config.bilibili.cookies).length > 0) { - return config.bilibili.cookies[Object.keys(config.bilibili.cookies)[Math.floor(Math.random() * Object.keys(config.bilibili.cookies).length)]]; - } - const key = 'bili-cookie'; - return cache.tryGet(key, async () => { - // default Referer: https://www.bilibili.com is limited - // Bilibili return cookies with multiple set-cookie - // let response = await got('https://space.bilibili.com/1'); - // const setCookie = response.headers['set-cookie']; // should contain buvid3 and b_nut - // if (typeof setCookie === 'undefined') { - // return ''; - // } - // const cookie = setCookie.map((cookie) => cookie.split(';')[0]); - const cookie = []; - cookie.push(['b_lsid', utils.lsid()].join('='), ['_uuid', utils._uuid()].join('='), ['b_nut', Date.now().toString()].join('=')); - let response = await got('https://api.bilibili.com/x/frontend/finger/spi', { +const getCookie = () => { + if (Object.keys(config.bilibili.cookies).length > 0) { + return config.bilibili.cookies[Object.keys(config.bilibili.cookies)[Math.floor(Math.random() * Object.keys(config.bilibili.cookies).length)]]; + } + const key = 'bili-cookie'; + return cache.tryGet(key, async () => { + // default Referer: https://www.bilibili.com is limited + // Bilibili return cookies with multiple set-cookie + // let response = await got('https://space.bilibili.com/1'); + // const setCookie = response.headers['set-cookie']; // should contain buvid3 and b_nut + // if (typeof setCookie === 'undefined') { + // return ''; + // } + // const cookie = setCookie.map((cookie) => cookie.split(';')[0]); + const cookie = []; + cookie.push(['b_lsid', utils.lsid()].join('='), ['_uuid', utils._uuid()].join('='), ['b_nut', Date.now().toString()].join('=')); + let response = await got('https://api.bilibili.com/x/frontend/finger/spi', { + headers: { + Referer: 'https://www.bilibili.com/', + Cookie: cookie.join('; '), + }, + }); + cookie.push(['buvid3', encodeURIComponent(response.data.data.b_3)].join('='), ['bvuid4', encodeURIComponent(response.data.data.b_4)].join('=')); + const e = Math.floor(Date.now() / 1000); + const hexsign = utils.hexsign(e); + // await got('https://space.bilibili.com/1', { + // headers: { + // Referer: 'https://www.bilibili.com/', + // Cookie: cookie.join('; '), + // }, + // }); + try { + response = await got.post(`https://api.bilibili.com/bapis/bilibili.api.ticket.v1.Ticket/GenWebTicket?key_id=ec02&hexsign=${hexsign}&context[ts]=${e}&csrf=`, { headers: { - Referer: 'https://www.bilibili.com/', + Referer: 'https://space.bilibili.com/1', Cookie: cookie.join('; '), }, }); - cookie.push(['buvid3', encodeURIComponent(response.data.data.b_3)].join('='), ['bvuid4', encodeURIComponent(response.data.data.b_4)].join('=')); - const e = Math.floor(Date.now() / 1000); - const hexsign = utils.hexsign(e); - // await got('https://space.bilibili.com/1', { - // headers: { - // Referer: 'https://www.bilibili.com/', - // Cookie: cookie.join('; '), - // }, - // }); - try { - response = await got.post(`https://api.bilibili.com/bapis/bilibili.api.ticket.v1.Ticket/GenWebTicket?key_id=ec02&hexsign=${hexsign}&context[ts]=${e}&csrf=`, { - headers: { - Referer: 'https://space.bilibili.com/1', - Cookie: cookie.join('; '), - }, - }); - cookie.push(['bili_ticket', response.data.data.ticket].join('='), ['bili_ticket_expires', (Number.parseInt(response.data.data.created_at) + Number.parseInt(response.data.data.ttl)).toString()].join('=')); - } catch { - // HTTPError: Response code 429 (Too Many Requests) - } + cookie.push(['bili_ticket', response.data.data.ticket].join('='), ['bili_ticket_expires', (Number.parseInt(response.data.data.created_at) + Number.parseInt(response.data.data.ttl)).toString()].join('=')); + } catch { + // HTTPError: Response code 429 (Too Many Requests) + } - return cookie.join('; '); + return cookie.join('; '); + }); +}; + +const getWbiVerifyString = () => { + const key = 'bili-wbi-verify-string'; + return cache.tryGet(key, async () => { + const cookie = await getCookie(); + const { data: navResponse } = await got('https://api.bilibili.com/x/web-interface/nav', { + headers: { + Referer: 'https://www.bilibili.com/', + Cookie: cookie, + }, }); - }, - getWbiVerifyString: (ctx) => { - const key = 'bili-wbi-verify-string'; - return cache.tryGet(key, async () => { - const cookie = await module.exports.getCookie(ctx); - const { data: navResponse } = await got('https://api.bilibili.com/x/web-interface/nav', { - headers: { - Referer: 'https://www.bilibili.com/', - Cookie: cookie, - }, - }); - const imgUrl = navResponse.data.wbi_img.img_url; - const subUrl = navResponse.data.wbi_img.sub_url; - const r = imgUrl.substring(imgUrl.lastIndexOf('/') + 1, imgUrl.length).split('.')[0] + subUrl.substring(subUrl.lastIndexOf('/') + 1, subUrl.length).split('.')[0]; - // const { body: spaceResponse } = await got('https://space.bilibili.com/1', { - // headers: { - // Referer: 'https://www.bilibili.com/', - // Cookie: cookie, - // }, - // }); - // const jsUrl = 'https:' + spaceResponse.match(/[^"]*9.space[^"]*/); - const jsUrl = 'https://s1.hdslb.com/bfs/seed/laputa-header/bili-header.umd.js'; - const { body: jsResponse } = await got(jsUrl, { - headers: { - Referer: 'https://space.bilibili.com/1', - }, - }); - // const array = [ - // 46, 47, 18, 2, 53, 8, 23, 32, 15, 50, 10, 31, 58, 3, 45, 35, 27, 43, 5, 49, 33, 9, 42, 19, 29, 28, 14, 39, 12, 38, 41, 13, 37, 48, 7, 16, 24, 55, 40, 61, 26, 17, 0, 1, 60, 51, 30, 4, 22, 25, 54, 21, 56, 59, 6, 63, 57, - // 62, 11, 36, 20, 34, 44, 52, - // ]; - const array = JSON.parse(jsResponse.match(/\[(?:\d+,){63}\d+]/)); - const o = []; - for (const t of array) { - r.charAt(t) && o.push(r.charAt(t)); - } - return o.join('').slice(0, 32); + const imgUrl = navResponse.data.wbi_img.img_url; + const subUrl = navResponse.data.wbi_img.sub_url; + const r = imgUrl.substring(imgUrl.lastIndexOf('/') + 1, imgUrl.length).split('.')[0] + subUrl.substring(subUrl.lastIndexOf('/') + 1, subUrl.length).split('.')[0]; + // const { body: spaceResponse } = await got('https://space.bilibili.com/1', { + // headers: { + // Referer: 'https://www.bilibili.com/', + // Cookie: cookie, + // }, + // }); + // const jsUrl = 'https:' + spaceResponse.match(/[^"]*9.space[^"]*/); + const jsUrl = 'https://s1.hdslb.com/bfs/seed/laputa-header/bili-header.umd.js'; + const { body: jsResponse } = await got(jsUrl, { + headers: { + Referer: 'https://space.bilibili.com/1', + }, }); - }, - getUsernameFromUID: (ctx, uid) => { - const key = 'bili-username-from-uid-' + uid; - return cache.tryGet(key, async () => { - const cookie = await module.exports.getCookie(ctx); - const wbiVerifyString = await module.exports.getWbiVerifyString(ctx); - // await got(`https://space.bilibili.com/${uid}/`, { - // headers: { - // Referer: 'https://www.bilibili.com/', - // Cookie: cookie, - // }, - // }); - const params = utils.addWbiVerifyInfo(`mid=${uid}&token=&platform=web&web_location=1550101`, wbiVerifyString); - const { data: nameResponse } = await got(`https://api.bilibili.com/x/space/wbi/acc/info?${params}`, { - headers: { - Referer: `https://space.bilibili.com/${uid}/`, - Cookie: cookie, - }, - }); - return nameResponse.data ? nameResponse.data.name : undefined; + // const array = [ + // 46, 47, 18, 2, 53, 8, 23, 32, 15, 50, 10, 31, 58, 3, 45, 35, 27, 43, 5, 49, 33, 9, 42, 19, 29, 28, 14, 39, 12, 38, 41, 13, 37, 48, 7, 16, 24, 55, 40, 61, 26, 17, 0, 1, 60, 51, 30, 4, 22, 25, 54, 21, 56, 59, 6, 63, 57, + // 62, 11, 36, 20, 34, 44, 52, + // ]; + const array = JSON.parse(jsResponse.match(/\[(?:\d+,){63}\d+]/)); + const o = []; + for (const t of array) { + r.charAt(t) && o.push(r.charAt(t)); + } + return o.join('').slice(0, 32); + }); +}; + +const getUsernameFromUID = (uid) => { + const key = 'bili-username-from-uid-' + uid; + return cache.tryGet(key, async () => { + const cookie = await getCookie(); + const wbiVerifyString = await getWbiVerifyString(); + // await got(`https://space.bilibili.com/${uid}/`, { + // headers: { + // Referer: 'https://www.bilibili.com/', + // Cookie: cookie, + // }, + // }); + const params = utils.addWbiVerifyInfo(`mid=${uid}&token=&platform=web&web_location=1550101`, wbiVerifyString); + const { data: nameResponse } = await got(`https://api.bilibili.com/x/space/wbi/acc/info?${params}`, { + headers: { + Referer: `https://space.bilibili.com/${uid}/`, + Cookie: cookie, + }, }); - }, - getUsernameAndFaceFromUID: async (ctx, uid) => { - const nameKey = 'bili-username-from-uid-' + uid; - const faceKey = 'bili-userface-from-uid-' + uid; - let name = await cache.get(nameKey); - let face = await cache.get(faceKey); - if (!name || !face) { - const cookie = await module.exports.getCookie(ctx); - const wbiVerifyString = await module.exports.getWbiVerifyString(ctx); - // await got(`https://space.bilibili.com/${uid}/`, { - // headers: { - // Referer: `https://www.bilibili.com/`, - // Cookie: cookie, - // }, - // }); - const params = utils.addWbiVerifyInfo(`mid=${uid}&token=&platform=web&web_location=1550101`, wbiVerifyString); - const { data: nameResponse } = await got(`https://api.bilibili.com/x/space/wbi/acc/info?${params}`, { - headers: { - Referer: `https://space.bilibili.com/${uid}/`, - Cookie: cookie, - }, - }); - if (nameResponse.data.name) { - name = nameResponse.data.name; - face = nameResponse.data.face; - } else { - logger.error(`Error when visiting /x/space/wbi/acc/info: ${JSON.stringify(nameResponse)}`); - } - cache.set(nameKey, name); - cache.set(faceKey, face); + return nameResponse.data ? nameResponse.data.name : undefined; + }); +}; + +const getUsernameAndFaceFromUID = async (uid) => { + const nameKey = 'bili-username-from-uid-' + uid; + const faceKey = 'bili-userface-from-uid-' + uid; + let name = await cache.get(nameKey); + let face = await cache.get(faceKey); + if (!name || !face) { + const cookie = await getCookie(); + const wbiVerifyString = await getWbiVerifyString(); + // await got(`https://space.bilibili.com/${uid}/`, { + // headers: { + // Referer: `https://www.bilibili.com/`, + // Cookie: cookie, + // }, + // }); + const params = utils.addWbiVerifyInfo(`mid=${uid}&token=&platform=web&web_location=1550101`, wbiVerifyString); + const { data: nameResponse } = await got(`https://api.bilibili.com/x/space/wbi/acc/info?${params}`, { + headers: { + Referer: `https://space.bilibili.com/${uid}/`, + Cookie: cookie, + }, + }); + if (nameResponse.data.name) { + name = nameResponse.data.name; + face = nameResponse.data.face; + } else { + logger.error(`Error when visiting /x/space/wbi/acc/info: ${JSON.stringify(nameResponse)}`); } - return [name, face]; - }, - getLiveIDFromShortID: (ctx, shortID) => { - const key = `bili-liveID-from-shortID-${shortID}`; - return cache.tryGet(key, async () => { - const { data: liveIDResponse } = await got(`https://api.live.bilibili.com/room/v1/Room/room_init?id=${shortID}`, { - headers: { - Referer: `https://live.bilibili.com/${shortID}`, - }, - }); - return liveIDResponse.data.room_id; + cache.set(nameKey, name); + cache.set(faceKey, face); + } + return [name, face]; +}; + +const getLiveIDFromShortID = (shortID) => { + const key = `bili-liveID-from-shortID-${shortID}`; + return cache.tryGet(key, async () => { + const { data: liveIDResponse } = await got(`https://api.live.bilibili.com/room/v1/Room/room_init?id=${shortID}`, { + headers: { + Referer: `https://live.bilibili.com/${shortID}`, + }, }); - }, - getUsernameFromLiveID: (ctx, liveID) => { - const key = `bili-username-from-liveID-${liveID}`; - return cache.tryGet(key, async () => { - const { data: nameResponse } = await got(`https://api.live.bilibili.com/live_user/v1/UserInfo/get_anchor_in_room?roomid=${liveID}`, { - headers: { - Referer: `https://live.bilibili.com/${liveID}`, - }, - }); - return nameResponse.data.info.uname; + return liveIDResponse.data.room_id; + }); +}; + +const getUsernameFromLiveID = (liveID) => { + const key = `bili-username-from-liveID-${liveID}`; + return cache.tryGet(key, async () => { + const { data: nameResponse } = await got(`https://api.live.bilibili.com/live_user/v1/UserInfo/get_anchor_in_room?roomid=${liveID}`, { + headers: { + Referer: `https://live.bilibili.com/${liveID}`, + }, }); - }, - getVideoNameFromId: (ctx, aid, bvid) => { - const key = `bili-videoname-from-id-${bvid || aid}`; - return cache.tryGet(key, async () => { - const { data } = await got(`https://api.bilibili.com/x/web-interface/view`, { - searchParams: { - aid: aid || undefined, - bvid: bvid || undefined, - }, - referer: `https://www.bilibili.com/video/${bvid || `av${aid}`}`, - }); - return data.data.title; + return nameResponse.data.info.uname; + }); +}; + +const getVideoNameFromId = (aid, bvid) => { + const key = `bili-videoname-from-id-${bvid || aid}`; + return cache.tryGet(key, async () => { + const { data } = await got(`https://api.bilibili.com/x/web-interface/view`, { + searchParams: { + aid: aid || undefined, + bvid: bvid || undefined, + }, + referer: `https://www.bilibili.com/video/${bvid || `av${aid}`}`, }); - }, - getCidFromId: (ctx, aid, pid, bvid) => { - const key = `bili-cid-from-id-${bvid || aid}-${pid}`; - return cache.tryGet(key, async () => { - const { data } = await got(`https://api.bilibili.com/x/web-interface/view?${bvid ? `bvid=${bvid}` : `aid=${aid}`}`, { - referer: `https://www.bilibili.com/video/${bvid || `av${aid}`}`, - }); - return data.data.pages[pid - 1].cid; + return data.data.title; + }); +}; + +const getCidFromId = (aid, pid, bvid) => { + const key = `bili-cid-from-id-${bvid || aid}-${pid}`; + return cache.tryGet(key, async () => { + const { data } = await got(`https://api.bilibili.com/x/web-interface/view?${bvid ? `bvid=${bvid}` : `aid=${aid}`}`, { + referer: `https://www.bilibili.com/video/${bvid || `av${aid}`}`, }); - }, - getAidFromBvid: async (ctx, bvid) => { - const key = `bili-cid-from-bvid-${bvid}`; - let aid = await cache.get(key); - if (!aid) { - const response = await got(`https://api.bilibili.com/x/web-interface/view?bvid=${bvid}`, { - headers: { - Referer: `https://www.bilibili.com/video/${bvid}`, - }, - }); - if (response.data && response.data.data && response.data.data.aid) { - aid = response.data.data.aid; - } - cache.set(key, aid); + return data.data.pages[pid - 1].cid; + }); +}; + +const getAidFromBvid = async (bvid) => { + const key = `bili-cid-from-bvid-${bvid}`; + let aid = await cache.get(key); + if (!aid) { + const response = await got(`https://api.bilibili.com/x/web-interface/view?bvid=${bvid}`, { + headers: { + Referer: `https://www.bilibili.com/video/${bvid}`, + }, + }); + if (response.data && response.data.data && response.data.data.aid) { + aid = response.data.data.aid; } - return aid; - }, - getArticleDataFromCvid: async (ctx, cvid, uid) => { - const url = `https://www.bilibili.com/read/cv${cvid}/`; - const data = await cache.tryGet( - url, - async () => - ( - await got({ - method: 'get', - url, - headers: { - Referer: `https://space.bilibili.com/${uid}/`, - }, - }) - ).data - ); - const $ = load(data); - let description = $('#read-article-holder').html(); - if (!description) { - try { - const newFormatData = JSON.parse( - $('script:contains("window.__INITIAL_STATE__")') - .text() - .match(/window\.__INITIAL_STATE__\s*=\s*(.*?);\(/)[1] - ); + cache.set(key, aid); + } + return aid; +}; - if (newFormatData?.readInfo?.opus?.content?.paragraphs) { - description = ''; - for (const element of newFormatData.readInfo.opus.content.paragraphs) { - if (element.para_type === 1) { - for (const text of element.text.nodes) { - if (text?.word?.words) { - description += `<p>${text.word.words}</p>`; - } - } - } - if (element.para_type === 2) { - for (const image of element.pic.pics) { - description += `<p ><img src="${image.url}@progressive.webp"></p>`; +const getArticleDataFromCvid = async (cvid, uid) => { + const url = `https://www.bilibili.com/read/cv${cvid}/`; + const data = await cache.tryGet( + url, + async () => + ( + await got({ + method: 'get', + url, + headers: { + Referer: `https://space.bilibili.com/${uid}/`, + }, + }) + ).data + ); + const $ = load(data); + let description = $('#read-article-holder').html(); + if (!description) { + try { + const newFormatData = JSON.parse( + $('script:contains("window.__INITIAL_STATE__")') + .text() + .match(/window\.__INITIAL_STATE__\s*=\s*(.*?);\(/)[1] + ); + + if (newFormatData?.readInfo?.opus?.content?.paragraphs) { + description = ''; + for (const element of newFormatData.readInfo.opus.content.paragraphs) { + if (element.para_type === 1) { + for (const text of element.text.nodes) { + if (text?.word?.words) { + description += `<p>${text.word.words}</p>`; } } - if (element.para_type === 3 && element.line?.pic?.url) { - description += `<figure><img src="${element.line.pic.url}"></figure>`; + } + if (element.para_type === 2) { + for (const image of element.pic.pics) { + description += `<p ><img src="${image.url}@progressive.webp"></p>`; } } + if (element.para_type === 3 && element.line?.pic?.url) { + description += `<figure><img src="${element.line.pic.url}"></figure>`; + } } - } catch { - /* empty */ } + } catch { + /* empty */ } - return { url, description }; - }, + } + return { url, description }; +}; + +export default { + getCookie, + getWbiVerifyString, + getUsernameFromUID, + getUsernameAndFaceFromUID, + getLiveIDFromShortID, + getUsernameFromLiveID, + getVideoNameFromId, + getCidFromId, + getAidFromBvid, + getArticleDataFromCvid, }; diff --git a/lib/routes/bilibili/coin.ts b/lib/routes/bilibili/coin.ts index 200f0d64f03202..e79a0d810f13c3 100644 --- a/lib/routes/bilibili/coin.ts +++ b/lib/routes/bilibili/coin.ts @@ -7,7 +7,7 @@ export default async (ctx) => { const uid = ctx.req.param('uid'); const disableEmbed = ctx.req.param('disableEmbed'); - const name = await cache.getUsernameFromUID(ctx, uid); + const name = await cache.getUsernameFromUID(uid); const response = await got({ url: `https://api.bilibili.com/x/space/coin/video?vmid=${uid}`, diff --git a/lib/routes/bilibili/danmaku.ts b/lib/routes/bilibili/danmaku.ts index bb4cab8c53f51c..870dceb89db373 100644 --- a/lib/routes/bilibili/danmaku.ts +++ b/lib/routes/bilibili/danmaku.ts @@ -1,7 +1,7 @@ import { load } from 'cheerio'; import cache from './cache'; import got from '@/utils/got'; -const zlib = require('zlib'); +import zlib from 'zlib'; const processFloatTime = (time) => { const totalSeconds = Number.parseInt(time); @@ -20,9 +20,9 @@ export default async (ctx) => { } const pid = Number(ctx.req.param('pid') || 1); const limit = 50; - const cid = await cache.getCidFromId(ctx, aid, pid, bvid); + const cid = await cache.getCidFromId(aid, pid, bvid); - const videoName = await cache.getVideoNameFromId(ctx, aid, bvid); + const videoName = await cache.getVideoNameFromId(aid, bvid); const link = `https://www.bilibili.com/video/${bvid || `av${aid}`}`; const danmakuResponse = await got.get(`https://comment.bilibili.com/${cid}.xml`, { diff --git a/lib/routes/bilibili/dynamic.ts b/lib/routes/bilibili/dynamic.ts index e7b06e95a7b187..a8015a8746493c 100644 --- a/lib/routes/bilibili/dynamic.ts +++ b/lib/routes/bilibili/dynamic.ts @@ -1,6 +1,6 @@ import cache from '@/utils/cache'; import got from '@/utils/got'; -const JSONbig = require('json-bigint'); +import JSONbig from 'json-bigint'; import utils from './utils'; import { parseDate } from '@/utils/parse-date'; import { fallback, queryToBoolean } from '@/utils/readable-social'; @@ -86,7 +86,7 @@ export default async (ctx) => { }); const cards = JSONbig.parse(response.body).data.cards; - const usernameAndFace = await cacheIn.getUsernameAndFaceFromUID(ctx, uid); + const usernameAndFace = await cacheIn.getUsernameAndFaceFromUID(uid); const author = usernameAndFace[0] ?? cards[0]?.desc?.user_profile?.info.uname; const face = usernameAndFace[1] ?? cards[0]?.desc?.user_profile?.info?.face; cache.set(`bili-username-from-uid-${uid}`, author); @@ -217,7 +217,7 @@ export default async (ctx) => { }; if (data.image_urls && displayArticle) { - data_content = (await cacheIn.getArticleDataFromCvid(ctx, data.id, uid)).description; + data_content = (await cacheIn.getArticleDataFromCvid(data.id, uid)).description; } return { diff --git a/lib/routes/bilibili/followers.ts b/lib/routes/bilibili/followers.ts index 7e33354b642152..ba9ee195e8fcba 100644 --- a/lib/routes/bilibili/followers.ts +++ b/lib/routes/bilibili/followers.ts @@ -11,7 +11,7 @@ export default async (ctx) => { throw new Error('缺少对应 loginUid 的 Bilibili 用户登录后的 Cookie 值 <a href="https://docs.rsshub.app/install/#pei-zhi-bu-fen-rss-mo-kuai-pei-zhi">bilibili 用户关注动态系列路由</a>'); } - const name = await cache.getUsernameFromUID(ctx, uid); + const name = await cache.getUsernameFromUID(uid); const countResponse = await got({ method: 'get', diff --git a/lib/routes/bilibili/followings-article.ts b/lib/routes/bilibili/followings-article.ts index d7039d2639baf9..0d5969065becd4 100644 --- a/lib/routes/bilibili/followings-article.ts +++ b/lib/routes/bilibili/followings-article.ts @@ -4,7 +4,7 @@ import { config } from '@/config'; export default async (ctx) => { const uid = String(ctx.req.param('uid')); - const name = await cache.getUsernameFromUID(ctx, uid); + const name = await cache.getUsernameFromUID(uid); const cookie = config.bilibili.cookies[uid]; if (cookie === undefined) { @@ -27,7 +27,7 @@ export default async (ctx) => { const out = await Promise.all( cards.map(async (card) => { const card_data = JSON.parse(card.card); - const { url: link, description } = await cache.getArticleDataFromCvid(ctx, card_data.id, uid); + const { url: link, description } = await cache.getArticleDataFromCvid(card_data.id, uid); const item = { title: card_data.title, diff --git a/lib/routes/bilibili/followings-dynamic.ts b/lib/routes/bilibili/followings-dynamic.ts index 86b8a8868dddf9..abb1b542fa2507 100644 --- a/lib/routes/bilibili/followings-dynamic.ts +++ b/lib/routes/bilibili/followings-dynamic.ts @@ -2,9 +2,9 @@ import got from '@/utils/got'; import cache from './cache'; import { config } from '@/config'; import utils from './utils'; -const JSONbig = require('json-bigint'); +import JSONbig from 'json-bigint'; import { fallback, queryToBoolean } from '@/utils/readable-social'; -const querystring = require('querystring'); +import querystring from 'querystring'; export default async (ctx) => { const uid = String(ctx.req.param('uid')); @@ -14,7 +14,7 @@ export default async (ctx) => { const disableEmbed = fallback(undefined, queryToBoolean(routeParams.disableEmbed), false); const displayArticle = fallback(undefined, queryToBoolean(routeParams.displayArticle), false); - const name = await cache.getUsernameFromUID(ctx, uid); + const name = await cache.getUsernameFromUID(uid); const cookie = config.bilibili.cookies[uid]; if (cookie === undefined) { @@ -123,7 +123,7 @@ export default async (ctx) => { } if (data.image_urls && displayArticle) { - data_content = (await cache.getArticleDataFromCvid(ctx, data.id, uid)).description; + data_content = (await cache.getArticleDataFromCvid(data.id, uid)).description; } return { diff --git a/lib/routes/bilibili/followings-video.ts b/lib/routes/bilibili/followings-video.ts index 5ea401fb70ca76..8c6ef292c1dee9 100644 --- a/lib/routes/bilibili/followings-video.ts +++ b/lib/routes/bilibili/followings-video.ts @@ -6,7 +6,7 @@ import utils from './utils'; export default async (ctx) => { const uid = String(ctx.req.param('uid')); const disableEmbed = ctx.req.param('disableEmbed'); - const name = await cache.getUsernameFromUID(ctx, uid); + const name = await cache.getUsernameFromUID(uid); const cookie = config.bilibili.cookies[uid]; if (cookie === undefined) { diff --git a/lib/routes/bilibili/followings.ts b/lib/routes/bilibili/followings.ts index 2041d06f2a6c59..fdf5ac3b299ca1 100644 --- a/lib/routes/bilibili/followings.ts +++ b/lib/routes/bilibili/followings.ts @@ -10,7 +10,7 @@ export default async (ctx) => { } const uid = ctx.req.param('uid'); - const name = await cache.getUsernameFromUID(ctx, uid); + const name = await cache.getUsernameFromUID(uid); const countResponse = await got({ method: 'get', diff --git a/lib/routes/bilibili/hot-search.ts b/lib/routes/bilibili/hot-search.ts index f54d36ea7defb0..9b05458bfc35c3 100644 --- a/lib/routes/bilibili/hot-search.ts +++ b/lib/routes/bilibili/hot-search.ts @@ -3,7 +3,7 @@ import cache from './cache'; import utils from './utils'; export default async (ctx) => { - const wbiVerifyString = await cache.getWbiVerifyString(ctx); + const wbiVerifyString = await cache.getWbiVerifyString(); const params = utils.addWbiVerifyInfo('limit=10&platform=web', wbiVerifyString); const url = `https://api.bilibili.com/x/web-interface/wbi/search/square?${params}`; const response = await got({ diff --git a/lib/routes/bilibili/like.ts b/lib/routes/bilibili/like.ts index 0655ecdd2b86de..41f15ea7daa298 100644 --- a/lib/routes/bilibili/like.ts +++ b/lib/routes/bilibili/like.ts @@ -7,7 +7,7 @@ export default async (ctx) => { const uid = ctx.req.param('uid'); const disableEmbed = ctx.req.param('disableEmbed'); - const name = await cache.getUsernameFromUID(ctx, uid); + const name = await cache.getUsernameFromUID(uid); const response = await got({ url: `https://api.bilibili.com/x/space/like/video?vmid=${uid}`, diff --git a/lib/routes/bilibili/live-room.ts b/lib/routes/bilibili/live-room.ts index a6eccd58b1bef8..2f21223c564b2f 100644 --- a/lib/routes/bilibili/live-room.ts +++ b/lib/routes/bilibili/live-room.ts @@ -6,9 +6,9 @@ export default async (ctx) => { // 短号查询长号 if (Number.parseInt(roomID, 10) < 10000) { - roomID = await cache.getLiveIDFromShortID(ctx, roomID); + roomID = await cache.getLiveIDFromShortID(roomID); } - const name = await cache.getUsernameFromLiveID(ctx, roomID); + const name = await cache.getUsernameFromLiveID(roomID); const response = await got({ method: 'get', diff --git a/lib/routes/bilibili/live-search.ts b/lib/routes/bilibili/live-search.ts index 0f70a65e520412..bb0ebc31f9c32f 100644 --- a/lib/routes/bilibili/live-search.ts +++ b/lib/routes/bilibili/live-search.ts @@ -17,7 +17,7 @@ export default async (ctx) => { orderTitle = '人气直播'; break; } - const wbiVerifyString = await cache.getWbiVerifyString(ctx); + const wbiVerifyString = await cache.getWbiVerifyString(); let params = `__refresh__=true&_extra=&context=&page=1&page_size=42&order=${order}&duration=&from_source=&from_spmid=333.337&platform=pc&highlight=1&single_column=0&keyword=${urlEncodedKey}&ad_resource=&source_tag=3&gaia_vtoken=&category_id=&search_type=live&dynamic_offset=0&web_location=1430654`; params = utils.addWbiVerifyInfo(params, wbiVerifyString); @@ -26,7 +26,7 @@ export default async (ctx) => { url: `https://api.bilibili.com/x/web-interface/wbi/search/type?${params}`, headers: { Referer: `https://search.bilibili.com/live?keyword=${urlEncodedKey}&from_source=webtop_search&spm_id_from=444.7&search_source=3&search_type=live_room`, - Cookie: await cache.getCookie(ctx), + Cookie: await cache.getCookie(), }, }); const data = response.data.data.result.live_room; diff --git a/lib/routes/bilibili/manga-followings.ts b/lib/routes/bilibili/manga-followings.ts index f182586558f78d..dad9e1d307b6f2 100644 --- a/lib/routes/bilibili/manga-followings.ts +++ b/lib/routes/bilibili/manga-followings.ts @@ -4,7 +4,7 @@ import { config } from '@/config'; export default async (ctx) => { const uid = String(ctx.req.param('uid')); - const name = await cache.getUsernameFromUID(ctx, uid); + const name = await cache.getUsernameFromUID(uid); const cookie = config.bilibili.cookies[uid]; if (cookie === undefined) { diff --git a/lib/routes/bilibili/reply.ts b/lib/routes/bilibili/reply.ts index 3d356ce9324e4d..24d965b5291699 100644 --- a/lib/routes/bilibili/reply.ts +++ b/lib/routes/bilibili/reply.ts @@ -8,9 +8,9 @@ export default async (ctx) => { aid = bvid; bvid = null; } - const name = await cache.getVideoNameFromId(ctx, aid, bvid); + const name = await cache.getVideoNameFromId(aid, bvid); if (!aid) { - aid = await cache.getAidFromBvid(ctx, bvid); + aid = await cache.getAidFromBvid(bvid); } const link = `https://www.bilibili.com/video/${bvid || `av${aid}`}`; diff --git a/lib/routes/bilibili/user-bangumi.ts b/lib/routes/bilibili/user-bangumi.ts index 335b0c63c94745..c79727d1625d43 100644 --- a/lib/routes/bilibili/user-bangumi.ts +++ b/lib/routes/bilibili/user-bangumi.ts @@ -5,7 +5,7 @@ export default async (ctx) => { const uid = ctx.req.param('uid'); const type = Number(ctx.req.param('type') || 1); const type_name = ((t) => ['', 'bangumi', 'cinema'][t])(type); - const name = await cache.getUsernameFromUID(ctx, uid); + const name = await cache.getUsernameFromUID(uid); const response = await got({ method: 'get', diff --git a/lib/routes/bilibili/user-channel.ts b/lib/routes/bilibili/user-channel.ts index ba31876af11e23..f35743696e836b 100644 --- a/lib/routes/bilibili/user-channel.ts +++ b/lib/routes/bilibili/user-channel.ts @@ -32,7 +32,7 @@ export default async (ctx) => { ctx.set('data', notFoundData); return; } - const [userName, face] = await cacheIn.getUsernameAndFaceFromUID(ctx, uid); + const [userName, face] = await cacheIn.getUsernameAndFaceFromUID(uid); const host = `https://api.bilibili.com/x/series/archives?mid=${uid}&series_id=${sid}&only_normal=true&sort=desc&pn=1&ps=${limit}`; const response = await got(host, { diff --git a/lib/routes/bilibili/user-collection.ts b/lib/routes/bilibili/user-collection.ts index affac3406f55bd..497a3c163af1a8 100644 --- a/lib/routes/bilibili/user-collection.ts +++ b/lib/routes/bilibili/user-collection.ts @@ -14,7 +14,7 @@ export default async (ctx) => { const limit = ctx.req.query('limit') ?? 25; const link = `https://space.bilibili.com/${uid}/channel/collectiondetail?sid=${sid}`; - const [userName, face] = await cache.getUsernameAndFaceFromUID(ctx, uid); + const [userName, face] = await cache.getUsernameAndFaceFromUID(uid); const host = `https://api.bilibili.com/x/polymer/space/seasons_archives_list?mid=${uid}&season_id=${sid}&sort_reverse=true&page_num=1&page_size=${limit}`; const response = await got(host, { diff --git a/lib/routes/bilibili/user-fav.ts b/lib/routes/bilibili/user-fav.ts index bc6bffbfa5e44d..157827cafe0e7f 100644 --- a/lib/routes/bilibili/user-fav.ts +++ b/lib/routes/bilibili/user-fav.ts @@ -6,7 +6,7 @@ import { config } from '@/config'; export default async (ctx) => { const uid = ctx.req.param('uid'); const disableEmbed = ctx.req.param('disableEmbed'); - const name = await cache.getUsernameFromUID(ctx, uid); + const name = await cache.getUsernameFromUID(uid); const response = await got({ method: 'get', diff --git a/lib/routes/bilibili/utils.ts b/lib/routes/bilibili/utils.ts index 8b9fc5c762f7e5..613e3a153b9c08 100644 --- a/lib/routes/bilibili/utils.ts +++ b/lib/routes/bilibili/utils.ts @@ -1,6 +1,6 @@ import { config } from '@/config'; import md5 from '@/utils/md5'; -const CryptoJS = require('crypto-js'); +import CryptoJS from 'crypto-js'; function iframe(aid, page, bvid) { return `<iframe src="https://www.bilibili.com/blackboard/html5mobileplayer.html?${bvid ? `bvid=${bvid}` : `aid=${aid}`}${ diff --git a/lib/routes/bilibili/video-all.ts b/lib/routes/bilibili/video-all.ts index ca78a3c1752088..20483b62d9324c 100644 --- a/lib/routes/bilibili/video-all.ts +++ b/lib/routes/bilibili/video-all.ts @@ -6,10 +6,10 @@ import { parseDate } from '@/utils/parse-date'; export default async (ctx) => { const uid = ctx.req.param('uid'); const disableEmbed = ctx.req.param('disableEmbed'); - const cookie = await cache.getCookie(ctx); - const wbiVerifyString = await cache.getWbiVerifyString(ctx); + const cookie = await cache.getCookie(); + const wbiVerifyString = await cache.getWbiVerifyString(); const dmImgList = utils.getDmImgList(); - const [name, face] = await cache.getUsernameAndFaceFromUID(ctx, uid); + const [name, face] = await cache.getUsernameAndFaceFromUID(uid); await got(`https://space.bilibili.com/${uid}/video?tid=0&page=1&keyword=&order=pubdate`, { headers: { @@ -29,7 +29,7 @@ export default async (ctx) => { const pageTotal = Math.ceil(response.data.data.page.count / response.data.data.page.ps); const getPage = async (pageId) => { - const cookie = await cache.getCookie(ctx); + const cookie = await cache.getCookie(); await got(`https://space.bilibili.com/${uid}/video?tid=0&page=${pageId}&keyword=&order=pubdate`, { headers: { Referer: `https://space.bilibili.com/${uid}/`, diff --git a/lib/routes/bilibili/video.ts b/lib/routes/bilibili/video.ts index 82397c98ada88b..e37db4777bb884 100644 --- a/lib/routes/bilibili/video.ts +++ b/lib/routes/bilibili/video.ts @@ -6,10 +6,10 @@ import logger from '@/utils/logger'; export default async (ctx) => { const uid = ctx.req.param('uid'); const disableEmbed = ctx.req.param('disableEmbed'); - const cookie = await cache.getCookie(ctx); - const wbiVerifyString = await cache.getWbiVerifyString(ctx); + const cookie = await cache.getCookie(); + const wbiVerifyString = await cache.getWbiVerifyString(); const dmImgList = utils.getDmImgList(); - const [name, face] = await cache.getUsernameAndFaceFromUID(ctx, uid); + const [name, face] = await cache.getUsernameAndFaceFromUID(uid); // await got(`https://space.bilibili.com/${uid}/video?tid=0&page=1&keyword=&order=pubdate`, { // headers: { diff --git a/lib/routes/bilibili/vsearch.ts b/lib/routes/bilibili/vsearch.ts index 49d7ad35087fc7..26cbb6e5b14c93 100644 --- a/lib/routes/bilibili/vsearch.ts +++ b/lib/routes/bilibili/vsearch.ts @@ -3,7 +3,7 @@ import { config } from '@/config'; import got from '@/utils/got'; import { parseDate } from '@/utils/parse-date'; import utils from './utils'; -const { CookieJar } = require('tough-cookie'); +import { CookieJar } from 'tough-cookie'; const cookieJar = new CookieJar(); import { queryToBoolean } from '@/utils/readable-social'; diff --git a/lib/routes/bilibili/watchlater.ts b/lib/routes/bilibili/watchlater.ts index 1dece7a0c06d56..5bbedf89d1f112 100644 --- a/lib/routes/bilibili/watchlater.ts +++ b/lib/routes/bilibili/watchlater.ts @@ -7,7 +7,7 @@ import { parseDate } from '@/utils/parse-date'; export default async (ctx) => { const uid = ctx.req.param('uid'); const disableEmbed = ctx.req.param('disableEmbed'); - const name = await cache.getUsernameFromUID(ctx, uid); + const name = await cache.getUsernameFromUID(uid); const cookie = config.bilibili.cookies[uid]; if (cookie === undefined) { diff --git a/lib/routes/bing/search.ts b/lib/routes/bing/search.ts index f3971bbca998dc..193d18e554a82c 100644 --- a/lib/routes/bing/search.ts +++ b/lib/routes/bing/search.ts @@ -1,8 +1,8 @@ import parser from '@/utils/rss-parser'; import { parseDate } from '@/utils/parse-date'; -const dayjs = require('dayjs'); -const localizedFormat = require('dayjs/plugin/localizedFormat'); -require('dayjs/locale/zh-cn'); +import dayjs from 'dayjs'; +import localizedFormat from 'dayjs/plugin/localizedFormat'; +import 'dayjs/locale/zh-cn'; dayjs.extend(localizedFormat); export default async (ctx) => { diff --git a/lib/routes/biquge/index.ts b/lib/routes/biquge/index.ts index 3a58e71c407664..43ffcb8fbd5dd7 100644 --- a/lib/routes/biquge/index.ts +++ b/lib/routes/biquge/index.ts @@ -2,7 +2,7 @@ import { getSubPath } from '@/utils/common-utils'; import cache from '@/utils/cache'; import got from '@/utils/got'; import { load } from 'cheerio'; -const iconv = require('iconv-lite'); +import iconv from 'iconv-lite'; import timezone from '@/utils/timezone'; import { parseDate } from '@/utils/parse-date'; import { config } from '@/config'; diff --git a/lib/routes/bjfu/it/index.ts b/lib/routes/bjfu/it/index.ts index 9e135ab034360e..4a7d7523ebbc0a 100644 --- a/lib/routes/bjfu/it/index.ts +++ b/lib/routes/bjfu/it/index.ts @@ -2,7 +2,7 @@ import cache from '@/utils/cache'; import got from '@/utils/got'; import { load } from 'cheerio'; import util from './utils'; -const iconv = require('iconv-lite'); +import iconv from 'iconv-lite'; export default async (ctx) => { const type = ctx.req.param('type'); diff --git a/lib/routes/bjfu/it/utils.ts b/lib/routes/bjfu/it/utils.ts index 4e7798c223f9c2..b6c1ce6d7669be 100644 --- a/lib/routes/bjfu/it/utils.ts +++ b/lib/routes/bjfu/it/utils.ts @@ -1,6 +1,6 @@ import got from '@/utils/got'; import { load } from 'cheerio'; -const iconv = require('iconv-lite'); +import iconv from 'iconv-lite'; import { parseDate } from '@/utils/parse-date'; import timezone from '@/utils/timezone'; diff --git a/lib/routes/bjfu/news/index.ts b/lib/routes/bjfu/news/index.ts index 427d2c58b05953..87e359c56b3d2b 100644 --- a/lib/routes/bjfu/news/index.ts +++ b/lib/routes/bjfu/news/index.ts @@ -2,7 +2,7 @@ import cache from '@/utils/cache'; import got from '@/utils/got'; import { load } from 'cheerio'; import util from './utils'; -const iconv = require('iconv-lite'); +import iconv from 'iconv-lite'; export default async (ctx) => { const type = ctx.req.param('type'); diff --git a/lib/routes/bjx/huanbao.ts b/lib/routes/bjx/huanbao.ts index aebcfae20c5e47..b6913fe97c2c4c 100644 --- a/lib/routes/bjx/huanbao.ts +++ b/lib/routes/bjx/huanbao.ts @@ -3,7 +3,7 @@ import got from '@/utils/got'; import { parseDate } from '@/utils/parse-date'; import { load } from 'cheerio'; import timezone from '@/utils/timezone'; -const asyncPool = require('tiny-async-pool'); +import asyncPool from 'tiny-async-pool'; const asyncPoolAll = async (...args) => { const results = []; diff --git a/lib/routes/bloomberg/utils.ts b/lib/routes/bloomberg/utils.ts index 22576efb67b5e3..8d515cdd93c117 100644 --- a/lib/routes/bloomberg/utils.ts +++ b/lib/routes/bloomberg/utils.ts @@ -4,7 +4,7 @@ const __dirname = getCurrentPath(import.meta.url); import cache from '@/utils/cache'; import { load } from 'cheerio'; import * as path from 'node:path'; -const asyncPool = require('tiny-async-pool'); +import asyncPool from 'tiny-async-pool'; import { parseDate } from '@/utils/parse-date'; import got from '@/utils/got'; diff --git a/lib/routes/bluestacks/release.ts b/lib/routes/bluestacks/release.ts index 5c0002974a545d..1a9f37dade8400 100644 --- a/lib/routes/bluestacks/release.ts +++ b/lib/routes/bluestacks/release.ts @@ -1,5 +1,5 @@ import cache from '@/utils/cache'; -const cherrio = require('cheerio'); +import cherrio from 'cheerio'; import { parseDate } from '@/utils/parse-date'; import puppeteer from '@/utils/puppeteer'; diff --git a/lib/routes/c114/roll.ts b/lib/routes/c114/roll.ts index 4ea8ec25e9bc60..f25a0ba2c2355e 100644 --- a/lib/routes/c114/roll.ts +++ b/lib/routes/c114/roll.ts @@ -3,7 +3,7 @@ import got from '@/utils/got'; import { load } from 'cheerio'; import timezone from '@/utils/timezone'; import { parseDate } from '@/utils/parse-date'; -const iconv = require('iconv-lite'); +import iconv from 'iconv-lite'; export default async (ctx) => { const rootUrl = 'https://www.c114.com.cn'; diff --git a/lib/routes/cartoonmad/comic.ts b/lib/routes/cartoonmad/comic.ts index a8b176c1aecca4..305b86990e0808 100644 --- a/lib/routes/cartoonmad/comic.ts +++ b/lib/routes/cartoonmad/comic.ts @@ -4,7 +4,7 @@ const __dirname = getCurrentPath(import.meta.url); import cache from '@/utils/cache'; import { load } from 'cheerio'; import got from '@/utils/got'; -const iconv = require('iconv-lite'); +import iconv from 'iconv-lite'; import { art } from '@/utils/render'; import * as path from 'node:path'; diff --git a/lib/routes/cas/mesalab/kb.ts b/lib/routes/cas/mesalab/kb.ts index f8cc91ca281bf7..9f36cfa363172d 100644 --- a/lib/routes/cas/mesalab/kb.ts +++ b/lib/routes/cas/mesalab/kb.ts @@ -1,5 +1,5 @@ import cache from '@/utils/cache'; -const cherrio = require('cheerio'); +import cherrio from 'cheerio'; import got from '@/utils/got'; import { parseDate } from '@/utils/parse-date'; import timezone from '@/utils/timezone'; diff --git a/lib/routes/cctv/xwlb.ts b/lib/routes/cctv/xwlb.ts index 22684639cf26ce..ef2c24f8be5aad 100644 --- a/lib/routes/cctv/xwlb.ts +++ b/lib/routes/cctv/xwlb.ts @@ -3,8 +3,8 @@ import got from '@/utils/got'; import { parseDate } from '@/utils/parse-date'; import timezone from '@/utils/timezone'; import { load } from 'cheerio'; -const dayjs = require('dayjs'); -const customParseFormat = require('dayjs/plugin/customParseFormat'); +import dayjs from 'dayjs'; +import customParseFormat from 'dayjs/plugin/customParseFormat'; dayjs.extend(customParseFormat); export default async (ctx) => { diff --git a/lib/routes/chinathinktanks/viewpoint.ts b/lib/routes/chinathinktanks/viewpoint.ts index 444d5437c7e90c..155e3a73228adc 100644 --- a/lib/routes/chinathinktanks/viewpoint.ts +++ b/lib/routes/chinathinktanks/viewpoint.ts @@ -3,7 +3,7 @@ import got from '@/utils/got'; import { load } from 'cheerio'; import { parseDate, parseRelativeDate } from '@/utils/parse-date'; import timezone from '@/utils/timezone'; -const { CookieJar } = require('tough-cookie'); +import { CookieJar } from 'tough-cookie'; const cookieJar = new CookieJar(); const baseUrl = 'https://www.chinathinktanks.org.cn'; diff --git a/lib/routes/chuanliu/nice.ts b/lib/routes/chuanliu/nice.ts index cbfc34193badb4..73e6596772befa 100644 --- a/lib/routes/chuanliu/nice.ts +++ b/lib/routes/chuanliu/nice.ts @@ -6,7 +6,8 @@ import { load } from 'cheerio'; import { parseDate } from '@/utils/parse-date'; import { art } from '@/utils/render'; import * as path from 'node:path'; -const md = require('markdown-it')({ +import MarkdownIt from 'markdown-it'; +const md = MarkdownIt({ html: true, }); diff --git a/lib/routes/cib/whpj.ts b/lib/routes/cib/whpj.ts index 689b6c5cb8dbc3..831736f2e3e4e8 100644 --- a/lib/routes/cib/whpj.ts +++ b/lib/routes/cib/whpj.ts @@ -2,8 +2,8 @@ import cache from '@/utils/cache'; import got from '@/utils/got'; import { load } from 'cheerio'; import { parseDate } from '@/utils/parse-date'; -const https = require('https'); -const crypto = require('crypto'); +import https from 'https'; +import crypto from 'crypto'; import { config } from '@/config'; export default async (ctx) => { diff --git a/lib/routes/ciidbnu/index.ts b/lib/routes/ciidbnu/index.ts index 97c415314d523e..123ffaf701f9fd 100644 --- a/lib/routes/ciidbnu/index.ts +++ b/lib/routes/ciidbnu/index.ts @@ -1,7 +1,7 @@ import cache from '@/utils/cache'; import got from '@/utils/got'; import { load } from 'cheerio'; -const iconv = require('iconv-lite'); +import iconv from 'iconv-lite'; import { parseDate } from '@/utils/parse-date'; import timezone from '@/utils/timezone'; diff --git a/lib/routes/cls/utils.ts b/lib/routes/cls/utils.ts index ae87fcab9481b5..27c7cbac2b232f 100644 --- a/lib/routes/cls/utils.ts +++ b/lib/routes/cls/utils.ts @@ -1,4 +1,4 @@ -const CryptoJS = require('crypto-js'); +import CryptoJS from 'crypto-js'; const rootUrl = 'https://www.cls.cn'; diff --git a/lib/routes/codeforces/contests.ts b/lib/routes/codeforces/contests.ts index 25d1b32d04ec99..57a56fafaf22c9 100644 --- a/lib/routes/codeforces/contests.ts +++ b/lib/routes/codeforces/contests.ts @@ -5,11 +5,15 @@ import got from '@/utils/got'; import * as path from 'node:path'; import { art } from '@/utils/render'; -const dayjs = require('dayjs'); -dayjs.extend(require('dayjs/plugin/localizedFormat')); -dayjs.extend(require('dayjs/plugin/duration')); -dayjs.extend(require('dayjs/plugin/relativeTime')); -require('dayjs/locale/zh-cn'); +import dayjs from 'dayjs'; +import localizedFormat from 'dayjs/plugin/localizedFormat'; +import duration from 'dayjs/plugin/duration'; +import relativeTime from 'dayjs/plugin/relativeTime'; +import 'dayjs/locale/zh-cn'; + +dayjs.extend(localizedFormat); +dayjs.extend(duration); +dayjs.extend(relativeTime); dayjs.locale('zh-cn'); const sec2str = (sec) => dayjs.duration(Number.parseInt(sec), 'seconds').humanize(); diff --git a/lib/routes/copymanga/comic.ts b/lib/routes/copymanga/comic.ts index 00c424ef45ba0d..e1da19a53fb256 100644 --- a/lib/routes/copymanga/comic.ts +++ b/lib/routes/copymanga/comic.ts @@ -8,7 +8,7 @@ import { parseDate } from '@/utils/parse-date'; import { art } from '@/utils/render'; import * as path from 'node:path'; import { config } from '@/config'; -const asyncPool = require('tiny-async-pool'); +import asyncPool from 'tiny-async-pool'; export default async (ctx) => { const id = ctx.req.param('id'); diff --git a/lib/routes/creative-comic/utils.ts b/lib/routes/creative-comic/utils.ts index 458942f9b960f6..dba027f1e91938 100644 --- a/lib/routes/creative-comic/utils.ts +++ b/lib/routes/creative-comic/utils.ts @@ -1,5 +1,5 @@ import got from '@/utils/got'; -const CryptoJS = require('crypto-js'); +import CryptoJS from 'crypto-js'; const apiHost = 'https://api.creative-comic.tw'; const device = 'web_desktop'; diff --git a/lib/routes/cs/index.ts b/lib/routes/cs/index.ts index 3c447e720321ce..87872a745b9fdb 100644 --- a/lib/routes/cs/index.ts +++ b/lib/routes/cs/index.ts @@ -1,7 +1,7 @@ import cache from '@/utils/cache'; import got from '@/utils/got'; import { load } from 'cheerio'; -const iconv = require('iconv-lite'); +import iconv from 'iconv-lite'; import timezone from '@/utils/timezone'; import { parseDate } from '@/utils/parse-date'; diff --git a/lib/routes/csu/utils.ts b/lib/routes/csu/utils.ts index 5f5cc6df3d4ad1..b0cf117fab8f85 100644 --- a/lib/routes/csu/utils.ts +++ b/lib/routes/csu/utils.ts @@ -1,4 +1,4 @@ -const { inflateSync } = require('zlib'); +import { inflateSync } from 'zlib'; const unzip = (b64Data) => { const strData = Buffer.from(b64Data, 'base64').toString('binary'); diff --git a/lib/routes/cts/news.ts b/lib/routes/cts/news.ts index dc4557e3f838fb..4cb9961dd137bf 100644 --- a/lib/routes/cts/news.ts +++ b/lib/routes/cts/news.ts @@ -2,7 +2,7 @@ import cache from '@/utils/cache'; import got from '@/utils/got'; import { load } from 'cheerio'; import { parseDate } from '@/utils/parse-date'; -const asyncPool = require('tiny-async-pool'); +import asyncPool from 'tiny-async-pool'; export default async (ctx) => { const category = ctx.req.param('category'); diff --git a/lib/routes/daily/utils.ts b/lib/routes/daily/utils.ts index 60097da50e6740..d9c67025b85d2b 100644 --- a/lib/routes/daily/utils.ts +++ b/lib/routes/daily/utils.ts @@ -1,4 +1,4 @@ -const dayjs = require('dayjs'); +import dayjs from 'dayjs'; import got from '@/utils/got'; const getData = async (graphqlQuery) => diff --git a/lib/routes/dapenti/utils.ts b/lib/routes/dapenti/utils.ts index d82347f92614a4..20f1983c0603ef 100644 --- a/lib/routes/dapenti/utils.ts +++ b/lib/routes/dapenti/utils.ts @@ -1,7 +1,7 @@ import cache from '@/utils/cache'; import got from '@/utils/got'; import { load } from 'cheerio'; -const iconv = require('iconv-lite'); +import iconv from 'iconv-lite'; import { parseDate } from '@/utils/parse-date'; import timezone from '@/utils/timezone'; diff --git a/lib/routes/dcard/utils.ts b/lib/routes/dcard/utils.ts index 4dbf4decd46005..3db10ad408bd3b 100644 --- a/lib/routes/dcard/utils.ts +++ b/lib/routes/dcard/utils.ts @@ -1,4 +1,4 @@ -const asyncPool = require('tiny-async-pool'); +import asyncPool from 'tiny-async-pool'; const ProcessFeed = async (items, cookies, browser, limit, cache) => { let newCookies = []; diff --git a/lib/routes/discuz/discuz.ts b/lib/routes/discuz/discuz.ts index 5f4b923dc90b78..fa3f861693c505 100644 --- a/lib/routes/discuz/discuz.ts +++ b/lib/routes/discuz/discuz.ts @@ -1,7 +1,7 @@ import cache from '@/utils/cache'; import got from '@/utils/got'; import { load } from 'cheerio'; -const iconv = require('iconv-lite'); +import iconv from 'iconv-lite'; import { parseDate } from '@/utils/parse-date'; import { config } from '@/config'; diff --git a/lib/routes/dlnews/category.ts b/lib/routes/dlnews/category.ts index 49919d947a535f..4928bfc47a39ee 100644 --- a/lib/routes/dlnews/category.ts +++ b/lib/routes/dlnews/category.ts @@ -7,7 +7,7 @@ import got from '@/utils/got'; import { getData, getList } from './utils'; import { art } from '@/utils/render'; import * as path from 'node:path'; -const asyncPool = require('tiny-async-pool'); +import asyncPool from 'tiny-async-pool'; const _website = 'dlnews'; const topics = { diff --git a/lib/routes/dlsite/utils.ts b/lib/routes/dlsite/utils.ts index 7ee354a554b860..b89d3ef566d5d6 100644 --- a/lib/routes/dlsite/utils.ts +++ b/lib/routes/dlsite/utils.ts @@ -7,7 +7,7 @@ import { load } from 'cheerio'; import timezone from '@/utils/timezone'; import { parseDate } from '@/utils/parse-date'; import { art } from '@/utils/render'; -const dayjs = require('dayjs'); +import dayjs from 'dayjs'; import * as path from 'node:path'; const rootUrl = 'https://www.dlsite.com'; diff --git a/lib/routes/dongqiudi/result.ts b/lib/routes/dongqiudi/result.ts index 94abec61ecddb1..03f934ef4ab08d 100644 --- a/lib/routes/dongqiudi/result.ts +++ b/lib/routes/dongqiudi/result.ts @@ -1,5 +1,5 @@ import got from '@/utils/got'; -const { JSDOM } = require('jsdom'); +import { JSDOM } from 'jsdom'; import { parseDate } from '@/utils/parse-date'; export default async (ctx) => { diff --git a/lib/routes/dongqiudi/utils.ts b/lib/routes/dongqiudi/utils.ts index f6f4c47222e8a5..6e4e527fee4066 100644 --- a/lib/routes/dongqiudi/utils.ts +++ b/lib/routes/dongqiudi/utils.ts @@ -1,7 +1,7 @@ import cache from '@/utils/cache'; import { load } from 'cheerio'; import got from '@/utils/got'; -const { JSDOM } = require('jsdom'); +import { JSDOM } from 'jsdom'; import { parseDate } from '@/utils/parse-date'; const ProcessVideo = (content) => { diff --git a/lib/routes/douban/other/explore-column.ts b/lib/routes/douban/other/explore-column.ts index b9610d60bc59c8..c5c71bdf771cf4 100644 --- a/lib/routes/douban/other/explore-column.ts +++ b/lib/routes/douban/other/explore-column.ts @@ -1,6 +1,6 @@ import got from '@/utils/got'; import { load } from 'cheerio'; -const url = require('url'); +import * as url from 'node:url'; const host = 'https://www.douban.com/explore/column/'; export default async (ctx) => { diff --git a/lib/routes/douban/people/status.ts b/lib/routes/douban/people/status.ts index 68d78168519c98..851d58086348f4 100644 --- a/lib/routes/douban/people/status.ts +++ b/lib/routes/douban/people/status.ts @@ -1,5 +1,5 @@ import cache from '@/utils/cache'; -const querystring = require('querystring'); +import querystring from 'querystring'; import got from '@/utils/got'; import { fallback, queryToBoolean, queryToInteger } from '@/utils/readable-social'; import { config } from '@/config'; diff --git a/lib/routes/douban/people/wish.ts b/lib/routes/douban/people/wish.ts index ed36ec193072ca..ac1d194ce1d6d9 100644 --- a/lib/routes/douban/people/wish.ts +++ b/lib/routes/douban/people/wish.ts @@ -1,5 +1,5 @@ import cache from '@/utils/cache'; -const querystring = require('querystring'); +import querystring from 'querystring'; import { load } from 'cheerio'; import got from '@/utils/got'; import { config } from '@/config'; diff --git a/lib/routes/duozhuayu/search.ts b/lib/routes/duozhuayu/search.ts index 1441b4bbf54019..47c5b1300a481b 100644 --- a/lib/routes/duozhuayu/search.ts +++ b/lib/routes/duozhuayu/search.ts @@ -2,7 +2,7 @@ import { getCurrentPath } from '@/utils/helpers'; const __dirname = getCurrentPath(import.meta.url); import got from '@/utils/got'; -const aesjs = require('aes-js'); +import aesjs from 'aes-js'; import { art } from '@/utils/render'; import * as path from 'node:path'; import { parseDate } from '@/utils/parse-date'; diff --git a/lib/routes/dxy/utils.ts b/lib/routes/dxy/utils.ts index 2cdde2e4ddfe0b..eaba4b5a5f9a11 100644 --- a/lib/routes/dxy/utils.ts +++ b/lib/routes/dxy/utils.ts @@ -1,4 +1,4 @@ -const CryptoJS = require('crypto-js'); +import CryptoJS from 'crypto-js'; import got from '@/utils/got'; import { load } from 'cheerio'; import { parseDate } from '@/utils/parse-date'; diff --git a/lib/routes/elsevier/issue.ts b/lib/routes/elsevier/issue.ts index 6e394f71e6bdcf..802192e917150e 100644 --- a/lib/routes/elsevier/issue.ts +++ b/lib/routes/elsevier/issue.ts @@ -7,7 +7,7 @@ import { load } from 'cheerio'; import * as path from 'node:path'; import { art } from '@/utils/render'; -const { CookieJar } = require('tough-cookie'); +import { CookieJar } from 'tough-cookie'; const cookieJar = new CookieJar(); export default async (ctx) => { diff --git a/lib/routes/elsevier/journal.ts b/lib/routes/elsevier/journal.ts index 17cfb06ca028ba..b7a9b9353227d0 100644 --- a/lib/routes/elsevier/journal.ts +++ b/lib/routes/elsevier/journal.ts @@ -7,7 +7,7 @@ import { load } from 'cheerio'; import * as path from 'node:path'; import { art } from '@/utils/render'; -const { CookieJar } = require('tough-cookie'); +import { CookieJar } from 'tough-cookie'; const cookieJar = new CookieJar(); export default async (ctx) => { diff --git a/lib/routes/epicgames/index.ts b/lib/routes/epicgames/index.ts index 6fa4f5d8b7a05a..91a6e2c5a4bc87 100644 --- a/lib/routes/epicgames/index.ts +++ b/lib/routes/epicgames/index.ts @@ -5,7 +5,7 @@ import got from '@/utils/got'; import { parseDate } from '@/utils/parse-date'; import { art } from '@/utils/render'; import * as path from 'node:path'; -const dayjs = require('dayjs'); +import dayjs from 'dayjs'; export default async (ctx) => { const locale = ctx.req.param('locale') ?? 'en-US'; diff --git a/lib/routes/farmatters/index.ts b/lib/routes/farmatters/index.ts index af70b071f36f7e..bbfc137b43fbae 100644 --- a/lib/routes/farmatters/index.ts +++ b/lib/routes/farmatters/index.ts @@ -7,7 +7,8 @@ import timezone from '@/utils/timezone'; import { parseDate } from '@/utils/parse-date'; import { art } from '@/utils/render'; import * as path from 'node:path'; -const md = require('markdown-it')({ +import MarkdownIt from 'markdown-it'; +const md = MarkdownIt({ html: true, }); diff --git a/lib/routes/feng/utils.ts b/lib/routes/feng/utils.ts index a87fc428d23e52..ff0d26a184216f 100644 --- a/lib/routes/feng/utils.ts +++ b/lib/routes/feng/utils.ts @@ -1,5 +1,5 @@ import cache from '@/utils/cache'; -const CryptoJS = require('crypto-js'); +import CryptoJS from 'crypto-js'; import got from '@/utils/got'; import { config } from '@/config'; const apiUrl = 'https://api.wfdata.club'; diff --git a/lib/routes/flyert/creditcard.ts b/lib/routes/flyert/creditcard.ts index 0bef691cbdb09a..db18888c9e09dd 100644 --- a/lib/routes/flyert/creditcard.ts +++ b/lib/routes/flyert/creditcard.ts @@ -2,7 +2,7 @@ import cache from '@/utils/cache'; import got from '@/utils/got'; import { load } from 'cheerio'; import util from './utils'; -const iconv = require('iconv-lite'); +import iconv from 'iconv-lite'; const gbk2utf8 = (s) => iconv.decode(s, 'gbk'); const host = 'https://www.flyert.com'; diff --git a/lib/routes/flyert/preferential.ts b/lib/routes/flyert/preferential.ts index 20ead7a535b780..eb0bf845f90c16 100644 --- a/lib/routes/flyert/preferential.ts +++ b/lib/routes/flyert/preferential.ts @@ -1,7 +1,7 @@ import cache from '@/utils/cache'; import got from '@/utils/got'; import { load } from 'cheerio'; -const iconv = require('iconv-lite'); +import iconv from 'iconv-lite'; import { parseDate } from '@/utils/parse-date'; import timezone from '@/utils/timezone'; diff --git a/lib/routes/flyert/utils.ts b/lib/routes/flyert/utils.ts index df4a569d55d37f..6e072e9fea209f 100644 --- a/lib/routes/flyert/utils.ts +++ b/lib/routes/flyert/utils.ts @@ -1,7 +1,7 @@ import got from '@/utils/got'; import { load } from 'cheerio'; -const url = require('url'); -const iconv = require('iconv-lite'); +import * as url from 'node:url'; +import iconv from 'iconv-lite'; const gbk2utf8 = (s) => iconv.decode(s, 'gbk'); diff --git a/lib/routes/foresightnews/util.ts b/lib/routes/foresightnews/util.ts index 56ff9281951836..50c862a57aea94 100644 --- a/lib/routes/foresightnews/util.ts +++ b/lib/routes/foresightnews/util.ts @@ -5,7 +5,7 @@ import got from '@/utils/got'; import { parseDate } from '@/utils/parse-date'; import { art } from '@/utils/render'; import * as path from 'node:path'; -const zlib = require('zlib'); +import zlib from 'zlib'; const constants = { labelHot: '热门', diff --git a/lib/routes/gdut/oa-news.ts b/lib/routes/gdut/oa-news.ts index aace2d89fd64cd..094551678c2f55 100644 --- a/lib/routes/gdut/oa-news.ts +++ b/lib/routes/gdut/oa-news.ts @@ -2,10 +2,10 @@ import cache from '@/utils/cache'; import got from '@/utils/got'; import wait from '@/utils/wait'; import { load } from 'cheerio'; -const { CookieJar } = require('tough-cookie'); +import { CookieJar } from 'tough-cookie'; import { parseDate } from '@/utils/parse-date'; import timezone from '@/utils/timezone'; -const asyncPool = require('tiny-async-pool'); +import asyncPool from 'tiny-async-pool'; const site = 'https://oas.gdut.edu.cn/seeyon'; const typeMap = { diff --git a/lib/routes/gitee/repos/commits.ts b/lib/routes/gitee/repos/commits.ts index 5dae915dab3047..eb271c042736f2 100644 --- a/lib/routes/gitee/repos/commits.ts +++ b/lib/routes/gitee/repos/commits.ts @@ -2,7 +2,8 @@ import cache from '@/utils/cache'; import got from '@/utils/got'; import { parseDate } from '@/utils/parse-date'; import { config } from '@/config'; -const md = require('markdown-it')({ +import MarkdownIt from 'markdown-it'; +const md = MarkdownIt({ html: true, }); diff --git a/lib/routes/gitee/repos/events.ts b/lib/routes/gitee/repos/events.ts index 6e5f5c19592ae8..36f6905e4f5c97 100644 --- a/lib/routes/gitee/repos/events.ts +++ b/lib/routes/gitee/repos/events.ts @@ -2,7 +2,8 @@ import cache from '@/utils/cache'; import got from '@/utils/got'; import { parseDate } from '@/utils/parse-date'; import { config } from '@/config'; -const md = require('markdown-it')({ +import MarkdownIt from 'markdown-it'; +const md = MarkdownIt({ html: true, }); diff --git a/lib/routes/gitee/repos/releases.ts b/lib/routes/gitee/repos/releases.ts index bf9123ed10bccb..f38db10e50dc62 100644 --- a/lib/routes/gitee/repos/releases.ts +++ b/lib/routes/gitee/repos/releases.ts @@ -1,7 +1,8 @@ import got from '@/utils/got'; import { parseDate } from '@/utils/parse-date'; import { config } from '@/config'; -const md = require('markdown-it')({ +import MarkdownIt from 'markdown-it'; +const md = MarkdownIt({ html: true, }); diff --git a/lib/routes/gitee/users/events.ts b/lib/routes/gitee/users/events.ts index 0044eccb2bb30c..1c590330b22b5c 100644 --- a/lib/routes/gitee/users/events.ts +++ b/lib/routes/gitee/users/events.ts @@ -2,7 +2,8 @@ import cache from '@/utils/cache'; import got from '@/utils/got'; import { parseDate } from '@/utils/parse-date'; import { config } from '@/config'; -const md = require('markdown-it')({ +import MarkdownIt from 'markdown-it'; +const md = MarkdownIt({ html: true, }); diff --git a/lib/routes/github/comments.ts b/lib/routes/github/comments.ts index 8fe7b2ee957331..c2e7b61f2231f5 100644 --- a/lib/routes/github/comments.ts +++ b/lib/routes/github/comments.ts @@ -1,6 +1,7 @@ import got from '@/utils/got'; import { parseDate } from '@/utils/parse-date'; -const md = require('markdown-it')({ +import MarkdownIt from 'markdown-it'; +const md = MarkdownIt({ html: true, }); const rootUrl = 'https://github.com'; diff --git a/lib/routes/github/issue.ts b/lib/routes/github/issue.ts index 5f00314e6b02ad..9820d9e8a0b4ac 100644 --- a/lib/routes/github/issue.ts +++ b/lib/routes/github/issue.ts @@ -1,6 +1,7 @@ import got from '@/utils/got'; import { config } from '@/config'; -const md = require('markdown-it')({ +import MarkdownIt from 'markdown-it'; +const md = MarkdownIt({ html: true, linkify: true, }); diff --git a/lib/routes/github/pulls.ts b/lib/routes/github/pulls.ts index a1acedb3686b8e..06c5930af059aa 100644 --- a/lib/routes/github/pulls.ts +++ b/lib/routes/github/pulls.ts @@ -1,6 +1,7 @@ import got from '@/utils/got'; import { config } from '@/config'; -const md = require('markdown-it')({ +import MarkdownIt from 'markdown-it'; +const md = MarkdownIt({ html: true, linkify: true, }); diff --git a/lib/routes/github/search.ts b/lib/routes/github/search.ts index 21e40c99b592bf..154fc2fddd2efb 100644 --- a/lib/routes/github/search.ts +++ b/lib/routes/github/search.ts @@ -1,6 +1,6 @@ import got from '@/utils/got'; import { load } from 'cheerio'; -const url = require('url'); +import * as url from 'node:url'; const host = 'https://github.com'; diff --git a/lib/routes/gov/ccdi/utils.ts b/lib/routes/gov/ccdi/utils.ts index 90507f6b743294..667be1a1458aa9 100644 --- a/lib/routes/gov/ccdi/utils.ts +++ b/lib/routes/gov/ccdi/utils.ts @@ -4,7 +4,7 @@ import { parseDate } from '@/utils/parse-date'; import got from '@/utils/got'; import timezone from '@/utils/timezone'; -const { CookieJar, Cookie } = require('tough-cookie'); +import { CookieJar, Cookie } from 'tough-cookie'; const cookieJar = new CookieJar(); const owner = '中央纪委国家监委网站'; diff --git a/lib/routes/gov/hunan/changsha/major-email.ts b/lib/routes/gov/hunan/changsha/major-email.ts index f6560f12491884..895ce041ca2f3b 100644 --- a/lib/routes/gov/hunan/changsha/major-email.ts +++ b/lib/routes/gov/hunan/changsha/major-email.ts @@ -1,7 +1,7 @@ import cache from '@/utils/cache'; import got from '@/utils/got'; import { load } from 'cheerio'; -const iconv = require('iconv-lite'); +import iconv from 'iconv-lite'; import { parseDate } from '@/utils/parse-date'; const baseUrl = 'http://wlwz.changsha.gov.cn'; diff --git a/lib/routes/gov/nopss/index.ts b/lib/routes/gov/nopss/index.ts index 4a6a0775ac6cb5..0ea7e83c762639 100644 --- a/lib/routes/gov/nopss/index.ts +++ b/lib/routes/gov/nopss/index.ts @@ -2,7 +2,7 @@ import { getSubPath } from '@/utils/common-utils'; import cache from '@/utils/cache'; import got from '@/utils/got'; import { load } from 'cheerio'; -const iconv = require('iconv-lite'); +import iconv from 'iconv-lite'; import timezone from '@/utils/timezone'; import { parseDate } from '@/utils/parse-date'; diff --git a/lib/routes/gov/nrta/dsj.ts b/lib/routes/gov/nrta/dsj.ts index 52893bb78e11da..71a74c4aad873c 100644 --- a/lib/routes/gov/nrta/dsj.ts +++ b/lib/routes/gov/nrta/dsj.ts @@ -2,7 +2,7 @@ import cache from '@/utils/cache'; import got from '@/utils/got'; import { load } from 'cheerio'; import { parseDate } from '@/utils/parse-date'; -const asyncPool = require('tiny-async-pool'); +import asyncPool from 'tiny-async-pool'; export default async (ctx) => { const { category = 'note' } = ctx.req.param(); diff --git a/lib/routes/gov/shanghai/rsj/ksxm.ts b/lib/routes/gov/shanghai/rsj/ksxm.ts index 343855270aad75..60e9abfa162b67 100644 --- a/lib/routes/gov/shanghai/rsj/ksxm.ts +++ b/lib/routes/gov/shanghai/rsj/ksxm.ts @@ -3,7 +3,7 @@ const __dirname = getCurrentPath(import.meta.url); import got from '@/utils/got'; import { load } from 'cheerio'; -const iconv = require('iconv-lite'); +import iconv from 'iconv-lite'; import { art } from '@/utils/render'; import * as path from 'node:path'; diff --git a/lib/routes/guduodata/daily.ts b/lib/routes/guduodata/daily.ts index 43d2a72d630fb1..334e6cf20a9311 100644 --- a/lib/routes/guduodata/daily.ts +++ b/lib/routes/guduodata/daily.ts @@ -3,7 +3,7 @@ const __dirname = getCurrentPath(import.meta.url); import cache from '@/utils/cache'; import got from '@/utils/got'; -const dayjs = require('dayjs'); +import dayjs from 'dayjs'; import { art } from '@/utils/render'; import * as path from 'node:path'; diff --git a/lib/routes/hellogithub/volume.ts b/lib/routes/hellogithub/volume.ts index 0d6f569e1e6364..ff9e9db8164238 100644 --- a/lib/routes/hellogithub/volume.ts +++ b/lib/routes/hellogithub/volume.ts @@ -4,7 +4,8 @@ const __dirname = getCurrentPath(import.meta.url); import got from '@/utils/got'; import { art } from '@/utils/render'; import * as path from 'node:path'; -const md = require('markdown-it')({ +import MarkdownIt from 'markdown-it'; +const md = MarkdownIt({ html: true, }); import { load } from 'cheerio'; diff --git a/lib/routes/hkej/index.ts b/lib/routes/hkej/index.ts index f8f96c11b3d935..cb102e4e106e63 100644 --- a/lib/routes/hkej/index.ts +++ b/lib/routes/hkej/index.ts @@ -8,7 +8,7 @@ import { parseDate, parseRelativeDate } from '@/utils/parse-date'; import timezone from '@/utils/timezone'; import { art } from '@/utils/render'; import * as path from 'node:path'; -const { CookieJar } = require('tough-cookie'); +import { CookieJar } from 'tough-cookie'; const cookieJar = new CookieJar(); diff --git a/lib/routes/hotukdeals/hottest.ts b/lib/routes/hotukdeals/hottest.ts index 759b9f20fc7c95..34d5d359f87630 100644 --- a/lib/routes/hotukdeals/hottest.ts +++ b/lib/routes/hotukdeals/hottest.ts @@ -1,5 +1,5 @@ import got from '@/utils/got'; -const { JSDOM } = require('jsdom'); +import { JSDOM } from 'jsdom'; export default async (ctx) => { const data = await got.get(`https://www.hotukdeals.com/`, { diff --git a/lib/routes/huxiu/util.ts b/lib/routes/huxiu/util.ts index bfd7c5a3b33433..76a8868a04bb54 100644 --- a/lib/routes/huxiu/util.ts +++ b/lib/routes/huxiu/util.ts @@ -6,7 +6,7 @@ import { load } from 'cheerio'; import { parseDate } from '@/utils/parse-date'; import { art } from '@/utils/render'; import * as path from 'node:path'; -const CryptoJS = require('crypto-js'); +import CryptoJS from 'crypto-js'; const domain = 'huxiu.com'; const rootUrl = `https://www.${domain}`; diff --git a/lib/routes/ieee/earlyaccess.ts b/lib/routes/ieee/earlyaccess.ts index fbecae76fc65dc..ca9367a7554014 100644 --- a/lib/routes/ieee/earlyaccess.ts +++ b/lib/routes/ieee/earlyaccess.ts @@ -7,7 +7,7 @@ import { load } from 'cheerio'; import * as path from 'node:path'; import { art } from '@/utils/render'; -const { CookieJar } = require('tough-cookie'); +import { CookieJar } from 'tough-cookie'; const cookieJar = new CookieJar(); export default async (ctx) => { diff --git a/lib/routes/ieee/journal.ts b/lib/routes/ieee/journal.ts index 68b1402ab6565e..7a3f7224e45227 100644 --- a/lib/routes/ieee/journal.ts +++ b/lib/routes/ieee/journal.ts @@ -7,7 +7,7 @@ import { load } from 'cheerio'; import * as path from 'node:path'; import { art } from '@/utils/render'; -const { CookieJar } = require('tough-cookie'); +import { CookieJar } from 'tough-cookie'; const cookieJar = new CookieJar(); export default async (ctx) => { diff --git a/lib/routes/ieee/recent.ts b/lib/routes/ieee/recent.ts index f255dec8d12528..f907af28738a55 100644 --- a/lib/routes/ieee/recent.ts +++ b/lib/routes/ieee/recent.ts @@ -7,7 +7,7 @@ import { load } from 'cheerio'; import * as path from 'node:path'; import { art } from '@/utils/render'; -const { CookieJar } = require('tough-cookie'); +import { CookieJar } from 'tough-cookie'; const cookieJar = new CookieJar(); export default async (ctx) => { diff --git a/lib/routes/imagemagick/changelog.ts b/lib/routes/imagemagick/changelog.ts index e2d4264bab1ce5..a0e6ce4fe29cee 100644 --- a/lib/routes/imagemagick/changelog.ts +++ b/lib/routes/imagemagick/changelog.ts @@ -1,7 +1,8 @@ import got from '@/utils/got'; import { load } from 'cheerio'; import { parseDate } from '@/utils/parse-date'; -const md = require('markdown-it')({ +import MarkdownIt from 'markdown-it'; +const md = MarkdownIt({ html: true, }); diff --git a/lib/routes/inewsweek/index.ts b/lib/routes/inewsweek/index.ts index 8f32f718aa2ded..de381956097c5f 100644 --- a/lib/routes/inewsweek/index.ts +++ b/lib/routes/inewsweek/index.ts @@ -3,7 +3,7 @@ import got from '@/utils/got'; import { load } from 'cheerio'; import { parseDate } from '@/utils/parse-date'; import timezone from '@/utils/timezone'; -const iconv = require('iconv-lite'); +import iconv from 'iconv-lite'; const rootUrl = 'http://news.inewsweek.cn'; diff --git a/lib/routes/instagram/private-api/utils.ts b/lib/routes/instagram/private-api/utils.ts index 7fc76823eacfb9..2ac6fd94802505 100644 --- a/lib/routes/instagram/private-api/utils.ts +++ b/lib/routes/instagram/private-api/utils.ts @@ -1,4 +1,4 @@ -const { IgApiClient } = require('instagram-private-api'); +import { IgApiClient } from 'instagram-private-api'; import logger from '@/utils/logger'; import { config } from '@/config'; diff --git a/lib/routes/instagram/web-api/index.ts b/lib/routes/instagram/web-api/index.ts index b1d8fb992dbd09..0c24f99efb31bc 100644 --- a/lib/routes/instagram/web-api/index.ts +++ b/lib/routes/instagram/web-api/index.ts @@ -1,5 +1,5 @@ import cache from '@/utils/cache'; -const { CookieJar } = require('tough-cookie'); +import { CookieJar } from 'tough-cookie'; import { config } from '@/config'; import { renderItems } from '../common-utils'; import { baseUrl, COOKIE_URL, checkLogin, getUserInfo, getUserFeedItems, getTagsFeedItems, getLoggedOutTagsFeedItems, renderGuestItems } from './utils'; diff --git a/lib/routes/iqnew/latest.ts b/lib/routes/iqnew/latest.ts index 9d8677fa1bd460..17f217dc812f1c 100644 --- a/lib/routes/iqnew/latest.ts +++ b/lib/routes/iqnew/latest.ts @@ -1,7 +1,7 @@ import cache from '@/utils/cache'; import got from '@/utils/got'; import { load } from 'cheerio'; -const iconv = require('iconv-lite'); +import iconv from 'iconv-lite'; import { parseDate } from '@/utils/parse-date'; import timezone from '@/utils/timezone'; diff --git a/lib/routes/issuehunt/funded.ts b/lib/routes/issuehunt/funded.ts index 44771e9f69def7..88b12f8b60c1a4 100644 --- a/lib/routes/issuehunt/funded.ts +++ b/lib/routes/issuehunt/funded.ts @@ -1,5 +1,5 @@ import got from '@/utils/got'; -const MarkdownIt = require('markdown-it'); +import MarkdownIt from 'markdown-it'; export default async (ctx) => { const { username, repo } = ctx.req.param(); diff --git a/lib/routes/iwara/subscriptions.ts b/lib/routes/iwara/subscriptions.ts index 3ed4816e570f9b..dca284618c6272 100644 --- a/lib/routes/iwara/subscriptions.ts +++ b/lib/routes/iwara/subscriptions.ts @@ -7,7 +7,8 @@ import { config } from '@/config'; import { art } from '@/utils/render'; import { parseDate } from '@/utils/parse-date'; import * as path from 'node:path'; -const md = require('markdown-it')({ +import MarkdownIt from 'markdown-it'; +const md = MarkdownIt({ html: true, }); diff --git a/lib/routes/japanpost/utils.ts b/lib/routes/japanpost/utils.ts index 5766a5a5566225..53d883be4a656e 100644 --- a/lib/routes/japanpost/utils.ts +++ b/lib/routes/japanpost/utils.ts @@ -1,10 +1,10 @@ -const crypto = require('crypto'); +import crypto from 'crypto'; -const cityTimezones = require('city-timezones'); -const dayjs = require('dayjs'); -const customParseFormat = require('dayjs/plugin/customParseFormat'); -const utc = require('dayjs/plugin/utc'); -const timezone = require('dayjs/plugin/timezone'); +import cityTimezones from 'city-timezones'; +import dayjs from 'dayjs'; +import customParseFormat from 'dayjs/plugin/customParseFormat'; +import utc from 'dayjs/plugin/utc'; +import timezone from 'dayjs/plugin/timezone'; dayjs.extend(customParseFormat); dayjs.extend(utc); dayjs.extend(timezone); diff --git a/lib/routes/jike/topic-text.ts b/lib/routes/jike/topic-text.ts index db1c280b034a7a..fbb20392ea3e3a 100644 --- a/lib/routes/jike/topic-text.ts +++ b/lib/routes/jike/topic-text.ts @@ -1,4 +1,4 @@ -const dayjs = require('dayjs'); +import dayjs from 'dayjs'; import { constructTopicEntry } from './utils'; export default async (ctx) => { diff --git a/lib/routes/jike/topic.ts b/lib/routes/jike/topic.ts index 667afd273b4a57..ab3f6f55c96deb 100644 --- a/lib/routes/jike/topic.ts +++ b/lib/routes/jike/topic.ts @@ -2,7 +2,7 @@ import cache from '@/utils/cache'; import got from '@/utils/got'; import { topicDataHanding, constructTopicEntry } from './utils'; import { load } from 'cheerio'; -const dayjs = require('dayjs'); +import dayjs from 'dayjs'; const urlRegex = /(https?:\/\/[^\s"'<>]+)/g; diff --git a/lib/routes/jjwxc/author.ts b/lib/routes/jjwxc/author.ts index dd90ec5bff86fe..463a9e5e77dbb0 100644 --- a/lib/routes/jjwxc/author.ts +++ b/lib/routes/jjwxc/author.ts @@ -3,7 +3,7 @@ const __dirname = getCurrentPath(import.meta.url); import got from '@/utils/got'; import { load } from 'cheerio'; -const iconv = require('iconv-lite'); +import iconv from 'iconv-lite'; import timezone from '@/utils/timezone'; import { parseDate } from '@/utils/parse-date'; import { art } from '@/utils/render'; diff --git a/lib/routes/jjwxc/book.ts b/lib/routes/jjwxc/book.ts index 44daa24d8c1eca..39d3bd028111a3 100644 --- a/lib/routes/jjwxc/book.ts +++ b/lib/routes/jjwxc/book.ts @@ -4,7 +4,7 @@ const __dirname = getCurrentPath(import.meta.url); import cache from '@/utils/cache'; import got from '@/utils/got'; import { load } from 'cheerio'; -const iconv = require('iconv-lite'); +import iconv from 'iconv-lite'; import timezone from '@/utils/timezone'; import { parseDate } from '@/utils/parse-date'; import { art } from '@/utils/render'; diff --git a/lib/routes/juejin/utils.ts b/lib/routes/juejin/utils.ts index ebc0517285c8e3..0c0119743d7fb0 100644 --- a/lib/routes/juejin/utils.ts +++ b/lib/routes/juejin/utils.ts @@ -1,7 +1,8 @@ import got from '@/utils/got'; import { load } from 'cheerio'; import { parseDate } from '@/utils/parse-date'; -const md = require('markdown-it')({ +import MarkdownIt from 'markdown-it'; +const md = MarkdownIt({ html: true, }); // 加载文章页 diff --git a/lib/routes/kcna/news.ts b/lib/routes/kcna/news.ts index 4368081f45a939..37cf25403924cb 100644 --- a/lib/routes/kcna/news.ts +++ b/lib/routes/kcna/news.ts @@ -4,11 +4,11 @@ const __dirname = getCurrentPath(import.meta.url); import cache from '@/utils/cache'; import got from '@/utils/got'; import { load } from 'cheerio'; -const asyncPool = require('tiny-async-pool'); +import asyncPool from 'tiny-async-pool'; import { art } from '@/utils/render'; import { parseJucheDate, fixDesc, fetchPhoto, fetchVideo } from './utils'; import * as path from 'node:path'; -const sanitizeHtml = require('sanitize-html'); +import sanitizeHtml from 'sanitize-html'; export default async (ctx) => { const { lang, category = '1ee9bdb7186944f765208f34ecfb5407' } = ctx.req.param(); diff --git a/lib/routes/kunchengblog/essay.ts b/lib/routes/kunchengblog/essay.ts index 7994940cabe8cb..dffb1e2f75c657 100644 --- a/lib/routes/kunchengblog/essay.ts +++ b/lib/routes/kunchengblog/essay.ts @@ -1,7 +1,7 @@ import got from '@/utils/got'; import { load } from 'cheerio'; import { parseDate } from '@/utils/parse-date'; -const { SourceMapConsumer } = require('source-map'); +import { SourceMapConsumer } from 'source-map'; export default async (ctx) => { const limit = ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit'), 10) : 100; diff --git a/lib/routes/laimanhua/index.ts b/lib/routes/laimanhua/index.ts index 1200aa0751852f..41f29e3d1f1c2d 100644 --- a/lib/routes/laimanhua/index.ts +++ b/lib/routes/laimanhua/index.ts @@ -1,5 +1,5 @@ import got from '@/utils/got'; -const iconv = require('iconv-lite'); +import iconv from 'iconv-lite'; import { load } from 'cheerio'; import { parseDate } from '@/utils/parse-date'; diff --git a/lib/routes/lanqiao/author.ts b/lib/routes/lanqiao/author.ts index 10c0c59156718c..3a11e4485fc6bf 100644 --- a/lib/routes/lanqiao/author.ts +++ b/lib/routes/lanqiao/author.ts @@ -1,7 +1,7 @@ import cache from '@/utils/cache'; import got from '@/utils/got'; import utils from './utils'; -const MarkdownIt = require('markdown-it'); +import MarkdownIt from 'markdown-it'; async function getUserName(uid) { // 获取用户信息 diff --git a/lib/routes/lanqiao/courses.ts b/lib/routes/lanqiao/courses.ts index 4ebcda9a0c5407..1b35007ebe51af 100644 --- a/lib/routes/lanqiao/courses.ts +++ b/lib/routes/lanqiao/courses.ts @@ -1,7 +1,7 @@ import cache from '@/utils/cache'; import got from '@/utils/got'; import utils from './utils'; -const MarkdownIt = require('markdown-it'); +import MarkdownIt from 'markdown-it'; export default async (ctx) => { const sort = ctx.req.param('sort'); diff --git a/lib/routes/lanqiao/questions.ts b/lib/routes/lanqiao/questions.ts index 5962287aa4b37d..d3526355d556f6 100644 --- a/lib/routes/lanqiao/questions.ts +++ b/lib/routes/lanqiao/questions.ts @@ -1,7 +1,7 @@ import cache from '@/utils/cache'; import got from '@/utils/got'; import { parseDate } from '@/utils/parse-date'; -const MarkdownIt = require('markdown-it'); +import MarkdownIt from 'markdown-it'; export default async (ctx) => { const id = ctx.req.param('id'); diff --git a/lib/routes/leetcode/articles.ts b/lib/routes/leetcode/articles.ts index 2ec1e36340fd98..5666dcee053b60 100644 --- a/lib/routes/leetcode/articles.ts +++ b/lib/routes/leetcode/articles.ts @@ -2,7 +2,8 @@ import cache from '@/utils/cache'; import got from '@/utils/got'; import { load } from 'cheerio'; import { parseDate } from '@/utils/parse-date'; -const md = require('markdown-it')({ +import MarkdownIt from 'markdown-it'; +const md = MarkdownIt({ html: true, breaks: true, }); diff --git a/lib/routes/leetcode/dailyquestion-solution-cn.ts b/lib/routes/leetcode/dailyquestion-solution-cn.ts index d98a0835ed0eee..2f5342758fb267 100644 --- a/lib/routes/leetcode/dailyquestion-solution-cn.ts +++ b/lib/routes/leetcode/dailyquestion-solution-cn.ts @@ -1,5 +1,6 @@ import got from '@/utils/got'; -const md = require('markdown-it')({ +import MarkdownIt from 'markdown-it'; +const md = MarkdownIt({ html: true, breaks: true, }); diff --git a/lib/routes/leetcode/dailyquestion-solution-en.ts b/lib/routes/leetcode/dailyquestion-solution-en.ts index 0ef0ee66b4bc59..07f35ebd22b783 100644 --- a/lib/routes/leetcode/dailyquestion-solution-en.ts +++ b/lib/routes/leetcode/dailyquestion-solution-en.ts @@ -1,5 +1,6 @@ import got from '@/utils/got'; -const md = require('markdown-it')({ +import MarkdownIt from 'markdown-it'; +const md = MarkdownIt({ html: true, breaks: true, }); diff --git a/lib/routes/leiphone/utils.ts b/lib/routes/leiphone/utils.ts index 72a88c80e96517..7fdaed9dcf700e 100644 --- a/lib/routes/leiphone/utils.ts +++ b/lib/routes/leiphone/utils.ts @@ -1,7 +1,7 @@ import { load } from 'cheerio'; import got from '@/utils/got'; import { parseDate } from '@/utils/parse-date'; -const url = require('url'); +import * as url from 'node:url'; const ProcessFeed = async (list, cache) => { const host = 'https://www.leiphone.com'; diff --git a/lib/routes/lemmy/index.ts b/lib/routes/lemmy/index.ts index 433c7db7743460..780134d7d6dcc0 100644 --- a/lib/routes/lemmy/index.ts +++ b/lib/routes/lemmy/index.ts @@ -1,7 +1,8 @@ import cache from '@/utils/cache'; import got from '@/utils/got'; import { parseDate } from '@/utils/parse-date'; -const md = require('markdown-it')({ html: true }); +import MarkdownIt from 'markdown-it'; +const md = MarkdownIt({ html: true }); import { config } from '@/config'; export default async (ctx) => { diff --git a/lib/routes/linkedin/cn/utils.ts b/lib/routes/linkedin/cn/utils.ts index 03e0bfa4970a70..4da23a8520c4be 100644 --- a/lib/routes/linkedin/cn/utils.ts +++ b/lib/routes/linkedin/cn/utils.ts @@ -2,7 +2,7 @@ import { getCurrentPath } from '@/utils/helpers'; const __dirname = getCurrentPath(import.meta.url); import cache from '@/utils/cache'; -const crypto = require('crypto'); +import crypto from 'crypto'; import * as path from 'node:path'; import { art } from '@/utils/render'; import got from '@/utils/got'; diff --git a/lib/routes/linkresearcher/index.ts b/lib/routes/linkresearcher/index.ts index 607e372d2d4568..8d1d925fb1a692 100644 --- a/lib/routes/linkresearcher/index.ts +++ b/lib/routes/linkresearcher/index.ts @@ -1,5 +1,5 @@ import got from '@/utils/got'; -const qs = require('query-string'); +import qs from 'query-string'; import { parseDate } from '@/utils/parse-date'; const baseURL = 'https://www.linkresearcher.com'; diff --git a/lib/routes/lofter/tag.ts b/lib/routes/lofter/tag.ts index a8e9cde4847fde..d1466cfd5a172c 100644 --- a/lib/routes/lofter/tag.ts +++ b/lib/routes/lofter/tag.ts @@ -1,7 +1,7 @@ import got from '@/utils/got'; import { load } from 'cheerio'; import { parseDate } from '@/utils/parse-date'; -const { JSDOM } = require('jsdom'); +import { JSDOM } from 'jsdom'; export default async (ctx) => { const name = ctx.req.param('name') ?? '摄影'; diff --git a/lib/routes/lovelive-anime/schedules.ts b/lib/routes/lovelive-anime/schedules.ts index 0d2efa0161c130..50a63d9102b3cc 100644 --- a/lib/routes/lovelive-anime/schedules.ts +++ b/lib/routes/lovelive-anime/schedules.ts @@ -5,9 +5,9 @@ import got from '@/utils/got'; import * as path from 'node:path'; import { art } from '@/utils/render'; const renderDescription = (desc) => art(path.join(__dirname, 'templates/scheduleDesc.art'), desc); -const dayjs = require('dayjs'); -const utc = require('dayjs/plugin/utc'); -const timezone = require('dayjs/plugin/timezone'); +import dayjs from 'dayjs'; +import utc from 'dayjs/plugin/utc'; +import timezone from 'dayjs/plugin/timezone'; export default async (ctx) => { dayjs.extend(utc); diff --git a/lib/routes/luogu/contest.ts b/lib/routes/luogu/contest.ts index d0561bc26b9fba..b93b1cdd53f5ef 100644 --- a/lib/routes/luogu/contest.ts +++ b/lib/routes/luogu/contest.ts @@ -4,7 +4,7 @@ import { load } from 'cheerio'; import { parseDate } from '@/utils/parse-date'; import MarkdownIt from 'markdown-it'; const md = MarkdownIt(); -const asyncPool = require('tiny-async-pool'); +import asyncPool from 'tiny-async-pool'; const baseUrl = 'https://www.luogu.com.cn'; diff --git a/lib/routes/mail/imap.ts b/lib/routes/mail/imap.ts index ded4cbf4daa1ca..b23f2a0d9f71c1 100644 --- a/lib/routes/mail/imap.ts +++ b/lib/routes/mail/imap.ts @@ -1,7 +1,7 @@ import cache from '@/utils/cache'; -const { ImapFlow } = require('imapflow'); +import { ImapFlow } from 'imapflow'; import { config } from '@/config'; -const { simpleParser } = require('mailparser'); +import { simpleParser } from 'mailparser'; import logger from '@/utils/logger'; import { parseDate } from '@/utils/parse-date'; diff --git a/lib/routes/manhuagui/comic.ts b/lib/routes/manhuagui/comic.ts index 78b5f14cbd504f..a6219f1a0ef7c9 100644 --- a/lib/routes/manhuagui/comic.ts +++ b/lib/routes/manhuagui/comic.ts @@ -1,6 +1,6 @@ import { load } from 'cheerio'; import got from '@/utils/got'; -const LZString = require('lz-string'); +import LZString from 'lz-string'; import { parseDate } from '@/utils/parse-date'; let baseUrl = ''; diff --git a/lib/routes/mdpi/journal.ts b/lib/routes/mdpi/journal.ts index 796fa73d0d866c..e137b916a9da36 100644 --- a/lib/routes/mdpi/journal.ts +++ b/lib/routes/mdpi/journal.ts @@ -6,7 +6,7 @@ import { load } from 'cheerio'; import * as path from 'node:path'; import { art } from '@/utils/render'; -const { CookieJar } = require('tough-cookie'); +import { CookieJar } from 'tough-cookie'; const cookieJar = new CookieJar(); export default async (ctx) => { diff --git a/lib/routes/mirror/index.ts b/lib/routes/mirror/index.ts index ff7db76c089944..0e36a74b548a2a 100644 --- a/lib/routes/mirror/index.ts +++ b/lib/routes/mirror/index.ts @@ -1,6 +1,7 @@ import got from '@/utils/got'; import { parseDate } from '@/utils/parse-date'; -const md = require('markdown-it')({ +import MarkdownIt from 'markdown-it'; +const md = MarkdownIt({ html: true, linkify: true, }); diff --git a/lib/routes/mixcloud/index.ts b/lib/routes/mixcloud/index.ts index c22405f18062b6..03c81af6ac2b7f 100644 --- a/lib/routes/mixcloud/index.ts +++ b/lib/routes/mixcloud/index.ts @@ -1,5 +1,5 @@ import got from '@/utils/got'; -const CryptoJS = require('crypto-js'); +import CryptoJS from 'crypto-js'; import { parseDate } from '@/utils/parse-date'; import { queries } from './queries'; diff --git a/lib/routes/modelscope/datasets.ts b/lib/routes/modelscope/datasets.ts index c7133626c6f818..d61ef74ac9e72c 100644 --- a/lib/routes/modelscope/datasets.ts +++ b/lib/routes/modelscope/datasets.ts @@ -3,7 +3,8 @@ const __dirname = getCurrentPath(import.meta.url); import cache from '@/utils/cache'; import got from '@/utils/got'; -const md = require('markdown-it')({ +import MarkdownIt from 'markdown-it'; +const md = MarkdownIt({ html: true, linkify: true, }); diff --git a/lib/routes/modelscope/models.ts b/lib/routes/modelscope/models.ts index ffd73aeb644dfb..46f58ad1073538 100644 --- a/lib/routes/modelscope/models.ts +++ b/lib/routes/modelscope/models.ts @@ -1,6 +1,7 @@ import cache from '@/utils/cache'; import got from '@/utils/got'; -const md = require('markdown-it')({ +import MarkdownIt from 'markdown-it'; +const md = MarkdownIt({ html: true, linkify: true, }); diff --git a/lib/routes/modelscope/studios.ts b/lib/routes/modelscope/studios.ts index 9b15aef01eee06..a2cdb823ee5a6f 100644 --- a/lib/routes/modelscope/studios.ts +++ b/lib/routes/modelscope/studios.ts @@ -3,7 +3,8 @@ const __dirname = getCurrentPath(import.meta.url); import cache from '@/utils/cache'; import got from '@/utils/got'; -const md = require('markdown-it')({ +import MarkdownIt from 'markdown-it'; +const md = MarkdownIt({ html: true, linkify: true, }); diff --git a/lib/routes/modrinth/versions.ts b/lib/routes/modrinth/versions.ts index 4bc62245607fe1..5c6740f8eeedd3 100644 --- a/lib/routes/modrinth/versions.ts +++ b/lib/routes/modrinth/versions.ts @@ -6,6 +6,7 @@ import { art } from '@/utils/render'; import * as path from 'node:path'; import { config } from '@/config'; import got from '@/utils/got'; +import MarkdownIt from 'markdown-it'; const customGot = got.extend({ headers: { @@ -13,7 +14,7 @@ const customGot = got.extend({ 'user-agent': config.trueUA, }, }); -const markdownIt = require('markdown-it')({ +const md = MarkdownIt({ html: true, }); @@ -64,7 +65,7 @@ export default async ( pubDate: parseDate(it.date_published), description: art(path.join(__dirname, 'templates/version.art'), { ...it, - changelog: markdownIt.render(it.changelog), + changelog: md.render(it.changelog), }), guid: it.id, author: authors[index].name, diff --git a/lib/routes/mrdx/daily.ts b/lib/routes/mrdx/daily.ts index 17804f54315cf9..88374a7a6a695c 100644 --- a/lib/routes/mrdx/daily.ts +++ b/lib/routes/mrdx/daily.ts @@ -2,8 +2,8 @@ import cache from '@/utils/cache'; import { load } from 'cheerio'; import { parseDate } from '@/utils/parse-date'; import { getElementChildrenInnerText } from './utils'; -const dayjs = require('dayjs'); -const utc = require('dayjs/plugin/utc'); +import dayjs from 'dayjs'; +import utc from 'dayjs/plugin/utc'; dayjs.extend(utc); import got from '@/utils/got'; diff --git a/lib/routes/nature/cover.ts b/lib/routes/nature/cover.ts index bab83f1d55120f..a08a3823fccc98 100644 --- a/lib/routes/nature/cover.ts +++ b/lib/routes/nature/cover.ts @@ -19,7 +19,7 @@ import got from '@/utils/got'; import { load } from 'cheerio'; import { parseDate } from '@/utils/parse-date'; import { baseUrl, journalMap } from './utils'; -const { CookieJar } = require('tough-cookie'); +import { CookieJar } from 'tough-cookie'; export default async (ctx) => { const cookieJar = new CookieJar(); diff --git a/lib/routes/nature/utils.ts b/lib/routes/nature/utils.ts index 751a2c10cbfbe6..b32d7844a793ae 100644 --- a/lib/routes/nature/utils.ts +++ b/lib/routes/nature/utils.ts @@ -2,7 +2,7 @@ import cache from '@/utils/cache'; import got from '@/utils/got'; import { load } from 'cheerio'; import { parseDate } from '@/utils/parse-date'; -const { CookieJar } = require('tough-cookie'); +import { CookieJar } from 'tough-cookie'; const baseUrl = 'https://www.nature.com'; const fixFigure = (html) => { diff --git a/lib/routes/ncc-cma/cmdp.ts b/lib/routes/ncc-cma/cmdp.ts index d059619d186394..f504bb33213222 100644 --- a/lib/routes/ncc-cma/cmdp.ts +++ b/lib/routes/ncc-cma/cmdp.ts @@ -6,7 +6,7 @@ import { load } from 'cheerio'; import { parseDate } from '@/utils/parse-date'; import { art } from '@/utils/render'; import * as path from 'node:path'; -const iconv = require('iconv-lite'); +import iconv from 'iconv-lite'; export default async (ctx) => { const id = ctx.req.param('id'); diff --git a/lib/routes/nextapple/realtime.ts b/lib/routes/nextapple/realtime.ts index 65103a5e99b0fb..054e6717027221 100644 --- a/lib/routes/nextapple/realtime.ts +++ b/lib/routes/nextapple/realtime.ts @@ -2,7 +2,7 @@ import cache from '@/utils/cache'; import got from '@/utils/got'; import { parseDate } from '@/utils/parse-date'; import { load } from 'cheerio'; -const asyncPool = require('tiny-async-pool'); +import asyncPool from 'tiny-async-pool'; export default async (ctx) => { const category = ctx.req.param('category') ?? 'latest'; diff --git a/lib/routes/nga/post.ts b/lib/routes/nga/post.ts index 2ae9e21cbe0179..f536e7b3308659 100644 --- a/lib/routes/nga/post.ts +++ b/lib/routes/nga/post.ts @@ -1,6 +1,6 @@ import got from '@/utils/got'; import { load } from 'cheerio'; -const iconv = require('iconv-lite'); +import iconv from 'iconv-lite'; import { parseDate } from '@/utils/parse-date'; import timezone from '@/utils/timezone'; import { config } from '@/config'; diff --git a/lib/routes/nintendo/utils.ts b/lib/routes/nintendo/utils.ts index b2f7e984590bb2..3918f63231fa9d 100644 --- a/lib/routes/nintendo/utils.ts +++ b/lib/routes/nintendo/utils.ts @@ -3,13 +3,13 @@ const __dirname = getCurrentPath(import.meta.url); import got from '@/utils/got'; import { load } from 'cheerio'; -const { JSDOM } = require('jsdom'); +import { JSDOM } from 'jsdom'; import { parseDate } from '@/utils/parse-date'; import { art } from '@/utils/render'; import * as path from 'node:path'; -const dayjs = require('dayjs'); -const localizedFormat = require('dayjs/plugin/localizedFormat'); -require('dayjs/locale/zh-cn'); +import dayjs from 'dayjs'; +import localizedFormat from 'dayjs/plugin/localizedFormat'; +import 'dayjs/locale/zh-cn'; dayjs.extend(localizedFormat); function nuxtReader(data) { diff --git a/lib/routes/nju/exchangesys.ts b/lib/routes/nju/exchangesys.ts index 1f31ccc955886b..32b81bc3493a5b 100644 --- a/lib/routes/nju/exchangesys.ts +++ b/lib/routes/nju/exchangesys.ts @@ -1,5 +1,5 @@ import got from '@/utils/got'; -const dayjs = require('dayjs'); +import dayjs from 'dayjs'; export default async (ctx) => { const type = ctx.req.param('type'); diff --git a/lib/routes/notefolio/search.ts b/lib/routes/notefolio/search.ts index 404d3b84e6aae6..c3d7aca0b8aba1 100644 --- a/lib/routes/notefolio/search.ts +++ b/lib/routes/notefolio/search.ts @@ -4,7 +4,7 @@ const __dirname = getCurrentPath(import.meta.url); // 导入所需模组 import got from '@/utils/got'; // 自订的 got import { parseDate } from '@/utils/parse-date'; -const dayjs = require('dayjs'); +import dayjs from 'dayjs'; import * as path from 'node:path'; import { art } from '@/utils/render'; diff --git a/lib/routes/notion/database.ts b/lib/routes/notion/database.ts index 9667b0b3c16447..9783b286af8c27 100644 --- a/lib/routes/notion/database.ts +++ b/lib/routes/notion/database.ts @@ -1,12 +1,13 @@ import cache from '@/utils/cache'; -const { Client, isNotionClientError, APIErrorCode } = require('@notionhq/client'); +import { Client, isNotionClientError, APIErrorCode } from '@notionhq/client'; import logger from '@/utils/logger'; import { config } from '@/config'; import { parseDate } from '@/utils/parse-date'; import got from '@/utils/got'; -const { NotionToMarkdown } = require('notion-to-md'); +import { NotionToMarkdown } from 'notion-to-md'; import { load } from 'cheerio'; -const md = require('markdown-it')({ +import MarkdownIt from 'markdown-it'; +const md = MarkdownIt({ html: true, linkify: true, }); diff --git a/lib/routes/nowcoder/jobcenter.ts b/lib/routes/nowcoder/jobcenter.ts index 8c3ebbb7630bba..743cdc3a487249 100644 --- a/lib/routes/nowcoder/jobcenter.ts +++ b/lib/routes/nowcoder/jobcenter.ts @@ -1,5 +1,5 @@ import cache from '@/utils/cache'; -const url = require('url'); +import * as url from 'node:url'; import got from '@/utils/got'; import { load } from 'cheerio'; diff --git a/lib/routes/nyaa/main.ts b/lib/routes/nyaa/main.ts index cb6660b0000390..d5e05e0f23495b 100644 --- a/lib/routes/nyaa/main.ts +++ b/lib/routes/nyaa/main.ts @@ -1,5 +1,5 @@ import { config } from '@/config'; -const Parser = require('rss-parser'); +import Parser from 'rss-parser'; export default async (ctx) => { const parser = new Parser({ diff --git a/lib/routes/oceanengine/arithmetic-index.ts b/lib/routes/oceanengine/arithmetic-index.ts index 067da2aa364c9b..e0d51d7f1d1dc4 100644 --- a/lib/routes/oceanengine/arithmetic-index.ts +++ b/lib/routes/oceanengine/arithmetic-index.ts @@ -2,13 +2,14 @@ import { getCurrentPath } from '@/utils/helpers'; const __dirname = getCurrentPath(import.meta.url); import cache from '@/utils/cache'; -const dayjs = require('dayjs'); +import dayjs from 'dayjs'; import { art } from '@/utils/render'; import { parseDate } from '@/utils/parse-date'; import timezone from '@/utils/timezone'; import * as path from 'node:path'; import { config } from '@/config'; import puppeteer from '@/utils/puppeteer'; +import { createDecipheriv } from 'node:crypto'; // Parameters const CACHE_MAX_AGE = config.cache.contentExpire; @@ -47,7 +48,6 @@ const getMultiKeywordHotTrend = async (page, keyword, start_date, end_date, app_ }; // Decrypt Data -const { createDecipheriv } = require('node:crypto'); const key = 'anN2bXA2NjYsamlh'; const iv = 'amlheW91LHFpYW53'; const algorithm = 'aes-128-cfb'; diff --git a/lib/routes/oncc/money18.ts b/lib/routes/oncc/money18.ts index a32e23940c5e22..91bad30ea5c9c2 100644 --- a/lib/routes/oncc/money18.ts +++ b/lib/routes/oncc/money18.ts @@ -4,7 +4,7 @@ const __dirname = getCurrentPath(import.meta.url); import cache from '@/utils/cache'; import got from '@/utils/got'; import { load } from 'cheerio'; -const dayjs = require('dayjs'); +import dayjs from 'dayjs'; import timezone from '@/utils/timezone'; import { parseDate } from '@/utils/parse-date'; import { art } from '@/utils/render'; diff --git a/lib/routes/openai/chatgpt.ts b/lib/routes/openai/chatgpt.ts index d61db06e6fe29f..4a6d6fda2f242c 100644 --- a/lib/routes/openai/chatgpt.ts +++ b/lib/routes/openai/chatgpt.ts @@ -1,10 +1,11 @@ import cache from '@/utils/cache'; -const dayjs = require('dayjs'); +import dayjs from 'dayjs'; import got from '@/utils/got'; import { load } from 'cheerio'; import { config } from '@/config'; -dayjs.extend(require('dayjs/plugin/isSameOrBefore')); +import isSameOrBefore from 'dayjs/plugin/isSameOrBefore'; +dayjs.extend(isSameOrBefore); export default async (ctx) => { const articleUrl = 'https://help.openai.com/en/articles/6825453-chatgpt-release-notes'; diff --git a/lib/routes/oshwhub/explore.ts b/lib/routes/oshwhub/explore.ts index 384ad88366b85d..41d985cfeab6d6 100644 --- a/lib/routes/oshwhub/explore.ts +++ b/lib/routes/oshwhub/explore.ts @@ -8,7 +8,8 @@ import * as path from 'node:path'; import { art } from '@/utils/render'; import timezone from '@/utils/timezone'; import { parseDate } from '@/utils/parse-date'; -const md = require('markdown-it')({ +import MarkdownIt from 'markdown-it'; +const md = MarkdownIt({ html: true, linkify: true, }); diff --git a/lib/routes/parliament/section77.ts b/lib/routes/parliament/section77.ts index b6757400a562c0..2d65202a17d4d6 100644 --- a/lib/routes/parliament/section77.ts +++ b/lib/routes/parliament/section77.ts @@ -2,7 +2,7 @@ import cache from '@/utils/cache'; import got from '@/utils/got'; import { load } from 'cheerio'; import timezone from '@/utils/timezone'; -const { CookieJar } = require('tough-cookie'); +import { CookieJar } from 'tough-cookie'; export default async (ctx) => { const baseUrl = 'https://www.parliament.go.th/section77'; diff --git a/lib/routes/people/index.ts b/lib/routes/people/index.ts index dfe478caae74eb..363b4bb75efcbf 100644 --- a/lib/routes/people/index.ts +++ b/lib/routes/people/index.ts @@ -1,7 +1,7 @@ import cache from '@/utils/cache'; import got from '@/utils/got'; import { load } from 'cheerio'; -const iconv = require('iconv-lite'); +import iconv from 'iconv-lite'; import timezone from '@/utils/timezone'; import { parseDate } from '@/utils/parse-date'; import { isValidHost } from '@/utils/valid-host'; diff --git a/lib/routes/people/xjpjh.ts b/lib/routes/people/xjpjh.ts index f89770363ffb6a..8a7bbe7ceafda6 100644 --- a/lib/routes/people/xjpjh.ts +++ b/lib/routes/people/xjpjh.ts @@ -1,7 +1,7 @@ import cache from '@/utils/cache'; import got from '@/utils/got'; import { load } from 'cheerio'; -const url = require('url'); +import * as url from 'node:url'; const host = 'http://jhsjk.people.cn'; diff --git a/lib/routes/phoronix/index.ts b/lib/routes/phoronix/index.ts index f56e6903e81492..be09d30bd2d029 100644 --- a/lib/routes/phoronix/index.ts +++ b/lib/routes/phoronix/index.ts @@ -2,9 +2,11 @@ import cache from '@/utils/cache'; import parser from '@/utils/rss-parser'; import { load } from 'cheerio'; import got from '@/utils/got'; -const dayjs = require('dayjs'); -dayjs.extend(require('dayjs/plugin/utc')); -dayjs.extend(require('dayjs/plugin/timezone')); +import dayjs from 'dayjs'; +import utc from 'dayjs/plugin/utc'; +import timezone from 'dayjs/plugin/timezone'; +dayjs.extend(utc); +dayjs.extend(timezone); const redirectCacheKey = 'phoronix:redirect'; const webArticlesCacheKey = 'phoronix:web-articles'; diff --git a/lib/routes/picuki/profile.ts b/lib/routes/picuki/profile.ts index a4ec17a360582b..75aa881bbfd5af 100644 --- a/lib/routes/picuki/profile.ts +++ b/lib/routes/picuki/profile.ts @@ -3,7 +3,7 @@ const __dirname = getCurrentPath(import.meta.url); import cache from '@/utils/cache'; import { load } from 'cheerio'; -const chrono = require('chrono-node'); +import chrono from 'chrono-node'; import { art } from '@/utils/render'; import * as path from 'node:path'; import { config } from '@/config'; diff --git a/lib/routes/pikabu/user.ts b/lib/routes/pikabu/user.ts index be0249cf132f0e..04cd49f6cfec9b 100644 --- a/lib/routes/pikabu/user.ts +++ b/lib/routes/pikabu/user.ts @@ -1,6 +1,6 @@ import got from '@/utils/got'; import { load } from 'cheerio'; -const iconv = require('iconv-lite'); +import iconv from 'iconv-lite'; import { parseDate } from '@/utils/parse-date'; import { baseUrl, fixImage, fixVideo } from './utils'; diff --git a/lib/routes/pixiv/api/get-ranking.ts b/lib/routes/pixiv/api/get-ranking.ts index df5653e4f97509..4632763659fa5a 100644 --- a/lib/routes/pixiv/api/get-ranking.ts +++ b/lib/routes/pixiv/api/get-ranking.ts @@ -1,6 +1,6 @@ import got from '../pixiv-got'; import { maskHeader } from '../constants'; -const assert = require('assert'); +import assert from 'assert'; import queryString from 'query-string'; const allowMode = new Set(['day', 'week', 'month', 'day_male', 'day_female', 'day_ai', 'week_original', 'week_rookie', 'day_r18', 'day_r18_ai', 'day_male_r18', 'day_female_r18', 'week_r18', 'week_r18g']); diff --git a/lib/routes/pixiv/pixiv-got.ts b/lib/routes/pixiv/pixiv-got.ts index 8daf8d0eda9182..847439d2a97754 100644 --- a/lib/routes/pixiv/pixiv-got.ts +++ b/lib/routes/pixiv/pixiv-got.ts @@ -1,4 +1,4 @@ -const tls = require('tls'); +import tls from 'tls'; import ipRegex from 'ip-regex'; import got from '@/utils/got'; import logger from '@/utils/logger'; diff --git a/lib/routes/playno1/utils.ts b/lib/routes/playno1/utils.ts index 976ad0a9b11372..10cbe66f89024b 100644 --- a/lib/routes/playno1/utils.ts +++ b/lib/routes/playno1/utils.ts @@ -1,6 +1,6 @@ import got from '@/utils/got'; import { load } from 'cheerio'; -const { CookieJar, Cookie } = require('tough-cookie'); +import { CookieJar, Cookie } from 'tough-cookie'; const cookieJar = new CookieJar(); const cookie = Cookie.fromJSON({ key: 'playno1', diff --git a/lib/routes/plurk/search.ts b/lib/routes/plurk/search.ts index 19d10066c81af0..f5b9675b9ee81e 100644 --- a/lib/routes/plurk/search.ts +++ b/lib/routes/plurk/search.ts @@ -1,6 +1,6 @@ import cache from '@/utils/cache'; import got from '@/utils/got'; -const dayjs = require('dayjs'); +import dayjs from 'dayjs'; import { baseUrl, getPlurk } from './utils'; export default async (ctx) => { diff --git a/lib/routes/pnas/index.ts b/lib/routes/pnas/index.ts index 4f7c7ead6332b4..c667ff730a2778 100644 --- a/lib/routes/pnas/index.ts +++ b/lib/routes/pnas/index.ts @@ -8,7 +8,7 @@ import { parseDate } from '@/utils/parse-date'; import { art } from '@/utils/render'; import * as path from 'node:path'; import { setCookies } from '@/utils/puppeteer-utils'; -const { CookieJar } = require('tough-cookie'); +import { CookieJar } from 'tough-cookie'; import logger from '@/utils/logger'; import puppeteer from '@/utils/puppeteer'; diff --git a/lib/routes/pornhub/utils.ts b/lib/routes/pornhub/utils.ts index e3489611e4fbd1..6112bfc1afde7d 100644 --- a/lib/routes/pornhub/utils.ts +++ b/lib/routes/pornhub/utils.ts @@ -4,7 +4,7 @@ const __dirname = getCurrentPath(import.meta.url); import { art } from '@/utils/render'; import * as path from 'node:path'; import { parseRelativeDate } from '@/utils/parse-date'; -const dayjs = require('dayjs'); +import dayjs from 'dayjs'; const defaultDomain = 'https://www.pornhub.com'; diff --git a/lib/routes/postman/release-notes.ts b/lib/routes/postman/release-notes.ts index 578543abed31c0..56f31b94cded3b 100644 --- a/lib/routes/postman/release-notes.ts +++ b/lib/routes/postman/release-notes.ts @@ -1,5 +1,6 @@ import got from '@/utils/got'; -const md = require('markdown-it')({ +import MarkdownIt from 'markdown-it'; +const md = MarkdownIt({ html: true, }); diff --git a/lib/routes/qingting/podcast.ts b/lib/routes/qingting/podcast.ts index 8d88c1560bb54d..f432a32f0a9b89 100644 --- a/lib/routes/qingting/podcast.ts +++ b/lib/routes/qingting/podcast.ts @@ -1,5 +1,5 @@ import cache from '@/utils/cache'; -const crypto = require('crypto'); +import crypto from 'crypto'; import got from '@/utils/got'; import timezone from '@/utils/timezone'; import { parseDate } from '@/utils/parse-date'; diff --git a/lib/routes/qq/fact/index.ts b/lib/routes/qq/fact/index.ts index bffb8026db6e20..e284810777987e 100644 --- a/lib/routes/qq/fact/index.ts +++ b/lib/routes/qq/fact/index.ts @@ -5,7 +5,7 @@ import cache from '@/utils/cache'; import got from '@/utils/got'; import { parseDate } from '@/utils/parse-date'; import { load } from 'cheerio'; -const CryptoJS = require('crypto-js'); +import CryptoJS from 'crypto-js'; import { art } from '@/utils/render'; import * as path from 'node:path'; diff --git a/lib/routes/qq/kg/cache.ts b/lib/routes/qq/kg/cache.ts index a26c88f0984c7d..18cb4ac7ead7ea 100644 --- a/lib/routes/qq/kg/cache.ts +++ b/lib/routes/qq/kg/cache.ts @@ -1,6 +1,6 @@ import cache from '@/utils/cache'; import got from '@/utils/got'; -const { JSDOM } = require('jsdom'); +import { JSDOM } from 'jsdom'; export default { getPlayInfo: async (ctx, shareId, ksong_mid = '') => { diff --git a/lib/routes/qq/kg/user.ts b/lib/routes/qq/kg/user.ts index 4f0540ae268970..3bf402d2459d6b 100644 --- a/lib/routes/qq/kg/user.ts +++ b/lib/routes/qq/kg/user.ts @@ -1,5 +1,5 @@ import got from '@/utils/got'; -const { JSDOM } = require('jsdom'); +import { JSDOM } from 'jsdom'; import cache from './cache'; import { parseDate } from '@/utils/parse-date'; diff --git a/lib/routes/radio/album.ts b/lib/routes/radio/album.ts index 83bd4e31996217..bb0ee6781a1649 100644 --- a/lib/routes/radio/album.ts +++ b/lib/routes/radio/album.ts @@ -5,7 +5,7 @@ import got from '@/utils/got'; import { parseDate } from '@/utils/parse-date'; import { art } from '@/utils/render'; import * as path from 'node:path'; -const CryptoJS = require('crypto-js'); +import CryptoJS from 'crypto-js'; export default async (ctx) => { const KEY = 'f0fc4c668392f9f9a447e48584c214ee'; diff --git a/lib/routes/radio/zhibo.ts b/lib/routes/radio/zhibo.ts index 654bc5ad9f0e1c..e96a2abd3b0e6a 100644 --- a/lib/routes/radio/zhibo.ts +++ b/lib/routes/radio/zhibo.ts @@ -5,7 +5,7 @@ import got from '@/utils/got'; import { parseDate } from '@/utils/parse-date'; import { art } from '@/utils/render'; import * as path from 'node:path'; -const CryptoJS = require('crypto-js'); +import CryptoJS from 'crypto-js'; export default async (ctx) => { const KEY = 'f0fc4c668392f9f9a447e48584c214ee'; diff --git a/lib/routes/readhub/util.ts b/lib/routes/readhub/util.ts index a8c01d14aded5a..584f6e5ad2baab 100644 --- a/lib/routes/readhub/util.ts +++ b/lib/routes/readhub/util.ts @@ -5,7 +5,7 @@ import got from '@/utils/got'; import { parseDate } from '@/utils/parse-date'; import { art } from '@/utils/render'; import * as path from 'node:path'; -const dayjs = require('dayjs'); +import dayjs from 'dayjs'; const domain = 'readhub.cn'; const rootUrl = `https://${domain}`; diff --git a/lib/routes/sciencenet/blog.ts b/lib/routes/sciencenet/blog.ts index abb7634e3ddc62..e54f47b5166a1e 100644 --- a/lib/routes/sciencenet/blog.ts +++ b/lib/routes/sciencenet/blog.ts @@ -1,7 +1,7 @@ import cache from '@/utils/cache'; import got from '@/utils/got'; import { load } from 'cheerio'; -const iconv = require('iconv-lite'); +import iconv from 'iconv-lite'; import timezone from '@/utils/timezone'; import { parseDate } from '@/utils/parse-date'; diff --git a/lib/routes/sciencenet/user.ts b/lib/routes/sciencenet/user.ts index b4ba161d6e066d..64ca36677c4ff6 100644 --- a/lib/routes/sciencenet/user.ts +++ b/lib/routes/sciencenet/user.ts @@ -1,7 +1,7 @@ import cache from '@/utils/cache'; import got from '@/utils/got'; import { load } from 'cheerio'; -const iconv = require('iconv-lite'); +import iconv from 'iconv-lite'; import timezone from '@/utils/timezone'; import { parseDate } from '@/utils/parse-date'; diff --git a/lib/routes/scut/jwc/news.ts b/lib/routes/scut/jwc/news.ts index 7041e18f8aba12..9d25af9f5f17e4 100644 --- a/lib/routes/scut/jwc/news.ts +++ b/lib/routes/scut/jwc/news.ts @@ -1,7 +1,7 @@ import cache from '@/utils/cache'; import got from '@/utils/got'; -const url = require('url'); -const querystring = require('querystring'); +import * as url from 'node:url'; +import querystring from 'querystring'; const baseUrl = 'http://jw.scut.edu.cn'; const refererUrl = baseUrl + '/dist/'; diff --git a/lib/routes/scut/jwc/notice.ts b/lib/routes/scut/jwc/notice.ts index ce2c0e89ad42ec..c91c39a309fa47 100644 --- a/lib/routes/scut/jwc/notice.ts +++ b/lib/routes/scut/jwc/notice.ts @@ -1,7 +1,7 @@ import cache from '@/utils/cache'; import got from '@/utils/got'; -const url = require('url'); -const querystring = require('querystring'); +import * as url from 'node:url'; +import querystring from 'querystring'; const baseUrl = 'http://jw.scut.edu.cn'; const refererUrl = baseUrl + '/dist/'; diff --git a/lib/routes/scut/jwc/school.ts b/lib/routes/scut/jwc/school.ts index 58b502278fffbd..dbf79de21ed648 100644 --- a/lib/routes/scut/jwc/school.ts +++ b/lib/routes/scut/jwc/school.ts @@ -1,7 +1,7 @@ import cache from '@/utils/cache'; import got from '@/utils/got'; -const url = require('url'); -const querystring = require('querystring'); +import * as url from 'node:url'; +import querystring from 'querystring'; const baseUrl = 'http://jw.scut.edu.cn'; const refererUrl = baseUrl + '/dist/'; diff --git a/lib/routes/seekingalpha/index.ts b/lib/routes/seekingalpha/index.ts index 06ef5bc7543ccf..a7fa5f76e9f539 100644 --- a/lib/routes/seekingalpha/index.ts +++ b/lib/routes/seekingalpha/index.ts @@ -2,7 +2,7 @@ import cache from '@/utils/cache'; import got from '@/utils/got'; import { load } from 'cheerio'; import { parseDate } from '@/utils/parse-date'; -const dayjs = require('dayjs'); +import dayjs from 'dayjs'; const baseUrl = 'https://seekingalpha.com'; export default async (ctx) => { diff --git a/lib/routes/segmentfault/utils.ts b/lib/routes/segmentfault/utils.ts index ef77467614542c..bf5c4dbe44b230 100644 --- a/lib/routes/segmentfault/utils.ts +++ b/lib/routes/segmentfault/utils.ts @@ -1,4 +1,4 @@ -const zlib = require('zlib'); +import zlib from 'zlib'; import got from '@/utils/got'; import { load } from 'cheerio'; import { parseDate } from '@/utils/parse-date'; diff --git a/lib/routes/sehuatang/index.ts b/lib/routes/sehuatang/index.ts index 4d38ae01ad2791..ee0a265e08ef7b 100644 --- a/lib/routes/sehuatang/index.ts +++ b/lib/routes/sehuatang/index.ts @@ -3,7 +3,7 @@ import got from '@/utils/got'; import { load } from 'cheerio'; import { parseDate } from '@/utils/parse-date'; import timezone from '@/utils/timezone'; -const { CookieJar } = require('tough-cookie'); +import { CookieJar } from 'tough-cookie'; const cookieJar = new CookieJar(); const host = 'https://www.sehuatang.net/'; diff --git a/lib/routes/shiep/index.ts b/lib/routes/shiep/index.ts index 9417b4122ae794..2be412f87da6e2 100644 --- a/lib/routes/shiep/index.ts +++ b/lib/routes/shiep/index.ts @@ -4,7 +4,7 @@ const __dirname = getCurrentPath(import.meta.url); import cache from '@/utils/cache'; import got from '@/utils/got'; import { load } from 'cheerio'; -const dayjs = require('dayjs'); +import dayjs from 'dayjs'; import * as path from 'node:path'; import { parseDate } from '@/utils/parse-date'; import { art } from '@/utils/render'; diff --git a/lib/routes/shoppingdesign/posts.ts b/lib/routes/shoppingdesign/posts.ts index 5035632ab37797..5fa67c25430c11 100644 --- a/lib/routes/shoppingdesign/posts.ts +++ b/lib/routes/shoppingdesign/posts.ts @@ -2,7 +2,7 @@ import cache from '@/utils/cache'; import got from '@/utils/got'; import { load } from 'cheerio'; import { parseDate } from '@/utils/parse-date'; -const asyncPool = require('tiny-async-pool'); +import asyncPool from 'tiny-async-pool'; export default async (ctx) => { // sn_f parameter is required to prevent redirection diff --git a/lib/routes/springer/journal.ts b/lib/routes/springer/journal.ts index 499c0cbee06cab..03988c335412ad 100644 --- a/lib/routes/springer/journal.ts +++ b/lib/routes/springer/journal.ts @@ -7,7 +7,7 @@ import { load } from 'cheerio'; import * as path from 'node:path'; import { art } from '@/utils/render'; -const { CookieJar } = require('tough-cookie'); +import { CookieJar } from 'tough-cookie'; const cookieJar = new CookieJar(); export default async (ctx) => { diff --git a/lib/routes/sse/renewal.ts b/lib/routes/sse/renewal.ts index 24f68819b8d88c..7570952def2149 100644 --- a/lib/routes/sse/renewal.ts +++ b/lib/routes/sse/renewal.ts @@ -5,9 +5,9 @@ import got from '@/utils/got'; import { parseDate } from '@/utils/parse-date'; import { art } from '@/utils/render'; import * as path from 'node:path'; -const dayjs = require('dayjs'); -const localizedFormat = require('dayjs/plugin/localizedFormat'); -require('dayjs/locale/zh-cn'); +import dayjs from 'dayjs'; +import localizedFormat from 'dayjs/plugin/localizedFormat'; +import 'dayjs/locale/zh-cn'; dayjs.extend(localizedFormat); const currStatusName = ['全部', '已受理', '已询问', '通过', '未通过', '提交注册', '补充审核', '注册结果', '中止', '终止']; diff --git a/lib/routes/stbu/jsjxy.ts b/lib/routes/stbu/jsjxy.ts index 0936ce2d3439e8..45df6d1d0b4db8 100644 --- a/lib/routes/stbu/jsjxy.ts +++ b/lib/routes/stbu/jsjxy.ts @@ -1,7 +1,7 @@ import cache from '@/utils/cache'; import got from '@/utils/got'; import { load } from 'cheerio'; -const iconv = require('iconv-lite'); +import iconv from 'iconv-lite'; import { parseDate } from '@/utils/parse-date'; import timezone from '@/utils/timezone'; diff --git a/lib/routes/stbu/xyxw.ts b/lib/routes/stbu/xyxw.ts index 9a45d796f848b7..726a923e21ac22 100644 --- a/lib/routes/stbu/xyxw.ts +++ b/lib/routes/stbu/xyxw.ts @@ -1,7 +1,7 @@ import cache from '@/utils/cache'; import got from '@/utils/got'; import { load } from 'cheerio'; -const iconv = require('iconv-lite'); +import iconv from 'iconv-lite'; import { parseDate } from '@/utils/parse-date'; import timezone from '@/utils/timezone'; diff --git a/lib/routes/studygolang/utils.ts b/lib/routes/studygolang/utils.ts index 76bca4d266f250..60dd6bdb6124cd 100644 --- a/lib/routes/studygolang/utils.ts +++ b/lib/routes/studygolang/utils.ts @@ -3,7 +3,8 @@ import got from '@/utils/got'; import { load } from 'cheerio'; import timezone from '@/utils/timezone'; import { parseDate } from '@/utils/parse-date'; -const md = require('markdown-it')({ +import MarkdownIt from 'markdown-it'; +const md = MarkdownIt({ html: true, linkify: true, }); diff --git a/lib/routes/syosetu/chapter.ts b/lib/routes/syosetu/chapter.ts index 6ef0cc09f3c78c..2e64eb8fac5140 100644 --- a/lib/routes/syosetu/chapter.ts +++ b/lib/routes/syosetu/chapter.ts @@ -3,7 +3,7 @@ import got from '@/utils/got'; import { load } from 'cheerio'; import timezone from '@/utils/timezone'; import { parseDate } from '@/utils/parse-date'; -const { CookieJar } = require('tough-cookie'); +import { CookieJar } from 'tough-cookie'; const cookieJar = new CookieJar(); cookieJar.setCookieSync('over18=yes', 'https://novel18.syosetu.com/'); diff --git a/lib/routes/sysu/ygafz.ts b/lib/routes/sysu/ygafz.ts index 00a28cb9a7fa0e..54f9f5d8c1d159 100644 --- a/lib/routes/sysu/ygafz.ts +++ b/lib/routes/sysu/ygafz.ts @@ -3,7 +3,7 @@ import got from '@/utils/got'; import { load } from 'cheerio'; import { parseDate } from '@/utils/parse-date'; import logger from '@/utils/logger'; -const { CookieJar } = require('tough-cookie'); +import { CookieJar } from 'tough-cookie'; import puppeteer from '@/utils/puppeteer'; export default async (ctx) => { diff --git a/lib/routes/szse/notice.ts b/lib/routes/szse/notice.ts index 702f7c71abecc8..4b777516c06d12 100644 --- a/lib/routes/szse/notice.ts +++ b/lib/routes/szse/notice.ts @@ -1,7 +1,7 @@ import cache from '@/utils/cache'; import got from '@/utils/got'; import { load } from 'cheerio'; -const url = require('url'); +import * as url from 'node:url'; const host = 'http://www.szse.cn/'; export default async (ctx) => { const link = 'http://www.szse.cn/disclosure/notice/company/index.html'; diff --git a/lib/routes/telecompaper/news.ts b/lib/routes/telecompaper/news.ts index 9fc93962f7c587..9f8a35aabf9dd8 100644 --- a/lib/routes/telecompaper/news.ts +++ b/lib/routes/telecompaper/news.ts @@ -1,9 +1,9 @@ import cache from '@/utils/cache'; import got from '@/utils/got'; import { load } from 'cheerio'; -const tough = require('tough-cookie'); +import tough from 'tough-cookie'; // eslint-disable-next-line n/no-extraneous-require -const FormData = require('form-data'); +import FormData from 'form-data'; export default async (ctx) => { const rootUrl = `https://www.telecompaper.com/${ctx.req.param('caty') === 'industry-resources' ? ctx.req.param('caty') : 'international/news/' + ctx.req.param('caty')}`; diff --git a/lib/routes/telegram/blog.ts b/lib/routes/telegram/blog.ts index 266ae5c59a5608..af54242bc863ea 100644 --- a/lib/routes/telegram/blog.ts +++ b/lib/routes/telegram/blog.ts @@ -1,5 +1,5 @@ import cache from '@/utils/cache'; -const cherrio = require('cheerio'); +import cherrio from 'cheerio'; import got from '@/utils/got'; import { parseDate } from '@/utils/parse-date'; diff --git a/lib/routes/telegram/channel.ts b/lib/routes/telegram/channel.ts index 22fd2dc9f7e282..e41b0596822500 100644 --- a/lib/routes/telegram/channel.ts +++ b/lib/routes/telegram/channel.ts @@ -8,7 +8,7 @@ import { load } from 'cheerio'; import { parseDate } from '@/utils/parse-date'; import { art } from '@/utils/render'; import * as path from 'node:path'; -const querystring = require('querystring'); +import querystring from 'querystring'; import { fallback, queryToBoolean } from '@/utils/readable-social'; import tglibchannel from './tglib/channel'; diff --git a/lib/routes/telegram/tglib/channel.ts b/lib/routes/telegram/tglib/channel.ts index 2911c2b05d3b90..b31f7f2c0cb514 100644 --- a/lib/routes/telegram/tglib/channel.ts +++ b/lib/routes/telegram/tglib/channel.ts @@ -1,8 +1,8 @@ import wait from '@/utils/wait'; import { config } from '@/config'; import { client, decodeMedia, getFilename, getMediaLink, streamDocument, streamThumbnail } from './client'; -const bigInt = require('telegram/Helpers').returnBigInt; -const HTMLParser = require('telegram/extensions/html').HTMLParser; +import { returnBigInt as bigInt } from 'telegram/Helpers'; +import { HTMLParser } from 'telegram/extensions/html'; function parseRange(range, length) { if (!range) { @@ -162,4 +162,4 @@ export default async (ctx) => { }); }; -module.exports.getMedia = getMedia; +export { getMedia }; diff --git a/lib/routes/telegram/tglib/client.ts b/lib/routes/telegram/tglib/client.ts index bd25b079c34665..47b40673e878bf 100644 --- a/lib/routes/telegram/tglib/client.ts +++ b/lib/routes/telegram/tglib/client.ts @@ -1,7 +1,7 @@ -const readline = require('node:readline/promises'); -const { Api, TelegramClient } = require('telegram'); -const { StringSession } = require('telegram/sessions'); -const { getAppropriatedPartSize } = require('telegram/Utils'); +import readline from 'node:readline/promises'; +import { Api, TelegramClient } from 'telegram'; +import { StringSession } from 'telegram/sessions'; +import { getAppropriatedPartSize } from 'telegram/Utils'; import { config } from '@/config'; diff --git a/lib/routes/tfc-taiwan/utils.ts b/lib/routes/tfc-taiwan/utils.ts index 64e1d18de41093..81abe1ce567988 100644 --- a/lib/routes/tfc-taiwan/utils.ts +++ b/lib/routes/tfc-taiwan/utils.ts @@ -5,7 +5,7 @@ import got from '@/utils/got'; import { load } from 'cheerio'; import * as path from 'node:path'; import { art } from '@/utils/render'; -const asyncPool = require('tiny-async-pool'); +import asyncPool from 'tiny-async-pool'; import { parseDate } from '@/utils/parse-date'; const asyncPoolAll = async (...args) => { diff --git a/lib/routes/threads/utils.ts b/lib/routes/threads/utils.ts index 08a5eccbeab875..5ef44395d2632b 100644 --- a/lib/routes/threads/utils.ts +++ b/lib/routes/threads/utils.ts @@ -1,6 +1,6 @@ import got from '@/utils/got'; import { load } from 'cheerio'; -const dayjs = require('dayjs'); +import dayjs from 'dayjs'; const profileUrl = (user) => `https://www.threads.net/@${user}`; const threadUrl = (code) => `https://www.threads.net/t/${code}`; diff --git a/lib/routes/thwiki/index.ts b/lib/routes/thwiki/index.ts index 6eb805e53e33bf..b423a5eabff9c9 100644 --- a/lib/routes/thwiki/index.ts +++ b/lib/routes/thwiki/index.ts @@ -1,5 +1,5 @@ import got from '@/utils/got'; -const dayjs = require('dayjs'); +import dayjs from 'dayjs'; export default async (ctx) => { const beforeDays = ctx.req.param('before') ? Number.parseInt(ctx.req.param('before')) : 30; diff --git a/lib/routes/tingshuitz/xian.ts b/lib/routes/tingshuitz/xian.ts index 60e445a271b3f3..9a76686f2a42b6 100644 --- a/lib/routes/tingshuitz/xian.ts +++ b/lib/routes/tingshuitz/xian.ts @@ -1,6 +1,6 @@ import got from '@/utils/got'; import { load } from 'cheerio'; -const iconv = require('iconv-lite'); +import iconv from 'iconv-lite'; export default async (ctx) => { const url = 'http://www.xazls.com/tsgg/index.htm'; diff --git a/lib/routes/tju/yzb/index.ts b/lib/routes/tju/yzb/index.ts index 7683ad8db3c9bb..9552d9436b77de 100644 --- a/lib/routes/tju/yzb/index.ts +++ b/lib/routes/tju/yzb/index.ts @@ -1,7 +1,7 @@ import cache from '@/utils/cache'; import got from '@/utils/got'; import { load } from 'cheerio'; -const iconv = require('iconv-lite'); +import iconv from 'iconv-lite'; import { parseDate } from '@/utils/parse-date'; import timezone from '@/utils/timezone'; diff --git a/lib/routes/tradingview/blog.ts b/lib/routes/tradingview/blog.ts index eb9f90fc585a76..420094973ec544 100644 --- a/lib/routes/tradingview/blog.ts +++ b/lib/routes/tradingview/blog.ts @@ -5,7 +5,7 @@ import cache from '@/utils/cache'; import got from '@/utils/got'; import { load } from 'cheerio'; import { parseDate } from '@/utils/parse-date'; -const asyncPool = require('tiny-async-pool'); +import asyncPool from 'tiny-async-pool'; import { art } from '@/utils/render'; import * as path from 'node:path'; diff --git a/lib/routes/trending/all-trending.ts b/lib/routes/trending/all-trending.ts index 267840af67720f..6c9ac0ebb1d45a 100644 --- a/lib/routes/trending/all-trending.ts +++ b/lib/routes/trending/all-trending.ts @@ -2,9 +2,11 @@ import { getCurrentPath } from '@/utils/helpers'; const __dirname = getCurrentPath(import.meta.url); import cache from '@/utils/cache'; -const dayjs = require('dayjs'); -dayjs.extend(require('dayjs/plugin/utc')); -dayjs.extend(require('dayjs/plugin/timezone')); +import dayjs from 'dayjs'; +import utc from 'dayjs/plugin/utc'; +import timezone from 'dayjs/plugin/timezone'; +dayjs.extend(utc); +dayjs.extend(timezone); import got from '@/utils/got'; import { art } from '@/utils/render'; import * as path from 'node:path'; diff --git a/lib/routes/twitter/collection.ts b/lib/routes/twitter/collection.ts index bd935f8f39fe16..6f4cd3b7d4488b 100644 --- a/lib/routes/twitter/collection.ts +++ b/lib/routes/twitter/collection.ts @@ -1,7 +1,7 @@ import utils from './utils'; import { config } from '@/config'; const T = {}; -const { TwitterApi } = require('twitter-api-v2'); +import { TwitterApi } from 'twitter-api-v2'; import { fallback, queryToBoolean } from '@/utils/readable-social'; export default async (ctx) => { diff --git a/lib/routes/twitter/followings.ts b/lib/routes/twitter/followings.ts index 760b613e434cce..0dfc32f0e4609f 100644 --- a/lib/routes/twitter/followings.ts +++ b/lib/routes/twitter/followings.ts @@ -1,7 +1,7 @@ import utils from './utils'; import { config } from '@/config'; const T = {}; -const { TwitterApi } = require('twitter-api-v2'); +import { TwitterApi } from 'twitter-api-v2'; import { fallback, queryToBoolean } from '@/utils/readable-social'; export default async (ctx) => { diff --git a/lib/routes/twitter/utils.ts b/lib/routes/twitter/utils.ts index 30fbf810c353c0..175800e6b36f66 100644 --- a/lib/routes/twitter/utils.ts +++ b/lib/routes/twitter/utils.ts @@ -1,6 +1,6 @@ -const URL = require('url'); +import URL from 'url'; import { config } from '@/config'; -const { TwitterApi } = require('twitter-api-v2'); +import { TwitterApi } from 'twitter-api-v2'; import { fallback, queryToBoolean, queryToInteger } from '@/utils/readable-social'; import { parseDate } from '@/utils/parse-date'; diff --git a/lib/routes/twitter/web-api/login.ts b/lib/routes/twitter/web-api/login.ts index df048d95a05bba..3518ea79739f8d 100644 --- a/lib/routes/twitter/web-api/login.ts +++ b/lib/routes/twitter/web-api/login.ts @@ -2,10 +2,10 @@ import { bearerToken, guestActivateUrl } from './constants'; import got from '@/utils/got'; -const crypto = require('crypto'); +import crypto from 'crypto'; import { config } from '@/config'; -const { v5: uuidv5 } = require('uuid'); -const { authenticator } = require('otplib'); +import { v5 as uuidv5 } from 'uuid'; +import { authenticator } from 'otplib'; import logger from '@/utils/logger'; import cache from '@/utils/cache'; diff --git a/lib/routes/twitter/web-api/twitter-api.ts b/lib/routes/twitter/web-api/twitter-api.ts index 16f3adf0486865..a33d861d008520 100644 --- a/lib/routes/twitter/web-api/twitter-api.ts +++ b/lib/routes/twitter/web-api/twitter-api.ts @@ -2,8 +2,8 @@ import { baseUrl, gqlMap, gqlFeatures, consumerKey, consumerSecret } from './con import { config } from '@/config'; import logger from '@/utils/logger'; import got from '@/utils/got'; -const OAuth = require('oauth-1.0a'); -const CryptoJS = require('crypto-js'); +import OAuth from 'oauth-1.0a'; +import CryptoJS from 'crypto-js'; import queryString from 'query-string'; import { getToken } from './token'; import cache from '@/utils/cache'; diff --git a/lib/routes/txrjy/fornumtopic.ts b/lib/routes/txrjy/fornumtopic.ts index a3af5d4205fae9..f1d88920d24883 100644 --- a/lib/routes/txrjy/fornumtopic.ts +++ b/lib/routes/txrjy/fornumtopic.ts @@ -4,7 +4,7 @@ const __dirname = getCurrentPath(import.meta.url); import cache from '@/utils/cache'; import got from '@/utils/got'; import { load } from 'cheerio'; -const iconv = require('iconv-lite'); +import iconv from 'iconv-lite'; import { parseDate } from '@/utils/parse-date'; import timezone from '@/utils/timezone'; import { art } from '@/utils/render'; diff --git a/lib/routes/uestc/scse.ts b/lib/routes/uestc/scse.ts index 059b2fe4175010..44a76f692b82a3 100644 --- a/lib/routes/uestc/scse.ts +++ b/lib/routes/uestc/scse.ts @@ -1,6 +1,6 @@ import { load } from 'cheerio'; import { parseDate } from '@/utils/parse-date'; -const dayjs = require('dayjs'); +import dayjs from 'dayjs'; import puppeteer from '@/utils/puppeteer'; const baseIndexUrl = 'https://www.scse.uestc.edu.cn/index.htm'; diff --git a/lib/routes/uestc/sice.ts b/lib/routes/uestc/sice.ts index 7402234c14ae4c..8a47ca55aed2f7 100644 --- a/lib/routes/uestc/sice.ts +++ b/lib/routes/uestc/sice.ts @@ -1,6 +1,6 @@ import { load } from 'cheerio'; import { parseDate } from '@/utils/parse-date'; -const dayjs = require('dayjs'); +import dayjs from 'dayjs'; import puppeteer from '@/utils/puppeteer'; const baseIndexUrl = 'https://www.sice.uestc.edu.cn/index.htm'; diff --git a/lib/routes/uestc/sise.ts b/lib/routes/uestc/sise.ts index d0bbdc7330ad0f..282802b9b60241 100644 --- a/lib/routes/uestc/sise.ts +++ b/lib/routes/uestc/sise.ts @@ -1,6 +1,6 @@ import { load } from 'cheerio'; import { parseDate } from '@/utils/parse-date'; -const dayjs = require('dayjs'); +import dayjs from 'dayjs'; import puppeteer from '@/utils/puppeteer'; const baseUrl = 'https://sise.uestc.edu.cn/'; diff --git a/lib/routes/uptimerobot/rss.ts b/lib/routes/uptimerobot/rss.ts index 290313fdb615df..90c9b4f6ffd023 100644 --- a/lib/routes/uptimerobot/rss.ts +++ b/lib/routes/uptimerobot/rss.ts @@ -1,10 +1,10 @@ import { getCurrentPath } from '@/utils/helpers'; const __dirname = getCurrentPath(import.meta.url); -const Parser = require('rss-parser'); +import Parser from 'rss-parser'; import { art } from '@/utils/render'; import * as path from 'node:path'; -const dayjs = require('dayjs'); +import dayjs from 'dayjs'; import { fallback, queryToBoolean } from '@/utils/readable-social'; const titleRegex = /(.+)\s+is\s+([A-Z]+)\s+\((.+)\)/; diff --git a/lib/routes/ustb/yjsy/news.ts b/lib/routes/ustb/yjsy/news.ts index c5cd013c2476a5..03289fafcd6593 100644 --- a/lib/routes/ustb/yjsy/news.ts +++ b/lib/routes/ustb/yjsy/news.ts @@ -1,6 +1,6 @@ import got from '@/utils/got'; import { load } from 'cheerio'; -const iconv = require('iconv-lite'); +import iconv from 'iconv-lite'; import { parseDate } from '@/utils/parse-date'; // import logger from '@/utils/logger'; diff --git a/lib/routes/utgd/category.ts b/lib/routes/utgd/category.ts index 73f67c2e7151c0..dd9e1eba56c70d 100644 --- a/lib/routes/utgd/category.ts +++ b/lib/routes/utgd/category.ts @@ -7,7 +7,8 @@ import timezone from '@/utils/timezone'; import { parseDate } from '@/utils/parse-date'; import { art } from '@/utils/render'; import * as path from 'node:path'; -const md = require('markdown-it')({ +import MarkdownIt from 'markdown-it'; +const md = MarkdownIt({ html: true, }); diff --git a/lib/routes/utgd/timeline.ts b/lib/routes/utgd/timeline.ts index 6c3c2f0d5fced1..1e8bf661101463 100644 --- a/lib/routes/utgd/timeline.ts +++ b/lib/routes/utgd/timeline.ts @@ -7,7 +7,8 @@ import timezone from '@/utils/timezone'; import { parseDate } from '@/utils/parse-date'; import { art } from '@/utils/render'; import * as path from 'node:path'; -const md = require('markdown-it')({ +import MarkdownIt from 'markdown-it'; +const md = MarkdownIt({ html: true, }); diff --git a/lib/routes/utgd/topic.ts b/lib/routes/utgd/topic.ts index 070df371a2982d..776fa4dd28be47 100644 --- a/lib/routes/utgd/topic.ts +++ b/lib/routes/utgd/topic.ts @@ -7,7 +7,8 @@ import timezone from '@/utils/timezone'; import { parseDate } from '@/utils/parse-date'; import { art } from '@/utils/render'; import * as path from 'node:path'; -const md = require('markdown-it')({ +import MarkdownIt from 'markdown-it'; +const md = MarkdownIt({ html: true, }); diff --git a/lib/routes/wechat/mp.ts b/lib/routes/wechat/mp.ts index 705de4e3d4814b..51e15ff6c35f61 100755 --- a/lib/routes/wechat/mp.ts +++ b/lib/routes/wechat/mp.ts @@ -1,6 +1,6 @@ import got from '@/utils/got'; import { load } from 'cheerio'; -const dayjs = require('dayjs'); +import dayjs from 'dayjs'; import { finishArticleItem } from '@/utils/wechat-mp'; export default async (ctx) => { diff --git a/lib/routes/wechat/msgalbum.ts b/lib/routes/wechat/msgalbum.ts index 16d33293fd8b4b..ea758ef019c2d1 100644 --- a/lib/routes/wechat/msgalbum.ts +++ b/lib/routes/wechat/msgalbum.ts @@ -1,6 +1,6 @@ import got from '@/utils/got'; import { load } from 'cheerio'; -const dayjs = require('dayjs'); +import dayjs from 'dayjs'; import { finishArticleItem } from '@/utils/wechat-mp'; export default async (ctx) => { diff --git a/lib/routes/weibo/friends.ts b/lib/routes/weibo/friends.ts index 30854ade8f358b..dc6c814785335a 100644 --- a/lib/routes/weibo/friends.ts +++ b/lib/routes/weibo/friends.ts @@ -1,5 +1,5 @@ import cache from '@/utils/cache'; -const querystring = require('querystring'); +import querystring from 'querystring'; import got from '@/utils/got'; import { config } from '@/config'; import weiboUtils from './utils'; diff --git a/lib/routes/weibo/group.ts b/lib/routes/weibo/group.ts index 807f03df3bbcee..9e6a3a0517e9c2 100644 --- a/lib/routes/weibo/group.ts +++ b/lib/routes/weibo/group.ts @@ -1,5 +1,5 @@ import cache from '@/utils/cache'; -const querystring = require('querystring'); +import querystring from 'querystring'; import got from '@/utils/got'; import { config } from '@/config'; import weiboUtils from './utils'; diff --git a/lib/routes/weibo/keyword.ts b/lib/routes/weibo/keyword.ts index dd4e0ca3bb4f9e..1bd4a6e781d893 100644 --- a/lib/routes/weibo/keyword.ts +++ b/lib/routes/weibo/keyword.ts @@ -1,5 +1,5 @@ import cache from '@/utils/cache'; -const querystring = require('querystring'); +import querystring from 'querystring'; import got from '@/utils/got'; import weiboUtils from './utils'; import timezone from '@/utils/timezone'; diff --git a/lib/routes/weibo/timeline.ts b/lib/routes/weibo/timeline.ts index 01dd5c5f0d9a26..7171ab50e7a89e 100644 --- a/lib/routes/weibo/timeline.ts +++ b/lib/routes/weibo/timeline.ts @@ -1,5 +1,5 @@ import cache from '@/utils/cache'; -const querystring = require('querystring'); +import querystring from 'querystring'; import got from '@/utils/got'; import { parseDate } from '@/utils/parse-date'; import { config } from '@/config'; diff --git a/lib/routes/weibo/utils.ts b/lib/routes/weibo/utils.ts index 4e4d02852adb17..84b4f720286f88 100644 --- a/lib/routes/weibo/utils.ts +++ b/lib/routes/weibo/utils.ts @@ -1,5 +1,5 @@ import cache from '@/utils/cache'; -const querystring = require('querystring'); +import querystring from 'querystring'; import got from '@/utils/got'; import { load } from 'cheerio'; import { fallback, queryToBoolean, queryToInteger } from '@/utils/readable-social'; diff --git a/lib/routes/wenku8/chapter.ts b/lib/routes/wenku8/chapter.ts index e3be78aca5ca61..ba6da82a7e6e79 100644 --- a/lib/routes/wenku8/chapter.ts +++ b/lib/routes/wenku8/chapter.ts @@ -1,6 +1,6 @@ import got from '@/utils/got'; import { load } from 'cheerio'; -const iconv = require('iconv-lite'); +import iconv from 'iconv-lite'; export default async (ctx) => { const id = ctx.req.param('id'); diff --git a/lib/routes/wenku8/index.ts b/lib/routes/wenku8/index.ts index 840d285189163b..f1b3104e0c2a60 100644 --- a/lib/routes/wenku8/index.ts +++ b/lib/routes/wenku8/index.ts @@ -1,6 +1,6 @@ import got from '@/utils/got'; import { load } from 'cheerio'; -const iconv = require('iconv-lite'); +import iconv from 'iconv-lite'; import { config } from '@/config'; const cateUrlMap = { diff --git a/lib/routes/wenku8/volume.ts b/lib/routes/wenku8/volume.ts index 96801b26848909..23c75001059614 100644 --- a/lib/routes/wenku8/volume.ts +++ b/lib/routes/wenku8/volume.ts @@ -1,7 +1,7 @@ import cache from '@/utils/cache'; import got from '@/utils/got'; import { load } from 'cheerio'; -const iconv = require('iconv-lite'); +import iconv from 'iconv-lite'; export default async (ctx) => { const aid = ctx.req.param('id'); diff --git a/lib/routes/wise/pair.ts b/lib/routes/wise/pair.ts index 56a91a5e57541b..183c17fe39b334 100644 --- a/lib/routes/wise/pair.ts +++ b/lib/routes/wise/pair.ts @@ -4,8 +4,8 @@ const __dirname = getCurrentPath(import.meta.url); import cache from '@/utils/cache'; import got from '@/utils/got'; import { parseDate } from '@/utils/parse-date'; -const dayjs = require('dayjs'); -const customParseFormat = require('dayjs/plugin/customParseFormat'); +import dayjs from 'dayjs'; +import customParseFormat from 'dayjs/plugin/customParseFormat'; dayjs.extend(customParseFormat); import { art } from '@/utils/render'; import * as path from 'node:path'; diff --git a/lib/routes/wsj/utils.ts b/lib/routes/wsj/utils.ts index 36344b0ce50f74..f3697d697e44ec 100644 --- a/lib/routes/wsj/utils.ts +++ b/lib/routes/wsj/utils.ts @@ -2,7 +2,7 @@ import { getCurrentPath } from '@/utils/helpers'; const __dirname = getCurrentPath(import.meta.url); import cache from '@/utils/cache'; -const asyncPool = require('tiny-async-pool'); +import asyncPool from 'tiny-async-pool'; import { load } from 'cheerio'; import got from '@/utils/got'; import { parseDate } from '@/utils/parse-date'; diff --git a/lib/routes/wsyu/news.ts b/lib/routes/wsyu/news.ts index 3e71f5a13de3ce..ce488fe7e998f4 100644 --- a/lib/routes/wsyu/news.ts +++ b/lib/routes/wsyu/news.ts @@ -1,7 +1,7 @@ import cache from '@/utils/cache'; import got from '@/utils/got'; import { load } from 'cheerio'; -const url = require('url'); +import * as url from 'node:url'; const baseUrl = 'http://www.wsyu.edu.cn'; diff --git a/lib/routes/wtu/job.ts b/lib/routes/wtu/job.ts index 32bafcff98c1af..44d1e9fd716a93 100644 --- a/lib/routes/wtu/job.ts +++ b/lib/routes/wtu/job.ts @@ -1,7 +1,7 @@ import cache from '@/utils/cache'; import got from '@/utils/got'; import { parseDate } from '@/utils/parse-date'; -const zlib = require('zlib'); +import zlib from 'zlib'; import { load } from 'cheerio'; const baseUrl = 'https://wtu.91wllm.com/'; diff --git a/lib/routes/wzu/news.ts b/lib/routes/wzu/news.ts index 934b4df88d3780..80d58fde641b5d 100644 --- a/lib/routes/wzu/news.ts +++ b/lib/routes/wzu/news.ts @@ -1,7 +1,7 @@ import cache from '@/utils/cache'; import got from '@/utils/got'; import { load } from 'cheerio'; -const { URL } = require('url'); +import { URL } from 'url'; import { parseDate } from '@/utils/parse-date'; /* 新闻列表 diff --git a/lib/routes/x-mol/paper.ts b/lib/routes/x-mol/paper.ts index 7bfcb55aa006f3..0c3077746402e3 100644 --- a/lib/routes/x-mol/paper.ts +++ b/lib/routes/x-mol/paper.ts @@ -4,7 +4,7 @@ import { load } from 'cheerio'; import utils from './utils'; import { parseDate } from '@/utils/parse-date'; import timezone from '@/utils/timezone'; -const asyncPool = require('tiny-async-pool'); +import asyncPool from 'tiny-async-pool'; export default async (ctx) => { const { type, magazine } = ctx.req.param(); diff --git a/lib/routes/xiaozhuanlan/column.ts b/lib/routes/xiaozhuanlan/column.ts index 5ff55ab7c9fca4..b2563a7cad385e 100644 --- a/lib/routes/xiaozhuanlan/column.ts +++ b/lib/routes/xiaozhuanlan/column.ts @@ -2,7 +2,8 @@ import cache from '@/utils/cache'; import got from '@/utils/got'; import { load } from 'cheerio'; import { parseDate } from '@/utils/parse-date'; -const md = require('markdown-it')({ +import MarkdownIt from 'markdown-it'; +const md = MarkdownIt({ linkify: true, }); const baseUrl = 'https://xiaozhuanlan.com'; diff --git a/lib/routes/ximalaya/utils.ts b/lib/routes/ximalaya/utils.ts index 7a6428836cffaa..c5b01864f5c1e5 100644 --- a/lib/routes/ximalaya/utils.ts +++ b/lib/routes/ximalaya/utils.ts @@ -1,4 +1,4 @@ -const crypto = require('crypto'); +import crypto from 'crypto'; const getParams = (ep) => { const a1 = 'xkt3a41psizxrh9l'; const a = [ diff --git a/lib/routes/xueqiu/column.ts b/lib/routes/xueqiu/column.ts index 78a2922391d0f5..ad94dc2e8a97b3 100644 --- a/lib/routes/xueqiu/column.ts +++ b/lib/routes/xueqiu/column.ts @@ -1,6 +1,6 @@ import got from '@/utils/got'; -const { JSDOM } = require('jsdom'); -const { CookieJar } = require('tough-cookie'); +import { JSDOM } from 'jsdom'; +import { CookieJar } from 'tough-cookie'; import { parseDate } from '@/utils/parse-date'; const cookieJar = new CookieJar(); const baseUrl = 'https://xueqiu.com'; diff --git a/lib/routes/xueqiu/hots.ts b/lib/routes/xueqiu/hots.ts index dce5c896615171..788fa2d8cd33e0 100644 --- a/lib/routes/xueqiu/hots.ts +++ b/lib/routes/xueqiu/hots.ts @@ -1,7 +1,7 @@ import got from '@/utils/got'; import queryString from 'query-string'; import { parseDate } from '@/utils/parse-date'; -const sanitizeHtml = require('sanitize-html'); +import sanitizeHtml from 'sanitize-html'; export default async (ctx) => { const res1 = await got({ diff --git a/lib/routes/xueqiu/stock-comments.ts b/lib/routes/xueqiu/stock-comments.ts index 405558cab553be..b0981723fb8f3e 100644 --- a/lib/routes/xueqiu/stock-comments.ts +++ b/lib/routes/xueqiu/stock-comments.ts @@ -7,7 +7,7 @@ import { load } from 'cheerio'; import { art } from '@/utils/render'; import * as path from 'node:path'; import { parseDate } from '@/utils/parse-date'; -const sanitizeHtml = require('sanitize-html'); +import sanitizeHtml from 'sanitize-html'; export default async (ctx) => { const id = ctx.req.param('id'); diff --git a/lib/routes/xueqiu/stock-info.ts b/lib/routes/xueqiu/stock-info.ts index 3093b2e330d743..b1f618a28cd7c7 100644 --- a/lib/routes/xueqiu/stock-info.ts +++ b/lib/routes/xueqiu/stock-info.ts @@ -2,7 +2,7 @@ import got from '@/utils/got'; import { load } from 'cheerio'; import queryString from 'query-string'; import { parseDate } from '@/utils/parse-date'; -const sanitizeHtml = require('sanitize-html'); +import sanitizeHtml from 'sanitize-html'; export default async (ctx) => { const id = ctx.req.param('id'); diff --git a/lib/routes/xueqiu/user.ts b/lib/routes/xueqiu/user.ts index c2d4e8fb555375..23a421f08e2cd2 100644 --- a/lib/routes/xueqiu/user.ts +++ b/lib/routes/xueqiu/user.ts @@ -2,7 +2,7 @@ import cache from '@/utils/cache'; import got from '@/utils/got'; import queryString from 'query-string'; import { parseDate } from '@/utils/parse-date'; -const sanitizeHtml = require('sanitize-html'); +import sanitizeHtml from 'sanitize-html'; const rootUrl = 'https://xueqiu.com'; diff --git a/lib/routes/xys/new.ts b/lib/routes/xys/new.ts index dd9c238ed5c69e..5878bec95f40d7 100644 --- a/lib/routes/xys/new.ts +++ b/lib/routes/xys/new.ts @@ -4,7 +4,7 @@ const __dirname = getCurrentPath(import.meta.url); import cache from '@/utils/cache'; import got from '@/utils/got'; import { load } from 'cheerio'; -const iconv = require('iconv-lite'); +import iconv from 'iconv-lite'; import * as path from 'node:path'; import { parseDate } from '@/utils/parse-date'; import { art } from '@/utils/render'; diff --git a/lib/routes/youtube/subscriptions.ts b/lib/routes/youtube/subscriptions.ts index f8a7232afcecec..992c4d194b2f1e 100644 --- a/lib/routes/youtube/subscriptions.ts +++ b/lib/routes/youtube/subscriptions.ts @@ -2,7 +2,7 @@ import cache from '@/utils/cache'; import { config } from '@/config'; import utils from './utils'; import { parseDate } from '@/utils/parse-date'; -const asyncPool = require('tiny-async-pool'); +import asyncPool from 'tiny-async-pool'; export default async (ctx) => { if (!config.youtube || !config.youtube.key || !config.youtube.clientId || !config.youtube.clientSecret || !config.youtube.refreshToken) { diff --git a/lib/routes/youtube/utils.ts b/lib/routes/youtube/utils.ts index c3f3a045ee8a6f..adcdd0240a2a08 100644 --- a/lib/routes/youtube/utils.ts +++ b/lib/routes/youtube/utils.ts @@ -1,7 +1,7 @@ import { getCurrentPath } from '@/utils/helpers'; const __dirname = getCurrentPath(import.meta.url); -const { google } = require('googleapis'); +import { google } from 'googleapis'; const { OAuth2 } = google.auth; import { art } from '@/utils/render'; import * as path from 'node:path'; diff --git a/lib/routes/yuque/book.ts b/lib/routes/yuque/book.ts index d89a0e86753ab7..2407f8f1e75fe0 100644 --- a/lib/routes/yuque/book.ts +++ b/lib/routes/yuque/book.ts @@ -3,7 +3,7 @@ import got from '@/utils/got'; import { load } from 'cheerio'; import { parseDate } from '@/utils/parse-date'; import { card2Html } from './utils'; -const { CookieJar } = require('tough-cookie'); +import { CookieJar } from 'tough-cookie'; const APP_DATA_REGEX = /window\.appData = JSON\.parse\(decodeURIComponent\("(.+?)"\)\);/; const baseUrl = 'https://www.yuque.com'; diff --git a/lib/routes/zaobao/util.ts b/lib/routes/zaobao/util.ts index c2505b19ffed3c..e74bcecea1de89 100644 --- a/lib/routes/zaobao/util.ts +++ b/lib/routes/zaobao/util.ts @@ -8,7 +8,7 @@ import { parseRelativeDate } from '@/utils/parse-date'; import timezone from '@/utils/timezone'; import { art } from '@/utils/render'; import * as path from 'node:path'; -const { base32 } = require('rfc4648'); +import { base32 } from 'rfc4648'; const baseUrl = 'https://www.zaobao.com'; const got_ins = got.extend({ diff --git a/lib/routes/zhiy/post.ts b/lib/routes/zhiy/post.ts index e9985c7962e375..c158ff55bbb1d1 100644 --- a/lib/routes/zhiy/post.ts +++ b/lib/routes/zhiy/post.ts @@ -7,7 +7,7 @@ import { parseDate } from '@/utils/parse-date'; import { baseUrl, fetchUserDate } from './utils'; import { art } from '@/utils/render'; import * as path from 'node:path'; -const dayjs = require('dayjs'); +import dayjs from 'dayjs'; export default async (ctx) => { art.defaults.imports = {
77a23f88244a554651af6c16ffdd9f510cf1fb21
2020-05-18 22:29:38
prnake
fix: regex for initium (#4806)
false
regex for initium (#4806)
fix
diff --git a/lib/routes/initium/full.js b/lib/routes/initium/full.js index 4650b13bc108f0..612c99188388c8 100644 --- a/lib/routes/initium/full.js +++ b/lib/routes/initium/full.js @@ -90,7 +90,9 @@ module.exports = async (ctx) => { if (data.byline.length) { content += '<p>' + data.byline + '</p>'; } - content += data.content.replace('<figure class="advertisement"/><br/>', '').replace(/<figure.class="image.invite_friend_image".*$/g, ''); + if (data.content) { + content += data.content.replace('<figure class="advertisement"/><br/>', '').replace(/<figure.class="image.invite_friend_image".*$/g, ''); + } ctx.cache.set(slug + language, content);
b378116a71828d0f5b88c46da7fa3caba181f595
2023-07-09 20:29:39
Andvari
fix(route/sjtu): gs (#12758)
false
gs (#12758)
fix
diff --git a/docs/university.md b/docs/university.md index 915850ecbe5d8a..78c0061687ae96 100644 --- a/docs/university.md +++ b/docs/university.md @@ -2576,11 +2576,11 @@ jsjxy.hbut.edu.cn 证书链不全,自建 RSSHub 可设置环境变量 NODE_TLS ### 电子信息与电气工程学院学术动态 -<Route author="HenryQW" example="/sjtu/seiee/academic" path="/sjtu/seiee/academic"/> +<Route author="HenryQW" example="/sjtu/seiee/academic" path="/sjtu/seiee/academic" radar="1"/> ### 电子信息与电气工程学院本科教务办 -<Route author="Polynomia" example="/sjtu/seiee/bjwb/major_select" path="/sjtu/seiee/bjwb/:type" :paramsDesc="['无默认选项']"> +<Route author="Polynomia" example="/sjtu/seiee/bjwb/major_select" path="/sjtu/seiee/bjwb/:type" :paramsDesc="['无默认选项']" radar="1"> | 分专业 | 转专业 | 直升研究生 | 交换交流 | 国际办学 | | ------------ | -------------- | ------------ | -------- | ------------- | @@ -2588,29 +2588,41 @@ jsjxy.hbut.edu.cn 证书链不全,自建 RSSHub 可设置环境变量 NODE_TLS </Route> -### 研究生通知公告 +### 电子信息与电气工程学院学生工作办公室 -<Route author="mzr1996" example="/sjtu/gs/tzgg/pyxx" path="/sjtu/gs/tzgg/:type?" :paramsDesc="['默认列举所有通知公告']"> +<Route author="Polynomia xxchan" example="/sjtu/seiee/xsb/news" path="/sjtu/seiee/xsb/:type?" :paramsDesc="['默认列举所有通知公告']" radar="1"> -| 通知公告 | 工作信息 | 招生信息 | 培养信息 | 学位学科 | 国际交流 | 创新工程 | -| -------- | -------- | -------- | -------- | -------- | -------- | -------- | -| 空 | gzxx | xwxx1 | pyxx | xwxx | gjjl | cxgc | +| 信息通告 | 奖学金 | 助学金 | 讲座活动 | 党团活动 | 新闻发布 | 本科生综合测评 | +| -------- | ----------- | ------------ | -------- | -------- | -------- | -------------- | +| 空 | scholarship | financialAid | lecture | activity | news | zhcp | </Route> -### 电子信息与电气工程学院学生工作办公室 +### 研究生通知公告 -<Route author="Polynomia xxchan" example="/sjtu/seiee/xsb/news" path="/sjtu/seiee/xsb/:type?" :paramsDesc="['默认列举所有通知公告']"> +<Route author="mzr1996 dzx-dzx" example="/sjtu/gs/enroll/59" path="/sjtu/gs/:type/:num?" :paramsDesc="['类别', '细分类别, 仅对`type`为`enroll`或`exchange`有效']" radar="1"> -| 信息通告 | 奖学金 | 助学金 | 讲座活动 | 党团活动 | 新闻发布 | 本科生综合测评 | -| -------- | ----------- | ------------ | -------- | -------- | -------- | -------------- | -| 空 | scholarship | financialAid | lecture | activity | news | zhcp | +| 工作信息 | 招生信息 | 培养信息 | 学位学科 | 国际交流 | 创新工程 | +| -------- | -------- | -------- | -------- | -------- | -------- | +| work | enroll | train | degree | exchange | xsjy | + +当`type`为`enroll`, `num`可选字段: + +| 58 | 59 | 60 | 61 | 62 | +| -------- | -------- | ---------- | -------- | -------- | +| 博士招生 | 硕士招生 | 港澳台招生 | 考点信息 | 院系动态 | + +当`type`为`exchange`, `num`可选字段: + +| 67 | 68 | 69 | 70 | 71 | +| -------------- | -------------- | -------------- | -------------- | -------------- | +| 国家公派研究生 | 国际化培养资助 | 校际交换与联培 | 交流与合作项目 | 项目招募与宣讲 | </Route> ### 教务处通知公告 -<Route author="SeanChao" example="/sjtu/jwc/" path="/sjtu/jwc/:type?" :paramsDesc="['默认为 all ']"> +<Route author="SeanChao" example="/sjtu/jwc" path="/sjtu/jwc/:type?" :paramsDesc="['默认为 notice']" radar="1"> | 新闻中心 | 通知通告 | 教学运行 | 注册学务 | 研究办 | 教改办 | 综合办 | 语言文字 | 工会与支部 | 通识教育 | | -------- | -------- | --------- | -------- | ------ | ------ | ------ | -------- | ---------- | -------- | @@ -2630,7 +2642,7 @@ jsjxy.hbut.edu.cn 证书链不全,自建 RSSHub 可设置环境变量 NODE_TLS ### 研究生招生网招考信息 -<Route author="richardchien" example="/sjtu/yzb/zkxx/sszs" path="/sjtu/yzb/zkxx/:type" :paramsDesc="['无默认选项']"> +<Route author="stdrc" example="/sjtu/yzb/zkxx/sszs" path="/sjtu/yzb/zkxx/:type" :paramsDesc="['无默认选项']" radar="1"> | 博士招生 | 硕士招生 | 港澳台招生 | 考点信息 | 院系动态 | | -------- | -------- | ---------- | -------- | -------- | diff --git a/lib/router.js b/lib/router.js index 118071e413de25..3ad08da3debfed 100644 --- a/lib/router.js +++ b/lib/router.js @@ -541,14 +541,14 @@ router.get('/shanghaitech/activity', lazyloadRouteHandler('./routes/universities router.get('/shanghaitech/sist/activity', lazyloadRouteHandler('./routes/universities/shanghaitech/sist/activity')); // 上海交通大学 -router.get('/sjtu/seiee/academic', lazyloadRouteHandler('./routes/universities/sjtu/seiee/academic')); -router.get('/sjtu/seiee/bjwb/:type', lazyloadRouteHandler('./routes/universities/sjtu/seiee/bjwb')); -router.get('/sjtu/seiee/xsb/:type?', lazyloadRouteHandler('./routes/universities/sjtu/seiee/xsb')); - -router.get('/sjtu/gs/tzgg/:type?', lazyloadRouteHandler('./routes/universities/sjtu/gs/tzgg')); -router.get('/sjtu/jwc/:type?', lazyloadRouteHandler('./routes/universities/sjtu/jwc')); -router.get('/sjtu/tongqu/:type?', lazyloadRouteHandler('./routes/universities/sjtu/tongqu/activity')); -router.get('/sjtu/yzb/zkxx/:type', lazyloadRouteHandler('./routes/universities/sjtu/yzb/zkxx')); +// router.get('/sjtu/seiee/academic', lazyloadRouteHandler('./routes/universities/sjtu/seiee/academic')); +// router.get('/sjtu/seiee/bjwb/:type', lazyloadRouteHandler('./routes/universities/sjtu/seiee/bjwb')); +// router.get('/sjtu/seiee/xsb/:type?', lazyloadRouteHandler('./routes/universities/sjtu/seiee/xsb')); + +// router.get('/sjtu/gs/tzgg/:type?', lazyloadRouteHandler('./routes/universities/sjtu/gs/tzgg')); +// router.get('/sjtu/jwc/:type?', lazyloadRouteHandler('./routes/universities/sjtu/jwc')); +// router.get('/sjtu/tongqu/:type?', lazyloadRouteHandler('./routes/universities/sjtu/tongqu/activity')); +// router.get('/sjtu/yzb/zkxx/:type', lazyloadRouteHandler('./routes/universities/sjtu/yzb/zkxx')); // 江南大学 router.get('/ju/jwc/:type?', lazyloadRouteHandler('./routes/universities/ju/jwc')); diff --git a/lib/routes/universities/sjtu/gs/tzgg.js b/lib/routes/universities/sjtu/gs/tzgg.js deleted file mode 100644 index c20fc4d891af82..00000000000000 --- a/lib/routes/universities/sjtu/gs/tzgg.js +++ /dev/null @@ -1,31 +0,0 @@ -const got = require('@/utils/got'); -const cheerio = require('cheerio'); -const util = require('./utils'); - -module.exports = async (ctx) => { - const type = ctx.params.type; - let url = ''; - if (type) { - url = `http://www.gs.sjtu.edu.cn/index/tzgg/${type}.htm`; - } else { - url = 'http://www.gs.sjtu.edu.cn/index/tzgg.htm'; - } - - const response = await got({ - method: 'get', - url, - }); - - const data = response.data; - - const $ = cheerio.load(data); - const list = $('.comm li').slice(0, 10).get(); - - const result = await util.ProcessFeed(list, ctx.cache, url); - - ctx.state.data = { - title: $('title').text(), - link: url, - item: result, - }; -}; diff --git a/lib/routes/universities/sjtu/gs/utils.js b/lib/routes/universities/sjtu/gs/utils.js deleted file mode 100644 index 7b2deca6be17bb..00000000000000 --- a/lib/routes/universities/sjtu/gs/utils.js +++ /dev/null @@ -1,64 +0,0 @@ -const got = require('@/utils/got'); -const cheerio = require('cheerio'); -const url = require('url'); - -const ProcessFeed = async (list, caches, host) => { - const requestList = []; - - const result = await Promise.all( - list.map(async (item) => { - const $ = cheerio.load(item); - - const itemUrl = url.resolve(host, $('a').attr('href')); - - const cache = await caches.get(itemUrl); - if (cache) { - return Promise.resolve(JSON.parse(cache)); - } - const single = { - title: $('a span').text(), - link: itemUrl, - guid: itemUrl, - }; - - const es = got.get(itemUrl); - requestList.push(es); - return Promise.resolve(single); - }) - ); - - const responses = await got.all(requestList); - - for (let i = 0; i < responses.length; i++) { - const $ = cheerio.load(responses[i].data); - - $('.ssdd a').each(function () { - if ($(this).attr('href')) { - $(this).attr('href', url.resolve(host, $(this).attr('href'))); - } - }); - $('.ssdd img').each(function () { - if ($(this).attr('src')) { - $(this).attr('src', url.resolve(host, $(this).attr('src'))); - } - }); - result[i].description = $('.ssdd').html(); - - const date = new Date( - $('.zz span:nth-child(2)') - .text() - .match(/\d{4}-\d{2}-\d{2}/) - ); - - const timeZone = 8; - const serverOffset = date.getTimezoneOffset() / 60; - result[i].pubDate = new Date(date.getTime() - 60 * 60 * 1000 * (timeZone + serverOffset)).toUTCString(); - caches.set(result[i].link, JSON.stringify(result[i])); - } - - return result; -}; - -module.exports = { - ProcessFeed, -}; diff --git a/lib/routes/universities/sjtu/seiee/utils.js b/lib/routes/universities/sjtu/seiee/utils.js deleted file mode 100644 index d5e5cfdc81ba28..00000000000000 --- a/lib/routes/universities/sjtu/seiee/utils.js +++ /dev/null @@ -1,45 +0,0 @@ -const got = require('@/utils/got'); -const cheerio = require('cheerio'); -const url = require('url'); - -const host = 'http://bjwb.seiee.sjtu.edu.cn'; - -module.exports = function (meta, extract) { - return async (ctx) => { - const { title, local, author } = meta(ctx); - - const link = url.resolve(host, local); - const response = await got.get(link); - - const list = extract(cheerio.load(response.data)); - - const out = await Promise.all( - list.map(async (item) => { - const itemUrl = url.resolve(host, item.link); - const cache = await ctx.cache.get(itemUrl); - if (cache) { - return Promise.resolve(JSON.parse(cache)); - } - - const response = await got.get(itemUrl); - const $ = cheerio.load(response.data); - - const single = { - title: item.title, - link: itemUrl, - author, - description: $('.article_content').text(), - pubDate: new Date(item.date).toUTCString(), - }; - ctx.cache.set(itemUrl, JSON.stringify(single)); - return Promise.resolve(single); - }) - ); - - ctx.state.data = { - title, - link, - item: out, - }; - }; -}; diff --git a/lib/v2/sjtu/gs.js b/lib/v2/sjtu/gs.js new file mode 100644 index 00000000000000..8ecacd030aa27b --- /dev/null +++ b/lib/v2/sjtu/gs.js @@ -0,0 +1,62 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const { parseDate } = require('@/utils/parse-date'); +const timezone = require('@/utils/timezone'); +const { fetchArticle } = require('@/utils/wechat-mp'); + +module.exports = async (ctx) => { + const type = ctx.params.type; + const num = ctx.params.num ?? ''; + + const rootUrl = 'https://www.gs.sjtu.edu.cn'; + const currentUrl = `${rootUrl}/announcement/${type}/${num}`; + const response = await got({ + method: 'get', + url: currentUrl, + }); + + const $ = cheerio.load(response.data); + + const list = $('a.announcement-item') + .map((_, item) => { + item = $(item); + + const day = item.find('.day').text().trim().replace('.', '-'); + const year = item.find('.month').text().trim(); + + return { + title: item.find('.title').text().trim(), + link: `${item.attr('href').startsWith('http') ? '' : rootUrl}${item.attr('href')}`, + pubDate: timezone(parseDate(`${year}-${day}`, 'YYYY-MM-DD'), +8), + }; + }) + .get(); + + const items = await Promise.all( + list.map((item) => + ctx.cache.tryGet(item.link, async () => { + + if (new URL(item.link).hostname === 'mp.weixin.qq.com') { + item.description = (await fetchArticle(ctx, item.link)).description; + } + else { + const detailResponse = await got({ + method: 'get', + url: item.link, + }); + const content = cheerio.load(detailResponse.data); + + item.description = content('.page-content').html(); + } + + return item; + }) + ) + ); + + ctx.state.data = { + title: `${num === '' ? '' : `${$('.category-nav-block .active').text().trim()} - `}${$('div.inner-banner-text .title').text().trim()} - ${$('title').text()}`, + link: currentUrl, + item: items, + }; +}; diff --git a/lib/routes/universities/sjtu/jwc.js b/lib/v2/sjtu/jwc.js similarity index 85% rename from lib/routes/universities/sjtu/jwc.js rename to lib/v2/sjtu/jwc.js index 07c967a9138321..d4650af9fe964e 100644 --- a/lib/routes/universities/sjtu/jwc.js +++ b/lib/v2/sjtu/jwc.js @@ -22,11 +22,11 @@ async function getFullArticle(link) { const absLink = new URL(relativeLink, urlRoot).href; $(e).attr('href', absLink); }); - return content.html(); + return content.html() + ($('.Newslist2').length ? $('.Newslist2').html() : ''); } module.exports = async (ctx) => { - const type = ctx.params.type ?? 'all'; + const type = ctx.params.type ?? 'notice'; const config = { all: { section: '通知通告', @@ -86,7 +86,8 @@ module.exports = async (ctx) => { const out = await Promise.all( $('body > div.list-box > div.container > div > div.ny_right > div > div.ny_right_con > div > ul') .find('li') - .map(async (i, e) => { + .toArray() + .map((e) => { const info = $(e).find('.wz'); const relativeLink = info.find('a').attr('href'); const link = new URL(relativeLink, sectionLink).href; @@ -95,16 +96,16 @@ module.exports = async (ctx) => { const day = timeElement.find('h2').text(); const yearAndMonth = timeElement.find('p').text(); const pubDate = parseDate(`${yearAndMonth}.${day}`, 'YYYY.MM.DD'); - const description = await ctx.cache.tryGet(link, () => getFullArticle(link)); - const single = { - title, - link, - pubDate, - description, - }; - return Promise.resolve(single); + return ctx.cache.tryGet(link, async () => { + const description = await getFullArticle(link); + return { + title, + link, + pubDate, + description, + }; + }); }) - .get() ); ctx.state.data = { diff --git a/lib/v2/sjtu/maintainer.js b/lib/v2/sjtu/maintainer.js new file mode 100644 index 00000000000000..625a4064c362ab --- /dev/null +++ b/lib/v2/sjtu/maintainer.js @@ -0,0 +1,9 @@ +module.exports = { + '/gs/:type/:num?': ['dzx-dzx'], + '/jwc/:type?': ['SeanChao'], + '/seiee/academic': ['HenryQW'], + '/seiee/bjwb/:type': ['Polynomia'], + '/seiee/xsb/:type?': ['Polynomia', 'xxchan'], + '/tongqu/:type?': ['SeanChao'], + '/yzb/zkxx/:type': ['stdrc'], +}; diff --git a/lib/v2/sjtu/radar.js b/lib/v2/sjtu/radar.js new file mode 100644 index 00000000000000..611207b903c3f6 --- /dev/null +++ b/lib/v2/sjtu/radar.js @@ -0,0 +1,126 @@ +module.exports = { + 'sjtu.edu.cn': { + _name: '上海交通大学', + 'bjwb.seiee': [ + { + title: '电子信息与电气工程学院', + docs: 'https://docs.rsshub.app/university.html#shang-hai-jiao-tong-da-xue', + source: ['/seiee/list/:type', '/bkjwb/list/:type', '/xsb/list/:type'], + target: (params) => { + let type = ''; + switch (params.type) { + // /sjtu/seiee/academic + case '683-1-20.htm': + type = 'academic'; + break; + // /sjtu/seiee/bjwb/:type + case '1503-1-20.htm': + type = 'bjwb/academic'; + break; + case '1505-1-20.htm': + type = 'bjwb/academic'; + break; + case '1506-1-20.htm': + type = 'bjwb/postgraduate'; + break; + case '1507-1-20.htm': + type = 'bjwb/abroad'; + break; + case '2281-1-20.htm': + type = 'bjwb/international'; + break; + // /sjtu/seiee/xsb/:type? + case '2938-1-20.htm': + type = 'xsb/news'; + break; + case '611-1-20.htm': + type = 'xsb/scholarship'; + break; + case '2676-1-20.htm': + type = 'xsb/activity'; + break; + case '1981-1-20.htm': + type = 'xsb/lecture'; + break; + case '705-1-20.htm': + type = 'xsb/all'; + break; + case '1001-1-20.htm': + type = 'xsb/financialAid'; + break; + case '3016-1-20.htm': + type = 'xsb/zhcp'; + break; + default: + return null; + } + return `/sjtu/seiee/${type}`; + }, + }, + ], + gs: [ + { + title: '研究生通知公告', + docs: 'https://docs.rsshub.app/university.html#shang-hai-jiao-tong-da-xue-yan-jiu-sheng-tong-zhi-gong-gao', + source: ['/announcement/:type'], + target: '/sjtu/gs/:type', + }, + ], + jwc: [ + { + title: '教务处通知公告', + docs: 'https://docs.rsshub.app/university.html#shang-hai-jiao-tong-da-xue', + source: ['/xwtg/:type'], + target: (params) => { + let type = ''; + switch (params.type) { + case 'xwzx.htm': + type = 'news'; + break; + case 'tztg.htm': + case '': + type = 'notice'; + break; + case 'jxyx.htm': + type = 'operation'; + break; + case 'zcxw.htm': + type = 'affairs'; + break; + case 'yjb.htm': + type = 'yjb'; + break; + case 'jgb.htm': + type = 'jgb'; + break; + case 'zhb.htm': + type = 'zhb'; + break; + case 'yywz.htm': + type = 'language'; + break; + case 'ghyzb.htm': + type = 'party'; + break; + case 'tsjy.htm': + type = 'ge'; + break; + default: + type = 'notice'; + break; + } + return `/sjtu/jwc/${type}`; + }, + }, + ], + tongqu: [{ title: '同去网最新活动', docs: 'https://docs.rsshub.app/university.html#shang-hai-jiao-tong-da-xue' }], + yzb: [ + { + title: '研究生招生网招考信息', + docs: 'https://docs.rsshub.app/university.html#shang-hai-jiao-tong-da-xue', + source: ['/index/zkxx/:type'], + target: (params) => `/sjtu/yzb/zkxx/${params.type.replace('.htm', '')}`, + }, + ], + }, +}; diff --git a/lib/v2/sjtu/router.js b/lib/v2/sjtu/router.js new file mode 100644 index 00000000000000..c1960550c21171 --- /dev/null +++ b/lib/v2/sjtu/router.js @@ -0,0 +1,9 @@ +module.exports = function (router) { + router.get('/gs/:type/:num?', require('./gs')); + router.get('/jwc/:type?', require('./jwc')); + router.get('/seiee/academic', require('./seiee/academic')); + router.get('/seiee/bjwb/:type', require('./seiee/bjwb')); + router.get('/seiee/xsb/:type?', require('./seiee/xsb')); + router.get('/tongqu/:type?', require('./tongqu/activity')); + router.get('/yzb/zkxx/:type', require('./yzb/zkxx')); +}; diff --git a/lib/routes/universities/sjtu/seiee/academic.js b/lib/v2/sjtu/seiee/academic.js similarity index 72% rename from lib/routes/universities/sjtu/seiee/academic.js rename to lib/v2/sjtu/seiee/academic.js index d64049cf2397be..ea571f1dc15562 100644 --- a/lib/routes/universities/sjtu/seiee/academic.js +++ b/lib/v2/sjtu/seiee/academic.js @@ -3,16 +3,15 @@ const workerFactory = require('./utils'); module.exports = workerFactory( () => ({ title: '上海交通大学电子信息与电气工程学院本科教务办 -- 学术动态', - local: `seiee/list/683-1-20.htm`, + local: 'seiee/list/683-1-20.htm', author: '上海交通大学电子信息与电气工程学院本科教务办', }), ($) => $('.list_style_1 li') - .slice(0, 10) - .map((i, e) => ({ + .toArray() + .map((e) => ({ date: $(e).children('span').text(), - title: $(e).children('a').text(), + title: $(e).children('a').attr('title'), link: $(e).children('a').attr('href'), })) - .get() ); diff --git a/lib/routes/universities/sjtu/seiee/bjwb.js b/lib/v2/sjtu/seiee/bjwb.js similarity index 76% rename from lib/routes/universities/sjtu/seiee/bjwb.js rename to lib/v2/sjtu/seiee/bjwb.js index d7df65b8a83849..0a61185f3fe6c2 100644 --- a/lib/routes/universities/sjtu/seiee/bjwb.js +++ b/lib/v2/sjtu/seiee/bjwb.js @@ -4,23 +4,23 @@ module.exports = workerFactory( (ctx) => { const config = { abroad: { - link: `bkjwb/list/1507-1-20.htm`, + link: 'bkjwb/list/1507-1-20.htm', title: '交换交流', }, international: { - link: `bkjwb/list/2281-1-20.htm`, + link: 'bkjwb/list/2281-1-20.htm', title: '国际办学通知', }, major_select: { - link: `bkjwb/list/1503-1-20.htm`, + link: 'bkjwb/list/1503-1-20.htm', title: '分专业', }, major_transfer: { - link: `bkjwb/list/1505-1-20.htm`, + link: 'bkjwb/list/1505-1-20.htm', title: '转专业', }, postgraduate: { - link: `bkjwb/list/1506-1-20.htm`, + link: 'bkjwb/list/1506-1-20.htm', title: '直升研究生', }, }; @@ -35,11 +35,10 @@ module.exports = workerFactory( }, ($) => $('.list_box_5 li') - .slice(0, 10) - .map((i, e) => ({ + .toArray() + .map((e) => ({ date: $(e).children('span').text().slice(1, -1), title: $(e).children('a').text().slice(2), link: $(e).children('a').attr('href'), })) - .get() ); diff --git a/lib/v2/sjtu/seiee/utils.js b/lib/v2/sjtu/seiee/utils.js new file mode 100644 index 00000000000000..97caa7bf7e5904 --- /dev/null +++ b/lib/v2/sjtu/seiee/utils.js @@ -0,0 +1,40 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const { parseDate } = require('@/utils/parse-date'); + +const host = 'https://bjwb.seiee.sjtu.edu.cn'; + +module.exports = function (meta, extract) { + return async (ctx) => { + const { title, local, author } = meta(ctx); + + const link = new URL(local, host).href; + const response = await got(link); + + const list = extract(cheerio.load(response.data)); + + const out = await Promise.all( + list.map((item) => { + const itemUrl = new URL(item.link, host).href; + return ctx.cache.tryGet(itemUrl, async () => { + const response = await got(itemUrl); + const $ = cheerio.load(response.data); + + return { + title: item.title, + link: itemUrl, + author, + description: $('.article_content').html(), + pubDate: parseDate(item.date, 'YYYY-MM-DD'), + }; + }); + }) + ); + + ctx.state.data = { + title, + link, + item: out, + }; + }; +}; diff --git a/lib/routes/universities/sjtu/seiee/xsb.js b/lib/v2/sjtu/seiee/xsb.js similarity index 95% rename from lib/routes/universities/sjtu/seiee/xsb.js rename to lib/v2/sjtu/seiee/xsb.js index 589b5b2f76c5e5..801d5aee8805cc 100644 --- a/lib/routes/universities/sjtu/seiee/xsb.js +++ b/lib/v2/sjtu/seiee/xsb.js @@ -43,11 +43,10 @@ module.exports = workerFactory( }, ($) => $('.list_box_5_2 li') - .slice(0, 10) - .map((i, e) => ({ + .toArray() + .map((e) => ({ date: $(e).children('span').text().slice(1, -1), title: $(e).children('a').text().slice(1), link: $(e).children('a').attr('href'), })) - .get() ); diff --git a/lib/v2/sjtu/templates/activity.art b/lib/v2/sjtu/templates/activity.art new file mode 100644 index 00000000000000..edf60c75032ed2 --- /dev/null +++ b/lib/v2/sjtu/templates/activity.art @@ -0,0 +1,6 @@ +{{ e.name }}<br> +开始时间: {{ e.sign_start_time }}<br> +结束时间: {{ e.sign_end_time }}<br> +地点: {{ e.location }}<br> +报名人数: {{ e.member_count }}/{{ e.max_member }}<br> +来自{{ e.source }} diff --git a/lib/routes/universities/sjtu/tongqu/activity.js b/lib/v2/sjtu/tongqu/activity.js similarity index 75% rename from lib/routes/universities/sjtu/tongqu/activity.js rename to lib/v2/sjtu/tongqu/activity.js index 18a4a984825c41..0a812b146fe6fc 100644 --- a/lib/routes/universities/sjtu/tongqu/activity.js +++ b/lib/v2/sjtu/tongqu/activity.js @@ -1,5 +1,6 @@ const got = require('@/utils/got'); -const url = require('url'); +const { art } = require('@/utils/render'); +const { join } = require('path'); const urlRoot = 'https://tongqu.sjtu.edu.cn'; @@ -30,9 +31,9 @@ module.exports = async (ctx) => { const activities = data.result.acts; const feeds = activities.map((e) => ({ title: e.name, - link: url.resolve(urlRoot, '/act/' + e.actid), + link: new URL(`/act/${e.actid}`, urlRoot).href, category: e.typename, - description: `${e.name}\r\n` + `开始时间: ${e.sign_start_time}\r\n结束时间: ${e.sign_end_time}\r\n` + `地点: ${e.location}\r\n` + `报名人数: ${e.member_count}/${e.max_member}\r\n` + `来自${e.source}\r\n`, + description: art(join(__dirname, '../templates/activity.art'), { e }), })); ctx.state.data = { diff --git a/lib/routes/universities/sjtu/yzb/zkxx.js b/lib/v2/sjtu/yzb/zkxx.js similarity index 72% rename from lib/routes/universities/sjtu/yzb/zkxx.js rename to lib/v2/sjtu/yzb/zkxx.js index 6bdfa184a995ab..9266d3e91f8981 100644 --- a/lib/routes/universities/sjtu/yzb/zkxx.js +++ b/lib/v2/sjtu/yzb/zkxx.js @@ -1,6 +1,6 @@ const got = require('@/utils/got'); const cheerio = require('cheerio'); -const url = require('url'); +const { parseDate } = require('@/utils/parse-date'); const baseTitle = '上海交通大学研究生招生网招考信息'; const baseUrl = 'https://yzb.sjtu.edu.cn/index/zkxx/'; @@ -22,12 +22,11 @@ module.exports = async (ctx) => { link: pageUrl, title: `${baseTitle} -- ${$('title').text().split('-')[0]}`, item: $('li[id^="line"] a') - .slice(0, 10) - .map((_, elem) => ({ - link: url.resolve(pageUrl, elem.attribs.href), + .toArray() + .map((elem) => ({ + link: new URL(elem.attribs.href, pageUrl).href, title: elem.attribs.title, - pubDate: new Date($(elem.next).text().trim()).toUTCString(), - })) - .get(), + pubDate: parseDate($(elem.next).text().trim()), + })), }; };
b1386984554716bf4223a8dba2b029117f97b1e5
2024-12-04 22:03:48
pseudoyu
chore(api): increase maxHeaderSize
false
increase maxHeaderSize
chore
diff --git a/lib/index.ts b/lib/index.ts index 97cf8882bbf482..bd6ba51d69091b 100644 --- a/lib/index.ts +++ b/lib/index.ts @@ -20,6 +20,9 @@ const server = serve({ fetch: app.fetch, hostname: config.listenInaddrAny ? '::' : '127.0.0.1', port, + serverOptions: { + maxHeaderSize: 1024 * 64, + }, }); export default server;
5cbd16ef124ad6deb8189f35a20a988cb3903198
2020-11-21 04:29:44
dependabot-preview[bot]
chore(deps-dev): bump eslint from 7.13.0 to 7.14.0
false
bump eslint from 7.13.0 to 7.14.0
chore
diff --git a/package.json b/package.json index 89dbbba92deb1b..09345a08eb342f 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "@vuepress/plugin-pwa": "1.7.1", "cross-env": "7.0.2", "entities": "2.1.0", - "eslint": "7.13.0", + "eslint": "7.14.0", "eslint-config-prettier": "6.15.0", "eslint-plugin-prettier": "3.1.4", "jest": "26.6.3", diff --git a/yarn.lock b/yarn.lock index 809cf155dc73fd..af0b1e84da12be 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5000,10 +5000,10 @@ eslint-visitor-keys@^2.0.0: resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-2.0.0.tgz#21fdc8fbcd9c795cc0321f0563702095751511a8" integrity sha512-QudtT6av5WXels9WjIM7qz1XD1cWGvX4gGXvp/zBn9nXG02D0utdU3Em2m/QjTnrsk6bBjmCygl3rmj118msQQ== [email protected]: - version "7.13.0" - resolved "https://registry.yarnpkg.com/eslint/-/eslint-7.13.0.tgz#7f180126c0dcdef327bfb54b211d7802decc08da" - integrity sha512-uCORMuOO8tUzJmsdRtrvcGq5qposf7Rw0LwkTJkoDbOycVQtQjmnhZSuLQnozLE4TmAzlMVV45eCHmQ1OpDKUQ== [email protected]: + version "7.14.0" + resolved "https://registry.yarnpkg.com/eslint/-/eslint-7.14.0.tgz#2d2cac1d28174c510a97b377f122a5507958e344" + integrity sha512-5YubdnPXrlrYAFCKybPuHIAH++PINe1pmKNc5wQRB9HSbqIK1ywAnntE3Wwua4giKu0bjligf1gLF6qxMGOYRA== dependencies: "@babel/code-frame" "^7.0.0" "@eslint/eslintrc" "^0.2.1" @@ -8143,12 +8143,7 @@ lodash.uniq@^4.5.0: resolved "https://registry.yarnpkg.com/lodash.uniq/-/lodash.uniq-4.5.0.tgz#d0225373aeb652adc1bc82e4945339a842754773" integrity sha1-0CJTc662Uq3BvILklFM5qEJ1R3M= -lodash@^4.15.0, lodash@^4.17.11, lodash@^4.17.13, lodash@^4.17.15, lodash@^4.17.19, lodash@^4.17.3, lodash@^4.17.5: - version "4.17.19" - resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.19.tgz#e48ddedbe30b3321783c5b4301fbd353bc1e4a4b" - integrity sha512-JNvd8XER9GQX0v2qJgsaN/mzFCNA5BRe/j8JN9d+tWyGLSodKQHKFicdwNYzWwI3wjRnaKPsGj1XkBjx/F96DQ== - -lodash@^4.17.20: +lodash@^4.15.0, lodash@^4.17.11, lodash@^4.17.13, lodash@^4.17.15, lodash@^4.17.19, lodash@^4.17.20, lodash@^4.17.3, lodash@^4.17.5: version "4.17.20" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.20.tgz#b44a9b6297bcb698f1c51a3545a2b3b368d59c52" integrity sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA==
ed62f28001886cfc0a9298f63c874c643996b093
2019-10-01 09:34:07
dependabot-preview[bot]
chore(deps-dev): bump eslint from 6.5.0 to 6.5.1
false
bump eslint from 6.5.0 to 6.5.1
chore
diff --git a/package.json b/package.json index 33ab9bbbe2c2c8..90b1c2bb3bb314 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "@vuepress/plugin-google-analytics": "1.1.0", "@vuepress/plugin-pwa": "1.1.0", "cross-env": "6.0.0", - "eslint": "6.5.0", + "eslint": "6.5.1", "eslint-config-prettier": "6.3.0", "eslint-plugin-prettier": "3.1.1", "jest": "24.9.0", diff --git a/yarn.lock b/yarn.lock index 6006c2b16cdd15..b8a1f1627cb13d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4060,10 +4060,10 @@ eslint-visitor-keys@^1.0.0, eslint-visitor-keys@^1.1.0: resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-1.1.0.tgz#e2a82cea84ff246ad6fb57f9bde5b46621459ec2" integrity sha512-8y9YjtM1JBJU/A9Kc+SbaOV4y29sSWckBwMHa+FGtVj5gN/sbnKDf6xJUl+8g7FAij9LVaP8C24DUiH/f/2Z9A== [email protected]: - version "6.5.0" - resolved "https://registry.yarnpkg.com/eslint/-/eslint-6.5.0.tgz#304623eec903969dd5c9f2d61c6ce3d6ecec8750" - integrity sha512-IIbSW+vKOqMatPmS9ayyku4tvWxHY2iricSRtOz6+ZA5IPRlgXzEL0u/j6dr4eha0ugmhMwDTqxtmNu3kj9O4w== [email protected]: + version "6.5.1" + resolved "https://registry.yarnpkg.com/eslint/-/eslint-6.5.1.tgz#828e4c469697d43bb586144be152198b91e96ed6" + integrity sha512-32h99BoLYStT1iq1v2P9uwpyznQ4M2jRiFB6acitKz52Gqn+vPaMDUTB1bYi1WN4Nquj2w+t+bimYUG83DC55A== dependencies: "@babel/code-frame" "^7.0.0" ajv "^6.10.0"
64d8c2acc31a14a601d61dabeee1ee927bdb9df6
2019-08-03 12:14:38
DIYgod
fix: install git in docker for compatibility with mercury-parser
false
install git in docker for compatibility with mercury-parser
fix
diff --git a/Dockerfile b/Dockerfile index 1c949966b74d31..c565be88b43077 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ FROM node:10.15-slim LABEL MAINTAINER https://github.com/DIYgod/RSSHub/ -RUN apt-get update && apt-get install -yq libgconf-2-4 apt-transport-https --no-install-recommends && apt-get clean \ +RUN apt-get update && apt-get install -yq libgconf-2-4 apt-transport-https git --no-install-recommends && apt-get clean \ && rm -rf /var/lib/apt/lists/* ENV NODE_ENV production
a21b5189462608c2931156d4d2c6a85900f8197c
2024-09-23 12:43:49
pseudoyu
feat: enhance route params for better follow display (#16874)
false
enhance route params for better follow display (#16874)
feat
diff --git a/lib/routes/dockerhub/build.ts b/lib/routes/dockerhub/build.ts index c38344e6d8991e..e9150660865a5a 100644 --- a/lib/routes/dockerhub/build.ts +++ b/lib/routes/dockerhub/build.ts @@ -6,7 +6,7 @@ export const route: Route = { path: '/build/:owner/:image/:tag?', categories: ['program-update', 'popular'], view: ViewType.Notifications, - example: '/dockerhub/build/diygod/rsshub', + example: '/dockerhub/build/diygod/rsshub/latest', parameters: { owner: 'Image owner, the owner of the official image fills in the library, for example: /dockerhub/build/library/mysql', image: 'Image name', diff --git a/lib/routes/epicgames/index.ts b/lib/routes/epicgames/index.ts index 4a435895ff4caa..182b6765f5ccfa 100644 --- a/lib/routes/epicgames/index.ts +++ b/lib/routes/epicgames/index.ts @@ -12,7 +12,7 @@ export const route: Route = { path: '/freegames/:locale?/:country?', categories: ['game', 'popular'], view: ViewType.Notifications, - example: '/epicgames/freegames', + example: '/epicgames/freegames/en-US/US', parameters: { locale: { description: 'Locale', diff --git a/lib/routes/hpoi/all.ts b/lib/routes/hpoi/all.ts index 05d7e91df52177..aff063070766a3 100644 --- a/lib/routes/hpoi/all.ts +++ b/lib/routes/hpoi/all.ts @@ -6,7 +6,20 @@ export const route: Route = { categories: ['anime', 'popular'], view: ViewType.Pictures, example: '/hpoi/items/all', - parameters: { order: '排序, 见下表,默认为 add' }, + parameters: { + order: { + description: '排序, 见下表,默认为 add', + options: [ + { value: 'release', label: '发售' }, + { value: 'add', label: '入库' }, + { value: 'hits', label: '总热度' }, + { value: 'hits7Day', label: '一周热度' }, + { value: 'hitsDay', label: '一天热度' }, + { value: 'rating', label: '评价' }, + ], + default: 'add', + }, + }, features: { requireConfig: false, requirePuppeteer: false, @@ -25,9 +38,6 @@ export const route: Route = { maintainers: ['DIYgod'], handler, url: 'www.hpoi.net/hobby/all', - description: `| 发售 | 入库 | 总热度 | 一周热度 | 一天热度 | 评价 | - | ------- | ---- | ------ | -------- | -------- | ------ | - | release | add | hits | hits7Day | hitsDay | rating |`, }; async function handler(ctx) { diff --git a/lib/routes/hpoi/character.ts b/lib/routes/hpoi/character.ts index 895b499763b333..94f799bff4a487 100644 --- a/lib/routes/hpoi/character.ts +++ b/lib/routes/hpoi/character.ts @@ -6,7 +6,21 @@ export const route: Route = { categories: ['anime', 'popular'], view: ViewType.Pictures, example: '/hpoi/items/character/1035374', - parameters: { id: '角色 ID', order: '排序, 见下表,默认为 add' }, + parameters: { + id: '角色 ID', + order: { + description: '排序, 见下表,默认为 add', + options: [ + { value: 'release', label: '发售' }, + { value: 'add', label: '入库' }, + { value: 'hits', label: '总热度' }, + { value: 'hits7Day', label: '一周热度' }, + { value: 'hitsDay', label: '一天热度' }, + { value: 'rating', label: '评价' }, + ], + default: 'add', + }, + }, features: { requireConfig: false, requirePuppeteer: false, @@ -18,9 +32,6 @@ export const route: Route = { name: '角色周边', maintainers: ['DIYgod'], handler, - description: `| 发售 | 入库 | 总热度 | 一周热度 | 一天热度 | 评价 | - | ------- | ---- | ------ | -------- | -------- | ------ | - | release | add | hits | hits7Day | hitsDay | rating |`, }; async function handler(ctx) { diff --git a/lib/routes/hpoi/work.ts b/lib/routes/hpoi/work.ts index 34887f5108638b..30d78ec855595c 100644 --- a/lib/routes/hpoi/work.ts +++ b/lib/routes/hpoi/work.ts @@ -6,7 +6,21 @@ export const route: Route = { categories: ['anime', 'popular'], view: ViewType.Pictures, example: '/hpoi/items/work/4117491', - parameters: { id: '作品 ID', order: '排序, 见下表,默认为 add' }, + parameters: { + id: '作品 ID', + order: { + description: '排序, 见下表,默认为 add', + options: [ + { value: 'release', label: '发售' }, + { value: 'add', label: '入库' }, + { value: 'hits', label: '总热度' }, + { value: 'hits7Day', label: '一周热度' }, + { value: 'hitsDay', label: '一天热度' }, + { value: 'rating', label: '评价' }, + ], + default: 'add', + }, + }, features: { requireConfig: false, requirePuppeteer: false, @@ -18,9 +32,6 @@ export const route: Route = { name: '作品周边', maintainers: ['DIYgod'], handler, - description: `| 发售 | 入库 | 总热度 | 一周热度 | 一天热度 | 评价 | - | ------- | ---- | ------ | -------- | -------- | ------ | - | release | add | hits | hits7Day | hitsDay | rating |`, }; async function handler(ctx) { diff --git a/lib/routes/mastodon/acct.ts b/lib/routes/mastodon/acct.ts index 0162fcb9074479..ae5f5b919ef6d7 100644 --- a/lib/routes/mastodon/acct.ts +++ b/lib/routes/mastodon/acct.ts @@ -6,7 +6,17 @@ export const route: Route = { categories: ['social-media', 'popular'], view: ViewType.SocialMedia, example: '/mastodon/acct/[email protected]/statuses', - parameters: { acct: 'Webfinger account URI, like `user@host`', only_media: 'whether only display media content, default to false, any value to true' }, + parameters: { + acct: 'Webfinger account URI, like `user@host`', + only_media: { + description: 'whether only display media content, default to false, any value to true', + options: [ + { value: 'true', label: 'true' }, + { value: 'false', label: 'false' }, + ], + default: 'false', + }, + }, features: { requireConfig: false, requirePuppeteer: false, diff --git a/lib/routes/mastodon/timeline-local.ts b/lib/routes/mastodon/timeline-local.ts index 46f2d46d59e1cc..1713c9e8fba5bb 100644 --- a/lib/routes/mastodon/timeline-local.ts +++ b/lib/routes/mastodon/timeline-local.ts @@ -9,7 +9,17 @@ export const route: Route = { categories: ['social-media', 'popular'], view: ViewType.SocialMedia, example: '/mastodon/timeline/pawoo.net/true', - parameters: { site: 'instance address, only domain, no `http://` or `https://` protocol header', only_media: 'whether only display media content, default to false, any value to true' }, + parameters: { + site: 'instance address, only domain, no `http://` or `https://` protocol header', + only_media: { + description: 'whether only display media content, default to false, any value to true', + options: [ + { value: 'true', label: 'true' }, + { value: 'false', label: 'false' }, + ], + default: 'false', + }, + }, features: { requireConfig: false, requirePuppeteer: false, diff --git a/lib/routes/mastodon/timeline-remote.ts b/lib/routes/mastodon/timeline-remote.ts index 5f55c05b5fff15..5e962735371731 100644 --- a/lib/routes/mastodon/timeline-remote.ts +++ b/lib/routes/mastodon/timeline-remote.ts @@ -9,7 +9,17 @@ export const route: Route = { categories: ['social-media', 'popular'], view: ViewType.SocialMedia, example: '/mastodon/remote/pawoo.net/true', - parameters: { site: 'instance address, only domain, no `http://` or `https://` protocol header', only_media: 'whether only display media content, default to false, any value to true' }, + parameters: { + site: 'instance address, only domain, no `http://` or `https://` protocol header', + only_media: { + description: 'whether only display media content, default to false, any value to true', + options: [ + { value: 'true', label: 'true' }, + { value: 'false', label: 'false' }, + ], + default: 'false', + }, + }, features: { requireConfig: false, requirePuppeteer: false, diff --git a/lib/routes/pixiv/ranking.ts b/lib/routes/pixiv/ranking.ts index 834721479e5c6e..bf1f6dffa2d14f 100644 --- a/lib/routes/pixiv/ranking.ts +++ b/lib/routes/pixiv/ranking.ts @@ -124,6 +124,7 @@ export const route: Route = { label: 'R-18G rank', }, ], + default: 'day', }, date: 'format: `2018-4-25`', }, diff --git a/lib/routes/pornhub/pornstar.ts b/lib/routes/pornhub/pornstar.ts index ec686325925131..9a19c4228607be 100644 --- a/lib/routes/pornhub/pornstar.ts +++ b/lib/routes/pornhub/pornstar.ts @@ -10,7 +10,36 @@ export const route: Route = { categories: ['multimedia', 'popular'], view: ViewType.Videos, example: '/pornhub/pornstar/june-liu', - parameters: { language: 'language, see below', username: 'username, part of the url e.g. `pornhub.com/pornstar/june-liu`', sort: 'sorting method, see below' }, + parameters: { + username: 'username, part of the url e.g. `pornhub.com/pornstar/june-liu`', + language: 'language', + sort: { + description: 'sorting method', + default: 'mv', + options: [ + { + label: 'Most Recent', + value: 'mr', + }, + { + label: 'Most Viewed', + value: 'mv', + }, + { + label: 'Top Rated', + value: 'tr', + }, + { + label: 'Longest', + value: 'lg', + }, + { + label: 'Best', + value: '', + }, + ], + }, + }, features: { requireConfig: false, requirePuppeteer: false, @@ -28,11 +57,6 @@ export const route: Route = { name: 'Pornstar', maintainers: ['I2IMk', 'queensferryme'], handler, - description: `**\`sort\`** - - | Most Recent | Most Viewed | Top Rated | Longest | Best | - | ----------- | ----------- | --------- | ------- | ---- | - | mr | mv | tr | lg | |`, }; async function handler(ctx) { diff --git a/lib/routes/reuters/common.ts b/lib/routes/reuters/common.ts index 5ae962ab299adf..e3812f10427f2e 100644 --- a/lib/routes/reuters/common.ts +++ b/lib/routes/reuters/common.ts @@ -14,7 +14,61 @@ export const route: Route = { categories: ['traditional-media', 'popular'], view: ViewType.Articles, example: '/reuters/world/us', - parameters: { category: 'find it in the URL, or tables below', topic: 'find it in the URL, or tables below' }, + parameters: { + category: { + description: 'find it in the URL, or tables below', + options: [ + { value: 'world', label: 'World' }, + { value: 'business', label: 'Business' }, + { value: 'legal', label: 'Legal' }, + { value: 'markets', label: 'Markets' }, + { value: 'breakingviews', label: 'Breakingviews' }, + { value: 'technology', label: 'Technology' }, + { value: 'graphics', label: 'Graphics' }, + { value: 'authors', label: 'Authors' }, + ], + default: 'world', + }, + topic: { + description: 'find it in the URL, or tables below', + options: [ + { value: '', label: 'All' }, + // World topics + { value: 'africa', label: 'Africa' }, + { value: 'americas', label: 'Americas' }, + { value: 'asia-pacific', label: 'Asia Pacific' }, + { value: 'china', label: 'China' }, + { value: 'europe', label: 'Europe' }, + { value: 'india', label: 'India' }, + { value: 'middle-east', label: 'Middle East' }, + { value: 'uk', label: 'United Kingdom' }, + { value: 'us', label: 'United States' }, + { value: 'the-great-reboot', label: 'The Great Reboot' }, + { value: 'reuters-next', label: 'Reuters Next' }, + // Business topics + { value: 'aerospace-defense', label: 'Aerospace & Defense' }, + { value: 'autos-transportation', label: 'Autos & Transportation' }, + { value: 'energy', label: 'Energy' }, + { value: 'environment', label: 'Environment' }, + { value: 'finance', label: 'Finance' }, + { value: 'healthcare-pharmaceuticals', label: 'Healthcare & Pharmaceuticals' }, + { value: 'media-telecom', label: 'Media & Telecom' }, + { value: 'retail-consumer', label: 'Retail & Consumer' }, + { value: 'sustainable-business', label: 'Sustainable Business' }, + { value: 'charged', label: 'Charged' }, + { value: 'future-of-health', label: 'Future of Health' }, + { value: 'future-of-money', label: 'Future of Money' }, + { value: 'take-five', label: 'Take Five' }, + { value: 'reuters-impact', label: 'Reuters Impact' }, + // Legal topics + { value: 'government', label: 'Government' }, + { value: 'legalindustry', label: 'Legal Industry' }, + { value: 'litigation', label: 'Litigation' }, + { value: 'transactional', label: 'Transactional' }, + ], + default: '', + }, + }, features: { requireConfig: false, requirePuppeteer: false, diff --git a/lib/routes/twitch/video.ts b/lib/routes/twitch/video.ts index 1ad198cbc65da7..38ecdc92852b2d 100644 --- a/lib/routes/twitch/video.ts +++ b/lib/routes/twitch/video.ts @@ -17,7 +17,18 @@ export const route: Route = { categories: ['live', 'popular'], view: ViewType.Videos, example: '/twitch/video/riotgames/highlights', - parameters: { login: 'Twitch username', filter: 'Video type, Default to all' }, + parameters: { + login: 'Twitch username', + filter: { + description: 'Video type, Default to all', + options: [ + { value: 'archive', label: 'Archive' }, + { value: 'highlights', label: 'Highlights' }, + { value: 'all', label: 'All' }, + ], + default: 'all', + }, + }, features: { requireConfig: false, requirePuppeteer: false, @@ -35,9 +46,6 @@ export const route: Route = { name: 'Channel Video', maintainers: ['hoilc'], handler, - description: `| archive | highlights | all | -| ----------------- | ----------------------------- | ---------- | -| Recent broadcasts | Recent highlights and uploads | All videos |`, }; async function handler(ctx) { diff --git a/lib/routes/v2ex/topics.ts b/lib/routes/v2ex/topics.ts index 4e514369a8544c..5ef462078e83ff 100644 --- a/lib/routes/v2ex/topics.ts +++ b/lib/routes/v2ex/topics.ts @@ -20,6 +20,7 @@ export const route: Route = { label: '最新主题', }, ], + default: 'hot', }, }, features: {
11abf30b3a6bb9bfde63e798eda86bd4017d1770
2020-10-15 00:35:20
dependabot-preview[bot]
chore(deps-dev): bump remark from 12.0.1 to 13.0.0
false
bump remark from 12.0.1 to 13.0.0
chore
diff --git a/package.json b/package.json index bd85a8d17f9434..979a903ca8bf72 100644 --- a/package.json +++ b/package.json @@ -53,7 +53,7 @@ "prettier": "2.1.2", "prettier-check": "2.0.0", "pretty-quick": "3.1.0", - "remark": "12.0.1", + "remark": "13.0.0", "remark-frontmatter": "2.0.0", "remark-pangu": "2.1.1", "remark-preset-prettier": "0.4.0", diff --git a/yarn.lock b/yarn.lock index 3f3bbeb4596605..feb5eb53996469 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1680,6 +1680,13 @@ "@types/koa-compose" "*" "@types/node" "*" +"@types/mdast@^3.0.0": + version "3.0.3" + resolved "https://registry.yarnpkg.com/@types/mdast/-/mdast-3.0.3.tgz#2d7d671b1cd1ea3deb306ea75036c2a0407d2deb" + integrity sha512-SXPBMnFVQg1s00dlMCc/jCdvPqdE4mXaMMCeRlxLDmTAEoegHT53xKtkDnzDTOcmMHUfcjyf36/YYZ6SxRdnsw== + dependencies: + "@types/unist" "*" + "@types/mime@*": version "2.0.1" resolved "https://registry.yarnpkg.com/@types/mime/-/mime-2.0.1.tgz#dc488842312a7f075149312905b5e3c0b054c79d" @@ -1740,7 +1747,7 @@ resolved "https://registry.yarnpkg.com/@types/tough-cookie/-/tough-cookie-2.3.5.tgz#9da44ed75571999b65c37b60c9b2b88db54c585d" integrity sha512-SCcK7mvGi3+ZNz833RRjFIxrn4gI1PPR3NtuIS+6vMkvmsGjosqTJwRt5bAEFLRz+wtJMWv8+uOnZf2hi2QXTg== -"@types/unist@^2.0.0", "@types/unist@^2.0.2": +"@types/unist@*", "@types/unist@^2.0.0", "@types/unist@^2.0.2": version "2.0.3" resolved "https://registry.yarnpkg.com/@types/unist/-/unist-2.0.3.tgz#9c088679876f374eb5983f150d4787aa6fb32d7e" integrity sha512-FvUupuM3rlRsRtCN+fDudtmytGO6iHJuuRKS1Ss0pG5z8oX0diNEw94UEL7hgDbpN94rgaK5R7sWm6RrSkZuAQ== @@ -3250,11 +3257,6 @@ caseless@~0.12.0: resolved "https://registry.yarnpkg.com/caseless/-/caseless-0.12.0.tgz#1b681c21ff84033c826543090689420d187151dc" integrity sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw= -ccount@^1.0.0: - version "1.0.5" - resolved "https://registry.yarnpkg.com/ccount/-/ccount-1.0.5.tgz#ac82a944905a65ce204eb03023157edf29425c17" - integrity sha512-MOli1W+nfbPLlKEhInaxhRdp7KVLFxLN5ykwzHgLsLI3H3gs5jjFAK4Eoj3OzzcxCtumDaI8onoVDeQyWaNTkw== - chalk@^1.1.3: version "1.1.3" resolved "https://registry.yarnpkg.com/chalk/-/chalk-1.1.3.tgz#a8115c55e4a702fe4d150abd3872822a7e09fc98" @@ -3503,11 +3505,6 @@ code-point-at@^1.0.0: resolved "https://registry.yarnpkg.com/code-point-at/-/code-point-at-1.1.0.tgz#0d070b4d043a5bea33a2f1a40e2edb3d9a4ccf77" integrity sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c= -collapse-white-space@^1.0.2: - version "1.0.6" - resolved "https://registry.yarnpkg.com/collapse-white-space/-/collapse-white-space-1.0.6.tgz#e63629c0016665792060dbbeb79c42239d2c5287" - integrity sha512-jEovNnrhMuqyCcjfEJA56v0Xq8SkIoPKDyaHahwo3POf4qcSXqMYuwNcOTzp74vTsR9Tn08z4MxWqAhcekogkQ== - collect-v8-coverage@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/collect-v8-coverage/-/collect-v8-coverage-1.0.0.tgz#150ee634ac3650b71d9c985eb7f608942334feb1" @@ -4216,6 +4213,13 @@ debug@^3.2.5, debug@^3.2.6: dependencies: ms "^2.1.1" +debug@^4.0.0: + version "4.2.0" + resolved "https://registry.yarnpkg.com/debug/-/debug-4.2.0.tgz#7f150f93920e94c58f5574c2fd01a3110effe7f1" + integrity sha512-IX2ncY78vDTjZMFUdmsvIRFY2Cf4FnD0wRs+nQwJU8Lu99/tPFdb0VybiiMTPe3I6rQmwsqQqRBvxU+bZ/I8sg== + dependencies: + ms "2.1.2" + debug@~3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/debug/-/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261" @@ -6475,7 +6479,7 @@ inflight@^1.0.4: once "^1.3.0" wrappy "1" -inherits@2, [email protected], inherits@^2.0.0, inherits@^2.0.1, inherits@^2.0.3, inherits@^2.0.4, inherits@~2.0.1, inherits@~2.0.3: +inherits@2, [email protected], inherits@^2.0.1, inherits@^2.0.3, inherits@^2.0.4, inherits@~2.0.1, inherits@~2.0.3: version "2.0.4" resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== @@ -6559,11 +6563,6 @@ is-alphabetical@^1.0.0: resolved "https://registry.yarnpkg.com/is-alphabetical/-/is-alphabetical-1.0.4.tgz#9e7d6b94916be22153745d184c298cbf986a686d" integrity sha512-DwzsA04LQ10FHTZuL0/grVDk4rFoVH1pjAToYwBrHSxcrBIGQuXrQMtD5U1b0U2XVgKZCTLLP8u2Qxqhy3l2Vg== -is-alphanumeric@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/is-alphanumeric/-/is-alphanumeric-1.0.0.tgz#4a9cef71daf4c001c1d81d63d140cf53fd6889f4" - integrity sha1-Spzvcdr0wAHB2B1j0UDPU/1oifQ= - is-alphanumerical@^1.0.0: version "1.0.4" resolved "https://registry.yarnpkg.com/is-alphanumerical/-/is-alphanumerical-1.0.4.tgz#7eb9a2431f855f6b1ef1a78e326df515696c4dbf" @@ -6889,21 +6888,11 @@ is-typedarray@^1.0.0, is-typedarray@~1.0.0: resolved "https://registry.yarnpkg.com/is-typedarray/-/is-typedarray-1.0.0.tgz#e479c80858df0c1b11ddda6940f96011fcda4a9a" integrity sha1-5HnICFjfDBsR3dppQPlgEfzaSpo= -is-whitespace-character@^1.0.0: - version "1.0.4" - resolved "https://registry.yarnpkg.com/is-whitespace-character/-/is-whitespace-character-1.0.4.tgz#0858edd94a95594c7c9dd0b5c174ec6e45ee4aa7" - integrity sha512-SDweEzfIZM0SJV0EUga669UTKlmL0Pq8Lno0QDQsPnvECB3IM2aP0gdx5TrU0A01MAPfViaZiI2V1QMZLaKK5w== - is-windows@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/is-windows/-/is-windows-1.0.2.tgz#d1850eb9791ecd18e6182ce12a30f396634bb19d" integrity sha512-eXK1UInq2bPmjyX6e3VHIzMLobc4J94i4AWn+Hpq3OU5KkrRC96OAcR3PRJ/pGu6m8TRnBHP9dkXQVsT/COVIA== -is-word-character@^1.0.0: - version "1.0.4" - resolved "https://registry.yarnpkg.com/is-word-character/-/is-word-character-1.0.4.tgz#ce0e73216f98599060592f62ff31354ddbeb0230" - integrity sha512-5SMO8RVennx3nZrqtKwCGyyetPE9VDba5ugvKLaD4KopPG5kR4mQ7tNt/r7feL5yt5h3lpuBbIUmCOG2eSzXHA== - is-wsl@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/is-wsl/-/is-wsl-1.1.0.tgz#1f16e4aa22b04d1336b66188a66af3c600c3a66d" @@ -8023,7 +8012,7 @@ loglevel@^1.6.2: resolved "https://registry.yarnpkg.com/loglevel/-/loglevel-1.6.2.tgz#668c77948a03dbd22502a3513ace1f62a80cc372" integrity sha512-Jt2MHrCNdtIe1W6co3tF5KXGRkzF+TYffiQstfXa04mrss9IKXzAAXYWak8LbZseAQY03sH2GzMCMU0ZOUc9bg== -longest-streak@^2.0.1: +longest-streak@^2.0.0: version "2.0.4" resolved "https://registry.yarnpkg.com/longest-streak/-/longest-streak-2.0.4.tgz#b8599957da5b5dab64dee3fe316fa774597d90e4" integrity sha512-vM6rUVCVUJJt33bnmHiZEvr7wPT78ztX7rojL+LW51bHtLh6HTjx84LA5W4+oa6aKEJA7jJu5LR6vQRBpA5DVg== @@ -8160,11 +8149,6 @@ map-visit@^1.0.0: dependencies: object-visit "^1.0.0" -markdown-escapes@^1.0.0: - version "1.0.4" - resolved "https://registry.yarnpkg.com/markdown-escapes/-/markdown-escapes-1.0.4.tgz#c95415ef451499d7602b91095f3c8e8975f78535" - integrity sha512-8z4efJYk43E0upd0NbVXwgSTQs6cT3T06etieCMEg7dRbzCbxUCK/GHlX8mhHRDcp+OLlHkPKsvqQTCvsRl2cg== - markdown-it-anchor@^5.0.2: version "5.2.3" resolved "https://registry.yarnpkg.com/markdown-it-anchor/-/markdown-it-anchor-5.2.3.tgz#76d07b5cfcf41a14cb6495522ed0f734ced337d9" @@ -8214,13 +8198,6 @@ markdown-it@^8.4.1: mdurl "^1.0.1" uc.micro "^1.0.5" -markdown-table@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/markdown-table/-/markdown-table-2.0.0.tgz#194a90ced26d31fe753d8b9434430214c011865b" - integrity sha512-Ezda85ToJUBhM6WGaG6veasyym+Tbs3cMAw/ZhOPqXiYsr0jgocBV3j3nx+4lk47plLlIqjwuTm/ywVI+zjJ/A== - dependencies: - repeat-string "^1.0.0" - md5.js@^1.3.4: version "1.3.5" resolved "https://registry.yarnpkg.com/md5.js/-/md5.js-1.3.5.tgz#b5d07b8e3216e3e27cd728d72f70d1e6a342005f" @@ -8230,12 +8207,33 @@ md5.js@^1.3.4: inherits "^2.0.1" safe-buffer "^5.1.2" -mdast-util-compact@^2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/mdast-util-compact/-/mdast-util-compact-2.0.1.tgz#cabc69a2f43103628326f35b1acf735d55c99490" - integrity sha512-7GlnT24gEwDrdAwEHrU4Vv5lLWrEer4KOkAiKT9nYstsTad7Oc1TwqT2zIMKRdZF7cTuaf+GA1E4Kv7jJh8mPA== +mdast-util-from-markdown@^0.8.0: + version "0.8.0" + resolved "https://registry.yarnpkg.com/mdast-util-from-markdown/-/mdast-util-from-markdown-0.8.0.tgz#0a13c0161a2974246bcb294cc77ff6858ef9c082" + integrity sha512-x9b9ekG2IfeqHSUPhn4+o8SeXqual0/ZHzzugV/cC21L6s1KyKAwIHKBJ1NN9ZstIlY8YAefELRSWfJMby4a9Q== dependencies: - unist-util-visit "^2.0.0" + "@types/mdast" "^3.0.0" + mdast-util-to-string "^1.0.0" + micromark "~2.10.0" + parse-entities "^2.0.0" + +mdast-util-to-markdown@^0.5.0: + version "0.5.1" + resolved "https://registry.yarnpkg.com/mdast-util-to-markdown/-/mdast-util-to-markdown-0.5.1.tgz#4a72a168f8a7b2c5506877498095144d32dcb026" + integrity sha512-7WS59irdm7lwd8iyfu+kLF+ktfzlvxLJzI/SwysF1EFFGpkU/G60Q61k7xZ420gsMVkXZ3MlcL3bTYCz5QwDeg== + dependencies: + "@types/unist" "^2.0.0" + longest-streak "^2.0.0" + mdast-util-to-string "^1.0.0" + parse-entities "^2.0.0" + repeat-string "^1.0.0" + stringify-entities "^3.0.0" + zwitch "^1.0.0" + +mdast-util-to-string@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/mdast-util-to-string/-/mdast-util-to-string-1.1.0.tgz#27055500103f51637bd07d01da01eb1967a43527" + integrity sha512-jVU0Nr2B9X3MU4tSK7JP1CMkSvOj7X5l/GboG1tKRw52lLF1x2Ju92Ms9tNetCcbfX3hzlM73zYo2NKkWSfF/A== mdn-data@~1.1.0: version "1.1.4" @@ -8296,6 +8294,14 @@ [email protected], methods@^1.1.2, methods@~1.1.2: resolved "https://registry.yarnpkg.com/methods/-/methods-1.1.2.tgz#5529a4d67654134edcc5266656835b0f851afcee" integrity sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4= +micromark@~2.10.0: + version "2.10.1" + resolved "https://registry.yarnpkg.com/micromark/-/micromark-2.10.1.tgz#cd73f54e0656f10e633073db26b663a221a442a7" + integrity sha512-fUuVF8sC1X7wsCS29SYQ2ZfIZYbTymp0EYr6sab3idFjigFFjGa5UwoniPlV9tAgntjuapW1t9U+S0yDYeGKHQ== + dependencies: + debug "^4.0.0" + parse-entities "^2.0.0" + micromatch@^3.1.10, micromatch@^3.1.4, micromatch@^3.1.8: version "3.1.10" resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-3.1.10.tgz#70859bc95c9840952f359a068a3fc49f9ecfac23" @@ -8550,7 +8556,7 @@ [email protected]: resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.1.tgz#30a5864eb3ebb0a66f2ebe6d727af06a09d86e0a" integrity sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg== -ms@^2.1.1: [email protected], ms@^2.1.1: version "2.1.2" resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009" integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w== @@ -10481,61 +10487,33 @@ [email protected]: unist-util-is "^4.0.2" unist-util-visit "^2.0.2" -remark-parse@^8.0.0: - version "8.0.2" - resolved "https://registry.yarnpkg.com/remark-parse/-/remark-parse-8.0.2.tgz#5999bc0b9c2e3edc038800a64ff103d0890b318b" - integrity sha512-eMI6kMRjsAGpMXXBAywJwiwAse+KNpmt+BK55Oofy4KvBZEqUDj6mWbGLJZrujoPIPPxDXzn3T9baRlpsm2jnQ== +remark-parse@^9.0.0: + version "9.0.0" + resolved "https://registry.yarnpkg.com/remark-parse/-/remark-parse-9.0.0.tgz#4d20a299665880e4f4af5d90b7c7b8a935853640" + integrity sha512-geKatMwSzEXKHuzBNU1z676sGcDcFoChMK38TgdHJNAYfFtsfHDQG7MoJAjs6sgYMqyLduCYWDIWZIxiPeafEw== dependencies: - ccount "^1.0.0" - collapse-white-space "^1.0.2" - is-alphabetical "^1.0.0" - is-decimal "^1.0.0" - is-whitespace-character "^1.0.0" - is-word-character "^1.0.0" - markdown-escapes "^1.0.0" - parse-entities "^2.0.0" - repeat-string "^1.5.4" - state-toggle "^1.0.0" - trim "0.0.1" - trim-trailing-lines "^1.0.0" - unherit "^1.0.4" - unist-util-remove-position "^2.0.0" - vfile-location "^3.0.0" - xtend "^4.0.1" + mdast-util-from-markdown "^0.8.0" [email protected]: version "0.4.0" resolved "https://registry.yarnpkg.com/remark-preset-prettier/-/remark-preset-prettier-0.4.0.tgz#b0edae6b46286c255ca897d44901145867585ab3" integrity sha512-Y0lwBg/xRyE8/yF4IYJVJxrUHSVE8WThbsnKS5/fE4lSAoX/s0yuiEl7gv/+OWA1G7r5o0xKLZPW3rJjhvfvpw== -remark-stringify@^8.0.0: - version "8.0.0" - resolved "https://registry.yarnpkg.com/remark-stringify/-/remark-stringify-8.0.0.tgz#33423ab8bf3076fb197f4cf582aaaf866b531625" - integrity sha512-cABVYVloFH+2ZI5bdqzoOmemcz/ZuhQSH6W6ZNYnLojAUUn3xtX7u+6BpnYp35qHoGr2NFBsERV14t4vCIeW8w== +remark-stringify@^9.0.0: + version "9.0.0" + resolved "https://registry.yarnpkg.com/remark-stringify/-/remark-stringify-9.0.0.tgz#8ba0c9e4167c42733832215a81550489759e3793" + integrity sha512-8x29DpTbVzEc6Dwb90qhxCtbZ6hmj3BxWWDpMhA+1WM4dOEGH5U5/GFe3Be5Hns5MvPSFAr1e2KSVtKZkK5nUw== dependencies: - ccount "^1.0.0" - is-alphanumeric "^1.0.0" - is-decimal "^1.0.0" - is-whitespace-character "^1.0.0" - longest-streak "^2.0.1" - markdown-escapes "^1.0.0" - markdown-table "^2.0.0" - mdast-util-compact "^2.0.0" - parse-entities "^2.0.0" - repeat-string "^1.5.4" - state-toggle "^1.0.0" - stringify-entities "^3.0.0" - unherit "^1.0.4" - xtend "^4.0.1" + mdast-util-to-markdown "^0.5.0" [email protected]: - version "12.0.1" - resolved "https://registry.yarnpkg.com/remark/-/remark-12.0.1.tgz#f1ddf68db7be71ca2bad0a33cd3678b86b9c709f" - integrity sha512-gS7HDonkdIaHmmP/+shCPejCEEW+liMp/t/QwmF0Xt47Rpuhl32lLtDV1uKWvGoq+kxr5jSgg5oAIpGuyULjUw== [email protected]: + version "13.0.0" + resolved "https://registry.yarnpkg.com/remark/-/remark-13.0.0.tgz#d15d9bf71a402f40287ebe36067b66d54868e425" + integrity sha512-HDz1+IKGtOyWN+QgBiAT0kn+2s6ovOxHyPAFGKVE81VSzJ+mq7RwHFledEvB5F1p4iJvOah/LOKdFuzvRnNLCA== dependencies: - remark-parse "^8.0.0" - remark-stringify "^8.0.0" - unified "^9.0.0" + remark-parse "^9.0.0" + remark-stringify "^9.0.0" + unified "^9.1.0" remove-trailing-separator@^1.0.1: version "1.1.0" @@ -10558,7 +10536,7 @@ repeat-element@^1.1.2: resolved "https://registry.yarnpkg.com/repeat-element/-/repeat-element-1.1.3.tgz#782e0d825c0c5a3bb39731f84efee6b742e6b1ce" integrity sha512-ahGq0ZnV5m5XtZLMb+vP76kcAM5nkLqk0lpqAuojSKGgQtn4eRi4ZZGm2olo2zKFH+sMsWaqOCW1dqAnOru72g== -repeat-string@^1.0.0, repeat-string@^1.5.4, repeat-string@^1.6.1: +repeat-string@^1.0.0, repeat-string@^1.6.1: version "1.6.1" resolved "https://registry.yarnpkg.com/repeat-string/-/repeat-string-1.6.1.tgz#8dcae470e1c88abc2d600fff4a776286da75e637" integrity sha1-jcrkcOHIirwtYA//Sndihtp15jc= @@ -11344,11 +11322,6 @@ [email protected]: resolved "https://registry.yarnpkg.com/staged-git-files/-/staged-git-files-1.2.0.tgz#05b43f4fcec6d4799ac41c826ecd17c0bd53ce82" integrity sha512-MYK3aDsO8XAXkv2ASsrznObxVDlocYm7gc/cMk/hB4vbJZeEqOO7H1mZR7EY2C5q3YgKOBo3Tmu0D30h7RjdWg== -state-toggle@^1.0.0: - version "1.0.3" - resolved "https://registry.yarnpkg.com/state-toggle/-/state-toggle-1.0.3.tgz#e123b16a88e143139b09c6852221bc9815917dfe" - integrity sha512-d/5Z4/2iiCnHw6Xzghyhb+GcmF89bxwgXG60wjIiZaxnymbyOmI8Hk4VqHXiVVp6u2ysaskFfXg3ekCj4WNftQ== - static-extend@^0.1.1: version "0.1.2" resolved "https://registry.yarnpkg.com/static-extend/-/static-extend-0.1.2.tgz#60809c39cbff55337226fd5e0b520f341f1fb5c6" @@ -12025,16 +11998,6 @@ trim-right@^1.0.1: resolved "https://registry.yarnpkg.com/trim-right/-/trim-right-1.0.1.tgz#cb2e1203067e0c8de1f614094b9fe45704ea6003" integrity sha1-yy4SAwZ+DI3h9hQJS5/kVwTqYAM= -trim-trailing-lines@^1.0.0: - version "1.1.3" - resolved "https://registry.yarnpkg.com/trim-trailing-lines/-/trim-trailing-lines-1.1.3.tgz#7f0739881ff76657b7776e10874128004b625a94" - integrity sha512-4ku0mmjXifQcTVfYDfR5lpgV7zVqPg6zV9rdZmwOPqq0+Zq19xDqEgagqVbc4pOOShbncuAOIs59R3+3gcF3ZA== - [email protected]: - version "0.0.1" - resolved "https://registry.yarnpkg.com/trim/-/trim-0.0.1.tgz#5858547f6b290757ee95cccc666fb50084c460dd" - integrity sha1-WFhUf2spB1fulczMZm+1AITEYN0= - triple-beam@^1.2.0, triple-beam@^1.3.0: version "1.3.0" resolved "https://registry.yarnpkg.com/triple-beam/-/triple-beam-1.3.0.tgz#a595214c7298db8339eeeee083e4d10bd8cb8dd9" @@ -12197,14 +12160,6 @@ underscore@*: resolved "https://registry.yarnpkg.com/underscore/-/underscore-1.10.2.tgz#73d6aa3668f3188e4adb0f1943bd12cfd7efaaaf" integrity sha512-N4P+Q/BuyuEKFJ43B9gYuOj4TQUHXX+j2FqguVOpjkssLUUrnJofCcBccJSCoeturDoZU6GorDTHSvUDlSQbTg== -unherit@^1.0.4: - version "1.1.3" - resolved "https://registry.yarnpkg.com/unherit/-/unherit-1.1.3.tgz#6c9b503f2b41b262330c80e91c8614abdaa69c22" - integrity sha512-Ft16BJcnapDKp0+J/rqFC3Rrk6Y/Ng4nzsC028k2jdDII/rdZ7Wd3pPT/6+vIIxRagwRc9K0IUX0Ra4fKvw+WQ== - dependencies: - inherits "^2.0.0" - xtend "^4.0.0" - unicode-canonical-property-names-ecmascript@^1.0.4: version "1.0.4" resolved "https://registry.yarnpkg.com/unicode-canonical-property-names-ecmascript/-/unicode-canonical-property-names-ecmascript-1.0.4.tgz#2619800c4c825800efdd8343af7dd9933cbe2818" @@ -12228,10 +12183,10 @@ unicode-property-aliases-ecmascript@^1.0.4: resolved "https://registry.yarnpkg.com/unicode-property-aliases-ecmascript/-/unicode-property-aliases-ecmascript-1.0.5.tgz#a9cc6cc7ce63a0a3023fc99e341b94431d405a57" integrity sha512-L5RAqCfXqAwR3RriF8pM0lU0w4Ryf/GgzONwi6KnL1taJQa7x1TCxdJnILX59WIGOwR57IVxn7Nej0fz1Ny6fw== -unified@^9.0.0: - version "9.0.0" - resolved "https://registry.yarnpkg.com/unified/-/unified-9.0.0.tgz#12b099f97ee8b36792dbad13d278ee2f696eed1d" - integrity sha512-ssFo33gljU3PdlWLjNp15Inqb77d6JnJSfyplGJPT/a+fNRNyCBeveBAYJdO5khKdF6WVHa/yYCC7Xl6BDwZUQ== +unified@^9.1.0: + version "9.2.0" + resolved "https://registry.yarnpkg.com/unified/-/unified-9.2.0.tgz#67a62c627c40589edebbf60f53edfd4d822027f8" + integrity sha512-vx2Z0vY+a3YoTj8+pttM3tiJHCwY5UFbYdiWrwBEbHmK8pvsPj2rtAX2BFfgXen8T39CJWblWRDT4L5WGXtDdg== dependencies: bail "^1.0.0" extend "^3.0.0" @@ -12286,13 +12241,6 @@ unist-util-is@^4.0.0, unist-util-is@^4.0.2: resolved "https://registry.yarnpkg.com/unist-util-is/-/unist-util-is-4.0.2.tgz#c7d1341188aa9ce5b3cff538958de9895f14a5de" integrity sha512-Ofx8uf6haexJwI1gxWMGg6I/dLnF2yE+KibhD3/diOqY2TinLcqHXCV6OI5gFVn3xQqDH+u0M625pfKwIwgBKQ== -unist-util-remove-position@^2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/unist-util-remove-position/-/unist-util-remove-position-2.0.1.tgz#5d19ca79fdba712301999b2b73553ca8f3b352cc" - integrity sha512-fDZsLYIe2uT+oGFnuZmy73K6ZxOPG/Qcm+w7jbEjaFcJgbQ6cqjs/eSPzXhsmGpAsWPkqZM9pYjww5QTn3LHMA== - dependencies: - unist-util-visit "^2.0.0" - unist-util-stringify-position@^2.0.0: version "2.0.3" resolved "https://registry.yarnpkg.com/unist-util-stringify-position/-/unist-util-stringify-position-2.0.3.tgz#cce3bfa1cdf85ba7375d1d5b17bdc4cada9bd9da" @@ -12308,7 +12256,7 @@ unist-util-visit-parents@^3.0.0: "@types/unist" "^2.0.0" unist-util-is "^4.0.0" -unist-util-visit@^2.0.0, unist-util-visit@^2.0.2: +unist-util-visit@^2.0.2: version "2.0.2" resolved "https://registry.yarnpkg.com/unist-util-visit/-/unist-util-visit-2.0.2.tgz#3843782a517de3d2357b4c193b24af2d9366afb7" integrity sha512-HoHNhGnKj6y+Sq+7ASo2zpVdfdRifhTgX2KTU3B/sO/TTlZchp7E3S4vjRzDJ7L60KmrCPsQkVK3lEF3cz36XQ== @@ -12529,11 +12477,6 @@ [email protected]: core-util-is "1.0.2" extsprintf "^1.2.0" -vfile-location@^3.0.0: - version "3.0.1" - resolved "https://registry.yarnpkg.com/vfile-location/-/vfile-location-3.0.1.tgz#d78677c3546de0f7cd977544c367266764d31bb3" - integrity sha512-yYBO06eeN/Ki6Kh1QAkgzYpWT1d3Qln+ZCtSbJqFExPl1S3y2qqotJQXoh6qEvl/jDlgpUJolBn3PItVnnZRqQ== - vfile-message@^2.0.0: version "2.0.4" resolved "https://registry.yarnpkg.com/vfile-message/-/vfile-message-2.0.4.tgz#5b43b88171d409eae58477d13f23dd41d52c371a" @@ -13197,11 +13140,6 @@ xtend@^4.0.0, xtend@~4.0.1: resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.1.tgz#a5c6d532be656e23db820efb943a1f04998d63af" integrity sha1-pcbVMr5lbiPbgg77lDofBJmNY68= -xtend@^4.0.1: - version "4.0.2" - resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.2.tgz#bb72779f5fa465186b1f438f674fa347fdb5db54" - integrity sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ== - "y18n@^3.2.1 || ^4.0.0", y18n@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/y18n/-/y18n-4.0.0.tgz#95ef94f85ecc81d007c264e190a120f0a3c8566b" @@ -13313,3 +13251,8 @@ zepto@^1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/zepto/-/zepto-1.2.0.tgz#e127bd9e66fd846be5eab48c1394882f7c0e4f98" integrity sha1-4Se9nmb9hGvl6rSME5SIL3wOT5g= + +zwitch@^1.0.0: + version "1.0.5" + resolved "https://registry.yarnpkg.com/zwitch/-/zwitch-1.0.5.tgz#d11d7381ffed16b742f6af7b3f223d5cd9fe9920" + integrity sha512-V50KMwwzqJV0NpZIZFwfOD5/lyny3WlSzRiXgA0G7VUnRlqttta1L6UQIHzd6EuBY/cHGfwTIck7w1yH6Q5zUw==
7a93e0c7276e92da3a93e95ac227ac592996f382
2024-03-03 20:39:47
cnkmmk
feat(route): add 国外主机测评 (#14633)
false
add 国外主机测评 (#14633)
feat
diff --git a/lib/routes/zhujiceping/maintainer.js b/lib/routes/zhujiceping/maintainer.js new file mode 100644 index 00000000000000..387d961bfe3f67 --- /dev/null +++ b/lib/routes/zhujiceping/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/': ['cnkmmk'], +}; diff --git a/lib/routes/zhujiceping/radar.js b/lib/routes/zhujiceping/radar.js new file mode 100644 index 00000000000000..5ea1b8e747a45d --- /dev/null +++ b/lib/routes/zhujiceping/radar.js @@ -0,0 +1,13 @@ +module.exports = { + 'zhujiceping.com': { + _name: '国外主机测评', + '.': [ + { + title: '最新发布', + docs: 'https://docs.rsshub.app/routes/blog#guo-wai-zhu-ji-ce-ping', + source: ['/'], + target: '/zhujiceping', + }, + ], + }, +}; diff --git a/lib/routes/zhujiceping/router.js b/lib/routes/zhujiceping/router.js new file mode 100644 index 00000000000000..09c585b57315bb --- /dev/null +++ b/lib/routes/zhujiceping/router.js @@ -0,0 +1,3 @@ +export default (router) => { + router.get('/', './rss'); +}; diff --git a/lib/routes/zhujiceping/rss.js b/lib/routes/zhujiceping/rss.js new file mode 100644 index 00000000000000..7c75304996c624 --- /dev/null +++ b/lib/routes/zhujiceping/rss.js @@ -0,0 +1,32 @@ +import { parseDate } from '@/utils/parse-date'; +import got from '@/utils/got'; +import { load } from 'cheerio'; + +export default async (ctx) => { + const url = 'https://www.zhujiceping.com/'; + const response = await got({ method: 'get', url }); + const $ = load(response.data); + + const list = $('article.excerpt') + .map((i, e) => { + const element = $(e); + const title = element.find('h2 > a').attr('title'); + const link = element.find('h2 > a').attr('href'); + const description = element.find('p.note').text(); + const dateraw = element.find('time').text(); + + return { + title, + description, + link, + pubDate: parseDate(dateraw, 'YYYY-MM-DD'), + }; + }) + .get(); + + ctx.set('data', { + title: '国外主机测评', + link: url, + item: list, + }); +}; diff --git a/website/docs/routes/blog.mdx b/website/docs/routes/blog.mdx index 84aa4d03b27789..f0c431f15af3f7 100644 --- a/website/docs/routes/blog.mdx +++ b/website/docs/routes/blog.mdx @@ -491,3 +491,9 @@ ### 上周热门 TOP 20 {#zhu-bai-shang-zhou-re-men-top-20} <Route author="nczitzk" example="/zhubai/top20" path="/zhubai/top20" radar="1" /> + +## 国外主机测评 {#guo-wai-zhu-ji-ce-ping} + +### 最新发布 {#guo-wai-zhu-ji-ce-ping-zui-xin-fa-bu} + +<Route author="cnkmmk" example="/zhujiceping" path="/zhujiceping" />
3dde0db9104fabeb5f28865bb83509e4015434a8
2019-06-12 15:27:28
Chenyang Shi
feat: 对路由空内容报错 (#2388)
false
对路由空内容报错 (#2388)
feat
diff --git a/lib/middleware/parameter.js b/lib/middleware/parameter.js index 62a3ec0152f67a..8dd288c5feff0e 100644 --- a/lib/middleware/parameter.js +++ b/lib/middleware/parameter.js @@ -55,4 +55,8 @@ module.exports = async (ctx, next) => { return item; }); } + + if (ctx.state.data && ctx.state.data.item.length === 0) { + throw Error('该路由目前获取内容为空,请检查源站情况或前往https://github.com/DIYgod/RSSHub/issues反馈该问题'); + } };
2453d71ce7e090cfcbf7ed2d6c656eaf113c8353
2020-09-27 04:13:52
dependabot-preview[bot]
chore(deps-dev): bump @vuepress/plugin-google-analytics
false
bump @vuepress/plugin-google-analytics
chore
diff --git a/package.json b/package.json index e41be563b79bb0..cfee80035a61ad 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "@types/got": "9.6.11", "@types/koa": "2.11.4", "@vuepress/plugin-back-to-top": "1.5.4", - "@vuepress/plugin-google-analytics": "1.5.4", + "@vuepress/plugin-google-analytics": "1.6.0", "@vuepress/plugin-pwa": "1.6.0", "cross-env": "7.0.2", "entities": "2.0.3", diff --git a/yarn.lock b/yarn.lock index 38b716f9f2b324..9f426a31aa392c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1936,10 +1936,10 @@ dependencies: lodash.debounce "^4.0.8" -"@vuepress/[email protected]": - version "1.5.4" - resolved "https://registry.yarnpkg.com/@vuepress/plugin-google-analytics/-/plugin-google-analytics-1.5.4.tgz#43dff0a84b18b21ea597f3d97281c40d754a5083" - integrity sha512-JVmIPBqKNiOVvow+XAZE+jgGvIRMBVxZOpKb5HBQ0xwz/E81Opl7cxdX9VkPKX+i9VoRBPWEiD/874RivzbW1g== +"@vuepress/[email protected]": + version "1.6.0" + resolved "https://registry.yarnpkg.com/@vuepress/plugin-google-analytics/-/plugin-google-analytics-1.6.0.tgz#1a3960259556016b668276ab00417f1c96ddf4bd" + integrity sha512-CPRTQsq6KnZEb4SEB/6KdXHFKGvKdsg0GWtSYpLTbF/aUETVRUVJsqR7i/tLWgtyB8qFMwzPUiTc7KlEFjvYyg== "@vuepress/[email protected]": version "1.5.3"
369d2902e86117e03ee44625a3f06b2179c03ad0
2022-02-02 00:22:14
Ethan Shen
feat(route): add Radio-Canada.ca latest news (#8275)
false
add Radio-Canada.ca latest news (#8275)
feat
diff --git a/docs/en/new-media.md b/docs/en/new-media.md index e62df65a6103ce..63453c0926131f 100644 --- a/docs/en/new-media.md +++ b/docs/en/new-media.md @@ -494,6 +494,18 @@ Compared to the official one, this feed: </RouteEn> +## Radio-Canada.ca + +### Latest News + +<RouteEn author="nczitzk" example="/radio-canada/latest" path="/radio-canada/latest/:language?" :paramsDesc="['Language, see below, English by default']"> + +| Français | English | Español | 简体中文 | 繁體中文 | العربية | ਪੰਜਾਬੀ | Tagalog | +| -------- | ------- | ------- | -------- | -------- | ------- | ------ | ------- | +| fr | en | es | zh-hans | zh-hant | ar | pa | tl | + +</RouteEn> + ## Research Gate ### Publications diff --git a/docs/new-media.md b/docs/new-media.md index 667a32eaa019a9..23a4555233e759 100644 --- a/docs/new-media.md +++ b/docs/new-media.md @@ -1858,6 +1858,18 @@ others = 热点新闻 + 滚动新闻 </Route> +## 加拿大国际广播电台 + +### 最新消息 + +<Route author="nczitzk" example="/radio-canada/latest" path="/radio-canada/latest/:language?" :paramsDesc="['语言,见下表,默认为 English']"> + +| Français | English | Español | 简体中文 | 繁體中文 | العربية | ਪੰਜਾਬੀ | Tagalog | +| -------- | ------- | ------- | -------- | -------- | ------- | ------ | ------- | +| fr | en | es | zh-hans | zh-hant | ar | pa | tl | + +</Route> + ## 贾真的电商 108 将 ### 「108 将」实战分享 diff --git a/lib/v2/radio-canada/latest.js b/lib/v2/radio-canada/latest.js new file mode 100644 index 00000000000000..789a48307d1982 --- /dev/null +++ b/lib/v2/radio-canada/latest.js @@ -0,0 +1,43 @@ +const got = require('@/utils/got'); +const { parseDate } = require('@/utils/parse-date'); + +module.exports = async (ctx) => { + const language = ctx.params.language ?? 'en'; + + const rootUrl = 'https://ici.radio-canada.ca'; + const apiRootUrl = 'https://services.radio-canada.ca'; + const currentUrl = `${apiRootUrl}/neuro/sphere/v1/rci/${language}/continuous-feed?pageSize=50`; + + const response = await got({ + method: 'get', + url: currentUrl, + }); + + const list = response.data.data.lineup.items.map((item) => ({ + title: item.title, + category: item.kicker, + link: `${rootUrl}${item.url}`, + pubDate: parseDate(item.date), + })); + + const items = await Promise.all( + list.map((item) => + ctx.cache.tryGet(item.link, async () => { + const detailResponse = await got({ + method: 'get', + url: item.link, + }); + + item.description = detailResponse.data.match(/"body":{"html":"(.*)","attachments"/)[1].replace(/\\n/g, ''); + + return item; + }) + ) + ); + + ctx.state.data = { + title: response.data.meta.title, + link: response.data.metric.metrikContent.omniture.url, + item: items, + }; +}; diff --git a/lib/v2/radio-canada/maintainer.js b/lib/v2/radio-canada/maintainer.js new file mode 100644 index 00000000000000..57f1d832a3f4ed --- /dev/null +++ b/lib/v2/radio-canada/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/latest/:language?': ['nczitzk'], +}; diff --git a/lib/v2/radio-canada/radar.js b/lib/v2/radio-canada/radar.js new file mode 100644 index 00000000000000..60ba06c2a3c660 --- /dev/null +++ b/lib/v2/radio-canada/radar.js @@ -0,0 +1,13 @@ +module.exports = { + 'ici.radio-canada.ca': { + _name: 'Radio Canada', + '.': [ + { + title: 'Latest News', + docs: 'https://docs.rsshub.app/new-media.html#jia-na-da-guo-ji-guang-bo-dian-tai-zui-xin-xiao-xi', + source: ['/rci/:lang', '/'], + target: '/radio-canada/latest/:language?', + }, + ], + }, +}; diff --git a/lib/v2/radio-canada/router.js b/lib/v2/radio-canada/router.js new file mode 100644 index 00000000000000..89de189ec1a908 --- /dev/null +++ b/lib/v2/radio-canada/router.js @@ -0,0 +1,3 @@ +module.exports = function (router) { + router.get('/latest/:language?', require('./latest')); +};
d4f340e122be8bc546f8e4163ba880bc921b82e7
2022-08-06 02:42:09
dependabot[bot]
chore(deps): bump @sentry/node from 7.8.1 to 7.9.0 (#10402)
false
bump @sentry/node from 7.8.1 to 7.9.0 (#10402)
chore
diff --git a/package.json b/package.json index af804c3e328e3b..5a18f8a5ddf134 100644 --- a/package.json +++ b/package.json @@ -79,7 +79,7 @@ "dependencies": { "@koa/router": "12.0.0", "@postlight/mercury-parser": "2.2.1", - "@sentry/node": "7.8.1", + "@sentry/node": "7.9.0", "aes-js": "3.1.2", "art-template": "4.13.2", "bbcodejs": "0.0.4", diff --git a/yarn.lock b/yarn.lock index 65a3a708c1fa86..24090beded6b73 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1536,50 +1536,50 @@ domhandler "^4.2.0" selderee "^0.6.0" -"@sentry/[email protected]": - version "7.8.1" - resolved "https://registry.yarnpkg.com/@sentry/core/-/core-7.8.1.tgz#d11ba7c97766d1e47edf697dbfd47fe4041477d9" - integrity sha512-PRivbdIzApi/gSixAxozhOBTylSVdw/9VxaStYHd7JJGhs36KXkV8ylpbCmYO4ap7/Ue9/slzwpvPOJJzmzAgA== - dependencies: - "@sentry/hub" "7.8.1" - "@sentry/types" "7.8.1" - "@sentry/utils" "7.8.1" +"@sentry/[email protected]": + version "7.9.0" + resolved "https://registry.yarnpkg.com/@sentry/core/-/core-7.9.0.tgz#fb9308e067a4b5794eb49f8bac303bb9c627b1a9" + integrity sha512-WVGd2hV7Clcpl7/GL8LsRr4Zk9o/7o4rZHfs1Qed5lMRNYcxiMwucC1CYILVpJqVfY+8vIRP9v9Ss9ta2VUikw== + dependencies: + "@sentry/hub" "7.9.0" + "@sentry/types" "7.9.0" + "@sentry/utils" "7.9.0" tslib "^1.9.3" -"@sentry/[email protected]": - version "7.8.1" - resolved "https://registry.yarnpkg.com/@sentry/hub/-/hub-7.8.1.tgz#bc255c6b8e99a3333e737f189c984c715df504aa" - integrity sha512-AxwyGyS9Lp4XsURu4t8opa5vZ+NAB6I/n+B/Uix3YZea9z8jdWYAu9vsXSizOrtxekc/i7ZN4bnlNgXVHix0iA== +"@sentry/[email protected]": + version "7.9.0" + resolved "https://registry.yarnpkg.com/@sentry/hub/-/hub-7.9.0.tgz#29d4c796006282a20e5f78a1bb156d8f5eacd772" + integrity sha512-KzPbGCB5mONgsXEzqHy6uOaOuqLnhmFmSpGg+M03J6UJnJaNM7nrNp80MhStmjLMq6whEYVE07DrMAn3+iaQdg== dependencies: - "@sentry/types" "7.8.1" - "@sentry/utils" "7.8.1" + "@sentry/types" "7.9.0" + "@sentry/utils" "7.9.0" tslib "^1.9.3" -"@sentry/[email protected]": - version "7.8.1" - resolved "https://registry.yarnpkg.com/@sentry/node/-/node-7.8.1.tgz#9dca7afee2d9ad38fd9756e13439ce09d2f01934" - integrity sha512-gQHeIip7QudeK1YWrLyZPc7nfirhbVDJ3gfCfL9mLT724Sk8gKd1kcpU1niI+wwIwY7SOpJqX4Oh/F0lRKjzDQ== +"@sentry/[email protected]": + version "7.9.0" + resolved "https://registry.yarnpkg.com/@sentry/node/-/node-7.9.0.tgz#2ce1f9336a22cee3530ccd472081f71073af5116" + integrity sha512-MeggSCLyhUhsX3gRRvDhTADKYshuWjTRO/dUv3Jw+2xToSDvSWXJXDkIg5mCdlyOhh9/G+5xdWY58CfomzPZgg== dependencies: - "@sentry/core" "7.8.1" - "@sentry/hub" "7.8.1" - "@sentry/types" "7.8.1" - "@sentry/utils" "7.8.1" + "@sentry/core" "7.9.0" + "@sentry/hub" "7.9.0" + "@sentry/types" "7.9.0" + "@sentry/utils" "7.9.0" cookie "^0.4.1" https-proxy-agent "^5.0.0" lru_map "^0.3.3" tslib "^1.9.3" -"@sentry/[email protected]": - version "7.8.1" - resolved "https://registry.yarnpkg.com/@sentry/types/-/types-7.8.1.tgz#c00a1ed02ad8f69d3b94fcda91e2d24e0bb3492a" - integrity sha512-LOoaeBXVI23Kh5SpIbxSRiJ6+eYZXVOFyPFH1T1mGBj95LPwRMqOdg0lUTmFJGBKbDGDB/YNjNnu1kQ7GrXBXw== +"@sentry/[email protected]": + version "7.9.0" + resolved "https://registry.yarnpkg.com/@sentry/types/-/types-7.9.0.tgz#8fa952865fda76f7c7c7fc6c84043979a22043ae" + integrity sha512-VGnUgELVMpGJCYW1triO+5XSyaPjB2Zu6esUgbb8iJ5bi+OWtxklixXgwhdaTb0FDzmRL/T/pckmrIuBTLySHQ== -"@sentry/[email protected]": - version "7.8.1" - resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-7.8.1.tgz#5d8a7e1c8d834de608ad834cf648d5291c62ba39" - integrity sha512-isUZjft4HWTOk1Z58KFJ/zzXeFtIJgP82CkYQlW464ZR2WCqPHYlXXXRWZpOHOfMnrf+gWeX9WAGS9rTAdhiSg== +"@sentry/[email protected]": + version "7.9.0" + resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-7.9.0.tgz#497c41efe1b32974208ca68570e42c853b874f77" + integrity sha512-4f9TZvAVopgG7Lp1TcPSekSX1Ashk68Et4T8Y+60EVX5se19i0hpytbHWWwrXSrb3w0KpGANk0byoZkdaTgkYA== dependencies: - "@sentry/types" "7.8.1" + "@sentry/types" "7.9.0" tslib "^1.9.3" "@sinclair/typebox@^0.24.1":
96d392fec97f7e96355ddfffea33ee226fb75c7b
2022-03-19 00:44:53
Tony
fix(route): github pull requests (#9341)
false
github pull requests (#9341)
fix
diff --git a/docs/en/programming.md b/docs/en/programming.md index 08936ea0570d5c..e703c21f51888b 100644 --- a/docs/en/programming.md +++ b/docs/en/programming.md @@ -141,7 +141,7 @@ For instance, the `/github/topics/framework/l=php&o=desc&s=stars` route will gen ### Repo Pull Requests -<RouteEn author="hashman" example="/github/pull/DIYgod/RSSHub" path="/github/pull/:user/:repo" :paramsDesc="['User name', 'Repo name']" radar="1" rssbud="1"/> +<RouteEn author="hashman TonyRL" example="/github/pull/DIYgod/RSSHub" path="/github/pull/:user/:repo/:state?" :paramsDesc="['User name', 'Repo name', 'the state of pull requests. Can be either `open`, `closed`, or `all`. Default: `open`.']" radar="1" rssbud="1"/> ### User Followers diff --git a/docs/programming.md b/docs/programming.md index eeedd748e5f619..8f919efc1d7ff6 100644 --- a/docs/programming.md +++ b/docs/programming.md @@ -219,7 +219,7 @@ GitHub 官方也提供了一些 RSS: ### 仓库 Pull Requests -<Route author="hashman" example="/github/pull/DIYgod/RSSHub" path="/github/pull/:user/:repo" :paramsDesc="['用户名', '仓库名']" radar="1" rssbud="1"/> +<Route author="hashman" example="/github/pull/DIYgod/RSSHub" path="/github/pull/:user/:repo/:state?" :paramsDesc="['用户名', '仓库名', 'pull request 状态,`open`,`closed`或`all`,默认为`open`']" radar="1" rssbud="1"/> ### 用户 Followers diff --git a/lib/v2/github/maintainer.js b/lib/v2/github/maintainer.js index 87e1db702e8f69..a286a5e2bc6259 100644 --- a/lib/v2/github/maintainer.js +++ b/lib/v2/github/maintainer.js @@ -4,7 +4,7 @@ module.exports = { '/contributors/:user/:repo/:order?/:anon?': ['zoenglinghou'], '/file/:user/:repo/:branch/:filepath+': ['zengxs'], '/issue/:user/:repo/:state?/:labels?': ['HenryQW', 'AndreyMZ'], - '/pull/:user/:repo': ['hashman'], + '/pull/:user/:repo/:state?': ['hashman', 'TonyRL'], '/repos/:user': ['DIYgod'], '/search/:query/:sort?/:order?': ['LogicJake'], '/starred_repos/:user': ['LanceZhu'], diff --git a/lib/v2/github/pulls.js b/lib/v2/github/pulls.js index 036c38f6aff625..ceac91e6a57d80 100644 --- a/lib/v2/github/pulls.js +++ b/lib/v2/github/pulls.js @@ -5,13 +5,14 @@ const md = require('markdown-it')({ linkify: true, }); const queryString = require('query-string'); +const { parseDate } = require('@/utils/parse-date'); module.exports = async (ctx) => { const user = ctx.params.user; const repo = ctx.params.repo; + const state = ctx.params.state ?? 'open'; const host = `https://github.com/${user}/${repo}/pulls`; - const link = `https://github.com/${user}/${repo}/pull`; const url = `https://api.github.com/repos/${user}/${repo}/pulls`; const headers = {}; @@ -22,7 +23,10 @@ module.exports = async (ctx) => { method: 'get', url, searchParams: queryString.stringify({ + state, sort: 'created', + direction: 'desc', + per_page: ctx.query.limit ? (parseInt(ctx.query.limit) <= 100 ? parseInt(ctx.query.limit) : 100) : 100, }), headers, }); @@ -36,8 +40,8 @@ module.exports = async (ctx) => { title: item.title, author: item.user.login, description: item.body ? md.render(item.body) : 'No description', - pubDate: new Date(item.created_at).toUTCString(), - link: `${link}/${item.number}`, + pubDate: parseDate(item.created_at), + link: item.html_url, })), }; }; diff --git a/lib/v2/github/router.js b/lib/v2/github/router.js index 1dda4be8c370e4..54b517de887e74 100644 --- a/lib/v2/github/router.js +++ b/lib/v2/github/router.js @@ -4,7 +4,7 @@ module.exports = function (router) { router.get('/contributors/:user/:repo/:order?/:anon?', require('./contributors')); router.get('/file/:user/:repo/:branch/:filepath+', require('./file')); router.get('/issue/:user/:repo/:state?/:labels?', require('./issue')); - router.get('/pull/:user/:repo', require('./pulls')); + router.get('/pull/:user/:repo/:state?', require('./pulls')); router.get('/repos/:user', require('./repos')); router.get('/search/:query/:sort?/:order?', require('./search')); router.get('/starred_repos/:user', require('./starred_repos'));
84ded422f1e17732879f9ab230ba61173bf95f39
2019-09-27 07:58:52
a14907
feat: 实现天涯论坛的抓取 (#3143)
false
实现天涯论坛的抓取 (#3143)
feat
diff --git a/docs/bbs.md b/docs/bbs.md index 78ad80248afb6d..411d44f10d7138 100644 --- a/docs/bbs.md +++ b/docs/bbs.md @@ -160,3 +160,17 @@ pageClass: routes ### 回帖 <Route author="LogicJake" example="/zhibo8/post/2601615" path="/zhibo8/post/:id" :paramsDesc="['帖子 id,可在帖子 URL 找到']"/> + +## 天涯论坛 + +### 子版块 + +<Route author="a14907" example="/tianya/index/lookout" path="/tianya/index/:type" :paramsDesc="['板块类型 type,可在 URL 找到 例如,天涯杂谈板块的地址是http://bbs.tianya.cn/list-free-1.shtml, 这个板块的type就是free; 同理,我的大学板块地址为http://bbs.tianya.cn/list-university-1.shtml,类型是university']"/> + +### 用户帖子 + +<Route author="a14907" example="/tianya/user/11488997" path="/tianya/user/:userid" :paramsDesc="['用户id userid,可在 URL 找到 例如,用户苕木匠的地址是http://www.tianya.cn/11488997/bbs, 苕木匠的userid就是11488997']"/> + +### 用户的回帖 + +<Route author="a14907" example="/tianya/comments/11488997" path="/tianya/comments/:userid" :paramsDesc="['用户id userid,可在 URL 找到 例如,用户苕木匠的地址是http://www.tianya.cn/11488997/bbs, 苕木匠的userid就是11488997']"/> diff --git a/lib/router.js b/lib/router.js index febf926a79b619..aa0a86faec0ee1 100644 --- a/lib/router.js +++ b/lib/router.js @@ -1649,6 +1649,11 @@ router.get('/soul/:id', require('./routes/soul')); // 单向空间 router.get('/owspace/read/:type?', require('./routes/owspace/read')); +// 天涯论坛 +router.get('/tianya/index/:type', require('./routes/tianya/index')); +router.get('/tianya/user/:userid', require('./routes/tianya/user')); +router.get('/tianya/comments/:userid', require('./routes/tianya/comments')); + // eleme router.get('/eleme/open/announce', require('./routes/eleme/open/announce')); router.get('/eleme/open-be/announce', require('./routes/eleme/open-be/announce')); diff --git a/lib/routes/tianya/comments.js b/lib/routes/tianya/comments.js new file mode 100644 index 00000000000000..2f7e5c6a3bf0b9 --- /dev/null +++ b/lib/routes/tianya/comments.js @@ -0,0 +1,36 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + +module.exports = async (ctx) => { + const { userid } = ctx.params; + const url = 'http://www.tianya.cn/' + userid + '/bbs?t=post'; + const responseraw = await got(url, { headers: { Referer: 'http://bbs.tianya.cn' } }); + const $ = cheerio.load(responseraw.data); + const username = $('div.portrait h2 a') + .first() + .text(); + + const turl = `http://www.tianya.cn/api/bbsuser?method=userinfo.ice.getUserTotalReplyList&params.userId=${userid}&params.pageSize=20&params.bMore=true`; + const response = await got(turl, { headers: { Referer: 'http://bbs.tianya.cn' } }); + const json = response.data; + const items = json.data.rows.map((ele) => { + const title = ele.title; + const clicknum = ` 点击数:${ele.click_counter},回复数:${ele.reply_counter}`; + const link = `http://bbs.tianya.cn/go_reply_position.jsp?item=${ele.item}&id=${ele.art_id}&rid=${ele.reply_id}`; + const date = ele.reply_time; + + const pubDate = new Date(date).toUTCString(); + return { + title, + description: title + clicknum, + link, + pubDate, + }; + }); + ctx.state.data = { + title: username + '的天涯回帖', + description: username, + link: url, + item: items, + }; +}; diff --git a/lib/routes/tianya/index.js b/lib/routes/tianya/index.js new file mode 100644 index 00000000000000..37dd33ac6f1658 --- /dev/null +++ b/lib/routes/tianya/index.js @@ -0,0 +1,34 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + +module.exports = async (ctx) => { + const { type } = ctx.params; + const url = 'http://bbs.tianya.cn/list-' + type + '-1.shtml'; + const response = await got(url, { headers: { Referer: 'http://bbs.tianya.cn' } }); + const $ = cheerio.load(response.data); + const typeTitle = $('div.location div.text strong').text(); + const items = $('table > tbody ~ tbody > tr') + .map((_, ele) => { + const $item = cheerio.load(ele); + const title = $item('td.td-title a').text(); + const link = $item('td.td-title a').attr('href'); + const date = $item('td') + .last() + .attr('title'); + + const pubDate = new Date(date).toUTCString(); + return { + title, + description: title, + link, + pubDate, + }; + }) + .get(); + ctx.state.data = { + title: typeTitle, + description: typeTitle, + link: url, + item: items, + }; +}; diff --git a/lib/routes/tianya/user.js b/lib/routes/tianya/user.js new file mode 100644 index 00000000000000..a27070ac03805d --- /dev/null +++ b/lib/routes/tianya/user.js @@ -0,0 +1,36 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + +module.exports = async (ctx) => { + const { userid } = ctx.params; + const url = 'http://www.tianya.cn/' + userid + '/bbs?t=post'; + const responseraw = await got(url, { headers: { Referer: 'http://bbs.tianya.cn' } }); + const $ = cheerio.load(responseraw.data); + const username = $('div.portrait h2 a') + .first() + .text(); + + const turl = `http://www.tianya.cn/api/bbsuser?method=userinfo.ice.getUserTotalArticleList&params.userId=${userid}&params.pageSize=20&params.bMore=true`; + const response = await got(turl, { headers: { Referer: 'http://bbs.tianya.cn' } }); + const json = response.data; + const items = json.data.rows.map((ele) => { + const title = ele.title; + const clicknum = ` 点击数:${ele.click_counter},回复数:${ele.reply_counter}`; + const link = `http://bbs.tianya.cn/post-${ele.item}-${ele.art_id}-1.shtml`; + const date = ele.compose_time; + + const pubDate = new Date(date).toUTCString(); + return { + title, + description: title + clicknum, + link, + pubDate, + }; + }); + ctx.state.data = { + title: username + '的天涯帖子', + description: username, + link: url, + item: items, + }; +};
f4749544b6a7e43276f125aabae4d4497ba10d9f
2024-03-18 12:20:20
github-actions[bot]
style: auto format
false
auto format
style
diff --git a/lib/routes/zrblog/rss.ts b/lib/routes/zrblog/rss.ts index a86ad6e440ab21..6eb16f7a0ab708 100644 --- a/lib/routes/zrblog/rss.ts +++ b/lib/routes/zrblog/rss.ts @@ -7,9 +7,11 @@ export const route: Route = { path: '/', categories: ['blog'], example: '/zrblog', - radar: [{ + radar: [ + { source: ['zrblog.net/'], - }], + }, + ], name: '最新文章', maintainers: ['cnkmmk'], handler,
548395b4b4f2887c01af64da67fef574ee5d3658
2022-06-02 19:03:24
Tony
fix(core): unnecessary redis io (#9875)
false
unnecessary redis io (#9875)
fix
diff --git a/lib/middleware/cache/redis.js b/lib/middleware/cache/redis.js index eb534abcab5416..1e9889d0f6f7f9 100644 --- a/lib/middleware/cache/redis.js +++ b/lib/middleware/cache/redis.js @@ -32,8 +32,10 @@ module.exports = { let [value, cacheTtl] = await redisClient.mget(key, cacheTtlKey); if (value && refresh) { if (!cacheTtl) { + // if cacheTtl is not set, that means the cache expire time is contentExpire cacheTtl = config.cache.contentExpire; - redisClient.set(cacheTtlKey, cacheTtl, 'EX', cacheTtl); + // dont save cacheTtl to Redis, as it is the default value + // redisClient.set(cacheTtlKey, cacheTtl, 'EX', cacheTtl); } else { redisClient.expire(cacheTtlKey, cacheTtl); } @@ -54,7 +56,10 @@ module.exports = { value = JSON.stringify(value); } if (key) { - redisClient.set(getCacheTtlKey(key), maxAge, 'EX', maxAge); + if (maxAge !== config.cache.contentExpire) { + // Only set cacheTtlKey if maxAge !== contentExpire + redisClient.set(getCacheTtlKey(key), maxAge, 'EX', maxAge); + } return redisClient.set(key, value, 'EX', maxAge); // setMode: https://redis.io/commands/set } },
f641a2ad7c8f5edc1cd4e6f3a96a8c507473a9d1
2023-09-01 20:08:42
Andvari
feat(route): refine category list for thepaper. (#13178)
false
refine category list for thepaper. (#13178)
feat
diff --git a/lib/v2/thepaper/utils.js b/lib/v2/thepaper/utils.js index 654ed586f36deb..b71b16bf58c4ca 100644 --- a/lib/v2/thepaper/utils.js +++ b/lib/v2/thepaper/utils.js @@ -52,7 +52,7 @@ module.exports = { title: contentDetail.name || contentDetail.shareName, link: itemUrl, description, - category: contentDetail.tagList?.map((t) => t.tag) ?? [], + category: (contentDetail.tagList?.map((t) => t.tag) ?? []).concat(contentDetail?.nodeInfo?.name ?? []), pubDate: parseDate(item.pubTimeLong || contentDetail.pubTime || contentDetail.publishTime), author: contentDetail.author || '', media: {
95c179862eda5838ae41cde286cd23686430305d
2023-11-19 00:20:48
Tony
fix(route): use api provided buvid3 and local b_nut (#13830)
false
use api provided buvid3 and local b_nut (#13830)
fix
diff --git a/lib/v2/bilibili/cache.js b/lib/v2/bilibili/cache.js index 7c08b8e65a0031..b4b4f08773fb2c 100644 --- a/lib/v2/bilibili/cache.js +++ b/lib/v2/bilibili/cache.js @@ -13,20 +13,23 @@ module.exports = { return ctx.cache.tryGet(key, async () => { // default Referer: https://www.bilibili.com is limited // Bilibili return cookies with multiple set-cookie - let response = await got('https://space.bilibili.com/1'); - const setCookie = response.headers['set-cookie']; // should contain buvid3 and b_nut - if (typeof setCookie === 'undefined') { - return ''; - } - const cookie = setCookie.map((cookie) => cookie.split(';')[0]); + // let response = await got('https://space.bilibili.com/1'); + // const setCookie = response.headers['set-cookie']; // should contain buvid3 and b_nut + // if (typeof setCookie === 'undefined') { + // return ''; + // } + // const cookie = setCookie.map((cookie) => cookie.split(';')[0]); + const cookie = []; cookie.push(['b_lsid', utils.lsid()].join('=')); cookie.push(['_uuid', utils._uuid()].join('=')); - response = await got('https://api.bilibili.com/x/frontend/finger/spi', { + cookie.push(['b_nut', Date.now().toString()].join('=')); + let response = await got('https://api.bilibili.com/x/frontend/finger/spi', { headers: { Referer: 'https://www.bilibili.com/', Cookie: cookie.join('; '), }, }); + cookie.push(['buvid3', encodeURIComponent(response.data.data.b_3)].join('=')); cookie.push(['bvuid4', encodeURIComponent(response.data.data.b_4)].join('=')); const e = Math.floor(Date.now() / 1000); const hexsign = utils.hexsign(e);
1574105a922f5074c234d13d4edc06a5336cf268
2024-01-19 09:00:45
DIYgod
fix: twitter changed the fields
false
twitter changed the fields
fix
diff --git a/lib/v2/twitter/utils.js b/lib/v2/twitter/utils.js index 4887e160e95ddd..15a3924e2ecbd3 100644 --- a/lib/v2/twitter/utils.js +++ b/lib/v2/twitter/utils.js @@ -124,7 +124,7 @@ const ProcessFeed = (ctx, { data = [] }, params = {}) => { case 'photo': default: - originalImg = getOriginalImg(item.media_url_https); + originalImg = getOriginalImg(media.media_url_https); if (!readable) { content += `<br>`; }
baec2b62433259038be18caa7b4874d3e889c7c8
2020-07-29 19:06:53
GitHub Action
style: auto format
false
auto format
style
diff --git a/docs/install/README.md b/docs/install/README.md index 932340bbd899fc..9e890a6195796b 100644 --- a/docs/install/README.md +++ b/docs/install/README.md @@ -187,13 +187,15 @@ $ git pull ## 部署到 Heroku ### 一键部署(无自动更新) + [![Deploy to Heroku](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy?template=https%3A%2F%2Fgithub.com%2FDIYgod%2FRSSHub) ### 自动更新部署 -1. 将 RSSHub [分叉(fork)](https://github.com/login?return_to=%2FDIYgod%2FRSSHub) 到自己的账户下。 -2. 把自己的分叉部署到 Heroku:`https://heroku.com/deploy?template=URL`,其中 `URL` 改为分叉地址(例如 `https://github.com/USERNAME/RSSHub`)。 -3. 检查 Heroku 设置,随代码库更新自动部署。 -4. 安装 [Pull](https://github.com/apps/pull) 应用,定期将 RSSHub 改动自动同步至你的分叉。 + +1. 将 RSSHub [分叉(fork)](https://github.com/login?return_to=%2FDIYgod%2FRSSHub) 到自己的账户下。 +2. 把自己的分叉部署到 Heroku:`https://heroku.com/deploy?template=URL`,其中 `URL` 改为分叉地址 (例如 `https://github.com/USERNAME/RSSHub`)。 +3. 检查 Heroku 设置,随代码库更新自动部署。 +4. 安装 [Pull](https://github.com/apps/pull) 应用,定期将 RSSHub 改动自动同步至你的分叉。 ## 部署到 Vercel (Zeit Now) diff --git a/lib/routes/liequtv/room.js b/lib/routes/liequtv/room.js index 8dd20466a2b896..7818db534c6470 100644 --- a/lib/routes/liequtv/room.js +++ b/lib/routes/liequtv/room.js @@ -6,7 +6,7 @@ module.exports = async (ctx) => { const id = ctx.params.id; const cache_key = `liequtv::latest_base_host::${new Date().toJSON().slice(0, 10)}`; - const url = `${await ctx.cache.get(cache_key) || original_host}/${id}`; + const url = `${(await ctx.cache.get(cache_key)) || original_host}/${id}`; const response = await got({ method: 'get',
cdd11700567c297c04561039798b942d8726fe27
2023-06-23 13:45:05
Akashi
feat(route): hinatazaka46 blog support id params (#12700)
false
hinatazaka46 blog support id params (#12700)
feat
diff --git a/docs/en/new-media.md b/docs/en/new-media.md index 66f270b1409f1c..3354f141421593 100644 --- a/docs/en/new-media.md +++ b/docs/en/new-media.md @@ -692,30 +692,42 @@ Compared to the official one, this feed: <RouteEn author="victor21813 nczitzk akashigakki" example="/sakurazaka46/blog" path="/sakurazaka46/blog/:id?/:page?" :paramsDesc="['Member ID, see below, `all` by default', 'Page, `0` by default']"> -| Member ID | Name | -| --------- | ----------- | -| 03 | 上村 莉菜 | -| 04 | 尾関 梨香 | -| 06 | 小池 美波 | -| 07 | 小林 由依 | -| 08 | 齋藤 冬優花 | -| 11 | 菅井 友香 | -| 14 | 土生 瑞穂 | -| 15 | 原田 葵 | -| 43 | 井上 梨名 | -| 53 | 遠藤 光莉 | -| 54 | 大園 玲 | -| 55 | 大沼 晶保 | -| 56 | 幸阪 茉里乃 | -| 44 | 関 有美子 | -| 45 | 武元 唯衣 | -| 46 | 田村 保乃 | -| 47 | 藤吉 夏鈴 | -| 57 | 増本 綺良 | -| 48 | 松田 里奈 | -| 50 | 森田 ひかる | -| 58 | 守屋 麗奈 | -| 51 | 山﨑 天 | +| Member ID | Name | +| --------- | ------------ | +| 2000 | 三期生リレー | +| 69 | 山下 瞳月 | +| 68 | 村山 美羽 | +| 67 | 村井 優 | +| 66 | 向井 純葉 | +| 65 | 的野 美青 | +| 64 | 中嶋 優月 | +| 63 | 谷口 愛季 | +| 62 | 小島 凪紗 | +| 61 | 小田倉 麗奈 | +| 60 | 遠藤 理子 | +| 59 | 石森 璃花 | +| 58 | 守屋 麗奈 | +| 57 | 増本 綺良 | +| 56 | 幸阪 茉里乃 | +| 55 | 大沼 晶保 | +| 54 | 大園 玲 | +| 53 | 遠藤 光莉 | +| 51 | 山﨑 天 | +| 50 | 森田 ひかる | +| 48 | 松田 里奈 | +| 47 | 藤吉 夏鈴 | +| 46 | 田村 保乃 | +| 45 | 武元 唯衣 | +| 44 | 関 有美子 | +| 43 | 井上 梨名 | +| 15 | 原田 葵 | +| 14 | 土生 瑞穂 | +| 11 | 菅井 友香 | +| 08 | 齋藤 冬優花 | +| 07 | 小林 由依 | +| 06 | 小池 美波 | +| 04 | 尾関 梨香 | +| 03 | 上村 莉菜 | </RouteEn> @@ -725,7 +737,45 @@ Compared to the official one, this feed: ### Hinatazaka46 Blog -<RouteEn author="nwindz" example="/hinatazaka46/blog" path="/hinatazaka46/blog" /> +<RouteEn author="nwindz" example="/hinatazaka46/blog" path="/hinatazaka46/blog/:id?" :paramsDesc="['Member ID, see below, `all` by default']"> + +| Member ID | Name | +| --------- | ------------ | +| 2000 | 四期生リレー | +| 36 | 渡辺 莉奈 | +| 35 | 山下 葉留花 | +| 34 | 宮地 すみれ | +| 33 | 藤嶌 果歩 | +| 32 | 平岡 海月 | +| 31 | 平尾 帆夏 | +| 30 | 竹内 希来里 | +| 29 | 正源司 陽子 | +| 28 | 清水 理央 | +| 27 | 小西 夏菜実 | +| 26 | 岸 帆夏 | +| 25 | 石塚 瑶季 | +| 24 | 山口 陽世 | +| 23 | 森本 茉莉 | +| 22 | 髙橋 未来虹 | +| 21 | 上村 ひなの | +| 18 | 松田 好花 | +| 17 | 濱岸 ひより | +| 16 | 丹生 明里 | +| 15 | 富田 鈴花 | +| 14 | 小坂 菜緒 | +| 13 | 河田 陽菜 | +| 12 | 金村 美玖 | +| 11 | 東村 芽依 | +| 10 | 高本 彩花 | +| 9 | 高瀬 愛奈 | +| 8 | 佐々木 美玲 | +| 7 | 佐々木 久美 | +| 6 | 齊藤 京子 | +| 5 | 加藤 史帆 | +| 4 | 影山 優佳 | +| 2 | 潮 紗理菜 | + +</RouteEn> ## Samsung diff --git a/docs/new-media.md b/docs/new-media.md index 3549195d40d8f3..b3150c1dff8695 100644 --- a/docs/new-media.md +++ b/docs/new-media.md @@ -1794,30 +1794,44 @@ Supported sub-sites: <Route author="victor21813 nczitzk akashigakki" example="/sakurazaka46/blog" path="/sakurazaka46/blog/:id?/:page?" :paramsDesc="['成员编号,见下表,默认为`all` (全部)', '订阅页码,默认为`0` (第一页)']"> -| 编号 | 姓名 | -| ---- | ----------- | -| 03 | 上村 莉菜 | -| 04 | 尾関 梨香 | -| 06 | 小池 美波 | -| 07 | 小林 由依 | -| 08 | 齋藤 冬優花 | -| 11 | 菅井 友香 | -| 14 | 土生 瑞穂 | -| 15 | 原田 葵 | -| 43 | 井上 梨名 | -| 53 | 遠藤 光莉 | -| 54 | 大園 玲 | -| 55 | 大沼 晶保 | -| 56 | 幸阪 茉里乃 | -| 44 | 関 有美子 | -| 45 | 武元 唯衣 | -| 46 | 田村 保乃 | -| 47 | 藤吉 夏鈴 | -| 57 | 増本 綺良 | -| 48 | 松田 里奈 | -| 50 | 森田 ひかる | -| 58 | 守屋 麗奈 | -| 51 | 山﨑 天 | +| 编号 | 姓名 | +| ---- | ------------ | +| 2000 | 三期生リレー | +| 69 | 山下 瞳月 | +| 68 | 村山 美羽 | +| 67 | 村井 優 | +| 66 | 向井 純葉 | +| 65 | 的野 美青 | +| 64 | 中嶋 優月 | +| 63 | 谷口 愛季 | +| 62 | 小島 凪紗 | +| 61 | 小田倉 麗奈 | +| 60 | 遠藤 理子 | +| 59 | 石森 璃花 | +| 58 | 守屋 麗奈 | +| 57 | 増本 綺良 | +| 56 | 幸阪 茉里乃 | +| 55 | 大沼 晶保 | +| 54 | 大園 玲 | +| 53 | 遠藤 光莉 | +| 51 | 山﨑 天 | +| 50 | 森田 ひかる | +| 48 | 松田 里奈 | +| 47 | 藤吉 夏鈴 | +| 46 | 田村 保乃 | +| 45 | 武元 唯衣 | +| 44 | 関 有美子 | +| 43 | 井上 梨名 | +| 15 | 原田 葵 | +| 14 | 土生 瑞穂 | +| 11 | 菅井 友香 | +| 08 | 齋藤 冬優花 | +| 07 | 小林 由依 | +| 06 | 小池 美波 | +| 04 | 尾関 梨香 | +| 03 | 上村 莉菜 | + +> 注:三期生个人博客暂未开通,统一博客编号为 `2000`。 </Route> @@ -1827,7 +1841,47 @@ Supported sub-sites: ### 日向坂 46 博客 -<Route author="nwindz" example="/hinatazaka46/blog" path="/hinatazaka46/blog" /> +<Route author="nwindz" example="/hinatazaka46/blog" path="/hinatazaka46/blog/:id?" :paramsDesc="['成员编号,见下表,默认为`all` (全部)']"> + +| 编号 | 姓名 | +| ---- | ------------ | +| 2000 | 四期生リレー | +| 36 | 渡辺 莉奈 | +| 35 | 山下 葉留花 | +| 34 | 宮地 すみれ | +| 33 | 藤嶌 果歩 | +| 32 | 平岡 海月 | +| 31 | 平尾 帆夏 | +| 30 | 竹内 希来里 | +| 29 | 正源司 陽子 | +| 28 | 清水 理央 | +| 27 | 小西 夏菜実 | +| 26 | 岸 帆夏 | +| 25 | 石塚 瑶季 | +| 24 | 山口 陽世 | +| 23 | 森本 茉莉 | +| 22 | 髙橋 未来虹 | +| 21 | 上村 ひなの | +| 18 | 松田 好花 | +| 17 | 濱岸 ひより | +| 16 | 丹生 明里 | +| 15 | 富田 鈴花 | +| 14 | 小坂 菜緒 | +| 13 | 河田 陽菜 | +| 12 | 金村 美玖 | +| 11 | 東村 芽依 | +| 10 | 高本 彩花 | +| 9 | 高瀬 愛奈 | +| 8 | 佐々木 美玲 | +| 7 | 佐々木 久美 | +| 6 | 齊藤 京子 | +| 5 | 加藤 史帆 | +| 4 | 影山 優佳 | +| 2 | 潮 紗理菜 | + +> 注:四期生个人博客暂未开通,统一博客编号为 `2000`。 + +</Route> ## 半月谈 diff --git a/lib/v2/hinatazaka46/blog.js b/lib/v2/hinatazaka46/blog.js index f58fa17bbd2d93..8bdc33cb782409 100644 --- a/lib/v2/hinatazaka46/blog.js +++ b/lib/v2/hinatazaka46/blog.js @@ -5,7 +5,9 @@ const { parseDate } = require('@/utils/parse-date'); const rootUrl = 'https://www.hinatazaka46.com'; module.exports = async (ctx) => { - const currentUrl = `${rootUrl}/s/official/diary/member/list`; + const id = ctx.params.id ?? 'all'; + const params = id === 'all' ? '' : `?ct=${id}`; + const currentUrl = `${rootUrl}/s/official/diary/member/list${params}`; const response = await got({ method: 'get', diff --git a/lib/v2/hinatazaka46/maintainer.js b/lib/v2/hinatazaka46/maintainer.js index e3cc82fe294d64..c03b71295b9bf4 100644 --- a/lib/v2/hinatazaka46/maintainer.js +++ b/lib/v2/hinatazaka46/maintainer.js @@ -1,4 +1,4 @@ module.exports = { '/news': ['crispgm', 'akashigakki'], - '/blog': ['nwindz', 'akashigakki'], + '/blog/:id?': ['nwindz', 'akashigakki'], }; diff --git a/lib/v2/hinatazaka46/news.js b/lib/v2/hinatazaka46/news.js index 7566111ab3727e..cb192962a44cbc 100644 --- a/lib/v2/hinatazaka46/news.js +++ b/lib/v2/hinatazaka46/news.js @@ -1,34 +1,51 @@ const got = require('@/utils/got'); const cheerio = require('cheerio'); +const { parseDate } = require('@/utils/parse-date'); module.exports = async (ctx) => { + const rootUrl = 'https://www.hinatazaka46.com'; + const currentUrl = `${rootUrl}/s/official/news/list`; + const response = await got({ method: 'get', - url: 'https://www.hinatazaka46.com/s/official/news/list', - headers: { - Referer: 'http://www.hinatazaka46.com/', - }, + url: currentUrl, }); - const data = response.data; - const $ = cheerio.load(data); - const list = $('main div.l-maincontents--news ul.p-news__list li'); + const $ = cheerio.load(response.data); + + let items = $('.p-news__list .p-news__item a') + .slice(0, ctx.query.limit ? parseInt(ctx.query.limit) : 30) + .toArray() + .map((item) => { + item = $(item); + + return { + title: item.find('.c-news__text').text(), + link: `${rootUrl}${item.attr('href').split('?')[0]}`, + pubDate: parseDate(item.find('.c-news__date').text()), + }; + }); + + items = await Promise.all( + items.map((item) => + ctx.cache.tryGet(item.link, async () => { + const detailResponse = await got({ + method: 'get', + url: item.link, + }); + + const content = cheerio.load(detailResponse.data); + + item.description = content('.p-article__text').html(); + + return item; + }) + ) + ); ctx.state.data = { - allowEmpty: true, - title: '日向坂46官网 NEWS', - link: 'http://www.hinatazaka46.com/news/', - item: - list && - list - .map((index, item) => { - item = $(item); - return { - title: item.find('a p.c-news__text').first().text(), - link: item.find('a').attr('href'), - pubDate: item.find('a time.c-news__date').first().text(), - }; - }) - .get(), + title: $('title').text(), + link: currentUrl, + item: items, }; }; diff --git a/lib/v2/hinatazaka46/router.js b/lib/v2/hinatazaka46/router.js index d0c2b646347e95..fbf52b5563718a 100644 --- a/lib/v2/hinatazaka46/router.js +++ b/lib/v2/hinatazaka46/router.js @@ -1,4 +1,4 @@ module.exports = function (router) { router.get('/news', require('./news')); - router.get('/blog', require('./blog')); + router.get('/blog/:id?', require('./blog')); };
53fc54bb810ee4aba2c1276e50d2eff366a6ca3b
2024-08-29 17:41:45
dependabot[bot]
chore(deps): bump @opentelemetry/resources from 1.25.1 to 1.26.0 (#16573)
false
bump @opentelemetry/resources from 1.25.1 to 1.26.0 (#16573)
chore
diff --git a/package.json b/package.json index c662a86ed914d4..5affd59a5f5e65 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,7 @@ "@opentelemetry/api": "1.9.0", "@opentelemetry/exporter-prometheus": "0.52.1", "@opentelemetry/exporter-trace-otlp-http": "0.52.1", - "@opentelemetry/resources": "1.25.1", + "@opentelemetry/resources": "1.26.0", "@opentelemetry/sdk-metrics": "1.25.1", "@opentelemetry/sdk-trace-base": "1.25.1", "@opentelemetry/semantic-conventions": "1.26.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 00a0c7398e9184..98063b8ca847f7 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -27,8 +27,8 @@ importers: specifier: 0.52.1 version: 0.52.1(@opentelemetry/[email protected]) '@opentelemetry/resources': - specifier: 1.25.1 - version: 1.25.1(@opentelemetry/[email protected]) + specifier: 1.26.0 + version: 1.26.0(@opentelemetry/[email protected]) '@opentelemetry/sdk-metrics': specifier: 1.25.1 version: 1.25.1(@opentelemetry/[email protected]) @@ -1527,6 +1527,12 @@ packages: peerDependencies: '@opentelemetry/api': '>=1.0.0 <1.10.0' + '@opentelemetry/[email protected]': + resolution: {integrity: sha512-1iKxXXE8415Cdv0yjG3G6hQnB5eVEsJce3QaawX8SjDn0mAS0ZM8fAbZZJD4ajvhC15cePvosSCut404KrIIvQ==} + engines: {node: '>=14'} + peerDependencies: + '@opentelemetry/api': '>=1.0.0 <1.10.0' + '@opentelemetry/[email protected]': resolution: {integrity: sha512-hwK0QnjtqAxGpQAXMNUY+kTT5CnHyz1I0lBA8SFySvaFtExZm7yQg/Ua/i+RBqgun7WkUbkUVJzEi3lKpJ7WdA==} engines: {node: '>=14'} @@ -1557,6 +1563,12 @@ packages: peerDependencies: '@opentelemetry/api': '>=1.0.0 <1.10.0' + '@opentelemetry/[email protected]': + resolution: {integrity: sha512-CPNYchBE7MBecCSVy0HKpUISEeJOniWqcHaAHpmasZ3j9o6V3AyBzhRc90jdmemq0HOxDr6ylhUbDhBqqPpeNw==} + engines: {node: '>=14'} + peerDependencies: + '@opentelemetry/api': '>=1.0.0 <1.10.0' + '@opentelemetry/[email protected]': resolution: {integrity: sha512-MBYh+WcPPsN8YpRHRmK1Hsca9pVlyyKd4BxOC4SsgHACnl/bPp4Cri9hWhVm5+2tiQ9Zf4qSc1Jshw9tOLGWQA==} engines: {node: '>=14'} @@ -1583,6 +1595,10 @@ packages: resolution: {integrity: sha512-U9PJlOswJPSgQVPI+XEuNLElyFWkb0hAiMg+DExD9V0St03X2lPHGMdxMY/LrVmoukuIpXJ12oyrOtEZ4uXFkw==} engines: {node: '>=14'} + '@opentelemetry/[email protected]': + resolution: {integrity: sha512-sAay1RrB+ONOem0OZanAR1ZI/k7yDpnOQSQmTMuGImUQb2y8EbSaCJ94FQluM74xoU03vlb2d2U90hZluL6nQg==} + engines: {node: '>=14'} + '@otplib/[email protected]': resolution: {integrity: sha512-4sGntwbA/AC+SbPhbsziRiD+jNDdIzsZ3JUyfZwjtKyc/wufl1pnSIaG4Uqx8ymPagujub0o92kgBnB89cuAMA==} @@ -2269,11 +2285,11 @@ packages: [email protected]: resolution: {integrity: sha512-qMKFd2qG/36aA4GwvKq8MxnPgCQAmBWmSyLWsJcbn8v03wvIPQ/hG1Ms8bPzndZxMDoHpxez5VOS+gC9Yi24/Q==} - [email protected]: - resolution: {integrity: sha512-W/Hfxc/6VehXlsgFtbB5B4xFcsCl+pAh30cYhoFyXErf6oGrwjh8SwiPAdHgpmWonKuYpZgGywN0SXt7dgsADA==} + [email protected]: + resolution: {integrity: sha512-Kcq/FG3lhspzGHK+Q0IMfImuFOmaW/jFofBAUJuuG7H67879JeaPUppUHhgLjJKenfxiO6Ix2AGSd47Pf7mRxg==} - [email protected]: - resolution: {integrity: sha512-v8DTT08AS/G0F9xrhyLtepoo9EJBJ85FRSMbu1pQUlAf6A8T0tEEQGMVObWeqpjhSPXsE0VGlluFBJu2fdoTNg==} + [email protected]: + resolution: {integrity: sha512-yQC/blMP/eUdULsF7hrcC9tUFXlUmAWRbSQndEln77nOIh/N4Loaqch/MA4hyoDKhw1Zd1Wj+uLV/bT6lC/4BQ==} [email protected]: resolution: {integrity: sha512-lh/eITfU8hrj9Ru5quUp0Io1kJWIk1bTjzo7JH1P5dWmQ2EL4hFUlfI8FonAhSlgIfhn63p84CDY/x+PisgcXA==} @@ -4351,8 +4367,8 @@ packages: encoding: optional: true - [email protected]: - resolution: {integrity: sha512-OSs33Z9yWr148JZcbZd5WiAXhh/n9z8TxQcdMhIOlpN9AhWpLfvVFO73+m77bBABQMaY9XSvIa+qk0jlI7Gcaw==} + [email protected]: + resolution: {integrity: sha512-IRUxE4BVsHWXkV/SFOut4qTlagw2aM8T5/vnTsmrHJvVoKueJHRc/JaFND7QDDc61kLYUJ6qlZM3sqTSyx2dTw==} hasBin: true [email protected]: @@ -5488,8 +5504,8 @@ packages: resolution: {integrity: sha512-yGSza74xk0UG8k+pLh5oeoYirvIiWo5t0/o3zHHAO2tRDiZcxWP7fywNlXhqb6/r6sWvwi+RsyQMWhVLe4BVuA==} engines: {node: '>=10'} - [email protected]: - resolution: {integrity: sha512-bRkIGlXsnGBRBQRAY56UXBm//9qH4bmJfFvq83gSz41N282df+fjy8ofcEgc1sM8geNt5cl6mC2g9Fht1cs8Aw==} + [email protected]: + resolution: {integrity: sha512-OduNjVJsFbifKb57UqZ2EMP1i4u64Xwow3NYXUtBbD4vIwJdQd4+xl8YDou1dlm4DVrtwT/7Ky8z8WyCULVfxw==} engines: {node: '>=16'} [email protected]: @@ -7090,6 +7106,11 @@ snapshots: '@opentelemetry/api': 1.9.0 '@opentelemetry/semantic-conventions': 1.25.1 + '@opentelemetry/[email protected](@opentelemetry/[email protected])': + dependencies: + '@opentelemetry/api': 1.9.0 + '@opentelemetry/semantic-conventions': 1.27.0 + '@opentelemetry/[email protected](@opentelemetry/[email protected])': dependencies: '@opentelemetry/api': 1.9.0 @@ -7129,6 +7150,12 @@ snapshots: '@opentelemetry/core': 1.25.1(@opentelemetry/[email protected]) '@opentelemetry/semantic-conventions': 1.25.1 + '@opentelemetry/[email protected](@opentelemetry/[email protected])': + dependencies: + '@opentelemetry/api': 1.9.0 + '@opentelemetry/core': 1.26.0(@opentelemetry/[email protected]) + '@opentelemetry/semantic-conventions': 1.27.0 + '@opentelemetry/[email protected](@opentelemetry/[email protected])': dependencies: '@opentelemetry/api': 1.9.0 @@ -7154,6 +7181,8 @@ snapshots: '@opentelemetry/[email protected]': {} + '@opentelemetry/[email protected]': {} + '@otplib/[email protected]': {} '@otplib/[email protected]': @@ -7318,7 +7347,7 @@ snapshots: dependencies: openapi-fetch: 0.11.1 ts-case-convert: 2.0.7 - type-fest: 4.25.0 + type-fest: 4.26.0 '@rss3/[email protected]': dependencies: @@ -7692,7 +7721,7 @@ snapshots: glob: 7.2.3 graceful-fs: 4.2.11 micromatch: 4.0.8 - node-gyp-build: 4.8.1 + node-gyp-build: 4.8.2 resolve-from: 5.0.0 transitivePeerDependencies: - encoding @@ -7907,19 +7936,19 @@ snapshots: [email protected]: optional: true - [email protected]: + [email protected]: dependencies: bare-events: 2.4.2 bare-path: 2.1.3 bare-stream: 2.2.0 optional: true - [email protected]: + [email protected]: optional: true [email protected]: dependencies: - bare-os: 2.4.0 + bare-os: 2.4.1 optional: true [email protected]: @@ -7997,7 +8026,7 @@ snapshots: [email protected]: dependencies: - node-gyp-build: 4.8.1 + node-gyp-build: 4.8.2 [email protected]: {} @@ -9295,7 +9324,7 @@ snapshots: lowercase-keys: 3.0.0 p-cancelable: 4.0.1 responselike: 3.0.0 - type-fest: 4.25.0 + type-fest: 4.26.0 [email protected]: {} @@ -10289,7 +10318,7 @@ snapshots: outvariant: 1.4.3 path-to-regexp: 6.2.2 strict-event-emitter: 0.5.1 - type-fest: 4.25.0 + type-fest: 4.26.0 yargs: 17.7.2 optionalDependencies: typescript: 5.5.4 @@ -10316,7 +10345,7 @@ snapshots: dependencies: whatwg-url: 5.0.0 - [email protected]: {} + [email protected]: {} [email protected]: dependencies: @@ -11317,7 +11346,7 @@ snapshots: pump: 3.0.0 tar-stream: 3.1.7 optionalDependencies: - bare-fs: 2.3.1 + bare-fs: 2.3.2 bare-path: 2.1.3 [email protected]: @@ -11509,7 +11538,7 @@ snapshots: [email protected]: {} - [email protected]: {} + [email protected]: {} [email protected]: {} @@ -11594,7 +11623,7 @@ snapshots: [email protected]: dependencies: - node-gyp-build: 4.8.1 + node-gyp-build: 4.8.2 [email protected]: {}
615a2a9c3ba8949615cef6c6c6af9d3b84c443f0
2024-04-06 03:53:42
dependabot[bot]
chore(deps): bump hono from 4.2.1 to 4.2.2 (#15125)
false
bump hono from 4.2.1 to 4.2.2 (#15125)
chore
diff --git a/package.json b/package.json index d197679c5de7dd..f8ba9f716889d8 100644 --- a/package.json +++ b/package.json @@ -75,7 +75,7 @@ "fanfou-sdk": "5.0.0", "form-data": "4.0.0", "googleapis": "134.0.0", - "hono": "4.2.1", + "hono": "4.2.2", "html-to-text": "9.0.5", "https-proxy-agent": "7.0.4", "iconv-lite": "0.6.3", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index f69ee5a34545a8..11d83760632bec 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -10,10 +10,10 @@ dependencies: version: 1.9.1 '@hono/swagger-ui': specifier: 0.2.1 - version: 0.2.1([email protected]) + version: 0.2.1([email protected]) '@hono/zod-openapi': specifier: 0.9.10 - version: 0.9.10([email protected])([email protected]) + version: 0.9.10([email protected])([email protected]) '@notionhq/client': specifier: 2.2.14 version: 2.2.14 @@ -81,8 +81,8 @@ dependencies: specifier: 134.0.0 version: 134.0.0 hono: - specifier: 4.2.1 - version: 4.2.1 + specifier: 4.2.2 + version: 4.2.2 html-to-text: specifier: 9.0.5 version: 9.0.5 @@ -1966,15 +1966,15 @@ packages: engines: {node: '>=18.14.1'} dev: false - /@hono/[email protected]([email protected]): + /@hono/[email protected]([email protected]): resolution: {integrity: sha512-wBxVMRe3/v8xH4o6icmwztiIq0DG0s7+jHVMHVUAoFFCWEQNL2iskMmQtrhSDtsFmBZUeUFQUaaJ6Ir6DOmHLA==} peerDependencies: hono: '*' dependencies: - hono: 4.2.1 + hono: 4.2.2 dev: false - /@hono/[email protected]([email protected])([email protected]): + /@hono/[email protected]([email protected])([email protected]): resolution: {integrity: sha512-v/b/z0qPxDo952gjRyhJ0n9ifbPoIluR2KmXDL20np0hj99+XvakoIHK5/T/3+hUmXlTj1Kn3TiGsSV6hwZesg==} engines: {node: '>=16.0.0'} peerDependencies: @@ -1982,18 +1982,18 @@ packages: zod: 3.* dependencies: '@asteasolutions/zod-to-openapi': 5.5.0([email protected]) - '@hono/zod-validator': 0.2.1([email protected])([email protected]) - hono: 4.2.1 + '@hono/zod-validator': 0.2.1([email protected])([email protected]) + hono: 4.2.2 zod: 3.22.4 dev: false - /@hono/[email protected]([email protected])([email protected]): + /@hono/[email protected]([email protected])([email protected]): resolution: {integrity: sha512-HFoxln7Q6JsE64qz2WBS28SD33UB2alp3aRKmcWnNLDzEL1BLsWfbdX6e1HIiUprHYTIXf5y7ax8eYidKUwyaA==} peerDependencies: hono: '>=3.9.0' zod: ^3.19.1 dependencies: - hono: 4.2.1 + hono: 4.2.2 zod: 3.22.4 dev: false @@ -5633,8 +5633,8 @@ packages: resolution: {integrity: sha512-4FP6J0oI8jqb6gLLl9tSwVdosWJ/AKSGJ+HwYf6Ixe4MUcEkst4uWzpVQrNOCin0fzTRQbXV8ePheU8WiiDYBw==} dev: false - /[email protected]: - resolution: {integrity: sha512-yDv/6esHiDgq5fvsALTNyNiRxktOplO6LfSMgIkGE+E5vF8axsUfcyfzzlbLYM9ZQDMuws/ZLGUGWwYnAwCcNw==} + /[email protected]: + resolution: {integrity: sha512-mDmjBHF6uBNN3TASdAbDCFsN9FLbrlgXyFZkhLEkU7hUgk0+T9hcsUrL/nho4qV+Xk0RDHx7gop4Q1gelZZVRw==} engines: {node: '>=16.0.0'} dev: false
19603a0f3df5600ed51e3a61a1852b418fef6e13
2022-02-09 19:55:23
uyoung
fix(route): 163music djradio missing data (#8822)
false
163music djradio missing data (#8822)
fix
diff --git a/lib/routes/ncm/djradio.js b/lib/routes/ncm/djradio.js index 74acd4c76cf9b3..898437bf1df3e6 100644 --- a/lib/routes/ncm/djradio.js +++ b/lib/routes/ncm/djradio.js @@ -1,24 +1,69 @@ const got = require('@/utils/got'); +const { parseDate } = require('@/utils/parse-date'); +const { art } = require('@/utils/render'); +const path = require('path'); module.exports = async (ctx) => { const id = ctx.params.id; - const response = await got({ - method: 'post', - url: 'http://music.163.com/api/dj/program/byradio', - headers: { - Referer: 'https://music.163.com/', - }, - form: { - radioId: id, - limit: 1000, - offset: 0, - }, - }); + const ProcessFeed = async (limit, offset) => + await got({ + method: 'post', + url: 'https://music.163.com/api/dj/program/byradio', + headers: { + Referer: 'https://music.163.com/', + }, + form: { + radioId: id, + limit, + offset, + }, + }); - const programs = response.data.programs || []; + const response = await ProcessFeed(1, 0); + const programs = response.data.programs || []; const { radio, dj } = programs[0] || { radio: {}, dj: {} }; + const count = response.data.count || 0; + + const countPage = []; + for (let i = 0; i < Math.ceil(count / 500); i++) { + countPage.push(i); + } + + const items = await Promise.all( + countPage.map(async (item) => { + const response = await ProcessFeed(500, item * 500); + const programs = response.data.programs || []; + const list = programs.map((pg) => { + const description = (pg.description || '').split('\n').map((p) => p); + const duration = ~~(pg.duration / 1000); + const itunes_duration = `${(duration / 60).toFixed(0).padStart(2, '0')}:${(duration % 60).toFixed(0).padStart(2, '0')}`; + + const html = art(path.join(__dirname, 'templates/djradio-content.art'), { + pg, + description, + itunes_duration, + }); + + return { + title: pg.name, + link: 'https://music.163.com/program/' + pg.id, + pubDate: parseDate(pg.createTime), + published: parseDate(pg.createTime), + author: pg.dj.nickname, + description: html, + content: { html }, + itunes_item_image: pg.coverUrl, + enclosure_url: `https://music.163.com/song/media/outer/url?id=${pg.mainTrackId}.mp3`, + enclosure_length: duration, + enclosure_type: 'audio/mpeg', + itunes_duration, + }; + }); + return list; + }) + ); ctx.state.data = { title: radio.name, @@ -31,36 +76,6 @@ module.exports = async (ctx) => { image: radio.picUrl, itunes_author: dj.nickname, itunes_category: radio.category, - item: programs.map((pg) => { - const image = `<img src=${pg.coverUrl} />`; - - const description = `<div>${(pg.description || '') - .split('\n') - .map((p) => `<p>${p}</p>`) - .join('')}</div>`; - - const src = `https://music.163.com/program/${pg.id}`; - - const duration = ~~(pg.duration / 1000); - const itunes_duration = `${(duration / 60).toFixed(0).padStart(2, '0')}:${(duration % 60).toFixed(0).padStart(2, '0')}`; - - const html = - image + description + `<div><audio src="http://music.163.com/song/media/outer/url?id=${pg.mainTrackId}.mp3" controls="controls"></audio><p>时长: ${itunes_duration}</p><p><a href="${src}">查看节目</a></p></div>`; - - return { - title: pg.name, - link: src, - pubDate: new Date(pg.createTime).toUTCString(), - published: new Date(pg.createTime).toISOString(), - author: pg.dj.nickname, - description: html, - content: { html }, - itunes_item_image: pg.coverUrl, - enclosure_url: `http://music.163.com/song/media/outer/url?id=${pg.mainTrackId}.mp3`, - enclosure_length: duration, - enclosure_type: 'audio/mpeg', - itunes_duration, - }; - }), + item: items.flat(), }; }; diff --git a/lib/routes/ncm/templates/djradio-content.art b/lib/routes/ncm/templates/djradio-content.art new file mode 100644 index 00000000000000..1db4ef731c2590 --- /dev/null +++ b/lib/routes/ncm/templates/djradio-content.art @@ -0,0 +1,11 @@ +<img src={{pg.coverUrl}} /> +<div> + {{each description}} + <p>{{$value}}</p> + {{/each}} +</div> +<div> + <audio src="https://music.163.com/song/media/outer/url?id={{pg.mainTrackId}}.mp3" controls="controls"></audio> + <p>时长: {{itunes_duration}}</p> + <p><a href="https://music.163.com/program/{{pg.id}}">查看节目</a></p> +</div>
810aae3997d9d130a786ee77b218479746bba5e2
2024-09-13 19:43:09
Luke Zhu
fix: 微博超话数据解析错误 (#16709)
false
微博超话数据解析错误 (#16709)
fix
diff --git a/lib/routes/weibo/super-index.ts b/lib/routes/weibo/super-index.ts index f4da6960f39cd7..c414d9ce5c4940 100644 --- a/lib/routes/weibo/super-index.ts +++ b/lib/routes/weibo/super-index.ts @@ -37,11 +37,15 @@ export const route: Route = { | feed | 最新评论 |`, }; +interface Card { + card_group?: Card[]; +} + async function handler(ctx) { const id = ctx.req.param('id'); const type = ctx.req.param('type') ?? 'feed'; - const containerData = await cache.tryGet( + const containerData = (await cache.tryGet( `weibo:super_index:container:${id}:${type}`, async () => { const _r = await got('https://m.weibo.cn/api/container/getIndex', { @@ -61,27 +65,35 @@ async function handler(ctx) { }, config.cache.routeExpire, false - ); + )) as { + cards?: Card[]; + pageInfo?: { + page_title: string; + }; + }; const resultItems = []; - for (const card of containerData.cards) { + function handleCard(ctx, card, resultItems) { + if (card.card_type === '9' && 'mblog' in card) { + const formatExtended = weiboUtils.formatExtended(ctx, card.mblog, undefined); + resultItems.push(formatExtended); + } + } + for (const card of containerData?.cards ?? []) { + handleCard(ctx, card, resultItems); if (!('card_group' in card)) { continue; } - for (const mblogCard of card.card_group) { - if (mblogCard.card_type === '9' && 'mblog' in mblogCard) { - const mblog = mblogCard.mblog; - const formatExtended = weiboUtils.formatExtended(ctx, mblog); - resultItems.push(formatExtended); - } + for (const mblogCard of card.card_group!) { + handleCard(ctx, mblogCard, resultItems); } } return weiboUtils.sinaimgTvax({ - title: `微博超话 - ${containerData.pageInfo.page_title}`, + title: `微博超话 - ${containerData?.pageInfo?.page_title}`, link: `https://weibo.com/p/${id}/super_index`, - description: `#${containerData.pageInfo.page_title}# 的超话`, + description: `#${containerData?.pageInfo?.page_title}# 的超话`, item: resultItems, }); }
4014732fa7dce541a66497ad3ec13665f6c370f4
2025-02-10 20:23:46
cnk
feat(routes/weibo): add showBloggerIcons option (#18302)
false
add showBloggerIcons option (#18302)
feat
diff --git a/lib/routes/weibo/friends.ts b/lib/routes/weibo/friends.ts index 16b72ba2a76602..119615649f63d4 100644 --- a/lib/routes/weibo/friends.ts +++ b/lib/routes/weibo/friends.ts @@ -141,7 +141,7 @@ async function handler(ctx) { } if (displayComments === '1') { - description = await weiboUtils.formatComments(ctx, description, item); + description = await weiboUtils.formatComments(ctx, description, item, '0'); } if (displayArticle === '1') { diff --git a/lib/routes/weibo/group.ts b/lib/routes/weibo/group.ts index 6cca099d7732d5..cfbd988fb1df35 100644 --- a/lib/routes/weibo/group.ts +++ b/lib/routes/weibo/group.ts @@ -96,7 +96,7 @@ async function handler(ctx) { } if (displayComments === '1') { - description = await weiboUtils.formatComments(ctx, description, item); + description = await weiboUtils.formatComments(ctx, description, item, '0'); } if (displayArticle === '1') { diff --git a/lib/routes/weibo/namespace.ts b/lib/routes/weibo/namespace.ts index e3ff1610dec369..f1d07f3870f654 100644 --- a/lib/routes/weibo/namespace.ts +++ b/lib/routes/weibo/namespace.ts @@ -31,6 +31,7 @@ export const namespace: Namespace = { | showLinkIconInDescription | 是否展示正文中的链接图标 | 0/1/true/false | true | | preferMobileLink | 是否使用移动版链接(默认使用 PC 版) | 0/1/true/false | false | | showRetweeted | 是否显示转发的微博 | 0/1/true/false | true | +| showBloggerIcons | 是否显示评论中博主的标志,只在显示热门评论时有效 | 0/1/true/false | false | 指定更多与默认值不同的参数选项可以改善 RSS 的可读性,如 diff --git a/lib/routes/weibo/timeline.ts b/lib/routes/weibo/timeline.ts index 5a3cc1a2438a2a..5303bc23afd233 100644 --- a/lib/routes/weibo/timeline.ts +++ b/lib/routes/weibo/timeline.ts @@ -47,6 +47,7 @@ async function handler(ctx) { let displayVideo = '1'; let displayArticle = '0'; let displayComments = '0'; + let showBloggerIcons = '0'; if (routeParams) { if (routeParams === '1' || routeParams === '0') { displayVideo = routeParams; @@ -55,6 +56,7 @@ async function handler(ctx) { displayVideo = fallback(undefined, queryToBoolean(routeParams.displayVideo), true) ? '1' : '0'; displayArticle = fallback(undefined, queryToBoolean(routeParams.displayArticle), false) ? '1' : '0'; displayComments = fallback(undefined, queryToBoolean(routeParams.displayComments), false) ? '1' : '0'; + showBloggerIcons = fallback(undefined, queryToBoolean(routeParams.showBloggerIcons), false) ? '1' : '0'; } } @@ -133,7 +135,7 @@ async function handler(ctx) { // 评论的处理 if (displayComments === '1') { - description = await weiboUtils.formatComments(ctx, description, item); + description = await weiboUtils.formatComments(ctx, description, item, showBloggerIcons); } // 文章的处理 diff --git a/lib/routes/weibo/user-bookmarks.ts b/lib/routes/weibo/user-bookmarks.ts index 94f10840b74b21..8ce63c4b63512e 100644 --- a/lib/routes/weibo/user-bookmarks.ts +++ b/lib/routes/weibo/user-bookmarks.ts @@ -167,7 +167,7 @@ async function handler(ctx) { // 评论的处理 if (displayComments === '1') { - description = await weiboUtils.formatComments(ctx, description, item.mblog); + description = await weiboUtils.formatComments(ctx, description, item.mblog, '0'); } // 文章的处理 diff --git a/lib/routes/weibo/user.ts b/lib/routes/weibo/user.ts index 023aef2e876878..0c4ad18976fd5b 100644 --- a/lib/routes/weibo/user.ts +++ b/lib/routes/weibo/user.ts @@ -56,6 +56,7 @@ async function handler(ctx) { let displayArticle = '0'; let displayComments = '0'; let showRetweeted = '1'; + let showBloggerIcons = '0'; if (ctx.req.param('routeParams')) { if (ctx.req.param('routeParams') === '1' || ctx.req.param('routeParams') === '0') { displayVideo = ctx.req.param('routeParams'); @@ -65,6 +66,7 @@ async function handler(ctx) { displayArticle = fallback(undefined, queryToBoolean(routeParams.displayArticle), false) ? '1' : '0'; displayComments = fallback(undefined, queryToBoolean(routeParams.displayComments), false) ? '1' : '0'; showRetweeted = fallback(undefined, queryToBoolean(routeParams.showRetweeted), false) ? '1' : '0'; + showBloggerIcons = fallback(undefined, queryToBoolean(routeParams.showBloggerIcons), false) ? '1' : '0'; } } const containerData = await cache.tryGet( @@ -161,7 +163,7 @@ async function handler(ctx) { // 评论的处理 if (displayComments === '1') { - description = await weiboUtils.formatComments(ctx, description, item.mblog); + description = await weiboUtils.formatComments(ctx, description, item.mblog, showBloggerIcons); } // 文章的处理 diff --git a/lib/routes/weibo/utils.ts b/lib/routes/weibo/utils.ts index 729150d827454c..9de9514dbd5f9b 100644 --- a/lib/routes/weibo/utils.ts +++ b/lib/routes/weibo/utils.ts @@ -399,7 +399,7 @@ const weiboUtils = { } return itemDesc; }, - formatComments: async (ctx, itemDesc, status) => { + formatComments: async (ctx, itemDesc, status, showBloggerIcons) => { if (status && status.comments_count && status.id && status.mid) { const id = status.id; const mid = status.mid; @@ -421,7 +421,11 @@ const weiboUtils = { itemDesc += '<h3>热门评论</h3>'; for (const comment of comments) { itemDesc += '<p style="margin-bottom: 0.5em;margin-top: 0.5em">'; - itemDesc += `<a href="https://weibo.com/${comment.user.id}" target="_blank">${comment.user.screen_name}</a>: ${comment.text}`; + let name = comment.user.screen_name; + if (showBloggerIcons === '1' && comment.blogger_icons) { + name += comment.blogger_icons[0].name; + } + itemDesc += `<a href="https://weibo.com/${comment.user.id}" target="_blank">${name}</a>: ${comment.text}`; // 带有图片的评论直接输出图片 if ('pic' in comment) { itemDesc += `<br><img src="${comment.pic.url}">`; @@ -445,7 +449,11 @@ const weiboUtils = { } } itemDesc += '<div style="font-size: 0.9em">'; - itemDesc += `<a href="https://weibo.com/${com.user.id}" target="_blank">${com.user.screen_name}</a>: ${com.text}`; + let name = com.user.screen_name; + if (showBloggerIcons === '1' && com.blogger_icons) { + name += com.blogger_icons[0].name; + } + itemDesc += `<a href="https://weibo.com/${com.user.id}" target="_blank">${name}</a>: ${com.text}`; itemDesc += '</div>'; } itemDesc += '</blockquote>';
5dbefe6e09820f18105d839c50c611482fdd3bdf
2019-09-07 03:25:48
dependabot-preview[bot]
chore(deps): bump googleapis from 42.0.0 to 43.0.0
false
bump googleapis from 42.0.0 to 43.0.0
chore
diff --git a/package.json b/package.json index 89d681da6b26e1..97232734d41f8a 100644 --- a/package.json +++ b/package.json @@ -64,7 +64,7 @@ "etag": "1.8.1", "form-data": "2.5.1", "git-rev-sync": "1.12.0", - "googleapis": "42.0.0", + "googleapis": "43.0.0", "got": "9.6.0", "he": "1.2.0", "iconv-lite": "0.5.0", diff --git a/yarn.lock b/yarn.lock index abe84e34135e04..be9027771fe734 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4777,17 +4777,17 @@ good-listener@^1.2.2: dependencies: delegate "^3.1.2" -google-auth-library@^5.1.0: - version "5.1.1" - resolved "https://registry.yarnpkg.com/google-auth-library/-/google-auth-library-5.1.1.tgz#d1b57f47d49f909ad10032e946d07e3b4142ca42" - integrity sha512-Au/lHG0Nvafprs8O66xu9qzfj/uEXWR+jmrhE2zHd9rh7mA+4b5H21rMP3xgQwmHXZHOOVN1GEuCEwlUut3gvg== +google-auth-library@^5.2.0: + version "5.2.1" + resolved "https://registry.yarnpkg.com/google-auth-library/-/google-auth-library-5.2.1.tgz#3df7cb4186a24355184551837b24012cb1b31013" + integrity sha512-p9vO6UcRIK/zD3PxoMijaUfFYu6tvzaQwvag1K/82O42NBeAnmllyQUgqaBhcAh9FzFAVlN4bQIaO8+prpE7Vg== dependencies: arrify "^2.0.0" base64-js "^1.3.0" fast-text-encoding "^1.0.0" gaxios "^2.0.0" gcp-metadata "^2.0.0" - gtoken "^3.0.0" + gtoken "^4.0.0" jws "^3.1.5" lru-cache "^5.0.0" @@ -4798,25 +4798,25 @@ google-p12-pem@^2.0.0: dependencies: node-forge "^0.8.0" -googleapis-common@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/googleapis-common/-/googleapis-common-3.0.0.tgz#da8ce5e5e0d37968132653224e578ab67a3b2670" - integrity sha512-M2SanEEgC0TiULNjH2jVROoMxM+0eCqRV4NhmIjaGhSwzgq7my47iq/m+yDVT4A1g4UpkbNX/6yt90zsJqmnlw== +googleapis-common@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/googleapis-common/-/googleapis-common-3.1.0.tgz#592dbf4e1fa543090b2671a524dcdb09184ec15c" + integrity sha512-abnogPoWqv0cU6O/EFpkerCVsaUsKEG6XpCm4P1YgK44PxIRcGtalDwijqUErkcivM1Xy5MNyf1PDkKTLEjOZA== dependencies: extend "^3.0.2" gaxios "^2.0.1" - google-auth-library "^5.1.0" + google-auth-library "^5.2.0" qs "^6.7.0" url-template "^2.0.8" uuid "^3.3.2" [email protected]: - version "42.0.0" - resolved "https://registry.yarnpkg.com/googleapis/-/googleapis-42.0.0.tgz#17de1fc4494a49bc120152e6df87b8eca9a6bf0d" - integrity sha512-nQiKPDmzmMusnU8UOibmlC6hsgkm70SjqmLxSlBBb7i0z7/J6UPilSzo9tAMoHA8u3BUw3OXn13+p9YLmBH6Gg== [email protected]: + version "43.0.0" + resolved "https://registry.yarnpkg.com/googleapis/-/googleapis-43.0.0.tgz#fcb1408fd1bd3f74eb9c4ca2b14ac7765ee0e50e" + integrity sha512-4b38mlTdDCA3KiyRTQmfPpeTxznC5ufgqx3AvKaEIoVm+iWeVLfwYs++/+OcGJJriH9bcs0gPbU7CR8DU6Oevg== dependencies: - google-auth-library "^5.1.0" - googleapis-common "^3.0.0" + google-auth-library "^5.2.0" + googleapis-common "^3.1.0" [email protected]: version "9.6.0" @@ -4877,16 +4877,15 @@ growly@^1.3.0: resolved "https://registry.yarnpkg.com/growly/-/growly-1.3.0.tgz#f10748cbe76af964b7c96c93c6bcc28af120c081" integrity sha1-8QdIy+dq+WS3yWyTxrzCivEgwIE= -gtoken@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/gtoken/-/gtoken-3.0.0.tgz#7d37245b5109442d8ec28075d5de15505c7462ad" - integrity sha512-IY9HVi78D4ykVHn+ThI7rlcpdFtKyo9e9YLim9S9T3rp6fEnfeTexcrqzSpExVshPofsdauLKIa8dEnzX7ZLfQ== +gtoken@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/gtoken/-/gtoken-4.0.0.tgz#42b63a935a03a61eedf0ec14f74f6875bad627bd" + integrity sha512-XaRCfHJxhj06LmnWNBzVTAr85NfAErq0W1oabkdqwbq3uL/QTB1kyvGog361Uu2FMG/8e3115sIy/97Rnd4GjQ== dependencies: gaxios "^2.0.0" google-p12-pem "^2.0.0" jws "^3.1.5" mime "^2.2.0" - pify "^4.0.0" handle-thing@^2.0.0: version "2.0.0" @@ -8041,7 +8040,7 @@ pify@^3.0.0: resolved "https://registry.yarnpkg.com/pify/-/pify-3.0.0.tgz#e5a4acd2c101fdf3d9a4d07f0dbc4db49dd28176" integrity sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY= -pify@^4.0.0, pify@^4.0.1: +pify@^4.0.1: version "4.0.1" resolved "https://registry.yarnpkg.com/pify/-/pify-4.0.1.tgz#4b2cd25c50d598735c50292224fd8c6df41e3231" integrity sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g==
5645b8466a681e8f2d0dd82a1183a14a6ac7745a
2024-02-26 20:08:18
DIYgod
test: mock client ip
false
mock client ip
test
diff --git a/lib/middleware/access-control.test.ts b/lib/middleware/access-control.test.ts index 9ba156ce739f32..d5bfc476e519a5 100644 --- a/lib/middleware/access-control.test.ts +++ b/lib/middleware/access-control.test.ts @@ -5,6 +5,8 @@ import type { serve } from '@hono/node-server'; let server: ReturnType<typeof serve>; +process.env.NODE_NAME = 'mock'; + function checkBlock(response) { expect(response.status).toBe(403); expect(response.text).toMatch(/Access denied\./); @@ -30,7 +32,7 @@ describe('access-control', () => { const response11 = await request.get('/test/1'); checkBlock(response11); - const response12 = await request.get('/test/1').set('X-Forwarded-For', '233.233.233.233'); + const response12 = await request.get('/test/1').set('X-Mock-IP', '233.233.233.233'); checkBlock(response12); const response13 = await request.get('/test/1').set('user-agent', 'blackua'); @@ -39,7 +41,7 @@ describe('access-control', () => { const response21 = await request.get('/test/2'); expect(response21.status).toBe(200); - const response22 = await request.get('/test/2').set('X-Forwarded-For', '233.233.233.233'); + const response22 = await request.get('/test/2').set('X-Mock-IP', '233.233.233.233'); checkBlock(response22); const response23 = await request.get('/test/2').set('user-agent', 'blackua'); @@ -53,17 +55,17 @@ describe('access-control', () => { expect(response312.status).toBe(200); // wrong key/code, on denylist - const response321 = await request.get(`/test/2?key=wrong+${key}`).set('X-Forwarded-For', '233.233.233.233'); + const response321 = await request.get(`/test/2?key=wrong+${key}`).set('X-Mock-IP', '233.233.233.233'); checkBlock(response321); - const response322 = await request.get(`/test/2?code=wrong+${code}`).set('X-Forwarded-For', '233.233.233.233'); + const response322 = await request.get(`/test/2?code=wrong+${code}`).set('X-Mock-IP', '233.233.233.233'); checkBlock(response322); // right key/code, on denylist - const response331 = await request.get(`/test/2?key=${key}`).set('X-Forwarded-For', '233.233.233.233'); + const response331 = await request.get(`/test/2?key=${key}`).set('X-Mock-IP', '233.233.233.233'); expect(response331.status).toBe(200); - const response332 = await request.get(`/test/2?code=${code}`).set('X-Forwarded-For', '233.233.233.233'); + const response332 = await request.get(`/test/2?code=${code}`).set('X-Mock-IP', '233.233.233.233'); expect(response332.status).toBe(200); }); @@ -84,7 +86,7 @@ describe('access-control', () => { const response11 = await request.get('/test/1'); expect(response11.status).toBe(200); - const response12 = await request.get('/test/1').set('X-Forwarded-For', '233.233.233.233'); + const response12 = await request.get('/test/1').set('X-Mock-IP', '233.233.233.233'); expect(response12.status).toBe(200); const response13 = await request.get('/test/1').set('user-agent', 'whiteua'); @@ -93,16 +95,16 @@ describe('access-control', () => { const response21 = await request.get('/test/2'); checkBlock(response21); - const response22 = await request.get('/test/2').set('X-Forwarded-For', '233.233.233.233'); + const response22 = await request.get('/test/2').set('X-Mock-IP', '233.233.233.233'); expect(response22.status).toBe(200); - const response221 = await request.get('/test/2').set('X-Forwarded-For', '103.31.4.0'); + const response221 = await request.get('/test/2').set('X-Mock-IP', '103.31.4.0'); expect(response221.status).toBe(200); - const response222 = await request.get('/test/2').set('X-Forwarded-For', '103.31.7.255'); + const response222 = await request.get('/test/2').set('X-Mock-IP', '103.31.7.255'); expect(response222.status).toBe(200); - const response223 = await request.get('/test/2').set('X-Forwarded-For', '103.31.8.0'); + const response223 = await request.get('/test/2').set('X-Mock-IP', '103.31.8.0'); checkBlock(response223); const response23 = await request.get('/test/2').set('user-agent', 'whiteua'); @@ -116,10 +118,10 @@ describe('access-control', () => { checkBlock(response312); // wrong key/code, on allowlist - const response321 = await request.get(`/test/2?code=wrong+${code}`).set('X-Forwarded-For', '233.233.233.233'); + const response321 = await request.get(`/test/2?code=wrong+${code}`).set('X-Mock-IP', '233.233.233.233'); expect(response321.status).toBe(200); - const response322 = await request.get(`/test/2?key=wrong+${key}`).set('X-Forwarded-For', '233.233.233.233'); + const response322 = await request.get(`/test/2?key=wrong+${key}`).set('X-Mock-IP', '233.233.233.233'); expect(response322.status).toBe(200); // right key/code diff --git a/lib/utils/helpers.ts b/lib/utils/helpers.ts index 32cff45b113749..aeed986fa18310 100644 --- a/lib/utils/helpers.ts +++ b/lib/utils/helpers.ts @@ -1,5 +1,6 @@ import { Context } from 'hono'; import { Ipware } from '@fullerstack/nax-ipware'; +import { config } from '@/config'; const ipware = new Ipware(); @@ -11,4 +12,4 @@ export const getRouteNameFromPath = (path: string) => { return null; }; -export const getIp = (ctx: Context) => ipware.getClientIP(ctx.req.raw)?.ip; +export const getIp = (ctx: Context) => (config.nodeName === 'mock' && ctx.req.header('X-Mock-IP') ? ctx.req.header('X-Mock-IP') : ipware.getClientIP(ctx.req.raw)?.ip);
bb524fbb1990de54275dad964b464fd5945843b1
2023-09-06 22:18:14
Tony
fix(route): douyin live (#13225)
false
douyin live (#13225)
fix
diff --git a/lib/v2/douyin/live.js b/lib/v2/douyin/live.js index e22ee7e6b967ca..a6cc9cdfa7603b 100644 --- a/lib/v2/douyin/live.js +++ b/lib/v2/douyin/live.js @@ -1,5 +1,6 @@ const config = require('@/config').value; -const { getOriginAvatar, universalGet } = require('./utils'); +const { getOriginAvatar } = require('./utils'); +const logger = require('@/utils/logger'); module.exports = async (ctx) => { const { rid } = ctx.params; @@ -9,31 +10,59 @@ module.exports = async (ctx) => { const pageUrl = `https://live.douyin.com/${rid}`; - const renderData = await ctx.cache.tryGet(`douyin:live:${rid}`, () => universalGet(pageUrl, 'live', ctx), config.cache.routeExpire, false); + const renderData = await ctx.cache.tryGet( + `douyin:live:${rid}`, + async () => { + let roomInfo; + const browser = await require('@/utils/puppeteer')(); + const page = await browser.newPage(); + await page.setRequestInterception(true); - if (renderData[Object.keys(renderData).find((k) => renderData[k].status_code)].status_code !== '0') { - throw `Status code ${renderData[Object.keys(renderData).find((k) => renderData[k].status_code)].status_code}`; + page.on('request', (request) => { + request.resourceType() === 'document' || request.resourceType() === 'script' || request.resourceType() === 'xhr' ? request.continue() : request.abort(); + }); + page.on('response', async (response) => { + const request = response.request(); + if (request.url().includes('/webcast/room/web/enter')) { + roomInfo = await response.json(); + } + }); + logger.debug(`Requesting ${pageUrl}`); + await page.goto(pageUrl, { + waitUntil: 'networkidle2', + }); + browser.close(); + + return roomInfo; + }, + config.cache.routeExpire, + false + ); + + if (renderData.status_code !== 0) { + throw Error(`Status code ${renderData.status_code}`); } - const roomInfo = renderData.app.initialState.roomStore.roomInfo; - const nickname = roomInfo.anchor.nickname; - const userAvatar = roomInfo.anchor.avatar_thumb.url_list[0]; + const roomInfo = renderData.data.data[0]; + const nickname = roomInfo.owner.nickname; + const userAvatar = roomInfo.owner.avatar_thumb.url_list[0]; const items = []; - if (roomInfo.roomId) { - if (roomInfo.room.status === 2) { + if (roomInfo.id_str) { + if (roomInfo.status === 2) { items.push({ - title: `开播:${roomInfo.room.title}`, + title: `开播:${roomInfo.title}`, + description: `<img src="${roomInfo.cover.url_list[0]}">`, link: pageUrl, author: nickname, - guid: roomInfo.roomId, // roomId is unique for each live event + guid: roomInfo.id_str, // roomId is unique for each live event }); - } else if (roomInfo.room.status === 4) { + } else if (roomInfo.status === 4) { items.push({ - title: `当前直播已结束,期待下一场:${roomInfo.room.title}`, - link: `https://www.douyin.com/user/${roomInfo.anchor.sec_uid}`, + title: `当前直播已结束,期待下一场:${roomInfo.title}`, + link: `https://www.douyin.com/user/${roomInfo.owner.sec_uid}`, author: nickname, - guid: roomInfo.roomId, + guid: roomInfo.id_str, }); } }
f218807ed703bf0dd64b7360cfe00fa492a0e317
2019-05-29 22:31:54
fengkx
fix: notch time (#2259)
false
notch time (#2259)
fix
diff --git a/lib/routes/qdaily/notch/explore.js b/lib/routes/qdaily/notch/explore.js index 09d0f6866b3a53..9fb590b400a50b 100644 --- a/lib/routes/qdaily/notch/explore.js +++ b/lib/routes/qdaily/notch/explore.js @@ -50,7 +50,7 @@ module.exports = async (ctx) => { title: post.title, description: await ProcessFeed(data.index_type, item), link: post.share.url, - pubDate: new Date(post.published_at).toUTCString(), + pubDate: new Date(post.published_at * 1000).toUTCString(), author: data.title, }; }) diff --git a/lib/routes/qdaily/notch/index.js b/lib/routes/qdaily/notch/index.js index 443e0cc22bbb0f..5ea700c8dd8c33 100644 --- a/lib/routes/qdaily/notch/index.js +++ b/lib/routes/qdaily/notch/index.js @@ -41,7 +41,7 @@ module.exports = async (ctx) => { title: post.title, description: await ProcessFeed(post.id), link: post.share.url, - pubDate: new Date(post.published_at).toUTCString(), + pubDate: new Date(post.published_at * 1000).toUTCString(), author: post.author_info ? post.author_info.username : '', }; })
69a35d2f563e9c9e5e4400c1c635decba3c7806c
2024-10-18 10:32:46
quiniapiezoelectricity
feat(route): add straits times route (#17163)
false
add straits times route (#17163)
feat
diff --git a/lib/routes/straitstimes/index.ts b/lib/routes/straitstimes/index.ts new file mode 100644 index 00000000000000..f0995231902fd8 --- /dev/null +++ b/lib/routes/straitstimes/index.ts @@ -0,0 +1,135 @@ +import { Route } from '@/types'; +import cache from '@/utils/cache'; +import got from '@/utils/got'; +import { parseDate } from '@/utils/parse-date'; +import { getCurrentPath } from '@/utils/helpers'; +import path from 'node:path'; +import { art } from '@/utils/render'; + +export const route: Route = { + path: '/:category?/:section?', + categories: ['traditional-media'], + example: '/straitstimes/singapore', + parameters: { + category: 'Category, see below for more information', + section: 'Section, see below for more information', + }, + features: { + requirePuppeteer: false, + antiCrawler: false, + supportBT: false, + supportPodcast: false, + supportScihub: false, + requireConfig: false, + }, + name: 'News', + maintainers: ['quiniapiezoelectricity'], + handler, + description: ` +| Category | \`:category\` | +| ---------------------- | --------------------------- | +| Singapore | \`singapore\` | +| Asia | \`asia\` | +| World | \`world\` | +| Opinion | \`opinion\` | +| Life | \`life\` | +| Business | \`business\` | +| Jobs | \`jobs\` | +| Parenting & Education | \`parenting-and-education\` | +| Food | \`food\` | +| Tech | \`tech\` | +| Sport | \`sport\` | +| Podcasts | \`podcasts\` |, + +| Section | \`:section\` | +| ---------------------- | --------------------------- | +| Top Stories | \`top-stories\` | +| Latest | \`latest\` |`, + radar: [ + { + source: ['www.straitstimes.com/:category'], + target: '/:category', + }, + { + source: ['www.straitstimes.com'], + target: '/', + }, + ], +}; + +async function handler(ctx) { + const category = ctx.req.param('category') ? ctx.req.param('category').toLowerCase() : 'singapore'; + const section = ctx.req.param('section') ? ctx.req.param('section').toLowerCase() : undefined; + const apiKey = 'T9XUJM9rAZoLOd2CAx2wCBSTrm3xoyPw'; + const platform = 'iosflex'; + const __dirname = getCurrentPath(import.meta.url); + let feed; + const response = await got({ + method: 'get', + url: `https://newsapi.sphdigital.com/v2/feed/section/st?page=1&platform=${platform}&section=${category}/star&subscribed=false&version=4.0`, + headers: { + 'x-api-key': apiKey, + }, + }); + feed = response.data.data; + const sections = new Set(feed.filter((item) => item.items[0].itemType === 'SectionFooter').map((items) => items.items[0].sectionFooterData.link.id)); + let slug = section && sections.has(`${category}-${section}-more/star`) ? `${category}-${section}-more/star` : undefined; + if (section === undefined) { + for (const section of ['latest', 'top-picks', 'top-stories']) { + if (sections.has(`${category}-${section}-more/star`)) { + slug = `${category}-${section}-more/star`; + break; + } + } + } + if (slug) { + const response = await got({ + method: 'get', + url: `https://newsapi.sphdigital.com/v2/feed/section/st?page=1&platform=${platform}&section=${slug}&subscribed=false&version=4.0`, + headers: { + 'x-api-key': apiKey, + }, + }); + feed = response.data.data; + } + const articles = feed.filter((item) => item.items[0].itemType === 'Article'); + const items = await Promise.all( + articles.map((item) => + cache.tryGet(item.items[0].articleData.url, async () => { + const article = item.items[0].articleData; + if (article.authors) { + item.author = article.authors.map((author) => author.name).join(', '); + } + if (article.keywords) { + item.category = article.keywords.map((keyword) => keyword.name); + } + item.title = article.headline; + item.pubDate = parseDate(article.publicationTime, 'X'); + item.updated = parseDate(article.updatedTime, 'X'); + item.link = article.url; + let content = article.teaser; + if (article.documentId) { + const response = await got({ + method: 'get', + url: `https://newsapi.sphdigital.com/v2/feed/article/st/${article.documentId}?platform=${platform}&version=4.0`, + headers: { + 'x-api-key': apiKey, + }, + }); + content = response.data.data.body; + } + item.description = art(path.join(__dirname, 'templates/description.art'), { + images: article.images ?? [], + article: content, + }); + return item; + }) + ) + ); + + return { + title: `The Strait Times - ${category.replaceAll('-', ' ').toUpperCase()}`, + link: `https://www.straitstimes.com/${category.toLowerCase()}`, + item: items, + }; +} diff --git a/lib/routes/straitstimes/namespace.ts b/lib/routes/straitstimes/namespace.ts new file mode 100644 index 00000000000000..c23481dd38552e --- /dev/null +++ b/lib/routes/straitstimes/namespace.ts @@ -0,0 +1,7 @@ +import type { Namespace } from '@/types'; + +export const namespace: Namespace = { + name: 'The Strait Times', + url: 'straitstimes.com', + description: '', +}; diff --git a/lib/routes/straitstimes/templates/description.art b/lib/routes/straitstimes/templates/description.art new file mode 100644 index 00000000000000..697ad38bc2f202 --- /dev/null +++ b/lib/routes/straitstimes/templates/description.art @@ -0,0 +1,27 @@ +{{ if images }} + {{ each images }} + {{if $value.url }} + <figure> + <img src= + {{ if $value.large }} + "{{ $value.large }}" + {{ else }} + "{{ $value.url }}" + {{ /if }} + {{ if $value.height }} + height="{{ $value.height }}" + {{ /if }} + {{ if $value.width }} + width="{{ $value.width }}" + {{ /if }} + > + {{ if $value.caption }} + <figcaption>{{ $value.caption }}</figcaption> + {{ /if }} + </figure> + {{ /if }} + {{ /each }} +{{ /if }} +{{ if article }} + {{@ article }} +{{ /if }} \ No newline at end of file
eea20288d550254d02c0db6dd0498310d742a160
2022-05-20 22:05:05
Wildmoe
fix(route): 南京停水通知 (#9782)
false
南京停水通知 (#9782)
fix
diff --git a/docs/forecast.md b/docs/forecast.md index cad3117d2a77c8..238b18122e82eb 100644 --- a/docs/forecast.md +++ b/docs/forecast.md @@ -96,11 +96,11 @@ pageClass: routes ### 95598 停电查询网 -<Route author="mjysci" example="/tingdiantz/95598/hb1/wh/wc/" path="/tingdiantz/95598/:province/:city/:district?" :paramsDesc="['省,2~3位拼音缩写,详情见http://www.sttcq.com/td/','市,同上', '区,同上']"/> +<Route author="mjysci" example="/tingdiantz/95598/hb1/wh/wc/" path="/tingdiantz/95598/:province/:city/:district?" :paramsDesc="['省,2~3位拼音缩写,详情见http://www.sttcq.com/td/', '市,同上', '区,同上']"/> ### 南京市 -<Route author="ocleo1" example="/tingdiantz/nanjing" path="/tingdiantz/nanjing"/> +<Route author="ocleo1" example="/tingdiantz/nanjing" path="/tingdiantz/nanjing"/> ## 停水通知 @@ -140,7 +140,14 @@ pageClass: routes ### 武汉市 -<Route author="MoonBegonia" example="/tingshuitz/wuhan" path="/tingshuitz/wuhan"/> +<Route author="MoonBegonia" example="/tingshuitz/wuhan" path="/tingshuitz/wuhan/:channelId"> + +| channelId | 分类 | +| --------- | ----- | +| 68 | 计划性停水 | +| 69 | 突发性停水 | + +</RouteEn> ## 香港天文台 diff --git a/lib/router.js b/lib/router.js index f31b1fcfc51d4f..c424bd6627fbe4 100644 --- a/lib/router.js +++ b/lib/router.js @@ -264,16 +264,16 @@ router.get('/smzdm/baoliao/:uid', lazyloadRouteHandler('./routes/smzdm/baoliao') router.get('/bjnews/:cat', lazyloadRouteHandler('./routes/bjnews/news')); router.get('/bjnews/epaper/:cat', lazyloadRouteHandler('./routes/bjnews/epaper')); -// 停水通知 -router.get('/tingshuitz/hangzhou', lazyloadRouteHandler('./routes/tingshuitz/hangzhou')); -router.get('/tingshuitz/xiaoshan', lazyloadRouteHandler('./routes/tingshuitz/xiaoshan')); -router.get('/tingshuitz/dalian', lazyloadRouteHandler('./routes/tingshuitz/dalian')); -router.get('/tingshuitz/guangzhou', lazyloadRouteHandler('./routes/tingshuitz/guangzhou')); -router.get('/tingshuitz/dongguan', lazyloadRouteHandler('./routes/tingshuitz/dongguan')); -router.get('/tingshuitz/xian', lazyloadRouteHandler('./routes/tingshuitz/xian')); -router.get('/tingshuitz/yangjiang', lazyloadRouteHandler('./routes/tingshuitz/yangjiang')); -router.get('/tingshuitz/nanjing', lazyloadRouteHandler('./routes/tingshuitz/nanjing')); -router.get('/tingshuitz/wuhan', lazyloadRouteHandler('./routes/tingshuitz/wuhan')); +// 停水通知 migrated to v2 +// router.get('/tingshuitz/hangzhou', lazyloadRouteHandler('./routes/tingshuitz/hangzhou')); +// router.get('/tingshuitz/xiaoshan', lazyloadRouteHandler('./routes/tingshuitz/xiaoshan')); +// router.get('/tingshuitz/dalian', lazyloadRouteHandler('./routes/tingshuitz/dalian')); +// router.get('/tingshuitz/guangzhou', lazyloadRouteHandler('./routes/tingshuitz/guangzhou')); +// router.get('/tingshuitz/dongguan', lazyloadRouteHandler('./routes/tingshuitz/dongguan')); +// router.get('/tingshuitz/xian', lazyloadRouteHandler('./routes/tingshuitz/xian')); +// router.get('/tingshuitz/yangjiang', lazyloadRouteHandler('./routes/tingshuitz/yangjiang')); +// router.get('/tingshuitz/nanjing', lazyloadRouteHandler('./routes/tingshuitz/nanjing')); +// router.get('/tingshuitz/wuhan', lazyloadRouteHandler('./routes/tingshuitz/wuhan')); // 米哈游 router.get('/mihoyo/bh3/:type', lazyloadRouteHandler('./routes/mihoyo/bh3')); diff --git a/lib/routes/tingshuitz/dalian.js b/lib/routes/tingshuitz/dalian.js deleted file mode 100644 index 5339b68fff6482..00000000000000 --- a/lib/routes/tingshuitz/dalian.js +++ /dev/null @@ -1,34 +0,0 @@ -const got = require('@/utils/got'); -const cheerio = require('cheerio'); - -module.exports = async (ctx) => { - // const area = ctx.params.area; - const url = 'http://www.swj.dl.gov.cn/html/tstz/'; - const response = await got({ - method: 'get', - url, - }); - - const data = response.data; - const $ = cheerio.load(data); - const list = $('.listBox li'); - - ctx.state.data = { - title: $('title').text() || '停水通知 - 大连市水务局', - link: 'http://www.swj.dl.gov.cn/html/tstz/', - description: $('meta[name="description"]').attr('content') || $('title').text() || '停水通知 - 大连市水务局', - item: - list && - list - .map((index, item) => { - item = $(item); - return { - title: item.find('a').text(), - description: `大连市停水通知:${item.find('a').text()}`, - pubDate: new Date(item.find('span').text()).toUTCString(), - link: item.find('a').attr('href'), - }; - }) - .get(), - }; -}; diff --git a/lib/routes/tingshuitz/wuhan.js b/lib/routes/tingshuitz/wuhan.js deleted file mode 100644 index a49ca983991a17..00000000000000 --- a/lib/routes/tingshuitz/wuhan.js +++ /dev/null @@ -1,34 +0,0 @@ -const got = require('@/utils/got'); -const cheerio = require('cheerio'); -const url = require('url'); - -module.exports = async (ctx) => { - const baseUrl = 'https://www.whwater.com/gsfw/tstz/'; - const response = await got({ - method: 'get', - url: baseUrl, - }); - - const data = response.data; - const $ = cheerio.load(data); - const list = $('.z4'); - - ctx.state.data = { - title: $('title').text() || '停水通知 - 武汉市水务集团有限公司', - link: 'https://www.whwater.com/gsfw/tstz/', - description: $('meta[name="description"]').attr('content') || $('title').text() || '停水通知 - 武汉市水务集团有限公司', - item: - list && - list - .map((index, item) => { - item = $(item); - return { - title: item.find('a').text(), - description: `武汉市停水通知:${item.find('a').text()}`, - pubDate: new Date(item.find('span').text()).toUTCString(), - link: url.resolve(baseUrl, item.find('a').attr('href')), - }; - }) - .get(), - }; -}; diff --git a/lib/v2/tingshuitz/dalian.js b/lib/v2/tingshuitz/dalian.js new file mode 100644 index 00000000000000..f976ad07bcd4dc --- /dev/null +++ b/lib/v2/tingshuitz/dalian.js @@ -0,0 +1,29 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const { parseDate } = require('@/utils/parse-date'); + +module.exports = async (ctx) => { + const url = + 'https://swj.dl.gov.cn/module/web/jpage/dataproxy.jsp?page=1&webid=28&path=https://swj.dl.gov.cn/&columnid=4296&unitid=31227&webname=%25E5%25A4%25A7%25E8%25BF%259E%25E5%25B8%2582%25E6%25B0%25B4%25E5%258A%25A1%25E5%25B1%2580&permissiontype=0'; + const response = await got(url); + + const $ = cheerio.load(response.data); + const items = $('recordset record') + .toArray() + .map((item) => { + item = $(item); + return { + title: item.find('a').text().trim(), + description: `大连市停水通知:${item.find('a').text().trim()}`, + pubDate: parseDate(item.find('span').text(), 'YYYY-MM-DD'), + link: item.find('a').attr('href'), + }; + }); + + ctx.state.data = { + title: '停水通知 - 大连市水务局', + link: 'https://swj.dl.gov.cn/col/col4296/index.html', + description: '停水通知 - 大连市水务局', + item: items, + }; +}; diff --git a/lib/routes/tingshuitz/dongguan.js b/lib/v2/tingshuitz/dongguan.js similarity index 88% rename from lib/routes/tingshuitz/dongguan.js rename to lib/v2/tingshuitz/dongguan.js index 979470cd619270..e77c6e96dfabd7 100644 --- a/lib/routes/tingshuitz/dongguan.js +++ b/lib/v2/tingshuitz/dongguan.js @@ -1,5 +1,6 @@ const got = require('@/utils/got'); const cheerio = require('cheerio'); +const { parseDate } = require('@/utils/parse-date'); module.exports = async (ctx) => { const url = 'http://www.djsw.com.cn/news/tstz/index.html'; @@ -24,7 +25,7 @@ module.exports = async (ctx) => { return { title: item.find('a').text(), description: `东莞市停水通知:${item.find('a').text()}`, - pubDate: new Date($(item.contents()[1]).text().slice(1, -1)).toUTCString(), + pubDate: parseDate($(item.contents()[1]).text().slice(1, -1)), link: item.find('a').attr('href'), }; }) diff --git a/lib/routes/tingshuitz/guangzhou.js b/lib/v2/tingshuitz/guangzhou.js similarity index 100% rename from lib/routes/tingshuitz/guangzhou.js rename to lib/v2/tingshuitz/guangzhou.js diff --git a/lib/routes/tingshuitz/hangzhou.js b/lib/v2/tingshuitz/hangzhou.js similarity index 100% rename from lib/routes/tingshuitz/hangzhou.js rename to lib/v2/tingshuitz/hangzhou.js diff --git a/lib/v2/tingshuitz/maintainer.js b/lib/v2/tingshuitz/maintainer.js new file mode 100644 index 00000000000000..6976a2f9e6c1cf --- /dev/null +++ b/lib/v2/tingshuitz/maintainer.js @@ -0,0 +1,11 @@ +module.exports = { + '/dalian': ['DIYgod'], + '/dongguan': ['victoriqueko'], + '/guangzhou': ['xyqfer'], + '/hangzhou': ['znhocn'], + '/nanjing': ['ocleo1'], + '/wuhan': ['MoonBegonia'], + '/xian': ['ciaranchen'], + '/xiaoshan': ['znhocn'], + '/yangjiang': ['ciaranchen'], +}; diff --git a/lib/routes/tingshuitz/nanjing.js b/lib/v2/tingshuitz/nanjing.js similarity index 56% rename from lib/routes/tingshuitz/nanjing.js rename to lib/v2/tingshuitz/nanjing.js index 924b02bfec5173..fbb1fb25209c33 100644 --- a/lib/routes/tingshuitz/nanjing.js +++ b/lib/v2/tingshuitz/nanjing.js @@ -1,15 +1,15 @@ const got = require('@/utils/got'); const cheerio = require('cheerio'); - +const { parseDate } = require('@/utils/parse-date'); const HOME_PAGE = 'http://www.jlwater.com/'; module.exports = async (ctx) => { - const url = `${HOME_PAGE}portal.do?method=news&subjectchildid=8`; - const response = await got.get(url); + const url = `${HOME_PAGE}portal/10000013`; + const response = await got(url); const data = response.data; const $ = cheerio.load(data); - const list = $('.maincol-list ul li'); + const list = $('.list-content ul li'); ctx.state.data = { title: $('head title').text(), @@ -17,14 +17,12 @@ module.exports = async (ctx) => { item: list .map((index, item) => { const $item = $(item); - const $title = $item.find('.rtitle'); - const link = $title.find('a').attr('href'); - - let pubDate = $item.find('.rtime').text(); - pubDate = new Date(pubDate.substring(1, pubDate.length - 1)).toUTCString(); - + const title = $item.find('a span').text(); + const link = $item.find('a').attr('href'); + const listTime = $item.find('.list-time').text(); + const pubDate = parseDate(listTime); return { - title: $title.text(), + title: `${title} ${listTime}`, description: '南京市停水通知', link: `${HOME_PAGE}${link}`, pubDate, diff --git a/lib/v2/tingshuitz/radar.js b/lib/v2/tingshuitz/radar.js new file mode 100644 index 00000000000000..a40f04245300a9 --- /dev/null +++ b/lib/v2/tingshuitz/radar.js @@ -0,0 +1,68 @@ +module.exports = { + 'dl.gov.cn': { + _name: '停水通知', + swj: [ + { + title: '大连市', + docs: 'https://docs.rsshub.app/forecast.html#ting-shui-tong-zhi', + source: ['/col/col4296/index.html', '/'], + target: '/tingshuitz/dalian', + }, + ], + }, + 'hzwgc.com': { + _name: '停水通知', + www: [ + { + title: '杭州市', + docs: 'https://docs.rsshub.app/forecast.html#ting-shui-tong-zhi', + source: ['/public/stop_the_water', '/'], + target: '/tingshuitz/hangzhou', + }, + ], + }, + 'jlwater.com': { + _name: '停水通知', + '.': [ + { + title: '南京市', + docs: 'https://docs.rsshub.app/forecast.html#ting-shui-tong-zhi', + source: ['/portal/10000013', '/'], + target: '/tingshuitz/nanjing', + }, + ], + }, + 'whwater.com': { + _name: '停水通知', + '.': [ + { + title: '武汉市', + docs: 'https://docs.rsshub.app/forecast.html#ting-shui-tong-zhi', + source: ['/IWater.shtml', '/'], + target: '/tingshuitz/wuhan', + }, + ], + }, + 'xswater.com': { + _name: '停水通知', + www: [ + { + title: '萧山区', + docs: 'https://docs.rsshub.app/forecast.html#ting-shui-tong-zhi', + source: ['/gongshui/channels/227.html', '/'], + target: '/tingshuitz/xiaoshan', + }, + ], + }, + 'yjsswjt.com': { + _name: '停水通知', + '.': [ + { + title: '阳江市', + docs: 'https://docs.rsshub.app/forecast.html#ting-shui-tong-zhi', + source: ['/zxdt_list.jsp', '/'], + target: '/tingshuitz/yangjiang', + }, + ], + }, +}; diff --git a/lib/v2/tingshuitz/router.js b/lib/v2/tingshuitz/router.js new file mode 100644 index 00000000000000..c90302af7b0845 --- /dev/null +++ b/lib/v2/tingshuitz/router.js @@ -0,0 +1,11 @@ +module.exports = (router) => { + router.get('/dalian', require('./dalian')); + router.get('/dongguan', require('./dongguan')); + router.get('/guangzhou', require('./guangzhou')); + router.get('/hangzhou', require('./hangzhou')); + router.get('/nanjing', require('./nanjing')); + router.get('/wuhan/:channelId?', require('./wuhan')); + router.get('/xian', require('./xian')); + router.get('/xiaoshan', require('./xiaoshan')); + router.get('/yangjiang', require('./yangjiang')); +}; diff --git a/lib/v2/tingshuitz/wuhan.js b/lib/v2/tingshuitz/wuhan.js new file mode 100644 index 00000000000000..17f19722c30e96 --- /dev/null +++ b/lib/v2/tingshuitz/wuhan.js @@ -0,0 +1,32 @@ +const got = require('@/utils/got'); +const { parseDate } = require('@/utils/parse-date'); +const baseUrl = 'https://www.whwater.com'; + +module.exports = async (ctx) => { + const { channelId = 68 } = ctx.params; + const response = await got.post('https://manager.whwater.com:8900/website/article/findChannelArticle', { + form: { + channelId, + searchKey: '', + thumbnailStatus: 0, + topStatus: 0, + recommendStatus: 0, + page: 1, + size: ctx.query.limit ? parseInt(ctx.query.limit) : 30, + }, + }); + + const data = response.data.data; + const items = data.articleArray.map((item) => ({ + title: item.title, + description: item.content, + pubDate: parseDate(item.publishTime), + link: `https://${baseUrl}/IPolicyDetails.shtml?id=31&sid=${channelId}${item.articleLink}`, + })); + + ctx.state.data = { + title: `${data.channelName}通知 - 武汉市水务集团有限公司`, + link: `${baseUrl}/IWater.shtml?id=31&sid=48`, + item: items, + }; +}; diff --git a/lib/routes/tingshuitz/xian.js b/lib/v2/tingshuitz/xian.js similarity index 95% rename from lib/routes/tingshuitz/xian.js rename to lib/v2/tingshuitz/xian.js index 56472e1f00af2a..47bdc3c9bfc0e8 100644 --- a/lib/routes/tingshuitz/xian.js +++ b/lib/v2/tingshuitz/xian.js @@ -4,7 +4,7 @@ const iconv = require('iconv-lite'); module.exports = async (ctx) => { const url = 'http://www.xazls.com/tsgg/index.htm'; - const response = await got.get(url, { + const response = await got(url, { responseType: 'buffer', }); diff --git a/lib/routes/tingshuitz/xiaoshan.js b/lib/v2/tingshuitz/xiaoshan.js similarity index 100% rename from lib/routes/tingshuitz/xiaoshan.js rename to lib/v2/tingshuitz/xiaoshan.js diff --git a/lib/routes/tingshuitz/yangjiang.js b/lib/v2/tingshuitz/yangjiang.js similarity index 66% rename from lib/routes/tingshuitz/yangjiang.js rename to lib/v2/tingshuitz/yangjiang.js index 1c1da60ebc50eb..5f406e60233979 100644 --- a/lib/routes/tingshuitz/yangjiang.js +++ b/lib/v2/tingshuitz/yangjiang.js @@ -1,20 +1,17 @@ const got = require('@/utils/got'); const cheerio = require('cheerio'); -const iconv = require('iconv-lite'); +const { parseDate } = require('@/utils/parse-date'); module.exports = async (ctx) => { - const url = 'http://www.yjsswjt.com/zxdt_list.jsp?flbz=7'; - const response = await got.get(url, { - responseType: 'buffer', - }); + const url = 'https://www.yjsswjt.com/zxdt_list.jsp?flbz=7'; + const response = await got(url); - const data = response.data; - const $ = cheerio.load(iconv.decode(data, 'gb2312')); + const $ = cheerio.load(response.data); const list = $('div.list_ul_div > ul > li'); ctx.state.data = { title: '停水通知 - 阳江市水务集团有限公司', - link: 'http://www.yjsswjt.com/zxdt_list.jsp?flbz=7', + link: 'https://www.yjsswjt.com/zxdt_list.jsp?flbz=7', item: list .map((_, el) => { const item = $(el); @@ -24,6 +21,7 @@ module.exports = async (ctx) => { title: item.find('span').text().trim(), description: item.find('span').text().trim(), link: 'http://www.yjsswjt.com/list.jsp?id=' + id, + pubDate: parseDate(item.find('.datetime').text(), 'YYYY.MM.DD'), }; }) .get(),
e555c6101ce4430901d74826eb4ea8dde8b8c0db
2023-07-25 20:09:27
Felix Hsu
fix(route): bloomberg story for newslettes (#12869)
false
bloomberg story for newslettes (#12869)
fix
diff --git a/lib/v2/bloomberg/react-renderer.js b/lib/v2/bloomberg/react-renderer.js index 3a174dcc0ca16b..00fc468c666d77 100644 --- a/lib/v2/bloomberg/react-renderer.js +++ b/lib/v2/bloomberg/react-renderer.js @@ -3,7 +3,7 @@ const path = require('path'); const { processVideo } = require('./utils'); const nodeRenderers = { - paragraph: (node, nextNode) => `<p>${nextNode(node.content)}</p>`, + paragraph: async (node, nextNode) => `<p>${await nextNode(node.content)}</p>`, text: (node) => { const { attributes: attr, value: val } = node; if (attr?.emphasis && attr?.strong) { @@ -16,71 +16,71 @@ const nodeRenderers = { return val; } }, - 'inline-newsletter': (node, nextNode) => `<div>${nextNode(node.content)}</div>`, - heading: (node, nextNode) => { + 'inline-newsletter': async (node, nextNode) => `<div>${await nextNode(node.content)}</div>`, + heading: async (node, nextNode) => { const nodeData = node.data; if (nodeData.level === 2 || nodeData.level === 3) { - return `<h3>${nextNode(node.content)}</h3>`; + return `<h3>${await nextNode(node.content)}</h3>`; } }, - link: (node, nextNode) => { + link: async (node, nextNode) => { const dest = node.data.destination; const web = dest.web; const bbg = dest.bbg; const title = node.data.title; if (web) { - return `<a href="${web}" title="${title}" target="_blank">${nextNode(node.content)}</a>`; + return `<a href="${web}" title="${title}" target="_blank">${await nextNode(node.content)}</a>`; } if (bbg && bbg.startsWith('bbg://news/stories')) { const o = bbg.split('bbg://news/stories/').pop(); const s = 'https://www.bloomberg.com/news/terminal/'.concat(o); - return `<a href="${s}" title="${title}" target="_blank">${nextNode(node.content)}</a>`; + return `<a href="${s}" title="${title}" target="_blank">${await nextNode(node.content)}</a>`; } - return String(nextNode(node.content)); + return String(await nextNode(node.content)); }, - entity: (node, nextNode) => { + entity: async (node, nextNode) => { const t = node.subType; const linkDest = node.data.link.destination; const web = linkDest.web; if (t === 'person') { - return String(nextNode(node.content)); + return nextNode(node.content); } if (t === 'story') { if (web) { - return `<a href="${web}" target="_blank">${nextNode(node.content)}</a>`; + return `<a href="${web}" target="_blank">${await nextNode(node.content)}</a>`; } const a = node.data.story.identifiers.suid; const o = 'https://www.bloomberg.com/news/terminal/'.concat(a); - return `<a href="${o}" target="_blank">${nextNode(node.content)}</a>`; + return `<a href="${o}" target="_blank">${await nextNode(node.content)}</a>`; } if (t === 'security') { const s = node.data.security.identifiers.parsekey; if (s) { const c = s.split(' '); const href = 'https://www.bloomberg.com/quote/'.concat(c[0], ':').concat(c[1]); - return `<a href="${href}" target="_blank">${nextNode(node.content)}</a>`; + return `<a href="${href}" target="_blank">${await nextNode(node.content)}</a>`; } } - return String(nextNode(node.content)); + return nextNode(node.content); }, br: () => `<br/>`, hr: () => `<br/>`, ad: () => {}, - blockquote: (node, nextNode) => `<blockquote>${nextNode(node.content)}</blockquote>`, - quote: (node, nextNode) => `<blockquote>${nextNode(node.content)}</blockquote>`, - aside: (node, nextNode) => `<aside>${nextNode(node.content)}</aside>`, - list: (node, nextNode) => { + blockquote: async (node, nextNode) => `<blockquote>${await nextNode(node.content)}</blockquote>`, + quote: async (node, nextNode) => `<blockquote>${await nextNode(node.content)}</blockquote>`, + aside: async (node, nextNode) => `<aside>${await nextNode(node.content)}</aside>`, + list: async (node, nextNode) => { const t = node.subType; if (t === 'unordered') { - return `<ul>${nextNode(node.content)}</ul>`; + return `<ul>${await nextNode(node.content)}</ul>`; } if (t === 'ordered') { - return `<ol>${nextNode(node.content)}</ol>`; + return `<ol>${await nextNode(node.content)}</ol>`; } }, - listItem: (node, nextNode) => `<li>${nextNode(node.content)}</li>`, - media: (node) => { + listItem: async (node, nextNode) => `<li>${await nextNode(node.content)}</li>`, + media: async (node) => { const t = node.subType; if (t === 'chart' && node.data.attachment) { if (node.data.attachment.creator === 'TOASTER') { @@ -129,7 +129,8 @@ const nodeRenderers = { if (t === 'video') { const h = node.data; const id = h.attachment && h.attachment.id; - return processVideo(id); + const v = await processVideo(id); + return v; } if (t === 'audio' && node.data.attachment) { const B = node.data.attachment; @@ -150,30 +151,38 @@ const nodeRenderers = { }, }; -const nodeToHtmlString = (node, obj) => { - const nextNode = (nodes) => nodeListToHtmlString(nodes); +const nodeToHtmlString = async (node, obj) => { + const nextNode = async (nodes) => { + const nodeStr = await nodeListToHtmlString(nodes); + return nodeStr; + }; if (!node.type || !nodeRenderers[node.type]) { return `<node>${node.type}</node>`; } - return nodeRenderers[node.type](node, nextNode, obj); + const str = await nodeRenderers[node.type](node, nextNode, obj); + return str; }; -const nodeListToHtmlString = (nodes) => - nodes - .map((node, index) => - nodeToHtmlString(node, { +const nodeListToHtmlString = async (nodes) => { + const res = await Promise.all( + nodes.map(async (node, index) => { + const str = await nodeToHtmlString(node, { index, prev: nodes[index - 1]?.type, next: nodes[index + 1]?.type, - }) - ) - .join(''); + }); + return str; + }) + ); + return res.join(''); +}; -const documentToHtmlString = (document) => { +const documentToHtmlString = async (document) => { if (!document || !document.content) { return ''; } - return nodeListToHtmlString(document.content); + const str = await nodeListToHtmlString(document.content); + return str; }; module.exports = { diff --git a/lib/v2/bloomberg/templates/image_figure.art b/lib/v2/bloomberg/templates/image_figure.art index 365bf7352b8d47..6925337512c34d 100644 --- a/lib/v2/bloomberg/templates/image_figure.art +++ b/lib/v2/bloomberg/templates/image_figure.art @@ -1,6 +1,6 @@ <figure> <img src="{{ src }}" alt="{{ alt }}" loading="lazy" style="display:block; margin-left:auto; margin-right:auto;" width:100%;> - {{if caption}} + {{if caption || credit}} <figcaption> <div class="caption">{{@ caption }}</div> <div class="credit">{{@ credit }}</div> diff --git a/lib/v2/bloomberg/utils.js b/lib/v2/bloomberg/utils.js index de8a76c24ab1dc..2f42ac910f1726 100644 --- a/lib/v2/bloomberg/utils.js +++ b/lib/v2/bloomberg/utils.js @@ -83,12 +83,12 @@ const parseArticle = (item, ctx) => .map((a) => a && a.groups)[0]; if (group) { const { page, link } = group; - if (apiEndpoints[page]) { const api = apiEndpoints[page]; - const apiUrl = `${api.url}${link}`; let res; + try { + const apiUrl = `${api.url}${link}`; res = await got(apiUrl, { headers }); } catch (err) { // fallback @@ -144,7 +144,7 @@ const parseNewsletterPage = async (res, api, item) => { title: story_json.headline || item.title, link: story_json.url || item.link, guid: `bloomberg:${story_json.id}`, - description: processHeadline(story_json) + (await processLedeMedia(story_json)) + documentToHtmlString(story_json.body || ''), + description: processHeadline(story_json) + (await processLedeMedia(story_json)) + (await documentToHtmlString(story_json.body || '')), pubDate: parseDate(story_json.publishedAt) || item.pubDate, author: story_json.authors?.map((a) => a.name).join(', ') ?? [], category: story_json.mostRelevantTags ?? [], @@ -283,7 +283,7 @@ const parseOtherPage = async function (res, api, item) { }; const processHeadline = (story_json) => { - const dek = story_json.dek || story_json.summary || ''; + const dek = story_json.dek || story_json.summary || story_json.headline || ''; const abs = story_json.abstract?.map((a) => `<li>${a}</li>`).join(''); return abs ? dek + `<ul>${abs}</ul>` : dek; }; @@ -312,8 +312,8 @@ const processLedeMedia = async (story_json) => { const attachment = Object.values(story_json.imageAttachments)[0]; if (attachment) { const image = { - src: attachment.baseUrl, - alt: attachment.alt, + src: attachment.baseUrl || attachment.url, + alt: attachment.alt || attachment.title, }; return art(path.join(__dirname, 'templates/image_figure.art'), image); }
52c887a2cb63db0be7f760836533c3632ecbdad2
2022-11-22 00:17:16
zxx-457
feat(route): add AIEA seminars (#11302)
false
add AIEA seminars (#11302)
feat
diff --git a/docs/en/study.md b/docs/en/study.md index 82b05fd628bafd..589148f79f6644 100644 --- a/docs/en/study.md +++ b/docs/en/study.md @@ -4,6 +4,20 @@ pageClass: routes # Study +## Asian Innovation and Entrepreneurship Association + +### Seminar Series + +<RouteEn author="zxx-457" example="/aiea/seminars/upcoming" path="/aiea/seminars/:period" :paramsDesc="['Time frame']"> + +| Time frame | +| ----- | +| upcoming | +| past | +| both| + +</RouteEn> + ## gradCafe ### gradCafe result diff --git a/docs/study.md b/docs/study.md index 4c565f9c813481..ae233e10a0ec44 100644 --- a/docs/study.md +++ b/docs/study.md @@ -37,12 +37,26 @@ pageClass: routes | bilingual | 双语新闻 (Bilingual News) | | address | 总统演讲 (President Address) | +## Asian Innovation and Entrepreneurship Association + +### Seminar Series + +<Route author="zxx-457" example="/aiea/seminars/upcoming" path="/aiea/seminars/:period" :paramsDesc="['时间段']"> + +| 时间段 | +| -------- | +| upcoming | +| past | +| both | + +</Route> + ## CTFHub Calendar ### 查询国内外 CTF 赛事信息 -<Route author="frankli0324" example="/ctfhub/search" -path="/ctfhub/search/:limit?/:form?/:class?/:title?" +<Route author="frankli0324" example="/ctfhub/search" +path="/ctfhub/search/:limit?/:form?/:class?/:title?" :paramsDesc="['一个整数,筛选最新的limit场比赛,默认为10', '比赛形式', '比赛类型', '通过CTF赛事名称过滤']"> | `:class` | 类型 | @@ -65,8 +79,8 @@ path="/ctfhub/search/:limit?/:form?/:class?/:title?" ### 查询近期赛事 -<Route author="frankli0324" example="/ctfhub/upcoming" -path="/ctfhub/upcoming/:limit?" +<Route author="frankli0324" example="/ctfhub/upcoming" +path="/ctfhub/upcoming/:limit?" :paramsDesc="['一个整数,筛选最近的limit场比赛,默认为5']"> </Route> diff --git a/lib/v2/aiea/index.js b/lib/v2/aiea/index.js new file mode 100644 index 00000000000000..a807a39ffd8314 --- /dev/null +++ b/lib/v2/aiea/index.js @@ -0,0 +1,39 @@ +const buildData = require('@/utils/common-config'); + +module.exports = async (ctx) => { + const link = 'http://www.aiea.org/0504'; + const period = ctx.params.period ?? ''; + + let nth_child = 'n'; + switch (period) { + case 'upcoming': + nth_child = '1'; + break; + + case 'past': + nth_child = '2'; + break; + + case 'both': + nth_child = 'n'; + break; + + default: + break; + } + + ctx.state.data = await buildData({ + link, + url: link, + title: `%title%`, + params: { + title: 'AIEA Seminars', + }, + item: { + item: `.seminar-contents .seminar-partWrap:nth-child(${nth_child}) > .seminar-list`, + title: `$('.seminar-list-title > span').text()`, + link: `$('a[href^="/0504"]').attr('href')`, + description: `$('.seminar-list .txt > .title').text()`, + }, + }); +}; diff --git a/lib/v2/aiea/maintainer.js b/lib/v2/aiea/maintainer.js new file mode 100644 index 00000000000000..75e1cf78ee126a --- /dev/null +++ b/lib/v2/aiea/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/seminars/:period': ['zxx-457'], +}; diff --git a/lib/v2/aiea/radar.js b/lib/v2/aiea/radar.js new file mode 100644 index 00000000000000..2dcbbd05dc41fb --- /dev/null +++ b/lib/v2/aiea/radar.js @@ -0,0 +1,13 @@ +module.exports = { + 'aiea.org': { + _name: 'Asian Innovation and Entrepreneurship Association', + www: [ + { + title: 'Seminar Series', + docs: 'https://docs.rsshub.app/study.html#AIEA-Seminar-Series', + source: ['/0504', '/'], + target: '/aiea/seminars/upcoming', + }, + ], + }, +}; diff --git a/lib/v2/aiea/router.js b/lib/v2/aiea/router.js new file mode 100644 index 00000000000000..129d36967383d6 --- /dev/null +++ b/lib/v2/aiea/router.js @@ -0,0 +1,3 @@ +module.exports = function (router) { + return router.get('/seminars/:period', require('.')); +};
ccad5e8f878eb2851d70cf3c9cac8ca60b5c18f5
2024-03-19 10:25:55
cnkmmk
fix(route): Fix 荒岛 (#14843)
false
Fix 荒岛 (#14843)
fix
diff --git a/lib/routes/lala/rss.ts b/lib/routes/lala/rss.ts index 9767abcec16c13..e574b561384b00 100644 --- a/lib/routes/lala/rss.ts +++ b/lib/routes/lala/rss.ts @@ -4,13 +4,14 @@ import { load } from 'cheerio'; export const route: Route = { path: '/', + categories: ['blog'], + example: '/lala', radar: [ { source: ['lala.im/'], - target: '', }, ], - name: 'Unknown', + name: '最新发布', maintainers: ['cnkmmk'], handler, url: 'lala.im/',
f917bdc654c35c94bd707a69d55681129c7f4aa0
2024-08-15 22:45:16
TheLittle_Yang
fix(route): devolverdigital no longer uses embedded json (#16440)
false
devolverdigital no longer uses embedded json (#16440)
fix
diff --git a/lib/routes/devolverdigital/blog.ts b/lib/routes/devolverdigital/blog.ts index fdcdae0735af13..dcc0a9d871ea1b 100644 --- a/lib/routes/devolverdigital/blog.ts +++ b/lib/routes/devolverdigital/blog.ts @@ -1,11 +1,10 @@ -import { Route } from '@/types'; -import cache from '@/utils/cache'; -import got from '@/utils/got'; +import { DataItem, Route } from '@/types'; import { load } from 'cheerio'; +import { ofetch } from 'ofetch'; export const route: Route = { path: '/blog', - categories: ['blog'], + categories: ['game'], example: '/devolverdigital/blog', parameters: {}, features: { @@ -28,44 +27,7 @@ export const route: Route = { }; async function handler() { - const baseUrl = 'https://www.devolverdigital.com/blog'; - const { data: response } = await got(baseUrl); - - const $ = load(response); - const nextData = JSON.parse($('#__NEXT_DATA__').text()); - - const items = await Promise.all( - nextData.props.pageProps.posts.map((postData) => { - const postUrl = `${baseUrl}/post/${postData.id}`; - return cache.tryGet(postUrl, async () => { - const { data: postPage } = await got(postUrl); - - const $page = load(postPage); - $page('noscript').remove(); - const postContent = $page('div.flex > div > div > div > div:not([class])'); - - // img resource redirection and - // clean up absolute layouts for img and span - const imageUrls = postData.body.filter((item) => item.type === 'upload' && item.value.cloudinary.resource_type === 'image').map((item) => item.value.cloudinary.secure_url); - const allImageSpans = postContent.find('span > img').parent(); - allImageSpans.each((spanIndex, span) => { - $(span).attr('style', $(span).attr('style').replace('position:absolute', '')); - const img = $(span).find('img'); - img.attr('src', imageUrls[spanIndex]); - img.attr('style', img.attr('style').replace('position:absolute', '').replace('width:0', '').replace('height:0', '')); - }); - - return { - title: postData.title, - link: postUrl, - author: postData.author, - pubDate: Date.parse(postData.createdAt), - updated: Date.parse(postData.updatedAt), - description: postContent.html(), - }; - }); - }) - ); + const items = await fetchPage(); return { title: 'DevolverDigital Blog', @@ -74,3 +36,58 @@ async function handler() { item: items, }; } + +async function fetchPage() { + const baseUrl = 'https://www.devolverdigital.com/blog'; + const response = await ofetch(baseUrl); + const $ = load(response, { scriptingEnabled: false }); + + // Extract all posts of this page + const $titleDivs = $('div.w-full.flex.justify-center.py-4.bg-red-400.undefined'); + const $contentDivs = $('div.bg-gray-800.flex.justify-center.font-sm.py-4'); + const items: DataItem[] = $titleDivs.toArray().map((titleDiv, index) => { + const content = $contentDivs[index]; + const postAuthor = parsePostAuthor($, titleDiv); + const postDate = parsePostDate($, titleDiv); + const postTitle = $(titleDiv).find('h1').text(); + const postLink = $(content).find('div.ml-auto.flex.items-center a').attr('href'); + // Modify the src attribute of the image + parsePostImages($, content); + const postContent = $.html($(content).find('div.cms-content')); + return { + title: postTitle, + link: postLink, + author: postAuthor, + pubDate: postDate, + description: postContent, + }; + }); + + return items; +} + +function parsePostAuthor($, titleDiv) { + const $postAuthorElement = $(titleDiv).find('div.font-xs.leading-none.mb-1'); + return $postAuthorElement.text().replace('By ', '') || 'Devolver Digital'; +} + +function parsePostDate($, titleDiv) { + const dateStr = $(titleDiv).find('div.font-2xs.leading-none.mb-1').text(); + const cleanedDateStr = dateStr.replace(/(\d+)(st|nd|rd|th)/, '$1'); + return new Date(cleanedDateStr); +} + +function parsePostImages($, content) { + $(content) + .find('img') + .each((index, img) => { + const $img = $(img); + const src = $img.attr('src') || ''; + if (src.startsWith('/_next/image')) { + const srcSet = $img.attr('srcset') || ''; + const actualSrc = srcSet.split(',').pop()?.split(' ')[0] || src; + $img.attr('src', actualSrc); + } + $img.removeAttr('loading').removeAttr('decoding').removeAttr('data-nimg').removeAttr('style').removeAttr('sizes').removeAttr('srcset').removeAttr('referrerpolicy'); + }); +}
71f65a51fe03420482eb7c938f7a0e66cfc142db
2023-04-25 15:49:11
Evan
fix: duplicate guid for each device (#12387)
false
duplicate guid for each device (#12387)
fix
diff --git a/lib/v2/amazon/kindle-software-updates.js b/lib/v2/amazon/kindle-software-updates.js index fa8965490f3e6d..5306112b69029e 100644 --- a/lib/v2/amazon/kindle-software-updates.js +++ b/lib/v2/amazon/kindle-software-updates.js @@ -41,6 +41,7 @@ module.exports = async (ctx) => { art(path.join(__dirname, 'templates/software-description.art'), { item, }), + guid: item.title + ' - ' + item.version, link: item.link, })), };
acb25bf3a6c505c52d4bbf62e1d504a743321203
2024-03-19 10:59:20
Tony
fix: don't start TG client unless routes are requested
false
don't start TG client unless routes are requested
fix
diff --git a/lib/routes/telegram/tglib/channel.ts b/lib/routes/telegram/tglib/channel.ts index 41c61e50342da2..1c4f0947332ef2 100644 --- a/lib/routes/telegram/tglib/channel.ts +++ b/lib/routes/telegram/tglib/channel.ts @@ -1,6 +1,4 @@ -import wait from '@/utils/wait'; -import { config } from '@/config'; -import { client, decodeMedia, getFilename, getMediaLink, streamDocument, streamThumbnail } from './client'; +import { client, decodeMedia, getClient, getFilename, getMediaLink, streamDocument, streamThumbnail } from './client'; import { returnBigInt as bigInt } from 'telegram/Helpers'; import { HTMLParser } from 'telegram/extensions/html'; @@ -111,13 +109,8 @@ async function getMedia(ctx) { return ctx.res.end(); } -export default async (ctx) => { - if (!config.telegram.session) { - return []; - } - if (!client.connected) { - await wait(1000); - } +export default async function handler(ctx) { + const client = await getClient(); const item = []; const chat = await client.getInputEntity(ctx.req.param('username')); @@ -160,6 +153,6 @@ export default async (ctx) => { allowEmpty: ctx.req.param('id') === 'allow_empty', description: `@${channelInfo.username} on Telegram`, }; -}; +} export { getMedia }; diff --git a/lib/routes/telegram/tglib/client.ts b/lib/routes/telegram/tglib/client.ts index 47b40673e878bf..d135afb4587636 100644 --- a/lib/routes/telegram/tglib/client.ts +++ b/lib/routes/telegram/tglib/client.ts @@ -1,27 +1,37 @@ import readline from 'node:readline/promises'; import { Api, TelegramClient } from 'telegram'; +import { UserAuthParams } from 'telegram/client/auth'; import { StringSession } from 'telegram/sessions'; import { getAppropriatedPartSize } from 'telegram/Utils'; import { config } from '@/config'; -const apiId = Number(config.telegram.apiId ?? 4); -const apiHash = config.telegram.apiHash ?? '014b35b6184100b085b0d0572f9b5103'; - -const stringSession = new StringSession(config.telegram.session); -const client = new TelegramClient(stringSession, apiId, apiHash, { - connectionRetries: Infinity, - autoReconnect: true, - retryDelay: 3000, - maxConcurrentDownloads: Number(config.telegram.maxConcurrentDownloads ?? 10), -}); - -if (config.telegram.session) { - client.start({ - onError: (err) => { - throw 'Cannot start TG: ' + err; - }, +let client: TelegramClient | undefined; +export async function getClient(authParams?: UserAuthParams, session?: string) { + if (!config.telegram.session && session === undefined) { + throw new Error('TELEGRAM_SESSION is not configured'); + } + if (client) { + return client; + } + const apiId = Number(config.telegram.apiId ?? 4); + const apiHash = config.telegram.apiHash ?? '014b35b6184100b085b0d0572f9b5103'; + + const stringSession = new StringSession(session ?? config.telegram.session); + client = new TelegramClient(stringSession, apiId, apiHash, { + connectionRetries: Infinity, + autoReconnect: true, + retryDelay: 3000, + maxConcurrentDownloads: Number(config.telegram.maxConcurrentDownloads ?? 10), }); + await client.start( + Object.assign(authParams ?? {}, { + onError: (err) => { + throw new Error('Cannot start TG: ' + err); + }, + }) as any + ); + return client; } function humanFileSize(size) { @@ -180,15 +190,17 @@ export { client, getMediaLink, decodeMedia, getFilename, streamDocument, streamT if (require.main === module) { Promise.resolve().then(async () => { - client.session = new StringSession(''); const rl = readline.createInterface({ input: process.stdin, output: process.stdout }); - await client.start({ - phoneNumber: () => rl.question('Please enter your number: '), - password: () => rl.question('Please enter your password: '), - phoneCode: () => rl.question('Please enter the code you received: '), - onError: (err) => process.stderr.write(err), - }); - process.stdout.write(`TG_SESSION=${client.session.save()}\n`); + const client = await getClient( + { + phoneNumber: () => rl.question('Please enter your phone number: '), + password: () => rl.question('Please enter your password: '), + phoneCode: () => rl.question('Please enter the code you received: '), + onError: (err) => process.stderr.write(err.toString()), + }, + '' + ); + process.stdout.write(`TELEGRAM_SESSION=${client.session.save()}\n`); process.exit(0); }); }
b5cf64f656dc17e7ed166b0b2771d1eb51b8f60d
2022-12-07 02:36:53
dependabot[bot]
chore(deps-dev): bump @vercel/nft from 0.22.1 to 0.22.5 (#11395)
false
bump @vercel/nft from 0.22.1 to 0.22.5 (#11395)
chore
diff --git a/package.json b/package.json index bf4a0ab5d4e5c1..9b711465307641 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "devDependencies": { "@napi-rs/pinyin": "1.7.1", "@types/koa": "2.13.5", - "@vercel/nft": "0.22.1", + "@vercel/nft": "0.22.5", "@vuepress/plugin-back-to-top": "1.9.7", "@vuepress/plugin-google-analytics": "1.9.7", "@vuepress/plugin-pwa": "1.9.7", diff --git a/yarn.lock b/yarn.lock index fccc31e84e4b6e..e8df0463573820 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1530,6 +1530,14 @@ dependencies: safe-buffer "^5.0.1" +"@rollup/pluginutils@^4.0.0": + version "4.2.1" + resolved "https://registry.yarnpkg.com/@rollup/pluginutils/-/pluginutils-4.2.1.tgz#e6c6c3aba0744edce3fb2074922d3776c0af2a6d" + integrity sha512-iKnFXr7NkdZAIHiIWE+BX5ULi/ucVFYWD6TbAV+rZctiRTY2PL6tsIKhoIOaoskiWAkgu+VsbXgUVDNLHf+InQ== + dependencies: + estree-walker "^2.0.1" + picomatch "^2.2.2" + "@selderee/plugin-htmlparser2@^0.6.0": version "0.6.0" resolved "https://registry.yarnpkg.com/@selderee/plugin-htmlparser2/-/plugin-htmlparser2-0.6.0.tgz#27e994afd1c2cb647ceb5406a185a5574188069d" @@ -2052,12 +2060,13 @@ dependencies: "@types/node" "*" -"@vercel/[email protected]": - version "0.22.1" - resolved "https://registry.yarnpkg.com/@vercel/nft/-/nft-0.22.1.tgz#0d91d2a21e3a7f0b23ce1550da9870eac4942828" - integrity sha512-lYYZIoxRurqDOSoVIdBicGnpUIpfyaS5qVjdPq+EfI285WqtZK3NK/dyCkiyBul+X2U2OEhRyeMdXPCHGJbohw== +"@vercel/[email protected]": + version "0.22.5" + resolved "https://registry.yarnpkg.com/@vercel/nft/-/nft-0.22.5.tgz#951bd7589ceebdd3e280afcf3a13bdacf83f6b7e" + integrity sha512-mug57Wd1BL7GMj9gXMgMeKUjdqO0e4u+0QLPYMFE1rwdJ+55oPy6lp3nIBCS8gOvigT62UI4QKUL2sGqcoW4Hw== dependencies: "@mapbox/node-pre-gyp" "^1.0.5" + "@rollup/pluginutils" "^4.0.0" acorn "^8.6.0" async-sema "^3.1.1" bindings "^1.4.0" @@ -2067,7 +2076,6 @@ micromatch "^4.0.2" node-gyp-build "^4.2.2" resolve-from "^5.0.0" - rollup-pluginutils "^2.8.2" "@vue/babel-helper-vue-jsx-merge-props@^1.4.0": version "1.4.0" @@ -5759,16 +5767,11 @@ estraverse@^5.1.0, estraverse@^5.2.0: resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-5.3.0.tgz#2eea5290702f26ab8fe5370370ff86c965d21123" integrity sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA== [email protected]: [email protected], estree-walker@^2.0.1: version "2.0.2" resolved "https://registry.yarnpkg.com/estree-walker/-/estree-walker-2.0.2.tgz#52f010178c2a4c117a7757cfe942adb7d2da4cac" integrity sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w== -estree-walker@^0.6.1: - version "0.6.1" - resolved "https://registry.yarnpkg.com/estree-walker/-/estree-walker-0.6.1.tgz#53049143f40c6eb918b23671d1fe3219f3a1b362" - integrity sha512-SqmZANLWS0mnatqbSfRP5g8OXZC12Fgg1IwNtLsyHDzJizORW4khDfjPqJZsemPWBB2uqykUah5YpQ6epsqC/w== - esutils@^2.0.2: version "2.0.3" resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.3.tgz#74d2eb4de0b8da1293711910d50775b9b710ef64" @@ -10726,7 +10729,7 @@ picocolors@^1.0.0: resolved "https://registry.yarnpkg.com/picocolors/-/picocolors-1.0.0.tgz#cb5bdc74ff3f51892236eaf79d68bc44564ab81c" integrity sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ== -picomatch@^2.0.4, picomatch@^2.2.1, picomatch@^2.2.3, picomatch@^2.3.1: +picomatch@^2.0.4, picomatch@^2.2.1, picomatch@^2.2.2, picomatch@^2.2.3, picomatch@^2.3.1: version "2.3.1" resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.3.1.tgz#3ba3833733646d9d3e4995946c1365a67fb07a42" integrity sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA== @@ -12094,13 +12097,6 @@ ripemd160@^2.0.0, ripemd160@^2.0.1: hash-base "^3.0.0" inherits "^2.0.1" -rollup-pluginutils@^2.8.2: - version "2.8.2" - resolved "https://registry.yarnpkg.com/rollup-pluginutils/-/rollup-pluginutils-2.8.2.tgz#72f2af0748b592364dbd3389e600e5a9444a351e" - integrity sha512-EEp9NhnUkwY8aif6bxgovPHMoMoNr2FulJziTndpt5H9RdwC47GSGuII9XxpSdzVGM0GWrNPHV6ie1LTNJPaLQ== - dependencies: - estree-walker "^0.6.1" - [email protected]: version "3.12.0" resolved "https://registry.yarnpkg.com/rss-parser/-/rss-parser-3.12.0.tgz#b8888699ea46304a74363fbd8144671b2997984c"
373b598100b5e4a3ea7406ada9c146b6703257ab
2024-04-13 09:01:01
ubbcou
feat: add OpenGithub - Github开源项目月刊精选 (#15181)
false
add OpenGithub - Github开源项目月刊精选 (#15181)
feat
diff --git a/lib/routes/itc/collection.ts b/lib/routes/itc/collection.ts new file mode 100644 index 00000000000000..9487149d32df59 --- /dev/null +++ b/lib/routes/itc/collection.ts @@ -0,0 +1,66 @@ +import { DataItem, Route } from '@/types'; +import ofetch from '@/utils/ofetch'; +import { load } from 'cheerio'; + +/** + * OpenGithub - Github开源项目精选 + * colType:0 | 1 | 2 | 3 + */ + +enum COL_TYPE { + HANDPICK, + SPECIAL, + WEEKLY, + MONTHLY, +} + +const RESULT_DESC_MAP = { + [COL_TYPE.HANDPICK]: 'OpenGithub - Github开源项目精选 - 精选文章', + [COL_TYPE.SPECIAL]: 'OpenGithub - Github开源项目精选 - 专栏', + [COL_TYPE.WEEKLY]: 'OpenGithub - Github开源项目精选 - 周刊', + [COL_TYPE.MONTHLY]: 'OpenGithub - Github开源项目精选 - 月刊', +}; + +export const route: Route = { + path: '/collection/:colType', + categories: ['blog'], + example: '/itc/collection/1', + radar: [ + { + source: ['open.itc.cn/'], + }, + ], + name: '合集', + maintainers: ['cnkmmk'], + handler, +}; + +async function handler(ctx) { + const url = 'https://open.itc.cn'; + + const colType = ctx.req.param('colType'); + + const result = { + title: RESULT_DESC_MAP[colType] ?? 'NULL', + link: url, + description: RESULT_DESC_MAP[colType] ?? 'NULL', + item: [] as DataItem[], + }; + const response = await ofetch(`${url}/github/collection/list?colType=${colType}`); + const $ = load(response); + + result.item = [...$('.tab-pane > .row > .card')].map((item) => { + const date = $(item).find('.d-flex.mt-3.ms-sm-auto').text()?.split(':')?.[1]; + const dataObject = date ? new Date(date) : undefined; + + return { + title: $(item).find('a.btn-link').text(), + description: $(item).find('.d-sm-inline-block').text(), + link: $(item).find('a.btn-link').attr('href') || '', + pubDate: dataObject, + category: [...$(item).find('.nav.nav-stack.small li')].map((sub) => $(sub).find('.badge').text()), + }; + }); + + return result; +} diff --git a/lib/routes/itc/namespace.ts b/lib/routes/itc/namespace.ts new file mode 100644 index 00000000000000..436bb50fc3dea0 --- /dev/null +++ b/lib/routes/itc/namespace.ts @@ -0,0 +1,6 @@ +import type { Namespace } from '@/types'; + +export const namespace: Namespace = { + name: 'Open Github社区', + url: 'open.itc.cn', +};
7b85955fe227455a85edafb3672669a822619db6
2019-01-20 19:47:17
DIYgod
rss: supply weibo headers
false
supply weibo headers
rss
diff --git a/lib/routes/weibo/keyword.js b/lib/routes/weibo/keyword.js index d1cc0238b3ea5c..7bfce7aa4a06d1 100644 --- a/lib/routes/weibo/keyword.js +++ b/lib/routes/weibo/keyword.js @@ -10,6 +10,9 @@ module.exports = async (ctx) => { url: `https://m.weibo.cn/api/container/getIndex?containerid=100103type%3D61%26q%3D${encodeURIComponent(keyword)}%26t%3D0`, headers: { Referer: `https://m.weibo.cn/p/searchall?containerid=100103type%3D1%26q%3D${encodeURIComponent(keyword)}`, + 'MWeibo-Pwa': 1, + 'X-Requested-With': 'XMLHttpRequest', + 'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1', }, }); const data = response.data.data.cards[0].card_group; diff --git a/lib/routes/weibo/search/hot.js b/lib/routes/weibo/search/hot.js index 49453089d0d328..471b2343178adf 100644 --- a/lib/routes/weibo/search/hot.js +++ b/lib/routes/weibo/search/hot.js @@ -7,6 +7,12 @@ module.exports = async (ctx) => { method: 'get', url: 'https://m.weibo.cn/api/container/getIndex?containerid=106003type%3D25%26t%3D3%26disable_hot%3D1%26filter_type%3Drealtimehot&title=%E5%BE%AE%E5%8D%9A%E7%83%AD%E6%90%9C&extparam=filter_type%3Drealtimehot%26mi_cid%3D100103%26pos%3D0_0%26c_type%3D30%26display_time%3D1540538388&luicode=10000011&lfid=231583', + headers: { + Referer: 'https://s.weibo.com/top/summary?cate=realtimehot', + 'MWeibo-Pwa': 1, + 'X-Requested-With': 'XMLHttpRequest', + 'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1', + }, }); ctx.state.data = { diff --git a/lib/routes/weibo/user.js b/lib/routes/weibo/user.js index 85e8d108fe17c7..c2f47589e070c1 100644 --- a/lib/routes/weibo/user.js +++ b/lib/routes/weibo/user.js @@ -20,6 +20,9 @@ module.exports = async (ctx) => { url: `https://m.weibo.cn/api/container/getIndex?type=uid&value=${uid}&containerid=${containerid}`, headers: { Referer: `https://m.weibo.cn/u/${uid}`, + 'MWeibo-Pwa': 1, + 'X-Requested-With': 'XMLHttpRequest', + 'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1', }, });
0d48f667b9b4d37e8e25dfd375b1553e92cfec10
2025-02-10 14:03:34
dependabot[bot]
chore(deps-dev): bump @babel/preset-env from 7.26.7 to 7.26.8 (#18312)
false
bump @babel/preset-env from 7.26.7 to 7.26.8 (#18312)
chore
diff --git a/package.json b/package.json index c9b5054b172cfe..a839faecfd7385 100644 --- a/package.json +++ b/package.json @@ -138,7 +138,7 @@ "zod": "3.24.1" }, "devDependencies": { - "@babel/preset-env": "7.26.7", + "@babel/preset-env": "7.26.8", "@babel/preset-typescript": "7.26.0", "@bbob/types": "4.2.0", "@eslint/eslintrc": "3.2.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b7fb70d1b608d5..939c5f85d0eeb3 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -277,8 +277,8 @@ importers: version: 3.24.1 devDependencies: '@babel/preset-env': - specifier: 7.26.7 - version: 7.26.7(@babel/[email protected]) + specifier: 7.26.8 + version: 7.26.8(@babel/[email protected]) '@babel/preset-typescript': specifier: 7.26.0 version: 7.26.0(@babel/[email protected]) @@ -472,8 +472,8 @@ packages: resolution: {integrity: sha512-RJlIHRueQgwWitWgF8OdFYGZX328Ax5BCemNGlqHfplnRT9ESi8JkFlvaVYbS+UubVY6dpv87Fs2u5M29iNFVQ==} engines: {node: '>=6.9.0'} - '@babel/[email protected]': - resolution: {integrity: sha512-XvcZi1KWf88RVbF9wn8MN6tYFloU5qX8KjuF3E1PVBmJ9eypXfs4GRiJwLuTZL0iSnJUKn1BFPa5BPZZJyFzPg==} + '@babel/[email protected]': + resolution: {integrity: sha512-oH5UPLMWR3L2wEFLnFJ1TZXqHufiTKAiLfqw5zkhS4dKXLJ10yVztfil/twG8EDTA4F/tvVNw9nOl4ZMslB8rQ==} engines: {node: '>=6.9.0'} '@babel/[email protected]': @@ -657,8 +657,8 @@ packages: peerDependencies: '@babel/core': ^7.0.0-0 - '@babel/[email protected]': - resolution: {integrity: sha512-RXV6QAzTBbhDMO9fWwOmwwTuYaiPbggWQ9INdZqAYeSHyG7FzQ+nOZaUUjNwKv9pV3aE4WFqFm1Hnbci5tBCAw==} + '@babel/[email protected]': + resolution: {integrity: sha512-He9Ej2X7tNf2zdKMAGOsmg2MrFc+hfoAhd3po4cWfo/NWjzEAKa0oQruj1ROVUdl0e6fb6/kE/G3SSxE0lRJOg==} engines: {node: '>=6.9.0'} peerDependencies: '@babel/core': ^7.0.0-0 @@ -915,8 +915,8 @@ packages: peerDependencies: '@babel/core': ^7.0.0-0 - '@babel/[email protected]': - resolution: {integrity: sha512-o97AE4syN71M/lxrCtQByzphAdlYluKPDBzDVzMmfCobUjjhAryZV0AIpRPrxN0eAkxXO6ZLEScmt+PNhj2OTw==} + '@babel/[email protected]': + resolution: {integrity: sha512-OmGDL5/J0CJPJZTHZbi2XpO0tyT2Ia7fzpW5GURwdtp2X3fMmN8au/ej6peC/T33/+CRiIpA8Krse8hFGVmT5Q==} engines: {node: '>=6.9.0'} peerDependencies: '@babel/core': ^7.0.0-0 @@ -957,8 +957,8 @@ packages: peerDependencies: '@babel/core': ^7.0.0 - '@babel/[email protected]': - resolution: {integrity: sha512-Ycg2tnXwixaXOVb29rana8HNPgLVBof8qqtNQ9LE22IoyZboQbGSxI6ZySMdW3K5nAe6gu35IaJefUJflhUFTQ==} + '@babel/[email protected]': + resolution: {integrity: sha512-um7Sy+2THd697S4zJEfv/U5MHGJzkN2xhtsR3T/SWRbVSic62nbISh51VVfU9JiO/L/Z97QczHTaFVkOU8IzNg==} engines: {node: '>=6.9.0'} peerDependencies: '@babel/core': ^7.0.0-0 @@ -982,8 +982,8 @@ packages: resolution: {integrity: sha512-AOPI3D+a8dXnja+iwsUqGRjr1BbZIe771sXdapOtYI531gSqpi92vXivKcq2asu/DFpdl1ceFAKZyRzK2PCVcQ==} engines: {node: '>=6.9.0'} - '@babel/[email protected]': - resolution: {integrity: sha512-9DGttpmPvIxBb/2uwpVo3dqJ+O6RooAFOS+lB+xDqoE2PVCE8nfoHMdZLpfCQRLwvohzXISPZcgxt80xLfsuwg==} + '@babel/[email protected]': + resolution: {integrity: sha512-iNKaX3ZebKIsCvJ+0jd6embf+Aulaa3vNBqZ41kM7iTWjx5qzWKXGHiJUW3+nTpQ18SG11hdF8OAzKrpXkb96Q==} engines: {node: '>=6.9.0'} '@babel/[email protected]': @@ -2286,8 +2286,8 @@ packages: peerDependencies: '@babel/core': ^7.4.0 || ^8.0.0-0 <8.0.0 - [email protected]: - resolution: {integrity: sha512-b37+KR2i/khY5sKmWNVQAnitvquQbNdWy6lJdsr0kmquCKEEUgMKK4SboVM3HtfnZilfjr4MMQ7vY58FVWDtIA==} + [email protected]: + resolution: {integrity: sha512-yGCqvBT4rwMczo28xkH/noxJ6MZ4nJfkVYdoDaC/utLtWrXxv27HVrzAeSbqR8SxDsp46n0YF47EbHoixy6rXQ==} peerDependencies: '@babel/core': ^7.4.0 || ^8.0.0-0 <8.0.0 @@ -2430,8 +2430,8 @@ packages: resolution: {integrity: sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==} engines: {node: '>=10'} - [email protected]: - resolution: {integrity: sha512-GwNPlWJin8E+d7Gxq96jxM6w0w+VFeyyXRsjU58emtkYqnbwHqXm5uT2uCmO0RQE9htWknOP4xtBlLmM/gWxvQ==} + [email protected]: + resolution: {integrity: sha512-b+uH5BakXZ9Do9iK+CkDmctUSEqZl+SP056vc5usa0PL+ev5OHw003rZXcnjNDv3L8P5j6rwT6C0BPKSikW08w==} [email protected]: resolution: {integrity: sha512-4tYFyifaFfGacoiObjJegolkwSU4xQNGbVgUiNYVUxbQ2x2lUsFvY4hVgVzGiIe6WLOPqycWXA40l+PWsxthUw==} @@ -2872,8 +2872,8 @@ packages: engines: {node: '>=14'} hasBin: true - [email protected]: - resolution: {integrity: sha512-sNSHHyq048PFmZY4S90ax61q+gLCs0X0YmcOII9wG9S2XwbVr+h4VW2wWhnbp/Eys3cCwTxVF292W3qPaxIapQ==} + [email protected]: + resolution: {integrity: sha512-8AJUW6dh75Fm/ny8+kZKJzI1pgoE8bKLZlzDU2W1ENd+DXKJrx7I7l9hb8UWR4ojlnb5OlixMt00QWiYJoVw1w==} [email protected]: resolution: {integrity: sha512-5gxbEjcb/Z2n6TTmXZx9wVi3N/DOzE7RXY3Xg9dakDuhX/izwumB9rGjeWUV6dTA0D0+juvo+JonZgNR9sgA5A==} @@ -5814,7 +5814,7 @@ snapshots: js-tokens: 4.0.0 picocolors: 1.1.1 - '@babel/[email protected]': {} + '@babel/[email protected]': {} '@babel/[email protected]': dependencies: @@ -5838,8 +5838,16 @@ snapshots: '@babel/[email protected]': dependencies: - '@babel/parser': 7.26.7 - '@babel/types': 7.26.7 + '@babel/parser': 7.26.8 + '@babel/types': 7.26.8 + '@jridgewell/gen-mapping': 0.3.8 + '@jridgewell/trace-mapping': 0.3.25 + jsesc: 3.1.0 + + '@babel/[email protected]': + dependencies: + '@babel/parser': 7.26.8 + '@babel/types': 7.26.8 '@jridgewell/gen-mapping': 0.3.8 '@jridgewell/trace-mapping': 0.3.25 jsesc: 3.1.0 @@ -5858,7 +5866,7 @@ snapshots: '@babel/[email protected]': dependencies: - '@babel/compat-data': 7.26.5 + '@babel/compat-data': 7.26.8 '@babel/helper-validator-option': 7.25.9 browserslist: 4.24.4 lru-cache: 5.1.1 @@ -5897,15 +5905,15 @@ snapshots: '@babel/[email protected]': dependencies: - '@babel/traverse': 7.26.7 - '@babel/types': 7.26.7 + '@babel/traverse': 7.26.8 + '@babel/types': 7.26.8 transitivePeerDependencies: - supports-color '@babel/[email protected]': dependencies: - '@babel/traverse': 7.26.7 - '@babel/types': 7.26.7 + '@babel/traverse': 7.26.8 + '@babel/types': 7.26.8 transitivePeerDependencies: - supports-color @@ -5914,13 +5922,13 @@ snapshots: '@babel/core': 7.26.7 '@babel/helper-module-imports': 7.25.9 '@babel/helper-validator-identifier': 7.25.9 - '@babel/traverse': 7.26.7 + '@babel/traverse': 7.26.8 transitivePeerDependencies: - supports-color '@babel/[email protected]': dependencies: - '@babel/types': 7.26.7 + '@babel/types': 7.26.8 '@babel/[email protected]': {} @@ -5929,7 +5937,7 @@ snapshots: '@babel/core': 7.26.7 '@babel/helper-annotate-as-pure': 7.25.9 '@babel/helper-wrap-function': 7.25.9 - '@babel/traverse': 7.26.7 + '@babel/traverse': 7.26.8 transitivePeerDependencies: - supports-color @@ -5938,7 +5946,7 @@ snapshots: '@babel/core': 7.26.7 '@babel/helper-member-expression-to-functions': 7.25.9 '@babel/helper-optimise-call-expression': 7.25.9 - '@babel/traverse': 7.26.7 + '@babel/traverse': 7.26.8 transitivePeerDependencies: - supports-color @@ -5957,9 +5965,9 @@ snapshots: '@babel/[email protected]': dependencies: - '@babel/template': 7.25.9 - '@babel/traverse': 7.26.7 - '@babel/types': 7.26.7 + '@babel/template': 7.26.8 + '@babel/traverse': 7.26.8 + '@babel/types': 7.26.8 transitivePeerDependencies: - supports-color @@ -5977,7 +5985,11 @@ snapshots: '@babel/[email protected]': dependencies: - '@babel/types': 7.26.7 + '@babel/types': 7.26.8 + + '@babel/[email protected]': + dependencies: + '@babel/types': 7.26.8 '@babel/[email protected]': dependencies: @@ -5987,7 +5999,7 @@ snapshots: dependencies: '@babel/core': 7.26.7 '@babel/helper-plugin-utils': 7.26.5 - '@babel/traverse': 7.26.7 + '@babel/traverse': 7.26.8 transitivePeerDependencies: - supports-color @@ -6014,7 +6026,7 @@ snapshots: dependencies: '@babel/core': 7.26.7 '@babel/helper-plugin-utils': 7.26.5 - '@babel/traverse': 7.26.7 + '@babel/traverse': 7.26.8 transitivePeerDependencies: - supports-color @@ -6053,12 +6065,12 @@ snapshots: '@babel/core': 7.26.7 '@babel/helper-plugin-utils': 7.26.5 - '@babel/[email protected](@babel/[email protected])': + '@babel/[email protected](@babel/[email protected])': dependencies: '@babel/core': 7.26.7 '@babel/helper-plugin-utils': 7.26.5 '@babel/helper-remap-async-to-generator': 7.25.9(@babel/[email protected]) - '@babel/traverse': 7.26.7 + '@babel/traverse': 7.26.8 transitivePeerDependencies: - supports-color @@ -6104,7 +6116,7 @@ snapshots: '@babel/helper-compilation-targets': 7.26.5 '@babel/helper-plugin-utils': 7.26.5 '@babel/helper-replace-supers': 7.26.5(@babel/[email protected]) - '@babel/traverse': 7.26.7 + '@babel/traverse': 7.26.8 globals: 11.12.0 transitivePeerDependencies: - supports-color @@ -6113,7 +6125,7 @@ snapshots: dependencies: '@babel/core': 7.26.7 '@babel/helper-plugin-utils': 7.26.5 - '@babel/template': 7.25.9 + '@babel/template': 7.26.8 '@babel/[email protected](@babel/[email protected])': dependencies: @@ -6165,7 +6177,7 @@ snapshots: '@babel/core': 7.26.7 '@babel/helper-compilation-targets': 7.26.5 '@babel/helper-plugin-utils': 7.26.5 - '@babel/traverse': 7.26.7 + '@babel/traverse': 7.26.8 transitivePeerDependencies: - supports-color @@ -6211,7 +6223,7 @@ snapshots: '@babel/helper-module-transforms': 7.26.0(@babel/[email protected]) '@babel/helper-plugin-utils': 7.26.5 '@babel/helper-validator-identifier': 7.25.9 - '@babel/traverse': 7.26.7 + '@babel/traverse': 7.26.8 transitivePeerDependencies: - supports-color @@ -6334,7 +6346,7 @@ snapshots: '@babel/core': 7.26.7 '@babel/helper-plugin-utils': 7.26.5 - '@babel/[email protected](@babel/[email protected])': + '@babel/[email protected](@babel/[email protected])': dependencies: '@babel/core': 7.26.7 '@babel/helper-plugin-utils': 7.26.5 @@ -6378,9 +6390,9 @@ snapshots: '@babel/helper-create-regexp-features-plugin': 7.26.3(@babel/[email protected]) '@babel/helper-plugin-utils': 7.26.5 - '@babel/[email protected](@babel/[email protected])': + '@babel/[email protected](@babel/[email protected])': dependencies: - '@babel/compat-data': 7.26.5 + '@babel/compat-data': 7.26.8 '@babel/core': 7.26.7 '@babel/helper-compilation-targets': 7.26.5 '@babel/helper-plugin-utils': 7.26.5 @@ -6395,7 +6407,7 @@ snapshots: '@babel/plugin-syntax-import-attributes': 7.26.0(@babel/[email protected]) '@babel/plugin-syntax-unicode-sets-regex': 7.18.6(@babel/[email protected]) '@babel/plugin-transform-arrow-functions': 7.25.9(@babel/[email protected]) - '@babel/plugin-transform-async-generator-functions': 7.25.9(@babel/[email protected]) + '@babel/plugin-transform-async-generator-functions': 7.26.8(@babel/[email protected]) '@babel/plugin-transform-async-to-generator': 7.25.9(@babel/[email protected]) '@babel/plugin-transform-block-scoped-functions': 7.26.5(@babel/[email protected]) '@babel/plugin-transform-block-scoping': 7.25.9(@babel/[email protected]) @@ -6438,7 +6450,7 @@ snapshots: '@babel/plugin-transform-shorthand-properties': 7.25.9(@babel/[email protected]) '@babel/plugin-transform-spread': 7.25.9(@babel/[email protected]) '@babel/plugin-transform-sticky-regex': 7.25.9(@babel/[email protected]) - '@babel/plugin-transform-template-literals': 7.25.9(@babel/[email protected]) + '@babel/plugin-transform-template-literals': 7.26.8(@babel/[email protected]) '@babel/plugin-transform-typeof-symbol': 7.26.7(@babel/[email protected]) '@babel/plugin-transform-unicode-escapes': 7.25.9(@babel/[email protected]) '@babel/plugin-transform-unicode-property-regex': 7.25.9(@babel/[email protected]) @@ -6446,7 +6458,7 @@ snapshots: '@babel/plugin-transform-unicode-sets-regex': 7.25.9(@babel/[email protected]) '@babel/preset-modules': 0.1.6-no-external-plugins(@babel/[email protected]) babel-plugin-polyfill-corejs2: 0.4.12(@babel/[email protected]) - babel-plugin-polyfill-corejs3: 0.10.6(@babel/[email protected]) + babel-plugin-polyfill-corejs3: 0.11.1(@babel/[email protected]) babel-plugin-polyfill-regenerator: 0.6.3(@babel/[email protected]) core-js-compat: 3.40.0 semver: 6.3.1 @@ -6457,7 +6469,7 @@ snapshots: dependencies: '@babel/core': 7.26.7 '@babel/helper-plugin-utils': 7.26.5 - '@babel/types': 7.26.7 + '@babel/types': 7.26.8 esutils: 2.0.3 '@babel/[email protected](@babel/[email protected])': @@ -6480,11 +6492,11 @@ snapshots: dependencies: regenerator-runtime: 0.14.1 - '@babel/[email protected]': + '@babel/[email protected]': dependencies: '@babel/code-frame': 7.26.2 - '@babel/parser': 7.26.7 - '@babel/types': 7.26.7 + '@babel/parser': 7.26.8 + '@babel/types': 7.26.8 '@babel/[email protected]': dependencies: @@ -6497,8 +6509,20 @@ snapshots: '@babel/code-frame': 7.26.2 '@babel/generator': 7.26.5 '@babel/parser': 7.26.7 - '@babel/template': 7.25.9 - '@babel/types': 7.26.7 + '@babel/template': 7.26.8 + '@babel/types': 7.26.8 + debug: 4.4.0 + globals: 11.12.0 + transitivePeerDependencies: + - supports-color + + '@babel/[email protected]': + dependencies: + '@babel/code-frame': 7.26.2 + '@babel/generator': 7.26.8 + '@babel/parser': 7.26.8 + '@babel/template': 7.26.8 + '@babel/types': 7.26.8 debug: 4.4.0 globals: 11.12.0 transitivePeerDependencies: @@ -7747,14 +7771,14 @@ snapshots: [email protected](@babel/[email protected]): dependencies: - '@babel/compat-data': 7.26.5 + '@babel/compat-data': 7.26.8 '@babel/core': 7.26.7 '@babel/helper-define-polyfill-provider': 0.6.3(@babel/[email protected]) semver: 6.3.1 transitivePeerDependencies: - supports-color - [email protected](@babel/[email protected]): + [email protected](@babel/[email protected]): dependencies: '@babel/core': 7.26.7 '@babel/helper-define-polyfill-provider': 0.6.3(@babel/[email protected]) @@ -7847,8 +7871,8 @@ snapshots: [email protected]: dependencies: - caniuse-lite: 1.0.30001697 - electron-to-chromium: 1.5.91 + caniuse-lite: 1.0.30001699 + electron-to-chromium: 1.5.96 node-releases: 2.0.19 update-browserslist-db: 1.1.2([email protected]) @@ -7914,7 +7938,7 @@ snapshots: [email protected]: {} - [email protected]: {} + [email protected]: {} [email protected]: {} @@ -8363,7 +8387,7 @@ snapshots: minimatch: 9.0.1 semver: 7.7.1 - [email protected]: {} + [email protected]: {} [email protected]: {}
98a4c7ad77fb8172733aff919682a56377d9ee86
2022-12-10 21:06:41
Tony
feat(route): sasac (#11433)
false
sasac (#11433)
feat
diff --git a/docs/government.md b/docs/government.md index 931cc1d4c8d1cb..e2687858984ddc 100644 --- a/docs/government.md +++ b/docs/government.md @@ -369,6 +369,22 @@ pageClass: routes </Route> +## 国务院国有资产监督管理委员会 + +### 通用 + +<Route author="TonyRL" example="/gov/sasac/n2588030/n16436141" path="/gov/sasac/:path+" :paramsDesc="['路径,可在 URL 找到']" radar="1" rssbud="1" > + +::: tip 提示 + +路径处填写对应页面 URL 中 `http://www.sasac.gov.cn/` 与 `/index.html` 之间的字段,下面是一个例子。 + +若订阅 [其他](http://www.sasac.gov.cn/n2588030/n16436141/index.html) 则将对应页面 URL <http://www.sasac.gov.cn/n2588030/n16436141/index.html> 中 `http://www.sasac.gov.cn/` 和 `/index.html` 之间的字段 `n2588030/n16436141` 作为路径填入。此时路由为 [`/gov/sasac/n2588030/n16436141`](https://rsshub.app/gov/nmpa/n2588030/n16436141) + +::: + +</Route> + ## 哈尔滨市科技局 ### 政务公开 diff --git a/lib/v2/gov/maintainer.js b/lib/v2/gov/maintainer.js index 17365a08fa26dd..7ead7f607f03ff 100644 --- a/lib/v2/gov/maintainer.js +++ b/lib/v2/gov/maintainer.js @@ -34,6 +34,7 @@ module.exports = { '/pbc/gzlw': ['Fatpandac'], '/pbc/tradeAnnouncement': ['nczitzk'], '/pbc/zcyj': ['Fatpandac'], + '/sasac/:path+': ['TonyRL'], '/stats/:path+': ['bigfei'], '/zhengce/govall/:advance?': ['ciaranchen'], '/zhengce/wenjian/:pcodeJiguan?': ['ciaranchen'], diff --git a/lib/v2/gov/radar.js b/lib/v2/gov/radar.js index b34a226c12d96d..d444c786fdbded 100644 --- a/lib/v2/gov/radar.js +++ b/lib/v2/gov/radar.js @@ -694,6 +694,17 @@ module.exports = { }, ], }, + 'sasac.gov.cn': { + _name: '国务院国有资产监督管理委员会', + '.': [ + { + title: '通用', + docs: 'https://docs.rsshub.app/other.html#guo-wu-yuan-guo-you-zi-chan-jian-du-guan-li-wei-yuan-hui', + source: ['/*path'], + target: (params) => `/gov/sasac/${params.path.replace('/index.html', '')}`, + }, + ], + }, 'sh.gov.cn': { _name: '上海市人民政府', wsjkw: [ diff --git a/lib/v2/gov/router.js b/lib/v2/gov/router.js index 71a7be59060595..dfcc6024a7ff50 100644 --- a/lib/v2/gov/router.js +++ b/lib/v2/gov/router.js @@ -26,6 +26,7 @@ module.exports = function (router) { router.get('/pbc/gzlw', require('./pbc/gzlw')); router.get('/pbc/tradeAnnouncement', require('./pbc/tradeAnnouncement')); router.get('/pbc/zcyj', require('./pbc/zcyj')); + router.get('/sasac/:path+', require('./sasac/generic')); router.get(/stats(\/[\w/-]+)?/, require('./stats')); router.get('/zhengce/govall/:advance?', require('./zhengce/govall')); router.get('/zhengce/wenjian/:pcodeJiguan?', require('./zhengce/wenjian')); diff --git a/lib/v2/gov/sasac/generic.js b/lib/v2/gov/sasac/generic.js new file mode 100644 index 00000000000000..dbc3ab83feaf52 --- /dev/null +++ b/lib/v2/gov/sasac/generic.js @@ -0,0 +1,42 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const { parseDate } = require('@/utils/parse-date'); + +module.exports = async (ctx) => { + const { path } = ctx.params; + const baseUrl = 'http://www.sasac.gov.cn'; + const url = `${baseUrl}/${path}/index.html`; + const response = await got(url); + + const $ = cheerio.load(response.data); + const list = $('.zsy_conlist li') + .toArray() + .filter((item) => !$(item).attr('style')) + .map((item) => { + item = $(item); + return { + title: item.find('a').attr('title'), + link: new URL(item.find('a').attr('href'), response.url).href, + pubDate: parseDate(item.find('span').text().replace('[', '').replace(']', '')), + }; + }); + + const items = await Promise.all( + list.map((item) => + ctx.cache.tryGet(item.link, async () => { + const response = await got(item.link); + const $ = cheerio.load(response.data); + $('style, #qr_container, #div_div, [class^=jiathis]').remove(); + item.description = $('.zsy_comain').html(); + return item; + }) + ) + ); + + ctx.state.data = { + title: $('head title').text().trim(), + link: url, + image: 'http://www.sasac.gov.cn/dbsource/11869722/11869731.jpg', + item: items, + }; +};
2bd4fd7b8d2780e86dcd10bf9b50703981936362
2022-10-10 22:40:52
DIYgod
chore: use foresight
false
use foresight
chore
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d74653da93b62d..075a985947d471 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -32,6 +32,11 @@ jobs: node-version: [ 14, 16 ] name: Jest on Node ${{ matrix.node-version }} steps: + - name: Collect Workflow Telemetry + uses: runforesight/foresight-workflow-kit-action@v1 + if: success() || failure() + with: + api_key: ${{ secrets.FORESIGHT_KEY }} - uses: actions/checkout@v3 - uses: actions/setup-node@v3 with: @@ -48,6 +53,14 @@ jobs: uses: codecov/codecov-action@v3 with: token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos as documented, but seems broken + - name: Analyze Test and/or Coverage Results + uses: runforesight/foresight-test-kit-action@v1 + if: success() || failure() + with: + api_key: ${{ secrets.FORESIGHT_KEY }} + test_format: JUNIT + test_framework: JEST + coverage_format: JACOCO/XML puppeteer: runs-on: ubuntu-latest
e6e7e8cc6badb1a0e2c719f77e528e11bf8dd5ce
2019-08-20 08:32:14
DIYgod
refactor: format
false
format
refactor
diff --git a/docs/support/README.md b/docs/support/README.md index 1eb8e98cf0f221..2f82b26f8eebad 100644 --- a/docs/support/README.md +++ b/docs/support/README.md @@ -23,4 +23,5 @@ RSSHub 是采用 MIT 许可的开源项目, 使用完全免费. 但是随着项 - [支付宝](https://i.loli.net/2019/03/23/5c950ebbc980e.png) ## 周边产品 + 也可以购买我们[官方授权的周边产品](https://telegra.ph/RSSHub-周边-08-20-2),每售出一件周边,我们将获得售价 10% 的捐赠。 diff --git a/lib/routes/juejin/utils.js b/lib/routes/juejin/utils.js index fa8586885462ff..5da5c2789f1c87 100644 --- a/lib/routes/juejin/utils.js +++ b/lib/routes/juejin/utils.js @@ -13,10 +13,10 @@ async function load(link) { const $ = cheerio.load(response.data); // 解析日期 - //const date = new Date($('time').attr('datetime')); - //const timeZone = 8 * 60; - //const serverOffset = date.getTimezoneOffset(); - //const pubDate = new Date(date.getTime() + 60 * 1000 * (timeZone + serverOffset)).toUTCString(); + // const date = new Date($('time').attr('datetime')); + // const timeZone = 8 * 60; + // const serverOffset = date.getTimezoneOffset(); + // const pubDate = new Date(date.getTime() + 60 * 1000 * (timeZone + serverOffset)).toUTCString(); // 提取内容 const description = $('.article-content') @@ -30,7 +30,7 @@ async function load(link) { const ProcessFeed = async (list, caches) => await Promise.all( list.map(async (item) => { - //解析时间,补偿时区offset + // 解析时间,补偿时区offset const pubdate = new Date(); pubdate.setTime(Date.parse(item.createdAt) - 8 * 60 * 60 * 1000); // 列表上提取到的信息
4dbadfe2b80043281b0565cc4fa5c03ff93bcc22
2022-10-05 18:04:23
Ethan Shen
feat(route): 得到用户主页 (#10993)
false
得到用户主页 (#10993)
feat
diff --git a/docs/new-media.md b/docs/new-media.md index e7079ae80913be..7528d376a89d64 100644 --- a/docs/new-media.md +++ b/docs/new-media.md @@ -1812,7 +1812,7 @@ Supported sub-sites: ### 首页 -<Route author="nczitzk" example="/dedao/list/年度日更" path="/dedao/list/:caty?" :paramsDesc="['分类名,默认为年度日更']"/> +<Route author="nczitzk" example="/dedao/list/年度日更" path="/dedao/list/:category?" :paramsDesc="['分类名,默认为年度日更']"/> ### 新闻 @@ -1828,7 +1828,17 @@ Supported sub-sites: ### 知识城邦 -<Route author="nczitzk" example="/dedao/knowledge" path="/dedao/knowledge/:topic?/:type?" :paramsDesc="['话题 id,可在话题页 URL 中找到', '分享类型,`true` 指精选,`false` 指最新,默认为精选']"/> +<Route author="nczitzk" example="/dedao/knowledge" path="/dedao/knowledge/:topic?/:type?" :paramsDesc="['话题 id,可在对应话题页 URL 中找到', '分享类型,`true` 指精选,`false` 指最新,默认为精选']"/> + +### 用户主页 + +<Route author="nczitzk" example="/dedao/user/VkA5OqLX4RyGxmZRNBMlwBrDaJQ9og" path="/dedao/user/:id/:type?" :paramsDesc="['用户 id,可在对应用户主页 URL 中找到', '类型,见下表,默认为`0`,即动态']"> + +| 动态 | 书评 | 视频 | +| -- | -- | -- | +| 0 | 7 | 12 | + +</Route> ## 电动邦 diff --git a/lib/router.js b/lib/router.js index b9358a332a1efb..204ac341f005ad 100644 --- a/lib/router.js +++ b/lib/router.js @@ -3353,9 +3353,9 @@ router.get('/nwpu/:column', lazyloadRouteHandler('./routes/nwpu/index')); router.get('/us/supremecourt/argument_audio/:year?', lazyloadRouteHandler('./routes/us/supremecourt/argument_audio')); // 得到 -router.get('/dedao/list/:caty?', lazyloadRouteHandler('./routes/dedao/list')); -router.get('/dedao/knowledge/:topic?/:type?', lazyloadRouteHandler('./routes/dedao/knowledge')); -router.get('/dedao/:caty?', lazyloadRouteHandler('./routes/dedao/index')); +// router.get('/dedao/list/:caty?', lazyloadRouteHandler('./routes/dedao/list')); +// router.get('/dedao/knowledge/:topic?/:type?', lazyloadRouteHandler('./routes/dedao/knowledge')); +// router.get('/dedao/:caty?', lazyloadRouteHandler('./routes/dedao/index')); // 未名新闻 router.get('/mitbbs/:caty?', lazyloadRouteHandler('./routes/mitbbs/index')); diff --git a/lib/routes/dedao/knowledge.js b/lib/routes/dedao/knowledge.js deleted file mode 100644 index 06fdfb9f6b4f4d..00000000000000 --- a/lib/routes/dedao/knowledge.js +++ /dev/null @@ -1,78 +0,0 @@ -const got = require('@/utils/got'); -const date = require('@/utils/date'); - -module.exports = async (ctx) => { - const topic = ctx.params.topic || ''; - const type = ctx.params.type || 'true'; - const rootUrl = 'https://www.dedao.cn'; - const detailUrl = `${rootUrl}/pc/ledgers/topic/detail`; - const currentUrl = `${rootUrl}/knowledge${topic === '' ? '' : '/topic/' + topic}`; - const apiUrl = `${rootUrl}/pc/ledgers/${topic === '' ? 'notes/friends_timeline' : 'topic/notes/list'}`; - - let title = '', - description = ''; - - if (topic !== '') { - const detailResponse = await got({ - method: 'post', - url: detailUrl, - json: { - incr_view_count: false, - topic_id_hazy: topic, - }, - }); - - title = detailResponse.data.c.name; - description = detailResponse.data.c.intro; - } - - const response = await got({ - method: 'post', - url: apiUrl, - json: { - count: 20, - load_chain: true, - is_elected: type === 'true', - page_id: 0, - topic_id_hazy: topic, - version: 2, - }, - }); - - const items = (topic === '' ? response.data.c.notes : response.data.c.note_detail_list).map((item) => { - let s_part = ''; - if (item.s_part) { - const s_author = `<p>引用 ${item.s_part.nick_name} (${item.s_part.v_info}):</p>`; - const s_content = `<p>${item.s_part.note.replace(/\n\n/g, '</p><p>')}</p> <a href="${rootUrl}/knowledge/note/${item.s_part.note_id_hazy}">[查看原文]</a>`; - let s_images = '<br>'; - if (item.s_part.images) { - for (const i of item.s_part.images) { - s_images += `<img src="${i.match(/"url":"(.*)"/)[1]}">`; - } - } - s_part = s_author + s_content + s_images; - } - - let f_images = '<br>'; - if (item.f_part.images) { - for (const i of item.f_part.images) { - f_images += `<img src="${i.match(/"url":"(.*)"/)[1]}">`; - } - } - - return { - title: item.f_part.note, - author: item.f_part.nick_name, - description: `<p>${item.f_part.note.replace(/\n\n/g, '</p><p>')}</p>${f_images}<br>${s_part}`, - link: `${rootUrl}/knowledge/note/${item.f_part.note_id_hazy}`, - pubDate: new Date(date(item.f_part.time_desc)).toUTCString(), - }; - }); - - ctx.state.data = { - title: `得到 - 知识城邦${title === '' ? '' : ' - ' + title}`, - link: currentUrl, - item: items, - description, - }; -}; diff --git a/lib/routes/dedao/index.js b/lib/v2/dedao/index.js similarity index 52% rename from lib/routes/dedao/index.js rename to lib/v2/dedao/index.js index 41a5725b437e7e..e53c8bc8882d26 100644 --- a/lib/routes/dedao/index.js +++ b/lib/v2/dedao/index.js @@ -1,9 +1,11 @@ const got = require('@/utils/got'); const cheerio = require('cheerio'); +const { parseDate } = require('@/utils/parse-date'); module.exports = async (ctx) => { - const caty = ctx.params.caty || 'news'; - const rootUrl = `https://www.igetget.com/${caty === 'video' ? 'video' : 'news'}`; + const category = ctx.params.category ?? 'news'; + + const rootUrl = `https://www.igetget.com/${category === 'video' ? 'video' : 'news'}`; const response = await got({ method: 'get', @@ -12,19 +14,20 @@ module.exports = async (ctx) => { const data = JSON.parse(response.data.match(/window.__INITIAL_STATE__= (.*);<\/script>/)[1]); - const list = (caty === 'news' ? data.news : caty === 'figure' ? data.figure : data.videoList).map((item) => ({ + let items = (category === 'news' ? data.news : category === 'figure' ? data.figure : data.videoList).map((item) => ({ title: item.title, - pubDate: new Date(item.online_time).toUTCString(), - link: `${rootUrl}/${caty === 'news' ? 'article/' : caty === 'figure' ? 'people/' : ''}${item.online_time.split('T')[0].split('-').join('')}/${item.token}`, + pubDate: parseDate(item.online_time), + link: `${rootUrl}/${category === 'news' ? 'article/' : category === 'figure' ? 'people/' : ''}${item.online_time.split('T')[0].split('-').join('')}/${item.token}`, })); - const items = await Promise.all( - list.map((item) => + items = await Promise.all( + items.map((item) => ctx.cache.tryGet(item.link, async () => { const detailResponse = await got({ method: 'get', url: item.link, }); + const content = cheerio.load(detailResponse.data); item.description = content('.menu-article').html(); @@ -35,7 +38,7 @@ module.exports = async (ctx) => { ); ctx.state.data = { - title: `得到${caty === 'video' ? '' : '大事件'} - ${caty === 'news' ? '新闻' : caty === 'figure' ? '人物故事' : '视频'}`, + title: `得到${category === 'video' ? '' : '大事件'} - ${category === 'news' ? '新闻' : category === 'figure' ? '人物故事' : '视频'}`, link: rootUrl, item: items, description: data.description, diff --git a/lib/v2/dedao/knowledge.js b/lib/v2/dedao/knowledge.js new file mode 100644 index 00000000000000..3a1aa66a8cf8dc --- /dev/null +++ b/lib/v2/dedao/knowledge.js @@ -0,0 +1,64 @@ +const got = require('@/utils/got'); +const { parseDate } = require('@/utils/parse-date'); +const { art } = require('@/utils/render'); +const path = require('path'); + +module.exports = async (ctx) => { + const topic = ctx.params.topic ?? ''; + const type = /t|y/i.test(ctx.params.type ?? 'true'); + const count = ctx.query.limit ? parseInt(ctx.query.limit) : 100; + + const rootUrl = 'https://www.dedao.cn'; + const currentUrl = `${rootUrl}/knowledge${topic === '' ? '' : '/topic/' + topic}`; + const apiUrl = `${rootUrl}/pc/ledgers/${topic === '' ? 'notes/friends_timeline' : 'topic/notes/list'}`; + const detailUrl = `${rootUrl}/pc/ledgers/topic/detail`; + + let title = '', + description = ''; + + if (topic !== '') { + const detailResponse = await got({ + method: 'post', + url: detailUrl, + json: { + incr_view_count: false, + topic_id_hazy: topic, + }, + }); + + title = detailResponse.data.c.name; + description = detailResponse.data.c.intro; + } + + const response = await got({ + method: 'post', + url: apiUrl, + json: { + count, + load_chain: true, + is_elected: type, + page_id: 0, + topic_id_hazy: topic, + version: 2, + }, + }); + + const items = (topic === '' ? response.data.c.notes : response.data.c.note_detail_list).map((item) => ({ + title: item.f_part.note, + author: item.f_part.nick_name, + link: `${rootUrl}/knowledge/note/${item.f_part.note_id_hazy}`, + pubDate: parseDate(item.f_part.time_desc, 'MM-DD'), + description: art(path.join(__dirname, 'templates/knowledge.art'), { + rootUrl, + f_part: item.f_part, + s_part: item.s_part, + }), + })); + + ctx.state.data = { + title: `得到 - 知识城邦${title === '' ? '' : ' - ' + title}`, + link: currentUrl, + item: items, + description, + }; +}; diff --git a/lib/routes/dedao/list.js b/lib/v2/dedao/list.js similarity index 76% rename from lib/routes/dedao/list.js rename to lib/v2/dedao/list.js index 7be680b51da4b9..0277441c337572 100644 --- a/lib/routes/dedao/list.js +++ b/lib/v2/dedao/list.js @@ -2,20 +2,24 @@ const got = require('@/utils/got'); const cheerio = require('cheerio'); module.exports = async (ctx) => { - const caty = ctx.params.caty || '年度日更'; + const category = ctx.params.category ?? '年度日更'; + const rootUrl = 'https://www.igetget.com'; + const response = await got({ method: 'get', url: rootUrl, }); const listUrl = `${rootUrl}${response.data.match(new RegExp('<a href="(.*)">年度日更<\\/a>'))[1]}`; + const listResponse = await got({ method: 'get', url: listUrl, }); - const currentUrl = `${rootUrl}${listResponse.data.match(new RegExp('<span>' + caty + '<\\/span><a href="(.*)" rel="tag"><\\/a>'))[1].split('"')[0]}`; + const currentUrl = `${rootUrl}${listResponse.data.match(new RegExp('<span>' + category + '<\\/span><a href="(.*)" rel="tag"><\\/a>'))[1].split('"')[0]}`; + const currentResponse = await got({ method: 'get', url: currentUrl, @@ -23,24 +27,26 @@ module.exports = async (ctx) => { const $ = cheerio.load(currentResponse.data); - const list = $('.pro-info p a') - .slice(0, 10) - .map((_, item) => { + let items = $('.pro-info p a') + .toArray() + .slice(0, ctx.query.limit ? parseInt(ctx.query.limit) : 10) + .map((item) => { item = $(item); + return { title: item.text(), link: `${rootUrl}${item.attr('href')}`, }; - }) - .get(); + }); - const items = await Promise.all( - list.map((item) => + items = await Promise.all( + items.map((item) => ctx.cache.tryGet(item.link, async () => { const detailResponse = await got({ method: 'get', url: item.link, }); + const content = cheerio.load(detailResponse.data); content('.more-bt').remove(); @@ -53,7 +59,7 @@ module.exports = async (ctx) => { ); ctx.state.data = { - title: `得到 - ${caty}`, + title: `得到 - ${category}`, link: currentUrl, item: items, }; diff --git a/lib/v2/dedao/maintainer.js b/lib/v2/dedao/maintainer.js new file mode 100644 index 00000000000000..57bfb1b03e87a0 --- /dev/null +++ b/lib/v2/dedao/maintainer.js @@ -0,0 +1,8 @@ +module.exports = { + '/figure': ['nczitzk'], + '/knowledge/:topic?/:type?': ['nczitzk'], + '/list/:category?': ['nczitzk'], + '/news': ['nczitzk'], + '/user/:id/:type?': ['nczitzk'], + '/video': ['nczitzk'], +}; diff --git a/lib/v2/dedao/radar.js b/lib/v2/dedao/radar.js new file mode 100644 index 00000000000000..f7c491827d0794 --- /dev/null +++ b/lib/v2/dedao/radar.js @@ -0,0 +1,50 @@ +module.exports = { + 'dedao.cn': { + _name: '得到', + '.': [ + { + title: '知识城邦', + docs: 'https://docs.rsshub.app/new-media.html#de-dao-zhi-shi-cheng-bang', + source: ['/knowledge/topic/:topic', '/knowledge', '/'], + target: '/dedao/knowledge/:topic?/:type?', + }, + ], + }, + 'igetget.com': { + _name: '得到', + '.': [ + { + title: '首页', + docs: 'https://docs.rsshub.app/new-media.html#de-dao-shou-ye', + source: ['/'], + target: '/dedao/list/:category?', + }, + { + title: '新闻', + docs: 'https://docs.rsshub.app/new-media.html#de-dao-xin-wen', + source: ['/news', '/'], + target: '/dedao/news', + }, + { + title: '人物故事', + docs: 'https://docs.rsshub.app/new-media.html#de-dao-ren-wu-gu-shi', + source: ['/news', '/'], + target: '/dedao/figure', + }, + { + title: '视频', + docs: 'https://docs.rsshub.app/new-media.html#de-dao-shi-pin', + source: ['/video', '/'], + target: '/dedao/video', + }, + ], + m: [ + { + title: '用户主页', + docs: 'https://docs.rsshub.app/new-media.html#de-dao-yong-hu-zhu-ye', + source: ['/native/mine/account', '/'], + target: (params, url) => `/dedao/user/${new URL(url).searchParams.get('enId')}`, + }, + ], + }, +}; diff --git a/lib/v2/dedao/router.js b/lib/v2/dedao/router.js new file mode 100644 index 00000000000000..095937907afb13 --- /dev/null +++ b/lib/v2/dedao/router.js @@ -0,0 +1,6 @@ +module.exports = function (router) { + router.get('/knowledge/:topic?/:type?', require('./knowledge')); + router.get('/list/:category?', require('./list')); + router.get('/user/:id/:type?', require('./user')); + router.get('/:category?', require('./index')); +}; diff --git a/lib/v2/dedao/templates/knowledge.art b/lib/v2/dedao/templates/knowledge.art new file mode 100644 index 00000000000000..fe5facf22a1ebf --- /dev/null +++ b/lib/v2/dedao/templates/knowledge.art @@ -0,0 +1,29 @@ +{{ if f_part.note }} +<p>{{@ f_part.note + .replace(/\n\n/g, '</p><p>') + .replace(/<≧❆>{"name":"(.*?)","uid":"\d+","at":"1"}<\/≦❆>/g, ' @$1') + }}</p> +{{ /if }} +{{ if f_part.images }} +<br> +{{ set f_part_images = f_part.images }} +{{ each f_part_images image }} +<img src="{{ image.match(/"url":"(.*?)"/)[1] }}"> +{{ /each }} +{{ /if }} +{{ if s_part }} +<br> +<p>引用 {{ s_part.nick_name }}{{ if s_part.v_info }} ({{ s_part.v_info }}){{ /if }}:</p> +<p>{{@ s_part.note + .replace(/\n\n/g, '</p><p>') + .replace(/<≧❆>{"name":"(.*?)","uid":"\d+","at":"1"}<\/≦❆>/g, ' @$1') + }}</p> +<a href="{{ rootUrl }}/knowledge/note/{{ s_part.note_id_hazy }}">[查看原文]</a> +{{ if s_part.images }} +<br> +{{ set s_part_images = s_part.images }} +{{ each s_part_images image}} +<img src="{{ image.match(/"url":"(.*?)"/)[1] }}"> +{{ /each }} +{{ /if }} +{{ /if }} \ No newline at end of file diff --git a/lib/v2/dedao/templates/user.art b/lib/v2/dedao/templates/user.art new file mode 100644 index 00000000000000..fc4525e23e77db --- /dev/null +++ b/lib/v2/dedao/templates/user.art @@ -0,0 +1,38 @@ +{{ if name }} +<p>{{@ content + .replace(/\n\n/g, '</p><p>') + .replace(/<≧❆>{"name":"(.*?)","uid":"\d+","at":"1"}<\/≦❆>/g, ' @$1') + }}</p> +<br> +<p>引用 {{ name }}{{ if vinfo }} ({{ vinfo }}){{ /if }}:</p> +{{ /if }} +<p>{{@ note + .replace(/\n\n/g, '</p><p>') + .replace(/<≧❆>{"name":"(.*?)","uid":"\d+","at":"1"}<\/≦❆>/g, ' @$1') + }}</p> +{{ if extra }} +<br> +{{ if extra.img }} +{{ if extra.share_ext }} +<a href="{{ extra.share_ext.h_5_url }}"> +{{ /if }} +<figure> + <img src="{{ extra.img }}"> + <figcaption>{{ extra.title }}</figcaption> +</figure> +{{ if extra.share_ext }} +</a> +{{ /if }} +{{ /if }} +{{ if extra.images }} +{{ set extra_images = extra.images }} +{{ each extra_images image }} +<img src="{{ image.match(/"url":"(.*?)"/)[1] }}"> +{{ /each }} +{{ /if }} +{{ if video }} +<figure> + <img src="{{ video.match(/"url":"(.*?)"/)[1] }}"> +</figure> +{{ /if }} +{{ /if }} \ No newline at end of file diff --git a/lib/v2/dedao/user.js b/lib/v2/dedao/user.js new file mode 100644 index 00000000000000..9a5046498264ac --- /dev/null +++ b/lib/v2/dedao/user.js @@ -0,0 +1,79 @@ +const got = require('@/utils/got'); +const { parseDate } = require('@/utils/parse-date'); +const { art } = require('@/utils/render'); +const path = require('path'); + +const types = { + 0: '动态', + 7: '书评', + 12: '视频', +}; + +module.exports = async (ctx) => { + const id = ctx.params.id ?? ''; + const type = ctx.params.type ? parseInt(ctx.params.type) : 0; + const count = ctx.query.limit ? parseInt(ctx.query.limit) : 100; + + const rootUrl = 'https://m.igetget.com'; + const currentUrl = `${rootUrl}/native/mine/account#/user/detail?enId=${id}`; + const apiUrl = `${rootUrl}/native/api/homePage/topicNote`; + const infoUrl = `${rootUrl}/native/api/homePage/userInfo`; + + const detailResponse = await got({ + method: 'post', + url: infoUrl, + json: { + hazy: id, + }, + }); + + const data = detailResponse.data; + + const author = data.c.nickname; + const image = data.c.avatar; + const description = `${data.c.v_info}: ${data.c.slogan}`; + + const response = await got({ + method: 'post', + url: apiUrl, + json: { + uid: null, + max_id_str: '0', + count, + max_createtime: 0, + is_only_repost: 0, + load_chain: true, + load_tag: 1, + source: 0, + note_type: type, + only_origin: false, + with_highlight: true, + hazy: id, + }, + }); + + const items = response.data.c.list.map((item) => ({ + author, + title: item.content || item.note || item.extra.title, + link: item.share_url, + pubDate: parseDate(item.create_time * 1000), + description: art(path.join(__dirname, 'templates/user.art'), { + rootUrl, + name: item.origin_notes_owner.name, + vinfo: item.origin_notes_owner.Vinfo, + content: item.content, + note: item.note, + extra: item.extra, + video: item.video.video_cover, + }), + })); + + ctx.state.data = { + title: `${author}的得到主页 - ${types[type]}`, + link: currentUrl, + item: items, + image, + description, + allowEmpty: true, + }; +};
801f75c732521fabe147068e1e7038cbb45fcb3a
2019-04-26 09:29:17
DIYgod
feat(core): add edge and last-modified header, close #338
false
add edge and last-modified header, close #338
feat
diff --git a/lib/middleware/header.js b/lib/middleware/header.js index 2a48f05649babb..2f351657dbe6dc 100644 --- a/lib/middleware/header.js +++ b/lib/middleware/header.js @@ -1,3 +1,4 @@ +const etagCalculate = require('etag'); const logger = require('../utils/logger'); const config = require('../config'); const headers = { @@ -11,5 +12,27 @@ const headers = { module.exports = async (ctx, next) => { logger.info(`${ctx.url}, user IP: ${ctx.ips[0] || ctx.ip}`); ctx.set(headers); + await next(); + + let body = ctx.body; + if (!body || typeof body !== 'string' || ctx.response.get('ETag')) { + return; + } + + const status = (ctx.status / 100) | 0; + if (2 !== status) { + return; + } + + const match = body.match(/<lastBuildDate>(.*)<\/lastBuildDate>/); + if (match) { + ctx.set({ + 'Last-Modified': body.match(/<lastBuildDate>(.*)<\/lastBuildDate>/)[1], + }); + } + + body = body.replace(/<lastBuildDate>(.*)<\/lastBuildDate>/, ''); + + ctx.response.etag = etagCalculate(body); }; diff --git a/package.json b/package.json index 66693d1bd35aaf..64ef94c6825b44 100644 --- a/package.json +++ b/package.json @@ -55,6 +55,7 @@ "co-redis": "2.1.1", "currency-symbol-map": "4.0.4", "dayjs": "1.8.12", + "etag": "1.8.1", "form-data": "2.3.3", "git-rev-sync": "1.12.0", "googleapis": "39.2.0", diff --git a/test/middleware/header.js b/test/middleware/header.js index de15c7bf1d340a..02a1e8e9488bf1 100644 --- a/test/middleware/header.js +++ b/test/middleware/header.js @@ -15,5 +15,7 @@ describe('header', () => { expect(response.headers['access-control-allow-methods']).toBe('GET'); expect(response.headers['content-type']).toBe('application/xml; charset=utf-8'); expect(response.headers['cache-control']).toBe(`max-age=${config.cacheExpire / 2}`); + expect(response.headers['last-modified']).toBe(response.text.match(/<lastBuildDate>(.*)<\/lastBuildDate>/)[1]); + expect(response.headers.etag).toBe('"b37-MORyrF0tJ8BFw0xLLZL/zBYAFPY"'); }); }); diff --git a/yarn.lock b/yarn.lock index 80fad18e0c54f1..04d6418b43f084 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3877,7 +3877,7 @@ esutils@^2.0.2: resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.2.tgz#0abf4f1caa5bcb1f7a9d8acc6dea4faaa04bac9b" integrity sha1-Cr9PHKpbyx96nYrMbepPqqBLrJs= -etag@~1.8.1: [email protected], etag@~1.8.1: version "1.8.1" resolved "https://registry.yarnpkg.com/etag/-/etag-1.8.1.tgz#41ae2eeb65efa62268aebfea83ac7d79299b0887" integrity sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc=
7410aaac901515f73f0d336b9a40e2cefcb0fee0
2023-10-21 04:56:43
dependabot[bot]
chore(deps-dev): bump eslint from 8.51.0 to 8.52.0 (#13591)
false
bump eslint from 8.51.0 to 8.52.0 (#13591)
chore
diff --git a/package.json b/package.json index 8a990d9ae2b4f7..90db6e3196bcc7 100644 --- a/package.json +++ b/package.json @@ -181,7 +181,7 @@ "@types/tough-cookie": "4.0.4", "@vercel/nft": "0.24.3", "cross-env": "7.0.3", - "eslint": "8.51.0", + "eslint": "8.52.0", "eslint-config-prettier": "9.0.0", "eslint-plugin-n": "16.2.0", "eslint-plugin-prettier": "5.0.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ba5cc3e944aa3f..7564f4c61280d1 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -296,20 +296,20 @@ devDependencies: specifier: 7.0.3 version: 7.0.3 eslint: - specifier: 8.51.0 - version: 8.51.0 + specifier: 8.52.0 + version: 8.52.0 eslint-config-prettier: specifier: 9.0.0 - version: 9.0.0([email protected]) + version: 9.0.0([email protected]) eslint-plugin-n: specifier: 16.2.0 - version: 16.2.0([email protected]) + version: 16.2.0([email protected]) eslint-plugin-prettier: specifier: 5.0.1 - version: 5.0.1(@types/[email protected])([email protected])([email protected])([email protected]) + version: 5.0.1(@types/[email protected])([email protected])([email protected])([email protected]) eslint-plugin-yml: specifier: 1.10.0 - version: 1.10.0([email protected]) + version: 1.10.0([email protected]) fs-extra: specifier: 11.1.1 version: 11.1.1 @@ -744,13 +744,13 @@ packages: kuler: 2.0.0 dev: false - /@eslint-community/[email protected]([email protected]): + /@eslint-community/[email protected]([email protected]): resolution: {integrity: sha512-1/sA4dwrzBAyeUoQ6oxahHKmrZvsnLCg4RfxW3ZFGGmQkSNQPFNLV9CUEFQP1x9EYXHTo5p6xdhZM1Ne9p/AfA==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: eslint: ^6.0.0 || ^7.0.0 || >=8.0.0 dependencies: - eslint: 8.51.0 + eslint: 8.52.0 eslint-visitor-keys: 3.4.3 dev: true @@ -776,16 +776,16 @@ packages: - supports-color dev: true - /@eslint/[email protected]: - resolution: {integrity: sha512-HxjQ8Qn+4SI3/AFv6sOrDB+g6PpUTDwSJiQqOrnneEk8L71161srI9gjzzZvYVbzHiVg/BvcH95+cK/zfIt4pg==} + /@eslint/[email protected]: + resolution: {integrity: sha512-mjZVbpaeMZludF2fsWLD0Z9gCref1Tk4i9+wddjRvpUNqqcndPkBD09N/Mapey0b3jaXbLm2kICwFv2E64QinA==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dev: true - /@humanwhocodes/[email protected]: - resolution: {integrity: sha512-N2brEuAadi0CcdeMXUkhbZB84eskAc8MEX1By6qEchoVywSgXPIjou4rYsl0V3Hj0ZnuGycGCjdNgockbzeWNA==} + /@humanwhocodes/[email protected]: + resolution: {integrity: sha512-JSBDMiDKSzQVngfRjOdFXgFfklaXI4K9nLF49Auh21lmBWRLIK3+xTErTWD4KU54pb6coM6ESE7Awz/FNU3zgQ==} engines: {node: '>=10.10.0'} dependencies: - '@humanwhocodes/object-schema': 1.2.1 + '@humanwhocodes/object-schema': 2.0.1 debug: 4.3.4 minimatch: 3.1.2 transitivePeerDependencies: @@ -797,8 +797,8 @@ packages: engines: {node: '>=12.22'} dev: true - /@humanwhocodes/[email protected]: - resolution: {integrity: sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==} + /@humanwhocodes/[email protected]: + resolution: {integrity: sha512-dvuCeX5fC9dXgJn9t+X5atfmgQAzUOWqS1254Gh0m6i8wKd10ebXkfNKiRK+1GWi/yTvvLDHpoxLr0xxxeslWw==} dev: true /@ioredis/[email protected]: @@ -1104,7 +1104,7 @@ packages: resolution: {integrity: sha512-KIKkT44hEqCzqxODYwFMUvYEK0CrdHx/Ll9xiOWgFbBSRuzbxmVy4d/tzfgoucGz72HJZNOMjuyzFTBKntRK5Q==} engines: {node: '>= 14'} dependencies: - eslint: 8.51.0 + eslint: 8.52.0 jschardet: 3.0.0 lodash: 4.17.21 utf8: 3.0.0 @@ -1803,6 +1803,10 @@ packages: dev: false optional: true + /@ungap/[email protected]: + resolution: {integrity: sha512-zuVdFrMJiuCDQUMCzQaD6KL28MjnqqN8XnAqiEq9PNm/hCPTSGfrXCOfwj1ow4LFb/tNymJPwsNbVePc1xFqrQ==} + dev: true + /@vercel/[email protected]: resolution: {integrity: sha512-IyBdIxmFAeGZnEfMgt4QrGK7XX4lWazlQj34HEi9dw04/WeDBJ7r1yaOIO5tTf9pbfvwUFodj9b0H+NDGGoOMg==} engines: {node: '>=16'} @@ -3170,45 +3174,45 @@ packages: source-map: 0.6.1 dev: false - /[email protected]([email protected]): + /[email protected]([email protected]): resolution: {integrity: sha512-Jia4JDldWnFNIru1Ehx1H5s9/yxiRHY/TimCuUc0jNexew3cF1gI6CYZil1ociakfWO3rRqFjl1mskBblB3RYg==} engines: {node: '>=12'} peerDependencies: eslint: '>=6.0.0' dependencies: - eslint: 8.51.0 + eslint: 8.52.0 dev: true - /[email protected]([email protected]): + /[email protected]([email protected]): resolution: {integrity: sha512-IcJsTkJae2S35pRsRAwoCE+925rJJStOdkKnLVgtE+tEpqU0EVVM7OqrwxqgptKdX29NUwC82I5pXsGFIgSevw==} hasBin: true peerDependencies: eslint: '>=7.0.0' dependencies: - eslint: 8.51.0 + eslint: 8.52.0 dev: true - /[email protected]([email protected]): + /[email protected]([email protected]): resolution: {integrity: sha512-9dvv5CcvNjSJPqnS5uZkqb3xmbeqRLnvXKK7iI5+oK/yTusyc46zbBZKENGsOfojm/mKfszyZb+wNqNPAPeGXA==} engines: {node: ^14.18.0 || >=16.0.0} peerDependencies: eslint: '>=8' dependencies: - '@eslint-community/eslint-utils': 4.4.0([email protected]) + '@eslint-community/eslint-utils': 4.4.0([email protected]) '@eslint-community/regexpp': 4.8.0 - eslint: 8.51.0 + eslint: 8.52.0 dev: true - /[email protected]([email protected]): + /[email protected]([email protected]): resolution: {integrity: sha512-AQER2jEyQOt1LG6JkGJCCIFotzmlcCZFur2wdKrp1JX2cNotC7Ae0BcD/4lLv3lUAArM9uNS8z/fsvXTd0L71g==} engines: {node: '>=16.0.0'} peerDependencies: eslint: '>=7.0.0' dependencies: - '@eslint-community/eslint-utils': 4.4.0([email protected]) + '@eslint-community/eslint-utils': 4.4.0([email protected]) builtins: 5.0.1 - eslint: 8.51.0 - eslint-plugin-es-x: 7.2.0([email protected]) + eslint: 8.52.0 + eslint-plugin-es-x: 7.2.0([email protected]) get-tsconfig: 4.7.0 ignore: 5.2.4 is-core-module: 2.13.0 @@ -3217,7 +3221,7 @@ packages: semver: 7.5.4 dev: true - /[email protected](@types/[email protected])([email protected])([email protected])([email protected]): + /[email protected](@types/[email protected])([email protected])([email protected])([email protected]): resolution: {integrity: sha512-m3u5RnR56asrwV/lDC4GHorlW75DsFfmUcjfCYylTUs85dBRnB7VM6xG8eCMJdeDRnppzmxZVf1GEPJvl1JmNg==} engines: {node: ^14.18.0 || >=16.0.0} peerDependencies: @@ -3232,22 +3236,22 @@ packages: optional: true dependencies: '@types/eslint': 8.44.6 - eslint: 8.51.0 - eslint-config-prettier: 9.0.0([email protected]) + eslint: 8.52.0 + eslint-config-prettier: 9.0.0([email protected]) prettier: 3.0.3 prettier-linter-helpers: 1.0.0 synckit: 0.8.5 dev: true - /[email protected]([email protected]): + /[email protected]([email protected]): resolution: {integrity: sha512-53SUwuNDna97lVk38hL/5++WXDuugPM9SUQ1T645R0EHMRCdBIIxGye/oOX2qO3FQ7aImxaUZJU/ju+NMUBrLQ==} engines: {node: ^14.17.0 || >=16.0.0} peerDependencies: eslint: '>=6.0.0' dependencies: debug: 4.3.4 - eslint: 8.51.0 - eslint-compat-utils: 0.1.2([email protected]) + eslint: 8.52.0 + eslint-compat-utils: 0.1.2([email protected]) lodash: 4.17.21 natural-compare: 1.4.0 yaml-eslint-parser: 1.2.2 @@ -3268,18 +3272,19 @@ packages: engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dev: true - /[email protected]: - resolution: {integrity: sha512-2WuxRZBrlwnXi+/vFSJyjMqrNjtJqiasMzehF0shoLaW7DzS3/9Yvrmq5JiT66+pNjiX4UBnLDiKHcWAr/OInA==} + /[email protected]: + resolution: {integrity: sha512-zh/JHnaixqHZsolRB/w9/02akBk9EPrOs9JwcTP2ek7yL5bVvXuRariiaAjjoJ5DvuwQ1WAE/HsMz+w17YgBCg==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} hasBin: true dependencies: - '@eslint-community/eslint-utils': 4.4.0([email protected]) + '@eslint-community/eslint-utils': 4.4.0([email protected]) '@eslint-community/regexpp': 4.8.0 '@eslint/eslintrc': 2.1.2 - '@eslint/js': 8.51.0 - '@humanwhocodes/config-array': 0.11.11 + '@eslint/js': 8.52.0 + '@humanwhocodes/config-array': 0.11.13 '@humanwhocodes/module-importer': 1.0.1 '@nodelib/fs.walk': 1.2.8 + '@ungap/structured-clone': 1.2.0 ajv: 6.12.6 chalk: 4.1.2 cross-spawn: 7.0.3
b7d0e5eb9976496eb925a2ae814a5ce008fc9e4f
2020-01-03 09:02:37
SweetDumpling
fix: maoyan upcoming (#3665)
false
maoyan upcoming (#3665)
fix
diff --git a/lib/routes/maoyan/upcoming.js b/lib/routes/maoyan/upcoming.js index 2f97dea194e34e..db9e5f8a29a2e1 100644 --- a/lib/routes/maoyan/upcoming.js +++ b/lib/routes/maoyan/upcoming.js @@ -4,6 +4,9 @@ module.exports = async (ctx) => { const response = await got({ method: 'get', url: 'https://m.maoyan.com/ajax/comingList?token=', + headers: { + cookie: '_lxsdk_cuid=16c04ba8492c8-00efb7395fe43-4c312272-e1000-16c04ba8492c8;', + }, }); const data = response.data.coming; const items = await Promise.all( @@ -16,9 +19,9 @@ module.exports = async (ctx) => { ); ctx.state.data = { - title: `猫眼电影 - 正在热映`, + title: `猫眼电影 - 即将上映`, link: `https://maoyan.com/films?showType=2`, - description: `猫眼电影 - 正在热映`, + description: `猫眼电影 - 即将上映`, item: items, }; };
d218467863977f0011310913e825dd859818d93b
2019-07-08 09:23:24
renovate[bot]
chore(deps): update dependency nock to v11.0.0-beta.21 (#2582)
false
update dependency nock to v11.0.0-beta.21 (#2582)
chore
diff --git a/package.json b/package.json index 4c1fd253c987b8..da384754cc23f7 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "eslint-plugin-prettier": "3.1.0", "jest": "24.8.0", "mockdate": "2.0.3", - "nock": "11.0.0-beta.20", + "nock": "11.0.0-beta.21", "nodemon": "1.19.1", "pinyin": "2.9.0", "prettier": "1.18.2", diff --git a/yarn.lock b/yarn.lock index 420f2ebceeb6e9..c29d77d924c505 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6886,10 +6886,10 @@ no-case@^2.2.0: dependencies: lower-case "^1.1.1" [email protected]: - version "11.0.0-beta.20" - resolved "https://registry.yarnpkg.com/nock/-/nock-11.0.0-beta.20.tgz#1566512010e4c5c6adc2244f611b2023c008c587" - integrity sha512-vZp0yVA793qXU6RmTOcOKqqzNWUEgaLizYwNyaq8p7wVHqlbcomIn3BlHIBzJMEF5z/JEvS9drPccoxct0kGMQ== [email protected]: + version "11.0.0-beta.21" + resolved "https://registry.yarnpkg.com/nock/-/nock-11.0.0-beta.21.tgz#c02c66fb7d26cc49677d1252aeadb4791991e762" + integrity sha512-t/gf913pdw34y4ZbkWsDXXd9ShtCRcScZTFLzd1LPcr/W6lUrGYQxtQ4zWwUnnLqcG2mejOaCP8tcckc7QsXEA== dependencies: chai "^4.1.2" debug "^4.1.0"
e025857586960fe9ffdab01e2b7853b6c404550a
2021-03-02 12:29:03
Ethan Shen
feat(route): add shuax 项目 (#7025)
false
add shuax 项目 (#7025)
feat
diff --git a/docs/program-update.md b/docs/program-update.md index 57cc1409169bbf..91114ab09aadbe 100644 --- a/docs/program-update.md +++ b/docs/program-update.md @@ -354,6 +354,18 @@ pageClass: routes <Route author="nczitzk" example="/sesame/release_notes" path="/sesame/release_notes"/> +## Shuax + +### Project + +<Route author="nczitzk" example="/shuax/project/chrome" path="/shuax/project" :paramsDesc="['项目名,见下表,默认为 MouseInc']"> + +| MouseInc | Chrome | Edge | +| -------- | ------ | ---- | +| mouseinc | chrome | edge | + +</Route> + ## simpread ### 消息通知 diff --git a/lib/router.js b/lib/router.js index c62a3af6295fbb..3a8160ab13056d 100644 --- a/lib/router.js +++ b/lib/router.js @@ -3933,6 +3933,9 @@ router.get('/tianyancha/hot', require('./routes/tianyancha/hot')); // King Arthur router.get('/kingarthur/:type', require('./routes/kingarthur/index')); +// Shuax +router.get('/shuax/project/:name?', require('./routes/shuax/project')); + // BioOne router.get('/bioone/featured', require('./routes/bioone/featured')); diff --git a/lib/routes/shuax/project.js b/lib/routes/shuax/project.js new file mode 100644 index 00000000000000..f38fb33aa52d98 --- /dev/null +++ b/lib/routes/shuax/project.js @@ -0,0 +1,37 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + +module.exports = async (ctx) => { + const name = ctx.params.name || 'mouseinc'; + + const rootUrl = 'https://shuax.com'; + const currentUrl = `${rootUrl}/project/${name}`; + const response = await got({ + method: 'get', + url: currentUrl, + }); + + const $ = cheerio.load(response.data); + + $('.love-box').remove(); + + const title = $('title').text(); + + ctx.state.data = { + title: `${title.split(' ')[0]} - 耍下`, + link: currentUrl, + item: [ + { + link: currentUrl, + title: title.replace(' – 耍下', ''), + description: $('#page-content').html(), + pubDate: new Date( + response.data + .match(/\d{4}年\d+月\d+日/)[0] + .replace(/年|月/g, '-') + .replace('日', '') + ).toUTCString(), + }, + ], + }; +};
01147c7623e62a2eb17f6776022fa262bfdff1f0
2024-06-24 21:36:53
Hossein Margani
feat(route): add Microsoft Artifact Registry route (#15973)
false
add Microsoft Artifact Registry route (#15973)
feat
diff --git a/lib/routes/microsoft/mcr.ts b/lib/routes/microsoft/mcr.ts new file mode 100644 index 00000000000000..56580750bd9cad --- /dev/null +++ b/lib/routes/microsoft/mcr.ts @@ -0,0 +1,63 @@ +import { Route } from '@/types'; +import got from '@/utils/got'; + +export const route: Route = { + path: '/mcr/product/*', + categories: ['program-update'], + example: '/microsoft/mcr/product/dotnet/framework/runtime', + parameters: { product: 'repository path in mcr.microsoft.com' }, + features: { + requireConfig: false, + requirePuppeteer: false, + antiCrawler: false, + supportBT: false, + supportPodcast: false, + supportScihub: false, + }, + radar: [ + { + source: ['https://mcr.microsoft.com/en-us/product/:product/tags'], + }, + ], + name: 'Product tags in mcr.microsoft.com', + maintainers: ['margani'], + handler, +}; + +async function handler(ctx) { + const product = ctx.req.path.replace('/microsoft/mcr/product/', ''); + const { data: details } = await got({ + method: 'get', + url: `https://mcr.microsoft.com/api/v1/catalog/${product}/details`, + }); + const { data: tags } = await got({ + method: 'get', + url: `https://mcr.microsoft.com/api/v1/catalog/${product}/tags`, + }); + + return { + title: `${details.name} - Microsoft Artifact Registry`, + description: String(details.shortDescription), + image: `https://mcr.microsoft.com${details.imagePath}`, + link: `https://mcr.microsoft.com/en-us/product/${product}`, + item: tags.map((tag: any) => { + const descriptionItems = [`Digest: \`${tag.digest}\``, `Last modified date: ${new Date(tag.lastModifiedDate).toDateString()}`]; + + if (tag.architecture) { + descriptionItems.push(`Architecture: ${tag.architecture}`); + } + if (tag.operatingSystem) { + descriptionItems.push(`Operating system: ${tag.operatingSystem}`); + } + + return { + title: `${details.name} - ${tag.name}`, + author: details.publisher, + description: descriptionItems.join('<br />'), + pubDate: new Date(tag.lastModifiedDate), + guid: `mcr::${product}::${tag.name}::${tag.digest}`, + link: `https://mcr.microsoft.com/en-us/product/${product}/tags`, + }; + }), + }; +} diff --git a/lib/routes/microsoft/namespace.ts b/lib/routes/microsoft/namespace.ts index 74ca7a2610cd21..44f7a31b63f5d6 100644 --- a/lib/routes/microsoft/namespace.ts +++ b/lib/routes/microsoft/namespace.ts @@ -1,6 +1,6 @@ import type { Namespace } from '@/types'; export const namespace: Namespace = { - name: 'Microsoft Edge', - url: 'microsoftedge.microsoft.com', + name: 'Microsoft', + url: 'microsoft.com', };
c13de97b78c5159befec7c9cfedce6ea33373c07
2025-01-12 18:34:16
Tsuyumi25
feat(misskey): add avatar to user timeline (#18104)
false
add avatar to user timeline (#18104)
feat
diff --git a/lib/routes/misskey/types.ts b/lib/routes/misskey/types.ts index e6b695f4293824..2aff1cc2f15510 100644 --- a/lib/routes/misskey/types.ts +++ b/lib/routes/misskey/types.ts @@ -51,7 +51,7 @@ export interface MisskeyNote { } // https://github.com/misskey-dev/misskey/blob/d2e8dc4fe3c6e90e68001ed1f092d4e3d2454283/packages/backend/src/models/json-schema/user.ts -interface MisskeyUser { +export interface MisskeyUser { id: string; name: string | null; username: string; diff --git a/lib/routes/misskey/user-timeline.ts b/lib/routes/misskey/user-timeline.ts index 3d97eef28affad..3cbdc24ad06280 100644 --- a/lib/routes/misskey/user-timeline.ts +++ b/lib/routes/misskey/user-timeline.ts @@ -1,4 +1,4 @@ -import { Route, ViewType } from '@/types'; +import { Route, ViewType, Data } from '@/types'; import utils from './utils'; import { config } from '@/config'; import ConfigNotFoundError from '@/errors/types/config-not-found'; @@ -38,7 +38,7 @@ Examples: handler, }; -async function handler(ctx) { +async function handler(ctx): Promise<Data> { const username = ctx.req.param('username'); const [, pureUsername, site] = username.match(/@?(\w+)@(\w+\.\w+)/) || []; if (!pureUsername || !site) { @@ -57,7 +57,7 @@ async function handler(ctx) { throw new InvalidParameterError('withRenotes and mediaOnly cannot both be true.'); } - const { accountData } = await utils.getUserTimelineByUsername(pureUsername, site, { + const { accountData, avatarUrl } = await utils.getUserTimelineByUsername(pureUsername, site, { withRenotes, mediaOnly, }); @@ -65,6 +65,7 @@ async function handler(ctx) { return { title: `User timeline for ${username} on ${site}`, link: `https://${site}/@${pureUsername}`, + image: avatarUrl || '', item: utils.parseNotes(accountData, site), }; } diff --git a/lib/routes/misskey/utils.ts b/lib/routes/misskey/utils.ts index 0d852b80f09575..5d140c3af68733 100644 --- a/lib/routes/misskey/utils.ts +++ b/lib/routes/misskey/utils.ts @@ -7,7 +7,7 @@ import path from 'node:path'; import cache from '@/utils/cache'; import got from '@/utils/got'; -import { MisskeyNote } from './types'; +import { MisskeyNote, MisskeyUser } from './types'; const allowSiteList = ['misskey.io', 'madost.one', 'mk.nixnet.social']; @@ -71,7 +71,7 @@ async function getUserTimelineByUsername(username, site, { withRenotes = false, const searchUrl = `https://${site}/api/users/search-by-username-and-host`; const cacheUid = `misskey_username/${site}/${username}`; - const accountId = await cache.tryGet(cacheUid, async () => { + const userData = (await cache.tryGet(cacheUid, async () => { const searchResponse = await got({ method: 'post', url: searchUrl, @@ -82,13 +82,16 @@ async function getUserTimelineByUsername(username, site, { withRenotes = false, limit: 1, }, }); - const userData = searchResponse.data.find((item) => item.username === username); + const user = searchResponse.data.find((item) => item.username === username); - if (!userData) { + if (!user) { throw new Error(`username ${username} not found`); } - return userData.id; - }); + return user; + })) as MisskeyUser; + + const accountId = userData.id; + const avatarUrl = userData.avatarUrl; // https://misskey.io/api-doc#tag/users/operation/users___notes const usernotesUrl = `https://${site}/api/users/notes`; @@ -106,7 +109,7 @@ async function getUserTimelineByUsername(username, site, { withRenotes = false, }, }); const accountData = usernotesResponse.data; - return { site, accountId, accountData }; + return { site, accountId, accountData, avatarUrl }; } export default { parseNotes, getUserTimelineByUsername, allowSiteList };
f51bfaeb0c5b127f293479fcfa069c0083f5124a
2022-02-21 19:23:34
Kasper
feat(route): add nogizaka46 blog (#9161)
false
add nogizaka46 blog (#9161)
feat
diff --git a/docs/new-media.md b/docs/new-media.md index a6c29fc25be3da..7f241a99d3c8a4 100644 --- a/docs/new-media.md +++ b/docs/new-media.md @@ -1232,6 +1232,10 @@ Supported sub-sites: <Route author="crispgm Fatpandac" example="/nogizaka46/news" path="/nogizaka46/news" /> +### 乃木坂 46 博客 + +<Route author="Kasper4649" example="/nogizaka46/blog" path="/nogizaka46/blog" /> + ### 欅坂 46 新闻 <Route author="crispgm" example="/keyakizaka46/news" path="/keyakizaka46/news" /> diff --git a/lib/v2/nogizaka46/blog.js b/lib/v2/nogizaka46/blog.js new file mode 100644 index 00000000000000..337110a8984da7 --- /dev/null +++ b/lib/v2/nogizaka46/blog.js @@ -0,0 +1,29 @@ +const got = require('@/utils/got'); +const { parseDate } = require('@/utils/parse-date'); + +const rootUrl = 'https://www.nogizaka46.com'; + +module.exports = async (ctx) => { + const response = await got({ + method: 'get', + url: `${rootUrl}/s/n46/api/list/blog`, + }); + + const list = JSON.parse(response.data.slice(4).slice(0, -2)).data; + + ctx.state.data = { + allowEmpty: true, + title: '乃木坂46 公式ブログ', + link: 'https://www.nogizaka46.com/s/n46/diary/MEMBER', + item: + list && + list.map((item) => ({ + title: item.title, + link: item.link, + pubDate: parseDate(item.date), + author: item.name, + description: item.text, + guid: rootUrl + new URL(item.link).pathname, + })), + }; +}; diff --git a/lib/v2/nogizaka46/maintainer.js b/lib/v2/nogizaka46/maintainer.js index c825d22f250308..01b4642bb06b66 100644 --- a/lib/v2/nogizaka46/maintainer.js +++ b/lib/v2/nogizaka46/maintainer.js @@ -1,3 +1,4 @@ module.exports = { '/news': ['crispgm', 'Fatpandac'], + '/blog': ['Kasper4649'], }; diff --git a/lib/v2/nogizaka46/radar.js b/lib/v2/nogizaka46/radar.js index dece9922b0ab3e..794eb97fcc810b 100644 --- a/lib/v2/nogizaka46/radar.js +++ b/lib/v2/nogizaka46/radar.js @@ -1,13 +1,21 @@ module.exports = { 'nogizaka46.com': { _name: '乃木坂46', - '.': [ + news: [ { title: '新闻', docs: 'https://docs.rsshub.app/new-media.html#ban-dao-xi-lie-guan-wang-zi-xun-nai-mu-ban-46-xin-wen', - source: ['/', '/s/n46/news/list'], + source: ['/s/n46/news/list'], target: '/nogizaka46/news', }, ], + blog: [ + { + title: '博客', + docs: 'https://docs.rsshub.app/new-media.html#ban-dao-xi-lie-guan-wang-zi-xun-nai-mu-ban-46-bo-ke', + source: ['/s/n46/diary/MEMBER'], + target: '/nogizaka46/blog', + }, + ], }, }; diff --git a/lib/v2/nogizaka46/router.js b/lib/v2/nogizaka46/router.js index 69a5972f6a8112..d0c2b646347e95 100644 --- a/lib/v2/nogizaka46/router.js +++ b/lib/v2/nogizaka46/router.js @@ -1,3 +1,4 @@ module.exports = function (router) { router.get('/news', require('./news')); + router.get('/blog', require('./blog')); };
91446102fc931fca6bd24007ba56e0d108529e9a
2019-07-30 09:01:41
dependabot-preview[bot]
chore(deps-dev): bump @vuepress/plugin-pwa from 1.0.2 to 1.0.3
false
bump @vuepress/plugin-pwa from 1.0.2 to 1.0.3
chore
diff --git a/package.json b/package.json index 62c59555a6e33c..a117ed0da5bdbc 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ "devDependencies": { "@vuepress/plugin-back-to-top": "1.0.3", "@vuepress/plugin-google-analytics": "1.0.2", - "@vuepress/plugin-pwa": "1.0.2", + "@vuepress/plugin-pwa": "1.0.3", "cross-env": "5.2.0", "eslint": "6.1.0", "eslint-config-prettier": "6.0.0", diff --git a/yarn.lock b/yarn.lock index 464523121a83df..a73754496dd2e6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1160,12 +1160,12 @@ dependencies: nprogress "^0.2.0" -"@vuepress/[email protected]": - version "1.0.2" - resolved "https://registry.yarnpkg.com/@vuepress/plugin-pwa/-/plugin-pwa-1.0.2.tgz#af37e2e1b3b29382a4daf8c2e350059b769dd3cb" - integrity sha512-UNFcZCUS2p0Ox9yH/VWzdivBJZTPjbfpXv53Pcv/PdEnwlVjRyM2rhD2gyBBe/Y+M7k4imRJI3SaAOOjVRq1BQ== +"@vuepress/[email protected]": + version "1.0.3" + resolved "https://registry.yarnpkg.com/@vuepress/plugin-pwa/-/plugin-pwa-1.0.3.tgz#4cf668fcf49a5875bbee2307695277d5adea78d3" + integrity sha512-kPvjo74/XqEivTd2QtS0SWD386GHpyuBCg1Km1HdaajIez8gvpQYG6AiLGNFlvFBc+hwEB2GHQkxSR2QvnPVUQ== dependencies: - "@vuepress/shared-utils" "^1.0.2" + "@vuepress/shared-utils" "^1.0.3" register-service-worker "^1.5.2" workbox-build "^4.3.1" @@ -1181,10 +1181,10 @@ resolved "https://registry.yarnpkg.com/@vuepress/plugin-search/-/plugin-search-1.0.2.tgz#6d43fb46b207d48b797a5bc5b01824662db4684d" integrity sha512-LCFZLp+adppdHETIEARwQhczj+mdpa+D25qL9RNmYxzU9mF6qItYNLl57P6omGU2Vr8frAc+rWgjbi4cjkbCvQ== -"@vuepress/shared-utils@^1.0.2": - version "1.0.2" - resolved "https://registry.yarnpkg.com/@vuepress/shared-utils/-/shared-utils-1.0.2.tgz#4e1342748b7594fe4fde9dce3bf201538fa5ca67" - integrity sha512-QyNV76Dn0u2ooXbC3AXJZrQLuTNS4i8xSmJqZWsel2ooJKknXP3UIMIENcK1QFHnlIACznyV53u9hRAYBaZEWQ== +"@vuepress/shared-utils@^1.0.2", "@vuepress/shared-utils@^1.0.3": + version "1.0.3" + resolved "https://registry.yarnpkg.com/@vuepress/shared-utils/-/shared-utils-1.0.3.tgz#224d2fc10fcf26d871eae8dd93b810616731123f" + integrity sha512-E9kh+nk+E0X6GTONXK1OWeY7Yyl/bUkWltmdh89f7hcSn2MxuBmlph4JdtZKrTK2m+9EqzpVR+CYanGjTA/ZQA== dependencies: chalk "^2.3.2" diacritics "^1.3.0"
83a0f2d705c6cad59d07485e6163ad6ee43973e9
2020-12-04 21:29:38
Ethan Shen
feat: add xyplorer what's new (#6334)
false
add xyplorer what's new (#6334)
feat
diff --git a/docs/en/program-update.md b/docs/en/program-update.md index 86f58cab1d552f..9ffb1e908b4a35 100644 --- a/docs/en/program-update.md +++ b/docs/en/program-update.md @@ -232,3 +232,9 @@ Refer to [#minecraft](/en/game.html#minecraft) ### Module Update <RouteEn author="nczitzk" example="/xposed/module/com.ext.star.wars" path="/xposed/module/:mod" :paramsDesc="['module package name']"/> + +## XYplorer + +### What's New + +<RouteEn author="nczitzk" example="/xyplorer/whatsnew" path="/xyplorer/whatsnew"/> \ No newline at end of file diff --git a/docs/program-update.md b/docs/program-update.md index ebdc8b299c0123..1db285b943569b 100644 --- a/docs/program-update.md +++ b/docs/program-update.md @@ -312,6 +312,12 @@ pageClass: routes <Route author="nczitzk" example="/xposed/module/com.ext.star.wars" path="/xposed/module/:mod" :paramsDesc="['模块包名, 模块页中的 Package 字段']"/> +## XYplorer + +### What's New + +<Route author="nczitzk" example="/xyplorer/whatsnew" path="/xyplorer/whatsnew"/> + ## 怪物猎人世界 ### 更新 diff --git a/lib/router.js b/lib/router.js index 3f5fd2f9d657f1..afdbf741637378 100644 --- a/lib/router.js +++ b/lib/router.js @@ -3517,6 +3517,9 @@ router.get('/uisdc/news', require('./routes/uisdc/news')); router.get('/uisdc/zt/:title?', require('./routes/uisdc/zt')); router.get('/uisdc/topic/:title?/:sort?', require('./routes/uisdc/topic')); +// XYplorer +router.get('/xyplorer/whatsnew', require('./routes/xyplorer/whatsnew')); + // RescueTime router.get('/rescuetime/release-notes/:os?', require('./routes/rescuetime/release-notes')); diff --git a/lib/routes/xyplorer/whatsnew.js b/lib/routes/xyplorer/whatsnew.js new file mode 100644 index 00000000000000..f7319e66651f8b --- /dev/null +++ b/lib/routes/xyplorer/whatsnew.js @@ -0,0 +1,32 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const date = require('@/utils/date'); + +module.exports = async (ctx) => { + const rootUrl = 'https://www.xyplorer.com'; + const currentUrl = `${rootUrl}/whatsnew.php`; + const response = await got({ + method: 'get', + url: currentUrl, + }); + + const $ = cheerio.load(response.data); + + const items = $('.waznu') + .map((_, item) => { + item = $(item); + return { + link: currentUrl, + description: item.html(), + title: item.prev().prev().text(), + pubDate: date(item.prev().text().replace('released ', '')), + }; + }) + .get(); + + ctx.state.data = { + title: $('title').text(), + link: currentUrl, + item: items, + }; +};
f3844a3b9922674367bbd38d74288ca8740f5009
2024-12-03 16:46:44
dependabot[bot]
chore(deps-dev): bump @typescript-eslint/eslint-plugin (#17784)
false
bump @typescript-eslint/eslint-plugin (#17784)
chore
diff --git a/package.json b/package.json index 89e9722c69828e..62bbc562d39dbf 100644 --- a/package.json +++ b/package.json @@ -167,7 +167,7 @@ "@types/tiny-async-pool": "2.0.3", "@types/title": "3.4.3", "@types/uuid": "10.0.0", - "@typescript-eslint/eslint-plugin": "8.16.0", + "@typescript-eslint/eslint-plugin": "8.17.0", "@typescript-eslint/parser": "8.17.0", "@vercel/nft": "0.27.7", "@vitest/coverage-v8": "2.0.5", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 4fb86454c7b8b3..bc954947836b93 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -362,8 +362,8 @@ importers: specifier: 10.0.0 version: 10.0.0 '@typescript-eslint/eslint-plugin': - specifier: 8.16.0 - version: 8.16.0(@typescript-eslint/[email protected]([email protected])([email protected]))([email protected])([email protected]) + specifier: 8.17.0 + version: 8.17.0(@typescript-eslint/[email protected]([email protected])([email protected]))([email protected])([email protected]) '@typescript-eslint/parser': specifier: 8.17.0 version: 8.17.0([email protected])([email protected]) @@ -1994,8 +1994,8 @@ packages: '@types/[email protected]': resolution: {integrity: sha512-oJoftv0LSuaDZE3Le4DbKX+KS9G36NzOeSap90UIK0yMA/NhKJhqlSGtNDORNRaIbQfzjXDrQa0ytJ6mNRGz/Q==} - '@typescript-eslint/[email protected]': - resolution: {integrity: sha512-5YTHKV8MYlyMI6BaEG7crQ9BhSc8RxzshOReKwZwRWN0+XvvTOm+L/UYLCYxFpfwYuAAqhxiq4yae0CMFwbL7Q==} + '@typescript-eslint/[email protected]': + resolution: {integrity: sha512-HU1KAdW3Tt8zQkdvNoIijfWDMvdSweFYm4hWh+KwhPstv+sCmWb89hCIP8msFm9N1R/ooh9honpSuvqKWlYy3w==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} peerDependencies: '@typescript-eslint/parser': ^8.0.0 || ^8.0.0-alpha.0 @@ -2019,16 +2019,12 @@ packages: resolution: {integrity: sha512-aBbBrnW9ARIDn92Zbo7rguLnqQ/pOrUguVpbUwzOhkFg2npFDwTgPGqFqE0H5feXcOoJOfX3SxlJaKEVtq54dw==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} - '@typescript-eslint/[email protected]': - resolution: {integrity: sha512-mwsZWubQvBki2t5565uxF0EYvG+FwdFb8bMtDuGQLdCCnGPrDEDvm1gtfynuKlnpzeBRqdFCkMf9jg1fnAK8sg==} - engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} - '@typescript-eslint/[email protected]': resolution: {integrity: sha512-/ewp4XjvnxaREtqsZjF4Mfn078RD/9GmiEAtTeLQ7yFdKnqwTOgRMSvFz4et9U5RiJQ15WTGXPLj89zGusvxBg==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} - '@typescript-eslint/[email protected]': - resolution: {integrity: sha512-IqZHGG+g1XCWX9NyqnI/0CX5LL8/18awQqmkZSl2ynn8F76j579dByc0jhfVSnSnhf7zv76mKBQv9HQFKvDCgg==} + '@typescript-eslint/[email protected]': + resolution: {integrity: sha512-q38llWJYPd63rRnJ6wY/ZQqIzPrBCkPdpIsaCfkR3Q4t3p6sb422zougfad4TFW9+ElIFLVDzWGiGAfbb/v2qw==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} peerDependencies: eslint: ^8.57.0 || ^9.0.0 @@ -2041,10 +2037,6 @@ packages: resolution: {integrity: sha512-yjeB9fnO/opvLJFAsPNYlKPnEM8+z4og09Pk504dkqonT02AyL5Z9SSqlE0XqezS93v6CXn49VHvB2G7XSsl0g==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} - '@typescript-eslint/[email protected]': - resolution: {integrity: sha512-NzrHj6thBAOSE4d9bsuRNMvk+BvaQvmY4dDglgkgGC0EW/tB3Kelnp3tAKH87GEwzoxgeQn9fNGRyFJM/xd+GQ==} - engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} - '@typescript-eslint/[email protected]': resolution: {integrity: sha512-gY2TVzeve3z6crqh2Ic7Cr+CAv6pfb0Egee7J5UAVWCpVvDI/F71wNfolIim4FE6hT15EbpZFVUj9j5i38jYXA==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} @@ -2058,15 +2050,6 @@ packages: typescript: optional: true - '@typescript-eslint/[email protected]': - resolution: {integrity: sha512-E2+9IzzXMc1iaBy9zmo+UYvluE3TW7bCGWSF41hVWUE01o8nzr1rvOQYSxelxr6StUvRcTMe633eY8mXASMaNw==} - engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} - peerDependencies: - typescript: '*' - peerDependenciesMeta: - typescript: - optional: true - '@typescript-eslint/[email protected]': resolution: {integrity: sha512-JqkOopc1nRKZpX+opvKqnM3XUlM7LpFMD0lYxTqOTKQfCWAmxw45e3qlOCsEqEB2yuacujivudOFpCnqkBDNMw==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} @@ -2082,8 +2065,8 @@ packages: peerDependencies: eslint: ^8.57.0 || ^9.0.0 - '@typescript-eslint/[email protected]': - resolution: {integrity: sha512-C1zRy/mOL8Pj157GiX4kaw7iyRLKfJXBR3L82hk5kS/GyHcOFmy4YUq/zfZti72I9wnuQtA/+xzft4wCC8PJdA==} + '@typescript-eslint/[email protected]': + resolution: {integrity: sha512-bQC8BnEkxqG8HBGKwG9wXlZqg37RKSMY7v/X8VEWD8JG2JuTHuNK0VFvMPMUKQcbk6B+tf05k+4AShAEtCtJ/w==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} peerDependencies: eslint: ^8.57.0 || ^9.0.0 @@ -2096,10 +2079,6 @@ packages: resolution: {integrity: sha512-vG0XZo8AdTH9OE6VFRwAZldNc7qtJ/6NLGWak+BtENuEUXGZgFpihILPiBvKXvJ2nFu27XNGC6rKiwuaoMbYzQ==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} - '@typescript-eslint/[email protected]': - resolution: {integrity: sha512-pq19gbaMOmFE3CbL0ZB8J8BFCo2ckfHBfaIsaOZgBIF4EoISJIdLX5xRhd0FGB0LlHReNRuzoJoMGpTjq8F2CQ==} - engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} - '@typescript-eslint/[email protected]': resolution: {integrity: sha512-1Hm7THLpO6ww5QU6H/Qp+AusUUl+z/CAm3cNZZ0jQvon9yicgO7Rwd+/WWRpMKLYV6p2UvdbR27c86rzCPpreg==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} @@ -7479,14 +7458,14 @@ snapshots: '@types/node': 22.10.1 optional: true - '@typescript-eslint/[email protected](@typescript-eslint/[email protected]([email protected])([email protected]))([email protected])([email protected])': + '@typescript-eslint/[email protected](@typescript-eslint/[email protected]([email protected])([email protected]))([email protected])([email protected])': dependencies: '@eslint-community/regexpp': 4.12.1 '@typescript-eslint/parser': 8.17.0([email protected])([email protected]) - '@typescript-eslint/scope-manager': 8.16.0 - '@typescript-eslint/type-utils': 8.16.0([email protected])([email protected]) - '@typescript-eslint/utils': 8.16.0([email protected])([email protected]) - '@typescript-eslint/visitor-keys': 8.16.0 + '@typescript-eslint/scope-manager': 8.17.0 + '@typescript-eslint/type-utils': 8.17.0([email protected])([email protected]) + '@typescript-eslint/utils': 8.17.0([email protected])([email protected]) + '@typescript-eslint/visitor-keys': 8.17.0 eslint: 9.16.0 graphemer: 1.4.0 ignore: 5.3.2 @@ -7515,20 +7494,15 @@ snapshots: '@typescript-eslint/types': 8.14.0 '@typescript-eslint/visitor-keys': 8.14.0 - '@typescript-eslint/[email protected]': - dependencies: - '@typescript-eslint/types': 8.16.0 - '@typescript-eslint/visitor-keys': 8.16.0 - '@typescript-eslint/[email protected]': dependencies: '@typescript-eslint/types': 8.17.0 '@typescript-eslint/visitor-keys': 8.17.0 - '@typescript-eslint/[email protected]([email protected])([email protected])': + '@typescript-eslint/[email protected]([email protected])([email protected])': dependencies: - '@typescript-eslint/typescript-estree': 8.16.0([email protected]) - '@typescript-eslint/utils': 8.16.0([email protected])([email protected]) + '@typescript-eslint/typescript-estree': 8.17.0([email protected]) + '@typescript-eslint/utils': 8.17.0([email protected])([email protected]) debug: 4.3.7 eslint: 9.16.0 ts-api-utils: 1.4.0([email protected]) @@ -7539,8 +7513,6 @@ snapshots: '@typescript-eslint/[email protected]': {} - '@typescript-eslint/[email protected]': {} - '@typescript-eslint/[email protected]': {} '@typescript-eslint/[email protected]([email protected])': @@ -7558,21 +7530,6 @@ snapshots: transitivePeerDependencies: - supports-color - '@typescript-eslint/[email protected]([email protected])': - dependencies: - '@typescript-eslint/types': 8.16.0 - '@typescript-eslint/visitor-keys': 8.16.0 - debug: 4.3.7 - fast-glob: 3.3.2 - is-glob: 4.0.3 - minimatch: 9.0.5 - semver: 7.6.3 - ts-api-utils: 1.4.0([email protected]) - optionalDependencies: - typescript: 5.7.2 - transitivePeerDependencies: - - supports-color - '@typescript-eslint/[email protected]([email protected])': dependencies: '@typescript-eslint/types': 8.17.0 @@ -7599,12 +7556,12 @@ snapshots: - supports-color - typescript - '@typescript-eslint/[email protected]([email protected])([email protected])': + '@typescript-eslint/[email protected]([email protected])([email protected])': dependencies: '@eslint-community/eslint-utils': 4.4.1([email protected]) - '@typescript-eslint/scope-manager': 8.16.0 - '@typescript-eslint/types': 8.16.0 - '@typescript-eslint/typescript-estree': 8.16.0([email protected]) + '@typescript-eslint/scope-manager': 8.17.0 + '@typescript-eslint/types': 8.17.0 + '@typescript-eslint/typescript-estree': 8.17.0([email protected]) eslint: 9.16.0 optionalDependencies: typescript: 5.7.2 @@ -7616,11 +7573,6 @@ snapshots: '@typescript-eslint/types': 8.14.0 eslint-visitor-keys: 3.4.3 - '@typescript-eslint/[email protected]': - dependencies: - '@typescript-eslint/types': 8.16.0 - eslint-visitor-keys: 4.2.0 - '@typescript-eslint/[email protected]': dependencies: '@typescript-eslint/types': 8.17.0
4d8c291c4d130faddfee0037829cafe57acd472e
2019-11-21 08:43:51
Ir1dXD
feat: 支持订阅 Kaggle 全站 discussions (#3456)
false
支持订阅 Kaggle 全站 discussions (#3456)
feat
diff --git a/docs/programming.md b/docs/programming.md index 5aabaa96544261..491d4bcab7d593 100644 --- a/docs/programming.md +++ b/docs/programming.md @@ -158,7 +158,7 @@ GitHub 官方也提供了一些 RSS: ### Discussion -<Route author="LogicJake" example="/kaggle/discussion/387811/active" path="/kaggle/discussion/:forumId/:sort?" :paramsDesc="['讨论区 id, 打开网页请求, 搜索 forumId', '排序方式见下表, 默认为 hot']"> +<Route author="LogicJake" example="/kaggle/discussion/387811/active" path="/kaggle/discussion/:forumId/:sort?" :paramsDesc="['讨论区 id, 打开网页请求, 搜索 forumId;填 all 可以订阅全站讨论区', '排序方式见下表, 默认为 hot']"> | hot | recent | new | top | active | | ------- | --------------- | --------------- | ---------- | ------------- | diff --git a/lib/routes/kaggle/discussion.js b/lib/routes/kaggle/discussion.js index 90f52e935778ab..5be227d3eb9a0d 100644 --- a/lib/routes/kaggle/discussion.js +++ b/lib/routes/kaggle/discussion.js @@ -18,7 +18,10 @@ module.exports = async (ctx) => { const response = await got({ method: 'get', - url: `https://www.kaggle.com/forums/${forumId}/topics.json?sortBy=${sort}&group=all&page=1&pageSize=20&category=all`, + url: + forumId !== 'all' + ? `https://www.kaggle.com/forums/${forumId}/topics.json?sortBy=${sort}&group=all&page=1&pageSize=20&category=all` + : `https://www.kaggle.com/topics.json?sortBy=${sort}&group=all&page=1&pageSize=20&category=all`, headers: { Referer: rootUrl, },
b49df679df71cd4c08924c3717b66052cf6924d3
2024-07-10 23:55:22
Stephen Zhou
feat(route): github user activity (#16140)
false
github user activity (#16140)
feat
diff --git a/lib/routes/github/activity.ts b/lib/routes/github/activity.ts new file mode 100644 index 00000000000000..0e1ffa7a17af6c --- /dev/null +++ b/lib/routes/github/activity.ts @@ -0,0 +1,54 @@ +import { Route } from '@/types'; +import ofetch from '@/utils/ofetch'; +import { parseDate } from '@/utils/parse-date'; +import Parser from 'rss-parser'; + +const parser = new Parser(); + +export const route: Route = { + path: '/activity/:user', + name: 'User Activities', + maintainers: ['hyoban'], + example: '/github/activity/DIYgod', + categories: ['programming'], + parameters: { + user: 'GitHub username', + }, + description: 'Get the activities of a user on GitHub, based on the GitHub official RSS feed', + features: { + requireConfig: false, + requirePuppeteer: false, + antiCrawler: false, + supportBT: false, + supportPodcast: false, + supportScihub: false, + }, + radar: [ + { + source: ['github.com/:user'], + target: '/activity/:user', + }, + ], + handler: async (ctx) => { + const { user } = ctx.req.param(); + const response = (await ofetch(`https://github.com/${user}.atom`)) as Blob; + const raw = await response.text(); + // <media:thumbnail height="30" width="30" url="https://avatars.githubusercontent.com/u/8266075?s=30&amp;v=4"/> + const image = raw.match(/<media:thumbnail height="30" width="30" url="(.+?)"/)?.[1]; + const feed = await parser.parseString(raw); + return { + title: `${user}'s GitHub Public Timeline Feed`, + link: feed.link, + image, + item: feed.items.map((item) => ({ + title: item.title ?? '', + link: item.link, + description: item.content?.replace(/href="(.+?)"/g, `href="https://github.com$1"`), + pubDate: item.pubDate ? parseDate(item.pubDate) : undefined, + author: item.author, + id: item.id, + image, + })), + }; + }, +};
a3f556d4de1536ba8a798fd2049cbffa9d6a84ae
2022-02-17 04:57:26
dependabot[bot]
chore(deps): bump @sentry/node from 6.17.8 to 6.17.9 (#9126)
false
bump @sentry/node from 6.17.8 to 6.17.9 (#9126)
chore
diff --git a/package.json b/package.json index 11f2411e0ba87c..9d8ce676de1ef6 100644 --- a/package.json +++ b/package.json @@ -76,7 +76,7 @@ "dependencies": { "@koa/router": "10.1.1", "@postlight/mercury-parser": "2.2.1", - "@sentry/node": "6.17.8", + "@sentry/node": "6.17.9", "aes-js": "3.1.2", "art-template": "4.13.2", "bbcodejs": "0.0.4", diff --git a/yarn.lock b/yarn.lock index b0c6b6c98af5a9..f9ec3cc60059ed 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1404,72 +1404,72 @@ domhandler "^4.2.0" selderee "^0.6.0" -"@sentry/[email protected]": - version "6.17.8" - resolved "https://registry.yarnpkg.com/@sentry/core/-/core-6.17.8.tgz#7dbdf394b47ed46048cbad6a8519cb3c4b84d6c4" - integrity sha512-4WTjgQom75Rvgn6XYy6e7vMIbWlj8utau1wWvr7kjqFKuuuuycRvPgVzAdVr4B3WDHHCInAZpUchsOLs2qwIEA== - dependencies: - "@sentry/hub" "6.17.8" - "@sentry/minimal" "6.17.8" - "@sentry/types" "6.17.8" - "@sentry/utils" "6.17.8" +"@sentry/[email protected]": + version "6.17.9" + resolved "https://registry.yarnpkg.com/@sentry/core/-/core-6.17.9.tgz#1c09f1f101207952566349a1921d46db670c8f62" + integrity sha512-14KalmTholGUtgdh9TklO+jUpyQ/D3OGkhlH1rnGQGoJgFy2eYm+s+MnUEMxFdGIUCz5kOteuNqYZxaDmFagpQ== + dependencies: + "@sentry/hub" "6.17.9" + "@sentry/minimal" "6.17.9" + "@sentry/types" "6.17.9" + "@sentry/utils" "6.17.9" tslib "^1.9.3" -"@sentry/[email protected]": - version "6.17.8" - resolved "https://registry.yarnpkg.com/@sentry/hub/-/hub-6.17.8.tgz#d8b04647d12f80807f721c0e4e8133d3f78e4566" - integrity sha512-GW0XYpkoQu/kSJaTLfsF4extHDOBPNRnT0qKr/YO20Z5wGxYp8LsdnAuU3njcFHcAV2F/QDTj2BPq1U385/4+A== +"@sentry/[email protected]": + version "6.17.9" + resolved "https://registry.yarnpkg.com/@sentry/hub/-/hub-6.17.9.tgz#f2c355088a49045e49feafb5356ca5d6e1e31d3c" + integrity sha512-34EdrweWDbBV9EzEFIXcO+JeoyQmKzQVJxpTKZoJA6PUwf2NrndaUdjlkDEtBEzjuLUTxhLxtOzEsYs1O6RVcg== dependencies: - "@sentry/types" "6.17.8" - "@sentry/utils" "6.17.8" + "@sentry/types" "6.17.9" + "@sentry/utils" "6.17.9" tslib "^1.9.3" -"@sentry/[email protected]": - version "6.17.8" - resolved "https://registry.yarnpkg.com/@sentry/minimal/-/minimal-6.17.8.tgz#237ed91d8da00ecedc97ce7c1c3bd87a9b1ff1b7" - integrity sha512-VJXFZBO/O8SViK0fdzodxpNr+pbpgczNgLpz/MNuSooV6EBesgCMVjXtxDUp1Ie1odc0GUprN/ZMLYBmYdIrKQ== +"@sentry/[email protected]": + version "6.17.9" + resolved "https://registry.yarnpkg.com/@sentry/minimal/-/minimal-6.17.9.tgz#0edca978097b3f56463ede028395d40adbf2ae84" + integrity sha512-T3PMCHcKk6lkZq6zKgANrYJJxXBXKOe+ousV1Fas1rVBMv7dtKfsa4itqQHszcW9shusPDiaQKIJ4zRLE5LKmg== dependencies: - "@sentry/hub" "6.17.8" - "@sentry/types" "6.17.8" + "@sentry/hub" "6.17.9" + "@sentry/types" "6.17.9" tslib "^1.9.3" -"@sentry/[email protected]": - version "6.17.8" - resolved "https://registry.yarnpkg.com/@sentry/node/-/node-6.17.8.tgz#6debd3cdb60e51b227b90b2fae10a4ee745a6433" - integrity sha512-b3zg1XjKtxp7o821ENORO1CCzMM4QzKP01rzztMwyMcj28dmUq36QXoQAnwdKn7jEYkJdLnMeniIBR6U6NUJrQ== +"@sentry/[email protected]": + version "6.17.9" + resolved "https://registry.yarnpkg.com/@sentry/node/-/node-6.17.9.tgz#9a13e2fa1739a6b334eb6aa9e1e022d2c4083cb3" + integrity sha512-jbn+q7qPGOh6D7nYoYGaAlmuvMDpQmyMwBtUVYybuZp2AALe43O3Z4LtoJ+1+F31XowpsIPZx1mwNs4ZrILskA== dependencies: - "@sentry/core" "6.17.8" - "@sentry/hub" "6.17.8" - "@sentry/tracing" "6.17.8" - "@sentry/types" "6.17.8" - "@sentry/utils" "6.17.8" + "@sentry/core" "6.17.9" + "@sentry/hub" "6.17.9" + "@sentry/tracing" "6.17.9" + "@sentry/types" "6.17.9" + "@sentry/utils" "6.17.9" cookie "^0.4.1" https-proxy-agent "^5.0.0" lru_map "^0.3.3" tslib "^1.9.3" -"@sentry/[email protected]": - version "6.17.8" - resolved "https://registry.yarnpkg.com/@sentry/tracing/-/tracing-6.17.8.tgz#a7a45aac3a1808afe946c1404538a8a1ab85a11b" - integrity sha512-WJ3W8O6iPI3w7MrzTnYcw3s5PGBNFqT4b9oBCl5Ndjexs8DsGlQOxjrsipo36z6TpnRHpAE4FEbOETb2R8JRJQ== +"@sentry/[email protected]": + version "6.17.9" + resolved "https://registry.yarnpkg.com/@sentry/tracing/-/tracing-6.17.9.tgz#d4a6d96d88f10c9cd496e5b32f44d6e67d4c5dc7" + integrity sha512-5Rb/OS4ryNJLvz2nv6wyjwhifjy6veqaF9ffLrwFYij/WDy7m62ASBblxgeiI3fbPLX0aBRFWIJAq1vko26+AQ== dependencies: - "@sentry/hub" "6.17.8" - "@sentry/minimal" "6.17.8" - "@sentry/types" "6.17.8" - "@sentry/utils" "6.17.8" + "@sentry/hub" "6.17.9" + "@sentry/minimal" "6.17.9" + "@sentry/types" "6.17.9" + "@sentry/utils" "6.17.9" tslib "^1.9.3" -"@sentry/[email protected]": - version "6.17.8" - resolved "https://registry.yarnpkg.com/@sentry/types/-/types-6.17.8.tgz#f1f9fbf2f87f0374b6e122ae065da5ca679bc5ea" - integrity sha512-0i0f+dpvV62Pm5QMVBHNfEsTGIXoXRGQbeN2LGL4XbhzrzUmIrBPzrnZHv9c/JYtSJnI6A0B9OG7Bdlh3aku+Q== +"@sentry/[email protected]": + version "6.17.9" + resolved "https://registry.yarnpkg.com/@sentry/types/-/types-6.17.9.tgz#d579c33cde0301adaf8ff4762479ad017bf0dffa" + integrity sha512-xuulX6qUCL14ayEOh/h6FUIvZtsi1Bx34dSOaWDrjXUOJHJAM7214uiqW1GZxPJ13YuaUIubjTSfDmSQ9CBzTw== -"@sentry/[email protected]": - version "6.17.8" - resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-6.17.8.tgz#a223f5184cbba8c4ad5ebd57800b6f368b274e48" - integrity sha512-cAOM53A5FHv95hpDuXKJU8rI4B1XdZ6qe3Yo+/nDS9QDpOgzvyjcItgXPvKW1wUjdHCcnwu7VBfBxB7teYOW9g== +"@sentry/[email protected]": + version "6.17.9" + resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-6.17.9.tgz#425fe9af4e2d6114c2e9aaede75ccb6ddf91fbda" + integrity sha512-4eo9Z3JlJCGlGrQRbtZWL+L9NnlUXgTbfK3Lk7oO8D1ev8R5b5+iE6tZHTvU5rQRcq6zu+POT+tK5u9oxc/rnQ== dependencies: - "@sentry/types" "6.17.8" + "@sentry/types" "6.17.9" tslib "^1.9.3" "@sindresorhus/is@^0.14.0":
9ee9dc608becfe792f378b969d47b3772a043ed3
2022-08-05 17:33:32
DIYgod
docs: update Related Projects
false
update Related Projects
docs
diff --git a/README.md b/README.md index b3c47ecbefea21..8c3e037eb86af2 100644 --- a/README.md +++ b/README.md @@ -58,6 +58,7 @@ Logo designer [sheldonrrr](https://dribbble.com/sheldonrrr) - [RSSHub Radar](https://github.com/DIYgod/RSSHub-Radar) | 一个可以帮助你快速发现和订阅当前网站 RSS 和 RSSHub 的浏览器扩展 - [RSSBud](https://github.com/Cay-Zhang/RSSBud) ([TestFlight 公测](https://testflight.apple.com/join/rjCVzzHP)) | iOS 平台的 RSSHub Radar,专为移动生态优化 - [RSSAid](https://github.com/LeetaoGoooo/RSSAid) | 基于 Flutter 构建的 Android 平台的 RSSHub Radar +- [DocSearch](https://github.com/Fatpandac/DocSearch) | Link RSSHub DocSearch into Raycast ## Join Us diff --git a/docs/README.md b/docs/README.md index 8138afaaeff10a..1b6d12a11c76b0 100644 --- a/docs/README.md +++ b/docs/README.md @@ -50,3 +50,4 @@ Logo designer [sheldonrrr](https://dribbble.com/sheldonrrr) - [RSSHub Radar](https://github.com/DIYgod/RSSHub-Radar) | 一个可以帮助你快速发现和订阅当前网站 RSS 和 RSSHub 的浏览器扩展 - [RSSBud](https://github.com/Cay-Zhang/RSSBud) ([TestFlight 公测](https://testflight.apple.com/join/rjCVzzHP)) | iOS 平台的 RSSHub Radar,专为移动生态优化 - [RSSAid](https://github.com/LeetaoGoooo/RSSAid) | 基于 Flutter 构建的 Android 平台的 RSSHub Radar +- [DocSearch](https://github.com/Fatpandac/DocSearch) | Link RSSHub DocSearch into Raycast diff --git a/docs/en/README.md b/docs/en/README.md index c7498ef92059fb..c7efb347f19167 100644 --- a/docs/en/README.md +++ b/docs/en/README.md @@ -44,3 +44,10 @@ Logo designer [sheldonrrr](https://dribbble.com/sheldonrrr) ### Backers <a href="https://www.cloudflare.com" target="_blank"><img height="50px" src="https://i.imgur.com/7Ph27Fq.png"></a><a href="https://www.netlify.com" target="_blank" style="margin-left: 60px;"><img height="40px" src="https://i.imgur.com/cU01915.png"></a> + +## Related Projects + +- [RSSHub Radar](https://github.com/DIYgod/RSSHub-Radar) | 一个可以帮助你快速发现和订阅当前网站 RSS 和 RSSHub 的浏览器扩展 +- [RSSBud](https://github.com/Cay-Zhang/RSSBud) ([TestFlight 公测](https://testflight.apple.com/join/rjCVzzHP)) | iOS 平台的 RSSHub Radar,专为移动生态优化 +- [RSSAid](https://github.com/LeetaoGoooo/RSSAid) | 基于 Flutter 构建的 Android 平台的 RSSHub Radar +- [DocSearch](https://github.com/Fatpandac/DocSearch) | Link RSSHub DocSearch into Raycast
c103270f7f0a720cdd5c4f161ccdd7c6f54ec8f9
2023-09-01 23:20:27
Ethan Shen
feat(route): add 木木博客频道 & 标签 & 专题 & 搜索 (#13170)
false
add 木木博客频道 & 标签 & 专题 & 搜索 (#13170)
feat
diff --git a/lib/v2/liulinblog/index.js b/lib/v2/liulinblog/index.js new file mode 100644 index 00000000000000..a06d1213152032 --- /dev/null +++ b/lib/v2/liulinblog/index.js @@ -0,0 +1,98 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const { parseDate } = require('@/utils/parse-date'); + +module.exports = async (ctx) => { + const { params } = ctx.params; + const limit = ctx.query.limit ? parseInt(ctx.query.limit, 10) : 20; + + const rootUrl = 'https://www.liulinblog.com'; + const currentUrl = params ? new URL(params, rootUrl).href : rootUrl; + + const { data: response } = await got(currentUrl); + + const $ = cheerio.load(response); + + let items = $('div.scroll') + .first() + .find('article') + .slice(0, limit) + .toArray() + .map((item) => { + item = $(item); + + const a = item.find('h2.entry-title a'); + + return { + title: a.prop('title'), + link: a.prop('href'), + description: item.find('div.entry-excerpt').html(), + author: item + .find('span.meta-author a') + .toArray() + .map((a) => $(a).prop('title')) + .join(' / '), + category: item + .find('span.meta-category-dot a[rel="category"]') + .toArray() + .map((c) => $(c).text()), + guid: `liulinblog-${item.prop('id')}`, + pubDate: parseDate(item.find('span.meta-date time').prop('datetime')), + comments: item.find('span.meta-comment').text() ? parseInt(item.find('span.meta-comment').text().trim(), 10) : 0, + }; + }); + + items = await Promise.all( + items.map((item) => + ctx.cache.tryGet(item.link, async () => { + const { data: detailResponse } = await got(item.link); + + const content = cheerio.load(detailResponse); + + content('div[role="alert"]').remove(); + + item.title = content('meta[property="og:title"]').prop('content'); + item.description = content('div.entry-content').html(); + item.author = content('div.entry-meta') + .first() + .find('span.meta-author a') + .toArray() + .map((a) => content(a).prop('title')) + .join(' / '); + item.category = content('div.entry-meta') + .first() + .find('span.meta-category a[rel="category"]') + .toArray() + .map((c) => content(c).text()); + item.guid = `liulinblog-${content('article').first().prop('id')}`; + item.pubDate = parseDate(content('span.meta-date time').first().prop('datetime')); + item.comments = content('h3.comments-title').text() + ? parseInt( + content('h3.comments-title') + .text() + .match(/\((\d+)\)/), + 10 + ) + : 0; + + return item; + }) + ) + ); + + const icon = $('link[rel="icon"]').prop('href'); + const title = $('img.logo').prop('alt'); + + ctx.state.data = { + item: items, + title: `${title} - ${params ? $('h1.term-title').text().split('搜索到')[0] : '最新'}`, + link: currentUrl, + description: $('meta[name="description"]').prop('content'), + language: 'zh-cn', + image: $('img.logo').prop('src'), + icon, + logo: icon, + subtitle: $('p.term-description').text(), + author: title, + }; +}; diff --git a/lib/v2/liulinblog/itnews.js b/lib/v2/liulinblog/itnews.js deleted file mode 100644 index c0e0750d22d0a6..00000000000000 --- a/lib/v2/liulinblog/itnews.js +++ /dev/null @@ -1,23 +0,0 @@ -const got = require('@/utils/got'); -const { processList, processItems } = require('./utils'); - -const host = 'https://www.liulinblog.com'; - -const titleMap = { - internet: '互联网早报', - seo: '站长圈', -}; - -module.exports = async (ctx) => { - const channel = ctx.params.channel ?? 'internet'; - const url = `${host}/itnews/${channel}`; - const response = await got(url); - const list = processList(response); - const items = await processItems(list, ctx); - - ctx.state.data = { - title: titleMap[channel], - link: url, - item: items, - }; -}; diff --git a/lib/v2/liulinblog/kuaixun.js b/lib/v2/liulinblog/kuaixun.js deleted file mode 100644 index 060b5a78928f67..00000000000000 --- a/lib/v2/liulinblog/kuaixun.js +++ /dev/null @@ -1,17 +0,0 @@ -const got = require('@/utils/got'); -const { processList, processItems } = require('./utils'); - -const host = 'https://www.liulinblog.com'; - -module.exports = async (ctx) => { - const url = `${host}/kuaixun`; - const response = await got(url); - const list = processList(response); - const items = await processItems(list, ctx); - - ctx.state.data = { - title: '每天六十秒(60秒)读懂世界', - link: url, - item: items, - }; -}; diff --git a/lib/v2/liulinblog/maintainer.js b/lib/v2/liulinblog/maintainer.js index c3055366331b34..154fa077c14157 100644 --- a/lib/v2/liulinblog/maintainer.js +++ b/lib/v2/liulinblog/maintainer.js @@ -1,4 +1,8 @@ module.exports = { - '/kuaixun': ['Fatpandac'], - '/itnews/:channel?': ['Fatpandac'], + '/itnews/:channel?': ['Fatpandac', 'nczitzk'], + '/kuaixun': ['Fatpandac', 'nczitzk'], + '/search/:keyword': ['nczitzk'], + '/series/:id': ['nczitzk'], + '/tag/:id': ['nczitzk'], + '/:channel?': ['nczitzk'], }; diff --git a/lib/v2/liulinblog/radar.js b/lib/v2/liulinblog/radar.js index 8e3681ffaa8863..15c9433b5cdf06 100644 --- a/lib/v2/liulinblog/radar.js +++ b/lib/v2/liulinblog/radar.js @@ -3,29 +3,49 @@ module.exports = { _name: '木木博客', '.': [ { - title: '每天六十秒(60秒)读懂世界', - docs: 'https://docs.rsshub.app/routes/new-media#mu-mu-bo-ke', - source: ['/kuaixun'], - target: '/liulinblog/kuaixun', + title: '频道', + docs: 'https://docs.rsshub.app/new-media.html#mu-mu-bo-ke', + source: ['/:channel', '/'], + target: (params, url) => { + url = new URL(url); + const path = url.href.match(/\.com(.*?)/)[1]; + + return `/liulinblog${path === '/' ? '' : path}`; + }, }, { - title: '互联网早报', - docs: 'https://docs.rsshub.app/routes/new-media#mu-mu-bo-ke', - source: ['/itnews/:channel'], - target: (params) => { - if (params.channel === 'internet') { - return '/liulinblog/itnews/:channel'; - } - }, + title: '标签', + docs: 'https://docs.rsshub.app/new-media.html#mu-mu-bo-ke', + source: ['/tag/:id', '/'], + target: '/liulinblog/tag/:id', + }, + { + title: '专题', + docs: 'https://docs.rsshub.app/new-media.html#mu-mu-bo-ke', + source: ['/series/:id', '/'], + target: '/liulinblog/series/:id', + }, + { + title: '搜索', + docs: 'https://docs.rsshub.app/new-media.html#mu-mu-bo-ke', + source: ['/search/:keyword', '/'], + target: '/liulinblog/search/:keyword', + }, + { + title: '60秒读懂世界', + docs: 'https://docs.rsshub.app/new-media.html#mu-mu-bo-ke', + source: ['/kuaixun', '/'], + target: '/liulinblog/kuaixun', }, { - title: '站长圈', - docs: 'https://docs.rsshub.app/routes/new-media#mu-mu-bo-ke', - source: ['/itnews/:channel'], - target: (params) => { - if (params.channel === 'seo') { - return '/liulinblog/itnews/:channel'; - } + title: '网络营销', + docs: 'https://docs.rsshub.app/new-media.html#mu-mu-bo-ke', + source: ['/:channel', '/'], + target: (params, url) => { + url = new URL(url); + const path = url.href.match(/\.com(.*?)/)[1]; + + return `/liulinblog${path === '/' ? '' : path}`; }, }, ], diff --git a/lib/v2/liulinblog/router.js b/lib/v2/liulinblog/router.js index 39fc12ec111fc2..c8525f656c8a43 100644 --- a/lib/v2/liulinblog/router.js +++ b/lib/v2/liulinblog/router.js @@ -1,4 +1,8 @@ -module.exports = function (router) { - router.get('/kuaixun', require('./kuaixun')); - router.get('/itnews/:channel?', require('./itnews')); +module.exports = (router) => { + router.get('/itnews/:channel', (ctx) => { + const { channel } = ctx.params; + const redirectTo = `/liulinblog/${channel}`; + ctx.redirect(redirectTo); + }); + router.get('/:params*', require('./')); }; diff --git a/lib/v2/liulinblog/utils.js b/lib/v2/liulinblog/utils.js deleted file mode 100644 index 395a78494ece48..00000000000000 --- a/lib/v2/liulinblog/utils.js +++ /dev/null @@ -1,42 +0,0 @@ -const got = require('@/utils/got'); -const cheerio = require('cheerio'); -const { parseDate } = require('@/utils/parse-date'); - -const processList = (res) => { - const $ = cheerio.load(res.data); - const list = $('div.archive.container > div.row > div > div > div.row.posts-wrapper.scroll > div') - .map((_, item) => ({ - title: $(item).find('h2.entry-title').text(), - link: $(item).find('h2.entry-title > a').attr('href'), - pubDate: parseDate($(item).find('time').attr('datetime')), - author: '60秒读懂世界', - })) - .get(); - - return list; -}; - -const processItems = async (list, ctx) => { - const items = await Promise.all( - list.map((item) => - ctx.cache.tryGet(item.link, async () => { - const detailResponse = await got(item.link); - const $ = cheerio.load(detailResponse.data); - const fullContent = $('div > div.entry-wrapper > div.entry-content'); - fullContent.find('img').remove(); - fullContent.find('div.pt-0').remove(); - fullContent.find('div.post-note').remove(); - item.description = fullContent.html(); - - return item; - }) - ) - ); - - return items; -}; - -module.exports = { - processList, - processItems, -}; diff --git a/website/docs/routes/new-media.md b/website/docs/routes/new-media.md index 739d7b1932f897..059223fdcddfaf 100644 --- a/website/docs/routes/new-media.md +++ b/website/docs/routes/new-media.md @@ -3719,17 +3719,91 @@ column 为 third 时可选的 category: ## 木木博客 {#mu-mu-bo-ke} -### 每天六十秒(60 秒)读懂世界 {#mu-mu-bo-ke-mei-tian-liu-shi-miao-%EF%BC%8860-miao-%EF%BC%89-du-dong-shi-jie} +### 频道 {#mu-mu-bo-ke-pin-dao} -<Route author="Fatpandac" example="/liulinblog/kuaixun" path="/liulinblog/kuaixun"/> +<Route author="nczitzk" example="/liulinblog" path="/liulinblog/:channel?" paramsDesc={['频道 id,可在对应频道页 URL 中找到,见下表,默认为最新']} radar="1" rssbud="1"> -### 科技新闻 {#mu-mu-bo-ke-ke-ji-xin-wen} +| 最新 | 60秒读懂世界 | 精品资源 | 视频资源 | 音频资源 | +| ---- | ------------ | -------- | -------- | -------- | +| | kuaixun | ziyuan | video | yinpin | -<Route author="Fatpandac" example="/liulinblog/itnews/seo" path="/liulinblog/itnews/:channel?" paramsDesc={['频道,默认为互联网早报']}> +| 绝版资源 | 实用文档 | PPT素材 | 后期素材 | 技能教程 | +| -------- | -------- | --------- | -------- | --------- | +| jueban | wendang | ppt-sucai | sucai | jiaocheng | -| 互联网早报 | 站长圈 | -| :--------: | :----: | -| internet | seo | +| 创业副业 | 单机游戏 | 冒险解谜 | 竞技格斗 | 赛车竞技 | +| -------- | -------- | -------- | ----------- | -------- | +| money | game | mxjm | jingjigedou | saiche | + +| 模拟经营 | 角色扮演 | 飞行游戏 | 塔防策略 | 射击游戏 | +| -------- | -------- | -------- | -------- | -------- | +| moni | jiaose | feixing | tafang | sheji | + +| 恐怖冒险 | 策略生存 | 动作冒险 | 电商运营 | 互联网早报 | +| -------- | -------- | -------- | --------- | ---------- | +| kongbu | celve | dongzuo | dianshang | internet | + +| 站长圈 | 自媒体运营 | 短视频 | +| ------ | ---------- | ----------- | +| seo | zimeiti | duan-shipin | + +</Route> + +### 标签 {#mu-mu-bo-ke-biao-qian} + +<Route author="nczitzk" example="/liulinblog/tag/qukuailian" path="/liulinblog/tag/:id" paramsDesc={['标签 id,可在对应标签页 URL 中找到,见下表']} radar="1" rssbud="1"> + +| 区块链 | 小红书 | 小说项目 | 微信公众号 | 微信营销 | +| ---------- | ----------- | -------- | ---------- | -------- | +| qukuailian | xiaohongshu | xiaoshuo | 微信公众号 | we-chat | + +| 抖音 | 抖音直播 | 拼多多 | 支付宝 | 教育 | +| ---- | -------- | --------- | ------ | ---- | +| 抖音 | 抖音直播 | pinduoduo | alipay | 教育 | + +| chrome插件 | galgame汉化游戏 | honeyselect 汉化游戏 | PSD笔刷素材 | ps插件 | +| ---------- | --------------- | -------------------- | ----------- | ---------- | +| chrome插件 | galgame | honey-select | psd-bishua | ps-chajian | + +| vip视频 | windows实用技巧 | 下载软件 | 丝袜玉足 | 免费字体下载 | +| ---------- | --------------- | -------- | -------- | ------------ | +| vip-shipin | computer | download | siwa | ziti | + +| 二战游戏下载 | 冒险解谜游戏 | 动作游戏下载 | 安卓游戏 | 策略游戏 | +| ------------ | ------------ | ------------ | ------------ | ---------- | +| war-games | 冒险解谜游戏 | 动作游戏下载 | android-game | game-celve | + +| Pr插件 | Python | seo优化 | VLOG | wordpress | word技巧 | +| ------ | ------ | ------- | ---- | --------- | -------- | +| pr插件 | python | seo | vlog | wordpress | word | + +</Route> + +### 专题 {#mu-mu-bo-ke-zhuan-ti} + +<Route author="nczitzk" example="/liulinblog/series/xunlei" path="/liulinblog/series/:id" paramsDesc={['专题 id,可在对应标签页 URL 中找到,见下表']} radar="1" rssbud="1"> + +| 【免费速存】迅雷资源合集 | 直播带货教程 | 电商培训课程 | 拼多多运营培训 | 小红书运营 | 抖音运营 | 闲鱼运营 | 短视频运营 | +| ------------------------ | ------------ | --------------- | -------------- | ----------- | ------------- | ------------- | ----------------- | +| xunlei | zhibodaihuo | dianshangpeixun | pinduoduo | xiaohongshu | douyinyunying | xianyuyunying | duanshipinyunying | + +</Route> + +### 搜索 {#mu-mu-bo-ke-sou-suo} + +<Route author="nczitzk" example="/liulinblog/search/单机游戏" path="/liulinblog/search/:keyword" paramsDesc={['关键字']} radar="1" rssbud="1"/> + +### 60秒读懂世界 {#mu-mu-bo-ke-60-miao-du-dong-shi-jie} + +<Route author="Fatpandac nczitzk" example="/liulinblog/kuaixun" path="/liulinblog/kuaixun"/> + +### 网络营销 {#mu-mu-bo-ke-wang-luo-ying-xiao} + +<Route author="Fatpandac nczitzk" example="/liulinblog/itnews" path="/liulinblog/itnews/:channel?" paramsDesc={['频道,默认为网络营销']}> + +| 网络营销 | 电商运营 | 互联网早报 | 站长圈 | +| -------- | --------- | ---------- | ------ | +| | dianshang | internet | seo | </Route>
4f6873f5d13325c2eacb1056712c9353d1f3ef53
2022-04-13 18:04:07
TonyRL
chore: rename to .eslintrc.json
false
rename to .eslintrc.json
chore
diff --git a/.eslintrc b/.eslintrc.json similarity index 100% rename from .eslintrc rename to .eslintrc.json
ccfcb0bbe3fa903709868473bd3e8f601f4968d2
2019-06-25 21:31:25
DIYgod
feat: disable cluster by default
false
disable cluster by default
feat
diff --git a/lib/config.js b/lib/config.js index b8703c536fa5d4..efcade19c64607 100644 --- a/lib/config.js +++ b/lib/config.js @@ -81,5 +81,5 @@ module.exports = { }, blacklist: process.env.BLACKLIST && process.env.BLACKLIST.split(','), whitelist: process.env.WHITELIST && process.env.WHITELIST.split(','), - disableCluster: process.env.DISABLE_CLUSTER, + enableCluster: process.env.ENABLE_CLUSTER, }; diff --git a/lib/index.js b/lib/index.js index 0078ac36eab921..4f56c17b0ad3d7 100644 --- a/lib/index.js +++ b/lib/index.js @@ -28,7 +28,7 @@ const apiResponseHandler = require('./middleware/api-response-handler'); const cluster = require('cluster'); const numCPUs = require('os').cpus().length; -if (cluster.isMaster && !config.disableCluster && process.env.NODE_ENV !== 'test' && process.env.NODE_ENV !== 'dev') { +if (cluster.isMaster && config.enableCluster && process.env.NODE_ENV !== 'test' && process.env.NODE_ENV !== 'dev') { for (let i = 0; i < numCPUs; i++) { cluster.fork(); }
deb4dbb8cb28d58d6df062bd1789b4bd246f6635
2020-12-04 21:27:17
Ethan Shen
fix: IT桔子投融资事件 (#6329)
false
IT桔子投融资事件 (#6329)
fix
diff --git a/lib/routes/itjuzi/invest.js b/lib/routes/itjuzi/invest.js index a4586af13d9b73..55a02c5344104d 100644 --- a/lib/routes/itjuzi/invest.js +++ b/lib/routes/itjuzi/invest.js @@ -6,7 +6,7 @@ module.exports = async (ctx) => { url: 'https://www.itjuzi.com/api/index/invse', }); - const data = response.data.data; + const data = response.data; ctx.state.data = { title: 'IT桔子-投融资事件',
cb210c8c723d3bd4f5d8d8de43c66c91caf60a5c
2022-12-19 17:15:32
CaoMeiYouRen
feat(route): 新增 腾讯新闻 - 新型冠状病毒肺炎疫情实时追踪 (#11467)
false
新增 腾讯新闻 - 新型冠状病毒肺炎疫情实时追踪 (#11467)
feat
diff --git a/docs/other.md b/docs/other.md index c3a8f8d6e14161..af25d2bfd9e098 100644 --- a/docs/other.md +++ b/docs/other.md @@ -806,6 +806,18 @@ type 为 all 时,category 参数不支持 cost 和 free <Route author="DIYgod" example="/coronavirus/qq/fact" path="/coronavirus/qq/fact"/> +### 腾讯新闻 - 新型冠状病毒肺炎疫情实时追踪 + +数据来源:<https://news.qq.com/zt2020/page/feiyan.htm#/> + +#### 中国本土数据统计 + +<Route author="CaoMeiYouRen" example="/tencent/news/coronavirus/total" path="/tencent/news/coronavirus/total"/> + +#### 省市疫情数据 + +<Route author="CaoMeiYouRen" example="/tencent/news/coronavirus/data/湖北/武汉" path="/tencent/news/coronavirus/data/:province?/:city?" :paramsDesc="['省/直辖市名,缺省则返回国内数据','城市名,缺省则返回全省数据。直辖市请使用区/县名。']"/> + ### South China Morning Post - China coronavirus outbreak <Route author="DIYgod" example="/coronavirus/scmp" path="/coronavirus/scmp"/> diff --git a/lib/v2/tencent/maintainer.js b/lib/v2/tencent/maintainer.js index 912c121af9e091..6fa25e9c216e4e 100644 --- a/lib/v2/tencent/maintainer.js +++ b/lib/v2/tencent/maintainer.js @@ -1,5 +1,7 @@ module.exports = { '/cloud/column/:id?/:tag?': ['nczitzk'], + '/news/coronavirus/data/:province?/:city?': ['CaoMeiYouRen'], + '/news/coronavirus/total': ['CaoMeiYouRen'], '/pvp/newsindex/:type': ['Jeason0228', 'HenryQW'], '/qq/sdk/changelog/:platform': ['nuomi1'], }; diff --git a/lib/v2/tencent/news/coronavirus/data.js b/lib/v2/tencent/news/coronavirus/data.js new file mode 100644 index 00000000000000..c5c28777c4d7de --- /dev/null +++ b/lib/v2/tencent/news/coronavirus/data.js @@ -0,0 +1,71 @@ +const { getData } = require('./utils'); +const { parseDate } = require('@/utils/parse-date'); +const { art } = require('@/utils/render'); +const path = require('path'); + +module.exports = async (ctx) => { + const province = ctx.params.province || ''; + const city = ctx.params.city || ''; + + const link = 'https://news.qq.com/zt2020/page/feiyan.htm#/'; + const item = []; + + const diseaseh5Shelf = (await getData(['diseaseh5Shelf']))?.data?.diseaseh5Shelf || {}; + const { lastUpdateTime, areaTree } = diseaseh5Shelf; + const nationalData = areaTree?.[0]; + const provinceList = nationalData?.children; + + let todayConfirm = 0; + let totalNowConfirm = 0; + let totalConfirm = 0; + let totalDead = 0; + let coronavirusData = {}; + let placeName = ''; + + if (!province || province === '中国' || province === '全国') { + // 没有传参则取全国 + coronavirusData = nationalData; + placeName = '中国'; + } else { + // 分省份获取 + coronavirusData = provinceList?.find((e) => e.name === province); + placeName = province; + if (city) { + // 继续获取 区县 数据 + coronavirusData = coronavirusData?.children?.find((e) => e.name === city); + if (coronavirusData) { + placeName = `${province}-${city}`; + } + } + } + if (!coronavirusData) { + throw new Error(`未找到 ${placeName} 的疫情数据,请检查输入的省市名称是否正确`); + } + todayConfirm = coronavirusData.today?.confirm; + totalNowConfirm = coronavirusData.total?.nowConfirm; + totalConfirm = coronavirusData.total?.confirm; + totalDead = coronavirusData.total?.dead; + const pubDate = parseDate(coronavirusData.total?.mtime || lastUpdateTime); + + const title = `${placeName} - 腾讯新闻 - 新型冠状病毒肺炎疫情实时追踪`; + + const info = { + title: `${placeName} - 疫情数据`, + description: art(path.join(__dirname, '../../templates/coronavirus/data.art'), { + todayConfirm, + totalNowConfirm, + totalConfirm, + totalDead, + }), + pubDate, + guid: `${link}${placeName}?pubDate=${pubDate.toISOString()}`, + }; + + item.push(info); + + ctx.state.data = { + title, + link, + item, + }; +}; diff --git a/lib/v2/tencent/news/coronavirus/total.js b/lib/v2/tencent/news/coronavirus/total.js new file mode 100644 index 00000000000000..08c10f2334ac21 --- /dev/null +++ b/lib/v2/tencent/news/coronavirus/total.js @@ -0,0 +1,34 @@ +const { getData } = require('./utils'); +const { parseDate } = require('@/utils/parse-date'); +const { art } = require('@/utils/render'); +const path = require('path'); + +module.exports = async (ctx) => { + const title = '腾讯新闻 - 新型冠状病毒肺炎疫情实时追踪'; + const link = 'https://news.qq.com/zt2020/page/feiyan.htm#/'; + const item = []; + + const chinaTotal = (await getData(['diseaseh5Shelf']))?.data?.diseaseh5Shelf?.chinaTotal || {}; + const { localConfirmH5, localWzzAdd, confirmAdd, localConfirm, nowLocalWzz, highRiskAreaNum, mtime } = chinaTotal; + const pubDate = parseDate(mtime); + const info = { + title: '中国本土数据统计', + description: art(path.join(__dirname, '../../templates/coronavirus/chinaTotal.art'), { + localConfirmH5, + localWzzAdd, + confirmAdd, + localConfirm, + nowLocalWzz, + highRiskAreaNum, + }), + pubDate, + guid: `${link}total?pubDate=${pubDate.toISOString()}`, + }; + item.push(info); + + ctx.state.data = { + title, + link, + item, + }; +}; diff --git a/lib/v2/tencent/news/coronavirus/utils.js b/lib/v2/tencent/news/coronavirus/utils.js new file mode 100644 index 00000000000000..ccdd18d8f67596 --- /dev/null +++ b/lib/v2/tencent/news/coronavirus/utils.js @@ -0,0 +1,17 @@ +const got = require('@/utils/got'); + +/** + * + * + * @author CaoMeiYouRen + * @date 2022-12-18 + * @param {string[]} [modules=[]] localCityNCOVDataList,diseaseh5Shelf,nowConfirmStatis,provinceCompare,FAutoforeignList,FAutoCountryConfirmAdd,WomWorld,WomAboard,VaccineTopData + */ +const getData = async (modules = []) => { + const response = await got('https://api.inews.qq.com/newsqa/v1/query/inner/publish/modules/list?modules=' + modules.join(',')); + return response.data; +}; + +module.exports = { + getData, +}; diff --git a/lib/v2/tencent/radar.js b/lib/v2/tencent/radar.js index cb806a3286bf38..6fd8cab0e61e05 100644 --- a/lib/v2/tencent/radar.js +++ b/lib/v2/tencent/radar.js @@ -27,6 +27,14 @@ module.exports = { target: (params, url) => `/wechat/mp/msgalbum/${new URL(url).searchParams.get('__biz')}/${new URL(url).searchParams.get('album_id')}`, }, ], + news: [ + { + title: '腾讯新闻 - 新型冠状病毒肺炎疫情实时追踪', + docs: 'https://docs.rsshub.app/other.html#xin-guan-fei-yan-yi-qing-xin-wen-dong-tai', + source: ['/zt2020/page/feiyan.htm#/'], + target: '/tencent/news/coronavirus/total', + }, + ], pvp: [ { title: '王者荣耀 - 新闻中心', diff --git a/lib/v2/tencent/router.js b/lib/v2/tencent/router.js index fc686be3ebe8dd..cec464ac118469 100644 --- a/lib/v2/tencent/router.js +++ b/lib/v2/tencent/router.js @@ -1,5 +1,7 @@ module.exports = (router) => { router.get('/cloud/column/:id?/:tag?', require('./cloud/column')); + router.get('/news/coronavirus/data/:province?/:city?', require('./news/coronavirus/data')); + router.get('/news/coronavirus/total', require('./news/coronavirus/total')); router.get('/pvp/newsindex/:type', require('./pvp/newsindex')); router.get('/qq/sdk/changelog/:platform', require('./qq/sdk/changelog')); }; diff --git a/lib/v2/tencent/templates/coronavirus/chinaTotal.art b/lib/v2/tencent/templates/coronavirus/chinaTotal.art new file mode 100644 index 00000000000000..63fb5b0ea83361 --- /dev/null +++ b/lib/v2/tencent/templates/coronavirus/chinaTotal.art @@ -0,0 +1,6 @@ +<p>本土确诊:</p><p>+{{@localConfirmH5}}</p></br> +<p>本土无症状:</p><p>+{{@localWzzAdd}}</p></br> +<p>确诊病例:</p><p>+{{@confirmAdd}}</p></br> +<p>现有本土确诊:</p><p>{{@localConfirm}}</p></br> +<p>现有本土无症状:</p><p>{{@nowLocalWzz}}</p></br> +<p>高风险地区:</p><p>{{@highRiskAreaNum}}</p></br> diff --git a/lib/v2/tencent/templates/coronavirus/data.art b/lib/v2/tencent/templates/coronavirus/data.art new file mode 100644 index 00000000000000..a5c80d081c88dd --- /dev/null +++ b/lib/v2/tencent/templates/coronavirus/data.art @@ -0,0 +1,4 @@ +<p>新增确诊:</p><p>+{{@todayConfirm}}</p></br> +<p>现有确诊:</p><p>{{@totalNowConfirm}}</p></br> +<p>累计确诊:</p><p>{{@totalConfirm}}</p></br> +<p>累计死亡:</p><p>{{@totalDead}}</p></br>
444544394664aded118a8d57fa9b029e554d42a4
2019-09-18 15:15:21
DIYgod
feat: use dynamical config
false
use dynamical config
feat
diff --git a/lib/index.js b/lib/index.js index d2421bc18a118f..57e6bbcda1ca25 100644 --- a/lib/index.js +++ b/lib/index.js @@ -1,5 +1,5 @@ const app = require('./app'); -const config = require('./config'); +const config = require('./config').value; const fs = require('fs'); const logger = require('./utils/logger'); diff --git a/lib/middleware/access-control.js b/lib/middleware/access-control.js index d7e2de0d8c7cc4..afb10c2cbabfae 100644 --- a/lib/middleware/access-control.js +++ b/lib/middleware/access-control.js @@ -1,6 +1,6 @@ const art = require('art-template'); const path = require('path'); -const config = require('@/config'); +const config = require('@/config').value; const reject = (ctx) => { ctx.response.status = 403; diff --git a/lib/middleware/cache.js b/lib/middleware/cache.js index fdecb6a8308b4b..45f65a878868b0 100644 --- a/lib/middleware/cache.js +++ b/lib/middleware/cache.js @@ -2,7 +2,7 @@ const wrapper = require('co-redis'); const Redis = require('redis'); const Lru = require('lru-cache'); const md5 = require('@/utils/md5'); -const config = require('@/config'); +const config = require('@/config').value; const logger = require('@/utils/logger'); const pathToRegExp = require('path-to-regexp'); diff --git a/lib/middleware/header.js b/lib/middleware/header.js index d50c871e57d443..e1118af5391bf7 100644 --- a/lib/middleware/header.js +++ b/lib/middleware/header.js @@ -1,6 +1,6 @@ const etagCalculate = require('etag'); const logger = require('@/utils/logger'); -const config = require('@/config'); +const config = require('@/config').value; const headers = { 'Access-Control-Allow-Methods': 'GET', 'Content-Type': 'application/xml; charset=utf-8', diff --git a/lib/middleware/onerror.js b/lib/middleware/onerror.js index c4f67fcb730708..16d6e89de36abc 100644 --- a/lib/middleware/onerror.js +++ b/lib/middleware/onerror.js @@ -1,5 +1,5 @@ const logger = require('@/utils/logger'); -const config = require('@/config'); +const config = require('@/config').value; const Sentry = require('@sentry/node'); const art = require('art-template'); const path = require('path'); diff --git a/lib/middleware/template.js b/lib/middleware/template.js index 3e226dcdc51935..ef2ff3035de6db 100644 --- a/lib/middleware/template.js +++ b/lib/middleware/template.js @@ -1,6 +1,6 @@ const art = require('art-template'); const path = require('path'); -const config = require('@/config'); +const config = require('@/config').value; const typeRegrx = /\.(atom|rss)$/; const unsupportedRegrx = /\.json$/; diff --git a/lib/pkg.js b/lib/pkg.js index 583b85422f7d44..160e52668256a0 100644 --- a/lib/pkg.js +++ b/lib/pkg.js @@ -1,9 +1,10 @@ -const app = require('./app'); +let app; const config = require('./config'); module.exports = { - setConfig: (conf) => { + init: (conf) => { config.set(conf); + app = require('./app'); }, request: (path) => new Promise((resolve) => { diff --git a/lib/protected_router.js b/lib/protected_router.js index d050416bd7d3da..a7ffafbaa6bacd 100644 --- a/lib/protected_router.js +++ b/lib/protected_router.js @@ -1,7 +1,7 @@ const Router = require('koa-router'); const router = new Router(); const auth = require('koa-basic-auth'); -const config = require('./config'); +const config = require('./config').value; router.use('/(.*)', auth(config.authentication)); diff --git a/lib/routes/bilibili/followings_article.js b/lib/routes/bilibili/followings_article.js index 7589ee2080694c..40cc6e125718f4 100644 --- a/lib/routes/bilibili/followings_article.js +++ b/lib/routes/bilibili/followings_article.js @@ -1,6 +1,6 @@ const got = require('@/utils/got'); const cache = require('./cache'); -const config = require('@/config'); +const config = require('@/config').value; const cheerio = require('cheerio'); module.exports = async (ctx) => { diff --git a/lib/routes/bilibili/followings_video.js b/lib/routes/bilibili/followings_video.js index aa31644f54410c..87b72322b5de99 100644 --- a/lib/routes/bilibili/followings_video.js +++ b/lib/routes/bilibili/followings_video.js @@ -1,6 +1,6 @@ const got = require('@/utils/got'); const cache = require('./cache'); -const config = require('@/config'); +const config = require('@/config').value; module.exports = async (ctx) => { const uid = String(ctx.params.uid); diff --git a/lib/routes/chuiniu/column.js b/lib/routes/chuiniu/column.js index 7219a00df63400..34c503d26311e3 100644 --- a/lib/routes/chuiniu/column.js +++ b/lib/routes/chuiniu/column.js @@ -1,5 +1,5 @@ const got = require('@/utils/got'); -const config = require('@/config'); +const config = require('@/config').value; module.exports = async (ctx) => { const url = 'http://chuiniu.duanshu.com'; diff --git a/lib/routes/disqus/posts.js b/lib/routes/disqus/posts.js index 4d1fb20026be8d..25c964d01bc5d6 100644 --- a/lib/routes/disqus/posts.js +++ b/lib/routes/disqus/posts.js @@ -1,5 +1,5 @@ const got = require('@/utils/got'); -const config = require('@/config'); +const config = require('@/config').value; module.exports = async (ctx) => { if (!config.disqus || !config.disqus.api_key) { diff --git a/lib/routes/github/branches.js b/lib/routes/github/branches.js index 5404703ef2677f..d20d6e5e403190 100644 --- a/lib/routes/github/branches.js +++ b/lib/routes/github/branches.js @@ -1,5 +1,5 @@ const got = require('@/utils/got'); -const config = require('@/config'); +const config = require('@/config').value; module.exports = async (ctx) => { const user = ctx.params.user; diff --git a/lib/routes/github/file.js b/lib/routes/github/file.js index 556c417f246946..7a1d5ccbc43ed3 100644 --- a/lib/routes/github/file.js +++ b/lib/routes/github/file.js @@ -1,5 +1,5 @@ const got = require('@/utils/got'); -const config = require('@/config'); +const config = require('@/config').value; module.exports = async (ctx) => { const user = ctx.params.user; diff --git a/lib/routes/github/follower.js b/lib/routes/github/follower.js index 6ee05aa4b8cfc6..f864b9d3e722fd 100644 --- a/lib/routes/github/follower.js +++ b/lib/routes/github/follower.js @@ -1,5 +1,5 @@ const got = require('@/utils/got'); -const config = require('@/config'); +const config = require('@/config').value; module.exports = async (ctx) => { if (!config.github || !config.github.access_token) { diff --git a/lib/routes/github/issue.js b/lib/routes/github/issue.js index 6878ec48cb0c98..4adfde42786c61 100644 --- a/lib/routes/github/issue.js +++ b/lib/routes/github/issue.js @@ -1,5 +1,5 @@ const got = require('@/utils/got'); -const config = require('@/config'); +const config = require('@/config').value; const md = require('markdown-it')({ html: true, }); diff --git a/lib/routes/github/pulls.js b/lib/routes/github/pulls.js index f7ccbd86492996..b6902c9a71b2fd 100644 --- a/lib/routes/github/pulls.js +++ b/lib/routes/github/pulls.js @@ -1,5 +1,5 @@ const got = require('@/utils/got'); -const config = require('@/config'); +const config = require('@/config').value; const md = require('markdown-it')({ html: true, }); diff --git a/lib/routes/github/repos.js b/lib/routes/github/repos.js index 7745ac46d09c15..a33bb7dba0c9bc 100644 --- a/lib/routes/github/repos.js +++ b/lib/routes/github/repos.js @@ -1,5 +1,5 @@ const got = require('@/utils/got'); -const config = require('@/config'); +const config = require('@/config').value; module.exports = async (ctx) => { const user = ctx.params.user; diff --git a/lib/routes/github/star.js b/lib/routes/github/star.js index f1dd55ef0ec295..1c7c394413c288 100644 --- a/lib/routes/github/star.js +++ b/lib/routes/github/star.js @@ -1,5 +1,5 @@ const got = require('@/utils/got'); -const config = require('@/config'); +const config = require('@/config').value; module.exports = async (ctx) => { if (!config.github || !config.github.access_token) { diff --git a/lib/routes/github/starred_repos.js b/lib/routes/github/starred_repos.js index be771ee97d7c20..a90841c4240b0a 100644 --- a/lib/routes/github/starred_repos.js +++ b/lib/routes/github/starred_repos.js @@ -1,5 +1,5 @@ const got = require('@/utils/got'); -const config = require('@/config'); +const config = require('@/config').value; module.exports = async (ctx) => { if (!config.github || !config.github.access_token) { diff --git a/lib/routes/index.js b/lib/routes/index.js index 5920f93086a1d7..6fcbd166ee0c3a 100644 --- a/lib/routes/index.js +++ b/lib/routes/index.js @@ -1,4 +1,4 @@ -const config = require('@/config'); +const config = require('@/config').value; const art = require('art-template'); const path = require('path'); const pidusage = require('pidusage'); diff --git a/lib/routes/mail/imap.js b/lib/routes/mail/imap.js index 32840424a7b19b..c4a33d21e48db1 100644 --- a/lib/routes/mail/imap.js +++ b/lib/routes/mail/imap.js @@ -1,6 +1,6 @@ const ImapClient = require('emailjs-imap-client').default; const queryString = require('query-string'); -const config = require('@/config'); +const config = require('@/config').value; const parser = require('mailparser').simpleParser; const iconv = require('iconv-lite'); diff --git a/lib/routes/pixiv/bookmarks.js b/lib/routes/pixiv/bookmarks.js index e0d334bbc887d3..3cd4117533dc2b 100644 --- a/lib/routes/pixiv/bookmarks.js +++ b/lib/routes/pixiv/bookmarks.js @@ -1,7 +1,7 @@ const getToken = require('./token'); const getBookmarks = require('./api/getBookmarks'); const getUserDetail = require('./api/getUserDetail'); -const config = require('@/config'); +const config = require('@/config').value; module.exports = async (ctx) => { if (!config.pixiv || !config.pixiv.username || !config.pixiv.password) { diff --git a/lib/routes/pixiv/illustfollow.js b/lib/routes/pixiv/illustfollow.js index 527dc14ae35eb2..e5abcb2a3b6c5a 100644 --- a/lib/routes/pixiv/illustfollow.js +++ b/lib/routes/pixiv/illustfollow.js @@ -1,6 +1,6 @@ const getToken = require('./token'); const getIllustFollows = require('./api/getIllustFollows'); -const config = require('@/config'); +const config = require('@/config').value; module.exports = async (ctx) => { if (!config.pixiv || !config.pixiv.username || !config.pixiv.password) { throw 'pixiv RSS is disabled due to the lack of <a href="https://docs.rsshub.app/install/#%E9%83%A8%E5%88%86-rss-%E6%A8%A1%E5%9D%97%E9%85%8D%E7%BD%AE">relevant config</a>'; diff --git a/lib/routes/pixiv/ranking.js b/lib/routes/pixiv/ranking.js index ab68d6a0955cba..5f008484db82e1 100644 --- a/lib/routes/pixiv/ranking.js +++ b/lib/routes/pixiv/ranking.js @@ -1,6 +1,6 @@ const getToken = require('./token'); const getRanking = require('./api/getRanking'); -const config = require('@/config'); +const config = require('@/config').value; const titles = { day: 'pixiv 日排行', diff --git a/lib/routes/pixiv/search.js b/lib/routes/pixiv/search.js index 7abfaa1658ac93..cae89c75488a7f 100644 --- a/lib/routes/pixiv/search.js +++ b/lib/routes/pixiv/search.js @@ -1,7 +1,7 @@ const getToken = require('./token'); const searchPopularIllust = require('./api/searchPopularIllust'); const searchIllust = require('./api/searchIllust'); -const config = require('@/config'); +const config = require('@/config').value; module.exports = async (ctx) => { if (!config.pixiv || !config.pixiv.username || !config.pixiv.password) { diff --git a/lib/routes/pixiv/token.js b/lib/routes/pixiv/token.js index 79547e043b0b22..9e8e21af0ad5ed 100644 --- a/lib/routes/pixiv/token.js +++ b/lib/routes/pixiv/token.js @@ -1,4 +1,4 @@ -const config = require('@/config'); +const config = require('@/config').value; const logger = require('@/utils/logger'); const wait = require('@/utils/wait'); const FormData = require('form-data'); diff --git a/lib/routes/pixiv/user.js b/lib/routes/pixiv/user.js index 09ef08e10ac43c..dbab92bae5955c 100644 --- a/lib/routes/pixiv/user.js +++ b/lib/routes/pixiv/user.js @@ -1,6 +1,6 @@ const getToken = require('./token'); const getIllusts = require('./api/getIllusts'); -const config = require('@/config'); +const config = require('@/config').value; module.exports = async (ctx) => { if (!config.pixiv || !config.pixiv.username || !config.pixiv.password) { diff --git a/lib/routes/telegram/stickerpack.js b/lib/routes/telegram/stickerpack.js index c37a07b03a3e55..f30cb4f0435bff 100644 --- a/lib/routes/telegram/stickerpack.js +++ b/lib/routes/telegram/stickerpack.js @@ -1,5 +1,5 @@ const got = require('@/utils/got'); -const config = require('@/config'); +const config = require('@/config').value; const logger = require('@/utils/logger'); const sharp = require('sharp'); const imgur = require('imgur'); diff --git a/lib/routes/test/index.js b/lib/routes/test/index.js index 2d668b6f443d96..b3f99fa13ca93e 100644 --- a/lib/routes/test/index.js +++ b/lib/routes/test/index.js @@ -1,4 +1,4 @@ -const config = require('@/config'); +const config = require('@/config').value; let cacheIndex = 0; const got = require('@/utils/got'); diff --git a/lib/routes/twitter/followings.js b/lib/routes/twitter/followings.js index 719d60c86b63d8..4d9f846e8fc9fb 100644 --- a/lib/routes/twitter/followings.js +++ b/lib/routes/twitter/followings.js @@ -1,5 +1,5 @@ const utils = require('./utils'); -const config = require('@/config'); +const config = require('@/config').value; const T = {}; const Twit = require('twit'); diff --git a/lib/routes/twitter/likes.js b/lib/routes/twitter/likes.js index 63de3b522f8677..0f91ed1e7a9c1b 100644 --- a/lib/routes/twitter/likes.js +++ b/lib/routes/twitter/likes.js @@ -1,5 +1,5 @@ const utils = require('./utils'); -const config = require('@/config'); +const config = require('@/config').value; module.exports = async (ctx) => { if (!config.twitter || !config.twitter.consumer_key || !config.twitter.consumer_secret) { diff --git a/lib/routes/twitter/list.js b/lib/routes/twitter/list.js index dc4b29ef8c97b1..6a319386cf98c5 100644 --- a/lib/routes/twitter/list.js +++ b/lib/routes/twitter/list.js @@ -1,5 +1,5 @@ const utils = require('./utils'); -const config = require('@/config'); +const config = require('@/config').value; module.exports = async (ctx) => { if (!config.twitter || !config.twitter.consumer_key || !config.twitter.consumer_secret) { diff --git a/lib/routes/twitter/user.js b/lib/routes/twitter/user.js index 10b263dd0d3f83..a245a49fe9d59c 100644 --- a/lib/routes/twitter/user.js +++ b/lib/routes/twitter/user.js @@ -1,5 +1,5 @@ const utils = require('./utils'); -const config = require('@/config'); +const config = require('@/config').value; module.exports = async (ctx) => { if (!config.twitter || !config.twitter.consumer_key || !config.twitter.consumer_secret) { diff --git a/lib/routes/twitter/utils.js b/lib/routes/twitter/utils.js index 0d8819b082972c..1efad0967da726 100644 --- a/lib/routes/twitter/utils.js +++ b/lib/routes/twitter/utils.js @@ -1,5 +1,5 @@ const URL = require('url'); -const config = require('@/config'); +const config = require('@/config').value; const Twit = require('twit'); const ProcessFeed = ({ data = [] }, showAuthor = false) => { diff --git a/lib/routes/youtube/channel.js b/lib/routes/youtube/channel.js index 34c53735510300..757bd7461556ad 100644 --- a/lib/routes/youtube/channel.js +++ b/lib/routes/youtube/channel.js @@ -1,5 +1,5 @@ const utils = require('./utils'); -const config = require('@/config'); +const config = require('@/config').value; module.exports = async (ctx) => { if (!config.youtube || !config.youtube.key) { diff --git a/lib/routes/youtube/playlist.js b/lib/routes/youtube/playlist.js index 5e24667ff15cd3..0a69c41c70f213 100644 --- a/lib/routes/youtube/playlist.js +++ b/lib/routes/youtube/playlist.js @@ -1,5 +1,5 @@ const utils = require('./utils'); -const config = require('@/config'); +const config = require('@/config').value; module.exports = async (ctx) => { if (!config.youtube || !config.youtube.key) { diff --git a/lib/routes/youtube/user.js b/lib/routes/youtube/user.js index 5df5ffe4071064..ebd8643e34e4fb 100644 --- a/lib/routes/youtube/user.js +++ b/lib/routes/youtube/user.js @@ -1,5 +1,5 @@ const utils = require('./utils'); -const config = require('@/config'); +const config = require('@/config').value; module.exports = async (ctx) => { if (!config.youtube || !config.youtube.key) { diff --git a/lib/routes/youtube/utils.js b/lib/routes/youtube/utils.js index cb0a56adf6bc4f..f9467a647e9f10 100644 --- a/lib/routes/youtube/utils.js +++ b/lib/routes/youtube/utils.js @@ -1,5 +1,5 @@ const { google } = require('googleapis'); -const config = require('@/config'); +const config = require('@/config').value; const youtube = google.youtube({ version: 'v3', diff --git a/lib/routes/yuque/doc.js b/lib/routes/yuque/doc.js index 4959998a3f2b60..0d14bf1cb88d1e 100644 --- a/lib/routes/yuque/doc.js +++ b/lib/routes/yuque/doc.js @@ -1,5 +1,5 @@ const got = require('@/utils/got'); -const config = require('@/config'); +const config = require('@/config').value; // token通过process.env.YUQUE_TOKEN或者在config.js 配置 const { token = '' } = config.yuque; diff --git a/lib/utils/got.js b/lib/utils/got.js index 25891cee383f5c..d4e385f717cad3 100644 --- a/lib/utils/got.js +++ b/lib/utils/got.js @@ -1,5 +1,5 @@ const logger = require('./logger'); -const config = require('@/config'); +const config = require('@/config').value; const got = require('got'); const queryString = require('query-string'); diff --git a/lib/utils/logger.js b/lib/utils/logger.js index 95f925e41c008e..cc07dea17bca36 100644 --- a/lib/utils/logger.js +++ b/lib/utils/logger.js @@ -1,5 +1,5 @@ const winston = require('winston'); -const config = require('@/config'); +const config = require('@/config').value; const logger = winston.createLogger({ level: config.loggerLevel, diff --git a/lib/utils/puppeteer.js b/lib/utils/puppeteer.js index 30e20c3992f0be..b9ba585117717d 100644 --- a/lib/utils/puppeteer.js +++ b/lib/utils/puppeteer.js @@ -1,4 +1,4 @@ -const config = require('@/config'); +const config = require('@/config').value; const puppeteer = require('puppeteer'); const options = { diff --git a/lib/utils/request-wrapper.js b/lib/utils/request-wrapper.js index 7e36c77d9b5ece..7af7fdbfc93687 100644 --- a/lib/utils/request-wrapper.js +++ b/lib/utils/request-wrapper.js @@ -1,4 +1,4 @@ -const config = require('@/config'); +const config = require('@/config').value; const SocksProxyAgent = require('socks-proxy-agent'); const tunnel = require('tunnel'); const logger = require('./logger'); diff --git a/lib/utils/rss-parser.js b/lib/utils/rss-parser.js index 28c36e7faab3b3..3ac9ce1eea40cc 100644 --- a/lib/utils/rss-parser.js +++ b/lib/utils/rss-parser.js @@ -1,4 +1,4 @@ -const config = require('@/config'); +const config = require('@/config').value; const Parser = require('rss-parser'); const parser = new Parser({ diff --git a/test/config.js b/test/config.js index 431acf04ad0f4d..8cc3b4f446e8b3 100644 --- a/test/config.js +++ b/test/config.js @@ -7,7 +7,7 @@ describe('config', () => { process.env.BILIBILI_COOKIE_12 = 'cookie1'; process.env.BILIBILI_COOKIE_34 = 'cookie2'; - const config = require('../lib/config'); + const config = require('../lib/config').value; expect(config.bilibili.cookies).toMatchObject({ 12: 'cookie1', 34: 'cookie2', @@ -21,7 +21,7 @@ describe('config', () => { process.env.TWITTER_TOKEN_12 = 'token1'; process.env.TWITTER_TOKEN_34 = 'token2'; - const config = require('../lib/config'); + const config = require('../lib/config').value; expect(config.twitter.tokens).toMatchObject({ 12: 'token1', 34: 'token2', @@ -35,7 +35,7 @@ describe('config', () => { process.env['EMAIL_CONFIG_xx.qq.com'] = 'token1'; process.env['EMAIL_CONFIG_oo.qq.com'] = 'token2'; - const config = require('../lib/config'); + const config = require('../lib/config').value; expect(config.email.config).toMatchObject({ 'xx.qq.com': 'token1', 'oo.qq.com': 'token2', diff --git a/test/middleware/header.js b/test/middleware/header.js index 8ffa6272fb56be..3429778d2af5d7 100644 --- a/test/middleware/header.js +++ b/test/middleware/header.js @@ -3,7 +3,7 @@ process.env.NODE_NAME = 'mock'; const supertest = require('supertest'); const { server } = require('../../lib/index'); const request = supertest(server); -const config = require('../../lib/config'); +const config = require('../../lib/config').value; afterAll(() => { server.close(); diff --git a/test/router.js b/test/router.js index e4053b2b4631ca..b2778ff39ffffa 100644 --- a/test/router.js +++ b/test/router.js @@ -5,7 +5,7 @@ const { server } = require('../lib/index'); const request = supertest(server); const Parser = require('rss-parser'); const parser = new Parser(); -const config = require('../lib/config'); +const config = require('../lib/config').value; afterAll(() => { delete process.env.SOCKET; diff --git a/test/utils/got.js b/test/utils/got.js index af8cff397b4520..3b414d1773562b 100644 --- a/test/utils/got.js +++ b/test/utils/got.js @@ -1,5 +1,5 @@ const got = require('../../lib/utils/got'); -const config = require('../../lib/config'); +const config = require('../../lib/config').value; const nock = require('nock'); describe('got', () => { diff --git a/test/utils/rss-parser.js b/test/utils/rss-parser.js index b72763c5d1e0ca..1faa989015d019 100644 --- a/test/utils/rss-parser.js +++ b/test/utils/rss-parser.js @@ -1,5 +1,5 @@ const parser = require('../../lib/utils/rss-parser'); -const config = require('../../lib/config'); +const config = require('../../lib/config').value; const nock = require('nock'); describe('got', () => {