component-shipinlv 2.0.18 → 2.1.0

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 (49) hide show
  1. package/dist/ActiveAccountMode/hour-enabled.d.ts +9 -0
  2. package/dist/ActiveAccountMode/hour-enabled.js +42 -0
  3. package/dist/ActiveAccountMode/hour-enabled.less +24 -0
  4. package/dist/ActiveAccountMode/index.d.ts +7 -0
  5. package/dist/ActiveAccountMode/index.js +12 -0
  6. package/dist/ActiveAccountMode/index.less +0 -0
  7. package/dist/ActiveAccountMode/setting.d.ts +8 -0
  8. package/dist/ActiveAccountMode/setting.js +206 -0
  9. package/dist/ActiveAccountMode/setting.less +39 -0
  10. package/dist/ActiveAccountMode/task/index.d.ts +36 -0
  11. package/dist/ActiveAccountMode/task/index.js +811 -0
  12. package/dist/Auth/index.js +2 -0
  13. package/dist/VideoPublish/account-manage/home.js +1 -0
  14. package/dist/VideoPublish/account-manage/list.js +1 -0
  15. package/dist/VideoPublish/create-task/base/index.js +1 -1
  16. package/dist/VideoPublish/index.js +11 -1
  17. package/dist/VideoPublish/index.less +2 -2
  18. package/dist/VideoPublish/publish-task-plan/tool.js +1 -1
  19. package/dist/VideoPublish/video-account/create.js +1 -1
  20. package/dist/VideoPublish/video-account/group.js +1 -1
  21. package/dist/VideoPublish/video-account/index.js +56 -5
  22. package/dist/config/apiUrls.js +1 -1
  23. package/dist/lib/Tool.js +7 -0
  24. package/dist/lib/allow-mine-type.d.ts +4 -0
  25. package/dist/lib/allow-mine-type.js +19 -0
  26. package/dist/lib/file-type.d.ts +2 -0
  27. package/dist/lib/file-type.js +156 -0
  28. package/dist/lib/fs.d.ts +14 -0
  29. package/dist/lib/fs.js +479 -0
  30. package/dist/lib/getFileExt.d.ts +2 -0
  31. package/dist/lib/getFileExt.js +6 -0
  32. package/dist/lib/save-path.d.ts +17 -0
  33. package/dist/lib/save-path.js +173 -0
  34. package/dist/lib/save-path.less +21 -0
  35. package/dist/service/api/ActiveAccountModeSettingController.d.ts +2 -0
  36. package/dist/service/api/ActiveAccountModeSettingController.js +53 -0
  37. package/dist/service/api/PublishTaskPlanStatisticController.d.ts +1 -0
  38. package/dist/service/api/PublishTaskPlanStatisticController.js +28 -0
  39. package/dist/service/api/VideoPublishController.d.ts +4 -0
  40. package/dist/service/api/VideoPublishController.js +23 -0
  41. package/dist/types/AutoMakeTaskSetting.d.ts +18 -0
  42. package/dist/types/AutoMakeTaskSetting.js +0 -0
  43. package/dist/types/PublishTaskPlanStatistic.d.ts +15 -0
  44. package/dist/types/PublishTaskPlanStatistic.js +0 -0
  45. package/dist/types/VideoPublish.d.ts +1 -0
  46. package/dist/typings/VideoPublishVideoAccount.d.ts +1 -0
  47. package/dist/typings.d.ts +1 -0
  48. package/dist/window.d.ts +5 -0
  49. package/package.json +1 -1
