1
0

feat: 支持自动生成 Markdown

This commit is contained in:
2024-03-11 13:48:50 +08:00
parent 744ae21570
commit 2a9b8f3001
8 changed files with 207 additions and 64 deletions

View File

@@ -2,7 +2,7 @@
记录籽岷在B站直播的时间和内容。
如有错漏,欢迎各位通过提交 Issue 或 Pull Request 的方式进行完善。
如有错漏,欢迎各位通过提交 Issue 或 Pull Request 的方式进行完善`data.json`
## 相关链接
@@ -13,3 +13,7 @@
- [data.json](./data.json)
- [data.md](./data.md)
## 其他说明
- 文件 `data.md` 为自动生成,具体可参考 `scripts/README.md`

126
data.md
View File

@@ -1,64 +1,64 @@
| 开始时间 | 结束时间 | 直播内容 |
| ---------------- | ---------------- | ---------------------------------------------- |
| 2024-03-10 21:27 | 2024-03-11 01:23 | Minecraft 生日地图、元梦之星 |
| 2024-03-09 20:14 | 2024-03-10 01:23 | Minecraft 生日地图、三角洲行动、元梦之星 |
| 开始时间 | 结束时间 | 直播内容 |
| ---- | ---- | ---- |
| 2024-03-10 21:27 | 2024-03-11 01:23 | Minecraft 生日地图、元梦之星 |
| 2024-03-09 20:14 | 2024-03-10 01:23 | Minecraft 生日地图、三角洲行动、元梦之星 |
| 2024-03-09 01:50 | 2024-03-09 09:22 | 元梦之星、Minecraft 魔法金属整合包、三角洲行动 |
| 2024-03-07 10:05 | 2024-03-07 12:09 | 三角洲行动 |
| 2024-03-07 00:03 | 2024-03-07 05:35 | 元梦之星、Minecraft 魔法金属整合包 |
| 2024-03-05 06:35 | 2024-03-05 10:28 | Minecraft 魔法金属整合包 |
| 2024-03-04 03:24 | 2024-03-04 09:49 | 元梦之星、Minecraft 魔法金属整合包 |
| 2024-03-03 03:18 | 2024-03-03 09:09 | Minecraft 魔法金属整合包 |
| 2024-03-02 18:03 | 2024-03-02 19:29 | 游戏《三角洲行动》线下活动 |
| 2024-03-02 15:33 | 2024-03-02 17:31 | 游戏《三角洲行动》线下活动 |
| 2024-03-02 00:55 | 2024-03-02 04:57 | 元梦之星、Minecraft 与岷同乐 |
| 2024-02-28 03:03 | 2024-02-28 09:11 | - |
| 2024-02-27 04:57 | 2024-02-27 08:17 | - |
| 2024-02-25 23:06 | 2024-02-26 06:22 | 元梦之星、Minecraft 春晓之巫整合包试玩 |
| 2024-02-25 21:22 | 2024-02-25 21:37 | - |
| 2024-02-24 23:56 | 2024-02-25 06:06 | - |
| 2024-02-24 03:05 | 2024-02-24 07:34 | - |
| 2024-02-23 18:40 | 2024-02-23 19:48 | 元宵节临港滴水湖 CityWalk |
| 2024-02-23 03:30 | 2024-02-23 06:32 | - |
| 2024-02-22 01:00 | 2024-02-22 05:44 | - |
| 2024-02-20 23:36 | 2024-02-21 04:20 | - |
| 2024-02-20 01:24 | 2024-02-20 06:16 | - |
| 2024-02-19 01:57 | 2024-02-19 06:21 | - |
| 2024-02-17 21:02 | 2024-02-18 03:36 | - |
| 2024-02-16 23:38 | 2024-02-17 05:06 | - |
| 2024-02-15 22:57 | 2024-02-16 05:37 | - |
| 2024-02-15 01:48 | 2024-02-15 07:05 | - |
| 2024-02-14 00:33 | 2024-02-14 05:04 | - |
| 2024-02-12 22:57 | 2024-02-13 05:17 | - |
| 2024-02-12 00:10 | 2024-02-12 04:37 | - |
| 2024-02-10 23:39 | 2024-02-11 04:16 | - |
| 2024-02-09 23:58 | 2024-02-10 05:33 | - |
| 2024-02-08 19:39 | 2024-02-08 23:46 | - |
| 2024-02-07 23:06 | 2024-02-08 04:35 | - |
| 2024-02-07 02:30 | 2024-02-07 07:01 | - |
| 2024-02-06 00:58 | 2024-02-06 06:06 | - |
| 2024-02-03 23:25 | 2024-02-04 05:48 | - |
| 2024-02-03 19:07 | 2024-02-03 19:22 | 测试设备 |
| 2024-02-03 02:48 | 2024-02-03 05:04 | - |
| 2024-02-02 00:53 | 2024-02-02 02:10 | - |
| 2024-01-31 01:24 | 2024-01-31 05:01 | - |
| 2024-01-29 22:41 | 2024-01-30 02:19 | - |
| 2024-01-28 23:00 | 2024-01-29 04:12 | - |
| 2024-01-27 19:43 | 2024-01-27 22:51 | - |
| 2024-01-26 21:05 | 2024-01-27 02:24 | - |
| 2024-01-26 01:01 | 2024-01-26 03:39 | - |
| 2024-01-24 21:47 | 2024-01-25 03:07 | - |
| 2024-01-23 21:21 | 2024-01-24 02:01 | - |
| 2024-01-21 21:00 | 2024-01-22 01:10 | - |
| 2024-01-14 20:14 | 2024-01-15 00:12 | - |
| 2024-01-13 21:06 | 2024-01-14 00:29 | - |
| 2024-01-12 22:36 | 2024-01-13 02:46 | - |
| 2024-01-11 22:12 | 2024-01-12 00:08 | - |
| 2024-01-09 23:58 | 2024-01-10 02:27 | - |
| 2024-01-08 20:17 | 2024-01-09 01:30 | - |
| 2024-01-07 19:22 | 2024-01-07 23:13 | - |
| 2024-01-07 01:33 | 2024-01-07 05:43 | - |
| 2024-01-05 20:10 | 2024-01-06 00:39 | - |
| 2024-01-04 19:18 | 2024-01-04 22:34 | - |
| 2024-01-03 19:08 | 2024-01-03 22:44 | - |
| 2024-01-02 19:14 | 2024-01-02 22:23 | - |
| 2024-01-01 19:05 | 2024-01-01 22:07 | - |
| 2024-03-07 10:05 | 2024-03-07 12:09 | 三角洲行动 |
| 2024-03-07 00:03 | 2024-03-07 05:35 | 元梦之星、Minecraft 魔法金属整合包 |
| 2024-03-05 06:35 | 2024-03-05 10:28 | Minecraft 魔法金属整合包 |
| 2024-03-04 03:24 | 2024-03-04 09:49 | 元梦之星、Minecraft 魔法金属整合包 |
| 2024-03-03 03:18 | 2024-03-03 09:09 | Minecraft 魔法金属整合包 |
| 2024-03-02 18:03 | 2024-03-02 19:29 | 游戏《三角洲行动》线下活动 |
| 2024-03-02 15:33 | 2024-03-02 17:31 | 游戏《三角洲行动》线下活动 |
| 2024-03-02 00:55 | 2024-03-02 04:57 | 元梦之星、Minecraft 与岷同乐 |
| 2024-02-28 03:03 | 2024-02-28 09:11 | |
| 2024-02-27 04:57 | 2024-02-27 08:17 | |
| 2024-02-25 23:06 | 2024-02-26 06:22 | 元梦之星、Minecraft 春晓之巫整合包试玩 |
| 2024-02-25 21:22 | 2024-02-25 21:37 | |
| 2024-02-24 23:56 | 2024-02-25 06:06 | |
| 2024-02-24 03:05 | 2024-02-24 07:34 | |
| 2024-02-23 18:40 | 2024-02-23 19:48 | 元宵节临港滴水湖 CityWalk |
| 2024-02-23 03:30 | 2024-02-23 06:32 | |
| 2024-02-22 01:00 | 2024-02-22 05:44 | |
| 2024-02-20 23:36 | 2024-02-21 04:20 | |
| 2024-02-20 01:24 | 2024-02-20 06:16 | |
| 2024-02-19 01:57 | 2024-02-19 06:21 | |
| 2024-02-17 21:02 | 2024-02-18 03:36 | |
| 2024-02-16 23:38 | 2024-02-17 05:06 | |
| 2024-02-15 22:57 | 2024-02-16 05:37 | |
| 2024-02-15 01:48 | 2024-02-15 07:05 | |
| 2024-02-14 00:33 | 2024-02-14 05:04 | |
| 2024-02-12 22:57 | 2024-02-13 05:17 | |
| 2024-02-12 00:10 | 2024-02-12 04:37 | |
| 2024-02-10 23:39 | 2024-02-11 04:16 | |
| 2024-02-09 23:58 | 2024-02-10 05:33 | |
| 2024-02-08 19:39 | 2024-02-08 23:46 | |
| 2024-02-07 23:06 | 2024-02-08 04:35 | |
| 2024-02-07 02:30 | 2024-02-07 07:01 | |
| 2024-02-06 00:58 | 2024-02-06 06:06 | |
| 2024-02-03 23:25 | 2024-02-04 05:48 | |
| 2024-02-03 19:07 | 2024-02-03 19:22 | 测试设备 |
| 2024-02-03 02:48 | 2024-02-03 05:04 | |
| 2024-02-02 00:53 | 2024-02-02 02:10 | |
| 2024-01-31 01:24 | 2024-01-31 05:01 | |
| 2024-01-29 22:41 | 2024-01-30 02:19 | |
| 2024-01-28 23:00 | 2024-01-29 04:12 | |
| 2024-01-27 19:43 | 2024-01-27 22:51 | |
| 2024-01-26 21:05 | 2024-01-27 02:24 | |
| 2024-01-26 01:01 | 2024-01-26 03:39 | |
| 2024-01-24 21:47 | 2024-01-25 03:07 | |
| 2024-01-23 21:21 | 2024-01-24 02:01 | |
| 2024-01-21 21:00 | 2024-01-22 01:10 | |
| 2024-01-14 20:14 | 2024-01-15 00:12 | |
| 2024-01-13 21:06 | 2024-01-14 00:29 | |
| 2024-01-12 22:36 | 2024-01-13 02:46 | |
| 2024-01-11 22:12 | 2024-01-12 00:08 | |
| 2024-01-09 23:58 | 2024-01-10 02:27 | |
| 2024-01-08 20:17 | 2024-01-09 01:30 | |
| 2024-01-07 19:22 | 2024-01-07 23:13 | |
| 2024-01-07 01:33 | 2024-01-07 05:43 | |
| 2024-01-05 20:10 | 2024-01-06 00:39 | |
| 2024-01-04 19:18 | 2024-01-04 22:34 | |
| 2024-01-03 19:08 | 2024-01-03 22:44 | |
| 2024-01-02 19:14 | 2024-01-02 22:23 | |
| 2024-01-01 19:05 | 2024-01-01 22:07 | |

