koishi-plugin-music-parser-all 0.0.2 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.js +34 -4
- package/package.json +1 -1
- package/readme.md +6 -4
package/lib/index.js
CHANGED
|
@@ -422,8 +422,8 @@ function generateFormattedText(p, format) {
|
|
|
422
422
|
album: p.album,
|
|
423
423
|
cover: p.cover,
|
|
424
424
|
music_url: p.musicUrl,
|
|
425
|
-
level: p.level || '
|
|
426
|
-
size: p.size || '
|
|
425
|
+
level: p.level || '',
|
|
426
|
+
size: p.size || '',
|
|
427
427
|
};
|
|
428
428
|
const formatVarRegex = /\$\{([^}]+)\}/g;
|
|
429
429
|
const lines = format.split('\n');
|
|
@@ -435,7 +435,7 @@ function generateFormattedText(p, format) {
|
|
|
435
435
|
for (const match of varMatches) {
|
|
436
436
|
const varName = match.slice(2, -1);
|
|
437
437
|
const val = vars[varName];
|
|
438
|
-
if (val && val !== '0') {
|
|
438
|
+
if (val !== undefined && val !== '' && val !== '0') {
|
|
439
439
|
allEmpty = false;
|
|
440
440
|
break;
|
|
441
441
|
}
|
|
@@ -577,7 +577,37 @@ function apply(ctx, config) {
|
|
|
577
577
|
if (!url)
|
|
578
578
|
throw new Error('链接为空');
|
|
579
579
|
await promises_1.default.mkdir(cacheDir, { recursive: true });
|
|
580
|
-
|
|
580
|
+
let ext = fileExts.find(e => new RegExp('\\.' + e + '(\\?|$)', 'i').test(url));
|
|
581
|
+
if (!ext) {
|
|
582
|
+
try {
|
|
583
|
+
const urlObj = new URL(url);
|
|
584
|
+
const mimeType = urlObj.searchParams.get('mime_type');
|
|
585
|
+
if (mimeType) {
|
|
586
|
+
const mimeMap = {
|
|
587
|
+
'audio_mp4': 'm4a',
|
|
588
|
+
'audio/mp4': 'm4a',
|
|
589
|
+
'audio_mpeg': 'mp3',
|
|
590
|
+
'audio/mpeg': 'mp3',
|
|
591
|
+
'audio_mp3': 'mp3',
|
|
592
|
+
'audio/mp3': 'mp3',
|
|
593
|
+
'audio_flac': 'flac',
|
|
594
|
+
'audio/flac': 'flac',
|
|
595
|
+
'audio_wav': 'wav',
|
|
596
|
+
'audio/wav': 'wav',
|
|
597
|
+
'audio_ogg': 'ogg',
|
|
598
|
+
'audio/ogg': 'ogg',
|
|
599
|
+
'audio_aac': 'aac',
|
|
600
|
+
'audio/aac': 'aac',
|
|
601
|
+
};
|
|
602
|
+
const mappedExt = mimeMap[mimeType];
|
|
603
|
+
if (mappedExt && fileExts.includes(mappedExt)) {
|
|
604
|
+
ext = mappedExt;
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
catch { }
|
|
609
|
+
}
|
|
610
|
+
ext = ext || fileExts[0];
|
|
581
611
|
const fileName = `${filePrefix}_${Date.now()}_${(0, crypto_1.randomBytes)(4).toString('hex')}.${ext}`;
|
|
582
612
|
const filePath = path_1.default.resolve(cacheDir, fileName);
|
|
583
613
|
if (downloadEngine === 'downloads' && ctx.downloads) {
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -112,9 +112,10 @@ This is a **multi-platform music parsing plugin** developed for the Koishi bot f
|
|
|
112
112
|
| `${size}` | 文件大小 |
|
|
113
113
|
|
|
114
114
|
## 解析策略 (Parsing Strategy)
|
|
115
|
-
1.
|
|
116
|
-
2.
|
|
117
|
-
3.
|
|
115
|
+
1. **独立接口优先**:每个平台默认使用专属接口(网易云、酷我、QQ、汽水)
|
|
116
|
+
2. **聚合接口备用**:当解析网易云或 QQ 音乐失败时,自动调用统一聚合接口 `https://api.bugpk.com/api/music` 进行补提
|
|
117
|
+
3. **自定义优先**:若配置了自定义 API 并开启“优先使用专属 API”,则会优先尝试自定义地址
|
|
118
|
+
4. **智能扩展名识别**:下载音频时,会优先从链接的 `mime_type` 参数(如汽水音乐)识别真实格式,支持 mp3/m4a/flac/wav/ogg/aac/opus/wma/ape/wv/alac 等常见格式
|
|
118
119
|
|
|
119
120
|
## 依赖说明 (Dependencies)
|
|
120
121
|
### 音乐语音(可选)
|
|
@@ -140,12 +141,13 @@ This is a **multi-platform music parsing plugin** developed for the Koishi bot f
|
|
|
140
141
|
| 酷我音乐 | kuwo.cn | 歌曲信息、直链、封面 |
|
|
141
142
|
| QQ音乐 | y.qq.com, i.y.qq.com | 歌曲信息、直链、封面 |
|
|
142
143
|
| 汽水音乐 | qishui.douyin.com | 歌曲信息、高音质直链、封面 |
|
|
143
|
-
| 自定义平台 | 通过 `customPlatforms` 添加 | 取决于 API |
|
|
144
|
+
| 🧩 自定义平台 | 通过 `customPlatforms` 添加 | 取决于 API |
|
|
144
145
|
|
|
145
146
|
## 项目贡献者 (Contributors)
|
|
146
147
|
| 贡献者 | 贡献内容 |
|
|
147
148
|
|--------|----------|
|
|
148
149
|
| Minecraft-1314 | 插件完整开发 |
|
|
150
|
+
| 梦安大佬 | 赞助恢复网易云SVIP接口 |
|
|
149
151
|
| JH-Ahua | BugPk-Api 支持 |
|
|
150
152
|
|
|
151
153
|
(欢迎通过 Issues 或 PR 加入贡献者列表)
|