From dbdd0b1a2576de8a895e758c885116a31cd20efd Mon Sep 17 00:00:00 2001 From: rsundp <107715710+rsundp@users.noreply.github.com> Date: Sun, 19 Jun 2022 14:10:01 +0100 Subject: [PATCH 1/4] Update kvf.fo.config.js --- sites/kvf.fo/kvf.fo.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sites/kvf.fo/kvf.fo.config.js b/sites/kvf.fo/kvf.fo.config.js index d09cc65c..475af06a 100644 --- a/sites/kvf.fo/kvf.fo.config.js +++ b/sites/kvf.fo/kvf.fo.config.js @@ -11,7 +11,7 @@ dayjs.extend(customParseFormat) module.exports = { site: 'kvf.fo', url({ date }) { - return `https://kvf.fo/nskra/uv?date=${date.format('YYYY-MM-DD')}` + return `https://kvf.fo/nskra/sv?date=${date.format('YYYY-MM-DD')}` }, parser({ content, date }) { let programs = [] From ccec99524d409aee0dbaa155b07b8722bb89f9a7 Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Fri, 1 Jul 2022 06:09:07 +0300 Subject: [PATCH 2/4] Create example.html --- sites/kvf.fo/__data__/example.html | 1008 ++++++++++++++++++++++++++++ 1 file changed, 1008 insertions(+) create mode 100644 sites/kvf.fo/__data__/example.html diff --git a/sites/kvf.fo/__data__/example.html b/sites/kvf.fo/__data__/example.html new file mode 100644 index 00000000..5d739ee3 --- /dev/null +++ b/sites/kvf.fo/__data__/example.html @@ -0,0 +1,1008 @@ + + + + + + + + + + + + + + | Kringvarp Føroya + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + +
+ + + +
+ + + +
+ + +
+ +
+
+ + +

+ +
+
+ + +
+
+
+
+
+
+
+ + + +
+ +
+ + +
+
+
+
+
+
+
+
+
+
+ + + +
+
+
+ +
+
+
+

fríggjadagur

+

1. juli 2022

+
+ +
+
+ + + +
+
+ +
+
10:00 - 10:29
+
+
+ +
+
10:30 - 10:50
+
Heimafimleikur við Sofíu 8:20
+
+ +
+
18:05 - 18:30
+
Letibygd 13
+
+ +
+
18:30 - 18:51
+
MORSA 3:12
+
+ +
+
19:00 - 19:25
+
Dagur og vika
+
+ +
+
19:35 - 20:15
+
Gekkur
+
+ +
+
20:15 - 21:51
+
The Duff
+
+ +
+
21:50 - 22:43
+
Melvin Kakooza Show 1
+
+ +
+
22:45 - 23:10
+
Dagur og vika
+
+ +
+
23:10 - 00:46
+
Non-Stop
+
+ + + + + + +
+ + +
+
+
+
+
+
+ + + + + + +
+
+ + + +
+
+
+
+
Nýggjastu sendingar í SV
+ +
+ + + +
+
+ + +
Mánadag 27. juni
+
3-2
+
141573
+
+ + +
Sunnudag 26. juni
+
Andakt við Róland í Skorini
+
141518
+
+ + +
Leygardag 25. juni
+
Video: 5mf kvinnur, jóansøka 2022
+
141491
+
+ + +
Leygardag 25. juni
+
Video: 10mf, jóansøka 2022
+
141489
+
+ + +
Leygardag 25. juni
+
Video: 5mf dreingir, 17-18 ár, jóansøka 2022
+
141488
+
+ + + + + + +
+ + +
+
+
+
+
+
+
+ +
+
+
+ + +
+ +
+ + + + + + + + + + + + + From efaea9d284e40656cfebf429fc24ed13dc1e3496 Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Fri, 1 Jul 2022 06:09:10 +0300 Subject: [PATCH 3/4] Update kvf.fo.config.js --- sites/kvf.fo/kvf.fo.config.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/sites/kvf.fo/kvf.fo.config.js b/sites/kvf.fo/kvf.fo.config.js index 475af06a..5b869781 100644 --- a/sites/kvf.fo/kvf.fo.config.js +++ b/sites/kvf.fo/kvf.fo.config.js @@ -20,6 +20,7 @@ module.exports = { const prev = programs[programs.length - 1] const $item = cheerio.load(item) let start = parseStart($item, date) + if (!start) return if (prev && start.isBefore(prev.stop)) { start = start.add(1, 'd') date = date.add(1, 'd') @@ -65,7 +66,5 @@ function parseTitle($item) { function parseItems(content) { const $ = cheerio.load(content) - return $( - '#block-system-main > div > div > div.panels-flexible-row.panels-flexible-row-339-main-row.panels-flexible-row-last.clearfix > div > div.panels-flexible-region.panels-flexible-region-339-center.panels-flexible-region-first > div > div > div > div > div.view-content > div.views-row' - ).toArray() + return $('.view > .view-content > div.views-row').toArray() } From 79126803c12604e3e2f1cbc8723934f38a975726 Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Fri, 1 Jul 2022 06:09:16 +0300 Subject: [PATCH 4/4] Update kvf.fo.test.js --- sites/kvf.fo/kvf.fo.test.js | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/sites/kvf.fo/kvf.fo.test.js b/sites/kvf.fo/kvf.fo.test.js index 181d6515..2493c982 100644 --- a/sites/kvf.fo/kvf.fo.test.js +++ b/sites/kvf.fo/kvf.fo.test.js @@ -1,6 +1,8 @@ -// npx epg-grabber --config=sites/kvf.fo/kvf.fo.config.js --channels=sites/kvf.fo/kvf.fo_fo.channels.xml --output=.gh-pages/guides/fo/kvf.fo.epg.xml --days=2 +// npx epg-grabber --config=sites/kvf.fo/kvf.fo.config.js --channels=sites/kvf.fo/kvf.fo_fo.channels.xml --output=guide.xml --days=2 const { parser, url } = require('./kvf.fo.config.js') +const fs = require('fs') +const path = require('path') const dayjs = require('dayjs') const utc = require('dayjs/plugin/utc') const customParseFormat = require('dayjs/plugin/customParseFormat') @@ -14,34 +16,22 @@ const channel = { } it('can generate valid url', () => { - expect(url({ date })).toBe('https://kvf.fo/nskra/uv?date=2021-11-21') + expect(url({ date })).toBe('https://kvf.fo/nskra/sv?date=2021-11-21') }) it('can parse response', () => { - const content = `
00:00 - 02:00
Plátubarrin
23:00 - 00:00
Tónleikur
00:00 - 01:00
Náttarrásin
` + const content = fs.readFileSync(path.resolve(__dirname, './__data__/example.html')) const result = parser({ content, date }).map(p => { p.start = p.start.toJSON() p.stop = p.stop.toJSON() return p }) - expect(result).toMatchObject([ - { - start: '2021-11-21T00:00:00.000Z', - stop: '2021-11-21T02:00:00.000Z', - title: `Plátubarrin` - }, - { - start: '2021-11-21T23:00:00.000Z', - stop: '2021-11-22T00:00:00.000Z', - title: `Tónleikur` - }, - { - start: '2021-11-22T00:00:00.000Z', - stop: '2021-11-22T01:00:00.000Z', - title: `Náttarrásin` - } - ]) + expect(result[2]).toMatchObject({ + start: '2021-11-21T18:05:00.000Z', + stop: '2021-11-21T18:30:00.000Z', + title: `Letibygd 13` + }) }) it('can handle empty guide', () => {