epg-grabber 0.37.3 → 0.37.5
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/eslint.config.mjs +25 -0
- package/package.json +4 -1
- package/src/Channel.js +0 -2
- package/src/index.d.ts +6 -4
- package/src/index.js +1 -1
- package/src/parser.js +3 -1
- package/tests/__data__/input/example.channels.xml +1 -0
- package/tests/__data__/output/guide.xml +1 -1
- package/.eslintrc.js +0 -11
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import globals from "globals";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
import js from "@eslint/js";
|
|
5
|
+
import { FlatCompat } from "@eslint/eslintrc";
|
|
6
|
+
|
|
7
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
8
|
+
const __dirname = path.dirname(__filename);
|
|
9
|
+
const compat = new FlatCompat({
|
|
10
|
+
baseDirectory: __dirname,
|
|
11
|
+
recommendedConfig: js.configs.recommended,
|
|
12
|
+
allConfig: js.configs.all
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
export default [...compat.extends("eslint:recommended"), {
|
|
16
|
+
languageOptions: {
|
|
17
|
+
globals: {
|
|
18
|
+
...Object.fromEntries(Object.entries(globals.browser).map(([key]) => [key, "off"])),
|
|
19
|
+
...globals.node,
|
|
20
|
+
},
|
|
21
|
+
|
|
22
|
+
ecmaVersion: 12,
|
|
23
|
+
sourceType: "commonjs",
|
|
24
|
+
},
|
|
25
|
+
}];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "epg-grabber",
|
|
3
|
-
"version": "0.37.
|
|
3
|
+
"version": "0.37.5",
|
|
4
4
|
"description": "Node.js CLI tool for grabbing EPG from different sites",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"preferGlobal": true,
|
|
@@ -48,8 +48,11 @@
|
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"@babel/core": "^7.13.14",
|
|
50
50
|
"@babel/preset-env": "^7.13.12",
|
|
51
|
+
"@eslint/eslintrc": "^3.2.0",
|
|
52
|
+
"@eslint/js": "^9.18.0",
|
|
51
53
|
"babel-jest": "^29.7.0",
|
|
52
54
|
"eslint": "^9.17.0",
|
|
55
|
+
"globals": "^15.14.0",
|
|
53
56
|
"jest": "^29.7.0",
|
|
54
57
|
"jest-mock-axios": "^4.4.1"
|
|
55
58
|
},
|
package/src/Channel.js
CHANGED
package/src/index.d.ts
CHANGED
|
@@ -101,19 +101,21 @@ export type GrabCallbackData = {
|
|
|
101
101
|
}
|
|
102
102
|
|
|
103
103
|
export declare class EPGGrabber {
|
|
104
|
-
constructor(config
|
|
104
|
+
constructor(config?: SiteConfig)
|
|
105
105
|
grab(
|
|
106
106
|
channel: Channel,
|
|
107
107
|
date: string | dayjs.Dayjs,
|
|
108
|
-
|
|
108
|
+
config?: SiteConfig,
|
|
109
|
+
cb?: (data: GrabCallbackData, err: Error | null) => void
|
|
109
110
|
): Promise<Program[]>
|
|
110
111
|
}
|
|
111
112
|
|
|
112
113
|
export declare class EPGGrabberMock {
|
|
113
|
-
constructor(config
|
|
114
|
+
constructor(config?: SiteConfig)
|
|
114
115
|
grab(
|
|
115
116
|
channel: Channel,
|
|
116
117
|
date: string | dayjs.Dayjs,
|
|
117
|
-
|
|
118
|
+
config?: SiteConfig,
|
|
119
|
+
cb?: (data: GrabCallbackData, err: Error | null) => void
|
|
118
120
|
): Promise<Program[]>
|
|
119
121
|
}
|
package/src/index.js
CHANGED
package/src/parser.js
CHANGED
|
@@ -27,12 +27,14 @@ function parseChannels(xml) {
|
|
|
27
27
|
.filter(el => el.name === 'channel')
|
|
28
28
|
.map(el => {
|
|
29
29
|
const c = el.attributes
|
|
30
|
+
if (!Array.isArray(el.elements)) return
|
|
30
31
|
c.name = el.elements.find(el => el.type === 'text').text
|
|
31
32
|
c.site = c.site || rootSite
|
|
32
|
-
if (!c.name)
|
|
33
|
+
if (!c.name) return
|
|
33
34
|
|
|
34
35
|
return new Channel(c)
|
|
35
36
|
})
|
|
37
|
+
.filter(Boolean)
|
|
36
38
|
|
|
37
39
|
return channels
|
|
38
40
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8" ?><tv date="
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" ?><tv date="20250124">
|
|
2
2
|
<channel id="1TV.com"><display-name>1 TV</display-name><icon src="https://example.com/logos/1TV.png"/><url>https://example.com</url></channel>
|
|
3
3
|
<channel id="2TV.com"><display-name>2 TV</display-name><url>https://example.com</url></channel>
|
|
4
4
|
<channel id="3TV.com"><display-name>3 TV</display-name><url>https://example2.com</url></channel>
|