From bc0bf4c3bcabf973a7b5f71523f05d55c6067034 Mon Sep 17 00:00:00 2001
From: CaoMeiYouRen <40430746+CaoMeiYouRen@users.noreply.github.com>
Date: Mon, 23 Jan 2023 22:25:11 +0800
Subject: [PATCH] =?UTF-8?q?feat(route):=20=E4=BF=AE=E5=A4=8D=20HelloGitHub?=
=?UTF-8?q?=20=E7=9A=84=20=E6=9C=88=E5=88=8A=20=E8=B7=AF=E7=94=B1=20(#1167?=
=?UTF-8?q?5)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* feat(route): 添加 百度股市通
* fix: 修改 百度股市通 路径
* docs: 添加 百度股市通 文档
* feat: 添加 radar 支持
* fix: 按字母顺序插入新路由
* feat(route): 新增 腾讯新闻 - 新型冠状病毒肺炎疫情实时追踪
* fix: 优化 腾讯新闻 - 新型冠状病毒肺炎疫情实时追踪 的标题
* fix: 修复 腾讯新闻 - 新型冠状病毒肺炎疫情实时追踪 部分情况下的非空判断
* fix: 修复 地区名称标题的问题
* fix: 腾讯新闻 - 新型冠状病毒肺炎疫情实时追踪 的 guid 增加 pubDate
* fix: 修复 腾讯新闻 - 新型冠状病毒肺炎疫情实时追踪 guid 中添加 pubDate
* fix: 修改 腾讯新闻 - 新型冠状病毒肺炎疫情实时追踪 的 title
* feat(route): 修复 HelloGitHub 的 月刊 路由
* fix: remove guid
---
docs/programming.md | 2 +-
lib/v2/hellogithub/maintainer.js | 2 +-
lib/v2/hellogithub/volume.js | 27 ++++++++++++++-------------
3 files changed, 16 insertions(+), 15 deletions(-)
diff --git a/docs/programming.md b/docs/programming.md
index bacce0f36..4df15ad75 100644
--- a/docs/programming.md
+++ b/docs/programming.md
@@ -448,7 +448,7 @@ GitHub 官方也提供了一些 RSS:
### 月刊
-
+
## Hex-Rays
diff --git a/lib/v2/hellogithub/maintainer.js b/lib/v2/hellogithub/maintainer.js
index 8bd65ccae..d4274cafc 100644
--- a/lib/v2/hellogithub/maintainer.js
+++ b/lib/v2/hellogithub/maintainer.js
@@ -5,5 +5,5 @@ module.exports = {
'/month': ['moke8', 'nczitzk'],
'/ranking/:type?': ['moke8', 'nczitzk'],
'/report/:type?': ['nczitzk'],
- '/volume': ['nczitzk'],
+ '/volume': ['nczitzk', 'CaoMeiYouRen'],
};
diff --git a/lib/v2/hellogithub/volume.js b/lib/v2/hellogithub/volume.js
index 6c3d11e0d..0c2ac5655 100644
--- a/lib/v2/hellogithub/volume.js
+++ b/lib/v2/hellogithub/volume.js
@@ -4,6 +4,7 @@ const path = require('path');
const md = require('markdown-it')({
html: true,
});
+const cheerio = require('cheerio');
art.defaults.imports.render = function (string) {
return md.render(string);
@@ -11,28 +12,28 @@ art.defaults.imports.render = function (string) {
module.exports = async (ctx) => {
const rootUrl = 'https://hellogithub.com';
- const currentUrl = `${rootUrl}/periodical/volume/`;
+ const apiUrl = 'https://api.hellogithub.com/v1/periodical/';
- const buildResponse = await got({
- method: 'get',
- url: rootUrl,
- });
-
- const buildId = buildResponse.data.match(/"buildId":"(.*?)",/)[1];
-
- const apiUrl = `${rootUrl}/_next/data/${buildId}/periodical/volume.json`;
-
- const response = await got({
+ const periodicalResponse = await got({
method: 'get',
url: apiUrl,
});
+ const current = periodicalResponse.data.volumes[0].num;
+ const currentUrl = `${rootUrl}/periodical/volume/${current}`;
+ const buildResponse = await got({
+ method: 'get',
+ url: currentUrl,
+ });
- const data = response.data;
+ const $ = cheerio.load(buildResponse.data);
+
+ const text = $('#__NEXT_DATA__').text();
+ const response = JSON.parse(text);
+ const data = response.props;
const id = data.pageProps.volume.current_num;
const items = [
{
- guid: id,
title: `No.${id}`,
link: `${rootUrl}/periodical/volume/${id}`,
description: art(path.join(__dirname, 'templates/volume.art'), {