ncm2mp3 1.0.0 → 1.0.2
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/README.md +9 -1
- package/index.js +8 -9
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -1,2 +1,10 @@
|
|
|
1
1
|
## ncm2mp3
|
|
2
|
-
部分代码和原理~~照搬~~借鉴自:[NCM2MP3](https://github.com/charlotte-xiao/NCM2MP3)
|
|
2
|
+
部分代码和原理~~照搬~~借鉴自:[NCM2MP3](https://github.com/charlotte-xiao/NCM2MP3)
|
|
3
|
+
|
|
4
|
+
## 用法
|
|
5
|
+
|
|
6
|
+
```ts
|
|
7
|
+
const ncm = require('ncm2mp3')
|
|
8
|
+
ncm.convertNcm('./1.ncm','./') //第一个为ncm文件路径,第二个为目标文件夹地址
|
|
9
|
+
|
|
10
|
+
```
|
package/index.js
CHANGED
|
@@ -142,7 +142,6 @@ class Ncm{
|
|
|
142
142
|
async imgData(filename) {//jpg格式
|
|
143
143
|
let test = await fs.promises.open(filename,"r");
|
|
144
144
|
let length = Buffer.alloc(4);
|
|
145
|
-
console.log(this.filenumber)
|
|
146
145
|
await test.read(length,0,4,this.filenumber);
|
|
147
146
|
this.filenumber += 4 ;
|
|
148
147
|
let keyBytes = Buffer.alloc(length.readUInt32LE(0));
|
|
@@ -178,21 +177,21 @@ class Ncm{
|
|
|
178
177
|
image:meta.image
|
|
179
178
|
}
|
|
180
179
|
let data = await this.musicData(this.filename,key);
|
|
181
|
-
const outputFile = NodeID3.write(metaInfo,data)
|
|
182
|
-
|
|
180
|
+
const outputFile = NodeID3.write(metaInfo,data);
|
|
181
|
+
const outputpath = this.output + meta.musicName+'-'+meta.artist[0][0]+'.mp3';
|
|
182
|
+
let output = await fs.promises.open(outputpath,"w");
|
|
183
183
|
|
|
184
|
-
console.log(meta)
|
|
185
184
|
output.write(outputFile);
|
|
186
185
|
output.close();
|
|
187
|
-
return
|
|
186
|
+
return outputpath;
|
|
188
187
|
}
|
|
189
188
|
}
|
|
190
189
|
/**
|
|
191
190
|
* @param {string} ncmfile - file path to the ncm file.
|
|
192
191
|
* @param {string} mp3file - file path to the target file.
|
|
192
|
+
* @returns
|
|
193
193
|
*/
|
|
194
|
-
async function convertNcm(ncmfile,mp3file){
|
|
194
|
+
export async function convertNcm(ncmfile,mp3file){
|
|
195
195
|
const ncm = new Ncm(ncmfile,mp3file);
|
|
196
|
-
return
|
|
197
|
-
}
|
|
198
|
-
moudle.exports = {convertNcm}
|
|
196
|
+
return await ncm.turnUp();
|
|
197
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ncm2mp3",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Use this moudle to convert ncm file to mp3 file.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ncm",
|
|
@@ -11,9 +11,10 @@
|
|
|
11
11
|
"type": "commonjs",
|
|
12
12
|
"main": "index.js",
|
|
13
13
|
"scripts": {
|
|
14
|
-
"test": "node index.
|
|
14
|
+
"test": "node index.mjs"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"node-id3": "^0.2.9"
|
|
18
|
-
}
|
|
18
|
+
},
|
|
19
|
+
"type": "module"
|
|
19
20
|
}
|