From 65f7b5806511a32ee2b5d89f92ba69e8ce9800f7 Mon Sep 17 00:00:00 2001 From: freearhey <7253922+freearhey@users.noreply.github.com> Date: Fri, 17 Jan 2025 20:30:00 +0300 Subject: [PATCH 1/3] Fix linter issues --- sites/rikstv.no/readme.md | 42 +++---- sites/rikstv.no/rikstv.no.channels.xml | 166 ++++++++++++------------- sites/rikstv.no/rikstv.no.config.js | 148 +++++++++++----------- sites/rikstv.no/rikstv.no.test.js | 138 ++++++++++---------- 4 files changed, 252 insertions(+), 242 deletions(-) diff --git a/sites/rikstv.no/readme.md b/sites/rikstv.no/readme.md index 31eb0b38..463a3282 100644 --- a/sites/rikstv.no/readme.md +++ b/sites/rikstv.no/readme.md @@ -1,21 +1,21 @@ -# rikstv.no - -https://play.rikstv.no/tv-guide - -### Download the guide - -```sh -npm run grab --- --site=rikstv.no -``` - -### Update channel list - -```sh -npm run channels:parse --- --config=./sites/rikstv.no/rikstv.no.config.js --output=./sites/rikstv.no/rikstv.no.channels.xml -``` - -### Test - -```sh -npm test --- rikstv.no -``` +# rikstv.no + +https://play.rikstv.no/tv-guide + +### Download the guide + +```sh +npm run grab --- --site=rikstv.no +``` + +### Update channel list + +```sh +npm run channels:parse --- --config=./sites/rikstv.no/rikstv.no.config.js --output=./sites/rikstv.no/rikstv.no.channels.xml +``` + +### Test + +```sh +npm test --- rikstv.no +``` diff --git a/sites/rikstv.no/rikstv.no.channels.xml b/sites/rikstv.no/rikstv.no.channels.xml index 96aebc97..8e9e46c9 100644 --- a/sites/rikstv.no/rikstv.no.channels.xml +++ b/sites/rikstv.no/rikstv.no.channels.xml @@ -1,83 +1,83 @@ - - - BBC News - Discovery - TLC - Disney Channel - Eurosport 1 - FEM - Frikanalen - REX - National Geographic - NRK Super/3 - NRK1 - NRK1 Tegnspråk - NRK2 - SVT1 - TV 2 Livsstil - TV 2 Direkte - TV 2 Nyheter - TV 2 Zebra - TV3 - TVNorge - TV3+ - Visjon Norge - VOX - Animal Planet - BBC Nordic - TV6 - History Channel - Eurosport Norge - Nick Jr. - Nickelodeon - TV 2 Danmark - DR2 - DR1 - SVT2 - TV4 - CNN - Discovery Science - Investigation Discovery - Norway Live - V Sport + - V Sport 1 - V Sport 2 - V Sport 3 - Hits - Stars - SF-kanalen - TV 2 Sport 1 - TV 2 Sport 2 - Sky News - CNBC - Deutsche Welle - France 24 - NRK1 Sørlandet - NRK1 Nordland - NRK1 Midtnytt - NRK1 Vestfold og Telemark - NRK1 Vestlandsrevyen - NRK1 Nordnytt - NRK1 Innlandet - MTV00s - TV Nord - Travel Channel - Food Network - Euronews - Auto Motor og Sport TV - Rikstoto Direkte - TV Øst - NRK1 Rogaland - NRK1 Møre og Romsdal - NRK1 Lydtekst - NRK2 Lydtekst - NRK3 Super Lydtekst - Heim TV - V sport golf - NRK1 Underteksting - NRK2 Underteksting - Naturkanal1 - V Film Action - V Film Premiere - V Series - + + + BBC News + Discovery + TLC + Disney Channel + Eurosport 1 + FEM + Frikanalen + REX + National Geographic + NRK Super/3 + NRK1 + NRK1 Tegnspråk + NRK2 + SVT1 + TV 2 Livsstil + TV 2 Direkte + TV 2 Nyheter + TV 2 Zebra + TV3 + TVNorge + TV3+ + Visjon Norge + VOX + Animal Planet + BBC Nordic + TV6 + History Channel + Eurosport Norge + Nick Jr. + Nickelodeon + TV 2 Danmark + DR2 + DR1 + SVT2 + TV4 + CNN + Discovery Science + Investigation Discovery + Norway Live + V Sport + + V Sport 1 + V Sport 2 + V Sport 3 + Hits + Stars + SF-kanalen + TV 2 Sport 1 + TV 2 Sport 2 + Sky News + CNBC + Deutsche Welle + France 24 + NRK1 Sørlandet + NRK1 Nordland + NRK1 Midtnytt + NRK1 Vestfold og Telemark + NRK1 Vestlandsrevyen + NRK1 Nordnytt + NRK1 Innlandet + MTV00s + TV Nord + Travel Channel + Food Network + Euronews + Auto Motor og Sport TV + Rikstoto Direkte + TV Øst + NRK1 Rogaland + NRK1 Møre og Romsdal + NRK1 Lydtekst + NRK2 Lydtekst + NRK3 Super Lydtekst + Heim TV + V sport golf + NRK1 Underteksting + NRK2 Underteksting + Naturkanal1 + V Film Action + V Film Premiere + V Series + diff --git a/sites/rikstv.no/rikstv.no.config.js b/sites/rikstv.no/rikstv.no.config.js index 29c64be7..b897473b 100644 --- a/sites/rikstv.no/rikstv.no.config.js +++ b/sites/rikstv.no/rikstv.no.config.js @@ -1,72 +1,76 @@ -const dayjs = require('dayjs') -const utc = require('dayjs/plugin/utc') -const axios = require('axios') - -dayjs.extend(utc) - -module.exports = { - site: 'rikstv.no', - days: 3, - request: { - cache: { - ttl: 60 * 60 * 1000 // 1 hour - } - }, - url({ channel, date }) { - return `https://play.rikstv.no/api/content-search/1/channel/${channel.site_id}/epg/${date.format('YYYY-MM-DD')}` - }, - parser: function ({ content }) { - let data - try { - data = JSON.parse(content) - } catch (error) { - console.error('Error parsing JSON:', error) - return [] - } - - const programs = [] - - if (data && Array.isArray(data)) { - data.forEach(item => { - if (!item) return - //const start = dayjs.utc(item.broadcastedTime) - //const stop = dayjs.utc(item.broadcastedTimeEnd) - - programs.push({ - title: item.seriesName, - sub_title: item.name, - description: item.description || item.synopsis, - season: item.season || null, - episode: item.episode || null, - category: item.genres, - actors: item.actors, - directors: item.director || item.directors, - icon: item.imagePackUri, - start: item.broadcastedTime, - stop: item.broadcastedTimeEnd - }) - }) - } - - return programs - }, - async channels() { - try { - const response = await axios.get('https://play.rikstv.no/api/content-search/1/channel?includePrograms=false') - if (!response.data || !Array.isArray(response.data)) { - console.error('Error: No channels data found') - return [] - } - return response.data.map(item => { - return { - lang: 'no', - site_id: item.channelId, - name: item.serviceName - } - }) - } catch (error) { - console.error('Error fetching channels:', error) - return [] - } - } -} +const dayjs = require('dayjs') +const utc = require('dayjs/plugin/utc') +const axios = require('axios') + +dayjs.extend(utc) + +module.exports = { + site: 'rikstv.no', + days: 3, + request: { + cache: { + ttl: 60 * 60 * 1000 // 1 hour + } + }, + url({ channel, date }) { + return `https://play.rikstv.no/api/content-search/1/channel/${ + channel.site_id + }/epg/${date.format('YYYY-MM-DD')}` + }, + parser: function ({ content }) { + let data + try { + data = JSON.parse(content) + } catch (error) { + console.error('Error parsing JSON:', error) + return [] + } + + const programs = [] + + if (data && Array.isArray(data)) { + data.forEach(item => { + if (!item) return + //const start = dayjs.utc(item.broadcastedTime) + //const stop = dayjs.utc(item.broadcastedTimeEnd) + + programs.push({ + title: item.seriesName, + sub_title: item.name, + description: item.description || item.synopsis, + season: item.season || null, + episode: item.episode || null, + category: item.genres, + actors: item.actors, + directors: item.director || item.directors, + icon: item.imagePackUri, + start: item.broadcastedTime, + stop: item.broadcastedTimeEnd + }) + }) + } + + return programs + }, + async channels() { + try { + const response = await axios.get( + 'https://play.rikstv.no/api/content-search/1/channel?includePrograms=false' + ) + if (!response.data || !Array.isArray(response.data)) { + console.error('Error: No channels data found') + return [] + } + return response.data.map(item => { + return { + lang: 'no', + site_id: item.channelId, + name: item.serviceName + } + }) + } catch (error) { + console.error('Error fetching channels:', error) + return [] + } + } +} diff --git a/sites/rikstv.no/rikstv.no.test.js b/sites/rikstv.no/rikstv.no.test.js index b37143e2..ce0f0959 100644 --- a/sites/rikstv.no/rikstv.no.test.js +++ b/sites/rikstv.no/rikstv.no.test.js @@ -1,66 +1,72 @@ -const { parser, url } = require('./rikstv.no.config.js') -const dayjs = require('dayjs') -const utc = require('dayjs/plugin/utc') -const customParseFormat = require('dayjs/plugin/customParseFormat') - -dayjs.extend(customParseFormat) -dayjs.extend(utc) - -const date = dayjs.utc('2025-01-14', 'YYYY-MM-DD').startOf('d') -const channel = { - site_id: '47', - xmltv_id: 'NRK1.no' -} - -describe('rikstv.no Module Tests', () => { - it('can generate valid url', () => { - expect(url({ date, channel })).toBe(`https://play.rikstv.no/api/content-search/1/channel/${channel.site_id}/epg/${date.format('YYYY-MM-DD')}`) - }) - - it('can parse response', () => { - const content = JSON.stringify([ - { - seriesName: 'Vakre og ville Oman', - name: 'Vakre og ville Oman', - description: 'Oman er eit arabisk skattkammer av unike habitat og variert dyreliv. Rev, kvalhai, reptil og skjelpadder er blant skapningane du finn her.', - season: 1, - episode: 1, - genres: ['Dokumentar', 'Fakta', 'Natur'], - actors: ['Gergana Muskalla'], - director: 'Stefania Muller', - imagePackUri: 'https://imageservice.rikstv.no/hash/EC206C374F42287C0BDF850A7D3CB4D3.jpg', - broadcastedTime: '2025-01-13T23:00:00Z', - broadcastedTimeEnd: '2025-01-13T23:55:00Z' - } - ]) - - const result = parser({ content }).map(p => { - p.start = dayjs(p.start).toISOString() - p.stop = dayjs(p.stop).toISOString() - return p - }) - - expect(result).toMatchObject([ - { - title: 'Vakre og ville Oman', - sub_title: 'Vakre og ville Oman', - description: 'Oman er eit arabisk skattkammer av unike habitat og variert dyreliv. Rev, kvalhai, reptil og skjelpadder er blant skapningane du finn her.', - season: 1, - episode: 1, - category: ['Dokumentar', 'Fakta', 'Natur'], - actors: ['Gergana Muskalla'], - directors: 'Stefania Muller', - icon: 'https://imageservice.rikstv.no/hash/EC206C374F42287C0BDF850A7D3CB4D3.jpg', - start: '2025-01-13T23:00:00.000Z', - stop: '2025-01-13T23:55:00.000Z' - } - ]) - }) - - it('can handle empty guide', () => { - const result = parser({ - content: '[]' - }) - expect(result).toMatchObject([]) - }) -}) +const { parser, url } = require('./rikstv.no.config.js') +const dayjs = require('dayjs') +const utc = require('dayjs/plugin/utc') +const customParseFormat = require('dayjs/plugin/customParseFormat') + +dayjs.extend(customParseFormat) +dayjs.extend(utc) + +const date = dayjs.utc('2025-01-14', 'YYYY-MM-DD').startOf('d') +const channel = { + site_id: '47', + xmltv_id: 'NRK1.no' +} + +describe('rikstv.no Module Tests', () => { + it('can generate valid url', () => { + expect(url({ date, channel })).toBe( + `https://play.rikstv.no/api/content-search/1/channel/${channel.site_id}/epg/${date.format( + 'YYYY-MM-DD' + )}` + ) + }) + + it('can parse response', () => { + const content = JSON.stringify([ + { + seriesName: 'Vakre og ville Oman', + name: 'Vakre og ville Oman', + description: + 'Oman er eit arabisk skattkammer av unike habitat og variert dyreliv. Rev, kvalhai, reptil og skjelpadder er blant skapningane du finn her.', + season: 1, + episode: 1, + genres: ['Dokumentar', 'Fakta', 'Natur'], + actors: ['Gergana Muskalla'], + director: 'Stefania Muller', + imagePackUri: 'https://imageservice.rikstv.no/hash/EC206C374F42287C0BDF850A7D3CB4D3.jpg', + broadcastedTime: '2025-01-13T23:00:00Z', + broadcastedTimeEnd: '2025-01-13T23:55:00Z' + } + ]) + + const result = parser({ content }).map(p => { + p.start = dayjs(p.start).toISOString() + p.stop = dayjs(p.stop).toISOString() + return p + }) + + expect(result).toMatchObject([ + { + title: 'Vakre og ville Oman', + sub_title: 'Vakre og ville Oman', + description: + 'Oman er eit arabisk skattkammer av unike habitat og variert dyreliv. Rev, kvalhai, reptil og skjelpadder er blant skapningane du finn her.', + season: 1, + episode: 1, + category: ['Dokumentar', 'Fakta', 'Natur'], + actors: ['Gergana Muskalla'], + directors: 'Stefania Muller', + icon: 'https://imageservice.rikstv.no/hash/EC206C374F42287C0BDF850A7D3CB4D3.jpg', + start: '2025-01-13T23:00:00.000Z', + stop: '2025-01-13T23:55:00.000Z' + } + ]) + }) + + it('can handle empty guide', () => { + const result = parser({ + content: '[]' + }) + expect(result).toMatchObject([]) + }) +}) From 35f55e4df59377919c159adec135b747579f8ad4 Mon Sep 17 00:00:00 2001 From: freearhey <7253922+freearhey@users.noreply.github.com> Date: Fri, 17 Jan 2025 20:30:17 +0300 Subject: [PATCH 2/3] Update tvgids.nl.test.js --- sites/tvgids.nl/tvgids.nl.test.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/sites/tvgids.nl/tvgids.nl.test.js b/sites/tvgids.nl/tvgids.nl.test.js index 790fb41f..88da3f0a 100644 --- a/sites/tvgids.nl/tvgids.nl.test.js +++ b/sites/tvgids.nl/tvgids.nl.test.js @@ -7,14 +7,16 @@ const customParseFormat = require('dayjs/plugin/customParseFormat') dayjs.extend(customParseFormat) dayjs.extend(utc) -const date = dayjs.utc('2023-06-13', 'YYYY-MM-DD').startOf('d') +const date = dayjs.utc('2025-01-19', 'YYYY-MM-DD').startOf('d') const channel = { site_id: 'npo1', xmltv_id: 'NPO1.nl' } it('can generate valid url', () => { - expect(url({ date, channel })).toBe('https://www.tvgids.nl/gids/13-06-2023/npo1') + jest.useFakeTimers().setSystemTime(new Date('2025-01-17')) + + expect(url({ date, channel })).toBe('https://www.tvgids.nl/gids/19-01-2025/npo1') }) it('can generate valid url for today', () => { @@ -32,16 +34,16 @@ it('can parse response', () => { }) expect(results[0]).toMatchObject({ - start: '2023-06-12T21:57:00.000Z', - stop: '2023-06-12T22:58:00.000Z', + start: '2025-01-18T22:57:00.000Z', + stop: '2025-01-18T23:58:00.000Z', title: 'Op1', image: 'https://tvgidsassets.nl/v301/upload/o/carrousel/op1-451542641.jpg', description: "Talkshow met wisselende presentatieduo's, live vanuit Amsterdam." }) expect(results[61]).toMatchObject({ - start: '2023-06-14T00:18:00.000Z', - stop: '2023-06-14T00:48:00.000Z', + start: '2025-01-20T01:18:00.000Z', + stop: '2025-01-20T01:48:00.000Z', title: 'NOS Journaal', image: 'https://tvgidsassets.nl/v301/upload/n/carrousel/nos-journaal-452818771.jpg', description: From a2d0cb3a8d292d1ce5127bc88521b15580f0098e Mon Sep 17 00:00:00 2001 From: freearhey <7253922+freearhey@users.noreply.github.com> Date: Fri, 17 Jan 2025 20:30:31 +0300 Subject: [PATCH 3/3] Update tvgids.nl.channels.xml --- sites/tvgids.nl/tvgids.nl.channels.xml | 41 +++++++++++++------------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/sites/tvgids.nl/tvgids.nl.channels.xml b/sites/tvgids.nl/tvgids.nl.channels.xml index 7ef462a2..e7c8abdb 100644 --- a/sites/tvgids.nl/tvgids.nl.channels.xml +++ b/sites/tvgids.nl/tvgids.nl.channels.xml @@ -1,36 +1,47 @@ + Al Jazeera Engels + CNN + Extreme Sports Channel + TV E + RTBF La 1 + Mezzo + Rai Uno ARD BBC 1 BBC 2 BBC 4 + BBC News + Canal+ Action Cartoonito Discovery Science E! Entertainment Euronews + HGTV NH Paramount Network RTL Sat 1 STAR Channel + Viaplay TV VRT 1 WDR Fernsehen + Ziggo Sport 2 + Ziggo Sport 3 + Ziggo Sport 4 + Ziggo Sport 5 + Ziggo Sport 6 3Sat 24Kitchen - Al Jazeera Engels Animal Planet ARTE AT5 - BBC Entertainment BBC First - BBC World - Beleef KPN BVN VRT Canvas Cartoon Network CBS Reality CNBC - CNN Comedy Central Crime + Investigation Discovery @@ -42,7 +53,6 @@ ESPN 1 Eurosport 1 Eurosport 2 - Extreme Sports Channel Film1 Action Film1 Drama Film1 Family @@ -51,11 +61,9 @@ HISTORY INPLUS Investigation Discovery - VRT Ketnet + Ketnet L1 TV - RTBF La 1 Love Nature - Mezzo MTV National Geographic Nat Geo Wild @@ -79,7 +87,6 @@ Pebble TV Play4 PRO 7 - Rai Uno RTL 4 RTL 5 RTL 7 @@ -93,15 +100,12 @@ RTV Rijnmond RTV Utrecht SBS 6 - SBS 9 ShortsTV Stingray Classica - RTBF La 2 + RTBF Tipik TLC - TRT World TV5MONDE TV 538 - TV E TV Noord Oranje TV RTV West @@ -110,10 +114,5 @@ XITE ZDF Ziggo Sport - Ziggo Sport Docu - Ziggo Sport Golf - Ziggo Sport Racing - Ziggo Sport Select - Ziggo Sport Tennis - Ziggo Sport Voetbal - \ No newline at end of file + TRT World +