From d55ba409be619fda86fede038d6d3dcd9afb490b Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Sun, 7 Nov 2021 22:21:29 +0300 Subject: [PATCH 1/3] Create tvplus.com.tr.test.js --- sites/tvplus.com.tr/tvplus.com.tr.test.js | 60 +++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 sites/tvplus.com.tr/tvplus.com.tr.test.js diff --git a/sites/tvplus.com.tr/tvplus.com.tr.test.js b/sites/tvplus.com.tr/tvplus.com.tr.test.js new file mode 100644 index 00000000..bbc69334 --- /dev/null +++ b/sites/tvplus.com.tr/tvplus.com.tr.test.js @@ -0,0 +1,60 @@ +// npx epg-grabber --config=sites/tvplus.com.tr/tvplus.com.tr.config.js --channels=sites/tvplus.com.tr/tvplus.com.tr_tr.channels.xml --output=.gh-pages/guides/tr/tvplus.com.tr.epg.xml --days=2 + +const { parser, url, logo, request } = require('./tvplus.com.tr.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-07', 'YYYY-MM-DD').startOf('d') +const channel = { + site_id: '32', + xmltv_id: '24TV.tr', + logo: 'https://izmottvsc23.tvplus.com.tr:33207/CPS/images/universal/film/poster/fileEntity/20180508/001300/001300000008479203/a226bfdd-9fe8-4c1c-bc0f-f64e624830a6.png' +} +const content = `{"counttotal":"23","playbilllist":[{"country":"","starttime":"20211107000000","type":"PROGRAM","isBlackout":"0","rerun":"0","ppvsubscribed":"0","foreignsn":"134383557","isLive":"0","ratingid":"0","episodeTotalCount":"0","id":"134383557","keyword":"24 Portre","contentType":"0","isnpvr":"1","slsType":"0","iscpvr":"0","advisory":[],"genreIds":["1179"],"istvod":"0","name":"24 Portre","tvodStatus":"0","pictures":[{"href":"https://izmottvsc23.tvplus.com.tr:33207/CPS/images/universal/film/program/202111/20211104/35/20211104000026695lh5.jpg","resolution":["null","null"],"imageType":"0"}],"externalContentCode":"105445035962202111070300","genres":"Yaşam","visittimes":"0","issubscribed":"0","programType":"program","gapFiller":"0","introduce":"Kendi alanında büyük başarılar elde etmiş insanların kendi ağzından hayat hikayeleri ekrana geliyor.","priceType":[{"value":"0","key":"BTV"},{"value":"0","key":"TVOD"}],"endtime":"20211107010000","seasonTotalCount":"0","recordedMediaIds":[],"picture":{},"isLoyalty":"0","isppv":"0","mainGenre":"0","contentRight":"[{\\"mediaId\\":\\"3000435\\",\\"businessType\\":\\"13\\",\\"enable\\":\\"0\\"},{\\"mediaId\\":\\"3000435\\",\\"businessType\\":\\"14\\",\\"enable\\":\\"0\\"},{\\"mediaId\\":\\"3000435\\",\\"businessType\\":\\"15\\",\\"enable\\":\\"1\\"},{\\"mediaId\\":\\"100067919\\",\\"businessType\\":\\"13\\",\\"enable\\":\\"0\\"},{\\"mediaId\\":\\"100067919\\",\\"businessType\\":\\"14\\",\\"enable\\":\\"0\\"},{\\"mediaId\\":\\"100067919\\",\\"businessType\\":\\"15\\",\\"enable\\":\\"1\\"}]","channelid":"32"}],"playbillVersion":[{"channelId":"32","date":"20211108","version":"20211106000043"},{"channelId":"32","date":"20211107","version":"20211105000027"}]}` + +it('can generate valid url', () => { + expect(url).toBe('https://izmottvsc23.tvplus.com.tr:33207/EPG/JSON/PlayBillList') +}) + +it('can generate valid request data', () => { + const result = request.data({ date, channel }) + expect(result).toMatchObject({ + type: '2', + channelid: '32', + begintime: '20211107000000', + endtime: '20211108000000' + }) +}) + +it('can get logo url', () => { + const result = logo({ channel }) + expect(result).toBe( + 'https://izmottvsc23.tvplus.com.tr:33207/CPS/images/universal/film/poster/fileEntity/20180508/001300/001300000008479203/a226bfdd-9fe8-4c1c-bc0f-f64e624830a6.png' + ) +}) + +it('can parse response', () => { + const result = parser({ date, channel, content }) + expect(result).toMatchObject([ + { + start: '2021-11-07T00:00:00.000Z', + stop: '2021-11-07T01:00:00.000Z', + title: '24 Portre', + category: 'Yaşam', + icon: 'https://izmottvsc23.tvplus.com.tr:33207/CPS/images/universal/film/program/202111/20211104/35/20211104000026695lh5.jpg', + description: `Kendi alanında büyük başarılar elde etmiş insanların kendi ağzından hayat hikayeleri ekrana geliyor.` + } + ]) +}) + +it('can handle empty guide', () => { + const result = parser({ + date, + channel, + content: `{"counttotal":"0","playbilllist":[],"playbillVersion":[{"channelId":"10000","date":"20211108","version":"20211107163253"},{"channelId":"10000","date":"20211107","version":"20211107163253"}]}` + }) + expect(result).toMatchObject([]) +}) From 4587a1bae7c52958247b8e50efdf3811b824e4ea Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Sun, 7 Nov 2021 22:21:34 +0300 Subject: [PATCH 2/3] Create tvplus.com.tr.config.js --- sites/tvplus.com.tr/tvplus.com.tr.config.js | 76 +++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 sites/tvplus.com.tr/tvplus.com.tr.config.js diff --git a/sites/tvplus.com.tr/tvplus.com.tr.config.js b/sites/tvplus.com.tr/tvplus.com.tr.config.js new file mode 100644 index 00000000..f26a7fdd --- /dev/null +++ b/sites/tvplus.com.tr/tvplus.com.tr.config.js @@ -0,0 +1,76 @@ +const axios = require('axios') +const dayjs = require('dayjs') +const utc = require('dayjs/plugin/utc') +const customParseFormat = require('dayjs/plugin/customParseFormat') + +dayjs.extend(utc) +dayjs.extend(customParseFormat) + +module.exports = { + site: 'tvplus.com.tr', + url: 'https://izmottvsc23.tvplus.com.tr:33207/EPG/JSON/PlayBillList', + request: { + method: 'POST', + async headers() { + const response = await axios + .post('https://izmottvsc23.tvplus.com.tr:33207/EPG/JSON/Authenticate', { + terminaltype: 'WEBTV_WIDEVINE', + userType: '3', + timezone: 'UTC' + }) + .catch(console.log) + const cookie = Array.isArray(response.headers['set-cookie']) + ? response.headers['set-cookie'].join('; ') + : '' + + return { cookie } + }, + data({ date, channel }) { + return { + type: '2', + channelid: channel.site_id, + begintime: date.format('YYYYMMDDHHmmss'), + endtime: date.add(1, 'd').format('YYYYMMDDHHmmss') + } + } + }, + logo({ channel }) { + return channel.logo + }, + parser: function ({ content }) { + let programs = [] + const items = parseItems(content) + items.forEach(item => { + const start = parseStart(item) + const stop = parseStop(item) + programs.push({ + title: item.name, + category: item.genres, + description: item.introduce, + icon: parseIcon(item), + start: start.toJSON(), + stop: stop.toJSON() + }) + }) + + return programs + } +} + +function parseIcon(item) { + return item.pictures && item.pictures.length ? item.pictures[0].href : null +} + +function parseStart(item) { + return dayjs.utc(item.starttime, 'YYYYMMDDHHmmss') +} + +function parseStop(item) { + return dayjs.utc(item.endtime, 'YYYYMMDDHHmmss') +} + +function parseItems(content) { + const data = JSON.parse(content) + + return data.playbilllist || [] +} From 70e3cde0d2541e3d4a3dd249bbb82c51d34b8770 Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Sun, 7 Nov 2021 22:21:37 +0300 Subject: [PATCH 3/3] Create tvplus.com.tr_tr.channels.xml --- .../tvplus.com.tr_tr.channels.xml | 150 ++++++++++++++++++ 1 file changed, 150 insertions(+) create mode 100644 sites/tvplus.com.tr/tvplus.com.tr_tr.channels.xml diff --git a/sites/tvplus.com.tr/tvplus.com.tr_tr.channels.xml b/sites/tvplus.com.tr/tvplus.com.tr_tr.channels.xml new file mode 100644 index 00000000..70abbca6 --- /dev/null +++ b/sites/tvplus.com.tr/tvplus.com.tr_tr.channels.xml @@ -0,0 +1,150 @@ + + + + 24 Kitchen Türkiye + 24 TV + 360 + A2 + Ada TV + A Haber + Akilli TV + Akit TV + Aljazeera Channel + Aljazeera English + A News + Animaux + A Para + A Spor + ATV Türkiye + Automoto la chaîne + Baby TV Europe + Bengü Türk + Beyaz TV + Bizimev TV + Bloomberg HT + BRT 1 + BRT 2 + Cartoon Network Türkiye + Cem TV + Chasse & Pêche + Çiftçi TV + CNN Türk + Da Vinci + Discovery Channel Türkiye + Discovery Science Türkiye + Disney Channel Türkiye + Disney Junior Türkiye & Polska + Diyanet TV + DMAX Türkiye + Dream Türk + Duck TV HD + DW Deutsch + DW English + EBA TV Ilkokul + EBA TV Lise + EBA TV Ortaokul + Edge Sport + Ekotürk + English Club TV + Epic Drama + EuroNews English + Eurosport 1 + Eurosport 2 + Fashion One Europe + FB TV + FM TV + Fox Crime Türkiye + Fox Türkiye + France 24 Arabic + France 24 English + FX Türkiye + Haber Global + Habertürk + Halk TV + Kadirga TV + Kanal 7 + Kanal 23 + Kanal 26 + Kanal 33 + Kanal D + Kanal Sim + Kanal V + Kibris Genç TV + Kibris Kanal T + Kibris TV + Kon TV + KRT + Love Nature + Meltem TV + Minika Çocuk + Minika Go + MyZen TV + National Geographic Türkiye + National Geographic Wild Türkiye + NBA TV + Nicktoons Türkiye + NTV + Number 1 Aşk + Number 1 Damar + Number 1 Dance + Number 1 Türk + Number 1 TV + On 6 + Power Türk TV + Power TV + Quran TV + RT Arabic + RT Español + Semerkand TV + Show TV + Sinema 2 + Sinema 1001 + Sinema 1002 + Sinema Aile + Sinema Aile 2 + Sinema Aksiyon + Sinema Aksiyon 2 + Sinema Komedi + Sinema TV + Sinema Yerli + Sinema Yerli 2 + Sky News Arabia + Sports TV + S Sport + S Sport 2 + Star TV + Sunna TV + Tarim TV + Tele 1 + Teve 2 + TGRT Haber + TJK TV + TLC Türkiye + TMB TV + TR 35 + TRT 1 + TRT 2 + TRT Arabi + TRT Avaz + TRT Belgesel + TRT Çocuk + TRT Haber + TRT Kurdî + TRT Müzik + TRT Spor + TRT Spor 2 + TRT Türk + TRT World + TV5Monde Europe + TV 8 + TV 8.5 + TV 100 + TV Net + UçanKus TV + Ülke TV + Ulusal Kanal + Vav TV + Viasat Explore + Viasat History HD + + \ No newline at end of file