19
scripts/README.md Normal file
View File

@@ -0,0 +1,19 @@
# 脚本
## 注意事项
- 需要安装 Node.js 和 NPM。
## 相关命令
初始化
```text
npm i
```
开始处理
```text
npm run start
```

6
scripts/config.js Normal file
View File

@@ -0,0 +1,6 @@
import path from 'path';
import process from 'process';
export const CWD = process.cwd();
export const PATH_JSON_FILE = path.join(CWD, '../data.json');
export const PATH_MD_FILE = path.join(CWD, '../data.md');

62
scripts/generate.js Normal file
View File

@@ -0,0 +1,62 @@
import { PATH_JSON_FILE, PATH_MD_FILE } from './config.js';
import fs from 'fs';
import json2md from 'json2md';
/** JSON 转 Markdown */
export function generateMarkdown() {
try {
console.info('开始生成 Markdown');
let jsonContent = fs.readFileSync(PATH_JSON_FILE, {
encoding: 'utf-8',
});
let jsonParsed = JSON.parse(jsonContent);
/** @type {json2md.DataObject[]} */
let jsonMarkdown = [{
table: {
headers: [
'开始时间',
'结束时间',
'直播内容',
],
rows: [],
},
}];
let tableRows = jsonMarkdown[0].table.rows;
let result = ''
jsonParsed.forEach((data) => {
tableRows.push([
data.startTime || '',
data.endTime || '',
data.content || '',
]);
});
result = json2md(jsonMarkdown);
if (result) {
fs.writeFileSync(PATH_MD_FILE, result, {
encoding: 'utf-8',
flag: 'w',
});
console.info('文件生成完毕');
return true;
} else {
console.error('文件生成失败');
return false;
}
} catch (error) {
console.error('文件生成出错:');
console.error(error);
return false;
}
}

