6 files changed
+36
-25
No files matched your search
@@ -1 +0,0 @@
|
||||
<!doctype html><html lang='is'><head><meta charset="UTF-8" /><meta data-rh="true" content="noarchive" name="robots" /><meta data-rh="true" content="Dagskrá | RÚV Sjónvarp" property="og:title" /><meta data-rh="true" content="Sjónvarp" property="og:description" /><meta data-rh="true" content="https://www.ruv.is/sjonvarp/screenshot/image.png" property="og:image" /><meta data-rh="true" content="https://www.ruv.is/sjonvarp/dagskra/ruv/2022-12-03" property="og:url" /><meta data-rh="true" content="website" property="og:type" /><meta data-rh="true" content="Sjónvarp" name="description" /> <link data-rh="true" href="https://www.ruv.is/sjonvarp/dagskra/ruv/2022-12-03" rel="canonical" /> <link data-rh="true" as="font" href="/spilari/open-sans-latin-400-normal.woff" rel="preload" type="font/woff" /><link data-rh="true" as="font" href="/spilari/open-sans-latin-400-normal.woff2" rel="preload" type="font/woff2" /><link data-rh="true" as="font" href="/spilari/open-sans-latin-600-normal.woff" rel="preload" type="font/woff" /><link data-rh="true" as="font" href="/spilari/open-sans-latin-600-normal.woff2" rel="preload" type="font/woff2" /><link data-rh="true" as="font" href="/spilari/open-sans-latin-700-normal.woff" rel="preload" type="font/woff" /><link data-rh="true" as="font" href="/spilari/open-sans-latin-700-normal.woff2" rel="preload" type="font/woff2" /><link data-rh="true" href="https://www.ruv.is" rel="preconnect" /><link data-rh="true" href="/spilari/favicons/favicon16.png?v=1.5.43" rel="icon" sizes="16x16" type="image/png" /><link data-rh="true" href="/spilari/favicons/favicon32.png?v=1.5.43" rel="icon" sizes="32x32" type="image/png" /><link data-rh="true" href="https://www.google-analytics.com" rel="preconnect" /><link data-rh="true" href="https://cdnjs.cloudflare.com" rel="preconnect" /><link data-rh="true" crossOrigin="true" href="https://myndir.spilari.ruv.is" rel="preconnect" /><link data-rh="true" href="/spilari" rel="preconnect" /><link data-rh="true" href="https://www.ruv.is/gql/" rel="preconnect" /><meta data-rh="true" content="width=device-width, initial-scale=1.0" name="viewport" /><meta data-rh="true" content="ie=edge" http-equiv="X-UA-Compatible" /><meta data-rh="true" content="summary_large_image" name="twitter:card" /><script data-rh="true" id="webtvconfig">window.WEBTVCONFIG = {"baseUrl":"/sjonvarp","image":"/spilari/favicons/menntaruv.png","favicon":{"16":"/spilari/favicons/favicon16.png","32":"/spilari/favicons/favicon32.png"},"showSearch":true,"channels":["ruv","ruv2"],"defaultChannel":"ruv","brand":"ruv","id":"webtv","className":"webtv","title":"RÚV Sjónvarp","description":"Sjónvarp","preBaseUrl":"https://www.ruv.is","brandUrl":"https://www.ruv.is","brandLabel":"Forsíða RÚV","name":"RÚV Sjónvarp","stationType":"tv","programType":"tv","properties":{"showAgeVerification":true,"alwaysShowEpisodeImageIfAvailable":false,"rating":99},"routes":[{"exact":true,"key":"PageNotFound","path":"/sjonvarp/pagenotfound","component":"PageNotFound"},{"exact":true,"path":"/sjonvarp/leit/","key":"tv-search","component":"Search"},{"exact":true,"path":"/sjonvarp/leit/:searchterm","key":"tv-search","component":"Search"},{"exact":true,"path":"/sjonvarp/flokkur/:categoryslug","key":"tv-category","component":"Category"},{"exact":true,"path":"/sjonvarp/","key":"tv-index","component":"Frontpage"},{"exact":true,"path":"/sjonvarp/beint","key":"tv-direct","component":"Direct"},{"exact":true,"path":"/sjonvarp/dagskra","key":"tv-schedule","component":"Schedule"},{"exact":true,"path":"/sjonvarp/dagskra/:channel","key":"tv-schedule","component":"Schedule"},{"exact":true,"path":"/sjonvarp/dagskra/:channel/:date","key":"tv-schedule","component":"Schedule"},{"exact":false,"path":"/krakkaruv","key":"krakkaruv","component":"ChangeConfig","attribute":"krakkaruv"},{"exact":false,"path":"/utvarp","key":"utvarp","component":"ChangeConfig","attribute":"utvarp"},{"exact":false,"path":"/ungruv","key":"ungruv","component":"ChangeConfig","attribute":"ungruv"},{"exact":true,"path":"/sjonvarp/dagskra/:channel/:date/:episode","key":"tv-schedule","component":"Schedule"},{"exact":true,"path":"/sjonvarp/beint","key":"tv-direct","component":"Direct"},{"exact":true,"path":"/sjonvarp/beint/:channel","key":"tv-direct","component":"Direct"},{"exact":true,"path":"/sjonvarp/spila/:slug/:programid/:episodeid","key":"tv-series","component":"Series"},{"exact":true,"path":"/sjonvarp/spila/:slug/:programid/:episodeid/:clipslug","key":"tv-series","component":"Series"},{"exact":false,"path":"/sjonvarp/renningur/:panelslug","key":"tv-panels","component":"Panel"},{"exact":true,"path":"/sjonvarp/spila/:slug/:programid","key":"tv-series","component":"Series"}],"links":[{"title":"Beint","link":"/sjonvarp/beint","childsLabel":"Velja rás","childs":[{"title":"RÚV","link":"/sjonvarp/beint/ruv"},{"title":"RÚV2","link":"/sjonvarp/beint/ruv2"}]},{"title":"Dagskrá","link":"/sjonvarp/dagskra"}],"externalLinks":[]}</script><script data-rh="true" id="cdnsrc">winLine truncated
|
||||
@@ -0,0 +1 @@
|
||||
{"data":{"Schedule":{"events":[{"accessible":true,"accessible_friendly":"Er aðgengilegt til 31. desember 9999.","closed_subtitles":true,"title":"Heimaleikfimi","slug":"heimaleikfimi","original_title":"","subtitle":"","duration_friendly":"10 mín","start_time_friendly":"13:00","end_time_friendly":"13:10","file_expires":null,"image":"https://d38kdhuogyllre.cloudfront.net/fit-in/$$IMAGESIZE$$x/filters:quality(65)/hd_posters/91pvig-3p3hig.jpg","is_header":false,"is_live":false,"is_rerun":true,"web_accessible":true,"description":"Góð ráð og æfingar sem tilvalið er að gera heima. Íris Rut Garðarsdóttir sjúkraþjálfari hefur umsjón með leikfiminni. e.","scope":"Global","rating":null,"id":5296901,"episodeId":"91pvip","programId":30389,"__typename":"ScheduleItem"},{"accessible":false,"accessible_friendly":"Er aðgengilegt til 17. janúar 2024.","closed_subtitles":false,"title":"Kastljós","slug":"kastljos","original_title":"","subtitle":"","duration_friendly":"25 mín","start_time_friendly":"13:10","end_time_friendly":"13:35","file_expires":null,"image":"https://d38kdhuogyllre.cloudfront.net/fit-in/$$IMAGESIZE$$x/filters:quality(65)/hd_posters/9vukn0-t11uco.jpg","is_header":false,"is_live":false,"is_rerun":true,"web_accessible":true,"description":"Lifandi og fjölbreyttur þáttur um fréttir, menningu og dægurmál. Helstu fréttir dagsins eru krufðar og ljósi varpað á litríkt mannlíf um land allt. Umsjón: Baldvin Þór Bergsson, Bergsteinn Sigurðsson, Chanel Björk Sturludóttir, Guðrún Sóley Gestsdóttir og Sigríður Dögg Auðunsdóttir. e.","scope":"Global","rating":null,"id":5295791,"episodeId":null,"programId":33550,"__typename":"ScheduleItem"},{"accessible":false,"accessible_friendly":"Er aðgengilegt til 17. apríl 2023.","closed_subtitles":false,"title":"Útsvar 2016-2017","slug":"utsvar-2016-2017","original_title":"Vestmannaeyjar - Kópavogur","subtitle":"","duration_friendly":"1 klst. 10 mín","start_time_friendly":"13:35","end_time_friendly":"14:45","file_expires":null,"image":"https://d38kdhuogyllre.cloudfront.net/fit-in/$$IMAGESIZE$$x/filters:quality(65)/hd_posters/700s9g-nlj2a8.jpg","is_header":false,"is_live":false,"is_rerun":true,"web_accessible":true,"description":"Spurningakeppni sveitarfélaga. Umsjónarmenn eru Sigmar Guðmundsson og Þóra Arnórsdóttir. Spurningahöfundar: Ævar Örn Jósepsson og Sigyn Blöndal. Dómari: Sveinn Guðmarsson. Stjórn útsendingar: Helgi Jóhannesson. e.","scope":"Global","rating":null,"id":5295716,"episodeId":null,"programId":23491,"__typename":"ScheduleItem"},{"accessible":false,"accessible_friendly":"Er aðgengilegt til 05. júní 2023.","closed_subtitles":false,"title":"Enn ein stöðin","slug":"enn-ein-stodin","original_title":"","subtitle":"(7 af 20)","duration_friendly":"25 mín","start_time_friendly":"14:45","end_time_friendly":"15:10","file_expires":null,"image":"https://d38kdhuogyllre.cloudfront.net/fit-in/$$IMAGESIZE$$x/filters:quality(65)/hd_posters/8he9og-2i3i10.jpg","is_header":false,"is_live":false,"is_rerun":true,"web_accessible":true,"description":"Spaugstofumennirnir Karl Ágúst Úlfsson, Pálmi Gestsson, Randver Þorláksson, Sigurður Sigurjónsson og Örn Árnason bregða á leik. Þáttaröð frá 1996. Stjórn upptöku: Sigurður Snæberg Jónsson. e.","scope":"Global","rating":null,"id":5290573,"episodeId":null,"programId":28673,"__typename":"ScheduleItem"},{"accessible":false,"accessible_friendly":"Er aðgengilegt til 27. mars 2024.","closed_subtitles":false,"title":"Meistarinn - Anne Sofie von Otter","slug":"meistarinn","original_title":"Mästaren","subtitle":"(6 af 8)","duration_friendly":"22 mín","start_time_friendly":"15:10","end_time_friendly":"15:32","file_expires":null,"image":"https://d38kdhuogyllre.cloudfront.net/fit-in/$$IMAGESIZE$$x/filters:quality(65)/hd_posters/9a3flg-lutks0.jpg","is_header":false,"is_live":false,"is_rerun":true,"web_accessible":true,"description":"Hvernig hugsa helstu listamenn og hugsuðir Svíþjóðar og hvaðan sækja þau sér innblástur og hvatningu? Í þessum þáttum er rætt við sænska meistara um sköpunarferlið, ákvarðanatöku og það hvernig mistök geta leitt til nýrra sigra. e.","scope":"Domestic","rating":null,"id":5257323,"episodeId":null,"programId":31259,"__typename":"ScheduleItem"},{"accessible":false,"accessible_friendly":"Er aðgengilegt til 17. apríl 2023.","closed_subtitles":true,"title":"Með okkar augum","slug":"med-okkar-augum","original_title":"","subtitle":"(2 af 6)","duration_friendly":"27 mín","start_time_friendly":"15:30","end_time_friendly":"15:57","file_expires":null,"image":"https://d38kdhuogyllre.cloudfront.net/fit-in/$$IMAGESIZE$$x/filters:quality(65)/hd_posters/7m7alg-24b490.jpg","is_header":false,"is_live":false,"is_rerun":true,"web_accessible":true,"description":"Áttunda þáttaröð þessara margverðlaunuðu þátta sem vakið hafa athygli fyrir nýstárleg og frumleg efnistök. Fólk með þroskahömlun vinnur þættina meLine truncated
|
||||
@@ -1 +0,0 @@
|
||||
<!doctype html><html lang='is'><head><meta charset="UTF-8" /><meta data-rh="true" content="noarchive" name="robots" /><meta data-rh="true" content="Dagskrá | RÚV Sjónvarp" property="og:title" /><meta data-rh="true" content="Sjónvarp" property="og:description" /><meta data-rh="true" content="https://www.ruv.is/sjonvarp/screenshot/image.png" property="og:image" /><meta data-rh="true" content="https://www.ruv.is/sjonvarp/dagskra/ruv/2023-12-03" property="og:url" /><meta data-rh="true" content="website" property="og:type" /><meta data-rh="true" content="Sjónvarp" name="description" /> <link data-rh="true" href="https://www.ruv.is/sjonvarp/dagskra/ruv/2023-12-03" rel="canonical" /> <link data-rh="true" as="font" href="/spilari/open-sans-latin-400-normal.woff" rel="preload" type="font/woff" /><link data-rh="true" as="font" href="/spilari/open-sans-latin-400-normal.woff2" rel="preload" type="font/woff2" /><link data-rh="true" as="font" href="/spilari/open-sans-latin-600-normal.woff" rel="preload" type="font/woff" /><link data-rh="true" as="font" href="/spilari/open-sans-latin-600-normal.woff2" rel="preload" type="font/woff2" /><link data-rh="true" as="font" href="/spilari/open-sans-latin-700-normal.woff" rel="preload" type="font/woff" /><link data-rh="true" as="font" href="/spilari/open-sans-latin-700-normal.woff2" rel="preload" type="font/woff2" /><link data-rh="true" href="https://www.ruv.is" rel="preconnect" /><link data-rh="true" href="/spilari/favicons/favicon16.png?v=1.5.43" rel="icon" sizes="16x16" type="image/png" /><link data-rh="true" href="/spilari/favicons/favicon32.png?v=1.5.43" rel="icon" sizes="32x32" type="image/png" /><link data-rh="true" href="https://www.google-analytics.com" rel="preconnect" /><link data-rh="true" href="https://cdnjs.cloudflare.com" rel="preconnect" /><link data-rh="true" crossOrigin="true" href="https://myndir.spilari.ruv.is" rel="preconnect" /><link data-rh="true" href="/spilari" rel="preconnect" /><link data-rh="true" href="https://www.ruv.is/gql/" rel="preconnect" /><meta data-rh="true" content="width=device-width, initial-scale=1.0" name="viewport" /><meta data-rh="true" content="ie=edge" http-equiv="X-UA-Compatible" /><meta data-rh="true" content="summary_large_image" name="twitter:card" /><script data-rh="true" id="webtvconfig">window.WEBTVCONFIG = {"baseUrl":"/sjonvarp","image":"/spilari/favicons/menntaruv.png","favicon":{"16":"/spilari/favicons/favicon16.png","32":"/spilari/favicons/favicon32.png"},"showSearch":true,"channels":["ruv","ruv2"],"defaultChannel":"ruv","brand":"ruv","id":"webtv","className":"webtv","title":"RÚV Sjónvarp","description":"Sjónvarp","preBaseUrl":"https://www.ruv.is","brandUrl":"https://www.ruv.is","brandLabel":"Forsíða RÚV","name":"RÚV Sjónvarp","stationType":"tv","programType":"tv","properties":{"showAgeVerification":true,"alwaysShowEpisodeImageIfAvailable":false,"rating":99},"routes":[{"exact":true,"key":"PageNotFound","path":"/sjonvarp/pagenotfound","component":"PageNotFound"},{"exact":true,"path":"/sjonvarp/leit/","key":"tv-search","component":"Search"},{"exact":true,"path":"/sjonvarp/leit/:searchterm","key":"tv-search","component":"Search"},{"exact":true,"path":"/sjonvarp/flokkur/:categoryslug","key":"tv-category","component":"Category"},{"exact":true,"path":"/sjonvarp/","key":"tv-index","component":"Frontpage"},{"exact":true,"path":"/sjonvarp/beint","key":"tv-direct","component":"Direct"},{"exact":true,"path":"/sjonvarp/dagskra","key":"tv-schedule","component":"Schedule"},{"exact":true,"path":"/sjonvarp/dagskra/:channel","key":"tv-schedule","component":"Schedule"},{"exact":true,"path":"/sjonvarp/dagskra/:channel/:date","key":"tv-schedule","component":"Schedule"},{"exact":false,"path":"/krakkaruv","key":"krakkaruv","component":"ChangeConfig","attribute":"krakkaruv"},{"exact":false,"path":"/utvarp","key":"utvarp","component":"ChangeConfig","attribute":"utvarp"},{"exact":false,"path":"/ungruv","key":"ungruv","component":"ChangeConfig","attribute":"ungruv"},{"exact":true,"path":"/sjonvarp/dagskra/:channel/:date/:episode","key":"tv-schedule","component":"Schedule"},{"exact":true,"path":"/sjonvarp/beint","key":"tv-direct","component":"Direct"},{"exact":true,"path":"/sjonvarp/beint/:channel","key":"tv-direct","component":"Direct"},{"exact":true,"path":"/sjonvarp/spila/:slug/:programid/:episodeid","key":"tv-series","component":"Series"},{"exact":true,"path":"/sjonvarp/spila/:slug/:programid/:episodeid/:clipslug","key":"tv-series","component":"Series"},{"exact":false,"path":"/sjonvarp/renningur/:panelslug","key":"tv-panels","component":"Panel"},{"exact":true,"path":"/sjonvarp/spila/:slug/:programid","key":"tv-series","component":"Series"}],"links":[{"title":"Beint","link":"/sjonvarp/beint","childsLabel":"Velja rás","childs":[{"title":"RÚV","link":"/sjonvarp/beint/ruv"},{"title":"RÚV2","link":"/sjonvarp/beint/ruv2"}]},{"title":"Dagskrá","link":"/sjonvarp/dagskra"}],"externalLinks":[]}</script><script data-rh="true" id="cdnsrc">winLine truncated
|
||||
@@ -0,0 +1 @@
|
||||
{"data":{"Schedule":{"events":null,"__typename":"Schedule"}}}
|
||||
@@ -12,11 +12,27 @@ module.exports = {
|
||||
site: 'ruv.is',
|
||||
days: 2,
|
||||
url({ channel, date }) {
|
||||
return `https://www.ruv.is/sjonvarp/dagskra/${channel.site_id}/${date.format('YYYY-MM-DD')}`
|
||||
let params = new URLSearchParams()
|
||||
params.append('operationName', 'getSchedule')
|
||||
params.append(
|
||||
'variables',
|
||||
JSON.stringify({ channel: channel.site_id, date: date.format('YYYY-MM-DD') })
|
||||
)
|
||||
params.append(
|
||||
'extensions',
|
||||
JSON.stringify({
|
||||
persistedQuery: {
|
||||
version: 1,
|
||||
sha256Hash: '7d133b9bd9e50127e90f2b3af1b41eb5e89cd386ed9b100b55169f395af350e6'
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
return `https://www.ruv.is/gql/?${params.toString()}`
|
||||
},
|
||||
parser({ content, channel, date }) {
|
||||
parser({ content, date }) {
|
||||
let programs = []
|
||||
const items = parseItems(content, channel, date)
|
||||
const items = parseItems(content, date)
|
||||
items.forEach(item => {
|
||||
let start = parseStart(item, date)
|
||||
let stop = parseStop(item, date)
|
||||
@@ -57,14 +73,8 @@ function parseStop(item, date) {
|
||||
}
|
||||
|
||||
function parseItems(content, channel, date) {
|
||||
const $ = cheerio.load(content)
|
||||
const apollo = $('#apollo').html()
|
||||
const [, state] = apollo.match(/window.__APOLLO_STATE__ = ([^;<]+)/) || [null, '']
|
||||
const data = JSON.parse(state)
|
||||
const data = JSON.parse(content)
|
||||
if (!data || !Array.isArray(data.data.Schedule.events)) return []
|
||||
|
||||
return (
|
||||
data?.ROOT_QUERY?.[
|
||||
`Schedule({"channel":"${channel.site_id}","date":"${date.format('YYYY-MM-DD')}"})`
|
||||
]?.events || []
|
||||
)
|
||||
return data.data.Schedule.events
|
||||
}
|
||||
+12
-11
@@ -9,39 +9,40 @@ const customParseFormat = require('dayjs/plugin/customParseFormat')
|
||||
dayjs.extend(customParseFormat)
|
||||
dayjs.extend(utc)
|
||||
|
||||
const date = dayjs.utc('2022-12-03', 'YYYY-MM-DD').startOf('d')
|
||||
const date = dayjs.utc('2023-01-17', 'YYYY-MM-DD').startOf('d')
|
||||
const channel = {
|
||||
site_id: 'ruv',
|
||||
xmltv_id: 'RUV.is'
|
||||
}
|
||||
|
||||
it('can generate valid url', () => {
|
||||
expect(url({ channel, date })).toBe('https://www.ruv.is/sjonvarp/dagskra/ruv/2022-12-03')
|
||||
expect(url({ channel, date })).toBe(
|
||||
'https://www.ruv.is/gql/?operationName=getSchedule&variables=%7B%22channel%22%3A%22ruv%22%2C%22date%22%3A%222023-01-17%22%7D&extensions=%7B%22persistedQuery%22%3A%7B%22version%22%3A1%2C%22sha256Hash%22%3A%227d133b9bd9e50127e90f2b3af1b41eb5e89cd386ed9b100b55169f395af350e6%22%7D%7D'
|
||||
)
|
||||
})
|
||||
|
||||
it('can parse response', () => {
|
||||
const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.html'))
|
||||
let results = parser({ content, channel, date }).map(p => {
|
||||
const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.json'))
|
||||
let results = parser({ content, date }).map(p => {
|
||||
p.start = p.start.toJSON()
|
||||
p.stop = p.stop.toJSON()
|
||||
return p
|
||||
})
|
||||
|
||||
expect(results[0]).toMatchObject({
|
||||
start: '2022-12-03T07:05:00.000Z',
|
||||
stop: '2022-12-03T07:15:00.000Z',
|
||||
title: `Smástund`,
|
||||
start: '2023-01-17T13:00:00.000Z',
|
||||
stop: '2023-01-17T13:10:00.000Z',
|
||||
title: `Heimaleikfimi`,
|
||||
description:
|
||||
'Smástund hentar vel fyrir þau allra yngstu, í hverjum þætti lærum við orð, liti, tölur og tónlist. e.',
|
||||
icon: 'https://d38kdhuogyllre.cloudfront.net/fit-in/480x/filters:quality(65)/hd_posters/a2kmk0-mcpf0o.jpg'
|
||||
'Góð ráð og æfingar sem tilvalið er að gera heima. Íris Rut Garðarsdóttir sjúkraþjálfari hefur umsjón með leikfiminni. e.',
|
||||
icon: 'https://d38kdhuogyllre.cloudfront.net/fit-in/480x/filters:quality(65)/hd_posters/91pvig-3p3hig.jpg'
|
||||
})
|
||||
})
|
||||
|
||||
it('can handle empty guide', () => {
|
||||
const result = parser({
|
||||
date,
|
||||
channel,
|
||||
content: fs.readFileSync(path.resolve(__dirname, '__data__/no_content.html'))
|
||||
content: fs.readFileSync(path.resolve(__dirname, '__data__/no_content.json'))
|
||||
})
|
||||
expect(result).toMatchObject([])
|
||||
})
|
||||
Reference in new issue
Block a user