mirror of
https://github.com/Jerryplusy/rc-plugin.git
synced 2025-10-14 08:09:19 +00:00
✨ feat: 新增AM解析
解析需要阅读文档
This commit is contained in:
parent
5a56db1f4a
commit
df2fe92916
51
README.md
51
README.md
@ -79,6 +79,16 @@ chmod a+rx ~/.local/bin/yt-dlp
|
|||||||
sudo pacman -Syu 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. 【可选】小程序解析适配了:
|
4. 【可选】小程序解析适配了:
|
||||||
* 喵崽:[Yoimiya / Miao-Yunzai](https://gitee.com/yoimiya-kokomi/Miao-Yunzai)
|
* 喵崽:[Yoimiya / Miao-Yunzai](https://gitee.com/yoimiya-kokomi/Miao-Yunzai)
|
||||||
* TRSS:[时雨◎星空 / Yunzai](https://gitee.com/TimeRainStarSky/Yunzai)
|
* TRSS:[时雨◎星空 / Yunzai](https://gitee.com/TimeRainStarSky/Yunzai)
|
||||||
@ -102,8 +112,8 @@ sudo pacman -Syu yt-dlp
|
|||||||
```shell
|
```shell
|
||||||
# 删除当前的R插件
|
# 删除当前的R插件
|
||||||
rm -rf ./plugins/rconsole-plugin/
|
rm -rf ./plugins/rconsole-plugin/
|
||||||
# 克隆指定版本的R插件
|
# 克隆指定版本的R插件稳定版本
|
||||||
git clone -b 1.5.1 https://gitee.com/kyrzy0416/rconsole-plugin.git
|
git clone -b 1.6.7-lts https://gitee.com/kyrzy0416/rconsole-plugin.git
|
||||||
```
|
```
|
||||||
|
|
||||||
## 🐤 Q&A
|
## 🐤 Q&A
|
||||||
@ -152,25 +162,25 @@ git clone -b 1.5.1 https://gitee.com/kyrzy0416/rconsole-plugin.git
|
|||||||
1. 配置文件,将拉格朗日的配置文件`appsettings.json`中`Implementations`加入一个正向连接`ForwardWebSocket`
|
1. 配置文件,将拉格朗日的配置文件`appsettings.json`中`Implementations`加入一个正向连接`ForwardWebSocket`
|
||||||
,如(最好是9091,这样就不用改tools配置文件):
|
,如(最好是9091,这样就不用改tools配置文件):
|
||||||
|
|
||||||
```json
|
```yaml
|
||||||
"Implementations": [
|
"Implementations": [
|
||||||
{
|
{
|
||||||
"Type": "ReverseWebSocket",
|
"Type": "ReverseWebSocket",
|
||||||
"Host": "127.0.0.1",
|
"Host": "127.0.0.1",
|
||||||
"Port": 9090,
|
"Port": 9090,
|
||||||
"Suffix": "/onebot/v11/",
|
"Suffix": "/onebot/v11/",
|
||||||
"ReconnectInterval": 5000,
|
"ReconnectInterval": 5000,
|
||||||
"HeartBeatInterval": 5000,
|
"HeartBeatInterval": 5000,
|
||||||
"AccessToken": ""
|
"AccessToken": ""
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Type": "ForwardWebSocket",
|
"Type": "ForwardWebSocket",
|
||||||
"Host": "127.0.0.1",
|
"Host": "127.0.0.1",
|
||||||
"Port": 9091,
|
"Port": 9091,
|
||||||
"HeartBeatInterval": 5000,
|
"HeartBeatInterval": 5000,
|
||||||
"HeartBeatEnable": true,
|
"HeartBeatEnable": true,
|
||||||
"AccessToken": ""
|
"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)
|
- [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),这是我开源这个插件的最大动力!
|
如果你觉得插件能帮助到你增进好友关系,那么你可以在有条件的情况下[请我喝一杯瑞幸咖啡](https://afdian.net/a/zhiyu1998),这是我开源这个插件的最大动力!
|
||||||
|
@ -8,7 +8,7 @@ import _ from "lodash";
|
|||||||
import tunnel from "tunnel";
|
import tunnel from "tunnel";
|
||||||
import HttpProxyAgent from "https-proxy-agent";
|
import HttpProxyAgent from "https-proxy-agent";
|
||||||
import { exec, execSync } from "child_process";
|
import { exec, execSync } from "child_process";
|
||||||
import { checkAndRemoveFile, mkdirIfNotExists } from "../utils/file.js";
|
import { checkAndRemoveFile, deleteFolderRecursive, mkdirIfNotExists } from "../utils/file.js";
|
||||||
import {
|
import {
|
||||||
downloadBFile,
|
downloadBFile,
|
||||||
getBiliAudio,
|
getBiliAudio,
|
||||||
@ -67,8 +67,14 @@ import { getDS } from "../utils/mihoyo.js";
|
|||||||
import GeneralLinkAdapter from "../utils/general-link-adapter.js";
|
import GeneralLinkAdapter from "../utils/general-link-adapter.js";
|
||||||
import { mid2id } from "../utils/weibo.js";
|
import { mid2id } from "../utils/weibo.js";
|
||||||
import { LagrangeAdapter } from "../utils/lagrange-adapter.js";
|
import { LagrangeAdapter } from "../utils/lagrange-adapter.js";
|
||||||
|
import path from "path";
|
||||||
|
|
||||||
export class tools extends plugin {
|
export class tools extends plugin {
|
||||||
|
/**
|
||||||
|
* 用于计数applemusic,达到一定数量清理文件
|
||||||
|
* @type {number}
|
||||||
|
*/
|
||||||
|
static #amCount = 0;
|
||||||
/**
|
/**
|
||||||
* 构造安全的命令
|
* 构造安全的命令
|
||||||
* @type {{existsPromptKey: string, existsTransKey: string}}
|
* @type {{existsPromptKey: string, existsTransKey: string}}
|
||||||
@ -161,6 +167,10 @@ export class tools extends plugin {
|
|||||||
{
|
{
|
||||||
reg: "share.xiaochuankeji.cn",
|
reg: "share.xiaochuankeji.cn",
|
||||||
fnc: "zuiyou"
|
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
|
* @param title
|
||||||
|
@ -39,11 +39,11 @@
|
|||||||
title: "bilibili/b23"
|
title: "bilibili/b23"
|
||||||
desc: 哔哩哔哩分享实时下载
|
desc: 哔哩哔哩分享实时下载
|
||||||
- icon: bqrcode
|
- icon: bqrcode
|
||||||
title: "R插件B站扫码"
|
title: "#rbq/#RBQ"
|
||||||
desc: R插件B站扫码
|
desc: R插件B站扫码
|
||||||
- icon: bilimusic
|
- icon: applemusic
|
||||||
title: "bili音乐+链接"
|
title: "Apple Music"
|
||||||
desc: 哔哩哔哩音乐分享实时下载
|
desc: Apple Music音乐分享实时下载
|
||||||
- icon: youtube
|
- icon: youtube
|
||||||
title: "youtube.com"
|
title: "youtube.com"
|
||||||
desc: 油管学习版分享实时下载
|
desc: 油管学习版分享实时下载
|
||||||
|
@ -1,11 +1,10 @@
|
|||||||
- {
|
- {
|
||||||
version: 1.7.0,
|
version: 1.7.1,
|
||||||
data:
|
data:
|
||||||
[
|
[
|
||||||
新增<span class="cmd">适配拉格朗日上传</span>功能,
|
新增<span class="cmd">AM解析</span>功能,
|
||||||
|
适配<span class="cmd">拉格朗日上传</span>功能,
|
||||||
新增<span class="cmd">超过文件大小转上传</span>功能,
|
新增<span class="cmd">超过文件大小转上传</span>功能,
|
||||||
新增<span class="cmd">B站下载</span>功能,
|
|
||||||
新增<span class="cmd">B站扫码</span>功能,
|
|
||||||
支持<span class="cmd">锅巴</span>插件,方便查看和修改配置,
|
支持<span class="cmd">锅巴</span>插件,方便查看和修改配置,
|
||||||
添加<span class="cmd">#R帮助</span>获取插件帮助,
|
添加<span class="cmd">#R帮助</span>获取插件帮助,
|
||||||
添加<span class="cmd">#R版本</span>获取插件版本,
|
添加<span class="cmd">#R版本</span>获取插件版本,
|
||||||
|
BIN
resources/img/icon/applemusic.png
Normal file
BIN
resources/img/icon/applemusic.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 8.2 KiB |
Binary file not shown.
Before Width: | Height: | Size: 3.4 KiB |
Loading…
x
Reference in New Issue
Block a user