@makarandkate/ezo-connect-wa 6.0.28 → 7.0.1
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/lib/h2i.d.ts +7 -7
- package/lib/h2i.d.ts.map +1 -1
- package/lib/h2i.js +110 -584
- package/lib/h2i.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/h2i.ts +97 -568
package/src/h2i.ts
CHANGED
|
@@ -10,58 +10,24 @@ export class H2I {
|
|
|
10
10
|
type?:'png'|'jpg',
|
|
11
11
|
debug?:boolean
|
|
12
12
|
}):Promise<string> {
|
|
13
|
-
let availableDomains=["md","md","md","md","md","md","md","md","md","md"];
|
|
14
|
-
let domains = Utils.shuffleArray([...availableDomains]);
|
|
15
13
|
return new Promise(async (resolve)=>{
|
|
16
|
-
let url=await this.getImgTryOnce(
|
|
14
|
+
let url=await this.getImgTryOnce(config)
|
|
17
15
|
if(url?.length){
|
|
18
16
|
return resolve(url);
|
|
19
17
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
url=await this.getImgTryOnce((domains[1]+''),config)
|
|
23
|
-
if(url?.length){
|
|
24
|
-
|
|
25
|
-
return resolve(url);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
for(let i=0;i<5;i++){
|
|
29
|
-
await Utils.wait(200);
|
|
30
|
-
url=await this.getImgTryOnce((domains[1]+''),config)
|
|
31
|
-
if(url?.length){
|
|
32
|
-
return resolve(url);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
for(let i=0;i<7;i++){
|
|
36
|
-
|
|
37
|
-
await Utils.wait(500);
|
|
38
|
-
url=await this.getImgTryOnce((domains[1]+''),config)
|
|
39
|
-
if(url?.length){
|
|
40
|
-
return resolve(url);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
for(let i=0;i<10;i++){
|
|
44
|
-
await Utils.wait(1000);
|
|
45
|
-
url=await this.getImgTryOnce((domains[1]+''),config)
|
|
46
|
-
if(url?.length){
|
|
47
|
-
return resolve(url);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
for(let i=0;i<5;i++){
|
|
51
|
-
await Utils.wait(2000);
|
|
52
|
-
url=await this.getImgTryOnce((domains[1]+''),config)
|
|
53
|
-
if(url?.length){
|
|
54
|
-
return resolve(url);
|
|
55
|
-
}
|
|
18
|
+
let retryMap:{[key:number]:number}={
|
|
19
|
+
50:10, 500:10, 1000:10, 2000:10, 5000:10, 20000:5
|
|
56
20
|
}
|
|
57
|
-
for(let
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
21
|
+
for(let k in retryMap){
|
|
22
|
+
for(let i=0;i<Number(retryMap[k]);i++){
|
|
23
|
+
await Utils.wait(Number(k));
|
|
24
|
+
url=await this.getImgTryOnce(config)
|
|
25
|
+
if(url?.length){
|
|
26
|
+
return resolve(url);
|
|
27
|
+
}
|
|
62
28
|
}
|
|
63
29
|
}
|
|
64
|
-
|
|
30
|
+
|
|
65
31
|
return resolve(url);
|
|
66
32
|
|
|
67
33
|
})
|
|
@@ -69,7 +35,7 @@ export class H2I {
|
|
|
69
35
|
}
|
|
70
36
|
|
|
71
37
|
|
|
72
|
-
public static getImgTryOnce(
|
|
38
|
+
public static getImgTryOnce(config: {
|
|
73
39
|
html: string,
|
|
74
40
|
bucketId : number,
|
|
75
41
|
waitTime?:number,
|
|
@@ -81,7 +47,7 @@ export class H2I {
|
|
|
81
47
|
request({
|
|
82
48
|
method: 'POST',
|
|
83
49
|
headers: {'Content-Type': 'application/json'},
|
|
84
|
-
url:`https
|
|
50
|
+
url:`https://md1.ezobooks.in/html2image/${config?.bucketId}`,
|
|
85
51
|
body:JSON.stringify({
|
|
86
52
|
htmlStr:config.html,
|
|
87
53
|
waitTime:config?.waitTime || 0,
|
|
@@ -109,7 +75,7 @@ export class H2I {
|
|
|
109
75
|
try{
|
|
110
76
|
let obj=JSON.parse(res?.body);
|
|
111
77
|
if(obj?.status == 'success' && obj?.image?.length){
|
|
112
|
-
let finalUrl = obj?.image.replace(/md.ezobooks/, 'mdr.ezobooks');
|
|
78
|
+
let finalUrl = obj?.image.replace(/md.ezobooks/, 'mdr.ezobooks')?.replace(/md1.ezobooks/, 'mdr.ezobooks');
|
|
113
79
|
return resolve(finalUrl);
|
|
114
80
|
|
|
115
81
|
}else{
|
|
@@ -138,65 +104,21 @@ export class H2I {
|
|
|
138
104
|
type?:'png'|'jpg',
|
|
139
105
|
debug?:boolean
|
|
140
106
|
}):Promise<string> {
|
|
141
|
-
let availableDomains=["md","md","md","md","md","md","md","md","md","md"];
|
|
142
|
-
let domains = Utils.shuffleArray([...availableDomains]);
|
|
143
107
|
return new Promise(async (resolve)=>{
|
|
144
|
-
let url=await this.getImgFromBase64TryOnce(
|
|
108
|
+
let url=await this.getImgFromBase64TryOnce(config)
|
|
145
109
|
if(url?.length){
|
|
146
110
|
return resolve(url);
|
|
147
111
|
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
await Utils.wait(50);
|
|
151
|
-
url=await this.getImgFromBase64TryOnce((domains[1]+''),config)
|
|
152
|
-
if(url?.length){
|
|
153
|
-
|
|
154
|
-
return resolve(url);
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
for(let i=0;i<5;i++){
|
|
158
|
-
|
|
159
|
-
await Utils.wait(200);
|
|
160
|
-
url=await this.getImgFromBase64TryOnce((domains[1]+''),config)
|
|
161
|
-
if(url?.length){
|
|
162
|
-
|
|
163
|
-
return resolve(url);
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
for(let i=0;i<7;i++){
|
|
167
|
-
|
|
168
|
-
await Utils.wait(500);
|
|
169
|
-
url=await this.getImgFromBase64TryOnce((domains[1]+''),config)
|
|
170
|
-
if(url?.length){
|
|
171
|
-
|
|
172
|
-
return resolve(url);
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
for(let i=0;i<10;i++){
|
|
176
|
-
|
|
177
|
-
await Utils.wait(1000);
|
|
178
|
-
url=await this.getImgFromBase64TryOnce((domains[1]+''),config)
|
|
179
|
-
if(url?.length){
|
|
180
|
-
|
|
181
|
-
return resolve(url);
|
|
182
|
-
}
|
|
112
|
+
let retryMap:{[key:number]:number}={
|
|
113
|
+
50:10, 500:10, 1000:10, 2000:10, 5000:10, 20000:5
|
|
183
114
|
}
|
|
184
|
-
for(let
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
for(let i=0;i<5;i++){
|
|
194
|
-
|
|
195
|
-
await Utils.wait(20000);
|
|
196
|
-
url=await this.getImgFromBase64TryOnce((domains[1]+''),config)
|
|
197
|
-
if(url?.length){
|
|
198
|
-
|
|
199
|
-
return resolve(url);
|
|
115
|
+
for(let k in retryMap){
|
|
116
|
+
for(let i=0;i<Number(retryMap[k]);i++){
|
|
117
|
+
await Utils.wait(Number(k));
|
|
118
|
+
url=await this.getImgFromBase64TryOnce(config)
|
|
119
|
+
if(url?.length){
|
|
120
|
+
return resolve(url);
|
|
121
|
+
}
|
|
200
122
|
}
|
|
201
123
|
}
|
|
202
124
|
|
|
@@ -207,7 +129,7 @@ export class H2I {
|
|
|
207
129
|
}
|
|
208
130
|
|
|
209
131
|
|
|
210
|
-
public static getImgFromBase64TryOnce(
|
|
132
|
+
public static getImgFromBase64TryOnce(config: {
|
|
211
133
|
base64Str: string,
|
|
212
134
|
bucketId : number,
|
|
213
135
|
type?:'png'|'jpg',
|
|
@@ -217,7 +139,7 @@ export class H2I {
|
|
|
217
139
|
request({
|
|
218
140
|
method: 'POST',
|
|
219
141
|
headers: {'Content-Type': 'application/json'},
|
|
220
|
-
url:`https
|
|
142
|
+
url:`https://md1.ezobooks.in/base642image/${config?.bucketId}`,
|
|
221
143
|
body:JSON.stringify({
|
|
222
144
|
base64Str:config.base64Str,
|
|
223
145
|
type:config?.type || 'png',
|
|
@@ -243,7 +165,7 @@ export class H2I {
|
|
|
243
165
|
try{
|
|
244
166
|
let obj=JSON.parse(res?.body);
|
|
245
167
|
if(obj?.status == 'success' && obj?.image?.length){
|
|
246
|
-
let finalUrl = obj?.image.replace(/md.ezobooks/, 'mdr.ezobooks');
|
|
168
|
+
let finalUrl = obj?.image.replace(/md.ezobooks/, 'mdr.ezobooks')?.replace(/md1.ezobooks/, 'mdr.ezobooks');
|
|
247
169
|
return resolve(finalUrl);
|
|
248
170
|
|
|
249
171
|
}else{
|
|
@@ -272,155 +194,22 @@ export class H2I {
|
|
|
272
194
|
waitTime?:number,
|
|
273
195
|
debug?:boolean
|
|
274
196
|
}):Promise<string> {
|
|
275
|
-
let availableDomains=["md","md","md","md","md","md","md","md","md","md"];
|
|
276
|
-
let domains = Utils.shuffleArray([...availableDomains]);
|
|
277
197
|
return new Promise(async (resolve)=>{
|
|
278
|
-
let url=await this.getPdfTryOnce(
|
|
279
|
-
if(url?.length){
|
|
280
|
-
return resolve(url);
|
|
281
|
-
}
|
|
282
|
-
await Utils.wait(50);
|
|
283
|
-
url=await this.getPdfTryOnce((domains[1]+''),config)
|
|
284
|
-
if(url?.length){
|
|
285
|
-
return resolve(url);
|
|
286
|
-
}
|
|
287
|
-
await Utils.wait(100);
|
|
288
|
-
url=await this.getPdfTryOnce((domains[2]+''),config)
|
|
289
|
-
if(url?.length){
|
|
290
|
-
return resolve(url);
|
|
291
|
-
}
|
|
292
|
-
await Utils.wait(200);
|
|
293
|
-
url=await this.getPdfTryOnce((domains[3]+''),config)
|
|
294
|
-
if(url?.length){
|
|
295
|
-
return resolve(url);
|
|
296
|
-
}
|
|
297
|
-
await Utils.wait(300);
|
|
298
|
-
url=await this.getPdfTryOnce((domains[4]+''),config)
|
|
299
|
-
if(url?.length){
|
|
300
|
-
return resolve(url);
|
|
301
|
-
}
|
|
302
|
-
await Utils.wait(300);
|
|
303
|
-
url=await this.getPdfTryOnce((domains[5]+''),config)
|
|
304
|
-
if(url?.length){
|
|
305
|
-
return resolve(url);
|
|
306
|
-
}
|
|
307
|
-
await Utils.wait(300);
|
|
308
|
-
url=await this.getPdfTryOnce((domains[6]+''),config)
|
|
309
|
-
if(url?.length){
|
|
310
|
-
return resolve(url);
|
|
311
|
-
}
|
|
312
|
-
await Utils.wait(300);
|
|
313
|
-
url=await this.getPdfTryOnce((domains[7]+''),config)
|
|
314
|
-
if(url?.length){
|
|
315
|
-
return resolve(url);
|
|
316
|
-
}
|
|
317
|
-
await Utils.wait(300);
|
|
318
|
-
url=await this.getPdfTryOnce((domains[8]+''),config)
|
|
319
|
-
if(url?.length){
|
|
320
|
-
return resolve(url);
|
|
321
|
-
}
|
|
322
|
-
await Utils.wait(300);
|
|
323
|
-
url=await this.getPdfTryOnce((domains[9]+''),config)
|
|
324
|
-
if(url?.length){
|
|
325
|
-
return resolve(url);
|
|
326
|
-
}
|
|
327
|
-
await Utils.wait(300);
|
|
328
|
-
url=await this.getPdfTryOnce((domains[10]+''),config)
|
|
329
|
-
if(url?.length){
|
|
330
|
-
return resolve(url);
|
|
331
|
-
}await Utils.wait(300);
|
|
332
|
-
url=await this.getPdfTryOnce((domains[10]+''),config)
|
|
333
|
-
if(url?.length){
|
|
334
|
-
return resolve(url);
|
|
335
|
-
}await Utils.wait(300);
|
|
336
|
-
url=await this.getPdfTryOnce((domains[10]+''),config)
|
|
337
|
-
if(url?.length){
|
|
338
|
-
return resolve(url);
|
|
339
|
-
}await Utils.wait(300);
|
|
340
|
-
url=await this.getPdfTryOnce((domains[10]+''),config)
|
|
341
|
-
if(url?.length){
|
|
342
|
-
return resolve(url);
|
|
343
|
-
}await Utils.wait(300);
|
|
344
|
-
url=await this.getPdfTryOnce((domains[10]+''),config)
|
|
345
|
-
if(url?.length){
|
|
346
|
-
return resolve(url);
|
|
347
|
-
}await Utils.wait(300);
|
|
348
|
-
url=await this.getPdfTryOnce((domains[10]+''),config)
|
|
349
|
-
if(url?.length){
|
|
350
|
-
return resolve(url);
|
|
351
|
-
}await Utils.wait(300);
|
|
352
|
-
url=await this.getPdfTryOnce((domains[10]+''),config)
|
|
353
|
-
if(url?.length){
|
|
354
|
-
return resolve(url);
|
|
355
|
-
}
|
|
356
|
-
await Utils.wait(1000);
|
|
357
|
-
url=await this.getPdfTryOnce((domains[0]+''),config)
|
|
358
|
-
if(url?.length){
|
|
359
|
-
return resolve(url);
|
|
360
|
-
}await Utils.wait(1000);
|
|
361
|
-
url=await this.getPdfTryOnce((domains[0]+''),config)
|
|
362
|
-
if(url?.length){
|
|
363
|
-
return resolve(url);
|
|
364
|
-
}await Utils.wait(1000);
|
|
365
|
-
url=await this.getPdfTryOnce((domains[0]+''),config)
|
|
366
|
-
if(url?.length){
|
|
367
|
-
return resolve(url);
|
|
368
|
-
}await Utils.wait(1000);
|
|
369
|
-
url=await this.getPdfTryOnce((domains[0]+''),config)
|
|
370
|
-
if(url?.length){
|
|
371
|
-
return resolve(url);
|
|
372
|
-
}await Utils.wait(1000);
|
|
373
|
-
url=await this.getPdfTryOnce((domains[0]+''),config)
|
|
374
|
-
if(url?.length){
|
|
375
|
-
return resolve(url);
|
|
376
|
-
}await Utils.wait(1000);
|
|
377
|
-
url=await this.getPdfTryOnce((domains[0]+''),config)
|
|
378
|
-
if(url?.length){
|
|
379
|
-
return resolve(url);
|
|
380
|
-
}await Utils.wait(1000);
|
|
381
|
-
url=await this.getPdfTryOnce((domains[0]+''),config)
|
|
382
|
-
if(url?.length){
|
|
383
|
-
return resolve(url);
|
|
384
|
-
}await Utils.wait(1000);
|
|
385
|
-
url=await this.getPdfTryOnce((domains[0]+''),config)
|
|
386
|
-
if(url?.length){
|
|
387
|
-
return resolve(url);
|
|
388
|
-
}await Utils.wait(1000);
|
|
389
|
-
url=await this.getPdfTryOnce((domains[0]+''),config)
|
|
390
|
-
if(url?.length){
|
|
391
|
-
return resolve(url);
|
|
392
|
-
}await Utils.wait(1000);
|
|
393
|
-
url=await this.getPdfTryOnce((domains[0]+''),config)
|
|
394
|
-
if(url?.length){
|
|
395
|
-
return resolve(url);
|
|
396
|
-
}await Utils.wait(1000);
|
|
397
|
-
url=await this.getPdfTryOnce((domains[0]+''),config)
|
|
398
|
-
if(url?.length){
|
|
399
|
-
return resolve(url);
|
|
400
|
-
}await Utils.wait(1000);
|
|
401
|
-
url=await this.getPdfTryOnce((domains[0]+''),config)
|
|
402
|
-
if(url?.length){
|
|
403
|
-
return resolve(url);
|
|
404
|
-
}
|
|
405
|
-
await Utils.wait(2000);
|
|
406
|
-
url=await this.getPdfTryOnce((domains[1]+''),config)
|
|
407
|
-
if(url?.length){
|
|
408
|
-
return resolve(url);
|
|
409
|
-
}
|
|
410
|
-
await Utils.wait(4000);
|
|
411
|
-
url=await this.getPdfTryOnce((domains[2]+''),config)
|
|
198
|
+
let url=await this.getPdfTryOnce(config)
|
|
412
199
|
if(url?.length){
|
|
413
200
|
return resolve(url);
|
|
414
201
|
}
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
if(url?.length){
|
|
418
|
-
return resolve(url);
|
|
202
|
+
let retryMap:{[key:number]:number}={
|
|
203
|
+
50:10, 500:10, 1000:10, 2000:10, 5000:10, 20000:5
|
|
419
204
|
}
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
205
|
+
for(let k in retryMap){
|
|
206
|
+
for(let i=0;i<Number(retryMap[k]);i++){
|
|
207
|
+
await Utils.wait(Number(k));
|
|
208
|
+
url=await this.getPdfTryOnce(config)
|
|
209
|
+
if(url?.length){
|
|
210
|
+
return resolve(url);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
424
213
|
}
|
|
425
214
|
|
|
426
215
|
return resolve(url);
|
|
@@ -429,7 +218,7 @@ export class H2I {
|
|
|
429
218
|
|
|
430
219
|
}
|
|
431
220
|
|
|
432
|
-
public static getPdfTryOnce(
|
|
221
|
+
public static getPdfTryOnce(config: {
|
|
433
222
|
html: string,
|
|
434
223
|
bucketId : number,
|
|
435
224
|
waitTime?:number,
|
|
@@ -439,7 +228,7 @@ export class H2I {
|
|
|
439
228
|
request({
|
|
440
229
|
method: 'POST',
|
|
441
230
|
headers: {'Content-Type': 'application/json'},
|
|
442
|
-
url:`https
|
|
231
|
+
url:`https://md1.ezobooks.in/html2pdf/${config.bucketId}`,
|
|
443
232
|
body:JSON.stringify({
|
|
444
233
|
htmlStr:config.html,
|
|
445
234
|
waitTime:config?.waitTime || 0
|
|
@@ -456,7 +245,7 @@ export class H2I {
|
|
|
456
245
|
try{
|
|
457
246
|
let obj=JSON.parse(res?.body);
|
|
458
247
|
if(obj?.status == 'success' && obj?.image?.length){
|
|
459
|
-
let finalUrl = obj?.image.replace(/md.ezobooks/, 'mdr.ezobooks');
|
|
248
|
+
let finalUrl = obj?.image.replace(/md.ezobooks/, 'mdr.ezobooks')?.replace(/md1.ezobooks/, 'mdr.ezobooks');
|
|
460
249
|
return resolve(finalUrl);
|
|
461
250
|
|
|
462
251
|
}else{
|
|
@@ -486,87 +275,22 @@ export class H2I {
|
|
|
486
275
|
requestId:string,
|
|
487
276
|
debug?:boolean
|
|
488
277
|
}):Promise<string> {
|
|
489
|
-
let availableDomains=["md","md","md","md","md","md","md","md","md","md"];
|
|
490
|
-
let domains = Utils.shuffleArray([...availableDomains]);
|
|
491
278
|
return new Promise(async (resolve)=>{
|
|
492
|
-
let url=await this.getVidTryOnce(
|
|
493
|
-
if(url?.length){
|
|
494
|
-
return resolve(url);
|
|
495
|
-
}
|
|
496
|
-
await Utils.wait(50);
|
|
497
|
-
url=await this.getVidTryOnce((domains[1]+''),config)
|
|
498
|
-
if(url?.length){
|
|
499
|
-
return resolve(url);
|
|
500
|
-
}
|
|
501
|
-
await Utils.wait(100);
|
|
502
|
-
url=await this.getVidTryOnce((domains[2]+''),config)
|
|
503
|
-
if(url?.length){
|
|
504
|
-
return resolve(url);
|
|
505
|
-
}
|
|
506
|
-
await Utils.wait(200);
|
|
507
|
-
url=await this.getVidTryOnce((domains[3]+''),config)
|
|
508
|
-
if(url?.length){
|
|
509
|
-
return resolve(url);
|
|
510
|
-
}
|
|
511
|
-
await Utils.wait(300);
|
|
512
|
-
url=await this.getVidTryOnce((domains[4]+''),config)
|
|
513
|
-
if(url?.length){
|
|
514
|
-
return resolve(url);
|
|
515
|
-
}
|
|
516
|
-
await Utils.wait(300);
|
|
517
|
-
url=await this.getVidTryOnce((domains[5]+''),config)
|
|
518
|
-
if(url?.length){
|
|
519
|
-
return resolve(url);
|
|
520
|
-
}
|
|
521
|
-
await Utils.wait(300);
|
|
522
|
-
url=await this.getVidTryOnce((domains[6]+''),config)
|
|
523
|
-
if(url?.length){
|
|
524
|
-
return resolve(url);
|
|
525
|
-
}
|
|
526
|
-
await Utils.wait(300);
|
|
527
|
-
url=await this.getVidTryOnce((domains[7]+''),config)
|
|
528
|
-
if(url?.length){
|
|
529
|
-
return resolve(url);
|
|
530
|
-
}
|
|
531
|
-
await Utils.wait(300);
|
|
532
|
-
url=await this.getVidTryOnce((domains[8]+''),config)
|
|
533
|
-
if(url?.length){
|
|
534
|
-
return resolve(url);
|
|
535
|
-
}
|
|
536
|
-
await Utils.wait(300);
|
|
537
|
-
url=await this.getVidTryOnce((domains[9]+''),config)
|
|
538
|
-
if(url?.length){
|
|
539
|
-
return resolve(url);
|
|
540
|
-
}
|
|
541
|
-
await Utils.wait(300);
|
|
542
|
-
url=await this.getVidTryOnce((domains[10]+''),config)
|
|
279
|
+
let url=await this.getVidTryOnce(config)
|
|
543
280
|
if(url?.length){
|
|
544
281
|
return resolve(url);
|
|
545
282
|
}
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
if(url?.length){
|
|
549
|
-
return resolve(url);
|
|
283
|
+
let retryMap:{[key:number]:number}={
|
|
284
|
+
50:10, 500:10, 1000:10, 2000:10, 5000:10, 20000:5
|
|
550
285
|
}
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
return resolve(url);
|
|
560
|
-
}
|
|
561
|
-
await Utils.wait(7000);
|
|
562
|
-
url=await this.getVidTryOnce((domains[3]+''),config)
|
|
563
|
-
if(url?.length){
|
|
564
|
-
return resolve(url);
|
|
565
|
-
}
|
|
566
|
-
await Utils.wait(11000);
|
|
567
|
-
url=await this.getVidTryOnce((domains[4]+''),config)
|
|
568
|
-
if(url?.length){
|
|
569
|
-
return resolve(url);
|
|
286
|
+
for(let k in retryMap){
|
|
287
|
+
for(let i=0;i<Number(retryMap[k]);i++){
|
|
288
|
+
await Utils.wait(Number(k));
|
|
289
|
+
url=await this.getVidTryOnce(config)
|
|
290
|
+
if(url?.length){
|
|
291
|
+
return resolve(url);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
570
294
|
}
|
|
571
295
|
|
|
572
296
|
return resolve(url);
|
|
@@ -575,7 +299,7 @@ export class H2I {
|
|
|
575
299
|
|
|
576
300
|
}
|
|
577
301
|
|
|
578
|
-
public static getVidTryOnce(
|
|
302
|
+
public static getVidTryOnce(config: {
|
|
579
303
|
videoUrl: string,
|
|
580
304
|
frameUrl:string,
|
|
581
305
|
contactImageUrl:string,
|
|
@@ -586,7 +310,7 @@ export class H2I {
|
|
|
586
310
|
request({
|
|
587
311
|
method: 'POST',
|
|
588
312
|
headers: {'Content-Type': 'application/json'},
|
|
589
|
-
url:`https
|
|
313
|
+
url:`https://md1.ezobooks.in/vd/compile`,
|
|
590
314
|
body:JSON.stringify({
|
|
591
315
|
videoUrl:config.videoUrl,
|
|
592
316
|
frameUrl:config.frameUrl,
|
|
@@ -602,7 +326,7 @@ export class H2I {
|
|
|
602
326
|
try{
|
|
603
327
|
let obj=JSON.parse(res?.body);
|
|
604
328
|
if(obj?.status == 'success' && obj?.url?.length){
|
|
605
|
-
let finalUrl = obj?.url?.replace(/md.ezobooks/, 'mdr.ezobooks');
|
|
329
|
+
let finalUrl = obj?.url?.replace(/md.ezobooks/, 'mdr.ezobooks')?.replace(/md1.ezobooks/, 'mdr.ezobooks');
|
|
606
330
|
return resolve(finalUrl);
|
|
607
331
|
|
|
608
332
|
}else{
|
|
@@ -633,87 +357,22 @@ export class H2I {
|
|
|
633
357
|
requestId:string,
|
|
634
358
|
debug?:boolean
|
|
635
359
|
}):Promise<string> {
|
|
636
|
-
let availableDomains=["md","md","md","md","md","md","md","md","md","md"];
|
|
637
|
-
let domains = Utils.shuffleArray([...availableDomains]);
|
|
638
360
|
return new Promise(async (resolve)=>{
|
|
639
|
-
let url=await this.getReelTryOnce(
|
|
640
|
-
if(url?.length){
|
|
641
|
-
return resolve(url);
|
|
642
|
-
}
|
|
643
|
-
await Utils.wait(50);
|
|
644
|
-
url=await this.getReelTryOnce((domains[1]+''),config)
|
|
645
|
-
if(url?.length){
|
|
646
|
-
return resolve(url);
|
|
647
|
-
}
|
|
648
|
-
await Utils.wait(100);
|
|
649
|
-
url=await this.getReelTryOnce((domains[2]+''),config)
|
|
650
|
-
if(url?.length){
|
|
651
|
-
return resolve(url);
|
|
652
|
-
}
|
|
653
|
-
await Utils.wait(200);
|
|
654
|
-
url=await this.getReelTryOnce((domains[3]+''),config)
|
|
655
|
-
if(url?.length){
|
|
656
|
-
return resolve(url);
|
|
657
|
-
}
|
|
658
|
-
await Utils.wait(300);
|
|
659
|
-
url=await this.getReelTryOnce((domains[4]+''),config)
|
|
660
|
-
if(url?.length){
|
|
661
|
-
return resolve(url);
|
|
662
|
-
}
|
|
663
|
-
await Utils.wait(300);
|
|
664
|
-
url=await this.getReelTryOnce((domains[5]+''),config)
|
|
665
|
-
if(url?.length){
|
|
666
|
-
return resolve(url);
|
|
667
|
-
}
|
|
668
|
-
await Utils.wait(300);
|
|
669
|
-
url=await this.getReelTryOnce((domains[6]+''),config)
|
|
670
|
-
if(url?.length){
|
|
671
|
-
return resolve(url);
|
|
672
|
-
}
|
|
673
|
-
await Utils.wait(300);
|
|
674
|
-
url=await this.getReelTryOnce((domains[7]+''),config)
|
|
675
|
-
if(url?.length){
|
|
676
|
-
return resolve(url);
|
|
677
|
-
}
|
|
678
|
-
await Utils.wait(300);
|
|
679
|
-
url=await this.getReelTryOnce((domains[8]+''),config)
|
|
680
|
-
if(url?.length){
|
|
681
|
-
return resolve(url);
|
|
682
|
-
}
|
|
683
|
-
await Utils.wait(300);
|
|
684
|
-
url=await this.getReelTryOnce((domains[9]+''),config)
|
|
685
|
-
if(url?.length){
|
|
686
|
-
return resolve(url);
|
|
687
|
-
}
|
|
688
|
-
await Utils.wait(300);
|
|
689
|
-
url=await this.getReelTryOnce((domains[10]+''),config)
|
|
690
|
-
if(url?.length){
|
|
691
|
-
return resolve(url);
|
|
692
|
-
}
|
|
693
|
-
await Utils.wait(1000);
|
|
694
|
-
url=await this.getReelTryOnce((domains[0]+''),config)
|
|
695
|
-
if(url?.length){
|
|
696
|
-
return resolve(url);
|
|
697
|
-
}
|
|
698
|
-
await Utils.wait(2000);
|
|
699
|
-
url=await this.getReelTryOnce((domains[1]+''),config)
|
|
700
|
-
if(url?.length){
|
|
701
|
-
return resolve(url);
|
|
702
|
-
}
|
|
703
|
-
await Utils.wait(4000);
|
|
704
|
-
url=await this.getReelTryOnce((domains[2]+''),config)
|
|
361
|
+
let url=await this.getReelTryOnce(config)
|
|
705
362
|
if(url?.length){
|
|
706
363
|
return resolve(url);
|
|
707
364
|
}
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
if(url?.length){
|
|
711
|
-
return resolve(url);
|
|
365
|
+
let retryMap:{[key:number]:number}={
|
|
366
|
+
50:10, 500:10, 1000:10, 2000:10, 5000:10, 20000:5
|
|
712
367
|
}
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
368
|
+
for(let k in retryMap){
|
|
369
|
+
for(let i=0;i<Number(retryMap[k]);i++){
|
|
370
|
+
await Utils.wait(Number(k));
|
|
371
|
+
url=await this.getReelTryOnce(config)
|
|
372
|
+
if(url?.length){
|
|
373
|
+
return resolve(url);
|
|
374
|
+
}
|
|
375
|
+
}
|
|
717
376
|
}
|
|
718
377
|
|
|
719
378
|
return resolve(url);
|
|
@@ -722,7 +381,7 @@ export class H2I {
|
|
|
722
381
|
|
|
723
382
|
}
|
|
724
383
|
|
|
725
|
-
public static getReelTryOnce(
|
|
384
|
+
public static getReelTryOnce(config: {
|
|
726
385
|
productVideoUrl: string,
|
|
727
386
|
modelVideoUrl:string,
|
|
728
387
|
infoImageUrl:string,
|
|
@@ -733,7 +392,7 @@ export class H2I {
|
|
|
733
392
|
request({
|
|
734
393
|
method: 'POST',
|
|
735
394
|
headers: {'Content-Type': 'application/json'},
|
|
736
|
-
url:`https
|
|
395
|
+
url:`https://md1.ezobooks.in/vd/composeReel`,
|
|
737
396
|
body:JSON.stringify({
|
|
738
397
|
productVideoUrl:config.productVideoUrl,
|
|
739
398
|
modelVideoUrl:config.modelVideoUrl,
|
|
@@ -749,7 +408,7 @@ export class H2I {
|
|
|
749
408
|
try{
|
|
750
409
|
let obj=JSON.parse(res?.body);
|
|
751
410
|
if(obj?.status == 'success' && obj?.url?.length){
|
|
752
|
-
let finalUrl = obj?.url?.replace(/md.ezobooks/, 'mdr.ezobooks');
|
|
411
|
+
let finalUrl = obj?.url?.replace(/md.ezobooks/, 'mdr.ezobooks')?.replace(/md1.ezobooks/, 'mdr.ezobooks');
|
|
753
412
|
return resolve(finalUrl);
|
|
754
413
|
|
|
755
414
|
}else{
|
|
@@ -780,87 +439,22 @@ export class H2I {
|
|
|
780
439
|
epilogue:string,
|
|
781
440
|
debug?:boolean
|
|
782
441
|
}):Promise<string> {
|
|
783
|
-
let availableDomains=["md","md","md","md","md","md","md","md","md","md"];
|
|
784
|
-
let domains = Utils.shuffleArray([...availableDomains]);
|
|
785
442
|
return new Promise(async (resolve)=>{
|
|
786
|
-
let url=await this.getSceneVidTryOnce(
|
|
787
|
-
if(url?.length){
|
|
788
|
-
return resolve(url);
|
|
789
|
-
}
|
|
790
|
-
await Utils.wait(50);
|
|
791
|
-
url=await this.getSceneVidTryOnce((domains[1]+''),config)
|
|
792
|
-
if(url?.length){
|
|
793
|
-
return resolve(url);
|
|
794
|
-
}
|
|
795
|
-
await Utils.wait(100);
|
|
796
|
-
url=await this.getSceneVidTryOnce((domains[2]+''),config)
|
|
797
|
-
if(url?.length){
|
|
798
|
-
return resolve(url);
|
|
799
|
-
}
|
|
800
|
-
await Utils.wait(200);
|
|
801
|
-
url=await this.getSceneVidTryOnce((domains[3]+''),config)
|
|
802
|
-
if(url?.length){
|
|
803
|
-
return resolve(url);
|
|
804
|
-
}
|
|
805
|
-
await Utils.wait(300);
|
|
806
|
-
url=await this.getSceneVidTryOnce((domains[4]+''),config)
|
|
443
|
+
let url=await this.getSceneVidTryOnce(config)
|
|
807
444
|
if(url?.length){
|
|
808
445
|
return resolve(url);
|
|
809
446
|
}
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
if(url?.length){
|
|
813
|
-
return resolve(url);
|
|
447
|
+
let retryMap:{[key:number]:number}={
|
|
448
|
+
50:10, 500:10, 1000:10, 2000:10, 5000:10, 20000:5
|
|
814
449
|
}
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
return resolve(url);
|
|
824
|
-
}
|
|
825
|
-
await Utils.wait(300);
|
|
826
|
-
url=await this.getSceneVidTryOnce((domains[8]+''),config)
|
|
827
|
-
if(url?.length){
|
|
828
|
-
return resolve(url);
|
|
829
|
-
}
|
|
830
|
-
await Utils.wait(300);
|
|
831
|
-
url=await this.getSceneVidTryOnce((domains[9]+''),config)
|
|
832
|
-
if(url?.length){
|
|
833
|
-
return resolve(url);
|
|
834
|
-
}
|
|
835
|
-
await Utils.wait(300);
|
|
836
|
-
url=await this.getSceneVidTryOnce((domains[10]+''),config)
|
|
837
|
-
if(url?.length){
|
|
838
|
-
return resolve(url);
|
|
839
|
-
}
|
|
840
|
-
await Utils.wait(1000);
|
|
841
|
-
url=await this.getSceneVidTryOnce((domains[0]+''),config)
|
|
842
|
-
if(url?.length){
|
|
843
|
-
return resolve(url);
|
|
844
|
-
}
|
|
845
|
-
await Utils.wait(2000);
|
|
846
|
-
url=await this.getSceneVidTryOnce((domains[1]+''),config)
|
|
847
|
-
if(url?.length){
|
|
848
|
-
return resolve(url);
|
|
849
|
-
}
|
|
850
|
-
await Utils.wait(4000);
|
|
851
|
-
url=await this.getSceneVidTryOnce((domains[2]+''),config)
|
|
852
|
-
if(url?.length){
|
|
853
|
-
return resolve(url);
|
|
854
|
-
}
|
|
855
|
-
await Utils.wait(7000);
|
|
856
|
-
url=await this.getSceneVidTryOnce((domains[3]+''),config)
|
|
857
|
-
if(url?.length){
|
|
858
|
-
return resolve(url);
|
|
859
|
-
}
|
|
860
|
-
await Utils.wait(11000);
|
|
861
|
-
url=await this.getSceneVidTryOnce((domains[4]+''),config)
|
|
862
|
-
if(url?.length){
|
|
863
|
-
return resolve(url);
|
|
450
|
+
for(let k in retryMap){
|
|
451
|
+
for(let i=0;i<Number(retryMap[k]);i++){
|
|
452
|
+
await Utils.wait(Number(k));
|
|
453
|
+
url=await this.getSceneVidTryOnce(config)
|
|
454
|
+
if(url?.length){
|
|
455
|
+
return resolve(url);
|
|
456
|
+
}
|
|
457
|
+
}
|
|
864
458
|
}
|
|
865
459
|
|
|
866
460
|
return resolve(url);
|
|
@@ -869,7 +463,7 @@ export class H2I {
|
|
|
869
463
|
|
|
870
464
|
}
|
|
871
465
|
|
|
872
|
-
public static getSceneVidTryOnce(
|
|
466
|
+
public static getSceneVidTryOnce(config: {
|
|
873
467
|
requestId:string,
|
|
874
468
|
videos: string[],
|
|
875
469
|
overlayImage:string,
|
|
@@ -880,7 +474,7 @@ export class H2I {
|
|
|
880
474
|
request({
|
|
881
475
|
method: 'POST',
|
|
882
476
|
headers: {'Content-Type': 'application/json'},
|
|
883
|
-
url:`https
|
|
477
|
+
url:`https://md1.ezobooks.in/vd/composeScene`,
|
|
884
478
|
body:JSON.stringify({
|
|
885
479
|
requestId:config.requestId,
|
|
886
480
|
videos:config.videos,
|
|
@@ -896,7 +490,7 @@ export class H2I {
|
|
|
896
490
|
try{
|
|
897
491
|
let obj=JSON.parse(res?.body);
|
|
898
492
|
if(obj?.status == 'success' && obj?.url?.length){
|
|
899
|
-
let finalUrl = obj?.url?.replace(/md.ezobooks/, 'mdr.ezobooks');
|
|
493
|
+
let finalUrl = obj?.url?.replace(/md.ezobooks/, 'mdr.ezobooks')?.replace(/md1.ezobooks/, 'mdr.ezobooks');
|
|
900
494
|
return resolve(finalUrl);
|
|
901
495
|
|
|
902
496
|
}else{
|
|
@@ -927,87 +521,22 @@ export class H2I {
|
|
|
927
521
|
}
|
|
928
522
|
debug?:boolean
|
|
929
523
|
}):Promise<string> {
|
|
930
|
-
let availableDomains=["md","md","md","md","md","md","md","md","md","md"];
|
|
931
|
-
let domains = Utils.shuffleArray([...availableDomains]);
|
|
932
524
|
return new Promise(async (resolve)=>{
|
|
933
|
-
let url=await this.compileVideoByCommandTryOnce(
|
|
934
|
-
if(url?.length){
|
|
935
|
-
return resolve(url);
|
|
936
|
-
}
|
|
937
|
-
await Utils.wait(50);
|
|
938
|
-
url=await this.compileVideoByCommandTryOnce((domains[1]+''),config)
|
|
525
|
+
let url=await this.compileVideoByCommandTryOnce(config)
|
|
939
526
|
if(url?.length){
|
|
940
527
|
return resolve(url);
|
|
941
528
|
}
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
if(url?.length){
|
|
945
|
-
return resolve(url);
|
|
529
|
+
let retryMap:{[key:number]:number}={
|
|
530
|
+
50:10, 500:10, 1000:10, 2000:10, 5000:10, 20000:5
|
|
946
531
|
}
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
return resolve(url);
|
|
956
|
-
}
|
|
957
|
-
await Utils.wait(300);
|
|
958
|
-
url=await this.compileVideoByCommandTryOnce((domains[5]+''),config)
|
|
959
|
-
if(url?.length){
|
|
960
|
-
return resolve(url);
|
|
961
|
-
}
|
|
962
|
-
await Utils.wait(300);
|
|
963
|
-
url=await this.compileVideoByCommandTryOnce((domains[6]+''),config)
|
|
964
|
-
if(url?.length){
|
|
965
|
-
return resolve(url);
|
|
966
|
-
}
|
|
967
|
-
await Utils.wait(300);
|
|
968
|
-
url=await this.compileVideoByCommandTryOnce((domains[7]+''),config)
|
|
969
|
-
if(url?.length){
|
|
970
|
-
return resolve(url);
|
|
971
|
-
}
|
|
972
|
-
await Utils.wait(300);
|
|
973
|
-
url=await this.compileVideoByCommandTryOnce((domains[8]+''),config)
|
|
974
|
-
if(url?.length){
|
|
975
|
-
return resolve(url);
|
|
976
|
-
}
|
|
977
|
-
await Utils.wait(300);
|
|
978
|
-
url=await this.compileVideoByCommandTryOnce((domains[9]+''),config)
|
|
979
|
-
if(url?.length){
|
|
980
|
-
return resolve(url);
|
|
981
|
-
}
|
|
982
|
-
await Utils.wait(300);
|
|
983
|
-
url=await this.compileVideoByCommandTryOnce((domains[10]+''),config)
|
|
984
|
-
if(url?.length){
|
|
985
|
-
return resolve(url);
|
|
986
|
-
}
|
|
987
|
-
await Utils.wait(1000);
|
|
988
|
-
url=await this.compileVideoByCommandTryOnce((domains[0]+''),config)
|
|
989
|
-
if(url?.length){
|
|
990
|
-
return resolve(url);
|
|
991
|
-
}
|
|
992
|
-
await Utils.wait(2000);
|
|
993
|
-
url=await this.compileVideoByCommandTryOnce((domains[1]+''),config)
|
|
994
|
-
if(url?.length){
|
|
995
|
-
return resolve(url);
|
|
996
|
-
}
|
|
997
|
-
await Utils.wait(4000);
|
|
998
|
-
url=await this.compileVideoByCommandTryOnce((domains[2]+''),config)
|
|
999
|
-
if(url?.length){
|
|
1000
|
-
return resolve(url);
|
|
1001
|
-
}
|
|
1002
|
-
await Utils.wait(7000);
|
|
1003
|
-
url=await this.compileVideoByCommandTryOnce((domains[3]+''),config)
|
|
1004
|
-
if(url?.length){
|
|
1005
|
-
return resolve(url);
|
|
1006
|
-
}
|
|
1007
|
-
await Utils.wait(11000);
|
|
1008
|
-
url=await this.compileVideoByCommandTryOnce((domains[4]+''),config)
|
|
1009
|
-
if(url?.length){
|
|
1010
|
-
return resolve(url);
|
|
532
|
+
for(let k in retryMap){
|
|
533
|
+
for(let i=0;i<Number(retryMap[k]);i++){
|
|
534
|
+
await Utils.wait(Number(k));
|
|
535
|
+
url=await this.compileVideoByCommandTryOnce(config)
|
|
536
|
+
if(url?.length){
|
|
537
|
+
return resolve(url);
|
|
538
|
+
}
|
|
539
|
+
}
|
|
1011
540
|
}
|
|
1012
541
|
|
|
1013
542
|
return resolve(url);
|
|
@@ -1016,7 +545,7 @@ export class H2I {
|
|
|
1016
545
|
|
|
1017
546
|
}
|
|
1018
547
|
|
|
1019
|
-
public static compileVideoByCommandTryOnce(
|
|
548
|
+
public static compileVideoByCommandTryOnce(config: {
|
|
1020
549
|
requestId:string,
|
|
1021
550
|
ffmpegCommand: string,
|
|
1022
551
|
mediaMap: {
|
|
@@ -1028,7 +557,7 @@ export class H2I {
|
|
|
1028
557
|
request({
|
|
1029
558
|
method: 'POST',
|
|
1030
559
|
headers: {'Content-Type': 'application/json'},
|
|
1031
|
-
url:`https
|
|
560
|
+
url:`https://md1.ezobooks.in/vd/compileVideoCommand`,
|
|
1032
561
|
body:JSON.stringify({
|
|
1033
562
|
requestId:config.requestId,
|
|
1034
563
|
ffmpegCommand:config.ffmpegCommand,
|
|
@@ -1043,7 +572,7 @@ export class H2I {
|
|
|
1043
572
|
try{
|
|
1044
573
|
let obj=JSON.parse(res?.body);
|
|
1045
574
|
if(obj?.status == 'success' && obj?.url?.length){
|
|
1046
|
-
let finalUrl = obj?.url?.replace(/md.ezobooks/, 'mdr.ezobooks');
|
|
575
|
+
let finalUrl = obj?.url?.replace(/md.ezobooks/, 'mdr.ezobooks')?.replace(/md1.ezobooks/, 'mdr.ezobooks');
|
|
1047
576
|
return resolve(finalUrl);
|
|
1048
577
|
|
|
1049
578
|
}else{
|