@makarandkate/ezo-connect-wa 6.0.27 → 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/src/h2i.ts CHANGED
@@ -10,72 +10,23 @@ export class H2I {
10
10
  type?:'png'|'jpg',
11
11
  debug?:boolean
12
12
  }):Promise<string> {
13
- let tryCount=0;
14
- let availableDomains=["md","md","md","md","md","md","md","md","md","md"];
15
- let domains = Utils.shuffleArray([...availableDomains]);
16
13
  return new Promise(async (resolve)=>{
17
- tryCount++;
18
- let url=await this.getImgTryOnce((domains[0]+''),config)
14
+ let url=await this.getImgTryOnce(config)
19
15
  if(url?.length){
20
16
  return resolve(url);
21
17
  }
22
- for(let i=0;i<3;i++){
23
- tryCount++;
24
- await Utils.wait(50);
25
- url=await this.getImgTryOnce((domains[1]+''),config)
26
- if(url?.length){
27
- console.log("H2I:TryCount",tryCount,url)
28
- return resolve(url);
29
- }
30
- }
31
- for(let i=0;i<5;i++){
32
- tryCount++;
33
- await Utils.wait(200);
34
- url=await this.getImgTryOnce((domains[1]+''),config)
35
- if(url?.length){
36
- console.log("H2I:TryCount",tryCount,url)
37
- return resolve(url);
38
- }
18
+ let retryMap:{[key:number]:number}={
19
+ 50:10, 500:10, 1000:10, 2000:10, 5000:10, 20000:5
39
20
  }
40
- for(let i=0;i<7;i++){
41
- tryCount++;
42
- await Utils.wait(500);
43
- url=await this.getImgTryOnce((domains[1]+''),config)
44
- if(url?.length){
45
- console.log("H2I:TryCount",tryCount,url)
46
- return resolve(url);
47
- }
48
- }
49
- for(let i=0;i<10;i++){
50
- tryCount++;
51
- await Utils.wait(1000);
52
- url=await this.getImgTryOnce((domains[1]+''),config)
53
- if(url?.length){
54
- console.log("H2I:TryCount",tryCount,url)
55
- return resolve(url);
56
- }
57
- }
58
- for(let i=0;i<5;i++){
59
- tryCount++;
60
- await Utils.wait(2000);
61
- url=await this.getImgTryOnce((domains[1]+''),config)
62
- if(url?.length){
63
- console.log("H2I:TryCount",tryCount,url)
64
- return resolve(url);
65
- }
66
- }
67
- for(let i=0;i<5;i++){
68
- tryCount++;
69
- await Utils.wait(20000);
70
- url=await this.getImgTryOnce((domains[1]+''),config)
71
- if(url?.length){
72
- console.log("H2I:TryCount",tryCount,url)
73
- return resolve(url);
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
+ }
74
28
  }
75
29
  }
76
-
77
-
78
- console.log("H2I:TryCount",tryCount,url)
79
30
 
80
31
  return resolve(url);
81
32
 
@@ -84,7 +35,7 @@ export class H2I {
84
35
  }
85
36
 
86
37
 
87
- public static getImgTryOnce(domain:string,config: {
38
+ public static getImgTryOnce(config: {
88
39
  html: string,
89
40
  bucketId : number,
90
41
  waitTime?:number,
@@ -96,7 +47,7 @@ export class H2I {
96
47
  request({
97
48
  method: 'POST',
98
49
  headers: {'Content-Type': 'application/json'},
99
- url:`https://${domain}.dhanda.app/html2image/${config?.bucketId}`,
50
+ url:`https://md1.ezobooks.in/html2image/${config?.bucketId}`,
100
51
  body:JSON.stringify({
101
52
  htmlStr:config.html,
102
53
  waitTime:config?.waitTime || 0,
@@ -124,7 +75,7 @@ export class H2I {
124
75
  try{
125
76
  let obj=JSON.parse(res?.body);
126
77
  if(obj?.status == 'success' && obj?.image?.length){
127
- let finalUrl = obj?.image.replace(/md.ezobooks/, 'mdr.ezobooks');
78
+ let finalUrl = obj?.image.replace(/md.ezobooks/, 'mdr.ezobooks')?.replace(/md1.ezobooks/, 'mdr.ezobooks');
128
79
  return resolve(finalUrl);
129
80
 
130
81
  }else{
@@ -147,161 +98,118 @@ export class H2I {
147
98
 
148
99
  }
149
100
 
150
- public static getPdf(config: {
151
- html: string,
152
- bucketId: number,
153
- waitTime?:number,
101
+ public static getImgFromBase64(config: {
102
+ base64Str: string,
103
+ bucketId : number,
104
+ type?:'png'|'jpg',
154
105
  debug?:boolean
155
106
  }):Promise<string> {
156
- let availableDomains=["md","md","md","md","md","md","md","md","md","md"];
157
- let domains = Utils.shuffleArray([...availableDomains]);
158
107
  return new Promise(async (resolve)=>{
159
- let url=await this.getPdfTryOnce((domains[0]+''),config)
108
+ let url=await this.getImgFromBase64TryOnce(config)
160
109
  if(url?.length){
161
110
  return resolve(url);
162
111
  }
163
- await Utils.wait(50);
164
- url=await this.getPdfTryOnce((domains[1]+''),config)
165
- if(url?.length){
166
- return resolve(url);
112
+ let retryMap:{[key:number]:number}={
113
+ 50:10, 500:10, 1000:10, 2000:10, 5000:10, 20000:5
167
114
  }
168
- await Utils.wait(100);
169
- url=await this.getPdfTryOnce((domains[2]+''),config)
170
- if(url?.length){
171
- return resolve(url);
172
- }
173
- await Utils.wait(200);
174
- url=await this.getPdfTryOnce((domains[3]+''),config)
175
- if(url?.length){
176
- return resolve(url);
177
- }
178
- await Utils.wait(300);
179
- url=await this.getPdfTryOnce((domains[4]+''),config)
180
- if(url?.length){
181
- return resolve(url);
182
- }
183
- await Utils.wait(300);
184
- url=await this.getPdfTryOnce((domains[5]+''),config)
185
- if(url?.length){
186
- return resolve(url);
187
- }
188
- await Utils.wait(300);
189
- url=await this.getPdfTryOnce((domains[6]+''),config)
190
- if(url?.length){
191
- return resolve(url);
192
- }
193
- await Utils.wait(300);
194
- url=await this.getPdfTryOnce((domains[7]+''),config)
195
- if(url?.length){
196
- return resolve(url);
197
- }
198
- await Utils.wait(300);
199
- url=await this.getPdfTryOnce((domains[8]+''),config)
200
- if(url?.length){
201
- return resolve(url);
202
- }
203
- await Utils.wait(300);
204
- url=await this.getPdfTryOnce((domains[9]+''),config)
205
- if(url?.length){
206
- return resolve(url);
207
- }
208
- await Utils.wait(300);
209
- url=await this.getPdfTryOnce((domains[10]+''),config)
210
- if(url?.length){
211
- return resolve(url);
212
- }await Utils.wait(300);
213
- url=await this.getPdfTryOnce((domains[10]+''),config)
214
- if(url?.length){
215
- return resolve(url);
216
- }await Utils.wait(300);
217
- url=await this.getPdfTryOnce((domains[10]+''),config)
218
- if(url?.length){
219
- return resolve(url);
220
- }await Utils.wait(300);
221
- url=await this.getPdfTryOnce((domains[10]+''),config)
222
- if(url?.length){
223
- return resolve(url);
224
- }await Utils.wait(300);
225
- url=await this.getPdfTryOnce((domains[10]+''),config)
226
- if(url?.length){
227
- return resolve(url);
228
- }await Utils.wait(300);
229
- url=await this.getPdfTryOnce((domains[10]+''),config)
230
- if(url?.length){
231
- return resolve(url);
232
- }await Utils.wait(300);
233
- url=await this.getPdfTryOnce((domains[10]+''),config)
234
- if(url?.length){
235
- return resolve(url);
236
- }
237
- await Utils.wait(1000);
238
- url=await this.getPdfTryOnce((domains[0]+''),config)
239
- if(url?.length){
240
- return resolve(url);
241
- }await Utils.wait(1000);
242
- url=await this.getPdfTryOnce((domains[0]+''),config)
243
- if(url?.length){
244
- return resolve(url);
245
- }await Utils.wait(1000);
246
- url=await this.getPdfTryOnce((domains[0]+''),config)
247
- if(url?.length){
248
- return resolve(url);
249
- }await Utils.wait(1000);
250
- url=await this.getPdfTryOnce((domains[0]+''),config)
251
- if(url?.length){
252
- return resolve(url);
253
- }await Utils.wait(1000);
254
- url=await this.getPdfTryOnce((domains[0]+''),config)
255
- if(url?.length){
256
- return resolve(url);
257
- }await Utils.wait(1000);
258
- url=await this.getPdfTryOnce((domains[0]+''),config)
259
- if(url?.length){
260
- return resolve(url);
261
- }await Utils.wait(1000);
262
- url=await this.getPdfTryOnce((domains[0]+''),config)
263
- if(url?.length){
264
- return resolve(url);
265
- }await Utils.wait(1000);
266
- url=await this.getPdfTryOnce((domains[0]+''),config)
267
- if(url?.length){
268
- return resolve(url);
269
- }await Utils.wait(1000);
270
- url=await this.getPdfTryOnce((domains[0]+''),config)
271
- if(url?.length){
272
- return resolve(url);
273
- }await Utils.wait(1000);
274
- url=await this.getPdfTryOnce((domains[0]+''),config)
275
- if(url?.length){
276
- return resolve(url);
277
- }await Utils.wait(1000);
278
- url=await this.getPdfTryOnce((domains[0]+''),config)
279
- if(url?.length){
280
- return resolve(url);
281
- }await Utils.wait(1000);
282
- url=await this.getPdfTryOnce((domains[0]+''),config)
283
- if(url?.length){
284
- return resolve(url);
285
- }
286
- await Utils.wait(2000);
287
- url=await this.getPdfTryOnce((domains[1]+''),config)
288
- if(url?.length){
289
- 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
+ }
122
+ }
290
123
  }
291
- await Utils.wait(4000);
292
- url=await this.getPdfTryOnce((domains[2]+''),config)
124
+
125
+ return resolve(url);
126
+
127
+ })
128
+
129
+ }
130
+
131
+
132
+ public static getImgFromBase64TryOnce(config: {
133
+ base64Str: string,
134
+ bucketId : number,
135
+ type?:'png'|'jpg',
136
+ debug? : boolean
137
+ }):Promise<string> {
138
+ return new Promise((resolve)=>{
139
+ request({
140
+ method: 'POST',
141
+ headers: {'Content-Type': 'application/json'},
142
+ url:`https://md1.ezobooks.in/base642image/${config?.bucketId}`,
143
+ body:JSON.stringify({
144
+ base64Str:config.base64Str,
145
+ type:config?.type || 'png',
146
+ })
147
+ },(error,res)=>{
148
+ if(error){
149
+ if(config?.debug===true){console.error('H2I:245',error);}
150
+ return resolve('');
151
+ }
152
+ if(res?.body){
153
+ if(res?.body?.indexOf("502 Bad Gateway")>-1){
154
+ return resolve('');
155
+ }
156
+
157
+ if(res?.body?.indexOf("504 Gateway Time-out")>-1){
158
+ return resolve('');
159
+ }
160
+
161
+ if(res?.body?.indexOf("504 Gateway Timeout")>-1){
162
+ return resolve('');
163
+ }
164
+
165
+ try{
166
+ let obj=JSON.parse(res?.body);
167
+ if(obj?.status == 'success' && obj?.image?.length){
168
+ let finalUrl = obj?.image.replace(/md.ezobooks/, 'mdr.ezobooks')?.replace(/md1.ezobooks/, 'mdr.ezobooks');
169
+ return resolve(finalUrl);
170
+
171
+ }else{
172
+ if(config?.debug===true){console.error('H2I:268',obj);}
173
+
174
+ return resolve('');
175
+
176
+ }
177
+ }catch(err){
178
+ if(config?.debug===true){console.error('H2I:274',res?.body,err);}
179
+
180
+ return resolve('');
181
+
182
+ }
183
+ }
184
+ return resolve('');
185
+ })
186
+
187
+ })
188
+
189
+ }
190
+
191
+ public static getPdf(config: {
192
+ html: string,
193
+ bucketId: number,
194
+ waitTime?:number,
195
+ debug?:boolean
196
+ }):Promise<string> {
197
+ return new Promise(async (resolve)=>{
198
+ let url=await this.getPdfTryOnce(config)
293
199
  if(url?.length){
294
200
  return resolve(url);
295
201
  }
296
- await Utils.wait(7000);
297
- url=await this.getPdfTryOnce((domains[3]+''),config)
298
- if(url?.length){
299
- return resolve(url);
202
+ let retryMap:{[key:number]:number}={
203
+ 50:10, 500:10, 1000:10, 2000:10, 5000:10, 20000:5
300
204
  }
301
- await Utils.wait(11000);
302
- url=await this.getPdfTryOnce((domains[4]+''),config)
303
- if(url?.length){
304
- return resolve(url);
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
+ }
305
213
  }
306
214
 
307
215
  return resolve(url);
@@ -310,7 +218,7 @@ export class H2I {
310
218
 
311
219
  }
312
220
 
313
- public static getPdfTryOnce(domain:string,config: {
221
+ public static getPdfTryOnce(config: {
314
222
  html: string,
315
223
  bucketId : number,
316
224
  waitTime?:number,
@@ -320,7 +228,7 @@ export class H2I {
320
228
  request({
321
229
  method: 'POST',
322
230
  headers: {'Content-Type': 'application/json'},
323
- url:`https://${domain}.ezobooks.in/html2pdf/${config.bucketId}`,
231
+ url:`https://md1.ezobooks.in/html2pdf/${config.bucketId}`,
324
232
  body:JSON.stringify({
325
233
  htmlStr:config.html,
326
234
  waitTime:config?.waitTime || 0
@@ -337,7 +245,7 @@ export class H2I {
337
245
  try{
338
246
  let obj=JSON.parse(res?.body);
339
247
  if(obj?.status == 'success' && obj?.image?.length){
340
- let finalUrl = obj?.image.replace(/md.ezobooks/, 'mdr.ezobooks');
248
+ let finalUrl = obj?.image.replace(/md.ezobooks/, 'mdr.ezobooks')?.replace(/md1.ezobooks/, 'mdr.ezobooks');
341
249
  return resolve(finalUrl);
342
250
 
343
251
  }else{
@@ -367,87 +275,22 @@ export class H2I {
367
275
  requestId:string,
368
276
  debug?:boolean
369
277
  }):Promise<string> {
370
- let availableDomains=["md","md","md","md","md","md","md","md","md","md"];
371
- let domains = Utils.shuffleArray([...availableDomains]);
372
278
  return new Promise(async (resolve)=>{
373
- let url=await this.getVidTryOnce((domains[0]+''),config)
374
- if(url?.length){
375
- return resolve(url);
376
- }
377
- await Utils.wait(50);
378
- url=await this.getVidTryOnce((domains[1]+''),config)
379
- if(url?.length){
380
- return resolve(url);
381
- }
382
- await Utils.wait(100);
383
- url=await this.getVidTryOnce((domains[2]+''),config)
384
- if(url?.length){
385
- return resolve(url);
386
- }
387
- await Utils.wait(200);
388
- url=await this.getVidTryOnce((domains[3]+''),config)
389
- if(url?.length){
390
- return resolve(url);
391
- }
392
- await Utils.wait(300);
393
- url=await this.getVidTryOnce((domains[4]+''),config)
394
- if(url?.length){
395
- return resolve(url);
396
- }
397
- await Utils.wait(300);
398
- url=await this.getVidTryOnce((domains[5]+''),config)
399
- if(url?.length){
400
- return resolve(url);
401
- }
402
- await Utils.wait(300);
403
- url=await this.getVidTryOnce((domains[6]+''),config)
404
- if(url?.length){
405
- return resolve(url);
406
- }
407
- await Utils.wait(300);
408
- url=await this.getVidTryOnce((domains[7]+''),config)
409
- if(url?.length){
410
- return resolve(url);
411
- }
412
- await Utils.wait(300);
413
- url=await this.getVidTryOnce((domains[8]+''),config)
279
+ let url=await this.getVidTryOnce(config)
414
280
  if(url?.length){
415
281
  return resolve(url);
416
282
  }
417
- await Utils.wait(300);
418
- url=await this.getVidTryOnce((domains[9]+''),config)
419
- if(url?.length){
420
- return resolve(url);
283
+ let retryMap:{[key:number]:number}={
284
+ 50:10, 500:10, 1000:10, 2000:10, 5000:10, 20000:5
421
285
  }
422
- await Utils.wait(300);
423
- url=await this.getVidTryOnce((domains[10]+''),config)
424
- if(url?.length){
425
- return resolve(url);
426
- }
427
- await Utils.wait(1000);
428
- url=await this.getVidTryOnce((domains[0]+''),config)
429
- if(url?.length){
430
- return resolve(url);
431
- }
432
- await Utils.wait(2000);
433
- url=await this.getVidTryOnce((domains[1]+''),config)
434
- if(url?.length){
435
- return resolve(url);
436
- }
437
- await Utils.wait(4000);
438
- url=await this.getVidTryOnce((domains[2]+''),config)
439
- if(url?.length){
440
- return resolve(url);
441
- }
442
- await Utils.wait(7000);
443
- url=await this.getVidTryOnce((domains[3]+''),config)
444
- if(url?.length){
445
- return resolve(url);
446
- }
447
- await Utils.wait(11000);
448
- url=await this.getVidTryOnce((domains[4]+''),config)
449
- if(url?.length){
450
- 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
+ }
451
294
  }
452
295
 
453
296
  return resolve(url);
@@ -456,7 +299,7 @@ export class H2I {
456
299
 
457
300
  }
458
301
 
459
- public static getVidTryOnce(domain:string,config: {
302
+ public static getVidTryOnce(config: {
460
303
  videoUrl: string,
461
304
  frameUrl:string,
462
305
  contactImageUrl:string,
@@ -467,7 +310,7 @@ export class H2I {
467
310
  request({
468
311
  method: 'POST',
469
312
  headers: {'Content-Type': 'application/json'},
470
- url:`https://${domain}.ezobooks.in/vd/compile`,
313
+ url:`https://md1.ezobooks.in/vd/compile`,
471
314
  body:JSON.stringify({
472
315
  videoUrl:config.videoUrl,
473
316
  frameUrl:config.frameUrl,
@@ -483,7 +326,7 @@ export class H2I {
483
326
  try{
484
327
  let obj=JSON.parse(res?.body);
485
328
  if(obj?.status == 'success' && obj?.url?.length){
486
- let finalUrl = obj?.url?.replace(/md.ezobooks/, 'mdr.ezobooks');
329
+ let finalUrl = obj?.url?.replace(/md.ezobooks/, 'mdr.ezobooks')?.replace(/md1.ezobooks/, 'mdr.ezobooks');
487
330
  return resolve(finalUrl);
488
331
 
489
332
  }else{
@@ -514,87 +357,22 @@ export class H2I {
514
357
  requestId:string,
515
358
  debug?:boolean
516
359
  }):Promise<string> {
517
- let availableDomains=["md","md","md","md","md","md","md","md","md","md"];
518
- let domains = Utils.shuffleArray([...availableDomains]);
519
360
  return new Promise(async (resolve)=>{
520
- let url=await this.getReelTryOnce((domains[0]+''),config)
521
- if(url?.length){
522
- return resolve(url);
523
- }
524
- await Utils.wait(50);
525
- url=await this.getReelTryOnce((domains[1]+''),config)
526
- if(url?.length){
527
- return resolve(url);
528
- }
529
- await Utils.wait(100);
530
- url=await this.getReelTryOnce((domains[2]+''),config)
361
+ let url=await this.getReelTryOnce(config)
531
362
  if(url?.length){
532
363
  return resolve(url);
533
364
  }
534
- await Utils.wait(200);
535
- url=await this.getReelTryOnce((domains[3]+''),config)
536
- if(url?.length){
537
- return resolve(url);
365
+ let retryMap:{[key:number]:number}={
366
+ 50:10, 500:10, 1000:10, 2000:10, 5000:10, 20000:5
538
367
  }
539
- await Utils.wait(300);
540
- url=await this.getReelTryOnce((domains[4]+''),config)
541
- if(url?.length){
542
- return resolve(url);
543
- }
544
- await Utils.wait(300);
545
- url=await this.getReelTryOnce((domains[5]+''),config)
546
- if(url?.length){
547
- return resolve(url);
548
- }
549
- await Utils.wait(300);
550
- url=await this.getReelTryOnce((domains[6]+''),config)
551
- if(url?.length){
552
- return resolve(url);
553
- }
554
- await Utils.wait(300);
555
- url=await this.getReelTryOnce((domains[7]+''),config)
556
- if(url?.length){
557
- return resolve(url);
558
- }
559
- await Utils.wait(300);
560
- url=await this.getReelTryOnce((domains[8]+''),config)
561
- if(url?.length){
562
- return resolve(url);
563
- }
564
- await Utils.wait(300);
565
- url=await this.getReelTryOnce((domains[9]+''),config)
566
- if(url?.length){
567
- return resolve(url);
568
- }
569
- await Utils.wait(300);
570
- url=await this.getReelTryOnce((domains[10]+''),config)
571
- if(url?.length){
572
- return resolve(url);
573
- }
574
- await Utils.wait(1000);
575
- url=await this.getReelTryOnce((domains[0]+''),config)
576
- if(url?.length){
577
- return resolve(url);
578
- }
579
- await Utils.wait(2000);
580
- url=await this.getReelTryOnce((domains[1]+''),config)
581
- if(url?.length){
582
- return resolve(url);
583
- }
584
- await Utils.wait(4000);
585
- url=await this.getReelTryOnce((domains[2]+''),config)
586
- if(url?.length){
587
- return resolve(url);
588
- }
589
- await Utils.wait(7000);
590
- url=await this.getReelTryOnce((domains[3]+''),config)
591
- if(url?.length){
592
- return resolve(url);
593
- }
594
- await Utils.wait(11000);
595
- url=await this.getReelTryOnce((domains[4]+''),config)
596
- if(url?.length){
597
- return resolve(url);
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
+ }
598
376
  }
599
377
 
600
378
  return resolve(url);
@@ -603,7 +381,7 @@ export class H2I {
603
381
 
604
382
  }
605
383
 
606
- public static getReelTryOnce(domain:string,config: {
384
+ public static getReelTryOnce(config: {
607
385
  productVideoUrl: string,
608
386
  modelVideoUrl:string,
609
387
  infoImageUrl:string,
@@ -614,7 +392,7 @@ export class H2I {
614
392
  request({
615
393
  method: 'POST',
616
394
  headers: {'Content-Type': 'application/json'},
617
- url:`https://${domain}.ezobooks.in/vd/composeReel`,
395
+ url:`https://md1.ezobooks.in/vd/composeReel`,
618
396
  body:JSON.stringify({
619
397
  productVideoUrl:config.productVideoUrl,
620
398
  modelVideoUrl:config.modelVideoUrl,
@@ -630,7 +408,7 @@ export class H2I {
630
408
  try{
631
409
  let obj=JSON.parse(res?.body);
632
410
  if(obj?.status == 'success' && obj?.url?.length){
633
- let finalUrl = obj?.url?.replace(/md.ezobooks/, 'mdr.ezobooks');
411
+ let finalUrl = obj?.url?.replace(/md.ezobooks/, 'mdr.ezobooks')?.replace(/md1.ezobooks/, 'mdr.ezobooks');
634
412
  return resolve(finalUrl);
635
413
 
636
414
  }else{
@@ -661,87 +439,22 @@ export class H2I {
661
439
  epilogue:string,
662
440
  debug?:boolean
663
441
  }):Promise<string> {
664
- let availableDomains=["md","md","md","md","md","md","md","md","md","md"];
665
- let domains = Utils.shuffleArray([...availableDomains]);
666
442
  return new Promise(async (resolve)=>{
667
- let url=await this.getSceneVidTryOnce((domains[0]+''),config)
668
- if(url?.length){
669
- return resolve(url);
670
- }
671
- await Utils.wait(50);
672
- url=await this.getSceneVidTryOnce((domains[1]+''),config)
443
+ let url=await this.getSceneVidTryOnce(config)
673
444
  if(url?.length){
674
445
  return resolve(url);
675
446
  }
676
- await Utils.wait(100);
677
- url=await this.getSceneVidTryOnce((domains[2]+''),config)
678
- if(url?.length){
679
- return resolve(url);
447
+ let retryMap:{[key:number]:number}={
448
+ 50:10, 500:10, 1000:10, 2000:10, 5000:10, 20000:5
680
449
  }
681
- await Utils.wait(200);
682
- url=await this.getSceneVidTryOnce((domains[3]+''),config)
683
- if(url?.length){
684
- return resolve(url);
685
- }
686
- await Utils.wait(300);
687
- url=await this.getSceneVidTryOnce((domains[4]+''),config)
688
- if(url?.length){
689
- return resolve(url);
690
- }
691
- await Utils.wait(300);
692
- url=await this.getSceneVidTryOnce((domains[5]+''),config)
693
- if(url?.length){
694
- return resolve(url);
695
- }
696
- await Utils.wait(300);
697
- url=await this.getSceneVidTryOnce((domains[6]+''),config)
698
- if(url?.length){
699
- return resolve(url);
700
- }
701
- await Utils.wait(300);
702
- url=await this.getSceneVidTryOnce((domains[7]+''),config)
703
- if(url?.length){
704
- return resolve(url);
705
- }
706
- await Utils.wait(300);
707
- url=await this.getSceneVidTryOnce((domains[8]+''),config)
708
- if(url?.length){
709
- return resolve(url);
710
- }
711
- await Utils.wait(300);
712
- url=await this.getSceneVidTryOnce((domains[9]+''),config)
713
- if(url?.length){
714
- return resolve(url);
715
- }
716
- await Utils.wait(300);
717
- url=await this.getSceneVidTryOnce((domains[10]+''),config)
718
- if(url?.length){
719
- return resolve(url);
720
- }
721
- await Utils.wait(1000);
722
- url=await this.getSceneVidTryOnce((domains[0]+''),config)
723
- if(url?.length){
724
- return resolve(url);
725
- }
726
- await Utils.wait(2000);
727
- url=await this.getSceneVidTryOnce((domains[1]+''),config)
728
- if(url?.length){
729
- return resolve(url);
730
- }
731
- await Utils.wait(4000);
732
- url=await this.getSceneVidTryOnce((domains[2]+''),config)
733
- if(url?.length){
734
- return resolve(url);
735
- }
736
- await Utils.wait(7000);
737
- url=await this.getSceneVidTryOnce((domains[3]+''),config)
738
- if(url?.length){
739
- return resolve(url);
740
- }
741
- await Utils.wait(11000);
742
- url=await this.getSceneVidTryOnce((domains[4]+''),config)
743
- if(url?.length){
744
- 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
+ }
745
458
  }
746
459
 
747
460
  return resolve(url);
@@ -750,7 +463,7 @@ export class H2I {
750
463
 
751
464
  }
752
465
 
753
- public static getSceneVidTryOnce(domain:string,config: {
466
+ public static getSceneVidTryOnce(config: {
754
467
  requestId:string,
755
468
  videos: string[],
756
469
  overlayImage:string,
@@ -761,7 +474,7 @@ export class H2I {
761
474
  request({
762
475
  method: 'POST',
763
476
  headers: {'Content-Type': 'application/json'},
764
- url:`https://${domain}.ezobooks.in/vd/composeScene`,
477
+ url:`https://md1.ezobooks.in/vd/composeScene`,
765
478
  body:JSON.stringify({
766
479
  requestId:config.requestId,
767
480
  videos:config.videos,
@@ -777,7 +490,7 @@ export class H2I {
777
490
  try{
778
491
  let obj=JSON.parse(res?.body);
779
492
  if(obj?.status == 'success' && obj?.url?.length){
780
- let finalUrl = obj?.url?.replace(/md.ezobooks/, 'mdr.ezobooks');
493
+ let finalUrl = obj?.url?.replace(/md.ezobooks/, 'mdr.ezobooks')?.replace(/md1.ezobooks/, 'mdr.ezobooks');
781
494
  return resolve(finalUrl);
782
495
 
783
496
  }else{
@@ -808,87 +521,22 @@ export class H2I {
808
521
  }
809
522
  debug?:boolean
810
523
  }):Promise<string> {
811
- let availableDomains=["md","md","md","md","md","md","md","md","md","md"];
812
- let domains = Utils.shuffleArray([...availableDomains]);
813
524
  return new Promise(async (resolve)=>{
814
- let url=await this.compileVideoByCommandTryOnce((domains[0]+''),config)
815
- if(url?.length){
816
- return resolve(url);
817
- }
818
- await Utils.wait(50);
819
- url=await this.compileVideoByCommandTryOnce((domains[1]+''),config)
525
+ let url=await this.compileVideoByCommandTryOnce(config)
820
526
  if(url?.length){
821
527
  return resolve(url);
822
528
  }
823
- await Utils.wait(100);
824
- url=await this.compileVideoByCommandTryOnce((domains[2]+''),config)
825
- if(url?.length){
826
- return resolve(url);
827
- }
828
- await Utils.wait(200);
829
- url=await this.compileVideoByCommandTryOnce((domains[3]+''),config)
830
- if(url?.length){
831
- return resolve(url);
832
- }
833
- await Utils.wait(300);
834
- url=await this.compileVideoByCommandTryOnce((domains[4]+''),config)
835
- if(url?.length){
836
- return resolve(url);
837
- }
838
- await Utils.wait(300);
839
- url=await this.compileVideoByCommandTryOnce((domains[5]+''),config)
840
- if(url?.length){
841
- return resolve(url);
842
- }
843
- await Utils.wait(300);
844
- url=await this.compileVideoByCommandTryOnce((domains[6]+''),config)
845
- if(url?.length){
846
- return resolve(url);
847
- }
848
- await Utils.wait(300);
849
- url=await this.compileVideoByCommandTryOnce((domains[7]+''),config)
850
- if(url?.length){
851
- return resolve(url);
852
- }
853
- await Utils.wait(300);
854
- url=await this.compileVideoByCommandTryOnce((domains[8]+''),config)
855
- if(url?.length){
856
- return resolve(url);
857
- }
858
- await Utils.wait(300);
859
- url=await this.compileVideoByCommandTryOnce((domains[9]+''),config)
860
- if(url?.length){
861
- return resolve(url);
862
- }
863
- await Utils.wait(300);
864
- url=await this.compileVideoByCommandTryOnce((domains[10]+''),config)
865
- if(url?.length){
866
- return resolve(url);
867
- }
868
- await Utils.wait(1000);
869
- url=await this.compileVideoByCommandTryOnce((domains[0]+''),config)
870
- if(url?.length){
871
- return resolve(url);
872
- }
873
- await Utils.wait(2000);
874
- url=await this.compileVideoByCommandTryOnce((domains[1]+''),config)
875
- if(url?.length){
876
- return resolve(url);
529
+ let retryMap:{[key:number]:number}={
530
+ 50:10, 500:10, 1000:10, 2000:10, 5000:10, 20000:5
877
531
  }
878
- await Utils.wait(4000);
879
- url=await this.compileVideoByCommandTryOnce((domains[2]+''),config)
880
- if(url?.length){
881
- return resolve(url);
882
- }
883
- await Utils.wait(7000);
884
- url=await this.compileVideoByCommandTryOnce((domains[3]+''),config)
885
- if(url?.length){
886
- return resolve(url);
887
- }
888
- await Utils.wait(11000);
889
- url=await this.compileVideoByCommandTryOnce((domains[4]+''),config)
890
- if(url?.length){
891
- 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
+ }
892
540
  }
893
541
 
894
542
  return resolve(url);
@@ -897,7 +545,7 @@ export class H2I {
897
545
 
898
546
  }
899
547
 
900
- public static compileVideoByCommandTryOnce(domain:string,config: {
548
+ public static compileVideoByCommandTryOnce(config: {
901
549
  requestId:string,
902
550
  ffmpegCommand: string,
903
551
  mediaMap: {
@@ -909,7 +557,7 @@ export class H2I {
909
557
  request({
910
558
  method: 'POST',
911
559
  headers: {'Content-Type': 'application/json'},
912
- url:`https://${domain}.ezobooks.in/vd/compileVideoCommand`,
560
+ url:`https://md1.ezobooks.in/vd/compileVideoCommand`,
913
561
  body:JSON.stringify({
914
562
  requestId:config.requestId,
915
563
  ffmpegCommand:config.ffmpegCommand,
@@ -924,7 +572,7 @@ export class H2I {
924
572
  try{
925
573
  let obj=JSON.parse(res?.body);
926
574
  if(obj?.status == 'success' && obj?.url?.length){
927
- let finalUrl = obj?.url?.replace(/md.ezobooks/, 'mdr.ezobooks');
575
+ let finalUrl = obj?.url?.replace(/md.ezobooks/, 'mdr.ezobooks')?.replace(/md1.ezobooks/, 'mdr.ezobooks');
928
576
  return resolve(finalUrl);
929
577
 
930
578
  }else{