@ygracs/xepg-lib-js 0.0.20 → 0.0.21
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/CHANGELOG.md +12 -76
- package/LICENSE +1 -1
- package/README.md +3 -3
- package/doc/xepgdoc-lib.md +261 -56
- package/doc/xepgdoc-spec-draft.dtd +65 -0
- package/index.js +5 -2
- package/lib/dts-helper.js +23 -28
- package/lib/xepgdoc-lib.js +146 -127
- package/package.json +6 -5
package/lib/xepgdoc-lib.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
// [v0.1.
|
|
1
|
+
// [v0.1.081-20250227]
|
|
2
2
|
|
|
3
3
|
// === module init block ===
|
|
4
4
|
|
|
5
|
-
const fs = require('fs');
|
|
6
|
-
const fse = require('fs').promises;
|
|
7
5
|
const xmlParser = require('@ygracs/xml-js6');
|
|
8
6
|
|
|
9
7
|
const {
|
|
@@ -18,12 +16,11 @@ const {
|
|
|
18
16
|
} = require('@ygracs/dtf-lib-js');
|
|
19
17
|
|
|
20
18
|
const {
|
|
21
|
-
chkDTSysID,
|
|
19
|
+
chkDTSysID, getDTSysDescr,
|
|
22
20
|
convStringToDTValue, convDTValueToString,
|
|
23
21
|
} = require('./dts-helper.js');
|
|
24
22
|
|
|
25
23
|
const {
|
|
26
|
-
checkFsError,
|
|
27
24
|
loadFileSync, loadFile,
|
|
28
25
|
saveToFileSync, saveToFile,
|
|
29
26
|
} = require('./file-helper.js');
|
|
@@ -68,8 +65,8 @@ function writeXEpgDocDeclSection(obj, opt){
|
|
|
68
65
|
let doc_def_enc = XEPG_DEF_ENCODING_VALUE;
|
|
69
66
|
let key_name = defParseOptions.settings.declarationKey;
|
|
70
67
|
if (isPlainObject(opt)) {
|
|
71
|
-
xml_ver = readAsString(opt.version, xml_ver);
|
|
72
|
-
doc_def_enc = readAsString(opt.encoding, doc_def_enc);
|
|
68
|
+
xml_ver = readAsString(opt.version, { defValue: xml_ver });
|
|
69
|
+
doc_def_enc = readAsString(opt.encoding, { defValue: doc_def_enc });
|
|
73
70
|
};
|
|
74
71
|
if (isPlainObject(obj) && isNotEmptyString(key_name)) {
|
|
75
72
|
obj[key_name] = {};
|
|
@@ -143,17 +140,31 @@ const defParseOptions = new TXmlContentParseOptions();
|
|
|
143
140
|
*/
|
|
144
141
|
|
|
145
142
|
/**
|
|
146
|
-
* @
|
|
143
|
+
* @typedef {Object} xepgShedInfoDesc
|
|
144
|
+
* @property {number} time - a schedule start time
|
|
145
|
+
* @property {string} title - schedule title
|
|
146
|
+
* @property {string} [cat] - schedule category
|
|
147
|
+
* @property {number} [pcmark] - schedule rating
|
|
148
|
+
* @property {string} [descr] - schedule description
|
|
149
|
+
* @description A schedule info descriptor
|
|
150
|
+
*/
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* @classdesc This class implements an interface of a EPG-schedules list
|
|
147
154
|
*/
|
|
148
155
|
class TXEpgSchedulesList {
|
|
149
|
-
|
|
150
|
-
#
|
|
156
|
+
/** @property {object[]} */
|
|
157
|
+
#_content;// = null;
|
|
158
|
+
/** @property {object} */
|
|
159
|
+
#_options;// = null;
|
|
160
|
+
/** @property {?object} */
|
|
151
161
|
#_dts_src = null;
|
|
162
|
+
/** @property {?object} */
|
|
152
163
|
#_tz_src = null;
|
|
153
164
|
|
|
154
165
|
/**
|
|
155
|
-
* @param {any[]} obj
|
|
156
|
-
* @param {object} [opt]
|
|
166
|
+
* @param {any[]} obj - list of an elements
|
|
167
|
+
* @param {object} [opt] - options
|
|
157
168
|
* @param {?object} [opt.dts_src]
|
|
158
169
|
* @param {?object} [opt.tz_src]
|
|
159
170
|
* @description Creates an instance of the schedules list
|
|
@@ -174,22 +185,23 @@ class TXEpgSchedulesList {
|
|
|
174
185
|
}
|
|
175
186
|
|
|
176
187
|
/**
|
|
177
|
-
* @param {(number|string)} value
|
|
178
|
-
* @returns {
|
|
188
|
+
* @param {(number|string)} value - element index
|
|
189
|
+
* @returns {any}
|
|
179
190
|
* @private
|
|
191
|
+
* @description Returns a raw schedule element
|
|
180
192
|
*/
|
|
181
|
-
#_getItem = function(value){
|
|
193
|
+
#_getItem = function(value) {
|
|
182
194
|
if (this.chkIndex(value)) {
|
|
183
195
|
return this.#_content[Number(value)];
|
|
184
196
|
};
|
|
185
197
|
};
|
|
186
198
|
|
|
187
199
|
/**
|
|
200
|
+
* Contains a quantity of a schedules
|
|
188
201
|
* @property {number}
|
|
189
202
|
* @readonly
|
|
190
|
-
* @description Contains a quantity of a schedules
|
|
191
203
|
*/
|
|
192
|
-
get schedQty(){
|
|
204
|
+
get schedQty() {
|
|
193
205
|
return this.#_content.length;
|
|
194
206
|
}
|
|
195
207
|
|
|
@@ -197,11 +209,11 @@ class TXEpgSchedulesList {
|
|
|
197
209
|
//get SchedulesQty(){ return this.#_content.length; }
|
|
198
210
|
|
|
199
211
|
/**
|
|
212
|
+
* Contains a dtstype ID
|
|
200
213
|
* @property {number}
|
|
201
214
|
* @readonly
|
|
202
|
-
* @description Contains a dtstype ID
|
|
203
215
|
*/
|
|
204
|
-
get dtstype(){
|
|
216
|
+
get dtstype() {
|
|
205
217
|
let result = valueToIndex(
|
|
206
218
|
_getXmlChildElementParam(this.#_dts_src, 'value')
|
|
207
219
|
);
|
|
@@ -209,11 +221,11 @@ class TXEpgSchedulesList {
|
|
|
209
221
|
}
|
|
210
222
|
|
|
211
223
|
/**
|
|
224
|
+
* Contains a TZ-offset
|
|
212
225
|
* @property {number}
|
|
213
226
|
* @readonly
|
|
214
|
-
* @description Contains a TZ-offset
|
|
215
227
|
*/
|
|
216
|
-
get curDocTZ(){
|
|
228
|
+
get curDocTZ() {
|
|
217
229
|
return (
|
|
218
230
|
this.#_tz_src
|
|
219
231
|
? convTZStringToValue(readXObjParam(this.#_tz_src).trim())
|
|
@@ -225,7 +237,7 @@ class TXEpgSchedulesList {
|
|
|
225
237
|
* @returns {boolean}
|
|
226
238
|
* @description Indicates whether an instance has none member
|
|
227
239
|
*/
|
|
228
|
-
hasNoSchedules(){
|
|
240
|
+
hasNoSchedules() {
|
|
229
241
|
return this.schedQty === 0;
|
|
230
242
|
}
|
|
231
243
|
|
|
@@ -233,7 +245,7 @@ class TXEpgSchedulesList {
|
|
|
233
245
|
* @returns {boolean}
|
|
234
246
|
* @description Indicates whether an instance has any member
|
|
235
247
|
*/
|
|
236
|
-
hasSchedules(){
|
|
248
|
+
hasSchedules() {
|
|
237
249
|
return this.schedQty > 0;
|
|
238
250
|
}
|
|
239
251
|
|
|
@@ -249,7 +261,7 @@ class TXEpgSchedulesList {
|
|
|
249
261
|
}
|
|
250
262
|
|
|
251
263
|
/**
|
|
252
|
-
* @param {(number|string)} value
|
|
264
|
+
* @param {(number|string)} value - index of some element
|
|
253
265
|
* @returns {boolean}
|
|
254
266
|
* @since 0.0.18
|
|
255
267
|
* @description Checks whether a given value is a valid index
|
|
@@ -261,12 +273,12 @@ class TXEpgSchedulesList {
|
|
|
261
273
|
}
|
|
262
274
|
|
|
263
275
|
/**
|
|
264
|
-
* @param {(number|string)} index
|
|
265
|
-
* @returns {
|
|
276
|
+
* @param {(number|string)} index - index of some element
|
|
277
|
+
* @returns {xepgShedInfoDesc}
|
|
266
278
|
* @description Returns a schedule info item for instance element
|
|
267
279
|
* addressed by a given index
|
|
268
280
|
*/
|
|
269
|
-
getScheduleInfo(index){
|
|
281
|
+
getScheduleInfo(index) {
|
|
270
282
|
//console.log('TXEpgSchedulesList => getScheduleInfo() => was called...');
|
|
271
283
|
const curObj = this.#_getItem(index);
|
|
272
284
|
let tmpObj = {};
|
|
@@ -295,10 +307,10 @@ class TXEpgSchedulesList {
|
|
|
295
307
|
}
|
|
296
308
|
|
|
297
309
|
/**
|
|
298
|
-
* @returns {
|
|
310
|
+
* @returns {xepgShedInfoDesc[]}
|
|
299
311
|
* @description Returns a schedule info for instance members
|
|
300
312
|
*/
|
|
301
|
-
getAllSchedulesInfo(){
|
|
313
|
+
getAllSchedulesInfo() {
|
|
302
314
|
let result = [];
|
|
303
315
|
for (let i = 0; i < this.schedQty; i++) {
|
|
304
316
|
let item = this.getScheduleInfo(i);
|
|
@@ -307,27 +319,39 @@ class TXEpgSchedulesList {
|
|
|
307
319
|
return result;
|
|
308
320
|
}
|
|
309
321
|
|
|
310
|
-
|
|
322
|
+
/**
|
|
323
|
+
* @protected
|
|
324
|
+
*/
|
|
325
|
+
asJSON() {
|
|
311
326
|
return JSON.stringify(this.#_content, null, 2);
|
|
312
327
|
}
|
|
313
328
|
|
|
314
329
|
};
|
|
315
330
|
|
|
316
331
|
/**
|
|
317
|
-
* @
|
|
332
|
+
* @typedef {Object} xepgProvInfoDesc
|
|
333
|
+
* @property {string} [name] - provider name
|
|
334
|
+
* @property {string} [version] - provider version
|
|
335
|
+
* @property {string} schema - document schema
|
|
336
|
+
* @property {string} doctype - document type
|
|
337
|
+
* @description A provider info descriptor
|
|
338
|
+
*/
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* @classdesc This class implements an interface of a EPG-provider element
|
|
318
342
|
*/
|
|
319
343
|
class TXEpgProviderContainer {
|
|
320
344
|
/** @property {Object} */
|
|
321
345
|
#_host;// = null;
|
|
322
346
|
/** @property {Object} */
|
|
323
347
|
#_options;// = null;
|
|
324
|
-
/** @property {
|
|
348
|
+
/** @property {TXmlContentParseOptions} */
|
|
325
349
|
#_parseOptions;// = null;
|
|
326
|
-
/** @property {?
|
|
350
|
+
/** @property {?TXEpgDTSProvider} */
|
|
327
351
|
|
|
328
352
|
/**
|
|
329
353
|
* @param {object} obj
|
|
330
|
-
* @param {object} [opt]
|
|
354
|
+
* @param {object} [opt] - options
|
|
331
355
|
* @param {object} [opt.parseOptions]
|
|
332
356
|
* @description Creates an instance of the EPG-provider element
|
|
333
357
|
*/
|
|
@@ -366,8 +390,8 @@ class TXEpgProviderContainer {
|
|
|
366
390
|
}
|
|
367
391
|
|
|
368
392
|
/**
|
|
393
|
+
* Contains a provider name
|
|
369
394
|
* @property {string}
|
|
370
|
-
* @description Contains a provider name
|
|
371
395
|
*/
|
|
372
396
|
get name() {
|
|
373
397
|
return _getXmlChildElementParam(this.#_host, 'name').trim();
|
|
@@ -378,8 +402,8 @@ class TXEpgProviderContainer {
|
|
|
378
402
|
}
|
|
379
403
|
|
|
380
404
|
/**
|
|
405
|
+
* Contains a version of a provider
|
|
381
406
|
* @property {string}
|
|
382
|
-
* @description Contains a version of a provider
|
|
383
407
|
*/
|
|
384
408
|
get version() {
|
|
385
409
|
return _getXmlChildElementParam(this.#_host, 'version').trim();
|
|
@@ -394,8 +418,8 @@ class TXEpgProviderContainer {
|
|
|
394
418
|
}
|
|
395
419
|
|
|
396
420
|
/**
|
|
421
|
+
* Contains a version of a document schema
|
|
397
422
|
* @property {string}
|
|
398
|
-
* @description Contains a version of a document schema
|
|
399
423
|
*/
|
|
400
424
|
get schema() {
|
|
401
425
|
return _getXmlChildElementParam(this.#_host, XEPG_DOCSCH_ETAG_NAME).trim();
|
|
@@ -410,8 +434,8 @@ class TXEpgProviderContainer {
|
|
|
410
434
|
}
|
|
411
435
|
|
|
412
436
|
/**
|
|
437
|
+
* Contains a document type
|
|
413
438
|
* @property {string}
|
|
414
|
-
* @description Contains a document type
|
|
415
439
|
*/
|
|
416
440
|
get doctype() {
|
|
417
441
|
return _getXmlChildElementParam(this.#_host, XEPG_DOCTYP_ETAG_NAME).trim();
|
|
@@ -440,15 +464,6 @@ class TXEpgProviderContainer {
|
|
|
440
464
|
return isSucceed;
|
|
441
465
|
}
|
|
442
466
|
|
|
443
|
-
/**
|
|
444
|
-
* @typedef {Object} xepgProvInfoDesc
|
|
445
|
-
* @property {string} name - provider name
|
|
446
|
-
* @property {string} version - provider version
|
|
447
|
-
* @property {string} schema - document schema
|
|
448
|
-
* @property {string} doctype - document type
|
|
449
|
-
* @description Contains a provider description
|
|
450
|
-
*/
|
|
451
|
-
|
|
452
467
|
/**
|
|
453
468
|
* @returns {xepgProvInfoDesc}
|
|
454
469
|
* @description Returns a provider info item
|
|
@@ -463,22 +478,25 @@ class TXEpgProviderContainer {
|
|
|
463
478
|
}
|
|
464
479
|
|
|
465
480
|
/**
|
|
466
|
-
* @param {
|
|
481
|
+
* @param {(string[]|xepgProvInfoDesc)} obj - provider info descriptor
|
|
467
482
|
* @returns {void}
|
|
468
483
|
* @description Sets a provider info
|
|
484
|
+
* @todo [since v0.0.21] deprecate use of `obj`-param as array
|
|
469
485
|
*/
|
|
470
|
-
setInfo(obj){
|
|
486
|
+
setInfo(obj) {
|
|
471
487
|
if (!isObject(obj)) return;
|
|
472
488
|
let name = '';
|
|
473
489
|
let version = '';
|
|
474
490
|
let schema = '';
|
|
475
491
|
let doctype = '';
|
|
476
492
|
if (isArray(obj)) {
|
|
493
|
+
// // TODO: [!] deprecate
|
|
477
494
|
[ name, version, schema, doctype ] = obj;
|
|
478
495
|
} else {
|
|
479
496
|
if (typeof obj.name === 'string') {
|
|
480
497
|
({ name, version, schema, doctype } = obj);
|
|
481
498
|
} else {
|
|
499
|
+
// // TODO: [?] deprecate
|
|
482
500
|
name = _getXmlChildElementParam(obj, 'name');
|
|
483
501
|
version = _getXmlChildElementParam(obj, 'version');
|
|
484
502
|
schema = _getXmlChildElementParam(obj, XEPG_DOCSCH_ETAG_NAME);
|
|
@@ -497,11 +515,11 @@ class TXEpgProviderContainer {
|
|
|
497
515
|
}
|
|
498
516
|
|
|
499
517
|
/**
|
|
500
|
-
* @param {
|
|
518
|
+
* @param {(xepgProvInfoDesc|string[])} opt - options
|
|
501
519
|
* @returns {void}
|
|
502
520
|
* @description Sets an initial instance state
|
|
503
521
|
*/
|
|
504
|
-
init(opt){
|
|
522
|
+
init(opt) {
|
|
505
523
|
let prov_opt = { ...defXEpgDocOptions.defProviderParam };
|
|
506
524
|
let name = '';
|
|
507
525
|
let version = '';
|
|
@@ -549,13 +567,15 @@ class TXEpgProviderContainer {
|
|
|
549
567
|
/**
|
|
550
568
|
* @classdesc This class implements an instance of a DTS-provider element
|
|
551
569
|
*/
|
|
552
|
-
class
|
|
553
|
-
|
|
554
|
-
#
|
|
570
|
+
class TXEpgDTSProvider {
|
|
571
|
+
/** @property {object} */
|
|
572
|
+
#_content;// = null;
|
|
573
|
+
/** @property {object} */
|
|
574
|
+
#_options;// = null;
|
|
555
575
|
|
|
556
576
|
/**
|
|
557
577
|
* @param {object} obj
|
|
558
|
-
* @param {object} [opt]
|
|
578
|
+
* @param {object} [opt] - options
|
|
559
579
|
* @param {object} [opt.parseOptions]
|
|
560
580
|
* @description Creates an instance of the DTS-provider element
|
|
561
581
|
*/
|
|
@@ -583,15 +603,15 @@ class TXepgDTSProvider {
|
|
|
583
603
|
* @returns {void}
|
|
584
604
|
* @private
|
|
585
605
|
*/
|
|
586
|
-
#_init(){
|
|
606
|
+
#_init() {
|
|
587
607
|
insertXObjElement(this.#_content, XEPG_DTSINFO_ETAG_NAME);
|
|
588
608
|
}
|
|
589
609
|
|
|
590
610
|
/**
|
|
611
|
+
* Contains a dtstype ID
|
|
591
612
|
* @property {number}
|
|
592
|
-
* @description Contains a dtstype ID
|
|
593
613
|
*/
|
|
594
|
-
get dtstype(){
|
|
614
|
+
get dtstype() {
|
|
595
615
|
const item = getXObjElement(this.#_content, XEPG_DTSINFO_ETAG_NAME);
|
|
596
616
|
let result = 0; //-1; // // TODO: [?]
|
|
597
617
|
if (isPlainObject(item)) {
|
|
@@ -601,7 +621,7 @@ class TXepgDTSProvider {
|
|
|
601
621
|
return result;
|
|
602
622
|
}
|
|
603
623
|
|
|
604
|
-
set dtstype(value){
|
|
624
|
+
set dtstype(value) {
|
|
605
625
|
let { index, name } = getDTSysDescr(value);
|
|
606
626
|
if (index !== -1) {
|
|
607
627
|
const item = insertXObjElement(
|
|
@@ -623,17 +643,17 @@ class TXepgDTSProvider {
|
|
|
623
643
|
}
|
|
624
644
|
|
|
625
645
|
/**
|
|
646
|
+
* Contains a TZ-offset
|
|
626
647
|
* @property {number}
|
|
627
|
-
* @description Contains a TZ-offset
|
|
628
648
|
*/
|
|
629
|
-
get curDocTZ(){
|
|
649
|
+
get curDocTZ() {
|
|
630
650
|
const tz = convTZStringToValue(
|
|
631
651
|
_getXmlChildElementParam(this.#_content, XEPG_DOCTZ_ETAG_NAME)
|
|
632
652
|
);
|
|
633
653
|
return Number.isNaN(tz) ? 0 : tz;
|
|
634
654
|
}
|
|
635
655
|
|
|
636
|
-
set curDocTZ(value){
|
|
656
|
+
set curDocTZ(value) {
|
|
637
657
|
let _value = convValueToTZString(value);
|
|
638
658
|
if (_value !== '') {
|
|
639
659
|
let item = insertXObjElement(
|
|
@@ -647,6 +667,15 @@ class TXepgDTSProvider {
|
|
|
647
667
|
|
|
648
668
|
};
|
|
649
669
|
|
|
670
|
+
/**
|
|
671
|
+
* @typedef {Object} xepgChnInfoDesc
|
|
672
|
+
* @property {string} chnid - channel ID
|
|
673
|
+
* @property {string} chname - channel name
|
|
674
|
+
* @property {string} [chngid] - channel 'Group ID'
|
|
675
|
+
* @property {string} [srcurl] - EPG-source URL
|
|
676
|
+
* @description A channel info descriptor
|
|
677
|
+
*/
|
|
678
|
+
|
|
650
679
|
/**
|
|
651
680
|
* @classdesc This class implements an instance of a EPG-header element
|
|
652
681
|
*/
|
|
@@ -655,14 +684,14 @@ class TXEpgHeaderContainer {
|
|
|
655
684
|
#_host;// = null;
|
|
656
685
|
/** @property {Object} */
|
|
657
686
|
#_options;// = null;
|
|
658
|
-
/** @property {
|
|
687
|
+
/** @property {TXmlContentParseOptions} */
|
|
659
688
|
#_parseOptions;// = null;
|
|
660
|
-
/** @property {
|
|
689
|
+
/** @property {TXEpgDTSProvider} */
|
|
661
690
|
#_dtsProv;// = null;
|
|
662
691
|
|
|
663
692
|
/**
|
|
664
693
|
* @param {object} obj
|
|
665
|
-
* @param {object} [opt]
|
|
694
|
+
* @param {object} [opt] - options
|
|
666
695
|
* @param {object} [opt.parseOptions]
|
|
667
696
|
* @description Creates an instance of the EPG-header element
|
|
668
697
|
*/
|
|
@@ -685,39 +714,41 @@ class TXEpgHeaderContainer {
|
|
|
685
714
|
// save content source
|
|
686
715
|
this.#_host = _host;
|
|
687
716
|
// init DTS-provider
|
|
688
|
-
this.#_dtsProv = new
|
|
717
|
+
this.#_dtsProv = new TXEpgDTSProvider(_host, _options);
|
|
689
718
|
}
|
|
690
719
|
|
|
691
720
|
/**
|
|
692
|
-
*
|
|
721
|
+
* Returns a `TXEpgDTSProvider` instance
|
|
722
|
+
* @property {TXEpgDTSProvider}
|
|
693
723
|
* @readonly
|
|
694
|
-
* @description Returns a `TXepgDTSProvider` instance
|
|
695
724
|
*/
|
|
696
|
-
get dts(){
|
|
725
|
+
get dts() {
|
|
697
726
|
return this.#_dtsProv;
|
|
698
727
|
}
|
|
699
728
|
|
|
700
729
|
/**
|
|
730
|
+
* Contains a dtstype ID
|
|
701
731
|
* @property {number}
|
|
702
|
-
* @
|
|
732
|
+
* @todo [since v0.0.22] becomes readonly
|
|
703
733
|
*/
|
|
704
|
-
get dtstype(){
|
|
734
|
+
get dtstype() {
|
|
705
735
|
return this.#_dtsProv.dtstype;
|
|
706
736
|
}
|
|
707
737
|
|
|
708
|
-
set dtstype(value){
|
|
738
|
+
set dtstype(value) {
|
|
709
739
|
this.#_dtsProv.dtstype = value;
|
|
710
740
|
}
|
|
711
741
|
|
|
712
742
|
/**
|
|
743
|
+
* Contains a TZ-offset
|
|
713
744
|
* @property {number}
|
|
714
|
-
* @
|
|
745
|
+
* @todo [since v0.0.22] becomes readonly
|
|
715
746
|
*/
|
|
716
|
-
get curDocTZ(){
|
|
747
|
+
get curDocTZ() {
|
|
717
748
|
return this.#_dtsProv.curDocTZ;
|
|
718
749
|
}
|
|
719
750
|
|
|
720
|
-
set curDocTZ(value){
|
|
751
|
+
set curDocTZ(value) {
|
|
721
752
|
this.#_dtsProv.curDocTZ = value;
|
|
722
753
|
}
|
|
723
754
|
|
|
@@ -748,7 +779,7 @@ class TXEpgHeaderContainer {
|
|
|
748
779
|
* @readonly
|
|
749
780
|
* @description Returns a `TXEpgProviderContainer` instance
|
|
750
781
|
*/
|
|
751
|
-
get Provider(){
|
|
782
|
+
get Provider() {
|
|
752
783
|
const docProv = this.#_getProv();
|
|
753
784
|
return (
|
|
754
785
|
docProv
|
|
@@ -798,7 +829,7 @@ class TXEpgHeaderContainer {
|
|
|
798
829
|
}
|
|
799
830
|
|
|
800
831
|
/**
|
|
801
|
-
* @param {any} value
|
|
832
|
+
* @param {any} value - document expire date
|
|
802
833
|
* @returns {void}
|
|
803
834
|
* @description Sets a document expire date to a given time
|
|
804
835
|
*/
|
|
@@ -813,15 +844,6 @@ class TXEpgHeaderContainer {
|
|
|
813
844
|
if (item) writeXObjParam(item, dt_str);
|
|
814
845
|
}
|
|
815
846
|
|
|
816
|
-
/**
|
|
817
|
-
* @typedef {Object} xepgChnInfoDesc
|
|
818
|
-
* @property {string} chnid - channel ID
|
|
819
|
-
* @property {string} chngid - channel 'Group ID'
|
|
820
|
-
* @property {string} chname - channel name
|
|
821
|
-
* @property {string} srcurl - EPG-source URL
|
|
822
|
-
* @description Contains a channel description
|
|
823
|
-
*/
|
|
824
|
-
|
|
825
847
|
/**
|
|
826
848
|
* @returns {xepgChnInfoDesc}
|
|
827
849
|
* @description Returns a channel info
|
|
@@ -839,22 +861,25 @@ class TXEpgHeaderContainer {
|
|
|
839
861
|
}
|
|
840
862
|
|
|
841
863
|
/**
|
|
842
|
-
* @param {
|
|
864
|
+
* @param {xepgChnInfoDesc} obj - channel info descriptor
|
|
843
865
|
* @returns {void}
|
|
844
866
|
* @description Sets a channel info
|
|
867
|
+
* @todo [since v0.0.21] deprecate use of `obj`-param as array
|
|
845
868
|
*/
|
|
846
|
-
setChannelInfo(obj){
|
|
869
|
+
setChannelInfo(obj) {
|
|
847
870
|
let chnid = '';
|
|
848
871
|
let chname = '';
|
|
849
872
|
let chngid = '';
|
|
850
873
|
let srcurl = '';
|
|
851
874
|
if (isArray(obj)) {
|
|
875
|
+
// // TODO: [!] deprecate
|
|
852
876
|
[ chnid, chname, chngid, srcurl ] = obj;
|
|
853
877
|
} else if (isObject(obj)) {
|
|
854
878
|
({ chnid } = obj);
|
|
855
879
|
if (typeof chnid === 'string') {
|
|
856
880
|
({ chname, chngid, srcurl } = obj);
|
|
857
881
|
} else {
|
|
882
|
+
// // TODO: [?] deprecate
|
|
858
883
|
chnid = _getXmlChildElementParam(obj, XEPG_CHNID_ETAG_NAME).trim();
|
|
859
884
|
chname = _getXmlChildElementParam(obj, XEPG_CHNNAME_ETAG_NAME).trim();
|
|
860
885
|
chngid = _getXmlChildElementParam(obj, XEPG_CHNGID_ETAG_NAME).trim();
|
|
@@ -888,7 +913,7 @@ class TXEpgHeaderContainer {
|
|
|
888
913
|
}
|
|
889
914
|
|
|
890
915
|
/**
|
|
891
|
-
* @returns {?
|
|
916
|
+
* @returns {?xepgProvInfoDesc}
|
|
892
917
|
* @description Returns a provider info
|
|
893
918
|
*/
|
|
894
919
|
getProviderInfo(){
|
|
@@ -897,7 +922,7 @@ class TXEpgHeaderContainer {
|
|
|
897
922
|
}
|
|
898
923
|
|
|
899
924
|
/**
|
|
900
|
-
* @param {
|
|
925
|
+
* @param {xepgProvInfoDesc} obj - provider info descriptor
|
|
901
926
|
* @returns {void}
|
|
902
927
|
* @description Sets a provider info
|
|
903
928
|
*/
|
|
@@ -935,6 +960,17 @@ class TXEpgHeaderContainer {
|
|
|
935
960
|
|
|
936
961
|
};
|
|
937
962
|
|
|
963
|
+
/**
|
|
964
|
+
* @typedef {Object} fsoDescr
|
|
965
|
+
* @property {boolean} isERR - flag
|
|
966
|
+
* @property {number} [errCode] - error code
|
|
967
|
+
* @property {string} errEvent - event ID
|
|
968
|
+
* @property {string} errMsg - event message
|
|
969
|
+
* @property {string} source - path to file
|
|
970
|
+
* @property {any} content - file content
|
|
971
|
+
* @description A fs ops description.
|
|
972
|
+
*/
|
|
973
|
+
|
|
938
974
|
/**
|
|
939
975
|
* @classdesc This class implements an interface of the container
|
|
940
976
|
* that manages a content of a XEPG-document
|
|
@@ -948,7 +984,7 @@ class TXEpgContentProvider {
|
|
|
948
984
|
#_parseOptions;// = null;
|
|
949
985
|
|
|
950
986
|
/**
|
|
951
|
-
* @param {object} [opt]
|
|
987
|
+
* @param {object} [opt] - options
|
|
952
988
|
* @param {object} [opt.parseOptions]
|
|
953
989
|
* @param {boolean} [opt.autoBindRoot] - <*reserved*> ([?] - deprecate)
|
|
954
990
|
* @description Creates an instance of the XEPG-content provider
|
|
@@ -988,7 +1024,7 @@ class TXEpgContentProvider {
|
|
|
988
1024
|
* @returns {?object}
|
|
989
1025
|
* @private
|
|
990
1026
|
*/
|
|
991
|
-
#_initRoot(){
|
|
1027
|
+
#_initRoot() {
|
|
992
1028
|
const _content = this.#_content;
|
|
993
1029
|
let docRoot = getXObjElement(_content, XEPG_ROOT_ETAG_NAME);
|
|
994
1030
|
if (!docRoot) {
|
|
@@ -1017,7 +1053,7 @@ class TXEpgContentProvider {
|
|
|
1017
1053
|
* @returns {?object}
|
|
1018
1054
|
* @private
|
|
1019
1055
|
*/
|
|
1020
|
-
#_initHdr(){
|
|
1056
|
+
#_initHdr() {
|
|
1021
1057
|
let docHdr = this.#_getHdr();
|
|
1022
1058
|
if (!docHdr) {
|
|
1023
1059
|
let docRoot = this.#_getRoot();
|
|
@@ -1046,7 +1082,7 @@ class TXEpgContentProvider {
|
|
|
1046
1082
|
* @returns {?object}
|
|
1047
1083
|
* @private
|
|
1048
1084
|
*/
|
|
1049
|
-
#_initBody(){
|
|
1085
|
+
#_initBody() {
|
|
1050
1086
|
let docBody = this.#_getBody();
|
|
1051
1087
|
if (!docBody) {
|
|
1052
1088
|
let docRoot = this.#_getRoot();
|
|
@@ -1059,9 +1095,9 @@ class TXEpgContentProvider {
|
|
|
1059
1095
|
}
|
|
1060
1096
|
|
|
1061
1097
|
/**
|
|
1098
|
+
* Returns a `TXEpgHeaderContainer` instance
|
|
1062
1099
|
* @property {?TXEpgHeaderContainer}
|
|
1063
1100
|
* @readonly
|
|
1064
|
-
* @description Returns a `TXEpgHeaderContainer` instance
|
|
1065
1101
|
*/
|
|
1066
1102
|
get Header() {
|
|
1067
1103
|
const docHdr = this.#_getHdr();
|
|
@@ -1073,21 +1109,21 @@ class TXEpgContentProvider {
|
|
|
1073
1109
|
}
|
|
1074
1110
|
|
|
1075
1111
|
/**
|
|
1112
|
+
* Returns a `TXEpgProviderContainer` instance
|
|
1076
1113
|
* @property {?TXEpgProviderContainer}
|
|
1077
1114
|
* @readonly
|
|
1078
|
-
* @description Returns a `TXEpgProviderContainer` instance
|
|
1079
1115
|
*/
|
|
1080
|
-
get Provider(){
|
|
1116
|
+
get Provider() {
|
|
1081
1117
|
const docHdr = this.Header;
|
|
1082
1118
|
return docHdr ? docHdr.Provider : null;
|
|
1083
1119
|
}
|
|
1084
1120
|
|
|
1085
1121
|
/**
|
|
1086
|
-
*
|
|
1122
|
+
* Returns a `TXEpgDTSProvider` instance
|
|
1123
|
+
* @property {?TXEpgDTSProvider}
|
|
1087
1124
|
* @readonly
|
|
1088
|
-
* @description Returns a `TXepgDTSProvider` instance
|
|
1089
1125
|
*/
|
|
1090
|
-
get dts(){
|
|
1126
|
+
get dts() {
|
|
1091
1127
|
const docHdr = this.Header;
|
|
1092
1128
|
return docHdr ? docHdr.dts : null;
|
|
1093
1129
|
}
|
|
@@ -1099,11 +1135,11 @@ class TXEpgContentProvider {
|
|
|
1099
1135
|
get Content(){ return this; }
|
|
1100
1136
|
|
|
1101
1137
|
/**
|
|
1138
|
+
* Returns a `TXEpgSchedulesList` instance
|
|
1102
1139
|
* @property {TXEpgSchedulesList}
|
|
1103
1140
|
* @readonly
|
|
1104
|
-
* @description Returns a `TXEpgSchedulesList` instance
|
|
1105
1141
|
*/
|
|
1106
|
-
get SchedulesList(){
|
|
1142
|
+
get SchedulesList() {
|
|
1107
1143
|
const _options = this.#_options;
|
|
1108
1144
|
const docBody = this.#_getBody();
|
|
1109
1145
|
if (docBody && isArray(docBody[XEPG_SCHED_ETAG_NAME])) {
|
|
@@ -1121,7 +1157,7 @@ class TXEpgContentProvider {
|
|
|
1121
1157
|
/**
|
|
1122
1158
|
* @returns {void}
|
|
1123
1159
|
*/
|
|
1124
|
-
init(){
|
|
1160
|
+
init() {
|
|
1125
1161
|
const _options = this.#_options;
|
|
1126
1162
|
const _content = this.#_content;
|
|
1127
1163
|
const {
|
|
@@ -1172,20 +1208,9 @@ class TXEpgContentProvider {
|
|
|
1172
1208
|
return result;
|
|
1173
1209
|
}
|
|
1174
1210
|
|
|
1175
|
-
/**
|
|
1176
|
-
* @typedef {Object} fsoDescr
|
|
1177
|
-
* @property {boolean} isERR - flag
|
|
1178
|
-
* @property {number|undefined} errCode - error code
|
|
1179
|
-
* @property {string} errEvent - event ID
|
|
1180
|
-
* @property {string} errMsg - event message
|
|
1181
|
-
* @property {string} source - path to file
|
|
1182
|
-
* @property {any} content - file content
|
|
1183
|
-
* @description A fs ops description.
|
|
1184
|
-
*/
|
|
1185
|
-
|
|
1186
1211
|
/**
|
|
1187
1212
|
* @param {string} source - a path to a file
|
|
1188
|
-
* @returns {fsoDescr}
|
|
1213
|
+
* @returns {Promise<fsoDescr, Error>}
|
|
1189
1214
|
* @throws {Error}
|
|
1190
1215
|
* @async
|
|
1191
1216
|
* @description Saves a document content to a file.
|
|
@@ -1299,7 +1324,7 @@ class TXEpgContentProvider {
|
|
|
1299
1324
|
|
|
1300
1325
|
/**
|
|
1301
1326
|
* @param {string} source - path to a file
|
|
1302
|
-
* @returns {fsoDescr}
|
|
1327
|
+
* @returns {Promise<fsoDescr, Error>}
|
|
1303
1328
|
* @throws {Error}
|
|
1304
1329
|
* @async
|
|
1305
1330
|
* @description Loads a document content from a file.
|
|
@@ -1357,19 +1382,10 @@ class TXEpgContentProvider {
|
|
|
1357
1382
|
return data;
|
|
1358
1383
|
}
|
|
1359
1384
|
|
|
1360
|
-
// will deprecate
|
|
1361
|
-
/**
|
|
1362
|
-
* @deprecated
|
|
1363
|
-
*/
|
|
1364
|
-
asXML(opt){
|
|
1365
|
-
let parseOptions = isPlainObject(opt) ? opt : defParseOptions.js2xml;
|
|
1366
|
-
return xmlParser.js2xml(this.#_content, parseOptions);
|
|
1367
|
-
}
|
|
1368
|
-
|
|
1369
1385
|
/**
|
|
1370
1386
|
* @protected
|
|
1371
1387
|
*/
|
|
1372
|
-
asJSON(){
|
|
1388
|
+
asJSON() {
|
|
1373
1389
|
return JSON.stringify(this.#_content, null, 2);
|
|
1374
1390
|
}
|
|
1375
1391
|
|
|
@@ -1377,7 +1393,7 @@ class TXEpgContentProvider {
|
|
|
1377
1393
|
|
|
1378
1394
|
// === module exports block ===
|
|
1379
1395
|
|
|
1380
|
-
exports.
|
|
1396
|
+
exports.TXEpgDTSProvider = TXEpgDTSProvider;
|
|
1381
1397
|
exports.TXEpgSchedulesList = TXEpgSchedulesList;
|
|
1382
1398
|
exports.TXEpgProviderContainer = TXEpgProviderContainer;
|
|
1383
1399
|
exports.TXEpgHeaderContainer = TXEpgHeaderContainer;
|
|
@@ -1387,3 +1403,6 @@ exports.XEPG_DEF_PROVIDER_NAME = XEPG_DEF_PROVIDER_NAME;
|
|
|
1387
1403
|
exports.XEPG_DEF_PROVIDER_VER = XEPG_DEF_PROVIDER_VER;
|
|
1388
1404
|
exports.XEPG_DEF_DOCUMENT_TYPE = XEPG_DEF_DOCUMENT_TYPE;
|
|
1389
1405
|
exports.XEPG_DEF_DOCUMENT_SCHEMA = XEPG_DEF_DOCUMENT_SCHEMA;
|
|
1406
|
+
|
|
1407
|
+
/** @deprecated */
|
|
1408
|
+
exports.TXepgDTSProvider = TXEpgDTSProvider;
|