component-shipinlv 1.1.27 → 1.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. package/dist/VideoPublish/account-manage/home.js +25 -4
  2. package/dist/VideoPublish/account-manage/list.d.ts +1 -0
  3. package/dist/VideoPublish/account-manage/list.js +69 -24
  4. package/dist/VideoPublish/account-manage/setting/index.js +43 -4
  5. package/dist/VideoPublish/log/index.js +90 -44
  6. package/dist/VideoPublish/log/index.less +1 -1
  7. package/dist/VideoPublish/publish-task-plan/index.js +14 -2
  8. package/dist/VideoPublish/publish-task-plan/tool-bak.txt +219 -0
  9. package/dist/VideoPublish/publish-task-plan/tool.d.ts +14 -4
  10. package/dist/VideoPublish/publish-task-plan/tool.js +302 -83
  11. package/dist/VideoPublish/video-account/index.js +5 -2
  12. package/dist/base/folderCreate.d.ts +2 -0
  13. package/dist/base/folderCreate.js +56 -0
  14. package/dist/component/folder-select.d.ts +1 -0
  15. package/dist/component/folder-select.js +46 -12
  16. package/dist/component/param.d.ts +5 -0
  17. package/dist/component/param.js +9 -0
  18. package/dist/component/sse.d.ts +11 -0
  19. package/dist/component/sse.js +66 -0
  20. package/dist/component/video-platform/logo.js +4 -2
  21. package/dist/index.d.ts +1 -0
  22. package/dist/index.js +1 -0
  23. package/dist/lib/Tool.d.ts +1 -1
  24. package/dist/lib/Tool.js +3 -2
  25. package/dist/lib/event.js +2 -2
  26. package/dist/lib/getApiUrl.d.ts +1 -0
  27. package/dist/lib/getApiUrl.js +9 -1
  28. package/dist/lib/openChrome.d.ts +2 -0
  29. package/dist/lib/openChrome.js +141 -0
  30. package/dist/lib/request.js +1 -1
  31. package/dist/lib/user-agent.d.ts +2 -0
  32. package/dist/lib/user-agent.js +10 -0
  33. package/dist/lib/video-api/open-chrome.d.ts +2 -0
  34. package/dist/lib/video-api/open-chrome.js +49 -0
  35. package/dist/lib/video-api/quit-chrome.d.ts +2 -0
  36. package/dist/lib/video-api/quit-chrome.js +51 -0
  37. package/dist/service/local/FileController.d.ts +3 -0
  38. package/dist/service/local/FileController.js +59 -32
  39. package/dist/service/video-api/VideoApiOpenChromeController.d.ts +2 -0
  40. package/dist/service/video-api/VideoApiOpenChromeController.js +50 -0
  41. package/dist/types/ApiLocal.d.ts +19 -0
  42. package/dist/types/ApiLocal.js +0 -0
  43. package/dist/types/ChromeOperate.d.ts +22 -0
  44. package/dist/types/ChromeOperate.js +0 -0
  45. package/dist/types/PublishTaskPlan.d.ts +7 -1
  46. package/dist/types/PublishVideo.d.ts +11 -0
  47. package/dist/types/PublishVideo.js +0 -0
  48. package/dist/types/VideoPublishLog.d.ts +4 -1
  49. package/dist/typings/LocalFile.d.ts +3 -0
  50. package/dist/typings/VideoPublishAccountManageSetting.d.ts +1 -0
  51. package/dist/typings/VideoPublishVideoAccount.d.ts +3 -0
  52. package/dist/window.d.ts +1 -0
  53. package/package.json +1 -1
@@ -0,0 +1,219 @@
1
+ import * as VideoPublishCrawlerTaskController from '../../service/api/VideoPublishCrawlerTaskController';
2
+ import sleep from "../../lib/sleep";
3
+ import event from "../../lib/event";
4
+ import AccountManageSettingConfig from "../../lib/accountManageSettingConfig";
5
+
6
+ class PublishTaskPlanClass {
7
+ timeLoopMillisecond = 15 * 1e3;
8
+ isPublishing = false;
9
+ env = '' as Global.Env | undefined ;
10
+ clientIdentity = '';
11
+ constructor( env?: Global.Env, clientIdentity = '' ) {
12
+ this.env = env;
13
+ this.clientIdentity = clientIdentity;
14
+ }
15
+ onInit(){
16
+ setInterval(() => {
17
+ if( this.isPublishing ){
18
+ return;
19
+ }
20
+ this.getWork();
21
+ }, 2e3 );
22
+
23
+ // 桥
24
+ window.getBridge?.()?.onLog?.( ( query: any ) => {
25
+ event.run('shipinlv-video-publish-log', query )
26
+ });
27
+ }
28
+
29
+ async getWork(){
30
+ const settingConfig = AccountManageSettingConfig();
31
+ if( settingConfig.disabledApplyTask ){
32
+ return;
33
+ }
34
+
35
+ this.isPublishing = true;
36
+ const taskDetail = await this.onTaskGet()
37
+ .catch( err => {
38
+
39
+ });
40
+
41
+ if( ! taskDetail ){
42
+ await sleep( this.timeLoopMillisecond );
43
+ this.isPublishing = false;
44
+ return;
45
+ }
46
+
47
+ this.doWork( taskDetail );
48
+ }
49
+
50
+ async doWork( taskDetail: PublishTaskPlan.TaskDetail ){
51
+ if( taskDetail.emptyLoopTimeSecond > 10 ){
52
+ this.timeLoopMillisecond = taskDetail.emptyLoopTimeSecond * 1e3;
53
+ }
54
+
55
+ console.log("taskDetail;", taskDetail );
56
+ const item = taskDetail.taskInfo;
57
+ if( item.taskType === '' ){
58
+ console.log('无任务');
59
+ await this.doWorkWait();
60
+ return;
61
+ }
62
+
63
+
64
+ const saveBaseData = {
65
+ taskType: item.taskType,
66
+ taskId: item.taskId,
67
+ platform: taskDetail.platform,
68
+ platformAccountId: taskDetail.platformVideoAccountId,
69
+ };
70
+ switch ( item.taskType ) {
71
+ case "publish-video":
72
+ if( ! item.publishVideo ){
73
+ console.warn("item.publishVideo is empty!")
74
+ this.onReport(false, "publishVideo 不存在", saveBaseData );
75
+ break;
76
+ }
77
+ const result = await this.onPublishVideo(
78
+ taskDetail.platform,
79
+ taskDetail.platformVideoAccountId,
80
+ taskDetail.taskInfo,
81
+ taskDetail.proxyInfo,
82
+ )
83
+ .catch( err => {
84
+ console.warn("onPublishVideo err:", err );
85
+ this.onReport(false, err?.message, saveBaseData );
86
+ });
87
+ if( result ){
88
+ this.onReport(result.success, result.message, saveBaseData );
89
+ }
90
+ break;
91
+ default:
92
+ const errMessage = '暂不支持 类型:'+ item.taskType ;
93
+ console.log( errMessage );
94
+ const errLog: VideoPublishLog.Receive = {
95
+ platform: taskDetail.platform,
96
+ platformAccountId: taskDetail.platformVideoAccountId,
97
+ code: 'not-support-task-type',
98
+ message: errMessage,
99
+ status: 'fail',
100
+ taskId: item.taskId,
101
+ eventType: 'task-kind'
102
+ }
103
+ this.onLog( errLog );
104
+
105
+ this.onReport(false, errMessage, saveBaseData );
106
+ }
107
+
108
+ await this.doWorkWait();
109
+ }
110
+
111
+ async onLog( query: VideoPublishLog.Receive ){
112
+ event.run('shipinlv-video-publish-log', query);
113
+ }
114
+
115
+ async doWorkWait(){
116
+ await sleep( this.timeLoopMillisecond );
117
+ this.isPublishing = false;
118
+ }
119
+
120
+ onReport(success: boolean, message: string, saveBaseData: PublishTaskPlan.ReportTaskQueryBaseInfo ){
121
+ VideoPublishCrawlerTaskController.report({
122
+ success,
123
+ message,
124
+ ...saveBaseData,
125
+ },{
126
+ env: this.env,
127
+ });
128
+ }
129
+
130
+ async onTaskGet(){
131
+ event.run('task-apply');
132
+ const env = this.env;
133
+
134
+ return await VideoPublishCrawlerTaskController.apply({
135
+
136
+ }, {
137
+ env,
138
+ });
139
+ }
140
+
141
+ async onPublishVideo(
142
+ platform: Global.VideoPlatformKind,
143
+ platformVideoAccountId: string,
144
+ taskInfo: PublishTaskPlan.TaskInfo,
145
+ proxyInfo: Global.ProxyInfo,
146
+ ){
147
+ // 发布抖音视频
148
+ await sleep( 1 );
149
+ return new Promise<PublishNpm.VideoPublishResult>(async ( resolve, reject ) => {
150
+ const settingConfig = AccountManageSettingConfig();
151
+ console.log('settingConfig 1:', settingConfig );
152
+ const publishResult = await window.getBridge?.().videoPublish(
153
+ proxyInfo,
154
+ {
155
+ platformVideoAccountId,
156
+ platform,
157
+ open: settingConfig.isChromeOpen, // 发布视频的时候是否打开图形界面
158
+ taskInfo,
159
+ // taskInfo: {
160
+ // taskId: detail.taskId,
161
+ // taskType:
162
+ // publishVideo: {
163
+ // taskId: detail.taskId,
164
+ // title: detail.title, // "视频标题",
165
+ // introduction: detail.introduction, //"视频简介",
166
+ // videoKindTag: detail.videoKindTag, //"", // shopping | ""
167
+ // videoUrl: detail.videoUrl, //"视频地址",
168
+ // publishTime: detail.publishTime, //"2024-08-14 10:00", // 可以是int也可以是string
169
+ // kindTagValue: detail.kindTagValue, // "" // 抖音是商品链接 快手是商品relItemId
170
+ // }
171
+ // },
172
+ })
173
+ .catch( err => {
174
+ // 基本不会到这里
175
+ console.warn('bridge. video Publish err:', err.code, err );
176
+ resolve( err );
177
+ });
178
+
179
+ if( ! publishResult ){
180
+ return publishResult;
181
+ }
182
+
183
+ console.log("publishResult:", publishResult);
184
+
185
+ if( ! publishResult.success ){
186
+ const errLog: VideoPublishLog.Receive = {
187
+ platform: publishResult.data.platform,
188
+ platformAccountId: publishResult.data.platformVideoAccountId,
189
+ code: publishResult.code,
190
+ message: publishResult.message,
191
+ status: 'fail',
192
+ taskId: taskInfo.taskId,
193
+ eventType: 'publish-video'
194
+ }
195
+ // event.run('lo g', errLog);
196
+ this.onLog( errLog );
197
+
198
+ const err = new Error( publishResult.message );
199
+ err.name = publishResult.code;
200
+ return reject( err );
201
+ }
202
+
203
+ resolve( publishResult );
204
+
205
+ // const logReceive: Log.Receive = {
206
+ // platform: publishResult.data.platform,
207
+ // platformAccountId: publishResult.data.platformVideoAccountId,
208
+ // code: 'publish-video-finish',
209
+ // message: '',
210
+ // status: 'success',
211
+ // taskId: 0,
212
+ // eventType: 'task-kind'
213
+ // }
214
+ // event.run('lo g', logReceive);
215
+ });
216
+ }
217
+ }
218
+
219
+ export default PublishTaskPlanClass;
@@ -1,16 +1,26 @@
1
1
  declare class PublishTaskPlanClass {
2
2
  timeLoopMillisecond: number;
3
3
  isPublishing: boolean;
4
- env: Global.Env | undefined;
4
+ env: Global.Env | '';
5
5
  clientIdentity: string;
6
- constructor(env?: Global.Env, clientIdentity?: string);
6
+ options: PublishTaskPlan.Options;
7
+ constructor(env: Global.Env | '', clientIdentity: string | undefined, options: PublishTaskPlan.Options);
7
8
  onInit(): void;
8
9
  getWork(): Promise<void>;
9
10
  doWork(taskDetail: PublishTaskPlan.TaskDetail): Promise<void>;
10
11
  onLog(query: VideoPublishLog.Receive): Promise<void>;
11
12
  doWorkWait(): Promise<void>;
12
- onReport(success: boolean, message: string, saveBaseData: PublishTaskPlan.ReportTaskQueryBaseInfo): void;
13
+ onReport(success: boolean, code: string, // not-login
14
+ message: string, saveBaseData: PublishTaskPlan.ReportTaskQueryBaseInfo): Promise<boolean>;
13
15
  onTaskGet(): Promise<PublishTaskPlan.TaskDetail>;
14
- onPublishVideo(platform: Global.VideoPlatformKind, platformVideoAccountId: string, taskInfo: PublishTaskPlan.TaskInfo, proxyInfo: Global.ProxyInfo): Promise<PublishNpm.VideoPublishResult>;
16
+ onPublishVideo(platform: Global.VideoPlatformKind, platformVideoAccountId: string, nickname: string, chromeProfileName: string, taskInfo: PublishTaskPlan.TaskInfo, proxyInfo: Global.ProxyInfo): Promise<boolean>;
17
+ onPublishVideoDo(proxyInfo: Global.ProxyInfo, query: {
18
+ platformVideoAccountId: string;
19
+ platform: Global.VideoPlatformKind;
20
+ nickname: string;
21
+ open: boolean;
22
+ chromeProfileName: string;
23
+ taskInfo: PublishTaskPlan.TaskInfo;
24
+ }, settingConfig: VideoPublishAccountManageSetting.Config): Promise<boolean>;
15
25
  }
16
26
  export default PublishTaskPlanClass;