tools_batch_files 1.0.20 → 1.0.22

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/index.js CHANGED
@@ -30,10 +30,10 @@ const SOURCE_VIDEO_DIR = "source_video";
30
30
  const ZIP_FILES_DIR = "zip";
31
31
 
32
32
  //并发数量
33
- const queueCount = 10;
33
+ const queueCount = 50;
34
34
 
35
35
  //起始任务下标
36
- let taskIndex = 0;
36
+ let taskIndex = 2066;
37
37
 
38
38
  /**
39
39
  * 递归遍历文件夹,查找mp4文件
@@ -102,12 +102,12 @@ const logger = (log, hash, err) => {
102
102
  };
103
103
 
104
104
  //错误日志
105
- const disposeError = (hash, err) => {
106
- logger("---任务失败---", hash, err);
105
+ const disposeError = (fileName) => {
106
+ logger("---任务失败---" + fileName);
107
107
  logger(
108
108
  `******************************************************************end`
109
109
  );
110
- fs.writeFileSync("error.txt", err + "\n", {
110
+ fs.writeFileSync("error.txt", fileName + "\n", {
111
111
  flag: "a",
112
112
  });
113
113
  };
@@ -422,7 +422,7 @@ const getMetadata = async (
422
422
  video_id: rowFileName,
423
423
  title,
424
424
  keyword,
425
- pr: 90,
425
+ pr: 100,
426
426
  format: "mp4",
427
427
  category_id: 4,
428
428
  demand_kind: 23,
@@ -485,10 +485,11 @@ const postData = (dataParams, indexFilePath) => {
485
485
 
486
486
  logger("等待接口返回结果……");
487
487
 
488
- return axios.post("http://192.168.101.149:9999/upload/video", formData, {
488
+ return axios.post("http://127.0.0.1:9999/upload/video", formData, {
489
489
  headers: {
490
490
  "Content-Type": "multipart/form-data",
491
491
  },
492
+ timeout: 600000,
492
493
  });
493
494
  };
494
495
 
@@ -509,7 +510,7 @@ const task = async (row, index) => {
509
510
  const keyword = filteredArray.join(" ");
510
511
 
511
512
  if (!fileName.includes(".")) {
512
- fileName = row.fileName + ".mp4";
513
+ fileName = row.fileName + ".mov";
513
514
  }
514
515
 
515
516
  // 源视频文件路径
@@ -519,7 +520,7 @@ const task = async (row, index) => {
519
520
  );
520
521
 
521
522
  if (!originFilePath) {
522
- logger(`图片文件 ${fileName} 不存在`);
523
+ logger(`视频文件 ${fileName} 不存在`);
523
524
  return;
524
525
  }
525
526
  logger("源视频文件路径");
@@ -547,10 +548,17 @@ const task = async (row, index) => {
547
548
  keyword,
548
549
  }
549
550
  );
550
- console.log("dataParams参数");
551
- console.log(dataParams);
552
551
 
553
552
  const resData = await postData(dataParams, indexFilePath);
553
+ if (resData.data.code === 200) {
554
+ logger("请求成功!");
555
+ logger(resData.data.code);
556
+ logger(resData.data);
557
+ //删除文件夹
558
+ // fs.rmdirSync(indexFilePath, { recursive: true });
559
+ } else {
560
+ throw new Error("请求失败!" + resData.data.msg);
561
+ }
554
562
  logger(resData.data);
555
563
  logger(
556
564
  `----------------------------------------第${index}条结束---------------------------------end`
@@ -563,7 +571,9 @@ const task = async (row, index) => {
563
571
  logger("视频处理失败:");
564
572
  logger(error);
565
573
  }
566
- disposeError(hash, fileName);
574
+ logger("catch日志*********************************");
575
+ disposeError(fileName);
576
+ // fs.rmdirSync(indexFilePath, { recursive: true });
567
577
  }
568
578
  };
569
579
 
@@ -601,7 +611,7 @@ const transitionExcelToJSON = () => {
601
611
  };
602
612
 
603
613
  for (let i = 0; i < queueCount; i++) {
604
- run(i);
614
+ run(i + taskIndex);
605
615
  }
606
616
  };
607
617
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tools_batch_files",
3
- "version": "1.0.20",
3
+ "version": "1.0.22",
4
4
  "description": "批处理视频工具",
5
5
  "keywords": [
6
6
  "utils",
@@ -11,7 +11,8 @@
11
11
  "main": "index.js",
12
12
  "bin": {
13
13
  "tbf": "./index.js",
14
- "tbfp": "./src/photoBatch.js"
14
+ "tbfp": "./src/photoBatch.js",
15
+ "tbfb": "./src/photoBatchBack.js"
15
16
  },
16
17
  "scripts": {
17
18
  "test": "echo \"Error: no test specified\" && exit 1",