From 129d62d897a17fd8e5b10eb4f4366381fbb75f41 Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Sat, 20 Nov 2021 23:22:44 +0300 Subject: [PATCH 1/5] Create teliatv.ee.test.js --- sites/teliatv.ee/teliatv.ee.test.js | 66 +++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 sites/teliatv.ee/teliatv.ee.test.js diff --git a/sites/teliatv.ee/teliatv.ee.test.js b/sites/teliatv.ee/teliatv.ee.test.js new file mode 100644 index 00000000..9e52fc6a --- /dev/null +++ b/sites/teliatv.ee/teliatv.ee.test.js @@ -0,0 +1,66 @@ +// node ./scripts/channels.js --config=./sites/teliatv.ee/teliatv.ee.config.js --output=./sites/teliatv.ee/teliatv.ee_ee-et.channels.xml --set=lang:et +// node ./scripts/channels.js --config=./sites/teliatv.ee/teliatv.ee.config.js --output=./sites/teliatv.ee/teliatv.ee_ee-ru.channels.xml --set=lang:ru +// node ./scripts/channels.js --config=./sites/teliatv.ee/teliatv.ee.config.js --output=./sites/teliatv.ee/teliatv.ee_ee-en.channels.xml --set=lang:en +// npx epg-grabber --config=sites/teliatv.ee/teliatv.ee.config.js --channels=sites/teliatv.ee/teliatv.ee_ee-et.channels.xml --output=.gh-pages/guides/ee-et/teliatv.ee.epg.xml --days=2 + +const { parser, url, logo } = require('./teliatv.ee.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-20', 'YYYY-MM-DD').startOf('d') +const channel = { + lang: 'et', + site_id: '1', + xmltv_id: 'ETV.ee' +} + +it('can generate valid url', () => { + expect(url({ date, channel })).toBe( + 'https://api.teliatv.ee/dtv-api/3.2/et/epg/guide?channelIds=1&relations=programmes&images=webGuideItemLarge&startAt=2021-11-21T00:00&startAtOp=lte&endAt=2021-11-20T00:00&endAtOp=gt' + ) +}) + +it('can generate valid url with different language', () => { + const ruChannel = { + lang: 'ru', + site_id: '1', + xmltv_id: 'ETV.ee' + } + expect(url({ date, channel: ruChannel })).toBe( + 'https://api.teliatv.ee/dtv-api/3.2/ru/epg/guide?channelIds=1&relations=programmes&images=webGuideItemLarge&startAt=2021-11-21T00:00&startAtOp=lte&endAt=2021-11-20T00:00&endAtOp=gt' + ) +}) + +it('can generate valid logo url', () => { + expect(logo({ channel })).toBe('https://inet-static.mw.elion.ee/images/channels/300x300/1.png') +}) + +it('can parse response', () => { + const content = `{"categoryItems":{"1":[{"id":136227,"type":"epgSeries","name":"Inimjaht","originalName":"Manhunt","price":null,"owner":"ETV","ownerId":1,"images":{"webGuideItemLarge":"/resized/ri93Qj4OLXXvg7QAsUOcKMnIb3g=/570x330/filters:format(jpeg)/inet-static.mw.elion.ee/epg_images/9/b/17e48b3966e65c02.jpg"},"packetIds":[30,34,38,129,130,162,191,242,243,244,447,483,484,485,486],"related":{"programmeIds":[27224371]}}]},"relations":{"programmes":{"27224371":{"id":27224371,"startAt":"2021-11-20T00:05:00+02:00","endAt":"2021-11-20T00:55:00+02:00","publicTo":"2021-12-04T02:05:00+02:00","status":"default","channelId":1,"broadcastId":78248901,"hasMarkers":false,"catchup":false}}}}` + const result = parser({ content, channel }).map(p => { + p.start = p.start.toJSON() + p.stop = p.stop.toJSON() + return p + }) + + expect(result).toMatchObject([ + { + start: '2021-11-19T22:05:00.000Z', + stop: '2021-11-19T22:55:00.000Z', + title: `Inimjaht`, + icon: 'https://inet-static.mw.elion.ee/resized/ri93Qj4OLXXvg7QAsUOcKMnIb3g=/570x330/filters:format(jpeg)/inet-static.mw.elion.ee/epg_images/9/b/17e48b3966e65c02.jpg' + } + ]) +}) + +it('can handle empty guide', () => { + const result = parser({ + date, + channel, + content: `{"categoryItems":{},"relations":{}}` + }) + expect(result).toMatchObject([]) +}) From 0a61d7637435bdb2dddda5e72dde4894a4cca193 Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Sat, 20 Nov 2021 23:23:00 +0300 Subject: [PATCH 2/5] Create teliatv.ee.config.js --- sites/teliatv.ee/teliatv.ee.config.js | 69 +++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 sites/teliatv.ee/teliatv.ee.config.js diff --git a/sites/teliatv.ee/teliatv.ee.config.js b/sites/teliatv.ee/teliatv.ee.config.js new file mode 100644 index 00000000..b1f740a7 --- /dev/null +++ b/sites/teliatv.ee/teliatv.ee.config.js @@ -0,0 +1,69 @@ +const axios = require('axios') +const dayjs = require('dayjs') + +module.exports = { + site: 'teliatv.ee', + url({ date, channel }) { + return `https://api.teliatv.ee/dtv-api/3.2/${channel.lang}/epg/guide?channelIds=${ + channel.site_id + }&relations=programmes&images=webGuideItemLarge&startAt=${date + .add(1, 'd') + .format('YYYY-MM-DDTHH:mm')}&startAtOp=lte&endAt=${date.format( + 'YYYY-MM-DDTHH:mm' + )}&endAtOp=gt` + }, + logo({ channel }) { + return `https://inet-static.mw.elion.ee/images/channels/300x300/${channel.site_id}.png` + }, + parser({ content, channel }) { + let programs = [] + const items = parseItems(content, channel) + items.forEach(item => { + programs.push({ + title: item.name, + icon: parseIcon(item), + start: dayjs(item.startAt), + stop: dayjs(item.endAt) + }) + }) + + return programs + }, + async channels({ lang }) { + const data = await axios + .get(`https://api.teliatv.ee/dtv-api/3.0/${lang}/channel-lists?listClass=tv&ui=tv-web`) + .then(r => r.data) + .catch(console.log) + + return Object.values(data.channels).map(item => { + return { + lang, + site_id: item.id, + name: item.title + } + }) + } +} + +function parseIcon(item) { + return item.images.webGuideItemLarge + ? `https://inet-static.mw.elion.ee${item.images.webGuideItemLarge}` + : null +} + +function parseItems(content, channel) { + const data = JSON.parse(content) + if (!data || !data.relations || !data.categoryItems) return [] + const items = data.categoryItems[channel.site_id] || [] + + return items + .map(i => { + const programmeId = i.related.programmeIds[0] + if (!programmeId) return null + const progData = data.relations.programmes[programmeId] + if (!progData) return null + + return { ...i, ...progData } + }) + .filter(i => i) +} From c111e3bd3bed62840f17839a46637a106c376267 Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Sat, 20 Nov 2021 23:23:07 +0300 Subject: [PATCH 3/5] Create teliatv.ee_ee-en.channels.xml --- .../teliatv.ee/teliatv.ee_ee-en.channels.xml | 137 ++++++++++++++++++ 1 file changed, 137 insertions(+) create mode 100644 sites/teliatv.ee/teliatv.ee_ee-en.channels.xml diff --git a/sites/teliatv.ee/teliatv.ee_ee-en.channels.xml b/sites/teliatv.ee/teliatv.ee_ee-en.channels.xml new file mode 100644 index 00000000..9fc0af2a --- /dev/null +++ b/sites/teliatv.ee/teliatv.ee_ee-en.channels.xml @@ -0,0 +1,137 @@ + + + + 1+2 + Aljazeera English + Alo TV + AMC Russia + Animal Planet Rossiya + ARTE Français + BBC Earth Asia + BBC World News Europe + Bloomberg TV Europe + Boomerang Central & Eastern Europe + Canal 24 Horas + Cartoon Network Russia & South East Europe + Club MTV + C Music TV + CNBC Europe + CNN International Europe + Discovery Channel Rossiya + Discovery Science Rossiya + Disney Channel Scandinavia + Disney Junior Scandinavia + Dom Kino International + Dozhd + DTX Rossiya + Duck TV SD + Duo 3 + Duo 4 + Duo 5 + Duo 6 + Duo 7 + Dusk + DW English + Eesti Kanal + Entusiast TV + Epic Drama + ETV + ETV 2 + ETV + + Eurochannel + EuroNews Russkiy + Eurosport 1 Rossiya + FashionTV Russia + Fight Sports + Filmzone + Filmzone+ + Fox Life Russia + Fox Russia + France 2 + France 24 English + Fuel TV + History 2 Asia + History Russia + Hustler TV Europe + Inspira + Investigation Discovery Rossiya + Kanal 2 + Karusel International + Kidzone+ + KidZone TV + KIKA + Life TV + Lolo TV + MCM Top Russia + Mezzo + Mezzo Live HD + Moya Planeta + MTV 00s + MTV 80s + MTV 90s + MTV Global + MTV Hits Europe + MTV Live HD + MyHits + MyZen TV + National Geographic Channel HD Europe + National Geographic Wild Europe + Nickelodeon CIS + Nick Jr Scandinavia + Nicktoons Scandinavia + N-TV + NTV Mir Baltic + NTV Serial + Okhota i Rybalka + Orsent TV + Perviy Baltijskyi Kanal + Private TV + ProSieben Deutschland + Pyatnitsa! International + Rai 1 + RBK TV + REN TV Baltic + RFM TV + Rossiya 24 + RTL Deutschland + RTR Planeta + Sat. 1 Deutschland + Setanta Sports 1 Evraziya + Sky News International + Smartzone + Stingray Classica + Stingray Djazz + Stingray IConcerts + STS Baltic + Super RTL Deutschland + Taevas TV7 + TBN Baltia + Telecafé International + Telekanal Futbol + TLC Russia + TNT Comedy + Travel Channel Europe + TV 3 Eesti + TV 3 Film + TV 3 Plus + TV 3 Sport + TV 3 Sport 2 + TV5Monde Europe + TV 6 Eesti + TV 1000 Action + TV 1000 East + TV 1000 Russkoe Kino + TV Centr International + TVE Internacional Europa + TVN + TV XXI + Usadba International + Viasat Explore + Viasat History + Viasat Nature East + VIP Comedy + Vremya + YLE TV 1 + YLE TV 2 + + \ No newline at end of file From 496251ff5fbcc73ddb4ed9e61b55d61967ff0b8a Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Sat, 20 Nov 2021 23:23:10 +0300 Subject: [PATCH 4/5] Create teliatv.ee_ee-et.channels.xml --- .../teliatv.ee/teliatv.ee_ee-et.channels.xml | 137 ++++++++++++++++++ 1 file changed, 137 insertions(+) create mode 100644 sites/teliatv.ee/teliatv.ee_ee-et.channels.xml diff --git a/sites/teliatv.ee/teliatv.ee_ee-et.channels.xml b/sites/teliatv.ee/teliatv.ee_ee-et.channels.xml new file mode 100644 index 00000000..67ed72a9 --- /dev/null +++ b/sites/teliatv.ee/teliatv.ee_ee-et.channels.xml @@ -0,0 +1,137 @@ + + + + 1+2 + Aljazeera English + Alo TV + AMC Russia + Animal Planet Rossiya + ARTE Français + BBC Earth Asia + BBC World News Europe + Bloomberg TV Europe + Boomerang Central & Eastern Europe + Canal 24 Horas + Cartoon Network Russia & South East Europe + Club MTV + C Music TV + CNBC Europe + CNN International Europe + Discovery Channel Rossiya + Discovery Science Rossiya + Disney Channel Scandinavia + Disney Junior Scandinavia + Dom Kino International + Dozhd + DTX Rossiya + Duck TV SD + Duo 3 + Duo 4 + Duo 5 + Duo 6 + Duo 7 + Dusk + DW English + Eesti Kanal + Entusiast TV + Epic Drama + ETV + ETV 2 + ETV + + Eurochannel + EuroNews Russkiy + Eurosport 1 Rossiya + FashionTV Russia + Fight Sports + Filmzone + Filmzone+ + Fox Life Russia + Fox Russia + France 2 + France 24 English + Fuel TV + History 2 Asia + History Russia + Hustler TV Europe + Inspira + Investigation Discovery Rossiya + Kanal 2 + Karusel International + Kidzone+ + KidZone TV + KIKA + Life TV + Lolo TV + MCM Top Russia + Mezzo + Mezzo Live HD + Moya Planeta + MTV 00s + MTV 80s + MTV 90s + MTV Global + MTV Hits Europe + MTV Live HD + MyHits + MyZen TV + National Geographic Channel HD Europe + National Geographic Wild Europe + Nickelodeon CIS + Nick Jr Scandinavia + Nicktoons Scandinavia + N-TV + NTV Mir Baltic + NTV Serial + Okhota i Rybalka + Orsent TV + Perviy Baltijskyi Kanal + Private TV + ProSieben Deutschland + Pyatnitsa! International + Rai 1 + RBK TV + REN TV Baltic + RFM TV + Rossiya 24 + RTL Deutschland + RTR Planeta + Sat. 1 Deutschland + Setanta Sports 1 Evraziya + Sky News International + Smartzone + Stingray Classica + Stingray Djazz + Stingray IConcerts + STS Baltic + Super RTL Deutschland + Taevas TV7 + TBN Baltia + Telecafé International + Telekanal Futbol + TLC Russia + TNT Comedy + Travel Channel Europe + TV 3 Eesti + TV 3 Film + TV 3 Plus + TV 3 Sport + TV 3 Sport 2 + TV5Monde Europe + TV 6 Eesti + TV 1000 Action + TV 1000 East + TV 1000 Russkoe Kino + TV Centr International + TVE Internacional Europa + TVN + TV XXI + Usadba International + Viasat Explore + Viasat History + Viasat Nature East + VIP Comedy + Vremya + YLE TV 1 + YLE TV 2 + + \ No newline at end of file From b1bb1b033cd0c6311f169fcc08025216cdab9058 Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Sat, 20 Nov 2021 23:23:15 +0300 Subject: [PATCH 5/5] Create teliatv.ee_ee-ru.channels.xml --- .../teliatv.ee/teliatv.ee_ee-ru.channels.xml | 137 ++++++++++++++++++ 1 file changed, 137 insertions(+) create mode 100644 sites/teliatv.ee/teliatv.ee_ee-ru.channels.xml diff --git a/sites/teliatv.ee/teliatv.ee_ee-ru.channels.xml b/sites/teliatv.ee/teliatv.ee_ee-ru.channels.xml new file mode 100644 index 00000000..d070011c --- /dev/null +++ b/sites/teliatv.ee/teliatv.ee_ee-ru.channels.xml @@ -0,0 +1,137 @@ + + + + 1+2 + Aljazeera English + Alo TV + AMC Russia + Animal Planet Rossiya + ARTE Français + BBC Earth Asia + BBC World News Europe + Bloomberg TV Europe + Boomerang Central & Eastern Europe + Canal 24 Horas + Cartoon Network Russia & South East Europe + Club MTV + C Music TV + CNBC Europe + CNN International Europe + Discovery Channel Rossiya + Discovery Science Rossiya + Disney Channel Scandinavia + Disney Junior Scandinavia + Dom Kino International + Dozhd + DTX Rossiya + Duck TV SD + Duo 3 + Duo 4 + Duo 5 + Duo 6 + Duo 7 + Dusk + DW English + Eesti Kanal + Entusiast TV + Epic Drama + ETV + ETV 2 + ETV + + Eurochannel + EuroNews Russkiy + Eurosport 1 Rossiya + FashionTV Russia + Fight Sports + Filmzone + Filmzone+ + Fox Life Russia + Fox Russia + France 2 + France 24 English + Fuel TV + History 2 Asia + History Russia + Hustler TV Europe + Inspira + Investigation Discovery Rossiya + Kanal 2 + Karusel International + Kidzone+ + KidZone TV + KIKA + Life TV + Lolo TV + MCM Top Russia + Mezzo + Mezzo Live HD + Moya Planeta + MTV 00s + MTV 80s + MTV 90s + MTV Global + MTV Hits Europe + MTV Live HD + MyHits + MyZen TV + National Geographic Channel HD Europe + National Geographic Wild Europe + Nickelodeon CIS + Nick Jr Scandinavia + Nicktoons Scandinavia + N-TV + NTV Mir Baltic + NTV Serial + Okhota i Rybalka + Orsent TV + Perviy Baltijskyi Kanal + Private TV + ProSieben Deutschland + Pyatnitsa! International + Rai 1 + RBK TV + REN TV Baltic + RFM TV + Rossiya 24 + RTL Deutschland + RTR Planeta + Sat. 1 Deutschland + Setanta Sports 1 Evraziya + Sky News International + Smartzone + Stingray Classica + Stingray Djazz + Stingray IConcerts + STS Baltic + Super RTL Deutschland + Taevas TV7 + TBN Baltia + Telecafé International + Telekanal Futbol + TLC Russia + TNT Comedy + Travel Channel Europe + TV 3 Eesti + TV 3 Film + TV 3 Plus + TV 3 Sport + TV 3 Sport 2 + TV5Monde Europe + TV 6 Eesti + TV 1000 Action + TV 1000 East + TV 1000 Russkoe Kino + TV Centr International + TVE Internacional Europa + TVN + TV XXI + Usadba International + Viasat Explore + Viasat History + Viasat Nature East + VIP Comedy + Vremya + YLE TV 1 + YLE TV 2 + + \ No newline at end of file