diff --git a/sites/mi.tv/__data__/content.html b/sites/mi.tv/__data__/content.html new file mode 100644 index 00000000..920a8d23 --- /dev/null +++ b/sites/mi.tv/__data__/content.html @@ -0,0 +1 @@ +
Programación 24/7 Canal de Noticias

Programación 24/7 Canal de Noticias Miércoles 24 de noviembre

\ No newline at end of file diff --git a/sites/mi.tv/__data__/no_content.html b/sites/mi.tv/__data__/no_content.html new file mode 100644 index 00000000..6fedfd4c --- /dev/null +++ b/sites/mi.tv/__data__/no_content.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/sites/mi.tv/mi.tv.config.js b/sites/mi.tv/mi.tv.config.js index 4f53f2a9..569259bb 100644 --- a/sites/mi.tv/mi.tv.config.js +++ b/sites/mi.tv/mi.tv.config.js @@ -102,13 +102,41 @@ function parseDescription($item) { return $item('a > div.content > p.synopsis').text().trim() } -function parseImage($item) { - const backgroundImage = $item('a > div.image-parent > div.image').css('background-image') - const [, image] = backgroundImage.match(/url\('(.*)'\)/) || [null, null] - return image +function parseImage($item) { + const styleAttr = $item('a > div.image-parent > div.image').attr('style') + + if (styleAttr) { + const match = styleAttr.match(/background-image:\s*url\(['"]?(.*?)['"]?\)/) + if (match) { + return cleanUrl(match[1]) + } + } + + const backgroundImage = $item('a > div.image-parent > div.image').css('background-image') + + if (backgroundImage && backgroundImage !== 'none') { + const match = backgroundImage.match(/url\(['"]?(.*?)['"]?\)/) + if (match) { + return cleanUrl(match[1]) + } + } + + return null } +function cleanUrl(url) { + if (!url) return null + + return url + .replace(/^['"`\\]+/, '') + .replace(/['"`\\]+$/, '') + .replace(/\\'/g, "'") + .replace(/\\"/g, '"') + .replace(/\\\\/g, '\\') +} + + function parseItems(content) { const $ = cheerio.load(content) diff --git a/sites/mi.tv/mi.tv.test.js b/sites/mi.tv/mi.tv.test.js index 5bd1a9f3..ec5652e0 100644 --- a/sites/mi.tv/mi.tv.test.js +++ b/sites/mi.tv/mi.tv.test.js @@ -1,4 +1,6 @@ const { parser, url } = require('./mi.tv.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') @@ -10,8 +12,6 @@ const channel = { site_id: 'ar#24-7-canal-de-noticias', xmltv_id: '247CanaldeNoticias.ar' } -const content = - '
Programación 24/7 Canal de Noticias

Programación 24/7 Canal de Noticias Miércoles 24 de noviembre

' it('can generate valid url', () => { expect(url({ channel, date })).toBe( @@ -20,6 +20,7 @@ it('can generate valid url', () => { }) it('can parse response', () => { + const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.html'), 'utf8') const result = parser({ content, date }).map(p => { p.start = p.start.toJSON() p.stop = p.stop.toJSON() @@ -60,7 +61,7 @@ it('can handle empty guide', () => { const result = parser({ date, channel, - content: '' + content: '' }) expect(result).toMatchObject([]) }) diff --git a/sites/moji.id/__data__/content.html b/sites/moji.id/__data__/content.html new file mode 100644 index 00000000..1870f972 --- /dev/null +++ b/sites/moji.id/__data__/content.html @@ -0,0 +1 @@ +

schedule

FriAug 18
SatAug 19
SunAug 20
Jam TayangProgram
00:00TRUST
Informasi seputar menjaga vitalitas pria
00:302023 AVC CHALLENGE CUP FOR WOMEN (RECORDED)
India Vs. Vietnam
02:30ONE CHAMPIONSHIP 2021
Siaran laga-laga pertandingan tinju gaya bebas internasional. Meyuguhkan pertarungan sengit dari para petarung profeisional kelas dunia.
03:30VOLLEYBALL NATION\'S LEAGUE 2023 (RECORDED)
TURKI vs BRAZIL
05:00MOJI SPORT
MOJI SPORT
06:15LIPUTAN 6 PAGI MOJI
Kompilasi ragam berita hard news dan soft news baik dari dalam negeri maupun internasional juga info prediksi cuaca di wilayah Indonesia
07:00UNGKAP
Liputan investigasi seputar berbagai topik dan peristiwa hangat serta kontroversial yang terjadi di Indonesia
08:00PIALA KAPOLRI 2023 PUTRI (LIVE)
PIALA KAPOLRI 2023 PUTRI (LIVE)
10:30SERIES PAGI
GANTENG GANTENG SERIGALA
12:30DIAM-DIAM SUKA
DIAM-DIAM SUKA
13:30PIALA KAPOLRI 2023 PUTRA (LIVE)
PIALA KAPOLRI 2023 PUTRA (LIVE)
16:00PIALA KAPOLRI 2023 PUTRI (LIVE)
PIALA KAPOLRI 2023 PUTRI (LIVE)
18:00PIALA KAPOLRI 2023 PUTRA (LIVE)
PIALA KAPOLRI 2023 PUTRA (LIVE)
20:00MOJI DRAMA (CHHOTI SARDARNI)
CHHOTI SARDARNI
21:30SINEMA MALAM (BIDADARI CANTIK DI RUMAH KOST)
(BIDADARI CANTIK DI RUMAH KOST
23:00TRUST
Informasi seputar menjaga vitalitas pria
23:30TRUST
Informasi seputar menjaga vitalitas pria
\ No newline at end of file diff --git a/sites/moji.id/moji.id.test.js b/sites/moji.id/moji.id.test.js index 452a7072..7e487374 100644 --- a/sites/moji.id/moji.id.test.js +++ b/sites/moji.id/moji.id.test.js @@ -1,19 +1,19 @@ const { parser } = require('./moji.id.config.js') +const fs = require('fs') +const path = require('path') const dayjs = require('dayjs') const utc = require('dayjs/plugin/utc') dayjs.extend(utc) const date = dayjs.utc('2023-08-18', 'YYYY-MM-DD').startOf('d') -const content = - '

schedule

FriAug 18
SatAug 19
SunAug 20
Jam TayangProgram
00:00TRUST
Informasi seputar menjaga vitalitas pria
00:302023 AVC CHALLENGE CUP FOR WOMEN (RECORDED)
India Vs. Vietnam
02:30ONE CHAMPIONSHIP 2021
Siaran laga-laga pertandingan tinju gaya bebas internasional. Meyuguhkan pertarungan sengit dari para petarung profeisional kelas dunia.
03:30VOLLEYBALL NATION\'S LEAGUE 2023 (RECORDED)
TURKI vs BRAZIL
05:00MOJI SPORT
MOJI SPORT
06:15LIPUTAN 6 PAGI MOJI
Kompilasi ragam berita hard news dan soft news baik dari dalam negeri maupun internasional juga info prediksi cuaca di wilayah Indonesia
07:00UNGKAP
Liputan investigasi seputar berbagai topik dan peristiwa hangat serta kontroversial yang terjadi di Indonesia
08:00PIALA KAPOLRI 2023 PUTRI (LIVE)
PIALA KAPOLRI 2023 PUTRI (LIVE)
10:30SERIES PAGI
GANTENG GANTENG SERIGALA
12:30DIAM-DIAM SUKA
DIAM-DIAM SUKA
13:30PIALA KAPOLRI 2023 PUTRA (LIVE)
PIALA KAPOLRI 2023 PUTRA (LIVE)
16:00PIALA KAPOLRI 2023 PUTRI (LIVE)
PIALA KAPOLRI 2023 PUTRI (LIVE)
18:00PIALA KAPOLRI 2023 PUTRA (LIVE)
PIALA KAPOLRI 2023 PUTRA (LIVE)
20:00MOJI DRAMA (CHHOTI SARDARNI)
CHHOTI SARDARNI
21:30SINEMA MALAM (BIDADARI CANTIK DI RUMAH KOST)
(BIDADARI CANTIK DI RUMAH KOST
23:00TRUST
Informasi seputar menjaga vitalitas pria
23:30TRUST
Informasi seputar menjaga vitalitas pria
' - it('can handle empty guide', () => { const results = parser({ content: '' }) expect(results).toMatchObject([]) }) it('can parse response', () => { + const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.html'), 'utf8') const results = parser({ content, date }).map(p => { p.start = p.start.year(2023).toJSON() p.stop = p.stop.year(2023).toJSON() diff --git a/sites/mysky.com.ph/__data__/content.json b/sites/mysky.com.ph/__data__/content.json new file mode 100644 index 00000000..0cc6dd0f --- /dev/null +++ b/sites/mysky.com.ph/__data__/content.json @@ -0,0 +1 @@ +{"events":[{"name":"TV PATROL","location":"8","start":"2022/10/04 19:00","end":"2022/10/04 20:00","userData":{"description":"Description example"}},{"name":"DARNA","location":"8","start":"2022/10/05 20:00","end":"2022/10/05 20:45","userData":{"description":""}},{"name":"Zoe Bakes S1","location":"22","start":"2022/10/04 20:30","end":"2022/10/04 21:00","userData":{"description":"Zo Franois Dad is a beekeeper. So for his birthday, she bakes him a special beehiveshaped cake."}}]} \ No newline at end of file diff --git a/sites/mysky.com.ph/mysky.com.ph.test.js b/sites/mysky.com.ph/mysky.com.ph.test.js index 1890037b..fba10472 100644 --- a/sites/mysky.com.ph/mysky.com.ph.test.js +++ b/sites/mysky.com.ph/mysky.com.ph.test.js @@ -1,4 +1,6 @@ const { parser, url } = require('./mysky.com.ph.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') @@ -16,8 +18,7 @@ it('can generate valid url', () => { }) it('can parse response', () => { - const content = - '{"events":[{"name":"TV PATROL","location":"8","start":"2022/10/04 19:00","end":"2022/10/04 20:00","userData":{"description":"Description example"}},{"name":"DARNA","location":"8","start":"2022/10/05 20:00","end":"2022/10/05 20:45","userData":{"description":""}},{"name":"Zoe Bakes S1","location":"22","start":"2022/10/04 20:30","end":"2022/10/04 21:00","userData":{"description":"Zo Franois Dad is a beekeeper. So for his birthday, she bakes him a special beehiveshaped cake."}}]}' + const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.json')) const result = parser({ content, channel, date }).map(p => { p.start = p.start.toJSON() p.stop = p.stop.toJSON() diff --git a/sites/neo.io/__data__/content.json b/sites/neo.io/__data__/content.json new file mode 100644 index 00000000..92aa32fe --- /dev/null +++ b/sites/neo.io/__data__/content.json @@ -0,0 +1,64 @@ +{ + "shows": [ + { + "title": "Napovedujemo", + "show_start": 1735185900, + "show_end": 1735192200, + "timestamp": "5:05 - 6:50", + "show_id": "CUP_IECOM_SLO1_10004660", + "thumbnail": "https://ngimg.siol.tv/sioltv/mtcmsprod/52/0/0/5200d01a-fe5f-487e-835a-274e77227a6b.jpg", + "is_adult": false, + "friendly_id": "napovedujemo_db48", + "pg": "", + "genres": [ + "napovednik" + ], + "year": 0, + "summary": "Vabilo k ogledu naših oddaj.", + "categories": "Ostalo", + "stb_only": false, + "is_live": false, + "original_title": "Napovedujemo" + }, + { + "title": "S0E0 - Hrabri zajčki: Prvi sneg", + "show_start": 1735192200, + "show_end": 1735192800, + "timestamp": "6:50 - 7:00", + "show_id": "CUP_IECOM_SLO1_79637910", + "thumbnail": "https://ngimg.siol.tv/sioltv/mtcmsprod/d6/4/5/d6456f4a-4f0a-4825-90c1-1749abd59688.jpg", + "is_adult": false, + "friendly_id": "hrabri_zajcki_prvi_sneg_1619", + "pg": "", + "genres": [ + "risanka" + ], + "year": 2020, + "summary": "Hrabri zajčki so prispeli v borov gozd in izkusili prvi sneg. Bob in Bu še nikoli nista videla snega. Mami kuha korenčkov kakav, Bu in Bob pa kmalu spoznata novega prijatelja, losa Danija.", + "categories": "Otroški/Mladinski", + "stb_only": false, + "is_live": false, + "original_title": "S0E0 - Brave Bunnies" + }, + { + "title": "Dobro jutro", + "show_start": 1735192800, + "show_end": 1735203900, + "timestamp": "7:00 - 10:05", + "show_id": "CUP_IECOM_SLO1_79637911", + "thumbnail": "https://ngimg.siol.tv/sioltv/mtcmsprod/e1/2/d/e12d8eb4-693a-43d3-89d4-fd96dade9f0f.jpg", + "is_adult": false, + "friendly_id": "dobro_jutro_2f10", + "pg": "", + "genres": [ + "zabavna oddaja" + ], + "year": 2024, + "summary": "Oddaja Dobro jutro poleg informativnih in zabavnih vsebin podaja koristne nasvete o najrazličnejših tematikah iz vsakdanjega življenja.", + "categories": "Razvedrilni program", + "stb_only": false, + "is_live": false, + "original_title": "Dobro jutro" + } + ] + } \ No newline at end of file diff --git a/sites/neo.io/__data__/no_content.json b/sites/neo.io/__data__/no_content.json new file mode 100644 index 00000000..78743050 --- /dev/null +++ b/sites/neo.io/__data__/no_content.json @@ -0,0 +1 @@ +{"shows":[]} \ No newline at end of file diff --git a/sites/neo.io/neo.io.test.js b/sites/neo.io/neo.io.test.js index 295120f7..be6e23a4 100644 --- a/sites/neo.io/neo.io.test.js +++ b/sites/neo.io/neo.io.test.js @@ -1,4 +1,6 @@ const { parser, url } = require('./neo.io.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') @@ -18,72 +20,7 @@ it('can generate valid url', () => { }) it('can parse response', () => { - const content = ` - { - "shows": [ - { - "title": "Napovedujemo", - "show_start": 1735185900, - "show_end": 1735192200, - "timestamp": "5:05 - 6:50", - "show_id": "CUP_IECOM_SLO1_10004660", - "thumbnail": "https://ngimg.siol.tv/sioltv/mtcmsprod/52/0/0/5200d01a-fe5f-487e-835a-274e77227a6b.jpg", - "is_adult": false, - "friendly_id": "napovedujemo_db48", - "pg": "", - "genres": [ - "napovednik" - ], - "year": 0, - "summary": "Vabilo k ogledu naših oddaj.", - "categories": "Ostalo", - "stb_only": false, - "is_live": false, - "original_title": "Napovedujemo" - }, - { - "title": "S0E0 - Hrabri zajčki: Prvi sneg", - "show_start": 1735192200, - "show_end": 1735192800, - "timestamp": "6:50 - 7:00", - "show_id": "CUP_IECOM_SLO1_79637910", - "thumbnail": "https://ngimg.siol.tv/sioltv/mtcmsprod/d6/4/5/d6456f4a-4f0a-4825-90c1-1749abd59688.jpg", - "is_adult": false, - "friendly_id": "hrabri_zajcki_prvi_sneg_1619", - "pg": "", - "genres": [ - "risanka" - ], - "year": 2020, - "summary": "Hrabri zajčki so prispeli v borov gozd in izkusili prvi sneg. Bob in Bu še nikoli nista videla snega. Mami kuha korenčkov kakav, Bu in Bob pa kmalu spoznata novega prijatelja, losa Danija.", - "categories": "Otroški/Mladinski", - "stb_only": false, - "is_live": false, - "original_title": "S0E0 - Brave Bunnies" - }, - { - "title": "Dobro jutro", - "show_start": 1735192800, - "show_end": 1735203900, - "timestamp": "7:00 - 10:05", - "show_id": "CUP_IECOM_SLO1_79637911", - "thumbnail": "https://ngimg.siol.tv/sioltv/mtcmsprod/e1/2/d/e12d8eb4-693a-43d3-89d4-fd96dade9f0f.jpg", - "is_adult": false, - "friendly_id": "dobro_jutro_2f10", - "pg": "", - "genres": [ - "zabavna oddaja" - ], - "year": 2024, - "summary": "Oddaja Dobro jutro poleg informativnih in zabavnih vsebin podaja koristne nasvete o najrazličnejših tematikah iz vsakdanjega življenja.", - "categories": "Razvedrilni program", - "stb_only": false, - "is_live": false, - "original_title": "Dobro jutro" - } - ] - }` - + const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.json')) const result = parser({ content, channel }) expect(result).toMatchObject([ @@ -118,7 +55,7 @@ it('can parse response', () => { it('can handle empty guide', () => { const result = parser({ - content: '{"shows":[]}' + content: fs.readFileSync(path.resolve(__dirname, '__data__/no_content.json')) }) expect(result).toMatchObject([]) }) diff --git a/sites/novacyprus.com/__data__/content.json b/sites/novacyprus.com/__data__/content.json new file mode 100644 index 00000000..f3504a96 --- /dev/null +++ b/sites/novacyprus.com/__data__/content.json @@ -0,0 +1 @@ +{"nodes":[{"datetime":"2021-11-17 06:20:00","day":"Wednesday","numDay":17,"numMonth":11,"month":"November","channelName":"Cyprus Novacinema1HD","channelLog":"https://ssl2.novago.gr/EPG/jsp/images/universal/film/logo/20200210/000100/XTV100000762/d6a2f5e0-dbc0-49c7-9843-e3161ca5ae5d.png","cid":"42","ChannelId":"614","startingTime":"06:20","endTime":"08:10","title":"Δεσμοί Αίματος","description":"Θρίλερ Μυστηρίου","duration":"109","slotDuration":"110","bref":"COMMOBLOOX","mediaItems":[{"MediaListTypeId":"6","CdnUrl":"http://cache-forthnet.secure.footprint.net/linear/3/0/305608_COMMOBLOOX_GUIDE_STILL.jpg"},{"MediaListTypeId":"7","CdnUrl":"http://cache-forthnet.secure.footprint.net/linear/3/0/305608_COMMOBLOOX_POSTER_CROSS.jpg"},{"MediaListTypeId":"8","CdnUrl":"http://cache-forthnet.secure.footprint.net/linear/3/0/305608_COMMOBLOOX_ICON_CYP.jpg"},{"MediaListTypeId":"9","CdnUrl":"http://cache-forthnet.secure.footprint.net/linear/3/0/305608_COMMOBLOOX_POSTER_CYP.jpg"},{"MediaListTypeId":"10","CdnUrl":"http://cache-forthnet.secure.footprint.net/linear/3/0/305608_COMMOBLOOX_BACKGROUND_CYP.jpg"}]},{"datetime":"2021-11-17 06:00:00","day":"Wednesday","numDay":17,"numMonth":11,"month":"November","channelName":"Cyprus Novacinema2HD","channelLog":"https://ssl2.novago.gr/EPG/jsp/images/universal/film/logo/20200210/000100/XTV100000763/24e05354-d6ad-4949-bcb3-a81d1c1d2cba.png","cid":"62","ChannelId":"653","startingTime":"06:00","endTime":"07:40","title":"Ανυπόφοροι Γείτονες","description":"Κωμωδία","duration":"93","slotDuration":"100","bref":"NEIGHBORSX","mediaItems":[{"MediaListTypeId":"7","CdnUrl":"http://cache-forthnet.secure.footprint.net/linear/3/1/312582_NEIGHBORSX_POSTER_CROSS.jpg"},{"MediaListTypeId":"8","CdnUrl":"http://cache-forthnet.secure.footprint.net/linear/3/1/312582_NEIGHBORSX_ICON_CYP.jpg"},{"MediaListTypeId":"9","CdnUrl":"http://cache-forthnet.secure.footprint.net/linear/3/1/312582_NEIGHBORSX_POSTER_CYP.jpg"},{"MediaListTypeId":"10","CdnUrl":"http://cache-forthnet.secure.footprint.net/linear/3/1/312582_NEIGHBORSX_BACKGROUND_CYP.jpg"}]}]} \ No newline at end of file diff --git a/sites/novacyprus.com/__data__/no_content.json b/sites/novacyprus.com/__data__/no_content.json new file mode 100644 index 00000000..a0b8012c --- /dev/null +++ b/sites/novacyprus.com/__data__/no_content.json @@ -0,0 +1 @@ +{"nodes":[],"total":0,"pages":0} \ No newline at end of file diff --git a/sites/novacyprus.com/novacyprus.com.test.js b/sites/novacyprus.com/novacyprus.com.test.js index 095b5998..0f4de631 100644 --- a/sites/novacyprus.com/novacyprus.com.test.js +++ b/sites/novacyprus.com/novacyprus.com.test.js @@ -1,4 +1,6 @@ const { parser, url } = require('./novacyprus.com.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') @@ -18,8 +20,7 @@ it('can generate valid url', () => { }) it('can parse response', () => { - const content = - '{"nodes":[{"datetime":"2021-11-17 06:20:00","day":"Wednesday","numDay":17,"numMonth":11,"month":"November","channelName":"Cyprus Novacinema1HD","channelLog":"https://ssl2.novago.gr/EPG/jsp/images/universal/film/logo/20200210/000100/XTV100000762/d6a2f5e0-dbc0-49c7-9843-e3161ca5ae5d.png","cid":"42","ChannelId":"614","startingTime":"06:20","endTime":"08:10","title":"Δεσμοί Αίματος","description":"Θρίλερ Μυστηρίου","duration":"109","slotDuration":"110","bref":"COMMOBLOOX","mediaItems":[{"MediaListTypeId":"6","CdnUrl":"http://cache-forthnet.secure.footprint.net/linear/3/0/305608_COMMOBLOOX_GUIDE_STILL.jpg"},{"MediaListTypeId":"7","CdnUrl":"http://cache-forthnet.secure.footprint.net/linear/3/0/305608_COMMOBLOOX_POSTER_CROSS.jpg"},{"MediaListTypeId":"8","CdnUrl":"http://cache-forthnet.secure.footprint.net/linear/3/0/305608_COMMOBLOOX_ICON_CYP.jpg"},{"MediaListTypeId":"9","CdnUrl":"http://cache-forthnet.secure.footprint.net/linear/3/0/305608_COMMOBLOOX_POSTER_CYP.jpg"},{"MediaListTypeId":"10","CdnUrl":"http://cache-forthnet.secure.footprint.net/linear/3/0/305608_COMMOBLOOX_BACKGROUND_CYP.jpg"}]},{"datetime":"2021-11-17 06:00:00","day":"Wednesday","numDay":17,"numMonth":11,"month":"November","channelName":"Cyprus Novacinema2HD","channelLog":"https://ssl2.novago.gr/EPG/jsp/images/universal/film/logo/20200210/000100/XTV100000763/24e05354-d6ad-4949-bcb3-a81d1c1d2cba.png","cid":"62","ChannelId":"653","startingTime":"06:00","endTime":"07:40","title":"Ανυπόφοροι Γείτονες","description":"Κωμωδία","duration":"93","slotDuration":"100","bref":"NEIGHBORSX","mediaItems":[{"MediaListTypeId":"7","CdnUrl":"http://cache-forthnet.secure.footprint.net/linear/3/1/312582_NEIGHBORSX_POSTER_CROSS.jpg"},{"MediaListTypeId":"8","CdnUrl":"http://cache-forthnet.secure.footprint.net/linear/3/1/312582_NEIGHBORSX_ICON_CYP.jpg"},{"MediaListTypeId":"9","CdnUrl":"http://cache-forthnet.secure.footprint.net/linear/3/1/312582_NEIGHBORSX_POSTER_CYP.jpg"},{"MediaListTypeId":"10","CdnUrl":"http://cache-forthnet.secure.footprint.net/linear/3/1/312582_NEIGHBORSX_BACKGROUND_CYP.jpg"}]}]}' + const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.json')) const result = parser({ content, channel }).map(p => { p.start = p.start.toJSON() p.stop = p.stop.toJSON() @@ -42,7 +43,7 @@ it('can handle empty guide', () => { const result = parser({ date, channel, - content: '{"nodes":[],"total":0,"pages":0}' + content: fs.readFileSync(path.resolve(__dirname, '__data__/no_content.json')) }) expect(result).toMatchObject([]) }) diff --git a/sites/nowplayer.now.com/__data__/content.json b/sites/nowplayer.now.com/__data__/content.json new file mode 100644 index 00000000..eafb2020 --- /dev/null +++ b/sites/nowplayer.now.com/__data__/content.json @@ -0,0 +1 @@ +[[{"key":"key_202111174524739","vimProgramId":"202111174524739","name":"ViuTVsix Station Closing","start":1637690400000,"end":1637715600000,"date":"20211124","startTime":"02:00AM","endTime":"09:00AM","duration":420,"recordable":false,"restartTv":false,"npvrProg":false,"npvrStartTime":0,"npvrEndTime":0,"cid":"viutvsix station closing","cc":"","isInWatchlist":false}]] \ No newline at end of file diff --git a/sites/nowplayer.now.com/nowplayer.now.com.test.js b/sites/nowplayer.now.com/nowplayer.now.com.test.js index 35d0528a..39e90077 100644 --- a/sites/nowplayer.now.com/nowplayer.now.com.test.js +++ b/sites/nowplayer.now.com/nowplayer.now.com.test.js @@ -1,4 +1,6 @@ const { parser, url, request } = require('./nowplayer.now.com.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') @@ -32,8 +34,7 @@ it('can generate valid request headers', () => { }) it('can parse response', () => { - const content = - '[[{"key":"key_202111174524739","vimProgramId":"202111174524739","name":"ViuTVsix Station Closing","start":1637690400000,"end":1637715600000,"date":"20211124","startTime":"02:00AM","endTime":"09:00AM","duration":420,"recordable":false,"restartTv":false,"npvrProg":false,"npvrStartTime":0,"npvrEndTime":0,"cid":"viutvsix station closing","cc":"","isInWatchlist":false}]]' + const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.json')) const result = parser({ content }).map(p => { p.start = p.start.toJSON() p.stop = p.stop.toJSON() diff --git a/sites/ontvtonight.com/__data__/content.html b/sites/ontvtonight.com/__data__/content.html new file mode 100644 index 00000000..00f26fb4 --- /dev/null +++ b/sites/ontvtonight.com/__data__/content.html @@ -0,0 +1 @@ +
7TWO
12:10 am
What A Carry On
12:50 am
Bones
The Devil In The Details
10:50 pm
Inspector Morse: The Remorseful Day
\ No newline at end of file diff --git a/sites/ontvtonight.com/__data__/no_content.html b/sites/ontvtonight.com/__data__/no_content.html new file mode 100644 index 00000000..6fedfd4c --- /dev/null +++ b/sites/ontvtonight.com/__data__/no_content.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/sites/ontvtonight.com/ontvtonight.com.test.js b/sites/ontvtonight.com/ontvtonight.com.test.js index 8ad6b96b..9f1eaf15 100644 --- a/sites/ontvtonight.com/ontvtonight.com.test.js +++ b/sites/ontvtonight.com/ontvtonight.com.test.js @@ -1,4 +1,6 @@ const { parser, url } = require('./ontvtonight.com.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') @@ -10,8 +12,6 @@ const channel = { site_id: 'au#1692/7two', xmltv_id: '7two.au' } -const content = - '
7TWO
12:10 am
What A Carry On
12:50 am
Bones
The Devil In The Details
10:50 pm
Inspector Morse: The Remorseful Day
' it('can generate valid url', () => { expect(url({ channel, date })).toBe( @@ -20,6 +20,7 @@ it('can generate valid url', () => { }) it('can parse response', () => { + const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.html'), 'utf8') const result = parser({ content, channel, date }).map(p => { p.start = p.start.toJSON() p.stop = p.stop.toJSON() @@ -50,7 +51,7 @@ it('can handle empty guide', () => { const result = parser({ date, channel, - content: '' + content: fs.readFileSync(path.resolve(__dirname, '__data__/no_content.html'), 'utf8') }) expect(result).toMatchObject([]) }) diff --git a/sites/pbsguam.org/__data__/content.html b/sites/pbsguam.org/__data__/content.html new file mode 100644 index 00000000..e946e965 --- /dev/null +++ b/sites/pbsguam.org/__data__/content.html @@ -0,0 +1,5 @@ + \ No newline at end of file diff --git a/sites/pbsguam.org/__data__/no_content.html b/sites/pbsguam.org/__data__/no_content.html new file mode 100644 index 00000000..8ef664e2 --- /dev/null +++ b/sites/pbsguam.org/__data__/no_content.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/sites/pbsguam.org/pbsguam.org.test.js b/sites/pbsguam.org/pbsguam.org.test.js index 70a16680..5921d3cc 100644 --- a/sites/pbsguam.org/pbsguam.org.test.js +++ b/sites/pbsguam.org/pbsguam.org.test.js @@ -1,4 +1,6 @@ const { parser, url } = require('./pbsguam.org.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') @@ -16,11 +18,7 @@ it('can generate valid url', () => { }) it('can parse response', () => { - const content = ` ` + const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.html'), 'utf8') const result = parser({ date, content }).map(p => { p.start = p.start.toJSON() p.stop = p.stop.toJSON() @@ -40,7 +38,7 @@ it('can handle empty guide', () => { const result = parser({ date, channel, - content: ' ' + content: fs.readFileSync(path.resolve(__dirname, '__data__/no_content.html'), 'utf8') }) expect(result).toMatchObject([]) })