4
scripts/index.js Normal file
View File

@@ -0,0 +1,4 @@
import { generateMarkdown } from './generate.js';
console.clear();
generateMarkdown();

29
scripts/package-lock.json generated Normal file
View File

@@ -0,0 +1,29 @@
{
"name": "zimin-live-streaming-timeline-scripts",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "zimin-live-streaming-timeline-scripts",
"version": "1.0.0",
"license": "MIT",
"dependencies": {
"json2md": "^2.0.1"
}
},
"node_modules/indento": {
"version": "1.1.13",
"resolved": "http://mirrors.tencentyun.com/npm/indento/-/indento-1.1.13.tgz",
"integrity": "sha512-YZWk3mreBEM7sBPddsiQnW9Z8SGg/gNpFfscJq00HCDS7pxcQWWWMSVKJU7YkTRyDu1Zv2s8zaK8gQWKmCXHlg=="
},
"node_modules/json2md": {
"version": "2.0.1",
"resolved": "http://mirrors.tencentyun.com/npm/json2md/-/json2md-2.0.1.tgz",
"integrity": "sha512-VbwmZ83qmUfKBS2pUOHlzNKEZFPBeJSbzEok3trMYyboZUgdHNn1XZfc1uT8UZs1GHCrmRUBXCfqw4YmmQuOhw==",
"dependencies": {
"indento": "^1.1.13"
}
}
}
}

19
scripts/package.json Normal file
View File

@@ -0,0 +1,19 @@
{
"name": "zimin-live-streaming-timeline-scripts",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "node index.js"
},
"type": "module",
"keywords": [
"auto",
"script"
],
"author": "Frost-ZX",
"license": "MIT",
"dependencies": {
"json2md": "^2.0.1"
}
}