@ygracs/xepg-lib-js 0.0.27-b → 0.0.30
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 +10 -5
- package/README.md +4 -2
- package/doc/xepgdoc-lib.md +14 -7
- package/index.d.ts +5 -1
- package/index.js +12 -3
- package/lib/dts-helper.d.ts +19 -3
- package/lib/dts-helper.js +69 -39
- package/lib/xepg-channel.d.ts +91 -0
- package/lib/xepg-channel.js +308 -0
- package/lib/xepg-defs.d.ts +67 -0
- package/lib/xepg-defs.js +88 -0
- package/lib/xepg-sched.d.ts +231 -0
- package/lib/xepg-sched.js +587 -0
- package/lib/xepgdoc-lib.d.ts +87 -339
- package/lib/xepgdoc-lib.js +102 -883
- package/lib/xml-base.d.ts +19 -0
- package/lib/xml-base.js +99 -1
- package/package.json +10 -7
package/lib/xepgdoc-lib.js
CHANGED
|
@@ -1,24 +1,23 @@
|
|
|
1
|
-
// [v0.3.
|
|
1
|
+
// [v0.3.153-20260612]
|
|
2
2
|
|
|
3
3
|
// === module init block ===
|
|
4
4
|
|
|
5
5
|
const xmlParser = require('@ygracs/xml-js6');
|
|
6
6
|
|
|
7
7
|
const {
|
|
8
|
-
|
|
9
|
-
readAsString, readAsNumber,
|
|
8
|
+
readAsString,
|
|
10
9
|
isNotEmptyString,
|
|
11
10
|
isArray, isObject, isPlainObject,
|
|
12
11
|
} = require('@ygracs/bsfoc-lib-js');
|
|
13
12
|
|
|
14
13
|
const {
|
|
15
14
|
convValueToTZString, convTZStringToValue,
|
|
16
|
-
tryDTValue,
|
|
17
15
|
} = require('@ygracs/dtf-lib-js');
|
|
18
16
|
|
|
19
17
|
const {
|
|
20
|
-
|
|
18
|
+
getDTSysDescr,
|
|
21
19
|
convStringToDTValue, convDTValueToString,
|
|
20
|
+
_getDTSTypeValueForXObj,
|
|
22
21
|
} = require('./dts-helper.js');
|
|
23
22
|
|
|
24
23
|
const {
|
|
@@ -40,115 +39,58 @@ const {
|
|
|
40
39
|
} = xObj;
|
|
41
40
|
// keep the next line for a type checking work properly :(
|
|
42
41
|
const { TXmlContentParseOptions } = require('@ygracs/xobj-lib-js/lib/xObj-defs');
|
|
42
|
+
// keep the next line for a type checking work properly :(
|
|
43
|
+
const { INode } = require('@ygracs/xobj-lib-js/lib/xObj-lib');
|
|
43
44
|
|
|
44
45
|
const {
|
|
45
|
-
readAsTagName,
|
|
46
|
-
readAsAttrName,
|
|
47
|
-
valueToElementID,
|
|
46
|
+
//readAsTagName,
|
|
47
|
+
//readAsAttrName,
|
|
48
|
+
//valueToElementID,
|
|
49
|
+
serializeXObjToXMLString, deserializeXObjFromXMLString,
|
|
50
|
+
_getXmlChildElementParam,
|
|
48
51
|
} = require('./xml-base');
|
|
49
52
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
*/
|
|
55
|
-
|
|
56
|
-
function readXObjParam(obj){
|
|
57
|
-
return xObj.readXObjParam(obj, defParseOptions.settings.textKey);
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
/*
|
|
61
|
-
* === xObj-function wrappers (end) ===
|
|
62
|
-
*/
|
|
53
|
+
const {
|
|
54
|
+
XEPG_CONSTANTS, XEPG_DEF_TNAMES,
|
|
55
|
+
defParseOptionsSettings,
|
|
56
|
+
} = require('./xepg-defs');
|
|
63
57
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
58
|
+
const {
|
|
59
|
+
TXEpgSchedulesList,
|
|
60
|
+
} = require('./xepg-sched');
|
|
67
61
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
*
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
*/
|
|
74
|
-
function _getXmlChildElementParam(obj, name) {
|
|
75
|
-
const child = obj ? getXObjElement(obj, name) : null;
|
|
76
|
-
return child ? readXObjParam(child) : '';
|
|
77
|
-
};
|
|
62
|
+
const {
|
|
63
|
+
TXEpgChannelContainer,
|
|
64
|
+
// * import types definitions *
|
|
65
|
+
IXEpgChnInfoDesc,
|
|
66
|
+
} = require('./xepg-channel');
|
|
78
67
|
|
|
79
|
-
|
|
80
|
-
* @param {object} obj - element
|
|
81
|
-
* @returns {number}
|
|
82
|
-
* @inner
|
|
83
|
-
*/
|
|
84
|
-
function _getDTSTypeValueForXObj(obj) {
|
|
85
|
-
const result = valueToIndex(
|
|
86
|
-
_getXmlChildElementParam(obj, 'value')
|
|
87
|
-
);
|
|
88
|
-
return chkDTSysID(result) ? result : 0; //-1; // // TODO: [?]
|
|
89
|
-
};
|
|
68
|
+
// === module inner block ===
|
|
90
69
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
function serializeXObjToXMLString(node, opt, tagName) {
|
|
102
|
-
let result = '';
|
|
103
|
-
try {
|
|
104
|
-
result = xmlParser.js2xml({ [tagName]: node }, opt);
|
|
105
|
-
} catch (err) {
|
|
106
|
-
//console.log('CHECK: serializeXObjToXMLString() => Error => '+err);
|
|
107
|
-
result = '';
|
|
108
|
-
//throw err;
|
|
109
|
-
};
|
|
110
|
-
return result;
|
|
111
|
-
};
|
|
70
|
+
const {
|
|
71
|
+
XEPG_DEF_NS_NAME,
|
|
72
|
+
XEPG_DEF_NS_PATH,
|
|
73
|
+
XEPG_XML_DOC_VERSION,
|
|
74
|
+
XEPG_DEF_ENCODING_VALUE,
|
|
75
|
+
XEPG_DEF_DOCUMENT_TYPE,
|
|
76
|
+
XEPG_DEF_DOCUMENT_SCHEMA,
|
|
77
|
+
XEPG_DEF_PROVIDER_NAME,
|
|
78
|
+
XEPG_DEF_PROVIDER_VER,
|
|
79
|
+
} = XEPG_CONSTANTS;
|
|
112
80
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
function deserializeXObjFromXMLString(node, opt, text, tagName) {
|
|
127
|
-
let result = false;
|
|
128
|
-
if (typeof text === 'string' && text !== '') {
|
|
129
|
-
try {
|
|
130
|
-
let obj = xmlParser.xml2js(text, opt);
|
|
131
|
-
if (isPlainObject(obj)) {
|
|
132
|
-
obj = obj[tagName];
|
|
133
|
-
if (isPlainObject(obj)) {
|
|
134
|
-
for (let prop in node) {
|
|
135
|
-
// // TODO: catch errors in strict mode
|
|
136
|
-
delete node[prop];
|
|
137
|
-
};
|
|
138
|
-
(Object.entries(obj)).forEach(([key, value]) => {
|
|
139
|
-
node[key] = value;
|
|
140
|
-
});
|
|
141
|
-
result = true;
|
|
142
|
-
};
|
|
143
|
-
};
|
|
144
|
-
} catch (err) {
|
|
145
|
-
//console.log('CHECK: deserializeXObjFromXMLString() => Error => '+err);
|
|
146
|
-
//console.log('CHECK: deserializeXObjFromXMLString() => Error => '+err.code);
|
|
147
|
-
throw err;
|
|
148
|
-
};
|
|
149
|
-
};
|
|
150
|
-
return result;
|
|
151
|
-
};
|
|
81
|
+
const {
|
|
82
|
+
XEPG_ROOT_ETAG_NAME,
|
|
83
|
+
XEPG_HEADER_ETAG_NAME,
|
|
84
|
+
XEPG_BODY_ETAG_NAME,
|
|
85
|
+
XEPG_SCHED_ETAG_NAME,
|
|
86
|
+
XEPG_PRVINFO_ETAG_NAME,
|
|
87
|
+
XEPG_DTSINFO_ETAG_NAME,
|
|
88
|
+
XEPG_DOCDTO_ETAG_NAME,
|
|
89
|
+
XEPG_DOCDTE_ETAG_NAME,
|
|
90
|
+
XEPG_DOCTZ_ETAG_NAME,
|
|
91
|
+
XEPG_DOCSCH_ETAG_NAME,
|
|
92
|
+
XEPG_DOCTYP_ETAG_NAME,
|
|
93
|
+
} = XEPG_DEF_TNAMES;
|
|
152
94
|
|
|
153
95
|
/**
|
|
154
96
|
* An XEPG-element options set (base)
|
|
@@ -188,40 +130,6 @@ function __evalXMLBaseNodeSettings(value) {
|
|
|
188
130
|
const XML_TE_INVARG_EMSG = 'invalid argument';
|
|
189
131
|
const XML_TE_NOBJ_EMSG = `${XML_TE_INVARG_EMSG} (an object is expected)`;
|
|
190
132
|
|
|
191
|
-
/**
|
|
192
|
-
* A list of a document schema version supported by a library
|
|
193
|
-
*/
|
|
194
|
-
const ALLOWED_XEPG_DOCUMENT_SCHEMA = [ '0.2' ];
|
|
195
|
-
|
|
196
|
-
const XEPG_ROOT_ETAG_NAME = 'epgdoc';
|
|
197
|
-
const XEPG_DEF_NS_NAME = 'tvp';
|
|
198
|
-
const XEPG_DEF_NS_PATH = 'urn:e-doc:epg-doc:xepg';
|
|
199
|
-
const XEPG_HEADER_ETAG_NAME = `${XEPG_DEF_NS_NAME}:info`;
|
|
200
|
-
const XEPG_BODY_ETAG_NAME = `${XEPG_DEF_NS_NAME}:list`;
|
|
201
|
-
const XEPG_SCHED_ETAG_NAME = `${XEPG_DEF_NS_NAME}:item`;
|
|
202
|
-
const XEPG_PRVINFO_ETAG_NAME = `${XEPG_DEF_NS_NAME}:provider`;
|
|
203
|
-
const XEPG_DTSINFO_ETAG_NAME = `${XEPG_DEF_NS_NAME}:dtstype`;
|
|
204
|
-
const XEPG_DOCDTO_ETAG_NAME = `${XEPG_DEF_NS_NAME}:time`;
|
|
205
|
-
const XEPG_DOCDTE_ETAG_NAME = `${XEPG_DEF_NS_NAME}:expire`;
|
|
206
|
-
const XEPG_DOCTZ_ETAG_NAME = `${XEPG_DEF_NS_NAME}:timezone`;
|
|
207
|
-
const XEPG_DOCSCH_ETAG_NAME = `${XEPG_DEF_NS_NAME}:schema`;
|
|
208
|
-
const XEPG_DOCTYP_ETAG_NAME = `${XEPG_DEF_NS_NAME}:doctype`;
|
|
209
|
-
const XEPG_CHNID_ETAG_NAME = `${XEPG_DEF_NS_NAME}:chnid`;
|
|
210
|
-
const XEPG_CHNNAME_ETAG_NAME = `${XEPG_DEF_NS_NAME}:chname`;
|
|
211
|
-
const XEPG_CHNGID_ETAG_NAME = `${XEPG_DEF_NS_NAME}:chngid`;
|
|
212
|
-
const XEPG_CHNURL_ETAG_NAME = `${XEPG_DEF_NS_NAME}:srcurl`;
|
|
213
|
-
const XEPG_SCHEDTIME_ETAG_NAME = `${XEPG_DEF_NS_NAME}:time`;
|
|
214
|
-
const XEPG_SCHEDTITL_ETAG_NAME = `${XEPG_DEF_NS_NAME}:title`;
|
|
215
|
-
const XEPG_SCHEDCAT_ETAG_NAME = `${XEPG_DEF_NS_NAME}:cat`;
|
|
216
|
-
const XEPG_SCHEDPMARK_ETAG_NAME = `${XEPG_DEF_NS_NAME}:pcmark`;
|
|
217
|
-
const XEPG_SCHEDDESC_ETAG_NAME = `${XEPG_DEF_NS_NAME}:desc`;
|
|
218
|
-
const XEPG_XML_DOC_VERSION = '1.0';
|
|
219
|
-
const XEPG_DEF_ENCODING_VALUE = 'UTF-8';
|
|
220
|
-
const XEPG_DEF_DOCUMENT_TYPE = 'xepg';
|
|
221
|
-
const XEPG_DEF_DOCUMENT_SCHEMA = ALLOWED_XEPG_DOCUMENT_SCHEMA[0];
|
|
222
|
-
const XEPG_DEF_PROVIDER_NAME = 'xepg-lib-js';
|
|
223
|
-
const XEPG_DEF_PROVIDER_VER = '0.0.21';
|
|
224
|
-
|
|
225
133
|
const defXEpgDocOptions = {
|
|
226
134
|
xmlns_xepg_pref: XEPG_DEF_NS_NAME,
|
|
227
135
|
xmlns_xepg_path: XEPG_DEF_NS_PATH,
|
|
@@ -240,517 +148,37 @@ const defXEpgDocOptions = {
|
|
|
240
148
|
},
|
|
241
149
|
};
|
|
242
150
|
|
|
243
|
-
const defParseOptions = new TXmlContentParseOptions();
|
|
244
|
-
//console.log('CHECK: defParseOptions => '+JSON.stringify(defParseOptions, null, 2));
|
|
245
|
-
|
|
246
|
-
/***
|
|
247
|
-
* (* function definitions *)
|
|
248
|
-
*/
|
|
249
|
-
|
|
250
|
-
/***
|
|
251
|
-
* (* class definitions *)
|
|
252
|
-
*/
|
|
253
|
-
|
|
254
|
-
/**
|
|
255
|
-
* A schedule info descriptor
|
|
256
|
-
* @typedef {Object} xepgShedInfoDesc
|
|
257
|
-
* @property {number} time - a schedule start time
|
|
258
|
-
* @property {string} title - schedule title
|
|
259
|
-
* @property {string} [cat] - schedule category
|
|
260
|
-
* @property {number} [pcmark] - schedule rating
|
|
261
|
-
* @property {string} [descr] - schedule description
|
|
262
|
-
*/
|
|
263
|
-
|
|
264
|
-
/**
|
|
265
|
-
* An extra options set
|
|
266
|
-
* @typedef {Object} OPT_extra
|
|
267
|
-
* @property {object} [dts_src] - 'DTS'-settings
|
|
268
|
-
* @property {object} [tz_src] - 'TZ'-settings
|
|
269
|
-
*/
|
|
270
|
-
|
|
271
|
-
/**
|
|
272
|
-
* An XEPG-element options set (extend)
|
|
273
|
-
* @typedef {Object} OPT_epgelsett_ex
|
|
274
|
-
* @property {TXmlContentParseOptions} [parseOptions] - parser options
|
|
275
|
-
* @property {object} [dts_src]
|
|
276
|
-
* @property {object} [tz_src]
|
|
277
|
-
*/
|
|
278
|
-
|
|
279
151
|
/**
|
|
280
|
-
*
|
|
281
|
-
* @
|
|
152
|
+
* A list of fields in order: `name`, `version`, `schema`, `doctype`
|
|
153
|
+
* @typedef {string[]} arrProviderInfo
|
|
154
|
+
* @deprecated
|
|
155
|
+
* @todo \[since v0.0.21] deprecated and will be removed
|
|
282
156
|
*/
|
|
283
|
-
class TXEpgScheduleItem {
|
|
284
|
-
/** @type {object} */
|
|
285
|
-
#_host;
|
|
286
|
-
/** @type {OPT_epgelsett_ex} */
|
|
287
|
-
#_options;
|
|
288
|
-
/** @type {TXmlContentParseOptions} */
|
|
289
|
-
#_parseOptions;
|
|
290
|
-
/** @type {?object} */
|
|
291
|
-
#_dts_src = null;
|
|
292
|
-
/** @type {?object} */
|
|
293
|
-
#_tz_src = null;
|
|
294
|
-
|
|
295
|
-
/**
|
|
296
|
-
* Creates an instance of the EPG-schedule element
|
|
297
|
-
* @param {object} obj - host object
|
|
298
|
-
* @param {OPT_epgelsett_ex} [opt] - options
|
|
299
|
-
* @param {OPT_extra} [extra] - \[since `v0.0.24`] extra options
|
|
300
|
-
*/
|
|
301
|
-
constructor(obj, opt, extra) {
|
|
302
|
-
// load content
|
|
303
|
-
const _host = isPlainObject(obj) ? obj : {};
|
|
304
|
-
// load options
|
|
305
|
-
/** @type {OPT_epgelsett_ex} */
|
|
306
|
-
const _options = isPlainObject(opt) ? opt : {};
|
|
307
|
-
let {
|
|
308
|
-
parseOptions,
|
|
309
|
-
} = _options;
|
|
310
|
-
if (!(parseOptions instanceof TXmlContentParseOptions)) {
|
|
311
|
-
parseOptions = new TXmlContentParseOptions(parseOptions);
|
|
312
|
-
_options.parseOptions = parseOptions;
|
|
313
|
-
};
|
|
314
|
-
let {
|
|
315
|
-
dts_src = _options.dts_src,
|
|
316
|
-
tz_src = _options.tz_src,
|
|
317
|
-
} = isPlainObject(extra) ? extra : {};
|
|
318
|
-
if (!isPlainObject(dts_src)) dts_src = null;
|
|
319
|
-
if (!isPlainObject(tz_src)) tz_src = null;
|
|
320
|
-
// save content source
|
|
321
|
-
this.#_host = _host;
|
|
322
|
-
// save options
|
|
323
|
-
this.#_options = _options;
|
|
324
|
-
// save parser options
|
|
325
|
-
this.#_parseOptions = parseOptions;
|
|
326
|
-
// save refs to a time source priveders
|
|
327
|
-
this.#_dts_src = dts_src;
|
|
328
|
-
this.#_tz_src = tz_src;
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
/**
|
|
332
|
-
* Contains a dtstype ID
|
|
333
|
-
* @type {number}
|
|
334
|
-
* @readonly
|
|
335
|
-
*/
|
|
336
|
-
get dtstype() {
|
|
337
|
-
return _getDTSTypeValueForXObj(this.#_dts_src);
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
/**
|
|
341
|
-
* Contains a TZ-offset
|
|
342
|
-
* @type {number}
|
|
343
|
-
* @readonly
|
|
344
|
-
*/
|
|
345
|
-
get curDocTZ() {
|
|
346
|
-
return (
|
|
347
|
-
this.#_tz_src
|
|
348
|
-
? convTZStringToValue(readXObjParam(this.#_tz_src).trim())
|
|
349
|
-
: 0
|
|
350
|
-
);
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
/**
|
|
354
|
-
* Contains a schedule start time as a timestamp
|
|
355
|
-
* @type {number}
|
|
356
|
-
* @readonly
|
|
357
|
-
*/
|
|
358
|
-
get time() {
|
|
359
|
-
return convStringToDTValue(
|
|
360
|
-
_getXmlChildElementParam(this.#_host, XEPG_SCHEDTIME_ETAG_NAME).trim(),
|
|
361
|
-
this.dtstype, this.curDocTZ
|
|
362
|
-
);
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
/**
|
|
366
|
-
* Contains a schedule title
|
|
367
|
-
* @type {string}
|
|
368
|
-
* @readonly
|
|
369
|
-
*/
|
|
370
|
-
get title() {
|
|
371
|
-
return _getXmlChildElementParam(this.#_host, XEPG_SCHEDTITL_ETAG_NAME).trim();
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
/**
|
|
375
|
-
* Contains a schedule category
|
|
376
|
-
* @type {string}
|
|
377
|
-
* @readonly
|
|
378
|
-
*/
|
|
379
|
-
get category() {
|
|
380
|
-
return _getXmlChildElementParam(this.#_host, XEPG_SCHEDCAT_ETAG_NAME).trim();
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
/**
|
|
384
|
-
* Contains a schedule rating value (aka pcmark)
|
|
385
|
-
* @type {number}
|
|
386
|
-
* @readonly
|
|
387
|
-
*/
|
|
388
|
-
get rating() {
|
|
389
|
-
return readAsNumber(
|
|
390
|
-
_getXmlChildElementParam(this.#_host, XEPG_SCHEDPMARK_ETAG_NAME), 0
|
|
391
|
-
);
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
/**
|
|
395
|
-
* Contains a schedule description
|
|
396
|
-
* @type {string}
|
|
397
|
-
* @readonly
|
|
398
|
-
*/
|
|
399
|
-
get descr() {
|
|
400
|
-
return _getXmlChildElementParam(this.#_host, XEPG_SCHEDDESC_ETAG_NAME);
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
/**
|
|
404
|
-
* Returns a schedule info item descriptor
|
|
405
|
-
* @returns {xepgShedInfoDesc}
|
|
406
|
-
*/
|
|
407
|
-
getInfo() {
|
|
408
|
-
const {
|
|
409
|
-
time,
|
|
410
|
-
title,
|
|
411
|
-
category: cat,
|
|
412
|
-
rating: pcmark,
|
|
413
|
-
descr,
|
|
414
|
-
} = this;
|
|
415
|
-
return {
|
|
416
|
-
time,
|
|
417
|
-
title,
|
|
418
|
-
cat,
|
|
419
|
-
pcmark,
|
|
420
|
-
descr,
|
|
421
|
-
};
|
|
422
|
-
}
|
|
423
|
-
|
|
424
|
-
/**
|
|
425
|
-
* Sets a schedule start time.
|
|
426
|
-
* @param {(number|string|Date)} value - some time value
|
|
427
|
-
* @returns {boolean}
|
|
428
|
-
*/
|
|
429
|
-
setTime(value) {
|
|
430
|
-
let { isSucceed, value: dtValue } = tryDTValue(value);
|
|
431
|
-
let result = false;
|
|
432
|
-
if (isSucceed && dtValue != null) {
|
|
433
|
-
const text = convDTValueToString(dtValue, this.dtstype, this.curDocTZ);
|
|
434
|
-
if (text !== '') {
|
|
435
|
-
const opt = { force: true };
|
|
436
|
-
const item = insertXObjElement(this.#_host, XEPG_SCHEDTIME_ETAG_NAME, opt);
|
|
437
|
-
if (item) {
|
|
438
|
-
result = writeXObjParam(item, text, defParseOptions.settings.textKey);
|
|
439
|
-
};
|
|
440
|
-
};
|
|
441
|
-
};
|
|
442
|
-
return result;
|
|
443
|
-
}
|
|
444
|
-
|
|
445
|
-
/**
|
|
446
|
-
* Sets a schedule title.
|
|
447
|
-
* @param {string} value - some title
|
|
448
|
-
* @returns {boolean}
|
|
449
|
-
*/
|
|
450
|
-
setTitle(value) {
|
|
451
|
-
let result = false;
|
|
452
|
-
if (typeof value === 'string') {
|
|
453
|
-
const opt = { force: true };
|
|
454
|
-
const item = insertXObjElement(this.#_host, XEPG_SCHEDTITL_ETAG_NAME, opt);
|
|
455
|
-
if (item) {
|
|
456
|
-
result = writeXObjParam(item, value.trim(), defParseOptions.settings.textKey);
|
|
457
|
-
};
|
|
458
|
-
};
|
|
459
|
-
return result;
|
|
460
|
-
}
|
|
461
|
-
|
|
462
|
-
/**
|
|
463
|
-
* Sets a schedule title.
|
|
464
|
-
* @param {string} value - some title
|
|
465
|
-
* @returns {boolean}
|
|
466
|
-
*/
|
|
467
|
-
setCategory(value) {
|
|
468
|
-
let result = false;
|
|
469
|
-
if (typeof value === 'string') {
|
|
470
|
-
const opt = { force: true };
|
|
471
|
-
const item = insertXObjElement(this.#_host, XEPG_SCHEDCAT_ETAG_NAME, opt);
|
|
472
|
-
if (item) {
|
|
473
|
-
result = writeXObjParam(item, value.trim(), defParseOptions.settings.textKey);
|
|
474
|
-
};
|
|
475
|
-
};
|
|
476
|
-
return result;
|
|
477
|
-
}
|
|
478
|
-
|
|
479
|
-
/**
|
|
480
|
-
* Sets a schedule rating value.
|
|
481
|
-
* @param {(number|string)} value - some value
|
|
482
|
-
* @returns {boolean}
|
|
483
|
-
*/
|
|
484
|
-
setRating(value) {
|
|
485
|
-
const _value = valueToIndex(value);
|
|
486
|
-
let result = false;
|
|
487
|
-
if (_value !== -1) {
|
|
488
|
-
const opt = { force: true };
|
|
489
|
-
const item = insertXObjElement(this.#_host, XEPG_SCHEDPMARK_ETAG_NAME, opt);
|
|
490
|
-
if (item) {
|
|
491
|
-
result = writeXObjParam(item, _value, defParseOptions.settings.textKey);
|
|
492
|
-
};
|
|
493
|
-
};
|
|
494
|
-
return result;
|
|
495
|
-
}
|
|
496
|
-
|
|
497
|
-
/**
|
|
498
|
-
* Sets a schedule description.
|
|
499
|
-
* @param {string} value - some text
|
|
500
|
-
* @returns {boolean}
|
|
501
|
-
*/
|
|
502
|
-
setDescr(value) {
|
|
503
|
-
let result = false;
|
|
504
|
-
if (typeof value === 'string') {
|
|
505
|
-
const opt = { force: true };
|
|
506
|
-
const item = insertXObjElement(this.#_host, XEPG_SCHEDDESC_ETAG_NAME, opt);
|
|
507
|
-
if (item) {
|
|
508
|
-
result = writeXObjParam(item, value.trim(), defParseOptions.settings.textKey);
|
|
509
|
-
};
|
|
510
|
-
};
|
|
511
|
-
return result;
|
|
512
|
-
}
|
|
513
|
-
|
|
514
|
-
/**
|
|
515
|
-
* Returns an instance content as a string in an XML-format.
|
|
516
|
-
* @returns {string}
|
|
517
|
-
*/
|
|
518
|
-
saveToXMLString() {
|
|
519
|
-
const options = this.#_parseOptions.js2xml;
|
|
520
|
-
options.ignoreDocType = true;
|
|
521
|
-
options.ignoreDeclaration = true;
|
|
522
|
-
return serializeXObjToXMLString(
|
|
523
|
-
this.#_host,
|
|
524
|
-
options,
|
|
525
|
-
XEPG_SCHED_ETAG_NAME,
|
|
526
|
-
);
|
|
527
|
-
}
|
|
528
|
-
|
|
529
|
-
/**
|
|
530
|
-
* Loads an element content from a string.
|
|
531
|
-
* @since v0.0.24
|
|
532
|
-
* @param {string} xmlString - some content
|
|
533
|
-
* @returns {boolean}
|
|
534
|
-
* @throws {Error}
|
|
535
|
-
* @experimental
|
|
536
|
-
*/
|
|
537
|
-
loadFromXMLString(xmlString) {
|
|
538
|
-
const options = this.#_parseOptions.xml2js;
|
|
539
|
-
options.ignoreDocType = true;
|
|
540
|
-
options.ignoreDeclaration = true;
|
|
541
|
-
return deserializeXObjFromXMLString(
|
|
542
|
-
this.#_host,
|
|
543
|
-
options,
|
|
544
|
-
xmlString,
|
|
545
|
-
XEPG_SCHED_ETAG_NAME,
|
|
546
|
-
);
|
|
547
|
-
}
|
|
548
|
-
|
|
549
|
-
};
|
|
550
|
-
|
|
551
157
|
/**
|
|
552
|
-
*
|
|
158
|
+
* A virtual constant meant for support jsdoc notation:
|
|
159
|
+
* @type {arrProviderInfo}
|
|
553
160
|
*/
|
|
554
|
-
|
|
555
|
-
/** @type {object[]} */
|
|
556
|
-
#_content;
|
|
557
|
-
/** @type {OPT_epgelsett_ex} */
|
|
558
|
-
#_options;
|
|
559
|
-
/** @type {?object} */
|
|
560
|
-
#_dts_src = null;
|
|
561
|
-
/** @type {?object} */
|
|
562
|
-
#_tz_src = null;
|
|
563
|
-
|
|
564
|
-
/**
|
|
565
|
-
* Creates an instance of the schedules list
|
|
566
|
-
* @param {any[]} obj - list of an elements
|
|
567
|
-
* @param {OPT_epgelsett_ex} [opt] - options
|
|
568
|
-
* @param {OPT_extra} [extra] - \[since `v0.0.24`] extra options
|
|
569
|
-
*/
|
|
570
|
-
constructor(obj, opt, extra) {
|
|
571
|
-
const _content = isArray(obj) ? obj : [];
|
|
572
|
-
/** @type {OPT_epgelsett_ex} */
|
|
573
|
-
const _options = isPlainObject(opt) ? opt : {};
|
|
574
|
-
let {
|
|
575
|
-
dts_src = _options.dts_src,
|
|
576
|
-
tz_src = _options.tz_src,
|
|
577
|
-
} = isPlainObject(extra) ? extra : {};
|
|
578
|
-
if (!isPlainObject(dts_src)) dts_src = null;
|
|
579
|
-
if (!isPlainObject(tz_src)) tz_src = null;
|
|
580
|
-
// save content source
|
|
581
|
-
this.#_content = _content;
|
|
582
|
-
// save options
|
|
583
|
-
this.#_options = _options;
|
|
584
|
-
// save refs to a time source priveders
|
|
585
|
-
this.#_dts_src = dts_src;
|
|
586
|
-
this.#_tz_src = tz_src;
|
|
587
|
-
}
|
|
588
|
-
|
|
589
|
-
[Symbol.iterator]() {
|
|
590
|
-
let index = 0;
|
|
591
|
-
return {
|
|
592
|
-
next: () => {
|
|
593
|
-
if (index < this.count) {
|
|
594
|
-
return { done: false, value: this.schedule(index++) };
|
|
595
|
-
} else {
|
|
596
|
-
return { done: true, value: undefined };
|
|
597
|
-
};
|
|
598
|
-
},
|
|
599
|
-
return() {
|
|
600
|
-
return { done: true, value: undefined };
|
|
601
|
-
},
|
|
602
|
-
};
|
|
603
|
-
}
|
|
604
|
-
|
|
605
|
-
/**
|
|
606
|
-
* Returns a raw schedule element
|
|
607
|
-
* @param {(number|string)} value - element index
|
|
608
|
-
* @returns {any}
|
|
609
|
-
*/
|
|
610
|
-
#_getItem = function(value) {
|
|
611
|
-
if (this.chkIndex(value)) {
|
|
612
|
-
return this.#_content[Number(value)];
|
|
613
|
-
};
|
|
614
|
-
};
|
|
615
|
-
|
|
616
|
-
/**
|
|
617
|
-
* Contains a quantity of a schedules
|
|
618
|
-
* @type {number}
|
|
619
|
-
* @readonly
|
|
620
|
-
* @deprecated
|
|
621
|
-
* @todo \[since `v0.0.24`] deprecated. Use `TXEpgSchedulesList.count`
|
|
622
|
-
*/
|
|
623
|
-
get schedQty() {
|
|
624
|
-
return this.#_content.length;
|
|
625
|
-
}
|
|
626
|
-
|
|
627
|
-
/**
|
|
628
|
-
* Contains a quantity of a schedules
|
|
629
|
-
* @since v0.0.24
|
|
630
|
-
* @type {number}
|
|
631
|
-
* @readonly
|
|
632
|
-
*/
|
|
633
|
-
get count() {
|
|
634
|
-
return this.#_content.length;
|
|
635
|
-
}
|
|
636
|
-
|
|
637
|
-
/**
|
|
638
|
-
* Contains a dtstype ID
|
|
639
|
-
* @type {number}
|
|
640
|
-
* @readonly
|
|
641
|
-
*/
|
|
642
|
-
get dtstype() {
|
|
643
|
-
return _getDTSTypeValueForXObj(this.#_dts_src);
|
|
644
|
-
}
|
|
645
|
-
|
|
646
|
-
/**
|
|
647
|
-
* Contains a TZ-offset
|
|
648
|
-
* @type {number}
|
|
649
|
-
* @readonly
|
|
650
|
-
*/
|
|
651
|
-
get curDocTZ() {
|
|
652
|
-
return (
|
|
653
|
-
this.#_tz_src
|
|
654
|
-
? convTZStringToValue(readXObjParam(this.#_tz_src).trim())
|
|
655
|
-
: 0
|
|
656
|
-
);
|
|
657
|
-
}
|
|
658
|
-
|
|
659
|
-
/**
|
|
660
|
-
* Indicates whether an instance has none member
|
|
661
|
-
* @since v0.0.24
|
|
662
|
-
* @returns {boolean}
|
|
663
|
-
*/
|
|
664
|
-
isEmpty() {
|
|
665
|
-
return this.count === 0;
|
|
666
|
-
}
|
|
667
|
-
|
|
668
|
-
/**
|
|
669
|
-
* Indicates whether an instance has any member
|
|
670
|
-
* @since v0.0.24
|
|
671
|
-
* @returns {boolean}
|
|
672
|
-
*/
|
|
673
|
-
isNotEmpty() {
|
|
674
|
-
return this.count > 0;
|
|
675
|
-
}
|
|
676
|
-
|
|
677
|
-
/**
|
|
678
|
-
* Checks whether a given value is a valid index and it fits the index range
|
|
679
|
-
* of an instance
|
|
680
|
-
* @since 0.0.20
|
|
681
|
-
* @param {(number|string)} value - index of some element
|
|
682
|
-
* @returns {boolean}
|
|
683
|
-
*/
|
|
684
|
-
chkIndex(value) {
|
|
685
|
-
const index = valueToIndex(value);
|
|
686
|
-
return index !== -1 && index < this.count;
|
|
687
|
-
}
|
|
688
|
-
|
|
689
|
-
/**
|
|
690
|
-
* Returns a schedule element addressed by a given index
|
|
691
|
-
* @since 0.0.22
|
|
692
|
-
* @param {(number|string)} index - index of some element
|
|
693
|
-
* @returns {?TXEpgScheduleItem}
|
|
694
|
-
*/
|
|
695
|
-
schedule(index) {
|
|
696
|
-
const curObj = this.#_getItem(index);
|
|
697
|
-
let item = null;
|
|
698
|
-
if (isPlainObject(curObj)) {
|
|
699
|
-
item = new TXEpgScheduleItem(curObj, {
|
|
700
|
-
dts_src: this.#_dts_src,
|
|
701
|
-
tz_src: this.#_tz_src,
|
|
702
|
-
});
|
|
703
|
-
};
|
|
704
|
-
return item;
|
|
705
|
-
}
|
|
706
|
-
|
|
707
|
-
/**
|
|
708
|
-
* Returns a schedule info item for instance element addressed
|
|
709
|
-
* by a given index
|
|
710
|
-
* @param {(number|string)} index - index of some element
|
|
711
|
-
* @returns {?xepgShedInfoDesc}
|
|
712
|
-
*/
|
|
713
|
-
getScheduleInfo(index) {
|
|
714
|
-
const obj = this.schedule(index);
|
|
715
|
-
return obj ? obj.getInfo() : null;
|
|
716
|
-
}
|
|
717
|
-
|
|
718
|
-
/**
|
|
719
|
-
* Returns a schedule info for instance members
|
|
720
|
-
* @returns {xepgShedInfoDesc[]}
|
|
721
|
-
*/
|
|
722
|
-
getAllSchedulesInfo() {
|
|
723
|
-
let result = [];
|
|
724
|
-
for (let i = 0; i < this.count; i++) {
|
|
725
|
-
let item = this.getScheduleInfo(i);
|
|
726
|
-
if (isPlainObject(item)) result.push(item);
|
|
727
|
-
};
|
|
728
|
-
return result;
|
|
729
|
-
}
|
|
730
|
-
|
|
731
|
-
/**
|
|
732
|
-
* @protected
|
|
733
|
-
*/
|
|
734
|
-
asJSON() {
|
|
735
|
-
return JSON.stringify(this.#_content, null, 2);
|
|
736
|
-
}
|
|
737
|
-
|
|
738
|
-
};
|
|
161
|
+
module.exports.arrProviderInfo = [];
|
|
739
162
|
|
|
740
163
|
/**
|
|
741
164
|
* A provider info descriptor
|
|
742
|
-
* @typedef {Object}
|
|
165
|
+
* @typedef {Object} IXEpgProvInfoDesc
|
|
743
166
|
* @property {string} [name] - provider name
|
|
744
167
|
* @property {string} [version] - provider version
|
|
745
168
|
* @property {string} schema - document schema
|
|
746
169
|
* @property {string} doctype - document type
|
|
747
170
|
*/
|
|
171
|
+
/**
|
|
172
|
+
* A virtual constant meant for support jsdoc notation:
|
|
173
|
+
* @type {IXEpgProvInfoDesc}
|
|
174
|
+
*/
|
|
175
|
+
module.exports.IXEpgProvInfoDesc = { schema: '', doctype: '' };
|
|
748
176
|
|
|
749
177
|
/**
|
|
750
178
|
* @classdesc This class implements an interface of a EPG-provider element
|
|
751
179
|
*/
|
|
752
180
|
class TXEpgProviderContainer {
|
|
753
|
-
/** @type {
|
|
181
|
+
/** @type {INode} */
|
|
754
182
|
#_host;
|
|
755
183
|
/** @type {OPT_epgelsett_bs} */
|
|
756
184
|
#_options;
|
|
@@ -759,7 +187,7 @@ class TXEpgProviderContainer {
|
|
|
759
187
|
|
|
760
188
|
/**
|
|
761
189
|
* Creates an instance of the EPG-provider element
|
|
762
|
-
* @param {
|
|
190
|
+
* @param {INode} obj - host object
|
|
763
191
|
* @param {OPT_epgelsett_bs} [opt] - options
|
|
764
192
|
*/
|
|
765
193
|
constructor(obj, opt) {
|
|
@@ -817,7 +245,7 @@ class TXEpgProviderContainer {
|
|
|
817
245
|
const opt = { force: true };
|
|
818
246
|
const item = insertXObjElement(this.#_host, 'version', opt);
|
|
819
247
|
if (item) {
|
|
820
|
-
writeXObjParam(item, value.trim(),
|
|
248
|
+
writeXObjParam(item, value.trim(), defParseOptionsSettings.textKey);
|
|
821
249
|
};
|
|
822
250
|
};
|
|
823
251
|
}
|
|
@@ -835,7 +263,7 @@ class TXEpgProviderContainer {
|
|
|
835
263
|
const opt = { force: true };
|
|
836
264
|
const item = insertXObjElement(this.#_host, XEPG_DOCSCH_ETAG_NAME, opt);
|
|
837
265
|
if (item) {
|
|
838
|
-
writeXObjParam(item, value.trim(),
|
|
266
|
+
writeXObjParam(item, value.trim(), defParseOptionsSettings.textKey);
|
|
839
267
|
};
|
|
840
268
|
};
|
|
841
269
|
}
|
|
@@ -853,7 +281,7 @@ class TXEpgProviderContainer {
|
|
|
853
281
|
const opt = { force: true };
|
|
854
282
|
const item = insertXObjElement(this.#_host, XEPG_DOCTYP_ETAG_NAME, opt);
|
|
855
283
|
if (item) {
|
|
856
|
-
writeXObjParam(item, value.trim(),
|
|
284
|
+
writeXObjParam(item, value.trim(), defParseOptionsSettings.textKey);
|
|
857
285
|
};
|
|
858
286
|
};
|
|
859
287
|
}
|
|
@@ -869,7 +297,7 @@ class TXEpgProviderContainer {
|
|
|
869
297
|
const name = value.trim();
|
|
870
298
|
const item = insertXObjElement(this.#_host, 'name', { force: true });
|
|
871
299
|
if (item) {
|
|
872
|
-
isSucceed = writeXObjParam(item, name,
|
|
300
|
+
isSucceed = writeXObjParam(item, name, defParseOptionsSettings.textKey);
|
|
873
301
|
};
|
|
874
302
|
};
|
|
875
303
|
return isSucceed;
|
|
@@ -877,7 +305,7 @@ class TXEpgProviderContainer {
|
|
|
877
305
|
|
|
878
306
|
/**
|
|
879
307
|
* Returns a provider info item
|
|
880
|
-
* @returns {
|
|
308
|
+
* @returns {IXEpgProvInfoDesc}
|
|
881
309
|
*/
|
|
882
310
|
getInfo() {
|
|
883
311
|
return {
|
|
@@ -890,7 +318,7 @@ class TXEpgProviderContainer {
|
|
|
890
318
|
|
|
891
319
|
/**
|
|
892
320
|
* Sets a provider info
|
|
893
|
-
* @param {
|
|
321
|
+
* @param {arrProviderInfo|IXEpgProvInfoDesc} obj - provider info descriptor
|
|
894
322
|
* @returns {void}
|
|
895
323
|
* @todo [since v0.0.21] deprecate use of `obj`-param as array
|
|
896
324
|
*/
|
|
@@ -927,20 +355,20 @@ class TXEpgProviderContainer {
|
|
|
927
355
|
|
|
928
356
|
/**
|
|
929
357
|
* Sets an initial instance state
|
|
930
|
-
* @param {
|
|
358
|
+
* @param {arrProviderInfo|IXEpgProvInfoDesc} [data] - options
|
|
931
359
|
* @returns {void}
|
|
360
|
+
* @todo [since v0.0.30] deprecate use of `obj`-param as array
|
|
932
361
|
*/
|
|
933
|
-
init(
|
|
362
|
+
init(data) {
|
|
934
363
|
let prov_opt = { ...defXEpgDocOptions.defProviderParam };
|
|
935
364
|
let name = '';
|
|
936
365
|
let version = '';
|
|
937
366
|
let schema = '';
|
|
938
367
|
let doctype = '';
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
[ name, version, schema, doctype ] = _options;
|
|
368
|
+
if (isArray(data)) {
|
|
369
|
+
[ name, version, schema, doctype ] = data;
|
|
942
370
|
} else {
|
|
943
|
-
({ name, version, schema, doctype } =
|
|
371
|
+
({ name, version, schema, doctype } = isObject(data) ? data : {});
|
|
944
372
|
};
|
|
945
373
|
name = readAsString(name, { defValue: prov_opt.name, useTrim: true });
|
|
946
374
|
version = readAsString(version, { defValue: prov_opt.version, useTrim: true });
|
|
@@ -989,229 +417,20 @@ class TXEpgProviderContainer {
|
|
|
989
417
|
}
|
|
990
418
|
|
|
991
419
|
};
|
|
992
|
-
|
|
993
|
-
/**
|
|
994
|
-
* A channel info descriptor
|
|
995
|
-
* @typedef {Object} xepgChnInfoDesc
|
|
996
|
-
* @property {string} chnid - channel ID
|
|
997
|
-
* @property {string} chname - channel name
|
|
998
|
-
* @property {string} [chngid] - channel 'Group ID'
|
|
999
|
-
* @property {string} [srcurl] - EPG-source URL
|
|
1000
|
-
*/
|
|
1001
|
-
|
|
1002
|
-
/**
|
|
1003
|
-
* @since 0.0.22
|
|
1004
|
-
* @classdesc This class implements an interface of a channel element
|
|
1005
|
-
*/
|
|
1006
|
-
class TXEpgChannelContainer {
|
|
1007
|
-
/** @type {object} */
|
|
1008
|
-
#_host;
|
|
1009
|
-
/** @type {OPT_epgelsett_bs} */
|
|
1010
|
-
#_options;
|
|
1011
|
-
/** @type {TXmlContentParseOptions} */
|
|
1012
|
-
#_parseOptions;
|
|
1013
|
-
/** @type {string} */
|
|
1014
|
-
#_xepgSchema;
|
|
1015
|
-
|
|
1016
|
-
/**
|
|
1017
|
-
* Creates an instance of the channel element
|
|
1018
|
-
* @param {object} obj - host object
|
|
1019
|
-
* @param {OPT_epgelsett_bs} [opt] - options
|
|
1020
|
-
*/
|
|
1021
|
-
constructor(obj, opt) {
|
|
1022
|
-
// load content
|
|
1023
|
-
const _host = isPlainObject(obj) ? obj : {};
|
|
1024
|
-
// load options
|
|
1025
|
-
const _options = __evalXMLBaseNodeSettings(opt);
|
|
1026
|
-
let {
|
|
1027
|
-
parseOptions,
|
|
1028
|
-
} = _options;
|
|
1029
|
-
// set document schema version
|
|
1030
|
-
this.#_xepgSchema = XEPG_DEF_DOCUMENT_SCHEMA;
|
|
1031
|
-
// save options
|
|
1032
|
-
this.#_options = _options;
|
|
1033
|
-
// save parser options
|
|
1034
|
-
this.#_parseOptions = parseOptions;
|
|
1035
|
-
// save content source
|
|
1036
|
-
this.#_host = _host;
|
|
1037
|
-
}
|
|
1038
|
-
|
|
1039
|
-
/**
|
|
1040
|
-
* Contains a channel ID
|
|
1041
|
-
* @type {string}
|
|
1042
|
-
* @readonly
|
|
1043
|
-
*/
|
|
1044
|
-
get id() {
|
|
1045
|
-
return _getXmlChildElementParam(this.#_host, XEPG_CHNID_ETAG_NAME).trim();
|
|
1046
|
-
}
|
|
1047
|
-
|
|
1048
|
-
/**
|
|
1049
|
-
* Contains a channel name
|
|
1050
|
-
* @type {string}
|
|
1051
|
-
*/
|
|
1052
|
-
get name() {
|
|
1053
|
-
return _getXmlChildElementParam(this.#_host, XEPG_CHNNAME_ETAG_NAME).trim();
|
|
1054
|
-
}
|
|
1055
|
-
|
|
1056
|
-
set name(value) {
|
|
1057
|
-
if (typeof value === 'string' && this.id !== '') {
|
|
1058
|
-
const item = insertXObjElement(
|
|
1059
|
-
this.#_host,
|
|
1060
|
-
XEPG_CHNNAME_ETAG_NAME,
|
|
1061
|
-
{ force: true },
|
|
1062
|
-
);
|
|
1063
|
-
if (item) {
|
|
1064
|
-
writeXObjParam(item, value.trim(), defParseOptions.settings.textKey);
|
|
1065
|
-
};
|
|
1066
|
-
};
|
|
1067
|
-
}
|
|
1068
|
-
|
|
1069
|
-
/**
|
|
1070
|
-
* Contains a channel Group ID
|
|
1071
|
-
* @type {string}
|
|
1072
|
-
*/
|
|
1073
|
-
get gid() {
|
|
1074
|
-
return _getXmlChildElementParam(this.#_host, XEPG_CHNGID_ETAG_NAME).trim();
|
|
1075
|
-
}
|
|
1076
|
-
|
|
1077
|
-
set gid(value) {
|
|
1078
|
-
if (typeof value === 'string' && this.id !== '') {
|
|
1079
|
-
const item = insertXObjElement(
|
|
1080
|
-
this.#_host,
|
|
1081
|
-
XEPG_CHNGID_ETAG_NAME,
|
|
1082
|
-
{ force: true },
|
|
1083
|
-
);
|
|
1084
|
-
if (item) {
|
|
1085
|
-
writeXObjParam(item, value.trim(), defParseOptions.settings.textKey);
|
|
1086
|
-
};
|
|
1087
|
-
};
|
|
1088
|
-
}
|
|
1089
|
-
|
|
1090
|
-
/**
|
|
1091
|
-
* Contains a channel source URL
|
|
1092
|
-
* @type {string}
|
|
1093
|
-
*/
|
|
1094
|
-
get url() {
|
|
1095
|
-
return _getXmlChildElementParam(this.#_host, XEPG_CHNURL_ETAG_NAME).trim();
|
|
1096
|
-
}
|
|
1097
|
-
|
|
1098
|
-
set url(value) {
|
|
1099
|
-
if (typeof value === 'string' && this.id !== '') {
|
|
1100
|
-
const item = insertXObjElement(
|
|
1101
|
-
this.#_host,
|
|
1102
|
-
XEPG_CHNURL_ETAG_NAME,
|
|
1103
|
-
{ force: true },
|
|
1104
|
-
);
|
|
1105
|
-
if (item) {
|
|
1106
|
-
writeXObjParam(item, value.trim(), defParseOptions.settings.textKey);
|
|
1107
|
-
};
|
|
1108
|
-
};
|
|
1109
|
-
}
|
|
1110
|
-
|
|
1111
|
-
/**
|
|
1112
|
-
* Tries to set a channel ID
|
|
1113
|
-
* @param {string} value - channel ID
|
|
1114
|
-
* @returns {boolean}
|
|
1115
|
-
*/
|
|
1116
|
-
setID(value) {
|
|
1117
|
-
let isSucceed = false;
|
|
1118
|
-
if (typeof value === 'string') {
|
|
1119
|
-
const chnid = value.trim();
|
|
1120
|
-
const item = insertXObjElement(
|
|
1121
|
-
this.#_host,
|
|
1122
|
-
XEPG_CHNID_ETAG_NAME,
|
|
1123
|
-
{ force: true },
|
|
1124
|
-
);
|
|
1125
|
-
if (item) {
|
|
1126
|
-
isSucceed = writeXObjParam(item, chnid, defParseOptions.settings.textKey);
|
|
1127
|
-
};
|
|
1128
|
-
};
|
|
1129
|
-
return isSucceed;
|
|
1130
|
-
}
|
|
1131
|
-
|
|
1132
|
-
/**
|
|
1133
|
-
* Returns a channel info
|
|
1134
|
-
* @returns {xepgChnInfoDesc}
|
|
1135
|
-
*/
|
|
1136
|
-
getInfo() {
|
|
1137
|
-
const {
|
|
1138
|
-
id: chnid,
|
|
1139
|
-
name: chname,
|
|
1140
|
-
gid: chngid,
|
|
1141
|
-
url: srcurl,
|
|
1142
|
-
} = this;
|
|
1143
|
-
/** @type {xepgChnInfoDesc} */
|
|
1144
|
-
return {
|
|
1145
|
-
chnid,
|
|
1146
|
-
chname,
|
|
1147
|
-
chngid,
|
|
1148
|
-
srcurl,
|
|
1149
|
-
};
|
|
1150
|
-
}
|
|
1151
|
-
|
|
1152
|
-
/**
|
|
1153
|
-
* Sets a channel info
|
|
1154
|
-
* @param {(string|xepgChnInfoDesc)} obj - channel info descriptor
|
|
1155
|
-
* @returns {void}
|
|
1156
|
-
*/
|
|
1157
|
-
setInfo(obj) {
|
|
1158
|
-
let chnid = '';
|
|
1159
|
-
let chname = '';
|
|
1160
|
-
let chngid = '';
|
|
1161
|
-
let srcurl = '';
|
|
1162
|
-
if (isObject(obj)) {
|
|
1163
|
-
({ chnid } = obj);
|
|
1164
|
-
if (typeof chnid === 'string') {
|
|
1165
|
-
({ chname, chngid, srcurl } = obj);
|
|
1166
|
-
} else {
|
|
1167
|
-
// // TODO: [?] deprecate
|
|
1168
|
-
chnid = _getXmlChildElementParam(obj, XEPG_CHNID_ETAG_NAME).trim();
|
|
1169
|
-
chname = _getXmlChildElementParam(obj, XEPG_CHNNAME_ETAG_NAME).trim();
|
|
1170
|
-
chngid = _getXmlChildElementParam(obj, XEPG_CHNGID_ETAG_NAME).trim();
|
|
1171
|
-
srcurl = _getXmlChildElementParam(obj, XEPG_CHNURL_ETAG_NAME).trim();
|
|
1172
|
-
};
|
|
1173
|
-
} else if (typeof obj === 'string') {
|
|
1174
|
-
chnid = obj;
|
|
1175
|
-
} else {
|
|
1176
|
-
return;
|
|
1177
|
-
};
|
|
1178
|
-
chnid = typeof chnid === 'string' ? chnid.trim() : '';
|
|
1179
|
-
if (chnid === '') {
|
|
1180
|
-
chname = '';
|
|
1181
|
-
chngid = '';
|
|
1182
|
-
srcurl = '';
|
|
1183
|
-
} else {
|
|
1184
|
-
chname = typeof chname === 'string' ? chname.trim() : '';
|
|
1185
|
-
chngid = typeof chngid === 'string' ? chngid.trim() : '';
|
|
1186
|
-
srcurl = typeof srcurl === 'string' ? srcurl.trim() : '';
|
|
1187
|
-
};
|
|
1188
|
-
let item = null;
|
|
1189
|
-
const _host = this.#_host;
|
|
1190
|
-
const text_key = defParseOptions.settings.textKey;
|
|
1191
|
-
item = insertXObjElement(_host, XEPG_CHNID_ETAG_NAME, { force: true });
|
|
1192
|
-
if (item) writeXObjParam(item, chnid, text_key);
|
|
1193
|
-
item = insertXObjElement(_host, XEPG_CHNNAME_ETAG_NAME, { force: true });
|
|
1194
|
-
if (item) writeXObjParam(item, chname, text_key);
|
|
1195
|
-
item = insertXObjElement(_host, XEPG_CHNGID_ETAG_NAME, { force: true });
|
|
1196
|
-
if (item) writeXObjParam(item, chngid, text_key);
|
|
1197
|
-
item = insertXObjElement(_host, XEPG_CHNURL_ETAG_NAME, { force: true });
|
|
1198
|
-
if (item) writeXObjParam(item, srcurl, text_key);
|
|
1199
|
-
}
|
|
1200
|
-
|
|
1201
|
-
}
|
|
420
|
+
module.exports.TXEpgProviderContainer = TXEpgProviderContainer;
|
|
1202
421
|
|
|
1203
422
|
/**
|
|
1204
423
|
* @classdesc This class implements an interface of a DTS-provider element
|
|
1205
424
|
*/
|
|
1206
425
|
class TXEpgDTSProvider {
|
|
1207
|
-
/** @type {
|
|
426
|
+
/** @type {INode} */
|
|
1208
427
|
#_content;
|
|
1209
428
|
/** @type {OPT_epgelsett_bs} */
|
|
1210
429
|
#_options;
|
|
1211
430
|
|
|
1212
431
|
/**
|
|
1213
432
|
* Creates an instance of the DTS-provider element
|
|
1214
|
-
* @param {
|
|
433
|
+
* @param {INode} obj - host object
|
|
1215
434
|
* @param {OPT_epgelsett_bs} [opt] - options
|
|
1216
435
|
*/
|
|
1217
436
|
constructor(obj, opt) {
|
|
@@ -1272,7 +491,7 @@ class TXEpgDTSProvider {
|
|
|
1272
491
|
{ force: true },
|
|
1273
492
|
);
|
|
1274
493
|
if (item) {
|
|
1275
|
-
writeXObjParam(item, _value,
|
|
494
|
+
writeXObjParam(item, _value, defParseOptionsSettings.textKey);
|
|
1276
495
|
};
|
|
1277
496
|
};
|
|
1278
497
|
}
|
|
@@ -1280,7 +499,7 @@ class TXEpgDTSProvider {
|
|
|
1280
499
|
/**
|
|
1281
500
|
* Tries to set a `DTS`-type
|
|
1282
501
|
* @since 0.0.22
|
|
1283
|
-
* @
|
|
502
|
+
* @param {number|string} value - dtstype ID
|
|
1284
503
|
* @returns {boolean}
|
|
1285
504
|
*/
|
|
1286
505
|
setType(value) {
|
|
@@ -1296,10 +515,10 @@ class TXEpgDTSProvider {
|
|
|
1296
515
|
let curItem = insertXObjElement(item, 'value', { force: true });
|
|
1297
516
|
if (
|
|
1298
517
|
curItem
|
|
1299
|
-
&& writeXObjParam(curItem, index,
|
|
518
|
+
&& writeXObjParam(curItem, index, defParseOptionsSettings.textKey)
|
|
1300
519
|
&& (curItem = insertXObjElement(item, 'name', { force: true }))
|
|
1301
520
|
) {
|
|
1302
|
-
isSucceed = writeXObjParam(curItem, name,
|
|
521
|
+
isSucceed = writeXObjParam(curItem, name, defParseOptionsSettings.textKey);
|
|
1303
522
|
};
|
|
1304
523
|
};
|
|
1305
524
|
};
|
|
@@ -1312,7 +531,7 @@ class TXEpgDTSProvider {
|
|
|
1312
531
|
* @classdesc This class implements an interface of a EPG-header element
|
|
1313
532
|
*/
|
|
1314
533
|
class TXEpgHeaderContainer {
|
|
1315
|
-
/** @type {
|
|
534
|
+
/** @type {INode} */
|
|
1316
535
|
#_host;
|
|
1317
536
|
/** @type {OPT_epgelsett_bs} */
|
|
1318
537
|
#_options;
|
|
@@ -1323,7 +542,7 @@ class TXEpgHeaderContainer {
|
|
|
1323
542
|
|
|
1324
543
|
/**
|
|
1325
544
|
* Creates an instance of the EPG-header element
|
|
1326
|
-
* @param {
|
|
545
|
+
* @param {INode} obj - host element
|
|
1327
546
|
* @param {OPT_epgelsett_bs} [opt] - options
|
|
1328
547
|
*/
|
|
1329
548
|
constructor(obj, opt) {
|
|
@@ -1451,7 +670,7 @@ class TXEpgHeaderContainer {
|
|
|
1451
670
|
{ force: true },
|
|
1452
671
|
);
|
|
1453
672
|
if (item) {
|
|
1454
|
-
writeXObjParam(item, dt_str,
|
|
673
|
+
writeXObjParam(item, dt_str, defParseOptionsSettings.textKey);
|
|
1455
674
|
};
|
|
1456
675
|
}
|
|
1457
676
|
|
|
@@ -1482,13 +701,13 @@ class TXEpgHeaderContainer {
|
|
|
1482
701
|
{ force: true },
|
|
1483
702
|
);
|
|
1484
703
|
if (item) {
|
|
1485
|
-
writeXObjParam(item, dt_str,
|
|
704
|
+
writeXObjParam(item, dt_str, defParseOptionsSettings.textKey);
|
|
1486
705
|
};
|
|
1487
706
|
}
|
|
1488
707
|
|
|
1489
708
|
/**
|
|
1490
709
|
* Returns a channel info
|
|
1491
|
-
* @returns {
|
|
710
|
+
* @returns {IXEpgChnInfoDesc}
|
|
1492
711
|
*/
|
|
1493
712
|
getChannelInfo() {
|
|
1494
713
|
return this.channel.getInfo();
|
|
@@ -1496,7 +715,7 @@ class TXEpgHeaderContainer {
|
|
|
1496
715
|
|
|
1497
716
|
/**
|
|
1498
717
|
* Returns a provider info
|
|
1499
|
-
* @returns {?
|
|
718
|
+
* @returns {?IXEpgProvInfoDesc}
|
|
1500
719
|
*/
|
|
1501
720
|
getProviderInfo() {
|
|
1502
721
|
const docProv = this.provider;
|
|
@@ -1540,14 +759,15 @@ class TXEpgHeaderContainer {
|
|
|
1540
759
|
}
|
|
1541
760
|
|
|
1542
761
|
};
|
|
762
|
+
module.exports.TXEpgHeaderContainer = TXEpgHeaderContainer;
|
|
1543
763
|
|
|
1544
764
|
/**
|
|
1545
|
-
* @since v0.0.
|
|
765
|
+
* @since v0.0.30
|
|
1546
766
|
* @classdesc This class implements an instance of an element
|
|
1547
767
|
* that managea content of a document declaration
|
|
1548
768
|
*/
|
|
1549
769
|
class TXmlContentDeclaration {
|
|
1550
|
-
/** @type {
|
|
770
|
+
/** @type {INode} */
|
|
1551
771
|
#_host;
|
|
1552
772
|
/** @type {XEpgElementConfigBase} */
|
|
1553
773
|
#_config;
|
|
@@ -1556,7 +776,7 @@ class TXmlContentDeclaration {
|
|
|
1556
776
|
|
|
1557
777
|
/**
|
|
1558
778
|
* Creates an instance of the element
|
|
1559
|
-
* @param {
|
|
779
|
+
* @param {INode} obj - some object
|
|
1560
780
|
* @param {OPT_epgelsett_bs} [opt] - options
|
|
1561
781
|
* @throws {TypeError}
|
|
1562
782
|
*/
|
|
@@ -1665,7 +885,7 @@ module.exports.TXmlContentDeclaration = TXmlContentDeclaration;
|
|
|
1665
885
|
* that manages a content of a XEPG-document
|
|
1666
886
|
*/
|
|
1667
887
|
class TXEpgContentProvider {
|
|
1668
|
-
/** @type {
|
|
888
|
+
/** @type {INode} */
|
|
1669
889
|
#_content;
|
|
1670
890
|
/** @type {XEpgContainerConfig} */
|
|
1671
891
|
#_options;
|
|
@@ -1715,12 +935,16 @@ class TXEpgContentProvider {
|
|
|
1715
935
|
if (!docRoot) {
|
|
1716
936
|
docRoot = insertXObjElement(content, XEPG_ROOT_ETAG_NAME);
|
|
1717
937
|
if (docRoot) {
|
|
1718
|
-
const config =
|
|
938
|
+
const config = (
|
|
939
|
+
opt && opt.settings
|
|
940
|
+
? opt.settings
|
|
941
|
+
: defParseOptionsSettings
|
|
942
|
+
);
|
|
1719
943
|
writeXObjAttr(
|
|
1720
944
|
docRoot,
|
|
1721
945
|
`xmlns:${XEPG_DEF_NS_NAME}`,
|
|
1722
946
|
XEPG_DEF_NS_PATH,
|
|
1723
|
-
config.
|
|
947
|
+
config.attributesKey,
|
|
1724
948
|
);
|
|
1725
949
|
};
|
|
1726
950
|
};
|
|
@@ -1729,7 +953,7 @@ class TXEpgContentProvider {
|
|
|
1729
953
|
|
|
1730
954
|
/**
|
|
1731
955
|
* Initializes a document content.
|
|
1732
|
-
* @since 0.0.
|
|
956
|
+
* @since 0.0.30
|
|
1733
957
|
* @param {object} content - some object to initialize
|
|
1734
958
|
* @param {XEpgContainerConfig} opt - options
|
|
1735
959
|
* @param {boolean} mode - flag
|
|
@@ -1866,7 +1090,7 @@ class TXEpgContentProvider {
|
|
|
1866
1090
|
/**
|
|
1867
1091
|
* Saves a document content to a file.
|
|
1868
1092
|
* @param {string} source - a path to a file
|
|
1869
|
-
* @returns {Promise<fsoDescr
|
|
1093
|
+
* @returns {Promise<fsoDescr>}
|
|
1870
1094
|
* @throws {Error}
|
|
1871
1095
|
* @async
|
|
1872
1096
|
*/
|
|
@@ -1967,7 +1191,7 @@ class TXEpgContentProvider {
|
|
|
1967
1191
|
/**
|
|
1968
1192
|
* Loads a document content from a file.
|
|
1969
1193
|
* @param {string} source - path to a file
|
|
1970
|
-
* @returns {Promise<fsoDescr
|
|
1194
|
+
* @returns {Promise<fsoDescr>}
|
|
1971
1195
|
* @throws {Error}
|
|
1972
1196
|
* @async
|
|
1973
1197
|
*/
|
|
@@ -2032,6 +1256,7 @@ class TXEpgContentProvider {
|
|
|
2032
1256
|
}
|
|
2033
1257
|
|
|
2034
1258
|
}
|
|
1259
|
+
module.exports.TXEpgContentProvider = TXEpgContentProvider;
|
|
2035
1260
|
|
|
2036
1261
|
// === module exports block ===
|
|
2037
1262
|
|
|
@@ -2041,9 +1266,3 @@ module.exports.XEPG_DEF_DOCUMENT_TYPE = XEPG_DEF_DOCUMENT_TYPE;
|
|
|
2041
1266
|
module.exports.XEPG_DEF_DOCUMENT_SCHEMA = XEPG_DEF_DOCUMENT_SCHEMA;
|
|
2042
1267
|
|
|
2043
1268
|
module.exports.TXEpgDTSProvider = TXEpgDTSProvider;
|
|
2044
|
-
module.exports.TXEpgScheduleItem = TXEpgScheduleItem;
|
|
2045
|
-
module.exports.TXEpgSchedulesList = TXEpgSchedulesList;
|
|
2046
|
-
module.exports.TXEpgProviderContainer = TXEpgProviderContainer;
|
|
2047
|
-
module.exports.TXEpgChannelContainer = TXEpgChannelContainer;
|
|
2048
|
-
module.exports.TXEpgHeaderContainer = TXEpgHeaderContainer;
|
|
2049
|
-
module.exports.TXEpgContentProvider = TXEpgContentProvider;
|