mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 00:50:09 -04:00
Create dishtv.in.config.js
This commit is contained in:
parent
e87d7322b1
commit
2a22a0e974
1 changed files with 83 additions and 0 deletions
83
sites/dishtv.in/dishtv.in.config.js
Normal file
83
sites/dishtv.in/dishtv.in.config.js
Normal file
|
@ -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()
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue