diff --git a/sites/turksatkablo.com.tr/turksatkablo.com.tr.config.js b/sites/turksatkablo.com.tr/turksatkablo.com.tr.config.js new file mode 100644 index 00000000..571a6375 --- /dev/null +++ b/sites/turksatkablo.com.tr/turksatkablo.com.tr.config.js @@ -0,0 +1,55 @@ +const dayjs = require('dayjs') +const timezone = require('dayjs/plugin/timezone') +const customParseFormat = require('dayjs/plugin/customParseFormat') + +dayjs.extend(timezone) +dayjs.extend(customParseFormat) + +module.exports = { + site: 'turksatkablo.com.tr', + url: function ({ date }) { + return `https://www.turksatkablo.com.tr/userUpload/EPG/y.json?_=${date.valueOf()}` + }, + parser: function ({ content, channel, date }) { + let PM = false + let programs = [] + const items = parseItems(content, channel) + items.forEach(item => { + let start = parseStart(item, date) + if (start.hour() > 11) PM = true + if (start.hour() < 12 && PM) start = start.add(1, 'd') + let stop = parseStop(item, date) + if (stop.hour() > 11) PM = true + if (stop.hour() < 12 && PM) stop = stop.add(1, 'd') + + programs.push({ + title: item.b, + start: start.toString(), + stop: stop.toString() + }) + }) + + return programs + } +} + +function parseStart(item, date) { + const time = `${date.format('MM/DD/YYYY')} ${item.c}` + + return dayjs.tz(time, 'MM/DD/YYYY HH:mm', 'Europe/Istanbul') +} + +function parseStop(item, date) { + const time = `${date.format('MM/DD/YYYY')} ${item.d}` + + return dayjs.tz(time, 'MM/DD/YYYY HH:mm', 'Europe/Istanbul') +} + +function parseItems(content, channel) { + const parsed = JSON.parse(content) + const channels = parsed.k + if (!channels) return [] + const data = channels.find(c => c.x == channel.site_id) + + return data ? data.p : [] +} diff --git a/sites/turksatkablo.com.tr/turksatkablo.com.tr.test.js b/sites/turksatkablo.com.tr/turksatkablo.com.tr.test.js new file mode 100644 index 00000000..c5d2b465 --- /dev/null +++ b/sites/turksatkablo.com.tr/turksatkablo.com.tr.test.js @@ -0,0 +1,29 @@ +// npx epg-grabber --config=sites/turksatkablo.com.tr/turksatkablo.com.tr.config.js --channels=sites/turksatkablo.com.tr/turksatkablo.com.tr_tr.channels.xml --days=2 --output=.gh-pages/guides/tr/turksatkablo.com.tr.epg.xml + +const { parser, url } = require('./turksatkablo.com.tr.config.js') +const dayjs = require('dayjs') +const utc = require('dayjs/plugin/utc') +dayjs.extend(utc) + +const date = dayjs.utc().startOf('d') +const channel = { site_id: '283', xmltv_id: 'SinemaTV.tr', display_name: 'Sinema TV' } +const content = `{"k":[{"x":283,"i":2,"n":"Sinema TV","p":[{"a":"196432597608","b":"Ölüm Ormanı","c":"01:15","d":"03:00"},{"a":"196432597628","b":"Kızım","c":"15:00","d":"17:00"},{"a": "196441294843","b":"Kaçakçı","c":"23:45","d":"03:45"}]}]}` + +it('can generate valid url', () => { + const result = url({ date }) + expect(result).toBe('https://www.turksatkablo.com.tr/userUpload/EPG/y.json?_=1635292800000') +}) + +it('can parse response', () => { + const result = parser({ date, channel, content }) + expect(result[0]).toMatchObject({ + start: 'Tue, 26 Oct 2021 22:15:00 GMT', + stop: 'Wed, 27 Oct 2021 00:00:00 GMT', + title: 'Ölüm Ormanı' + }) + expect(result[2]).toMatchObject({ + start: 'Wed, 27 Oct 2021 20:45:00 GMT', + stop: 'Thu, 28 Oct 2021 00:45:00 GMT', + title: 'Kaçakçı' + }) +}) diff --git a/sites/turksatkablo.com.tr/turksatkablo.com.tr_tr.channels.xml b/sites/turksatkablo.com.tr/turksatkablo.com.tr_tr.channels.xml new file mode 100644 index 00000000..dfcd3fe4 --- /dev/null +++ b/sites/turksatkablo.com.tr/turksatkablo.com.tr_tr.channels.xml @@ -0,0 +1,154 @@ + + + + 24 Kitchen Türkiye + 24 TV + 360 + 360 Tune Box + A2 + A Haber + Akit TV + Ala Too 24 + Aljazeera Channel + Aljazeera English + A News + Animaux + A Para + Arirang World + A Spor + ATV Türkiye + Automoto la chaîne + Az TV + Baby TV Europe + BBC Entertainment Europe + BBC World News Europe + BBN Türk + BeIn Sports 1 Türkiye + BeIn Sports 2 Türkiye + BeIn Sports 3 Türkiye + BeIn Sports 4 Türkiye + BeIn Sports Haber + BeIn Sports Max 1 Türkiye + BeIn Sports Max 2 Türkiye + Bengü Türk + Beyaz TV + Beykent TV + Bloomberg HT + Bloomberg TV Europe + BRT 1 + Cartoon Network Türkiye + CCTV 4 Europe + CGTN + CGTN Documentary + Chasse & Pêche + CNN Türk + Da Vinci + Discovery Channel Türkiye + Disney Channel Türkiye + Diyanet TV + DMAX Türkiye + DocuBox HD + Duck TV SD + DW Deutsch + DW English + EBA TV Ilkokul + EBA TV Lise + EBA TV Ortaokul + Edge Sport + Ekotürk + English Club TV + Eurosport 1 + Eurosport 2 + Fast & FunBox HD + FB TV + FightBox HD + FilmBox Arthouse Africa & Turkey & Middle East + FilmBox Türkiye + Flash TV + Fox Crime Türkiye + Fox Türkiye + France 24 English + France 24 Français + FunBox UHD + FX Türkiye + Gametoon + Haber Global + Habertürk + Hayat Plus + Investigation Discovery Europe + Kablo Info + Kanal 7 + Kanal B + Kanal D + KBS World + Kibris Genç TV + Kocaeli TV + Kon TV + Minika Çocuk + Minika Go + MyZen TV + National Geographic Türkiye + National Geographic Wild Türkiye + NBA TV + NHK World Japan + NTV + Qazaq TV + Quran TV + Rossiya 24 + RTG International + Saudi TV + Science & Vie TV + Show TV + Sinema 2 + Sinema 1001 + Sinema 1002 + Sinema Aile + Sinema Aile 2 + Sinema Aksiyon + Sinema Aksiyon 2 + Sinema Komedi + Sinema Komedi 2 + Sinema TV + Sinema Yerli + Sinema Yerli 2 + S Sport + S Sport 2 + Star TV + Sunna TV + Teve 2 + TGRT Haber + The History Channel Turkey + TLC Türkiye + TMB + Trace Sport Stars + Trace Urban + Trek + TRT 1 + TRT 2 + TRT Arabi + TRT Avaz + TRT Belgesel + TRT Çocuk + TRT Haber + TRT Kurdî + TRT Müzik + TRT Spor + TRT Spor Yildiz + TRT Türk + TRT World + Türkmeneli TV + TV 5 Monde Europe + TV 8 + TV 8.5 + TV 100 + TV Net + UA TV + UçanKus TV + Ülke TV + Ulusal Kanal + Vav TV + Viasat Explore Türkiye + Viasat History HD + Viasat Nature Türkiye + + \ No newline at end of file