@ygracs/xepg-lib-js 0.0.20 → 0.0.22
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 +29 -76
- package/LICENSE +1 -1
- package/README.md +5 -3
- package/doc/xepgdoc-lib.md +523 -57
- package/doc/xepgdoc-spec-draft.dtd +65 -0
- package/index.js +12 -8
- package/lib/dts-helper.js +23 -28
- package/lib/xepgdoc-lib.js +753 -257
- package/package.json +10 -14
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
<!-- DTD for TV-listings
|
|
2
|
+
======================
|
|
3
|
+
* [rev.0.2.002-20241016]
|
|
4
|
+
* [schema 0.2] -->
|
|
5
|
+
|
|
6
|
+
<!ELEMENT epgdoc (tvp:info, tvp:list)>
|
|
7
|
+
<!ATTLIST epgdoc xmlns:tvp CDATA #REQUIRED >
|
|
8
|
+
|
|
9
|
+
<!ELEMENT tvp:info (tvp:provider,
|
|
10
|
+
(tvp:channel?|(tvp:chnid, tvp:chngid?, tvp:chname)),
|
|
11
|
+
tvp:srcurl?,
|
|
12
|
+
tvp:time?, tvp:expire?, tvp:timezone, tvp:dtstype)>
|
|
13
|
+
|
|
14
|
+
<!ELEMENT tvp:provider (name, version?, tvp:schema, tvp:doctype)>
|
|
15
|
+
|
|
16
|
+
<!ELEMENT name (#PCDATA)>
|
|
17
|
+
<!ATTLIST name lang CDATA #IMPLIED >
|
|
18
|
+
|
|
19
|
+
<!ELEMENT version (#PCDATA)>
|
|
20
|
+
|
|
21
|
+
<!ELEMENT tvp:schema (#PCDATA)>
|
|
22
|
+
|
|
23
|
+
<!ELEMENT tvp:doctype (#PCDATA)>
|
|
24
|
+
|
|
25
|
+
<!-- NOTE: tag <tvp:channel> reserved for schema 0.3+ -->
|
|
26
|
+
<!ELEMENT tvp:channel (tvp:chnid, tvp:chngid?, tvp:chname*)>
|
|
27
|
+
|
|
28
|
+
<!ELEMENT tvp:chnid (#PCDATA)>
|
|
29
|
+
|
|
30
|
+
<!ELEMENT tvp:chngid (#PCDATA)>
|
|
31
|
+
|
|
32
|
+
<!ELEMENT tvp:chname (#PCDATA)>
|
|
33
|
+
<!ATTLIST tvp:chname lang CDATA #IMPLIED >
|
|
34
|
+
|
|
35
|
+
<!ELEMENT tvp:srcurl (#PCDATA)>
|
|
36
|
+
|
|
37
|
+
<!ELEMENT tvp:time (#PCDATA)>
|
|
38
|
+
|
|
39
|
+
<!ELEMENT tvp:expire (#PCDATA)>
|
|
40
|
+
|
|
41
|
+
<!ELEMENT tvp:timezone (#PCDATA)>
|
|
42
|
+
|
|
43
|
+
<!ELEMENT tvp:dtstype (value, name)>
|
|
44
|
+
|
|
45
|
+
<!ELEMENT value (#PCDATA)>
|
|
46
|
+
|
|
47
|
+
<!ELEMENT tvp:list ((tvp:item|tvp:schedule)*)>
|
|
48
|
+
|
|
49
|
+
<!ELEMENT tvp:item (tvp:time, tvp:title+, tvp:pcmark?, tvp:cat*, tvp:desc*)>
|
|
50
|
+
|
|
51
|
+
<!ELEMENT tvp:title (#PCDATA)>
|
|
52
|
+
<!ATTLIST tvp:chname lang CDATA #IMPLIED >
|
|
53
|
+
|
|
54
|
+
<!ELEMENT tvp:pcmark (#PCDATA)>
|
|
55
|
+
|
|
56
|
+
<!ELEMENT tvp:cat (#PCDATA)>
|
|
57
|
+
<!ATTLIST tvp:cat lang CDATA #IMPLIED >
|
|
58
|
+
|
|
59
|
+
<!ELEMENT tvp:desc (#PCDATA)>
|
|
60
|
+
<!ATTLIST tvp:desc lang CDATA #IMPLIED >
|
|
61
|
+
|
|
62
|
+
<!-- NOTE: tag <tvp:channel> reserved for schema 0.3+ -->
|
|
63
|
+
<!ELEMENT tvp:schedule (tvp:title+, tvp:pcmark?, tvp:cat*, tvp:desc*)>
|
|
64
|
+
<!ATTLIST tvp:schedule start CDATA #REQUIRED
|
|
65
|
+
stop CDATA #IMPLIED >
|
package/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
// [v0.0.
|
|
1
|
+
// [v0.0.010-20250228]
|
|
2
2
|
|
|
3
3
|
// === module init block ===
|
|
4
4
|
|
|
5
|
-
const
|
|
5
|
+
const xepgdoc = require('./lib/xepgdoc-lib.js');
|
|
6
6
|
|
|
7
7
|
const xObj = require('@ygracs/xobj-lib-js');
|
|
8
8
|
|
|
@@ -13,11 +13,15 @@ const xObj = require('@ygracs/xobj-lib-js');
|
|
|
13
13
|
// === module exports block ===
|
|
14
14
|
|
|
15
15
|
/**/// v1 branch
|
|
16
|
-
exports.TXEpgContentProvider =
|
|
17
|
-
exports.
|
|
18
|
-
exports.
|
|
19
|
-
exports.
|
|
20
|
-
exports.
|
|
16
|
+
module.exports.TXEpgContentProvider = xepgdoc.TXEpgContentProvider;
|
|
17
|
+
module.exports.TXEpgScheduleItem = xepgdoc.TXEpgScheduleItem;
|
|
18
|
+
module.exports.TXEpgSchedulesList = xepgdoc.TXEpgSchedulesList;
|
|
19
|
+
module.exports.TXEpgDTSProvider = xepgdoc.TXEpgDTSProvider;
|
|
20
|
+
module.exports.TXEpgProviderContainer = xepgdoc.TXEpgProviderContainer;
|
|
21
|
+
module.exports.TXEpgHeaderContainer = xepgdoc.TXEpgHeaderContainer;
|
|
21
22
|
|
|
22
23
|
// re-export stuff from `@ygracs/xobj-lib-js` module
|
|
23
|
-
exports.TXmlContentParseOptions = xObj.TXmlContentParseOptions;
|
|
24
|
+
module.exports.TXmlContentParseOptions = xObj.TXmlContentParseOptions;
|
|
25
|
+
|
|
26
|
+
/**/// will deprecate
|
|
27
|
+
module.exports.TXepgDTSProvider = xepgdoc.TXepgDTSProvider;
|
package/lib/dts-helper.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
// [v0.1.
|
|
1
|
+
// [v0.1.047-20250225]
|
|
2
2
|
|
|
3
3
|
// === module init block ===
|
|
4
4
|
|
|
5
5
|
const {
|
|
6
|
-
valueToIndex,
|
|
7
|
-
isDateObject,
|
|
6
|
+
valueToIndex,
|
|
8
7
|
} = require('@ygracs/bsfoc-lib-js');
|
|
9
8
|
|
|
10
9
|
const {
|
|
@@ -32,22 +31,22 @@ const def_dts_param = [
|
|
|
32
31
|
|
|
33
32
|
/**
|
|
34
33
|
* @function chkDTSysID
|
|
35
|
-
* @param {(number|string)} value
|
|
34
|
+
* @param {(number|string)} value - value to verify
|
|
36
35
|
* @returns {boolean}
|
|
37
36
|
* @description Checs if a given value is a valid dtstype ID
|
|
38
37
|
*/
|
|
39
|
-
function chkDTSysID(value){
|
|
38
|
+
function chkDTSysID(value) {
|
|
40
39
|
const _value = valueToIndex(value);
|
|
41
40
|
return _value !== -1 && def_dts_param[_value] ? true : false;
|
|
42
41
|
};
|
|
43
42
|
|
|
44
43
|
/**
|
|
45
44
|
* @function getDTSysName
|
|
46
|
-
* @param {(number|string)} value
|
|
45
|
+
* @param {(number|string)} value - DTS-type identifier
|
|
47
46
|
* @returns {string}
|
|
48
47
|
* @description Returns a dtstype name by a given dtstype ID
|
|
49
48
|
*/
|
|
50
|
-
function getDTSysName(value){
|
|
49
|
+
function getDTSysName(value) {
|
|
51
50
|
let result = 'undefined';
|
|
52
51
|
if (chkDTSysID(value)) {
|
|
53
52
|
result = def_dts_param[Number(value)];
|
|
@@ -56,19 +55,19 @@ function getDTSysName(value){
|
|
|
56
55
|
};
|
|
57
56
|
|
|
58
57
|
/**
|
|
59
|
-
* @typedef DTSysDescr
|
|
60
|
-
* @type {object}
|
|
58
|
+
* @typedef {Object} DTSysDescr
|
|
61
59
|
* @property {number} index - dtstype ID
|
|
62
60
|
* @property {string} name - dtstype name
|
|
61
|
+
* @description A DTS-type descriptor
|
|
63
62
|
*/
|
|
64
63
|
|
|
65
64
|
/**
|
|
66
65
|
* @function getDTSysDescr
|
|
67
|
-
* @param {(number|string)} value
|
|
66
|
+
* @param {(number|string)} value - DTS-type identifier
|
|
68
67
|
* @returns {DTSysDescr}
|
|
69
68
|
* @description Returns a dtstype description for a given dtstype ID
|
|
70
69
|
*/
|
|
71
|
-
function getDTSysDescr(value){
|
|
70
|
+
function getDTSysDescr(value) {
|
|
72
71
|
let index = valueToIndex(value);
|
|
73
72
|
let name = 'undefined';
|
|
74
73
|
if (index !== -1) {
|
|
@@ -86,13 +85,14 @@ function getDTSysDescr(value){
|
|
|
86
85
|
|
|
87
86
|
/**
|
|
88
87
|
* @function convStringToDTValue
|
|
89
|
-
* @param {string} value
|
|
90
|
-
* @param {(number|string)} [dts_id=0]
|
|
91
|
-
* @param {(number|string)} [tz]
|
|
88
|
+
* @param {string} value - some value
|
|
89
|
+
* @param {(number|string)} [dts_id=0] - DTS-type identifier
|
|
90
|
+
* @param {(number|string)} [tz] - <*reserved*>
|
|
92
91
|
* @returns {number}
|
|
93
92
|
* @description Tries to convert a given string to timestamp
|
|
93
|
+
* @todo check TZ
|
|
94
94
|
*/
|
|
95
|
-
function convStringToDTValue(value, dts_id = 0, tz){
|
|
95
|
+
function convStringToDTValue(value, dts_id = 0, tz) {
|
|
96
96
|
const dtstype = getDTSysName(dts_id);
|
|
97
97
|
let result = 0;
|
|
98
98
|
if (dtstype !== 'undefined') {
|
|
@@ -151,20 +151,17 @@ function convStringToDTValue(value, dts_id = 0, tz){
|
|
|
151
151
|
|
|
152
152
|
/**
|
|
153
153
|
* @function convDTValueToString
|
|
154
|
-
* @param {(number|string|Date)} value
|
|
155
|
-
* @param {(number|string)} dts_id
|
|
156
|
-
* @param {(number|string)} tz
|
|
154
|
+
* @param {(number|string|Date)} value - some value
|
|
155
|
+
* @param {(number|string)} [dts_id=0] - DTS-type identifier
|
|
156
|
+
* @param {(number|string)} [tz] - <*reserved*>
|
|
157
157
|
* @returns {string}
|
|
158
158
|
* @description Tries to convert a given value to its string representation
|
|
159
|
+
* @todo check TZ
|
|
159
160
|
*/
|
|
160
|
-
function convDTValueToString(value, dts_id, tz){
|
|
161
|
+
function convDTValueToString(value, dts_id, tz) {
|
|
162
|
+
let { isSucceed, value: dtValue } = tryDTValue(value);
|
|
163
|
+
let dt_val = isSucceed ? dtValue.getTime() : new Date(0);
|
|
161
164
|
let result = '';
|
|
162
|
-
let dt_val = (
|
|
163
|
-
isDateObject(value)
|
|
164
|
-
? value
|
|
165
|
-
: (new Date(readAsNumberEx(value, 0)))
|
|
166
|
-
).getTime();
|
|
167
|
-
if (Number.isNaN(dt_val)) dt_val = new Date(0);
|
|
168
165
|
let dtstype = valueToIndex(dts_id);
|
|
169
166
|
if (!chkDTSysID(dtstype)) dtstype = 0;
|
|
170
167
|
switch (getDTSysName(dtstype)) {
|
|
@@ -208,9 +205,7 @@ function convDTValueToString(value, dts_id, tz){
|
|
|
208
205
|
//console.log('convDTValueToString => result:['+result+']');
|
|
209
206
|
break;
|
|
210
207
|
}
|
|
211
|
-
default: {
|
|
212
|
-
break;
|
|
213
|
-
}
|
|
208
|
+
default: {}
|
|
214
209
|
};
|
|
215
210
|
return result;
|
|
216
211
|
};
|