@@ -0,0 +1,811 @@
1
+ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
2
+ import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
3
+ import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIteratorHelper";
4
+ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
5
+ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
6
+ import _createClass from "@babel/runtime/helpers/esm/createClass";
7
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
8
+ import * as ActiveAccountModeSettingController from "../../service/api/ActiveAccountModeSettingController";
9
+ import * as PublishTaskPlanStatisticController from "../../service/api/PublishTaskPlanStatisticController";
10
+ import * as VideoPublishVideoAccountController from "../../service/api/VideoPublishVideoAccountController";
11
+ import * as VideoPublishController from "../../service/api/VideoPublishController";
12
+ import dayjs from "dayjs";
13
+ import toastError from "../../lib/toastError";
14
+ import sleep from "../../lib/sleep";
15
+ import { delFile, fsDirVideoList } from "../../lib/fs";
16
+ import Tool from "../../lib/Tool";
17
+ var ActiveAccountModeTask = /*#__PURE__*/function () {
18
+ function ActiveAccountModeTask(env) {
19
+ var _this = this;
20
+ _classCallCheck(this, ActiveAccountModeTask);
21
+ _defineProperty(this, "timer", void 0);
22
+ _defineProperty(this, "loopSecond", 20);
23
+ _defineProperty(this, "modeSetting", {
24
+ dayTimeHourList: [],
25
+ dayPublishMaxAmount: 5,
26
+ timeAreaRandOffsetPercent: 10,
27
+ publishMaxDay: 3,
28
+ enabled: true,
29
+ isPublishFinishDelVideo: true
30
+ });
31
+ _defineProperty(this, "env", 'prod');
32
+ _defineProperty(this, "accountList", []);
33
+ _defineProperty(this, "planDict", {});
34
+ this.env = env;
35
+ this.timer = setInterval(function () {
36
+ _this.loop();
37
+ }, this.loopSecond * 1e3);
38
+ }
39
+ _createClass(ActiveAccountModeTask, [{
40
+ key: "destroy",
41
+ value: function destroy() {}
42
+ }, {
43
+ key: "loop",
44
+ value: function () {
45
+ var _loop = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
46
+ var setting, accountList, dayIndex, day, startTime, endTime, list, _iterator, _step, items, _iterator2, _step2, _this$planDict$accoun, accountItem, count;
47
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
48
+ while (1) switch (_context.prev = _context.next) {
49
+ case 0:
50
+ _context.next = 2;
51
+ return this.getSetting().catch(function (err) {
52
+ toastError('获取设置错误:' + (err === null || err === void 0 ? void 0 : err.message));
53
+ });
54
+ case 2:
55
+ setting = _context.sent;
56
+ if (setting) {
57
+ _context.next = 5;
58
+ break;
59
+ }
60
+ return _context.abrupt("return");
61
+ case 5:
62
+ this.modeSetting = setting;
63
+ if (setting.enabled) {
64
+ _context.next = 9;
65
+ break;
66
+ }
67
+ console.log('setting disabled!');
68
+ return _context.abrupt("return");
69
+ case 9:
70
+ _context.next = 11;
71
+ return this.getAccountList().catch(function (err) {
72
+ toastError('获取视频账户错误:' + (err === null || err === void 0 ? void 0 : err.message));
73
+ });
74
+ case 11:
75
+ accountList = _context.sent;
76
+ if (accountList) {
77
+ _context.next = 14;
78
+ break;
79
+ }
80
+ return _context.abrupt("return");
81
+ case 14:
82
+ this.accountList = accountList.list;
83
+ if (!(this.accountList.length === 0)) {
84
+ _context.next = 17;
85
+ break;
86
+ }
87
+ return _context.abrupt("return");
88
+ case 17:
89
+ dayIndex = 0;
90
+ case 18:
91
+ if (!(dayIndex < setting.publishMaxDay)) {
92
+ _context.next = 63;
93
+ break;
94
+ }
95
+ console.log('publishMaxDay:', dayIndex);
96
+ day = dayjs().add(dayIndex, 'day');
97
+ startTime = Math.floor(day.startOf('day').valueOf() * 0.001);
98
+ endTime = Math.floor(day.endOf('day').valueOf() * 0.001); // 获取用户列表;
99
+ _context.next = 25;
100
+ return this.getTaskPlanStatisticList(startTime, endTime).catch(function (err) {
101
+ toastError('获取账户列表失败:' + (err === null || err === void 0 ? void 0 : err.message));
102
+ });
103
+ case 25:
104
+ list = _context.sent;
105
+ if (list) {
106
+ _context.next = 30;
107
+ break;
108
+ }
109
+ _context.next = 29;
110
+ return sleep(20e3);
111
+ case 29:
112
+ return _context.abrupt("continue", 60);
113
+ case 30:
114
+ // 把发布过的,做一个字段
115
+ this.planDict = {};
116
+ _iterator = _createForOfIteratorHelper(list);
117
+ try {
118
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
119
+ items = _step.value;
120
+ if (!this.planDict[items.videoAccountId]) {
121
+ this.planDict[items.videoAccountId] = [];
122
+ }
123
+ this.planDict[items.videoAccountId].push(items);
124
+ }
125
+
126
+ // 所有用户
127
+ } catch (err) {
128
+ _iterator.e(err);
129
+ } finally {
130
+ _iterator.f();
131
+ }
132
+ _iterator2 = _createForOfIteratorHelper(this.accountList);
133
+ _context.prev = 34;
134
+ _iterator2.s();
135
+ case 36:
136
+ if ((_step2 = _iterator2.n()).done) {
137
+ _context.next = 52;
138
+ break;
139
+ }
140
+ accountItem = _step2.value;
141
+ count = ((_this$planDict$accoun = this.planDict[accountItem.id]) === null || _this$planDict$accoun === void 0 ? void 0 : _this$planDict$accoun.length) || 0; // 需要指定路径
142
+ if (accountItem.videoFromFolder) {
143
+ _context.next = 42;
144
+ break;
145
+ }
146
+ console.log('no videoFromFolder :', accountItem.nickname);
147
+ return _context.abrupt("continue", 50);
148
+ case 42:
149
+ // 删除 此账户下面,所有已经发布的视频
150
+ this.checkDelFile(accountItem.id, accountItem.videoFromFolder);
151
+ if (!(count >= setting.publishMaxDay)) {
152
+ _context.next = 45;
153
+ break;
154
+ }
155
+ return _context.abrupt("continue", 50);
156
+ case 45:
157
+ console.log('makePublishTask in:', accountItem.id, setting.publishMaxDay - count, dayIndex);
158
+
159
+ // 生成任务
160
+ _context.next = 48;
161
+ return this.makePublishTask(accountItem.id, setting.publishMaxDay - count, dayIndex).catch(function (err) {
162
+ console.log('makePublishTask err:', err);
163
+ });
164
+ case 48:
165
+ _context.next = 50;
166
+ return sleep(1e3);
167
+ case 50:
168
+ _context.next = 36;
169
+ break;
170
+ case 52:
171
+ _context.next = 57;
172
+ break;
173
+ case 54:
174
+ _context.prev = 54;
175
+ _context.t0 = _context["catch"](34);
176
+ _iterator2.e(_context.t0);
177
+ case 57:
178
+ _context.prev = 57;
179
+ _iterator2.f();
180
+ return _context.finish(57);
181
+ case 60:
182
+ dayIndex++;
183
+ _context.next = 18;
184
+ break;
185
+ case 63:
186
+ case "end":
187
+ return _context.stop();
188
+ }
189
+ }, _callee, this, [[34, 54, 57, 60]]);
190
+ }));
191
+ function loop() {
192
+ return _loop.apply(this, arguments);
193
+ }
194
+ return loop;
195
+ }()
196
+ }, {
197
+ key: "makePublishTask",
198
+ value: function () {
199
+ var _makePublishTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(videoAccountId, needTaskCount, dayIndex) {
200
+ var _this$accountList$fil;
201
+ var videoFromFolder, fileListInfo;
202
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
203
+ while (1) switch (_context2.prev = _context2.next) {
204
+ case 0:
205
+ // 先不管 每天做了一部分的,假设 每次都是 做完整
206
+ // 到这里来,肯定没做够
207
+ videoFromFolder = (_this$accountList$fil = this.accountList.filter(function (item) {
208
+ return item.id;
209
+ })) === null || _this$accountList$fil === void 0 || (_this$accountList$fil = _this$accountList$fil[0]) === null || _this$accountList$fil === void 0 ? void 0 : _this$accountList$fil.videoFromFolder;
210
+ if (videoFromFolder) {
211
+ _context2.next = 4;
212
+ break;
213
+ }
214
+ console.log('没有设置 videoFromFolder,跳过:', videoAccountId);
215
+ return _context2.abrupt("return");
216
+ case 4:
217
+ _context2.next = 6;
218
+ return this.getFileList(videoAccountId, needTaskCount, videoFromFolder).catch(function (err) {});
219
+ case 6:
220
+ fileListInfo = _context2.sent;
221
+ if (fileListInfo) {
222
+ _context2.next = 10;
223
+ break;
224
+ }
225
+ console.log('no fileListInfo :', videoAccountId, needTaskCount, dayIndex);
226
+ return _context2.abrupt("return");
227
+ case 10:
228
+ return _context2.abrupt("return", this.postTask(videoAccountId, fileListInfo.videoList || [], fileListInfo.topicList || [], dayIndex));
229
+ case 11:
230
+ case "end":
231
+ return _context2.stop();
232
+ }
233
+ }, _callee2, this);
234
+ }));
235
+ function makePublishTask(_x, _x2, _x3) {
236
+ return _makePublishTask.apply(this, arguments);
237
+ }
238
+ return makePublishTask;
239
+ }()
240
+ }, {
241
+ key: "postTask",
242
+ value: function () {
243
+ var _postTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(videoAccountId, videoList, topicList, dayIndex) {
244
+ var _this2 = this;
245
+ var dayStartTime, _this$modeSetting, dayPublishMaxAmount, dayTimeHourList, timeAreaRandOffsetPercent, oneVideoByMinute, publishTimeList, i, hourIndex, dayHour, hourMinute, stepTime, stepMin, stepMax;
246
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
247
+ while (1) switch (_context4.prev = _context4.next) {
248
+ case 0:
249
+ if (!(((videoList === null || videoList === void 0 ? void 0 : videoList.length) || 0) <= 0)) {
250
+ _context4.next = 3;
251
+ break;
252
+ }
253
+ console.log('no videoList :', videoAccountId);
254
+ return _context4.abrupt("return");
255
+ case 3:
256
+ dayStartTime = dayjs().startOf('day').valueOf() + dayIndex * 86400e3; // 计算发视频间隔;
257
+ // const planList = this.planDict[ videoAccountId ];
258
+ // if( planList.length == 0 ){
259
+ // return ;
260
+ // }
261
+ if (!(videoList.length == 0)) {
262
+ _context4.next = 7;
263
+ break;
264
+ }
265
+ console.log('postTask 没视频');
266
+ return _context4.abrupt("return");
267
+ case 7:
268
+ _this$modeSetting = this.modeSetting, dayPublishMaxAmount = _this$modeSetting.dayPublishMaxAmount, dayTimeHourList = _this$modeSetting.dayTimeHourList, timeAreaRandOffsetPercent = _this$modeSetting.timeAreaRandOffsetPercent;
269
+ oneVideoByMinute = dayTimeHourList.length * 60 / dayPublishMaxAmount;
270
+ publishTimeList = [];
271
+ i = 0;
272
+ case 11:
273
+ if (!(i < dayPublishMaxAmount)) {
274
+ _context4.next = 28;
275
+ break;
276
+ }
277
+ if (!(i < dayPublishMaxAmount - videoList.length)) {
278
+ _context4.next = 15;
279
+ break;
280
+ }
281
+ console.log('for dayPublishMaxAmount :', i, dayPublishMaxAmount, videoList);
282
+ return _context4.abrupt("continue", 25);
283
+ case 15:
284
+ // 到多少分钟了
285
+ hourIndex = Math.floor(i * oneVideoByMinute / 60);
286
+ dayHour = parseInt(dayTimeHourList[hourIndex]);
287
+ if (dayHour) {
288
+ _context4.next = 20;
289
+ break;
290
+ }
291
+ console.log('postTask not dayHour:', i, hourIndex, oneVideoByMinute);
292
+ return _context4.abrupt("continue", 25);
293
+ case 20:
294
+ hourMinute = i * oneVideoByMinute % 60;
295
+ stepTime = dayStartTime + dayHour * 3600e3 + hourMinute * 60e3;
296
+ stepMin = stepTime - 3600e3 * 0.01 * timeAreaRandOffsetPercent;
297
+ stepMax = stepTime + 3600e3 * 0.01 * timeAreaRandOffsetPercent;
298
+ publishTimeList.push(Tool.math.randInt(stepMin, stepMax));
299
+ case 25:
300
+ i++;
301
+ _context4.next = 11;
302
+ break;
303
+ case 28:
304
+ if (!(publishTimeList.length == 0)) {
305
+ _context4.next = 31;
306
+ break;
307
+ }
308
+ console.log('publishTimeList empty!');
309
+ return _context4.abrupt("return");
310
+ case 31:
311
+ return _context4.abrupt("return", new Promise( /*#__PURE__*/function () {
312
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(resolve) {
313
+ var videoIndex, _iterator3, _step3, videoPath, introduction, startTime, newVideoPath, publishResult;
314
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
315
+ while (1) switch (_context3.prev = _context3.next) {
316
+ case 0:
317
+ videoIndex = -1;
318
+ _iterator3 = _createForOfIteratorHelper(videoList);
319
+ _context3.prev = 2;
320
+ _iterator3.s();
321
+ case 4:
322
+ if ((_step3 = _iterator3.n()).done) {
323
+ _context3.next = 28;
324
+ break;
325
+ }
326
+ videoPath = _step3.value;
327
+ videoIndex++;
328
+ introduction = topicList.map(function (topic) {
329
+ return "#".concat(topic, " ");
330
+ }).join(' ');
331
+ startTime = publishTimeList[videoIndex];
332
+ if (startTime) {
333
+ _context3.next = 12;
334
+ break;
335
+ }
336
+ console.log('视频没有匹配到 发布时间:', videoIndex, videoList, publishTimeList);
337
+ return _context3.abrupt("continue", 26);
338
+ case 12:
339
+ if (!(startTime <= Date.now())) {
340
+ _context3.next = 16;
341
+ break;
342
+ }
343
+ // 抛弃
344
+
345
+ console.log('已经过了时间了 0。。。', dayIndex, videoAccountId);
346
+ console.log('已经过了时间了 1。。。', videoIndex, videoList, publishTimeList);
347
+ return _context3.abrupt("continue", 26);
348
+ case 16:
349
+ _context3.next = 18;
350
+ return _this2.videoRename(videoPath).catch(function (err) {
351
+ // reject( err );
352
+ });
353
+ case 18:
354
+ newVideoPath = _context3.sent;
355
+ if (newVideoPath) {
356
+ _context3.next = 21;
357
+ break;
358
+ }
359
+ return _context3.abrupt("continue", 26);
360
+ case 21:
361
+ _context3.next = 23;
362
+ return VideoPublishController.taskCreate({
363
+ "videoFrom": "local",
364
+ "taskFromProductType": "",
365
+ "accountList": ["account-".concat(videoAccountId)],
366
+ "normalVideoRate": 1,
367
+ "normalVideoRateType": "hour",
368
+ "normalDayMaxCount": 1,
369
+ "normalVideoKindRateType": "",
370
+ "whoCanView": "0",
371
+ "noTopicIsUserRecommendTopic": true,
372
+ startTime: Math.floor(startTime * 0.001),
373
+ "publishOrder": "",
374
+ "salesVideoRate": 2,
375
+ "salesVideoRateType": "hour",
376
+ "salesDayMaxCount": 2,
377
+ "salesVideoKindRateType": "",
378
+ "hourEnabled": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23],
379
+ "videoList": [{
380
+ "taskId": 0,
381
+ "productType": "active-account-mode",
382
+ "title": "",
383
+ "videoUrl": newVideoPath,
384
+ "introduction": introduction,
385
+ "videoKindTag": "",
386
+ "kindTagValue": "",
387
+ "goodsTitle": ""
388
+ }]
389
+ }, {
390
+ env: _this2.env
391
+ }).catch(function (err) {
392
+ // reject( err );
393
+ });
394
+ case 23:
395
+ publishResult = _context3.sent;
396
+ _context3.next = 26;
397
+ return sleep(2e3);
398
+ case 26:
399
+ _context3.next = 4;
400
+ break;
401
+ case 28:
402
+ _context3.next = 33;
403
+ break;
404
+ case 30:
405
+ _context3.prev = 30;
406
+ _context3.t0 = _context3["catch"](2);
407
+ _iterator3.e(_context3.t0);
408
+ case 33:
409
+ _context3.prev = 33;
410
+ _iterator3.f();
411
+ return _context3.finish(33);
412
+ case 36:
413
+ resolve(true);
414
+ case 37:
415
+ case "end":
416
+ return _context3.stop();
417
+ }
418
+ }, _callee3, null, [[2, 30, 33, 36]]);
419
+ }));
420
+ return function (_x8) {
421
+ return _ref.apply(this, arguments);
422
+ };
423
+ }()));
424
+ case 32:
425
+ case "end":
426
+ return _context4.stop();
427
+ }
428
+ }, _callee4, this);
429
+ }));
430
+ function postTask(_x4, _x5, _x6, _x7) {
431
+ return _postTask.apply(this, arguments);
432
+ }
433
+ return postTask;
434
+ }()
435
+ }, {
436
+ key: "getSetting",
437
+ value: function () {
438
+ var _getSetting = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
439
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
440
+ while (1) switch (_context5.prev = _context5.next) {
441
+ case 0:
442
+ return _context5.abrupt("return", ActiveAccountModeSettingController.detail({}, {
443
+ env: this.env
444
+ }));
445
+ case 1:
446
+ case "end":
447
+ return _context5.stop();
448
+ }
449
+ }, _callee5, this);
450
+ }));
451
+ function getSetting() {
452
+ return _getSetting.apply(this, arguments);
453
+ }
454
+ return getSetting;
455
+ }()
456
+ }, {
457
+ key: "getTopicList",
458
+ value: function () {
459
+ var _getTopicList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(dir) {
460
+ var _window$getBridge;
461
+ var text, list, topicList;
462
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
463
+ while (1) switch (_context6.prev = _context6.next) {
464
+ case 0:
465
+ _context6.next = 2;
466
+ return (_window$getBridge = window.getBridge()) === null || _window$getBridge === void 0 ? void 0 : _window$getBridge.getFileText("".concat(dir, "/\u8BDD\u9898.txt")).catch(function (err) {
467
+ console.log('getTopicList err:', err);
468
+ return '';
469
+ });
470
+ case 2:
471
+ text = _context6.sent;
472
+ if (text) {
473
+ _context6.next = 6;
474
+ break;
475
+ }
476
+ console.log('getTopicList empty:', dir);
477
+ return _context6.abrupt("return", []);
478
+ case 6:
479
+ list = text.split(/[\s\n#]/g) || [];
480
+ topicList = [];
481
+ list.forEach(function (topic) {
482
+ if (!topic) {
483
+ return;
484
+ }
485
+ topicList.push(topic);
486
+ });
487
+ return _context6.abrupt("return", topicList);
488
+ case 10:
489
+ case "end":
490
+ return _context6.stop();
491
+ }
492
+ }, _callee6);
493
+ }));
494
+ function getTopicList(_x9) {
495
+ return _getTopicList.apply(this, arguments);
496
+ }
497
+ return getTopicList;
498
+ }()
499
+ }, {
500
+ key: "getAccountList",
501
+ value: function () {
502
+ var _getAccountList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
503
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
504
+ while (1) switch (_context7.prev = _context7.next) {
505
+ case 0:
506
+ return _context7.abrupt("return", VideoPublishVideoAccountController.list({
507
+ current: 1,
508
+ pageSize: 100
509
+ }, {
510
+ env: this.env
511
+ }));
512
+ case 1:
513
+ case "end":
514
+ return _context7.stop();
515
+ }
516
+ }, _callee7, this);
517
+ }));
518
+ function getAccountList() {
519
+ return _getAccountList.apply(this, arguments);
520
+ }
521
+ return getAccountList;
522
+ }()
523
+ }, {
524
+ key: "getTaskPlanStatisticList",
525
+ value: function () {
526
+ var _getTaskPlanStatisticList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(startTime, endTime) {
527
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
528
+ while (1) switch (_context8.prev = _context8.next) {
529
+ case 0:
530
+ return _context8.abrupt("return", PublishTaskPlanStatisticController.list({
531
+ productType: 'active-account-mode',
532
+ platform: 'douyin',
533
+ startTime: startTime,
534
+ endTime: endTime
535
+ }, {
536
+ env: this.env
537
+ }));
538
+ case 1:
539
+ case "end":
540
+ return _context8.stop();
541
+ }
542
+ }, _callee8, this);
543
+ }));
544
+ function getTaskPlanStatisticList(_x10, _x11) {
545
+ return _getTaskPlanStatisticList.apply(this, arguments);
546
+ }
547
+ return getTaskPlanStatisticList;
548
+ }()
549
+ }, {
550
+ key: "getaArrayRandList",
551
+ value: function getaArrayRandList(list, count) {
552
+ if ((list === null || list === void 0 ? void 0 : list.length) < count) {
553
+ return list;
554
+ }
555
+ return this.removeFiveUniqueItems(list, count).slice(0, count);
556
+ }
557
+ }, {
558
+ key: "removeFiveUniqueItems",
559
+ value: function removeFiveUniqueItems(arr, count) {
560
+ // 检查输入是否为数组且长度大于等于5
561
+ if (!Array.isArray(arr) || arr.length < count) {
562
+ return arr;
563
+ }
564
+
565
+ // 创建数组副本,避免修改原数组
566
+ var copyArr = _toConsumableArray(arr);
567
+ var removedItems = [];
568
+ var uniqueSet = new Set();
569
+ while (uniqueSet.size < 5 && copyArr.length > 0) {
570
+ // 获取随机索引
571
+ var randomIndex = Math.floor(Math.random() * copyArr.length);
572
+ // 移除并获取该项
573
+ var item = copyArr.splice(randomIndex, 1)[0];
574
+ // 将其添加到 Set 确保唯一性
575
+ uniqueSet.add(item);
576
+ }
577
+
578
+ // 将 Set 转换回数组
579
+ removedItems = Array.from(uniqueSet);
580
+ return removedItems;
581
+ }
582
+ }, {
583
+ key: "getFileList",
584
+ value: function () {
585
+ var _getFileList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(videoAccountId, needTaskCount, videoFromFolder) {
586
+ var fileList, videoList, _iterator4, _step4, filePath, _this$getCommandByPat, command, topicList;
587
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
588
+ while (1) switch (_context9.prev = _context9.next) {
589
+ case 0:
590
+ fileList = fsDirVideoList(videoFromFolder);
591
+ if (!(fileList.length === 0)) {
592
+ _context9.next = 4;
593
+ break;
594
+ }
595
+ console.log('文件夹没视频,跳过:', videoAccountId, videoFromFolder);
596
+ return _context9.abrupt("return", {
597
+ videoList: [],
598
+ topicList: []
599
+ });
600
+ case 4:
601
+ console.log('fileList:', fileList);
602
+ videoList = []; // 获取视频
603
+ _iterator4 = _createForOfIteratorHelper(fileList);
604
+ _context9.prev = 7;
605
+ _iterator4.s();
606
+ case 9:
607
+ if ((_step4 = _iterator4.n()).done) {
608
+ _context9.next = 25;
609
+ break;
610
+ }
611
+ filePath = _step4.value;
612
+ _this$getCommandByPat = this.getCommandByPath(filePath), command = _this$getCommandByPat.command;
613
+ if (command) {
614
+ _context9.next = 16;
615
+ break;
616
+ }
617
+ videoList.push(filePath);
618
+ _context9.next = 23;
619
+ break;
620
+ case 16:
621
+ _context9.t0 = command;
622
+ _context9.next = _context9.t0 === 'needDel' ? 19 : _context9.t0 === 'waitPublish' ? 21 : 23;
623
+ break;
624
+ case 19:
625
+ delFile(filePath);
626
+ return _context9.abrupt("break", 23);
627
+ case 21:
628
+ this.fileTimeTooLongNeedDel(filePath);
629
+ return _context9.abrupt("break", 23);
630
+ case 23:
631
+ _context9.next = 9;
632
+ break;
633
+ case 25:
634
+ _context9.next = 30;
635
+ break;
636
+ case 27:
637
+ _context9.prev = 27;
638
+ _context9.t1 = _context9["catch"](7);
639
+ _iterator4.e(_context9.t1);
640
+ case 30:
641
+ _context9.prev = 30;
642
+ _iterator4.f();
643
+ return _context9.finish(30);
644
+ case 33:
645
+ if (!(videoList.length === 0)) {
646
+ _context9.next = 36;
647
+ break;
648
+ }
649
+ console.log('文件夹 没 可用的视频,跳过 2:', videoAccountId, videoFromFolder);
650
+ return _context9.abrupt("return", {
651
+ videoList: videoList,
652
+ topicList: []
653
+ });
654
+ case 36:
655
+ _context9.next = 38;
656
+ return this.getTopicList(videoFromFolder).catch(function () {
657
+ return [];
658
+ });
659
+ case 38:
660
+ topicList = _context9.sent;
661
+ return _context9.abrupt("return", {
662
+ videoList: this.getaArrayRandList(videoList, needTaskCount),
663
+ topicList: this.getaArrayRandList(topicList, 5)
664
+ });
665
+ case 40:
666
+ case "end":
667
+ return _context9.stop();
668
+ }
669
+ }, _callee9, this, [[7, 27, 30, 33]]);
670
+ }));
671
+ function getFileList(_x12, _x13, _x14) {
672
+ return _getFileList.apply(this, arguments);
673
+ }
674
+ return getFileList;
675
+ }()
676
+ }, {
677
+ key: "getCommandByPath",
678
+ value: function getCommandByPath(filePath) {
679
+ var fileName = this.getFileName(filePath);
680
+ var commandInfo = fileName.match(/^◀([a-z0-9]+)-([a-z0-9]+)▶/i) || [];
681
+ var command = commandInfo[1] || '';
682
+ var fileTime = parseInt(commandInfo[2]) || 0;
683
+ return {
684
+ command: command,
685
+ fileTime: fileTime
686
+ };
687
+ }
688
+ }, {
689
+ key: "getLocalVideoList",
690
+ value: function getLocalVideoList(videoFromFolder) {
691
+ var fileList = fsDirVideoList(videoFromFolder);
692
+ if (fileList.length === 0) {
693
+ console.log('文件夹没视频,跳过:', videoFromFolder);
694
+ return [];
695
+ }
696
+ return fileList;
697
+ }
698
+ }, {
699
+ key: "getFileName",
700
+ value: function getFileName(filePath) {
701
+ var videoPathInfo = filePath.split(/[\/\\]/g);
702
+ return videoPathInfo[videoPathInfo.length - 1] || '';
703
+ }
704
+ }, {
705
+ key: "videoRename",
706
+ value: function () {
707
+ var _videoRename = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(videoPath) {
708
+ var videoPathInfo, newName, newFilePath;
709
+ return _regeneratorRuntime().wrap(function _callee11$(_context11) {
710
+ while (1) switch (_context11.prev = _context11.next) {
711
+ case 0:
712
+ videoPathInfo = videoPath.split(/[\/\\]/g);
713
+ newName = "\u25C0waitPublish-".concat(Math.floor(Date.now() * 0.001), "\u25B6") + this.getFileName(videoPath);
714
+ newFilePath = videoPathInfo.slice(0, -1).join('/') + "/".concat(newName);
715
+ console.log('newFilePath:', newFilePath);
716
+ return _context11.abrupt("return", new Promise( /*#__PURE__*/function () {
717
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(resolve, reject) {
718
+ return _regeneratorRuntime().wrap(function _callee10$(_context10) {
719
+ while (1) switch (_context10.prev = _context10.next) {
720
+ case 0:
721
+ window.getBridge().fs.rename(videoPath, newFilePath, function (err) {
722
+ if (err) {
723
+ console.log('videoRename err:', err);
724
+ reject(err);
725
+ return;
726
+ }
727
+ resolve(newFilePath);
728
+ });
729
+ case 1:
730
+ case "end":
731
+ return _context10.stop();
732
+ }
733
+ }, _callee10);
734
+ }));
735
+ return function (_x16, _x17) {
736
+ return _ref2.apply(this, arguments);
737
+ };
738
+ }()));
739
+ case 5:
740
+ case "end":
741
+ return _context11.stop();
742
+ }
743
+ }, _callee11, this);
744
+ }));
745
+ function videoRename(_x15) {
746
+ return _videoRename.apply(this, arguments);
747
+ }
748
+ return videoRename;
749
+ }()
750
+ }, {
751
+ key: "fileTimeTooLongNeedDel",
752
+ value: function fileTimeTooLongNeedDel(filePath) {
753
+ var _this$getCommandByPat2 = this.getCommandByPath(filePath),
754
+ command = _this$getCommandByPat2.command,
755
+ fileTime = _this$getCommandByPat2.fileTime;
756
+ if (!command || fileTime <= 0) {
757
+ return;
758
+ }
759
+
760
+ // 太久了,删除
761
+ if (fileTime * 1e3 + (this.modeSetting.publishMaxDay + 2) * 86400e3 < Date.now()) {
762
+ delFile(filePath);
763
+ }
764
+ }
765
+ }, {
766
+ key: "checkDelFile",
767
+ value: function () {
768
+ var _checkDelFile = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(accountId, videoFromFolder) {
769
+ var _this3 = this;
770
+ var folderVideoList, planList;
771
+ return _regeneratorRuntime().wrap(function _callee12$(_context12) {
772
+ while (1) switch (_context12.prev = _context12.next) {
773
+ case 0:
774
+ folderVideoList = this.getLocalVideoList(videoFromFolder).map(function (filePath) {
775
+ return filePath.replace(/\\/g, '/');
776
+ });
777
+ planList = this.planDict[accountId] || [];
778
+ planList.forEach(function (item) {
779
+ var _item$videoUrl;
780
+ if (item.status !== 'finish') {
781
+ return;
782
+ }
783
+ if (!item.videoUrl) {
784
+ return;
785
+ }
786
+ var videoUrl = ((_item$videoUrl = item.videoUrl) === null || _item$videoUrl === void 0 ? void 0 : _item$videoUrl.replace(/\\/g, '/')) || '';
787
+ if (folderVideoList.indexOf(videoUrl) === -1) {
788
+ return;
789
+ }
790
+ if (_this3.modeSetting.isPublishFinishDelVideo) {
791
+ delFile(videoUrl);
792
+ } else {
793
+ // 改名字
794
+ delFile(videoUrl);
795
+ }
796
+ });
797
+ case 3:
798
+ case "end":
799
+ return _context12.stop();
800
+ }
801
+ }, _callee12, this);
802
+ }));
803
+ function checkDelFile(_x18, _x19) {
804
+ return _checkDelFile.apply(this, arguments);
805
+ }
806
+ return checkDelFile;
807
+ }()
808
+ }]);
809
+ return ActiveAccountModeTask;
810
+ }();
811
+ export default ActiveAccountModeTask;