diff --git a/sites/dishtv.in/dishtv.in.config.js b/sites/dishtv.in/dishtv.in.config.js new file mode 100644 index 00000000..369b3e35 --- /dev/null +++ b/sites/dishtv.in/dishtv.in.config.js @@ -0,0 +1,83 @@ +const cheerio = require('cheerio') +const dayjs = require('dayjs') +const utc = require('dayjs/plugin/utc') +const timezone = require('dayjs/plugin/timezone') +const customParseFormat = require('dayjs/plugin/customParseFormat') + +dayjs.extend(utc) +dayjs.extend(timezone) +dayjs.extend(customParseFormat) + +module.exports = { + site: 'dishtv.in', + url: `https://www.dishtv.in/WhatsonIndiaWebService.asmx/LoadPagginResultDataForProgram`, + request: { + timeout: 10000, + method: 'POST', + data({ channel, date }) { + return { + Channelarr: channel.site_id, + fromdate: date.format('YYYYMMDDHHmm'), + todate: date.add(1, 'd').format('YYYYMMDDHHmm') + } + } + }, + logo({ content }) { + const data = parseContent(content) + const $ = cheerio.load(data) + + return $(`img.chnl-logo`).attr('src') + }, + parser: function ({ content, channel, date }) { + let programs = [] + const data = parseContent(content) + const items = parseItems(data) + items.forEach(item => { + const title = parseTitle(item) + const start = parseStart(item, date) + const stop = parseStop(item, start) + if (title === 'No Information Available') return + + programs.push({ + title, + start: start.toString(), + stop: stop.toString() + }) + }) + + return programs + } +} + +function parseTitle(item) { + const $ = cheerio.load(item) + + return $('a').text() +} + +function parseStart(item, date) { + const $ = cheerio.load(item) + const onclick = $('i.fa-circle').attr('onclick') + const [_, time] = onclick.match(/RecordingEnteryOpen\('.*','.*','(.*)','.*',.*\)/) + + return dayjs.tz(time, 'YYYYMMDDHHmm', 'Asia/Kolkata') +} + +function parseStop(item, start) { + const $ = cheerio.load(item) + const duration = $('*').data('time') + + return start.add(duration, 'm') +} + +function parseContent(content) { + const data = JSON.parse(content) + + return data.d +} + +function parseItems(data) { + const $ = cheerio.load(data) + + return $('.datatime').toArray() +} diff --git a/sites/dishtv.in/dishtv.in.test.js b/sites/dishtv.in/dishtv.in.test.js new file mode 100644 index 00000000..73b3f187 --- /dev/null +++ b/sites/dishtv.in/dishtv.in.test.js @@ -0,0 +1,50 @@ +// npx epg-grabber --config=sites/dishtv.in/dishtv.in.config.js --channels=sites/dishtv.in/dishtv.in_in.channels.xml --output=.gh-pages/guides/in/dishtv.in.epg.xml --days=2 + +const { parser, url, logo, request } = require('./dishtv.in.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-05', 'YYYY-MM-DD').startOf('d') +const channel = { site_id: '10000000075992337', xmltv_id: 'WomensActive.in' } +const content = `{"d":"\\u003cdiv class=\\"pgrid\\"\\u003e\\u003cdiv class=\\"img sm-30 grid\\"\\u003e\\u003cimg class=\\"chnl-logo\\" src=\\"http://imagesdishtvd2h.whatsonindia.com/dasimages/channel/landscape/360x270/hiyj8ndf.png\\" onclick=\\"ShowChannelGuid(\\u0027womens-active\\u0027,\\u002710000000075992337\\u0027);\\" /\\u003e\\u003cdiv class=\\"cnl-fav\\"\\u003e\\u003ca href=\\"javascript:;\\"\\u003e\\u003cem\\u003ech. no\\u003c/em\\u003e\\u003cspan\\u003e117\\u003c/span\\u003e\\u003c/a\\u003e\\u003c/div\\u003e\\u003ci class=\\"fa fa-heart Set_Favourite_Channel\\" aria-hidden=\\"true\\" title=\\"Set womens active channel as your favourite channel\\" onclick=\\"SetFavouriteChannel();\\"\\u003e\\u003c/i\\u003e\\u003c/div\\u003e\\u003cdiv class=\\"grid-wrap\\"\\u003e\\u003cdiv class=\\"sm-30 grid datatime\\" data-time=\\"24\\" data-starttime=\\"12:00 AM\\" data-endttime=\\"12:24 AM\\" data-reamintime=\\"0\\"\\u003e\\u003ca title=\\"Event Name: Cynthia Williams - Diwali Look Part 01\\r\\nStart Time: 12:00 AM\\r\\nDuration: 24min\\r\\nSynopsis: Learn diwali look by cynthia williams p1\\r\\n\\" href=\\"javascript:;\\" onclick=\\"ShowCurrentTime(\\u002730000000550913679\\u0027,\\u002710000000075992337\\u0027,\\u0027202111051200\\u0027)\\"\\u003eCynthia Williams - Diwali Look Part 01\\u003c/a\\u003e\\u003cdiv class=\\"cnlSerialIcon\\"\\u003e\\u003ci class=\\"fa fa-heart\\" aria-hidden=\\"true\\" title=\\"Set Favourite Serial\\" onclick=\\"SetFavouriteShow();\\"\\u003e\\u003c/i\\u003e\\u003ci class=\\"fa fa-clock-o\\" aria-hidden=\\"true\\" title=\\"Reminder Serial\\" onclick=\\"ReminderEnteryOpen(\\u002730000000550913679\\u0027,\\u002710000000075992337\\u0027,\\u0027202111050000\\u0027,\\u0027117\\u0027)\\"\\u003e\\u003c/i\\u003e\\u003ci class=\\"fa fa-circle\\" aria-hidden=\\"true\\" title=\\"Record Serial\\" onclick=\\"RecordingEnteryOpen(\\u002730000000550913679\\u0027,\\u002710000000075992337\\u0027,\\u0027202111050000\\u0027,\\u0027117\\u0027,30000000550913679)\\"\\u003e\\u003c/i\\u003e\\u003c/div\\u003e\\u003c/div\\u003e\\u003c/div\\u003e\\u003c/div\\u003e"}` + +it('can generate valid url', () => { + expect(url).toBe( + 'https://www.dishtv.in/WhatsonIndiaWebService.asmx/LoadPagginResultDataForProgram' + ) +}) + +it('can generate valid request data', () => { + const result = request.data({ channel, date }) + expect(result).toMatchObject({ + Channelarr: '10000000075992337', + fromdate: '202111050000', + todate: '202111060000' + }) +}) + +it('can get logo url', () => { + const result = logo({ content }) + expect(result).toBe( + 'http://imagesdishtvd2h.whatsonindia.com/dasimages/channel/landscape/360x270/hiyj8ndf.png' + ) +}) + +it('can parse response', () => { + const result = parser({ date, channel, content }) + expect(result).toMatchObject([ + { + start: 'Thu, 04 Nov 2021 18:30:00 GMT', + stop: 'Thu, 04 Nov 2021 18:54:00 GMT', + title: 'Cynthia Williams - Diwali Look Part 01' + } + ]) +}) + +it('can handle empty guide', () => { + const result = parser({ date, channel, content: `{"d":""}` }) + expect(result).toMatchObject([]) +}) diff --git a/sites/dishtv.in/dishtv.in_in.channels.xml b/sites/dishtv.in/dishtv.in_in.channels.xml new file mode 100644 index 00000000..a29354a1 --- /dev/null +++ b/sites/dishtv.in/dishtv.in_in.channels.xml @@ -0,0 +1,369 @@ + + + + 1 Sports + 9X Jhakaas + 9XM + 9X Tashan + Aaj Tak + Aakaash Aath + Aastha India + ABP Ananda + ABP Asmita + ABP Ganga + ABP Majha + ABP News India + Alankar TV + Aljazeera English + Animal Planet HD World India + Animal Planet India + Argus News + Arihant TV + Asianet + Asianet News + Assam Talks + B4U Bhojpuri + B4U Kadak + B4U Movies India + B4U Music India + Baby TV Asia + Balle Balle + BBC World News South Asia + Bflix Movies + Bhojpuri Cinema + Big Ganga + Big Magic + Bindass + Box Cinema + Cartoon Network India + Channel Divya + Channel WIN + Chardikla Time TV + Cinema TV + CNBC Awaaz + CNBC Bajar + CNBC TV 18 + CNN International South Asia + CNN News 18 + Colors + Colors Bangla + Colors Cineplex + Colors Cineplex Bollywood + Colors Gujarati + Colors Gujarati Cinema + Colors Infinity + Colors Marathi + Colors Odia + Colors Rishtey Asia + Comedy Central India + CTVN AKD Plus + Dangal TV + DD Arun Prabha + DD Assam + DD Bharati + DD Bihar + DD Chandana + DD Chhattisgarh + DD Girnar + DD Himachal Pradesh + DD Hissar + DD India + DD Jharkhand + DD Kashir + DD Kisan + DD Madhya Pradesh + DD Malayalam + DD Manipur + DD Meghalaya + DD Mizoram + DD Nagaland + DD National + DD News + DD Odia + DD Podhigai + DD Punjabi + DD Rajasthan + DD Retro + DD Sahyadri + DD Saptagiri + DD Sports + DD Tripura + DD Urdu + DD Uttarakhand + DD Uttar Pradesh + DD Yadagiri + Dhinchaak + Dhinchaak 2 + Dhoom Music + Digi Shala + Discovery Channel India + Discovery HD World India + Discovery Kids India + Discovery Turbo India + Dish Buzz + Dish Buzz 2 + Disney Channel India + Disney International HD + Disney Junior India + Dr Shuddhi + DY 36 + Enterr 10 Movies + Epic TV + ET Now + Eurosport India + E-Vidya 6 + EZMall + Fakt Marathi + Filamchi + & flix + Flowers TV + Fox Life India + Gemini TV + Gubbare + Gyandarshan + Hare Krsna TV + History TV 18 + Hungama TV + ILove + India News + India News Haryana + India News Uttar Pradesh + India Today + India TV + Indradhanu + Investigation Discovery India + Ishara TV + Jalsha Movies + Jinvani Channel + Jonack + Jyotish Duniya + Kalinga TV + Kanak News + KBS World + Khushboo TV Bangla + Lok Sabha TV + Lokshahi News + Maiboli + Manjari TV + Manoranjan Grand + Manoranjan Movies + Manoranjan TV + Marvel HQ + Mastiii + Mazhavil Manorama + MBC TV + Mh 1 Music + Mirror Now + MNX + Movie Plus + Movies Now + Movies Now + + MTV India + Naaptol Tamil + Nandighosha TV + National Geographic India + National Geographic Wild Asia + Naxatra News + NDTV 24x7 + NDTV India + Nepal 1 + News 18 Assam & North-East + News 18 Bengali + News 18 Bihar & Jharkhand + News 18 Gujarati + News 18 India + News 18 Lokmat + News 18 Madhya Pradesh & Chhattisgarh + News 18 Odia + News 18 Punjab & Haryana & Himachal Pradesh + News 18 Rajasthan + News 18 Urdu + News 18 Uttar Pradesh & Uttarakhand + News 24 + News Daily 24 + News India 24x7 + News Live + News Nation + News State UP & UK + NewsTime Bangla + Nickelodeon India + Nick HD+ + Nick Jr India + Odisha TV + Paras Gold + Peace of Mind TV + & pictures + Pitaara + Pogo + Prag News + Prameya News 7 + Prarthana TV + Pratidin Time + & privé HD + PTC Music + PTC News + PTC Punjabi + PTC Punjabi Gold + PTC Simran + Punjabi Hits + Rajya Sabha TV + Rang + Rengoni + Republic Bangla + Republic Bharat + Republic TV + Rishtey Cineplex + Romedy Now + Rongeen TV + R Plus + RT News + Rupasi Bangla + Saam TV + Sadhna TV + Sandesh News + Sangeet Bangla + Sangeet Bhojpuri + Sanskar TV + Santvani Channel + Satsang TV + SET India + Shemaroo Marathi Bana + Shemaroo TV + Shubh TV + Songdew TV + Sonic Nickelodeon + Sony Aath + Sony BBC Earth + Sony Marathi + Sony Max 2 + Sony Max India + Sony Pal + Sony Pix + Sony SAB TV India + Sony Six + Sony Ten 1 + Sony Ten 2 + Sony Ten 3 + Sony Wah + Sony Yay! + Star Bharat India + Star Gold 2 + Star Gold HD India + Star Gold Select + Star Jalsha + Star Maa + Star Maa Movies + Star Movies HD India + Star Movies Select + Star Plus HD India + Star Pravah + Star Sports 1 + Star Sports 1 Hindi + Star Sports 2 + Star Sports 3 + Star Sports First + Star Sports Select HD1 + Star Sports Select HD2 + Star Utsav + Star Utsav Movies + Star World HD India + Star World Premiere HD + Sudarshan News + Sun Bangla + Sun TV + Swayam Prabha 1 + Swayam Prabha 2 + Swayam Prabha 3 + Swayam Prabha 4 + Swayam Prabha 5 + Swayam Prabha 6 + Swayam Prabha 7 + Swayam Prabha 8 + Swayam Prabha 9 + Swayam Prabha 10 + Swayam Prabha 11 + Swayam Prabha 12 + Swayam Prabha 13 + Swayam Prabha 14 + Swayam Prabha 15 + Swayam Prabha 16 + Swayam Prabha 17 + Swayam Prabha 18 + Swayam Prabha 19 + Swayam Prabha 20 + Swayam Prabha 21 + Swayam Prabha 22 + Tarang TV + The Q India + Times Now World + TLC India + Topper TV + & TV + TV 9 Bangla + TV 9 Gujarati + TV 9 Kannada + TV 9 Marathi + Udaya TV + UTV Action + UTV Movies + VANDE Gujarat 1 + VANDE Gujarat 2 + VANDE Gujarat 3 + VANDE Gujarat 4 + VANDE Gujarat 5 + VANDE Gujarat 6 + VANDE Gujarat 7 + VANDE Gujarat 8 + VANDE Gujarat 9 + VANDE Gujarat 10 + VANDE Gujarat 11 + VANDE Gujarat 12 + VANDE Gujarat 13 + VANDE Gujarat 14 + VANDE Gujarat 15 + VANDE Gujarat 16 + VH1 India + Vijay TV + VTV News + WION + Wow Cinema One + Zee 24 Ghanta + Zee 24 Kalak + Zee 24 Taas + Zee Action + Zee Anmol + Zee Anmol Cinema + Zee Bangla + Zee Bangla Cinema + Zee Bihar Jharkhand + Zee Biskope + Zee Bollywood + Zee Business + Zee Café + Zee Chitramandir + Zee Cinema Asia + Zee Classic + Zee Kannada + Zee Keralam + Zee Madhya Pradesh Chhattisgarh + Zee Marathi + Zee News + Zee Odisha + Zee Punjab Haryana Himachal + Zee Punjabi + Zee Rajasthan + Zee Salaam + Zee Sarthak + Zee Talkies + Zee Tamil + Zee Telugu + Zee TV India + Zee Uttar Pradesh Uttarakhand + Zee Vajwa + Zee Yuva + Zee Zest + Zing Asia + Zing Home + Zoom + + \ No newline at end of file