tools_batch_files 1.0.4 → 1.0.5
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 +15 -10
- package/package.json +2 -2
package/index.js
CHANGED
@@ -7,10 +7,15 @@ const archiver = require("archiver");
|
|
7
7
|
const axios = require("axios");
|
8
8
|
const generateUniqueHash = require("./utils/index");
|
9
9
|
|
10
|
+
//执行目录
|
11
|
+
const exeDir = __dirname;
|
12
|
+
//当前工作目录
|
13
|
+
const workDir = process.cwd();
|
14
|
+
|
10
15
|
// 表格目录
|
11
|
-
const excelDir = path.join(
|
16
|
+
const excelDir = path.join(workDir, "excel", "excel.xlsx");
|
12
17
|
//水印
|
13
|
-
const watermarkImage = path.join(
|
18
|
+
const watermarkImage = path.join(__dirname, "imgs", "miz-watermark.png");
|
14
19
|
// 截图数量
|
15
20
|
const SCREENSHOT_COUNT = 5;
|
16
21
|
const ORIGIN_FILE_DIR = "video";
|
@@ -129,7 +134,7 @@ function logFileSize(path) {
|
|
129
134
|
* @returns Promise
|
130
135
|
*/
|
131
136
|
const compressVideo = (fileName, outputFileDir, inputFilePath) => {
|
132
|
-
// const inputFilePath = path.join(
|
137
|
+
// const inputFilePath = path.join(workDir, "video", fileName);
|
133
138
|
const outputFilePath = path.join(
|
134
139
|
outputFileDir,
|
135
140
|
ZIP_VIDEO_DIR,
|
@@ -287,7 +292,7 @@ const watermarkScreenshots = (indexFilePath) => {
|
|
287
292
|
* 打包物料
|
288
293
|
*/
|
289
294
|
const archiveZip = (fileName, inputPath) => {
|
290
|
-
const sourceVideoPath = path.join(
|
295
|
+
const sourceVideoPath = path.join(workDir, "video", fileName);
|
291
296
|
const zipDir = path.join(inputPath, "zip");
|
292
297
|
|
293
298
|
ensureDirSync(zipDir);
|
@@ -350,7 +355,7 @@ const archiveZip = (fileName, inputPath) => {
|
|
350
355
|
* 获取 元数据
|
351
356
|
*/
|
352
357
|
const getMetadata = async (fileName, indexFilePath) => {
|
353
|
-
const inputFilePath = path.join(
|
358
|
+
const inputFilePath = path.join(workDir, "video", fileName);
|
354
359
|
//第一张截图
|
355
360
|
const photoInputPath = path.join(
|
356
361
|
indexFilePath,
|
@@ -426,16 +431,16 @@ const task = async (row, index) => {
|
|
426
431
|
);
|
427
432
|
// Excel的列名分别为: fileName title keyword
|
428
433
|
const fileName = row.fileName;
|
429
|
-
// const originFilePath = path.join(
|
434
|
+
// const originFilePath = path.join(workDir, "video", fileName); // 源视频文件路径
|
430
435
|
const originFilePath = findFileInDir(
|
431
|
-
path.join(
|
436
|
+
path.join(workDir, ORIGIN_FILE_DIR),
|
432
437
|
fileName
|
433
438
|
); // 源视频文件路径
|
434
439
|
console.log("originFilePath");
|
435
440
|
console.log(originFilePath);
|
436
441
|
|
437
442
|
//index文件夹 output/0
|
438
|
-
const indexFilePath = path.join(
|
443
|
+
const indexFilePath = path.join(workDir, "output", index + "");
|
439
444
|
|
440
445
|
try {
|
441
446
|
await fs_asnyc.access(originFilePath, fs_asnyc.constants.F_OK);
|
@@ -472,8 +477,8 @@ const transitionExcelToJSON = () => {
|
|
472
477
|
const hashOrigin = generateUniqueHash();
|
473
478
|
const hash = hashOrigin.slice(0, 8);
|
474
479
|
logger("任务开始---" + hash);
|
475
|
-
logger("当前目录: " +
|
476
|
-
logger("工作目录: " +
|
480
|
+
logger("当前目录: " + workDir);
|
481
|
+
logger("工作目录: " + __dirname);
|
477
482
|
|
478
483
|
const jsonData = readExcel(excelDir);
|
479
484
|
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "tools_batch_files",
|
3
|
-
"version": "1.0.
|
3
|
+
"version": "1.0.5",
|
4
4
|
"description": "批处理视频工具",
|
5
5
|
"keywords": [
|
6
6
|
"utils",
|
@@ -16,7 +16,7 @@
|
|
16
16
|
"test": "echo \"Error: no test specified\" && exit 1",
|
17
17
|
"start": "node index.js"
|
18
18
|
},
|
19
|
-
"author": "
|
19
|
+
"author": "zephyr",
|
20
20
|
"license": "ISC",
|
21
21
|
"dependencies": {
|
22
22
|
"archiver": "^7.0.1",
|