ncm2mp3 1.0.0 → 1.0.1

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.
Files changed (3) hide show
  1. package/README.md +9 -1
  2. package/index.js +10 -10
  3. package/package.json +2 -2
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
@@ -1,6 +1,6 @@
1
- import fs from 'fs';
2
- import crypto from 'crypto'
3
- import NodeID3 from 'node-id3';
1
+ const fs = require('fs');
2
+ const crypto = require('crypto')
3
+ const NodeID3 = require('node-id3');
4
4
  function aes128EcbDecrypt(encrypted,secretKey) {
5
5
  try {
6
6
  // 1. 将十六进制密钥转换为 Buffer (这正是你之前学习的 Buffer 转换)
@@ -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,22 @@ 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
- let output = await fs.promises.open(this.output + meta.musicName+'-'+meta.artist[0][0]+'.mp3',"w");
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 1;
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
194
  async function convertNcm(ncmfile,mp3file){
195
195
  const ncm = new Ncm(ncmfile,mp3file);
196
- return await ncm.turnUp();
196
+ return await ncm.turnUp();
197
197
  }
198
- moudle.exports = {convertNcm}
198
+ module.exports = {convertNcm}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ncm2mp3",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Use this moudle to convert ncm file to mp3 file.",
5
5
  "keywords": [
6
6
  "ncm",
@@ -11,7 +11,7 @@
11
11
  "type": "commonjs",
12
12
  "main": "index.js",
13
13
  "scripts": {
14
- "test": "node index.js"
14
+ "test": "node index.mjs"
15
15
  },
16
16
  "dependencies": {
17
17
  "node-id3": "^0.2.9"