tools_batch_files 1.0.9 → 1.0.12

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 (2) hide show
  1. package/index.js +18 -14
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ #!/usr/bin/env node
1
2
  const XLSX = require("xlsx");
2
3
  const ffmpeg = require("fluent-ffmpeg");
3
4
  const fs = require("fs");
@@ -330,8 +331,7 @@ const watermarkScreenshots = (indexFilePath) => {
330
331
  /**
331
332
  * 打包物料
332
333
  */
333
- const archiveZip = (fileName, inputPath) => {
334
- const sourceVideoPath = path.join(workDir, "video", fileName);
334
+ const archiveZip = (fileName, inputPath, originFilePath) => {
335
335
  const zipDir = path.join(inputPath, "zip");
336
336
  const timestamp = new Date().getTime();
337
337
 
@@ -386,7 +386,7 @@ const archiveZip = (fileName, inputPath) => {
386
386
  archive.directory(dirPath, dir);
387
387
  });
388
388
 
389
- archive.file(sourceVideoPath, {
389
+ archive.file(originFilePath, {
390
390
  name: path.join(SOURCE_VIDEO_DIR, fileName),
391
391
  });
392
392
  // 完成归档
@@ -400,9 +400,9 @@ const archiveZip = (fileName, inputPath) => {
400
400
  const getMetadata = async (
401
401
  fileName,
402
402
  indexFilePath,
403
+ originFilePath,
403
404
  { rowFileName, title, keyword }
404
405
  ) => {
405
- const inputFilePath = path.join(workDir, "video", fileName);
406
406
  //第一张截图
407
407
  const photoInputPath = path.join(
408
408
  indexFilePath,
@@ -410,7 +410,7 @@ const getMetadata = async (
410
410
  "screenshots-1.png"
411
411
  );
412
412
 
413
- const videoMetadataComand = ffmpeg(inputFilePath);
413
+ const videoMetadataComand = ffmpeg(originFilePath);
414
414
  const photoMetadataComand = ffmpeg(photoInputPath);
415
415
  const metaDataParams = {
416
416
  userid: 1003,
@@ -515,8 +515,8 @@ const task = async (row, index) => {
515
515
  path.join(workDir, ORIGIN_FILE_DIR),
516
516
  fileName
517
517
  );
518
- console.log("源视频文件路径");
519
- console.log(originFilePath);
518
+ logger("源视频文件路径");
519
+ logger(originFilePath);
520
520
 
521
521
  //index文件夹 output/0
522
522
  const indexFilePath = path.join(workDir, "output", index + "");
@@ -529,12 +529,17 @@ const task = async (row, index) => {
529
529
  await get5Screenshots(fileName, indexFilePath, originFilePath);
530
530
  await watermarkVideo(fileName, indexFilePath);
531
531
  await watermarkScreenshots(indexFilePath);
532
- await archiveZip(fileName, indexFilePath);
533
- const dataParams = await getMetadata(fileName, indexFilePath, {
534
- rowFileName,
535
- title,
536
- keyword,
537
- });
532
+ await archiveZip(fileName, indexFilePath, originFilePath);
533
+ const dataParams = await getMetadata(
534
+ fileName,
535
+ indexFilePath,
536
+ originFilePath,
537
+ {
538
+ rowFileName,
539
+ title,
540
+ keyword,
541
+ }
542
+ );
538
543
  console.log("dataParams参数");
539
544
  console.log(dataParams);
540
545
 
@@ -543,7 +548,6 @@ const task = async (row, index) => {
543
548
  logger(
544
549
  `----------------------------------------第${index}条结束---------------------------------end`
545
550
  );
546
-
547
551
  } catch (error) {
548
552
  // 可以约定code,来表示不同的错误信息
549
553
  if (error.code === "ENOENT") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tools_batch_files",
3
- "version": "1.0.9",
3
+ "version": "1.0.12",
4
4
  "description": "批处理视频工具",
5
5
  "keywords": [
6
6
  "utils",