From 2c04324ea205528968883f94b2348c155dd3d5cf Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Tue, 9 Nov 2021 08:41:26 +0300 Subject: [PATCH 1/3] Create tvheute.at.test.js --- sites/tvheute.at/tvheute.at.test.js | 54 +++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 sites/tvheute.at/tvheute.at.test.js diff --git a/sites/tvheute.at/tvheute.at.test.js b/sites/tvheute.at/tvheute.at.test.js new file mode 100644 index 00000000..8d58059c --- /dev/null +++ b/sites/tvheute.at/tvheute.at.test.js @@ -0,0 +1,54 @@ +// npx epg-grabber --config=sites/tvheute.at/tvheute.at.config.js --channels=sites/tvheute.at/tvheute.at_at.channels.xml --output=.gh-pages/guides/at/tvheute.at.epg.xml --days=2 + +const { parser, url, logo, request } = require('./tvheute.at.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('2021-11-08', 'YYYY-MM-DD').startOf('d') +const channel = { site_id: 'orf1', xmltv_id: 'ORF1.at' } +const content = ` +

Das ORF1 Programm mit allen Sendungen live im TV von tv.orf.at. Sie haben eine Sendung verpasst. In der ORF TVthek finden Sie viele Sendungen on demand zum Abruf als online Video und live stream.

ORF1 heute

SKYsp2 ORF2
Sender Zeit Zeit Titel Start Titel
ORF1 Kids
Monchhichi (Wh.) ANIMATIONSSERIE Der Streiche-Wettbewerb
Roger hat sich Ärger mit Dr. Bellows eingehandelt, der ihn für einen Monat strafversetzen möchte. Einmal mehr hadert Roger mit dem Schicksal, dass er keinen eigenen Flaschengeist besitzt, der ihm aus der Patsche helfen kann. Jeannie schlägt vor, ihm Cousine Marilla zu schicken. Doch Tony ist strikt dagegen. Als ein Zaubererpärchen im exotischen Bühnenoutfit für die Zeit von Rogers Abwesenheit sein Apartment in Untermiete bezieht, glaubt Roger, Jeannie habe ihm ihre Verwandte doch noch gesandt.
ORF1
ZIB 18 NACHRICHTEN
+` + +it('can generate valid url', () => { + expect(url({ channel, date })).toBe( + 'https://tvheute.at/part/channel-shows/partial/orf1/08-11-2021' + ) +}) + +it('can get logo url', () => { + expect(logo({ content })).toBe('https://tvheute.at/images/channels/ORF1--1394099696-01.png') +}) + +it('can parse response', () => { + expect(parser({ date, channel, content })).toMatchObject([ + { + start: '2021-11-08T05:00:00.000Z', + stop: '2021-11-08T05:10:00.000Z', + title: 'Monchhichi (Wh.)', + category: 'Kids', + description: + 'Roger hat sich Ärger mit Dr. Bellows eingehandelt, der ihn für einen Monat strafversetzen möchte. Einmal mehr hadert Roger mit dem Schicksal, dass er keinen eigenen Flaschengeist besitzt, der ihm aus der Patsche helfen kann. Jeannie schlägt vor, ihm Cousine Marilla zu schicken. Doch Tony ist strikt dagegen. Als ein Zaubererpärchen im exotischen Bühnenoutfit für die Zeit von Rogers Abwesenheit sein Apartment in Untermiete bezieht, glaubt Roger, Jeannie habe ihm ihre Verwandte doch noch gesandt.', + icon: 'https://tvheute.at/images/orf1/monchhichi_kids--1895216560-00.jpg' + }, + { + start: '2021-11-08T17:00:00.000Z', + stop: '2021-11-08T17:10:00.000Z', + title: 'ZIB 18' + } + ]) +}) + +it('can handle empty guide', () => { + const result = parser({ + date, + channel, + content: `Object moved +

Object moved to here.

