From feddd9500b410d733d0634a9d73741c132d529ea Mon Sep 17 00:00:00 2001
From: freearhey <7253922+freearhey@users.noreply.github.com>
Date: Fri, 30 Jun 2023 14:41:15 +0300
Subject: [PATCH 1/5] Update tests/__data__
---
.../expected/sites/parse-channels-clean.channels.xml | 7 +++++++
tests/__data__/expected/sites/parse-channels.channels.xml | 1 +
tests/__data__/input/sites/parse-channels.channels.xml | 6 ++++++
tests/__data__/input/sites/parse-channels.config.js | 6 +++++-
4 files changed, 19 insertions(+), 1 deletion(-)
create mode 100644 tests/__data__/expected/sites/parse-channels-clean.channels.xml
create mode 100644 tests/__data__/input/sites/parse-channels.channels.xml
diff --git a/tests/__data__/expected/sites/parse-channels-clean.channels.xml b/tests/__data__/expected/sites/parse-channels-clean.channels.xml
new file mode 100644
index 00000000..2b8e092f
--- /dev/null
+++ b/tests/__data__/expected/sites/parse-channels-clean.channels.xml
@@ -0,0 +1,7 @@
+
+
+
+ CNN International
+ BBC World News
+
+
diff --git a/tests/__data__/expected/sites/parse-channels.channels.xml b/tests/__data__/expected/sites/parse-channels.channels.xml
index 82cbe2a7..33163fe9 100644
--- a/tests/__data__/expected/sites/parse-channels.channels.xml
+++ b/tests/__data__/expected/sites/parse-channels.channels.xml
@@ -2,5 +2,6 @@
CNN International
+ BBC World News
diff --git a/tests/__data__/input/sites/parse-channels.channels.xml b/tests/__data__/input/sites/parse-channels.channels.xml
new file mode 100644
index 00000000..29f16d4b
--- /dev/null
+++ b/tests/__data__/input/sites/parse-channels.channels.xml
@@ -0,0 +1,6 @@
+
+
+
+ CNN International
+
+
diff --git a/tests/__data__/input/sites/parse-channels.config.js b/tests/__data__/input/sites/parse-channels.config.js
index 9db10dc2..e79ffa4e 100644
--- a/tests/__data__/input/sites/parse-channels.config.js
+++ b/tests/__data__/input/sites/parse-channels.config.js
@@ -10,9 +10,13 @@ module.exports = {
return [
{
lang: 'en',
- xmltv_id: 'CNNInternational.us',
site_id: 140,
name: 'CNN International'
+ },
+ {
+ lang: 'en',
+ site_id: 240,
+ name: 'BBC World News'
}
]
}
From f2057dd0157a81c001063a669b577c2f0c74f8ce Mon Sep 17 00:00:00 2001
From: freearhey <7253922+freearhey@users.noreply.github.com>
Date: Fri, 30 Jun 2023 14:41:19 +0300
Subject: [PATCH 2/5] Update parse.test.js
---
tests/commands/channels/parse.test.js | 23 +++++++++++++++++++----
1 file changed, 19 insertions(+), 4 deletions(-)
diff --git a/tests/commands/channels/parse.test.js b/tests/commands/channels/parse.test.js
index bc82251c..a9242a4f 100644
--- a/tests/commands/channels/parse.test.js
+++ b/tests/commands/channels/parse.test.js
@@ -4,19 +4,34 @@ const path = require('path')
beforeEach(() => {
fs.emptyDirSync('tests/__data__/output')
-
- const stdout = execSync(
- 'npm run channels:parse -- --config=tests/__data__/input/sites/parse-channels.config.js --output=tests/__data__/output/channels.xml',
- { encoding: 'utf8' }
+ fs.copySync(
+ 'tests/__data__/input/sites/parse-channels.channels.xml',
+ 'tests/__data__/output/channels.xml'
)
})
it('can parse channels', () => {
+ const stdout = execSync(
+ 'npm run channels:parse -- --config=tests/__data__/input/sites/parse-channels.config.js --output=tests/__data__/output/channels.xml',
+ { encoding: 'utf8' }
+ )
+
expect(content('tests/__data__/output/channels.xml')).toEqual(
content('tests/__data__/expected/sites/parse-channels.channels.xml')
)
})
+it('can parse channels with clean flag', () => {
+ const stdout = execSync(
+ 'npm run channels:parse -- --config=tests/__data__/input/sites/parse-channels.config.js --output=tests/__data__/output/channels.xml --clean',
+ { encoding: 'utf8' }
+ )
+
+ expect(content('tests/__data__/output/channels.xml')).toEqual(
+ content('tests/__data__/expected/sites/parse-channels-clean.channels.xml')
+ )
+})
+
function content(filepath) {
return fs.readFileSync(path.resolve(filepath), {
encoding: 'utf8'
From 114ff0823b973a209bfaa3124b971f7025cfa897 Mon Sep 17 00:00:00 2001
From: freearhey <7253922+freearhey@users.noreply.github.com>
Date: Fri, 30 Jun 2023 14:41:28 +0300
Subject: [PATCH 3/5] Update parse.js
---
scripts/commands/channels/parse.js | 29 +++++++++++++++++++++--------
1 file changed, 21 insertions(+), 8 deletions(-)
diff --git a/scripts/commands/channels/parse.js b/scripts/commands/channels/parse.js
index 0200de32..84e8f175 100644
--- a/scripts/commands/channels/parse.js
+++ b/scripts/commands/channels/parse.js
@@ -1,4 +1,4 @@
-const { logger, file, xml } = require('../../core')
+const { logger, file, xml, parser } = require('../../core')
const { Command } = require('commander')
const path = require('path')
const _ = require('lodash')
@@ -8,31 +8,44 @@ program
.requiredOption('-c, --config ', 'Config file')
.option('-s, --set [args...]', 'Set custom arguments', [])
.option('-o, --output