diff --git a/README.md b/README.md
index 72a058d..0db0527 100644
--- a/README.md
+++ b/README.md
@@ -79,6 +79,16 @@ chmod a+rx ~/.local/bin/yt-dlp
sudo pacman -Syu yt-dlp
```
+`AM解析`需要使用两个依赖`freyr`、`atomicparsley`,现在只以Debian系统为例:
+
+```shell
+npm install -g freyr
+# 或者你有yarn的话可以使用
+yarn global add freyr
+# 接着安装它的依赖
+apt-get install atomicparsley
+```
+
4. 【可选】小程序解析适配了:
* 喵崽:[Yoimiya / Miao-Yunzai](https://gitee.com/yoimiya-kokomi/Miao-Yunzai)
* TRSS:[时雨◎星空 / Yunzai](https://gitee.com/TimeRainStarSky/Yunzai)
@@ -102,8 +112,8 @@ sudo pacman -Syu yt-dlp
```shell
# 删除当前的R插件
rm -rf ./plugins/rconsole-plugin/
-# 克隆指定版本的R插件
-git clone -b 1.5.1 https://gitee.com/kyrzy0416/rconsole-plugin.git
+# 克隆指定版本的R插件稳定版本
+git clone -b 1.6.7-lts https://gitee.com/kyrzy0416/rconsole-plugin.git
```
## 🐤 Q&A
@@ -152,25 +162,25 @@ git clone -b 1.5.1 https://gitee.com/kyrzy0416/rconsole-plugin.git
1. 配置文件,将拉格朗日的配置文件`appsettings.json`中`Implementations`加入一个正向连接`ForwardWebSocket`
,如(最好是9091,这样就不用改tools配置文件):
-```json
+```yaml
"Implementations": [
-{
-"Type": "ReverseWebSocket",
-"Host": "127.0.0.1",
-"Port": 9090,
-"Suffix": "/onebot/v11/",
-"ReconnectInterval": 5000,
-"HeartBeatInterval": 5000,
-"AccessToken": ""
-},
-{
-"Type": "ForwardWebSocket",
-"Host": "127.0.0.1",
-"Port": 9091,
-"HeartBeatInterval": 5000,
-"HeartBeatEnable": true,
-"AccessToken": ""
-}
+ {
+ "Type": "ReverseWebSocket",
+ "Host": "127.0.0.1",
+ "Port": 9090,
+ "Suffix": "/onebot/v11/",
+ "ReconnectInterval": 5000,
+ "HeartBeatInterval": 5000,
+ "AccessToken": ""
+ },
+ {
+ "Type": "ForwardWebSocket",
+ "Host": "127.0.0.1",
+ "Port": 9091,
+ "HeartBeatInterval": 5000,
+ "HeartBeatEnable": true,
+ "AccessToken": ""
+ }
]
```
@@ -233,6 +243,7 @@ git clone -b 1.5.1 https://gitee.com/kyrzy0416/rconsole-plugin.git
🌸 感谢以下框架的开源:
- [yt-dlp:A youtube-dl fork with additional features and fixes](https://github.com/yt-dlp/yt-dlp)
+- [freyr-js](https://github.com/miraclx/freyr-js)
## ☕ 请我喝一杯瑞幸咖啡
如果你觉得插件能帮助到你增进好友关系,那么你可以在有条件的情况下[请我喝一杯瑞幸咖啡](https://afdian.net/a/zhiyu1998),这是我开源这个插件的最大动力!
diff --git a/apps/tools.js b/apps/tools.js
index dcd5c48..a6b8d57 100644
--- a/apps/tools.js
+++ b/apps/tools.js
@@ -8,7 +8,7 @@ import _ from "lodash";
import tunnel from "tunnel";
import HttpProxyAgent from "https-proxy-agent";
import { exec, execSync } from "child_process";
-import { checkAndRemoveFile, mkdirIfNotExists } from "../utils/file.js";
+import { checkAndRemoveFile, deleteFolderRecursive, mkdirIfNotExists } from "../utils/file.js";
import {
downloadBFile,
getBiliAudio,
@@ -67,8 +67,14 @@ import { getDS } from "../utils/mihoyo.js";
import GeneralLinkAdapter from "../utils/general-link-adapter.js";
import { mid2id } from "../utils/weibo.js";
import { LagrangeAdapter } from "../utils/lagrange-adapter.js";
+import path from "path";
export class tools extends plugin {
+ /**
+ * 用于计数applemusic,达到一定数量清理文件
+ * @type {number}
+ */
+ static #amCount = 0;
/**
* 构造安全的命令
* @type {{existsPromptKey: string, existsTransKey: string}}
@@ -161,6 +167,10 @@ export class tools extends plugin {
{
reg: "share.xiaochuankeji.cn",
fnc: "zuiyou"
+ },
+ {
+ reg: "music.apple.com",
+ fnc: "applemusic"
}
],
});
@@ -1432,6 +1442,77 @@ export class tools extends plugin {
}
}
+ async applemusic(e) {
+ // https://music.apple.com/cn/album/hectopascal-from-yagate-kimi-ni-naru-piano-arrangement/1468323115?i=1468323724
+ // 过滤参数
+ const message = e.msg.replace("&ls", "");
+ // 找到R插件保存目录
+ const currentWorkingDirectory = path.resolve(this.defaultPath);
+ // 如果没有文件夹就创建一个
+ await mkdirIfNotExists(currentWorkingDirectory + "/am")
+ // 执行命令
+ const result = await execSync(`freyr -d ${ currentWorkingDirectory } get ${ message }`);
+ logger.info(result.toString());
+ // 获取信息
+ const { title, album, artist } = await this.parseFreyrLog(result.toString());
+ e.reply(`识别:Apple Music,${ title }--${ artist }\n${ album }`);
+ // 检查目录是否存在
+ const musicPath = currentWorkingDirectory + "/am/" + artist + "/" + album;
+ const that = this;
+ // 找到音频文件
+ if (fs.existsSync(musicPath)) {
+ logger.info('目录存在。正在获取.m4a文件...');
+
+ // 读取目录中的所有文件和文件夹
+ fs.readdir(musicPath, (err, files) => {
+ if (err) {
+ e.reply("Apple Music解析出错,请查看日志!")
+ logger.error('读取目录时出错:', err);
+ return;
+ }
+
+ // 过滤出以.m4a结尾的文件
+ const m4aFiles = files.filter(file => path.extname(file).toLowerCase() === '.m4a');
+
+ // 打印出所有.m4a文件
+ logger.info('找到以下.m4a文件:');
+ m4aFiles.forEach(file => {
+ that.uploadGroupFile(e, path.join(musicPath, file));
+ });
+ });
+ } else {
+ e.reply("下载失败!没有找到Apple Music下载下来文件!");
+ }
+ // 计数
+ tools.#amCount += 1;
+ logger.info(`当前Apple Music已经下载了:${ tools.#amCount }次`);
+ // 定时清理
+ if (tools.#amCount >= 5) {
+ await deleteFolderRecursive(currentWorkingDirectory + "/am");
+ // 重置
+ tools.#amCount = 0;
+ }
+ return true;
+ }
+
+ /**
+ * 用于Apple Music抓取部分信息的函数
+ * @link {applemusic}
+ * @param log
+ * @returns {Promise<{artist: (*|string), album: (*|string), title: (*|string)}>}
+ */
+ async parseFreyrLog(log) {
+ const titleMatch = log.match(/Title: (.*)/);
+ const albumMatch = log.match(/Album: (.*)/);
+ const artistMatch = log.match(/Artist: (.*)/);
+
+ const title = titleMatch ? titleMatch[1] : 'N/A';
+ const album = albumMatch ? albumMatch[1] : 'N/A';
+ const artist = artistMatch ? artistMatch[1] : 'N/A';
+
+ return { title, album, artist };
+ }
+
/**
* 哔哩哔哩下载
* @param title
diff --git a/config/help.yaml b/config/help.yaml
index abdc896..eef37fc 100644
--- a/config/help.yaml
+++ b/config/help.yaml
@@ -39,11 +39,11 @@
title: "bilibili/b23"
desc: 哔哩哔哩分享实时下载
- icon: bqrcode
- title: "R插件B站扫码"
+ title: "#rbq/#RBQ"
desc: R插件B站扫码
- - icon: bilimusic
- title: "bili音乐+链接"
- desc: 哔哩哔哩音乐分享实时下载
+ - icon: applemusic
+ title: "Apple Music"
+ desc: Apple Music音乐分享实时下载
- icon: youtube
title: "youtube.com"
desc: 油管学习版分享实时下载
diff --git a/config/version.yaml b/config/version.yaml
index e4faafc..3222ccf 100644
--- a/config/version.yaml
+++ b/config/version.yaml
@@ -1,11 +1,10 @@
- {
- version: 1.7.0,
+ version: 1.7.1,
data:
[
- 新增适配拉格朗日上传功能,
+ 新增AM解析功能,
+ 适配拉格朗日上传功能,
新增超过文件大小转上传功能,
- 新增B站下载功能,
- 新增B站扫码功能,
支持锅巴插件,方便查看和修改配置,
添加#R帮助获取插件帮助,
添加#R版本获取插件版本,
diff --git a/resources/img/icon/applemusic.png b/resources/img/icon/applemusic.png
new file mode 100644
index 0000000..2e2a10b
Binary files /dev/null and b/resources/img/icon/applemusic.png differ
diff --git a/resources/img/icon/bilimusic.png b/resources/img/icon/bilimusic.png
deleted file mode 100644
index e9ba276..0000000
Binary files a/resources/img/icon/bilimusic.png and /dev/null differ