+` + }) + expect(result).toMatchObject([]) +}) From 355139238eacb1705cc2fdb3b89c50179228e2a0 Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Tue, 9 Nov 2021 08:42:35 +0300 Subject: [PATCH 2/3] Create tvheute.at.config.js --- sites/tvheute.at/tvheute.at.config.js | 78 +++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 sites/tvheute.at/tvheute.at.config.js diff --git a/sites/tvheute.at/tvheute.at.config.js b/sites/tvheute.at/tvheute.at.config.js new file mode 100644 index 00000000..87081acf --- /dev/null +++ b/sites/tvheute.at/tvheute.at.config.js @@ -0,0 +1,78 @@ +const cheerio = require('cheerio') +const dayjs = require('dayjs') + +module.exports = { + site: 'tvheute.at', + url({ channel, date }) { + return `https://tvheute.at/part/channel-shows/partial/${channel.site_id}/${date.format( + 'DD-MM-YYYY' + )}` + }, + logo({ content }) { + const $ = cheerio.load(content) + const imgSrc = $(`.station-info .logo`).attr('src') + + return imgSrc ? `https://tvheute.at${imgSrc}` : null + }, + parser: function ({ content, channel, date }) { + let programs = [] + const items = parseItems(content) + items.forEach(item => { + programs.push({ + title: parseTitle(item), + description: parseDescription(item), + icon: parseIcon(item), + category: parseCategory(item), + start: parseStart(item).toJSON(), + stop: parseStop(item).toJSON() + }) + }) + + return programs + } +} + +function parseTitle(item) { + const $ = cheerio.load(item) + + return $('.title-col strong').text() +} + +function parseDescription(item) { + const $ = cheerio.load(item) + + return $('.title-col .description').text() +} + +function parseCategory(item) { + const $ = cheerio.load(item) + + return $('.station-col > .type').text() +} + +function parseIcon(item) { + const $ = cheerio.load(item) + const imgSrc = $('.title-col .image img').data('src-desktop') + + return imgSrc ? `https://tvheute.at${imgSrc}` : null +} + +function parseStart(item) { + const $ = cheerio.load(item) + const time = $('.end-col > .duration-wrapper').data('start') + + return dayjs(time) +} + +function parseStop(item) { + const $ = cheerio.load(item) + const time = $('.end-col > .duration-wrapper').data('stop') + + return dayjs(time) +} + +function parseItems(content) { + const $ = cheerio.load(content) + + return $('#showListContainer > table > tbody > tr').toArray() +} From 4a8ac8dab2cffc5e6e895e70429be42f6dc4ef20 Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Tue, 9 Nov 2021 08:42:39 +0300 Subject: [PATCH 3/3] Create tvheute.at_at.channels.xml --- sites/tvheute.at/tvheute.at_at.channels.xml | 57 +++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 sites/tvheute.at/tvheute.at_at.channels.xml diff --git a/sites/tvheute.at/tvheute.at_at.channels.xml b/sites/tvheute.at/tvheute.at_at.channels.xml new file mode 100644 index 00000000..ce43140d --- /dev/null +++ b/sites/tvheute.at/tvheute.at_at.channels.xml @@ -0,0 +1,57 @@ + + + + 3sat + ARTE Deutsch + ATV + ATV 2 + Bayerisches Fernsehen Süd + Das Erste + DAZN 1 Deutschland + Disney Channel Deutschland + DMAX Austria + Eurosport 1 Germany + HR Fernsehen + Kabel Eins Austria + KIKA + MDR Fernsehen Sachsen-Anhalt + NDR Fernsehen Niedersachsen + Nickelodeon Austria + Nitro Austria + N-TV Austria + Oe24 TV + One + ORF 1 + ORF 2 + ORF III + ORF Sport + + Phoenix + ProSieben Austria + ProSieben Maxx Austria + Puls 4 + RBB Berlin + RTL Austria + RTL Crime Deutschland + RTL Living Deutschland + RTL Zwei Austria + Sat. 1 Gold Österreich + Sat. 1 Österreich + Servus TV Österreich + Sixx Austria + Sky Cinema Premieren + Sky Sport 1 + Sky Sport 2 + Sky Sport Austria 1 + Sky Sport Bundesliga 1 + Sport 1 + Super RTL Austria + SWR Fernsehen Baden-Württemberg + Tele 5 + Vox Austria + WDR Fernsehen Köln + Welt + ZDF + ZDF Info + ZDF Neo + + \ No newline at end of file