mirror of
https://github.com/iptv-org/epg
synced 2026-04-20 09:37:00 -04:00
LF to CRLF
This commit is contained in:
@@ -1,59 +1,59 @@
|
||||
const { parser, url } = require('./allente.no.config.js')
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
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-17', 'YYYY-MM-DD').startOf('d')
|
||||
const channel = {
|
||||
site_id: 'se#0148',
|
||||
xmltv_id: 'SVT1.se'
|
||||
}
|
||||
|
||||
it('can generate valid url', () => {
|
||||
if (channel.site_id.split('#')[0] !== 'se') {
|
||||
expect(url({ channel, date })).toBe('https://cs-vcb.allente.se/epg/events?date=2021-11-17')
|
||||
} else if (channel.site_id.split('#')[0] === 'fi') {
|
||||
expect(url({ channel, date })).toBe('https://cs-vcb.allente.fi/epg/events?date=2021-11-17')
|
||||
} else if (channel.site_id.split('#')[0] === 'no') {
|
||||
expect(url({ channel, date })).toBe('https://cs-vcb.allente.no/epg/events?date=2021-11-17')
|
||||
} else if (channel.site_id.split('#')[0] === 'dk') {
|
||||
expect(url({ channel, date })).toBe('https://cs-vcb.allente.dk/epg/events?date=2021-11-17')
|
||||
}
|
||||
})
|
||||
|
||||
it('can parse response', () => {
|
||||
const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.json'))
|
||||
const result = parser({ content, channel }).map(p => {
|
||||
p.start = p.start.toJSON()
|
||||
p.stop = p.stop.toJSON()
|
||||
return p
|
||||
})
|
||||
|
||||
expect(result).toMatchObject([
|
||||
{
|
||||
start: '2022-08-22T07:10:00.000Z',
|
||||
stop: '2022-08-22T07:30:00.000Z',
|
||||
title: 'Hemmagympa med Sofia',
|
||||
category: ['other'],
|
||||
description:
|
||||
'Svenskt träningsprogram från 2021. Styrka. Sofia Åhman leder SVT:s hemmagympapass. Denna gång fokuserar vi på styrka.',
|
||||
image:
|
||||
'https://viasatps.api.comspace.se/PS/channeldate/image/viasat.ps/21/2022-08-22/se.cs.svt1.event.A_41214031600.jpg?size=2560x1440',
|
||||
season: 4,
|
||||
episode: 1
|
||||
}
|
||||
])
|
||||
})
|
||||
|
||||
it('can handle empty guide', () => {
|
||||
const result = parser({
|
||||
date,
|
||||
channel,
|
||||
content: fs.readFileSync(path.resolve(__dirname, '__data__/no_content.json'))
|
||||
})
|
||||
expect(result).toMatchObject([])
|
||||
})
|
||||
const { parser, url } = require('./allente.no.config.js')
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
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-17', 'YYYY-MM-DD').startOf('d')
|
||||
const channel = {
|
||||
site_id: 'se#0148',
|
||||
xmltv_id: 'SVT1.se'
|
||||
}
|
||||
|
||||
it('can generate valid url', () => {
|
||||
if (channel.site_id.split('#')[0] !== 'se') {
|
||||
expect(url({ channel, date })).toBe('https://cs-vcb.allente.se/epg/events?date=2021-11-17')
|
||||
} else if (channel.site_id.split('#')[0] === 'fi') {
|
||||
expect(url({ channel, date })).toBe('https://cs-vcb.allente.fi/epg/events?date=2021-11-17')
|
||||
} else if (channel.site_id.split('#')[0] === 'no') {
|
||||
expect(url({ channel, date })).toBe('https://cs-vcb.allente.no/epg/events?date=2021-11-17')
|
||||
} else if (channel.site_id.split('#')[0] === 'dk') {
|
||||
expect(url({ channel, date })).toBe('https://cs-vcb.allente.dk/epg/events?date=2021-11-17')
|
||||
}
|
||||
})
|
||||
|
||||
it('can parse response', () => {
|
||||
const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.json'))
|
||||
const result = parser({ content, channel }).map(p => {
|
||||
p.start = p.start.toJSON()
|
||||
p.stop = p.stop.toJSON()
|
||||
return p
|
||||
})
|
||||
|
||||
expect(result).toMatchObject([
|
||||
{
|
||||
start: '2022-08-22T07:10:00.000Z',
|
||||
stop: '2022-08-22T07:30:00.000Z',
|
||||
title: 'Hemmagympa med Sofia',
|
||||
category: ['other'],
|
||||
description:
|
||||
'Svenskt träningsprogram från 2021. Styrka. Sofia Åhman leder SVT:s hemmagympapass. Denna gång fokuserar vi på styrka.',
|
||||
image:
|
||||
'https://viasatps.api.comspace.se/PS/channeldate/image/viasat.ps/21/2022-08-22/se.cs.svt1.event.A_41214031600.jpg?size=2560x1440',
|
||||
season: 4,
|
||||
episode: 1
|
||||
}
|
||||
])
|
||||
})
|
||||
|
||||
it('can handle empty guide', () => {
|
||||
const result = parser({
|
||||
date,
|
||||
channel,
|
||||
content: fs.readFileSync(path.resolve(__dirname, '__data__/no_content.json'))
|
||||
})
|
||||
expect(result).toMatchObject([])
|
||||
})
|
||||
|
||||
@@ -1,91 +1,97 @@
|
||||
const cheerio = require('cheerio')
|
||||
const axios = require('axios')
|
||||
const { DateTime } = require('luxon')
|
||||
|
||||
module.exports = {
|
||||
site: 'awilime.com',
|
||||
days: 2,
|
||||
url({ channel, date }) {
|
||||
return `https://www.awilime.com/tv/napi_musor/${channel.site_id}/${date.format('YYYY_MM_DD')}`
|
||||
},
|
||||
request: {
|
||||
headers: {
|
||||
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36'
|
||||
}
|
||||
},
|
||||
parser({ content, date }) {
|
||||
const programs = []
|
||||
const items = parseItems(content)
|
||||
items.forEach(item => {
|
||||
const prev = programs[programs.length - 1]
|
||||
const $item = cheerio.load(item)
|
||||
let start = parseStart($item, date)
|
||||
if (!start) return
|
||||
if (prev) {
|
||||
prev.stop = start
|
||||
}
|
||||
const stop = start.plus({ minute: 30 })
|
||||
|
||||
programs.push({
|
||||
title: parseTitle($item),
|
||||
sub_title: parseSubTitle($item),
|
||||
description: parseDescription($item),
|
||||
start,
|
||||
stop
|
||||
})
|
||||
})
|
||||
|
||||
return programs
|
||||
},
|
||||
async channels() {
|
||||
const html = await axios
|
||||
.get('https://www.awilime.com/tv/napi_musor', { headers: { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36' } })
|
||||
.then(r => r.data)
|
||||
.catch(console.log)
|
||||
const $ = cheerio.load(html)
|
||||
const items = $('#body > div.tk > div > div').toArray()
|
||||
|
||||
const channels = []
|
||||
items.forEach(item => {
|
||||
const name = $(item).find('a').text().trim()
|
||||
const url = $(item).find('a').attr('href')
|
||||
const [, site_id] = url.match(/\/tv\/napi_musor\/(.*)/) || [null, null]
|
||||
if (!site_id) return
|
||||
if (channels.find(channel => channel.site_id === site_id)) return
|
||||
|
||||
channels.push({
|
||||
lang: 'hu',
|
||||
site_id,
|
||||
name
|
||||
})
|
||||
})
|
||||
|
||||
return channels
|
||||
}
|
||||
}
|
||||
|
||||
function parseTitle($item) {
|
||||
return $item('b > a').text().trim()
|
||||
}
|
||||
|
||||
function parseSubTitle($item) {
|
||||
return $item('i').clone().children().remove('s').end().text().trim()
|
||||
}
|
||||
|
||||
function parseDescription($item) {
|
||||
return $item('p').text().trim()
|
||||
}
|
||||
|
||||
function parseStart($item, date) {
|
||||
let time = $item('b').clone().children().remove().end().text().trim()
|
||||
if (!time || !/^\d/.test(time)) return null
|
||||
time = `${date.format('YYYY-MM-DD')} ${time}`
|
||||
|
||||
return DateTime.fromFormat(time, 'yyyy-MM-dd HH:mm', { zone: 'Europe/Budapest' }).toUTC()
|
||||
}
|
||||
|
||||
function parseItems(content) {
|
||||
const $ = cheerio.load(content)
|
||||
|
||||
return $('#body > div.tdc > div.td2 > div').toArray()
|
||||
}
|
||||
const cheerio = require('cheerio')
|
||||
const axios = require('axios')
|
||||
const { DateTime } = require('luxon')
|
||||
|
||||
module.exports = {
|
||||
site: 'awilime.com',
|
||||
days: 2,
|
||||
url({ channel, date }) {
|
||||
return `https://www.awilime.com/tv/napi_musor/${channel.site_id}/${date.format('YYYY_MM_DD')}`
|
||||
},
|
||||
request: {
|
||||
headers: {
|
||||
'User-Agent':
|
||||
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36'
|
||||
}
|
||||
},
|
||||
parser({ content, date }) {
|
||||
const programs = []
|
||||
const items = parseItems(content)
|
||||
items.forEach(item => {
|
||||
const prev = programs[programs.length - 1]
|
||||
const $item = cheerio.load(item)
|
||||
let start = parseStart($item, date)
|
||||
if (!start) return
|
||||
if (prev) {
|
||||
prev.stop = start
|
||||
}
|
||||
const stop = start.plus({ minute: 30 })
|
||||
|
||||
programs.push({
|
||||
title: parseTitle($item),
|
||||
sub_title: parseSubTitle($item),
|
||||
description: parseDescription($item),
|
||||
start,
|
||||
stop
|
||||
})
|
||||
})
|
||||
|
||||
return programs
|
||||
},
|
||||
async channels() {
|
||||
const html = await axios
|
||||
.get('https://www.awilime.com/tv/napi_musor', {
|
||||
headers: {
|
||||
'User-Agent':
|
||||
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36'
|
||||
}
|
||||
})
|
||||
.then(r => r.data)
|
||||
.catch(console.log)
|
||||
const $ = cheerio.load(html)
|
||||
const items = $('#body > div.tk > div > div').toArray()
|
||||
|
||||
const channels = []
|
||||
items.forEach(item => {
|
||||
const name = $(item).find('a').text().trim()
|
||||
const url = $(item).find('a').attr('href')
|
||||
const [, site_id] = url.match(/\/tv\/napi_musor\/(.*)/) || [null, null]
|
||||
if (!site_id) return
|
||||
if (channels.find(channel => channel.site_id === site_id)) return
|
||||
|
||||
channels.push({
|
||||
lang: 'hu',
|
||||
site_id,
|
||||
name
|
||||
})
|
||||
})
|
||||
|
||||
return channels
|
||||
}
|
||||
}
|
||||
|
||||
function parseTitle($item) {
|
||||
return $item('b > a').text().trim()
|
||||
}
|
||||
|
||||
function parseSubTitle($item) {
|
||||
return $item('i').clone().children().remove('s').end().text().trim()
|
||||
}
|
||||
|
||||
function parseDescription($item) {
|
||||
return $item('p').text().trim()
|
||||
}
|
||||
|
||||
function parseStart($item, date) {
|
||||
let time = $item('b').clone().children().remove().end().text().trim()
|
||||
if (!time || !/^\d/.test(time)) return null
|
||||
time = `${date.format('YYYY-MM-DD')} ${time}`
|
||||
|
||||
return DateTime.fromFormat(time, 'yyyy-MM-dd HH:mm', { zone: 'Europe/Budapest' }).toUTC()
|
||||
}
|
||||
|
||||
function parseItems(content) {
|
||||
const $ = cheerio.load(content)
|
||||
|
||||
return $('#body > div.tdc > div.td2 > div').toArray()
|
||||
}
|
||||
|
||||
@@ -1,43 +1,43 @@
|
||||
const { parser, url } = require('./beinsports.com.config.js')
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
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('2023-10-22T00:00:00.000', '"YYYY-MM-DDTHH:mm:ss.SSS').startOf('d')
|
||||
const channel = { site_id: 'C244C48D-3B54-406A-94C9-D63B16318267', xmltv_id: 'beINSportsUSA.us' }
|
||||
|
||||
it('can generate valid url', () => {
|
||||
const result = url({ date, channel })
|
||||
expect(result).toBe(
|
||||
'https://www.beinsports.com/api/opta/tv-event?&startBefore=2023-10-23T00:00:00.000Z&endAfter=2023-10-22T00:00:00.000Z&channelIds=C244C48D-3B54-406A-94C9-D63B16318267'
|
||||
)
|
||||
})
|
||||
|
||||
it('can parse response', () => {
|
||||
const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.json'))
|
||||
const result = parser({ content, channel, date }).map(p => {
|
||||
p.start = p.start.toJSON()
|
||||
p.stop = p.stop.toJSON()
|
||||
return p
|
||||
})
|
||||
|
||||
expect(result).toMatchObject([
|
||||
{
|
||||
start: '2023-10-20T23:30:00.000Z',
|
||||
stop: '2023-10-21T01:00:00.000Z',
|
||||
title: 'Tokyo Day 5 QF 2',
|
||||
description: 'Exclusive coverage of the 2023 ATP Tour on beIN SPORTS'
|
||||
}
|
||||
])
|
||||
})
|
||||
|
||||
it('can handle empty guide', () => {
|
||||
const result = parser({
|
||||
content: '[]'
|
||||
})
|
||||
expect(result).toMatchObject([])
|
||||
})
|
||||
const { parser, url } = require('./beinsports.com.config.js')
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
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('2023-10-22T00:00:00.000', '"YYYY-MM-DDTHH:mm:ss.SSS').startOf('d')
|
||||
const channel = { site_id: 'C244C48D-3B54-406A-94C9-D63B16318267', xmltv_id: 'beINSportsUSA.us' }
|
||||
|
||||
it('can generate valid url', () => {
|
||||
const result = url({ date, channel })
|
||||
expect(result).toBe(
|
||||
'https://www.beinsports.com/api/opta/tv-event?&startBefore=2023-10-23T00:00:00.000Z&endAfter=2023-10-22T00:00:00.000Z&channelIds=C244C48D-3B54-406A-94C9-D63B16318267'
|
||||
)
|
||||
})
|
||||
|
||||
it('can parse response', () => {
|
||||
const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.json'))
|
||||
const result = parser({ content, channel, date }).map(p => {
|
||||
p.start = p.start.toJSON()
|
||||
p.stop = p.stop.toJSON()
|
||||
return p
|
||||
})
|
||||
|
||||
expect(result).toMatchObject([
|
||||
{
|
||||
start: '2023-10-20T23:30:00.000Z',
|
||||
stop: '2023-10-21T01:00:00.000Z',
|
||||
title: 'Tokyo Day 5 QF 2',
|
||||
description: 'Exclusive coverage of the 2023 ATP Tour on beIN SPORTS'
|
||||
}
|
||||
])
|
||||
})
|
||||
|
||||
it('can handle empty guide', () => {
|
||||
const result = parser({
|
||||
content: '[]'
|
||||
})
|
||||
expect(result).toMatchObject([])
|
||||
})
|
||||
|
||||
@@ -1,114 +1,114 @@
|
||||
const dayjs = require('dayjs')
|
||||
const timezone = require('dayjs/plugin/timezone')
|
||||
const utc = require('dayjs/plugin/utc')
|
||||
|
||||
dayjs.extend(timezone)
|
||||
dayjs.extend(utc)
|
||||
|
||||
module.exports = {
|
||||
site: 'cubmu.com',
|
||||
days: 2,
|
||||
url({ channel, date }) {
|
||||
return `https://servicebuss.transvision.co.id/v2/cms/getEPGData?app_id=cubmu&tvs_platform_id=standalone&schedule_date=${date.format(
|
||||
'YYYY-MM-DD'
|
||||
)}&channel_id=${channel.site_id}`
|
||||
},
|
||||
parser({ content, channel }) {
|
||||
const programs = []
|
||||
const items = parseItems(content)
|
||||
items.forEach(item => {
|
||||
programs.push({
|
||||
title: parseTitle(item),
|
||||
description: parseDescription(item, channel.lang),
|
||||
episode: parseEpisode(item),
|
||||
start: parseStart(item).toISOString(),
|
||||
stop: parseStop(item).toISOString()
|
||||
})
|
||||
})
|
||||
|
||||
return programs
|
||||
},
|
||||
async channels({ lang }) {
|
||||
const axios = require('axios')
|
||||
const cheerio = require('cheerio')
|
||||
const result = await axios
|
||||
.get('https://cubmu.com/live-tv')
|
||||
.then(response => response.data)
|
||||
.catch(console.error)
|
||||
|
||||
const $ = cheerio.load(result)
|
||||
|
||||
// retrieve service api data
|
||||
const config = JSON.parse($('#__NEXT_DATA__').text()).runtimeConfig || {}
|
||||
|
||||
const options = {
|
||||
headers: {
|
||||
Origin: 'https://cubmu.com',
|
||||
Referer: 'https://cubmu.com/live-tv'
|
||||
}
|
||||
}
|
||||
// login to service bus
|
||||
await axios
|
||||
.post(
|
||||
`https://servicebuss.transvision.co.id/tvs/login/external?email=${config.email}&password=${config.password}&deviceId=${config.deviceId}&deviceType=${config.deviceType}&deviceModel=${config.deviceModel}&deviceToken=&serial=&platformId=${config.platformId}`,
|
||||
options
|
||||
)
|
||||
.then(response => response.data)
|
||||
.catch(console.error)
|
||||
// list channels
|
||||
const subscribedChannels = await axios
|
||||
.post(
|
||||
`https://servicebuss.transvision.co.id/tvs/subscribe_product/list?platformId=${config.platformId}`,
|
||||
options
|
||||
)
|
||||
.then(response => response.data)
|
||||
.catch(console.error)
|
||||
|
||||
const channels = []
|
||||
const included = []
|
||||
if (Array.isArray(subscribedChannels.channelPackageList)) {
|
||||
subscribedChannels.channelPackageList.forEach(pkg => {
|
||||
pkg.channelList.forEach(channel => {
|
||||
if (included.indexOf(channel.id) < 0) {
|
||||
included.push(channel.id)
|
||||
channels.push({
|
||||
lang,
|
||||
site_id: channel.id,
|
||||
name: channel.name
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
return channels
|
||||
}
|
||||
}
|
||||
|
||||
function parseItems(content) {
|
||||
return content ? JSON.parse(content.trim()).result || [] : []
|
||||
}
|
||||
|
||||
function parseTitle(item) {
|
||||
return item.scehedule_title
|
||||
}
|
||||
|
||||
function parseDescription(item, lang = 'id') {
|
||||
return lang === 'id' ? item.schedule_json.primarySynopsis : item.schedule_json.secondarySynopsis
|
||||
}
|
||||
|
||||
function parseEpisode(item) {
|
||||
return item.schedule_json.episodeName
|
||||
}
|
||||
|
||||
function parseStart(item) {
|
||||
return dayjs.tz(item.schedule_date, 'YYYY-MM-DD HH:mm:ss', 'Asia/Jakarta')
|
||||
}
|
||||
|
||||
function parseStop(item) {
|
||||
return dayjs.tz(
|
||||
[item.schedule_date.split(' ')[0], item.schedule_end_time].join(' '),
|
||||
'YYYY-MM-DD HH:mm:ss',
|
||||
'Asia/Jakarta'
|
||||
)
|
||||
}
|
||||
const dayjs = require('dayjs')
|
||||
const timezone = require('dayjs/plugin/timezone')
|
||||
const utc = require('dayjs/plugin/utc')
|
||||
|
||||
dayjs.extend(timezone)
|
||||
dayjs.extend(utc)
|
||||
|
||||
module.exports = {
|
||||
site: 'cubmu.com',
|
||||
days: 2,
|
||||
url({ channel, date }) {
|
||||
return `https://servicebuss.transvision.co.id/v2/cms/getEPGData?app_id=cubmu&tvs_platform_id=standalone&schedule_date=${date.format(
|
||||
'YYYY-MM-DD'
|
||||
)}&channel_id=${channel.site_id}`
|
||||
},
|
||||
parser({ content, channel }) {
|
||||
const programs = []
|
||||
const items = parseItems(content)
|
||||
items.forEach(item => {
|
||||
programs.push({
|
||||
title: parseTitle(item),
|
||||
description: parseDescription(item, channel.lang),
|
||||
episode: parseEpisode(item),
|
||||
start: parseStart(item).toISOString(),
|
||||
stop: parseStop(item).toISOString()
|
||||
})
|
||||
})
|
||||
|
||||
return programs
|
||||
},
|
||||
async channels({ lang }) {
|
||||
const axios = require('axios')
|
||||
const cheerio = require('cheerio')
|
||||
const result = await axios
|
||||
.get('https://cubmu.com/live-tv')
|
||||
.then(response => response.data)
|
||||
.catch(console.error)
|
||||
|
||||
const $ = cheerio.load(result)
|
||||
|
||||
// retrieve service api data
|
||||
const config = JSON.parse($('#__NEXT_DATA__').text()).runtimeConfig || {}
|
||||
|
||||
const options = {
|
||||
headers: {
|
||||
Origin: 'https://cubmu.com',
|
||||
Referer: 'https://cubmu.com/live-tv'
|
||||
}
|
||||
}
|
||||
// login to service bus
|
||||
await axios
|
||||
.post(
|
||||
`https://servicebuss.transvision.co.id/tvs/login/external?email=${config.email}&password=${config.password}&deviceId=${config.deviceId}&deviceType=${config.deviceType}&deviceModel=${config.deviceModel}&deviceToken=&serial=&platformId=${config.platformId}`,
|
||||
options
|
||||
)
|
||||
.then(response => response.data)
|
||||
.catch(console.error)
|
||||
// list channels
|
||||
const subscribedChannels = await axios
|
||||
.post(
|
||||
`https://servicebuss.transvision.co.id/tvs/subscribe_product/list?platformId=${config.platformId}`,
|
||||
options
|
||||
)
|
||||
.then(response => response.data)
|
||||
.catch(console.error)
|
||||
|
||||
const channels = []
|
||||
const included = []
|
||||
if (Array.isArray(subscribedChannels.channelPackageList)) {
|
||||
subscribedChannels.channelPackageList.forEach(pkg => {
|
||||
pkg.channelList.forEach(channel => {
|
||||
if (included.indexOf(channel.id) < 0) {
|
||||
included.push(channel.id)
|
||||
channels.push({
|
||||
lang,
|
||||
site_id: channel.id,
|
||||
name: channel.name
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
return channels
|
||||
}
|
||||
}
|
||||
|
||||
function parseItems(content) {
|
||||
return content ? JSON.parse(content.trim()).result || [] : []
|
||||
}
|
||||
|
||||
function parseTitle(item) {
|
||||
return item.scehedule_title
|
||||
}
|
||||
|
||||
function parseDescription(item, lang = 'id') {
|
||||
return lang === 'id' ? item.schedule_json.primarySynopsis : item.schedule_json.secondarySynopsis
|
||||
}
|
||||
|
||||
function parseEpisode(item) {
|
||||
return item.schedule_json.episodeName
|
||||
}
|
||||
|
||||
function parseStart(item) {
|
||||
return dayjs.tz(item.schedule_date, 'YYYY-MM-DD HH:mm:ss', 'Asia/Jakarta')
|
||||
}
|
||||
|
||||
function parseStop(item) {
|
||||
return dayjs.tz(
|
||||
[item.schedule_date.split(' ')[0], item.schedule_end_time].join(' '),
|
||||
'YYYY-MM-DD HH:mm:ss',
|
||||
'Asia/Jakarta'
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,184 +1,191 @@
|
||||
process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = 0
|
||||
const dayjs = require('dayjs')
|
||||
const axios = require('axios')
|
||||
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: 'directv.com.ar',
|
||||
days: 2,
|
||||
url: 'https://www.directv.com.ar/guia/ChannelDetail.aspx/GetProgramming',
|
||||
request: {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
Cookie: 'PGCSS=16; PGLang=S; PGCulture=es-AR;',
|
||||
Accept: '*/*',
|
||||
'Accept-Language': 'es-419,es;q=0.9',
|
||||
Connection: 'keep-alive',
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
Origin: 'https://www.directv.com.ar',
|
||||
Referer: 'https://www.directv.com.ar/guia/ChannelDetail.aspx?id=1740&name=TLCHD',
|
||||
'Sec-Fetch-Dest': 'empty',
|
||||
'Sec-Fetch-Mode': 'cors',
|
||||
'Sec-Fetch-Site': 'same-origin',
|
||||
'User-Agent':
|
||||
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36',
|
||||
'sec-ch-ua': '"Not.A/Brand";v="8", "Chromium";v="114", "Google Chrome";v="114"',
|
||||
'sec-ch-ua-mobile': '?0',
|
||||
'sec-ch-ua-platform': '"Windows"',
|
||||
'X-Requested-With': 'XMLHttpRequest'
|
||||
},
|
||||
data({ channel, date }) {
|
||||
const [channelNum, channelName] = channel.site_id.split('#')
|
||||
|
||||
return {
|
||||
filterParameters: {
|
||||
day: date.date(),
|
||||
time: 0,
|
||||
minute: 0,
|
||||
month: date.month() + 1,
|
||||
year: date.year(),
|
||||
offSetValue: 0,
|
||||
homeScreenFilter: '',
|
||||
filtersScreenFilters: [''],
|
||||
isHd: '',
|
||||
isChannelDetails: 'Y',
|
||||
channelNum,
|
||||
channelName: channelName.replace('&', '&')
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
parser({ content, channel }) {
|
||||
let programs = []
|
||||
const items = parseItems(content, channel)
|
||||
items.forEach(item => {
|
||||
programs.push({
|
||||
title: item.title,
|
||||
description: item.description,
|
||||
rating: parseRating(item),
|
||||
start: parseStart(item),
|
||||
stop: parseStop(item)
|
||||
})
|
||||
})
|
||||
|
||||
return programs
|
||||
},
|
||||
async channels() {
|
||||
let channels = []
|
||||
const cookies = await axios.get('https://www.directv.com.ar/guia/guia.aspx', {
|
||||
headers: {
|
||||
Accept: 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8',
|
||||
'Accept-Encoding': 'gzip, deflate, br, zstd',
|
||||
'Accept-Language': 'es-419,es;q=0.9',
|
||||
'Cache-Control': 'no-cache',
|
||||
Connection: 'keep-alive',
|
||||
Host: 'www.directv.com.ar',
|
||||
Pragma: 'no-cache',
|
||||
Referer: 'https://www.google.com/',
|
||||
'Sec-Fetch-Dest': 'document',
|
||||
'Sec-Fetch-Mode': 'navigate',
|
||||
'Sec-Fetch-Site': 'same-origin',
|
||||
'Sec-Fetch-User': '?1',
|
||||
'Sec-GPC': 1,
|
||||
'Upgrade-Insecure-Requests': 1,
|
||||
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36',
|
||||
'sec-ch-ua': '"Not;A=Brand";v="99", "Brave";v="139", "Chromium";v="139"',
|
||||
'sec-ch-ua-mobile': '?0',
|
||||
'sec-ch-ua-platform': '"Windows"'
|
||||
}})
|
||||
const cookieHeader = cookies.headers['set-cookie'].map(cookie => cookie.split(';')[0]).join('; ')
|
||||
|
||||
const date = dayjs().tz('America/Argentina/Buenos_Aires')
|
||||
|
||||
const response = await axios.post(
|
||||
'https://www.directv.com.ar/guia/guia.aspx/GetProgramming',
|
||||
{
|
||||
filterParam: {
|
||||
day: date.date(),
|
||||
time: date.hour(),
|
||||
minute: 0,
|
||||
month: date.month() + 1,
|
||||
year: date.year(),
|
||||
offSetValue: 0,
|
||||
homeScreenFilter: '',
|
||||
filtersScreenFilters: [''],
|
||||
isHd: ''
|
||||
}
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
Accept: '*/*',
|
||||
'Accept-Encoding': 'gzip, deflate, br, zstd',
|
||||
'Accept-Language': 'es-419,es;q=0.9',
|
||||
'Cache-Control': 'no-cache',
|
||||
Connection: 'keep-alive',
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
Cookie: cookieHeader,
|
||||
Host: 'www.directv.com.ar',
|
||||
Origin: 'https://www.directv.com.ar',
|
||||
Pragma: 'no-cache',
|
||||
Referer: 'https://www.directv.com.ar/guia/guia.aspx',
|
||||
'Sec-Fetch-Dest': 'empty',
|
||||
'Sec-Fetch-Mode': 'cors',
|
||||
'Sec-Fetch-Site': 'same-origin',
|
||||
'Sec-GPC': 1,
|
||||
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'sec-ch-ua': '"Not;A=Brand";v="99", "Brave";v="139", "Chromium";v="139"',
|
||||
'sec-ch-ua-mobile': '?0',
|
||||
'sec-ch-ua-platform': '"Windows"',
|
||||
'uzlc': true,
|
||||
}
|
||||
}
|
||||
)
|
||||
.then(r => r.data)
|
||||
.catch(console.log)
|
||||
|
||||
response.d.forEach(item => {
|
||||
channels.push({
|
||||
site_id: `${item.ContentChannelID}#${item.ChannelName.replace(/&/g, '&')}`,
|
||||
name: item.ChannelFullName,
|
||||
logo: item.ImageUrl,
|
||||
lang: 'es'
|
||||
})
|
||||
})
|
||||
|
||||
return channels
|
||||
}
|
||||
}
|
||||
|
||||
function parseRating(item) {
|
||||
return item.rating
|
||||
? {
|
||||
system: 'MPA',
|
||||
value: item.rating
|
||||
}
|
||||
: null
|
||||
}
|
||||
|
||||
function parseStart(item) {
|
||||
return dayjs.tz(item.startTimeString, 'M/D/YYYY h:mm:ss A', 'America/Argentina/Buenos_Aires')
|
||||
}
|
||||
|
||||
function parseStop(item) {
|
||||
return dayjs.tz(item.endTimeString, 'M/D/YYYY h:mm:ss A', 'America/Argentina/Buenos_Aires')
|
||||
}
|
||||
|
||||
function parseItems(content, channel) {
|
||||
if (!content) return []
|
||||
let [ChannelNumber, ChannelName] = channel.site_id.split('#')
|
||||
ChannelName = ChannelName.replace('&', '&')
|
||||
const data = JSON.parse(content)
|
||||
if (!data || !Array.isArray(data.d)) return []
|
||||
const channelData = data.d.find(
|
||||
c => c.ChannelNumber == ChannelNumber && c.ChannelName === ChannelName
|
||||
)
|
||||
|
||||
return channelData && Array.isArray(channelData.ProgramList) ? channelData.ProgramList : []
|
||||
}
|
||||
process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = 0
|
||||
const dayjs = require('dayjs')
|
||||
const axios = require('axios')
|
||||
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: 'directv.com.ar',
|
||||
days: 2,
|
||||
url: 'https://www.directv.com.ar/guia/ChannelDetail.aspx/GetProgramming',
|
||||
request: {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
Cookie: 'PGCSS=16; PGLang=S; PGCulture=es-AR;',
|
||||
Accept: '*/*',
|
||||
'Accept-Language': 'es-419,es;q=0.9',
|
||||
Connection: 'keep-alive',
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
Origin: 'https://www.directv.com.ar',
|
||||
Referer: 'https://www.directv.com.ar/guia/ChannelDetail.aspx?id=1740&name=TLCHD',
|
||||
'Sec-Fetch-Dest': 'empty',
|
||||
'Sec-Fetch-Mode': 'cors',
|
||||
'Sec-Fetch-Site': 'same-origin',
|
||||
'User-Agent':
|
||||
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36',
|
||||
'sec-ch-ua': '"Not.A/Brand";v="8", "Chromium";v="114", "Google Chrome";v="114"',
|
||||
'sec-ch-ua-mobile': '?0',
|
||||
'sec-ch-ua-platform': '"Windows"',
|
||||
'X-Requested-With': 'XMLHttpRequest'
|
||||
},
|
||||
data({ channel, date }) {
|
||||
const [channelNum, channelName] = channel.site_id.split('#')
|
||||
|
||||
return {
|
||||
filterParameters: {
|
||||
day: date.date(),
|
||||
time: 0,
|
||||
minute: 0,
|
||||
month: date.month() + 1,
|
||||
year: date.year(),
|
||||
offSetValue: 0,
|
||||
homeScreenFilter: '',
|
||||
filtersScreenFilters: [''],
|
||||
isHd: '',
|
||||
isChannelDetails: 'Y',
|
||||
channelNum,
|
||||
channelName: channelName.replace('&', '&')
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
parser({ content, channel }) {
|
||||
let programs = []
|
||||
const items = parseItems(content, channel)
|
||||
items.forEach(item => {
|
||||
programs.push({
|
||||
title: item.title,
|
||||
description: item.description,
|
||||
rating: parseRating(item),
|
||||
start: parseStart(item),
|
||||
stop: parseStop(item)
|
||||
})
|
||||
})
|
||||
|
||||
return programs
|
||||
},
|
||||
async channels() {
|
||||
let channels = []
|
||||
const cookies = await axios.get('https://www.directv.com.ar/guia/guia.aspx', {
|
||||
headers: {
|
||||
Accept:
|
||||
'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8',
|
||||
'Accept-Encoding': 'gzip, deflate, br, zstd',
|
||||
'Accept-Language': 'es-419,es;q=0.9',
|
||||
'Cache-Control': 'no-cache',
|
||||
Connection: 'keep-alive',
|
||||
Host: 'www.directv.com.ar',
|
||||
Pragma: 'no-cache',
|
||||
Referer: 'https://www.google.com/',
|
||||
'Sec-Fetch-Dest': 'document',
|
||||
'Sec-Fetch-Mode': 'navigate',
|
||||
'Sec-Fetch-Site': 'same-origin',
|
||||
'Sec-Fetch-User': '?1',
|
||||
'Sec-GPC': 1,
|
||||
'Upgrade-Insecure-Requests': 1,
|
||||
'User-Agent':
|
||||
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36',
|
||||
'sec-ch-ua': '"Not;A=Brand";v="99", "Brave";v="139", "Chromium";v="139"',
|
||||
'sec-ch-ua-mobile': '?0',
|
||||
'sec-ch-ua-platform': '"Windows"'
|
||||
}
|
||||
})
|
||||
const cookieHeader = cookies.headers['set-cookie']
|
||||
.map(cookie => cookie.split(';')[0])
|
||||
.join('; ')
|
||||
|
||||
const date = dayjs().tz('America/Argentina/Buenos_Aires')
|
||||
|
||||
const response = await axios
|
||||
.post(
|
||||
'https://www.directv.com.ar/guia/guia.aspx/GetProgramming',
|
||||
{
|
||||
filterParam: {
|
||||
day: date.date(),
|
||||
time: date.hour(),
|
||||
minute: 0,
|
||||
month: date.month() + 1,
|
||||
year: date.year(),
|
||||
offSetValue: 0,
|
||||
homeScreenFilter: '',
|
||||
filtersScreenFilters: [''],
|
||||
isHd: ''
|
||||
}
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
Accept: '*/*',
|
||||
'Accept-Encoding': 'gzip, deflate, br, zstd',
|
||||
'Accept-Language': 'es-419,es;q=0.9',
|
||||
'Cache-Control': 'no-cache',
|
||||
Connection: 'keep-alive',
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
Cookie: cookieHeader,
|
||||
Host: 'www.directv.com.ar',
|
||||
Origin: 'https://www.directv.com.ar',
|
||||
Pragma: 'no-cache',
|
||||
Referer: 'https://www.directv.com.ar/guia/guia.aspx',
|
||||
'Sec-Fetch-Dest': 'empty',
|
||||
'Sec-Fetch-Mode': 'cors',
|
||||
'Sec-Fetch-Site': 'same-origin',
|
||||
'Sec-GPC': 1,
|
||||
'User-Agent':
|
||||
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'sec-ch-ua': '"Not;A=Brand";v="99", "Brave";v="139", "Chromium";v="139"',
|
||||
'sec-ch-ua-mobile': '?0',
|
||||
'sec-ch-ua-platform': '"Windows"',
|
||||
uzlc: true
|
||||
}
|
||||
}
|
||||
)
|
||||
.then(r => r.data)
|
||||
.catch(console.log)
|
||||
|
||||
response.d.forEach(item => {
|
||||
channels.push({
|
||||
site_id: `${item.ContentChannelID}#${item.ChannelName.replace(/&/g, '&')}`,
|
||||
name: item.ChannelFullName,
|
||||
logo: item.ImageUrl,
|
||||
lang: 'es'
|
||||
})
|
||||
})
|
||||
|
||||
return channels
|
||||
}
|
||||
}
|
||||
|
||||
function parseRating(item) {
|
||||
return item.rating
|
||||
? {
|
||||
system: 'MPA',
|
||||
value: item.rating
|
||||
}
|
||||
: null
|
||||
}
|
||||
|
||||
function parseStart(item) {
|
||||
return dayjs.tz(item.startTimeString, 'M/D/YYYY h:mm:ss A', 'America/Argentina/Buenos_Aires')
|
||||
}
|
||||
|
||||
function parseStop(item) {
|
||||
return dayjs.tz(item.endTimeString, 'M/D/YYYY h:mm:ss A', 'America/Argentina/Buenos_Aires')
|
||||
}
|
||||
|
||||
function parseItems(content, channel) {
|
||||
if (!content) return []
|
||||
let [ChannelNumber, ChannelName] = channel.site_id.split('#')
|
||||
ChannelName = ChannelName.replace('&', '&')
|
||||
const data = JSON.parse(content)
|
||||
if (!data || !Array.isArray(data.d)) return []
|
||||
const channelData = data.d.find(
|
||||
c => c.ChannelNumber == ChannelNumber && c.ChannelName === ChannelName
|
||||
)
|
||||
|
||||
return channelData && Array.isArray(channelData.ProgramList) ? channelData.ProgramList : []
|
||||
}
|
||||
|
||||
@@ -1,169 +1,176 @@
|
||||
process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = 0
|
||||
const axios = require('axios')
|
||||
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: 'directv.com.uy',
|
||||
days: 2,
|
||||
url: 'https://www.directv.com.uy/guia/ChannelDetail.aspx/GetProgramming',
|
||||
request: {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
Cookie: 'PGCSS=16384; PGLang=S; PGCulture=es-UY;'
|
||||
},
|
||||
data({ channel, date }) {
|
||||
const [channelNum, channelName] = channel.site_id.split('#')
|
||||
|
||||
return {
|
||||
filterParameters: {
|
||||
day: date.date(),
|
||||
time: 0,
|
||||
minute: 0,
|
||||
month: date.month() + 1,
|
||||
year: date.year(),
|
||||
offSetValue: 0,
|
||||
filtersScreenFilters: [''],
|
||||
isHd: '',
|
||||
isChannelDetails: 'Y',
|
||||
channelNum,
|
||||
channelName: channelName.replace('&', '&')
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
parser({ content, channel }) {
|
||||
let programs = []
|
||||
const items = parseItems(content, channel)
|
||||
items.forEach(item => {
|
||||
programs.push({
|
||||
title: item.title,
|
||||
description: item.description,
|
||||
rating: parseRating(item),
|
||||
start: parseStart(item),
|
||||
stop: parseStop(item)
|
||||
})
|
||||
})
|
||||
|
||||
return programs
|
||||
},
|
||||
async channels() {
|
||||
let channels = []
|
||||
const cookies = await axios.get('https://www.directv.com.uy/guia/guia.aspx', {
|
||||
headers: {
|
||||
Accept: 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8',
|
||||
'Accept-Encoding': 'gzip, deflate, br, zstd',
|
||||
'Accept-Language': 'es-419,es;q=0.9',
|
||||
'Cache-Control': 'no-cache',
|
||||
Connection: 'keep-alive',
|
||||
Host: 'www.directv.com.ar',
|
||||
Pragma: 'no-cache',
|
||||
Referer: 'https://www.google.com/',
|
||||
'Sec-Fetch-Dest': 'document',
|
||||
'Sec-Fetch-Mode': 'navigate',
|
||||
'Sec-Fetch-Site': 'same-origin',
|
||||
'Sec-Fetch-User': '?1',
|
||||
'Sec-GPC': 1,
|
||||
'Upgrade-Insecure-Requests': 1,
|
||||
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36',
|
||||
'sec-ch-ua': '"Not;A=Brand";v="99", "Brave";v="139", "Chromium";v="139"',
|
||||
'sec-ch-ua-mobile': '?0',
|
||||
'sec-ch-ua-platform': '"Windows"'
|
||||
}})
|
||||
const cookieHeader = cookies.headers['set-cookie'].map(cookie => cookie.split(';')[0]).join('; ')
|
||||
|
||||
const date = dayjs().tz('America/Montevideo')
|
||||
|
||||
const response = await axios.post(
|
||||
'https://www.directv.com.uy/guia/guia.aspx/GetProgramming',
|
||||
{
|
||||
filterParam: {
|
||||
day: date.date(),
|
||||
time: date.hour(),
|
||||
minute: 0,
|
||||
month: date.month() + 1,
|
||||
year: date.year(),
|
||||
offSetValue: 0,
|
||||
homeScreenFilter: '',
|
||||
filtersScreenFilters: [''],
|
||||
isHd: ''
|
||||
}
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
Accept: '*/*',
|
||||
'Accept-Encoding': 'gzip, deflate, br, zstd',
|
||||
'Accept-Language': 'es-419,es;q=0.9',
|
||||
'Cache-Control': 'no-cache',
|
||||
Connection: 'keep-alive',
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
Cookie: cookieHeader,
|
||||
Host: 'www.directv.com.ar',
|
||||
Origin: 'https://www.directv.com.uy',
|
||||
Pragma: 'no-cache',
|
||||
Referer: 'https://www.directv.com.uy/guia/guia.aspx',
|
||||
'Sec-Fetch-Dest': 'empty',
|
||||
'Sec-Fetch-Mode': 'cors',
|
||||
'Sec-Fetch-Site': 'same-origin',
|
||||
'Sec-GPC': 1,
|
||||
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'sec-ch-ua': '"Not;A=Brand";v="99", "Brave";v="139", "Chromium";v="139"',
|
||||
'sec-ch-ua-mobile': '?0',
|
||||
'sec-ch-ua-platform': '"Windows"',
|
||||
'uzlc': true,
|
||||
}
|
||||
}
|
||||
)
|
||||
.then(r => r.data)
|
||||
.catch(console.log)
|
||||
|
||||
response.d.forEach(item => {
|
||||
channels.push({
|
||||
site_id: `${item.ContentChannelID}#${item.ChannelName.replace(/&/g, '&')}`,
|
||||
name: item.ChannelFullName,
|
||||
logo: item.ImageUrl,
|
||||
lang: 'es'
|
||||
})
|
||||
})
|
||||
|
||||
return channels
|
||||
}
|
||||
}
|
||||
|
||||
function parseRating(item) {
|
||||
return item.rating
|
||||
? {
|
||||
system: 'MPA',
|
||||
value: item.rating
|
||||
}
|
||||
: null
|
||||
}
|
||||
|
||||
function parseStart(item) {
|
||||
return dayjs.tz(item.startTimeString, 'M/D/YYYY h:mm:ss A', 'America/Montevideo')
|
||||
}
|
||||
|
||||
function parseStop(item) {
|
||||
return dayjs.tz(item.endTimeString, 'M/D/YYYY h:mm:ss A', 'America/Montevideo')
|
||||
}
|
||||
|
||||
function parseItems(content, channel) {
|
||||
if (!content) return []
|
||||
let [ChannelNumber, ChannelName] = channel.site_id.split('#')
|
||||
ChannelName = ChannelName.replace('&', '&')
|
||||
const data = JSON.parse(content)
|
||||
if (!data || !Array.isArray(data.d)) return []
|
||||
const channelData = data.d.find(
|
||||
c => c.ChannelNumber == ChannelNumber && c.ChannelName === ChannelName
|
||||
)
|
||||
|
||||
return channelData && Array.isArray(channelData.ProgramList) ? channelData.ProgramList : []
|
||||
}
|
||||
process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = 0
|
||||
const axios = require('axios')
|
||||
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: 'directv.com.uy',
|
||||
days: 2,
|
||||
url: 'https://www.directv.com.uy/guia/ChannelDetail.aspx/GetProgramming',
|
||||
request: {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
Cookie: 'PGCSS=16384; PGLang=S; PGCulture=es-UY;'
|
||||
},
|
||||
data({ channel, date }) {
|
||||
const [channelNum, channelName] = channel.site_id.split('#')
|
||||
|
||||
return {
|
||||
filterParameters: {
|
||||
day: date.date(),
|
||||
time: 0,
|
||||
minute: 0,
|
||||
month: date.month() + 1,
|
||||
year: date.year(),
|
||||
offSetValue: 0,
|
||||
filtersScreenFilters: [''],
|
||||
isHd: '',
|
||||
isChannelDetails: 'Y',
|
||||
channelNum,
|
||||
channelName: channelName.replace('&', '&')
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
parser({ content, channel }) {
|
||||
let programs = []
|
||||
const items = parseItems(content, channel)
|
||||
items.forEach(item => {
|
||||
programs.push({
|
||||
title: item.title,
|
||||
description: item.description,
|
||||
rating: parseRating(item),
|
||||
start: parseStart(item),
|
||||
stop: parseStop(item)
|
||||
})
|
||||
})
|
||||
|
||||
return programs
|
||||
},
|
||||
async channels() {
|
||||
let channels = []
|
||||
const cookies = await axios.get('https://www.directv.com.uy/guia/guia.aspx', {
|
||||
headers: {
|
||||
Accept:
|
||||
'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8',
|
||||
'Accept-Encoding': 'gzip, deflate, br, zstd',
|
||||
'Accept-Language': 'es-419,es;q=0.9',
|
||||
'Cache-Control': 'no-cache',
|
||||
Connection: 'keep-alive',
|
||||
Host: 'www.directv.com.ar',
|
||||
Pragma: 'no-cache',
|
||||
Referer: 'https://www.google.com/',
|
||||
'Sec-Fetch-Dest': 'document',
|
||||
'Sec-Fetch-Mode': 'navigate',
|
||||
'Sec-Fetch-Site': 'same-origin',
|
||||
'Sec-Fetch-User': '?1',
|
||||
'Sec-GPC': 1,
|
||||
'Upgrade-Insecure-Requests': 1,
|
||||
'User-Agent':
|
||||
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36',
|
||||
'sec-ch-ua': '"Not;A=Brand";v="99", "Brave";v="139", "Chromium";v="139"',
|
||||
'sec-ch-ua-mobile': '?0',
|
||||
'sec-ch-ua-platform': '"Windows"'
|
||||
}
|
||||
})
|
||||
const cookieHeader = cookies.headers['set-cookie']
|
||||
.map(cookie => cookie.split(';')[0])
|
||||
.join('; ')
|
||||
|
||||
const date = dayjs().tz('America/Montevideo')
|
||||
|
||||
const response = await axios
|
||||
.post(
|
||||
'https://www.directv.com.uy/guia/guia.aspx/GetProgramming',
|
||||
{
|
||||
filterParam: {
|
||||
day: date.date(),
|
||||
time: date.hour(),
|
||||
minute: 0,
|
||||
month: date.month() + 1,
|
||||
year: date.year(),
|
||||
offSetValue: 0,
|
||||
homeScreenFilter: '',
|
||||
filtersScreenFilters: [''],
|
||||
isHd: ''
|
||||
}
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
Accept: '*/*',
|
||||
'Accept-Encoding': 'gzip, deflate, br, zstd',
|
||||
'Accept-Language': 'es-419,es;q=0.9',
|
||||
'Cache-Control': 'no-cache',
|
||||
Connection: 'keep-alive',
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
Cookie: cookieHeader,
|
||||
Host: 'www.directv.com.ar',
|
||||
Origin: 'https://www.directv.com.uy',
|
||||
Pragma: 'no-cache',
|
||||
Referer: 'https://www.directv.com.uy/guia/guia.aspx',
|
||||
'Sec-Fetch-Dest': 'empty',
|
||||
'Sec-Fetch-Mode': 'cors',
|
||||
'Sec-Fetch-Site': 'same-origin',
|
||||
'Sec-GPC': 1,
|
||||
'User-Agent':
|
||||
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'sec-ch-ua': '"Not;A=Brand";v="99", "Brave";v="139", "Chromium";v="139"',
|
||||
'sec-ch-ua-mobile': '?0',
|
||||
'sec-ch-ua-platform': '"Windows"',
|
||||
uzlc: true
|
||||
}
|
||||
}
|
||||
)
|
||||
.then(r => r.data)
|
||||
.catch(console.log)
|
||||
|
||||
response.d.forEach(item => {
|
||||
channels.push({
|
||||
site_id: `${item.ContentChannelID}#${item.ChannelName.replace(/&/g, '&')}`,
|
||||
name: item.ChannelFullName,
|
||||
logo: item.ImageUrl,
|
||||
lang: 'es'
|
||||
})
|
||||
})
|
||||
|
||||
return channels
|
||||
}
|
||||
}
|
||||
|
||||
function parseRating(item) {
|
||||
return item.rating
|
||||
? {
|
||||
system: 'MPA',
|
||||
value: item.rating
|
||||
}
|
||||
: null
|
||||
}
|
||||
|
||||
function parseStart(item) {
|
||||
return dayjs.tz(item.startTimeString, 'M/D/YYYY h:mm:ss A', 'America/Montevideo')
|
||||
}
|
||||
|
||||
function parseStop(item) {
|
||||
return dayjs.tz(item.endTimeString, 'M/D/YYYY h:mm:ss A', 'America/Montevideo')
|
||||
}
|
||||
|
||||
function parseItems(content, channel) {
|
||||
if (!content) return []
|
||||
let [ChannelNumber, ChannelName] = channel.site_id.split('#')
|
||||
ChannelName = ChannelName.replace('&', '&')
|
||||
const data = JSON.parse(content)
|
||||
if (!data || !Array.isArray(data.d)) return []
|
||||
const channelData = data.d.find(
|
||||
c => c.ChannelNumber == ChannelNumber && c.ChannelName === ChannelName
|
||||
)
|
||||
|
||||
return channelData && Array.isArray(channelData.ProgramList) ? channelData.ProgramList : []
|
||||
}
|
||||
|
||||
@@ -1,176 +1,177 @@
|
||||
const axios = require('axios')
|
||||
const dayjs = require('dayjs')
|
||||
const utc = require('dayjs/plugin/utc')
|
||||
const tz = require('dayjs/plugin/timezone')
|
||||
const timezone = 'Asia/Kolkata'
|
||||
|
||||
dayjs.extend(utc)
|
||||
dayjs.extend(tz)
|
||||
|
||||
let authToken
|
||||
|
||||
module.exports = {
|
||||
site: 'dishtv.in',
|
||||
days: 2,
|
||||
url: 'https://epg.mysmartstick.com/dishtv/api/v1/epg/entities/programs',
|
||||
request: {
|
||||
method: 'POST',
|
||||
async headers() {
|
||||
await fetchToken()
|
||||
|
||||
return {
|
||||
Authorization: authToken
|
||||
}
|
||||
},
|
||||
data({ channel, date }) {
|
||||
return {
|
||||
allowPastEvents: true,
|
||||
channelid: channel.site_id,
|
||||
date: date.format('DD/MM/YYYY')
|
||||
}
|
||||
}
|
||||
},
|
||||
parser: ({ content }) => {
|
||||
const programs = []
|
||||
const items = parseItems(content)
|
||||
items.forEach(item => {
|
||||
programs.push({
|
||||
title: parseTitle(item),
|
||||
description: parseDescription(item),
|
||||
category: parseCategory(item),
|
||||
actors: item.credits.actors,
|
||||
directors: item.credits.directors,
|
||||
producers: item.credits.producers,
|
||||
date: item.productionyear,
|
||||
icon: parseIcon(item),
|
||||
image: parseImage(item),
|
||||
episode: parseEpisode(item),
|
||||
start: dayjs(item.start),
|
||||
stop: dayjs(item.stop)
|
||||
})
|
||||
})
|
||||
|
||||
return programs
|
||||
},
|
||||
async channels() {
|
||||
await fetchToken()
|
||||
|
||||
const totalPages = await fetchPages()
|
||||
|
||||
const queue = Array.from(Array(totalPages).keys()).map(i => {
|
||||
const data = new FormData()
|
||||
data.append('pageNum', i + 1)
|
||||
data.append('date', dayjs.tz(dayjs(), timezone).format('DD/MM/YYYY'))
|
||||
|
||||
return {
|
||||
method: 'post',
|
||||
url: 'https://www.dishtv.in/services/epg/channels',
|
||||
data,
|
||||
headers: {
|
||||
'authorization-token': authToken
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
const channels = []
|
||||
for (let item of queue) {
|
||||
const data = await axios(item)
|
||||
.then(r => r.data)
|
||||
.catch(console.error)
|
||||
|
||||
data.programDetailsByChannel.forEach(channel => {
|
||||
channels.push({
|
||||
lang: 'en',
|
||||
site_id: channel.channelid,
|
||||
name: channel.channelname
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
return channels
|
||||
}
|
||||
}
|
||||
|
||||
function parseTitle(item) {
|
||||
return Object.values(item.regional)
|
||||
.map(region => ({
|
||||
lang: region.languagecode,
|
||||
value: region.title
|
||||
}))
|
||||
.filter(i => Boolean(i.value))
|
||||
}
|
||||
|
||||
function parseDescription(item) {
|
||||
return Object.values(item.regional)
|
||||
.map(region => ({
|
||||
lang: region.languagecode,
|
||||
value: region.desc
|
||||
}))
|
||||
.filter(i => Boolean(i.value))
|
||||
}
|
||||
|
||||
function parseCategory(item) {
|
||||
return Object.values(item.regional)
|
||||
.map(region => ({
|
||||
lang: region.languagecode,
|
||||
value: region.genre
|
||||
}))
|
||||
.filter(i => Boolean(i.value))
|
||||
}
|
||||
|
||||
function parseEpisode(item) {
|
||||
return item['episode-num'] ? parseInt(item['episode-num']) : null
|
||||
}
|
||||
|
||||
function parseIcon(item) {
|
||||
return item.programmeurl || null
|
||||
}
|
||||
|
||||
function parseImage(item) {
|
||||
return item?.images?.landscape?.['1280x720'] ? item.images.landscape['1280x720'] : null
|
||||
}
|
||||
|
||||
function parseItems(content) {
|
||||
try {
|
||||
const data = JSON.parse(content)
|
||||
|
||||
return Array.isArray(data) ? data : []
|
||||
} catch {
|
||||
return []
|
||||
}
|
||||
}
|
||||
|
||||
async function fetchToken() {
|
||||
if (authToken) return
|
||||
|
||||
const data = await axios
|
||||
.post('https://www.dishtv.in/services/epg/signin', null, {
|
||||
headers: {
|
||||
'sec-fetch-dest': 'empty',
|
||||
'sec-fetch-mode': 'cors',
|
||||
'sec-fetch-site': 'same-origin',
|
||||
'x-requested-with': 'XMLHttpRequest',
|
||||
Referer: 'https://www.dishtv.in/channel-guide.html',
|
||||
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36'
|
||||
}
|
||||
})
|
||||
.then(r => r.data)
|
||||
.catch(console.error)
|
||||
|
||||
authToken = data.token
|
||||
}
|
||||
|
||||
async function fetchPages() {
|
||||
const formData = new FormData()
|
||||
formData.append('pageNum', 1)
|
||||
formData.append('date', dayjs.tz(dayjs(), timezone).format('DD/MM/YYYY'))
|
||||
|
||||
const data = await axios
|
||||
.post('https://www.dishtv.in/services/epg/channels', formData, {
|
||||
headers: { 'authorization-token': authToken }
|
||||
})
|
||||
.then(r => r.data)
|
||||
.catch(console.error)
|
||||
|
||||
return data.totalPages ? parseInt(data.totalPages) : 0
|
||||
}
|
||||
const axios = require('axios')
|
||||
const dayjs = require('dayjs')
|
||||
const utc = require('dayjs/plugin/utc')
|
||||
const tz = require('dayjs/plugin/timezone')
|
||||
const timezone = 'Asia/Kolkata'
|
||||
|
||||
dayjs.extend(utc)
|
||||
dayjs.extend(tz)
|
||||
|
||||
let authToken
|
||||
|
||||
module.exports = {
|
||||
site: 'dishtv.in',
|
||||
days: 2,
|
||||
url: 'https://epg.mysmartstick.com/dishtv/api/v1/epg/entities/programs',
|
||||
request: {
|
||||
method: 'POST',
|
||||
async headers() {
|
||||
await fetchToken()
|
||||
|
||||
return {
|
||||
Authorization: authToken
|
||||
}
|
||||
},
|
||||
data({ channel, date }) {
|
||||
return {
|
||||
allowPastEvents: true,
|
||||
channelid: channel.site_id,
|
||||
date: date.format('DD/MM/YYYY')
|
||||
}
|
||||
}
|
||||
},
|
||||
parser: ({ content }) => {
|
||||
const programs = []
|
||||
const items = parseItems(content)
|
||||
items.forEach(item => {
|
||||
programs.push({
|
||||
title: parseTitle(item),
|
||||
description: parseDescription(item),
|
||||
category: parseCategory(item),
|
||||
actors: item.credits.actors,
|
||||
directors: item.credits.directors,
|
||||
producers: item.credits.producers,
|
||||
date: item.productionyear,
|
||||
icon: parseIcon(item),
|
||||
image: parseImage(item),
|
||||
episode: parseEpisode(item),
|
||||
start: dayjs(item.start),
|
||||
stop: dayjs(item.stop)
|
||||
})
|
||||
})
|
||||
|
||||
return programs
|
||||
},
|
||||
async channels() {
|
||||
await fetchToken()
|
||||
|
||||
const totalPages = await fetchPages()
|
||||
|
||||
const queue = Array.from(Array(totalPages).keys()).map(i => {
|
||||
const data = new FormData()
|
||||
data.append('pageNum', i + 1)
|
||||
data.append('date', dayjs.tz(dayjs(), timezone).format('DD/MM/YYYY'))
|
||||
|
||||
return {
|
||||
method: 'post',
|
||||
url: 'https://www.dishtv.in/services/epg/channels',
|
||||
data,
|
||||
headers: {
|
||||
'authorization-token': authToken
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
const channels = []
|
||||
for (let item of queue) {
|
||||
const data = await axios(item)
|
||||
.then(r => r.data)
|
||||
.catch(console.error)
|
||||
|
||||
data.programDetailsByChannel.forEach(channel => {
|
||||
channels.push({
|
||||
lang: 'en',
|
||||
site_id: channel.channelid,
|
||||
name: channel.channelname
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
return channels
|
||||
}
|
||||
}
|
||||
|
||||
function parseTitle(item) {
|
||||
return Object.values(item.regional)
|
||||
.map(region => ({
|
||||
lang: region.languagecode,
|
||||
value: region.title
|
||||
}))
|
||||
.filter(i => Boolean(i.value))
|
||||
}
|
||||
|
||||
function parseDescription(item) {
|
||||
return Object.values(item.regional)
|
||||
.map(region => ({
|
||||
lang: region.languagecode,
|
||||
value: region.desc
|
||||
}))
|
||||
.filter(i => Boolean(i.value))
|
||||
}
|
||||
|
||||
function parseCategory(item) {
|
||||
return Object.values(item.regional)
|
||||
.map(region => ({
|
||||
lang: region.languagecode,
|
||||
value: region.genre
|
||||
}))
|
||||
.filter(i => Boolean(i.value))
|
||||
}
|
||||
|
||||
function parseEpisode(item) {
|
||||
return item['episode-num'] ? parseInt(item['episode-num']) : null
|
||||
}
|
||||
|
||||
function parseIcon(item) {
|
||||
return item.programmeurl || null
|
||||
}
|
||||
|
||||
function parseImage(item) {
|
||||
return item?.images?.landscape?.['1280x720'] ? item.images.landscape['1280x720'] : null
|
||||
}
|
||||
|
||||
function parseItems(content) {
|
||||
try {
|
||||
const data = JSON.parse(content)
|
||||
|
||||
return Array.isArray(data) ? data : []
|
||||
} catch {
|
||||
return []
|
||||
}
|
||||
}
|
||||
|
||||
async function fetchToken() {
|
||||
if (authToken) return
|
||||
|
||||
const data = await axios
|
||||
.post('https://www.dishtv.in/services/epg/signin', null, {
|
||||
headers: {
|
||||
'sec-fetch-dest': 'empty',
|
||||
'sec-fetch-mode': 'cors',
|
||||
'sec-fetch-site': 'same-origin',
|
||||
'x-requested-with': 'XMLHttpRequest',
|
||||
Referer: 'https://www.dishtv.in/channel-guide.html',
|
||||
'User-Agent':
|
||||
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36'
|
||||
}
|
||||
})
|
||||
.then(r => r.data)
|
||||
.catch(console.error)
|
||||
|
||||
authToken = data.token
|
||||
}
|
||||
|
||||
async function fetchPages() {
|
||||
const formData = new FormData()
|
||||
formData.append('pageNum', 1)
|
||||
formData.append('date', dayjs.tz(dayjs(), timezone).format('DD/MM/YYYY'))
|
||||
|
||||
const data = await axios
|
||||
.post('https://www.dishtv.in/services/epg/channels', formData, {
|
||||
headers: { 'authorization-token': authToken }
|
||||
})
|
||||
.then(r => r.data)
|
||||
.catch(console.error)
|
||||
|
||||
return data.totalPages ? parseInt(data.totalPages) : 0
|
||||
}
|
||||
|
||||
@@ -1,141 +1,142 @@
|
||||
const { parser, url, request } = require('./dishtv.in.config.js')
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const axios = require('axios')
|
||||
const dayjs = require('dayjs')
|
||||
const utc = require('dayjs/plugin/utc')
|
||||
const customParseFormat = require('dayjs/plugin/customParseFormat')
|
||||
dayjs.extend(customParseFormat)
|
||||
dayjs.extend(utc)
|
||||
|
||||
jest.mock('axios')
|
||||
|
||||
axios.post.mockImplementation((url, data, params) => {
|
||||
if (
|
||||
url === 'https://www.dishtv.in/services/epg/signin' &&
|
||||
data === null &&
|
||||
JSON.stringify(params) ===
|
||||
JSON.stringify({
|
||||
headers: {
|
||||
'sec-fetch-dest': 'empty',
|
||||
'sec-fetch-mode': 'cors',
|
||||
'sec-fetch-site': 'same-origin',
|
||||
'x-requested-with': 'XMLHttpRequest',
|
||||
Referer: 'https://www.dishtv.in/channel-guide.html',
|
||||
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36'
|
||||
}
|
||||
})
|
||||
) {
|
||||
const content = fs.readFileSync(path.resolve(__dirname, '__data__/session.json'))
|
||||
|
||||
return Promise.resolve({
|
||||
data: JSON.parse(content)
|
||||
})
|
||||
} else {
|
||||
return Promise.resolve({
|
||||
data: ''
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
const date = dayjs.utc('2025-01-26', 'YYYY-MM-DD').startOf('d')
|
||||
const channel = { site_id: '142639', xmltv_id: 'AndpriveHD.in' }
|
||||
|
||||
it('can generate valid url', () => {
|
||||
expect(url).toBe('https://epg.mysmartstick.com/dishtv/api/v1/epg/entities/programs')
|
||||
})
|
||||
|
||||
it('can generate valid request method', () => {
|
||||
expect(request.method).toBe('POST')
|
||||
})
|
||||
|
||||
it('can generate valid request headers', async () => {
|
||||
expect(await request.headers()).toMatchObject({
|
||||
Authorization:
|
||||
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjbGllbnRpZCI6ImRpc2h0di13ZWJzaXRlIiwicGxhdGZvcm0iOiJkaXNodHYiLCJpYXQiOjE3Mzc2ODIxNjEsImV4cCI6MTczNzc2ODU2MX0.sPrYfodVTbf1kJ-wGICDlnH-Yt3J0-mB-M2YROU8v2Q'
|
||||
})
|
||||
})
|
||||
|
||||
it('can generate valid request data', () => {
|
||||
expect(request.data({ channel, date })).toMatchObject({
|
||||
allowPastEvents: true,
|
||||
channelid: '142639',
|
||||
date: '26/01/2025'
|
||||
})
|
||||
})
|
||||
|
||||
it('can parse response', () => {
|
||||
const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.json'))
|
||||
let results = parser({ content })
|
||||
results = results.map(p => {
|
||||
p.start = p.start.toJSON()
|
||||
p.stop = p.stop.toJSON()
|
||||
return p
|
||||
})
|
||||
|
||||
expect(results.length).toBe(16)
|
||||
expect(results[0]).toMatchObject({
|
||||
start: '2025-01-26T00:30:00.000Z',
|
||||
stop: '2025-01-26T02:05:00.000Z',
|
||||
title: [
|
||||
{ lang: 'en', value: 'Train to Busan 2: Peninsula' },
|
||||
{ lang: 'hi', value: 'ट्रेन टू बुसान 2: पेनीनसुला' },
|
||||
{ lang: 'ta', value: 'ட்ரெயின் டு பூசன் ப்ரெசென்ட்ஸ்: பெனின்சுலா' },
|
||||
{ lang: 'te', value: 'ట్రేన్ టు బూసాన్ ప్రజెంట్స్: పెనిన్సులా' }
|
||||
],
|
||||
description: [
|
||||
{
|
||||
lang: 'en',
|
||||
value:
|
||||
'Jung Seok, a former soldier, along with his teammates, sets out on a mission to battle hordes of post-apocalyptic zombies in the Korean peninsula wastelands.'
|
||||
},
|
||||
{
|
||||
lang: 'hi',
|
||||
value:
|
||||
'एक भूतपूर्व सैनिक जंग सोक अपने साथियों के साथ कोरियाई प्रायद्वीप के बंजर इलाकों में सर्वनाश के बाद की जोंबी से लड़ने के मिशन पर निकलता है।'
|
||||
},
|
||||
{
|
||||
lang: 'ta',
|
||||
value:
|
||||
'கொரிய தீபகற்பத்தின் தரிசு நிலங்களில் அபோகாலிப்டிக் ஜாம்பிக்களின் கூட்டத்தை எதிர்த்து தன் குழுவுடன் போரிடும் ஜங் சியோக்.'
|
||||
},
|
||||
{
|
||||
lang: 'te',
|
||||
value:
|
||||
'మాజీ సైనికుడు జంగ్ సియోక్ తన సహచరులతో కలిసి కొరియా ద్వీపకల్పంలో పోస్ట్-అపోకలిప్టిక్ జాంబీలతో యుద్దానికి సిద్దమవుతాడు.'
|
||||
}
|
||||
],
|
||||
category: [
|
||||
{ lang: 'en', value: 'Film' },
|
||||
{ lang: 'hi', value: 'फ़िल्म' },
|
||||
{ lang: 'ta', value: '??????????' },
|
||||
{ lang: 'te', value: 'సినిమా' },
|
||||
{ lang: 'mr', value: 'चित्रपट' }
|
||||
],
|
||||
actors: [
|
||||
'Gang Dong-won',
|
||||
'Lee Jung-hyun',
|
||||
'Lee Re',
|
||||
'Kwon Hae-hyo',
|
||||
'John D. Michaels',
|
||||
'Kim Min-jae',
|
||||
'Kim Doyun',
|
||||
'Lee Ye-won',
|
||||
'Daniel Joey Albright',
|
||||
'Pierce Conran',
|
||||
'Geoffrey Giuliano',
|
||||
'Milan-Devi LaBrey'
|
||||
],
|
||||
producers: [],
|
||||
directors: ['Yeon Sang-ho'],
|
||||
icon: 'https://dtil.tmsimg.com/assets/p17850257_v_h9_al.jpg?lock=880x660',
|
||||
image: 'https://dtil.tmsimg.com/assets/p17850257_v_h8_am.jpg?lock=1280x720',
|
||||
date: '2020'
|
||||
})
|
||||
})
|
||||
|
||||
it('can handle empty guide', () => {
|
||||
const results = parser({ content: '[]' })
|
||||
|
||||
expect(results).toMatchObject([])
|
||||
})
|
||||
const { parser, url, request } = require('./dishtv.in.config.js')
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const axios = require('axios')
|
||||
const dayjs = require('dayjs')
|
||||
const utc = require('dayjs/plugin/utc')
|
||||
const customParseFormat = require('dayjs/plugin/customParseFormat')
|
||||
dayjs.extend(customParseFormat)
|
||||
dayjs.extend(utc)
|
||||
|
||||
jest.mock('axios')
|
||||
|
||||
axios.post.mockImplementation((url, data, params) => {
|
||||
if (
|
||||
url === 'https://www.dishtv.in/services/epg/signin' &&
|
||||
data === null &&
|
||||
JSON.stringify(params) ===
|
||||
JSON.stringify({
|
||||
headers: {
|
||||
'sec-fetch-dest': 'empty',
|
||||
'sec-fetch-mode': 'cors',
|
||||
'sec-fetch-site': 'same-origin',
|
||||
'x-requested-with': 'XMLHttpRequest',
|
||||
Referer: 'https://www.dishtv.in/channel-guide.html',
|
||||
'User-Agent':
|
||||
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36'
|
||||
}
|
||||
})
|
||||
) {
|
||||
const content = fs.readFileSync(path.resolve(__dirname, '__data__/session.json'))
|
||||
|
||||
return Promise.resolve({
|
||||
data: JSON.parse(content)
|
||||
})
|
||||
} else {
|
||||
return Promise.resolve({
|
||||
data: ''
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
const date = dayjs.utc('2025-01-26', 'YYYY-MM-DD').startOf('d')
|
||||
const channel = { site_id: '142639', xmltv_id: 'AndpriveHD.in' }
|
||||
|
||||
it('can generate valid url', () => {
|
||||
expect(url).toBe('https://epg.mysmartstick.com/dishtv/api/v1/epg/entities/programs')
|
||||
})
|
||||
|
||||
it('can generate valid request method', () => {
|
||||
expect(request.method).toBe('POST')
|
||||
})
|
||||
|
||||
it('can generate valid request headers', async () => {
|
||||
expect(await request.headers()).toMatchObject({
|
||||
Authorization:
|
||||
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjbGllbnRpZCI6ImRpc2h0di13ZWJzaXRlIiwicGxhdGZvcm0iOiJkaXNodHYiLCJpYXQiOjE3Mzc2ODIxNjEsImV4cCI6MTczNzc2ODU2MX0.sPrYfodVTbf1kJ-wGICDlnH-Yt3J0-mB-M2YROU8v2Q'
|
||||
})
|
||||
})
|
||||
|
||||
it('can generate valid request data', () => {
|
||||
expect(request.data({ channel, date })).toMatchObject({
|
||||
allowPastEvents: true,
|
||||
channelid: '142639',
|
||||
date: '26/01/2025'
|
||||
})
|
||||
})
|
||||
|
||||
it('can parse response', () => {
|
||||
const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.json'))
|
||||
let results = parser({ content })
|
||||
results = results.map(p => {
|
||||
p.start = p.start.toJSON()
|
||||
p.stop = p.stop.toJSON()
|
||||
return p
|
||||
})
|
||||
|
||||
expect(results.length).toBe(16)
|
||||
expect(results[0]).toMatchObject({
|
||||
start: '2025-01-26T00:30:00.000Z',
|
||||
stop: '2025-01-26T02:05:00.000Z',
|
||||
title: [
|
||||
{ lang: 'en', value: 'Train to Busan 2: Peninsula' },
|
||||
{ lang: 'hi', value: 'ट्रेन टू बुसान 2: पेनीनसुला' },
|
||||
{ lang: 'ta', value: 'ட்ரெயின் டு பூசன் ப்ரெசென்ட்ஸ்: பெனின்சுலா' },
|
||||
{ lang: 'te', value: 'ట్రేన్ టు బూసాన్ ప్రజెంట్స్: పెనిన్సులా' }
|
||||
],
|
||||
description: [
|
||||
{
|
||||
lang: 'en',
|
||||
value:
|
||||
'Jung Seok, a former soldier, along with his teammates, sets out on a mission to battle hordes of post-apocalyptic zombies in the Korean peninsula wastelands.'
|
||||
},
|
||||
{
|
||||
lang: 'hi',
|
||||
value:
|
||||
'एक भूतपूर्व सैनिक जंग सोक अपने साथियों के साथ कोरियाई प्रायद्वीप के बंजर इलाकों में सर्वनाश के बाद की जोंबी से लड़ने के मिशन पर निकलता है।'
|
||||
},
|
||||
{
|
||||
lang: 'ta',
|
||||
value:
|
||||
'கொரிய தீபகற்பத்தின் தரிசு நிலங்களில் அபோகாலிப்டிக் ஜாம்பிக்களின் கூட்டத்தை எதிர்த்து தன் குழுவுடன் போரிடும் ஜங் சியோக்.'
|
||||
},
|
||||
{
|
||||
lang: 'te',
|
||||
value:
|
||||
'మాజీ సైనికుడు జంగ్ సియోక్ తన సహచరులతో కలిసి కొరియా ద్వీపకల్పంలో పోస్ట్-అపోకలిప్టిక్ జాంబీలతో యుద్దానికి సిద్దమవుతాడు.'
|
||||
}
|
||||
],
|
||||
category: [
|
||||
{ lang: 'en', value: 'Film' },
|
||||
{ lang: 'hi', value: 'फ़िल्म' },
|
||||
{ lang: 'ta', value: '??????????' },
|
||||
{ lang: 'te', value: 'సినిమా' },
|
||||
{ lang: 'mr', value: 'चित्रपट' }
|
||||
],
|
||||
actors: [
|
||||
'Gang Dong-won',
|
||||
'Lee Jung-hyun',
|
||||
'Lee Re',
|
||||
'Kwon Hae-hyo',
|
||||
'John D. Michaels',
|
||||
'Kim Min-jae',
|
||||
'Kim Doyun',
|
||||
'Lee Ye-won',
|
||||
'Daniel Joey Albright',
|
||||
'Pierce Conran',
|
||||
'Geoffrey Giuliano',
|
||||
'Milan-Devi LaBrey'
|
||||
],
|
||||
producers: [],
|
||||
directors: ['Yeon Sang-ho'],
|
||||
icon: 'https://dtil.tmsimg.com/assets/p17850257_v_h9_al.jpg?lock=880x660',
|
||||
image: 'https://dtil.tmsimg.com/assets/p17850257_v_h8_am.jpg?lock=1280x720',
|
||||
date: '2020'
|
||||
})
|
||||
})
|
||||
|
||||
it('can handle empty guide', () => {
|
||||
const results = parser({ content: '[]' })
|
||||
|
||||
expect(results).toMatchObject([])
|
||||
})
|
||||
|
||||
@@ -1,87 +1,87 @@
|
||||
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: 'dtv8.net',
|
||||
days: 2,
|
||||
url({ date }) {
|
||||
const day = date.format('dddd')
|
||||
|
||||
return `https://dtv8.net/tv-listings/${day.toLowerCase()}/`
|
||||
},
|
||||
parser({ content, date }) {
|
||||
let programs = []
|
||||
|
||||
const items = parseItems(content)
|
||||
items.forEach(item => {
|
||||
const $item = cheerio.load(item)
|
||||
let prev = programs[programs.length - 1]
|
||||
let start = parseStart($item, date)
|
||||
if (prev) {
|
||||
if (start < prev.start) {
|
||||
start = start.add(1, 'd')
|
||||
date = date.add(1, 'd')
|
||||
}
|
||||
prev.stop = start
|
||||
}
|
||||
const stop = start.add(30, 'm')
|
||||
|
||||
programs.push({
|
||||
title: parseTitle($item),
|
||||
description: parseDescription($item),
|
||||
image: parseImage($item),
|
||||
start,
|
||||
stop
|
||||
})
|
||||
})
|
||||
|
||||
return programs
|
||||
}
|
||||
}
|
||||
|
||||
function parseTitle($item) {
|
||||
return $item(
|
||||
'td:nth-child(2) > strong:nth-child(1),td:nth-child(2) > span > strong,td:nth-child(2) > span > b'
|
||||
).text()
|
||||
}
|
||||
|
||||
function parseDescription($item) {
|
||||
return (
|
||||
$item(
|
||||
'td:nth-child(2) > strong:nth-child(3) > span,td:nth-child(2) > p:nth-child(3) > strong > span'
|
||||
).text() || null
|
||||
)
|
||||
}
|
||||
|
||||
function parseImage($item) {
|
||||
return $item('td:nth-child(1) > img.size-full').attr('src') || null
|
||||
}
|
||||
|
||||
function parseStart($item, date) {
|
||||
const time = $item('td:nth-child(1)').text()
|
||||
|
||||
return dayjs.tz(
|
||||
`${date.format('YYYY-MM-DD')} ${time}`,
|
||||
'YYYY-MM-DD HH:mm [hrs.]',
|
||||
'America/Guyana'
|
||||
)
|
||||
}
|
||||
|
||||
function parseItems(content) {
|
||||
const $ = cheerio.load(content)
|
||||
|
||||
return $('table tr')
|
||||
.filter((i, el) => {
|
||||
const firstColumn = $(el).find('td').text()
|
||||
|
||||
return Boolean(firstColumn) && !firstColumn.includes('Time')
|
||||
})
|
||||
.toArray()
|
||||
}
|
||||
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: 'dtv8.net',
|
||||
days: 2,
|
||||
url({ date }) {
|
||||
const day = date.format('dddd')
|
||||
|
||||
return `https://dtv8.net/tv-listings/${day.toLowerCase()}/`
|
||||
},
|
||||
parser({ content, date }) {
|
||||
let programs = []
|
||||
|
||||
const items = parseItems(content)
|
||||
items.forEach(item => {
|
||||
const $item = cheerio.load(item)
|
||||
let prev = programs[programs.length - 1]
|
||||
let start = parseStart($item, date)
|
||||
if (prev) {
|
||||
if (start < prev.start) {
|
||||
start = start.add(1, 'd')
|
||||
date = date.add(1, 'd')
|
||||
}
|
||||
prev.stop = start
|
||||
}
|
||||
const stop = start.add(30, 'm')
|
||||
|
||||
programs.push({
|
||||
title: parseTitle($item),
|
||||
description: parseDescription($item),
|
||||
image: parseImage($item),
|
||||
start,
|
||||
stop
|
||||
})
|
||||
})
|
||||
|
||||
return programs
|
||||
}
|
||||
}
|
||||
|
||||
function parseTitle($item) {
|
||||
return $item(
|
||||
'td:nth-child(2) > strong:nth-child(1),td:nth-child(2) > span > strong,td:nth-child(2) > span > b'
|
||||
).text()
|
||||
}
|
||||
|
||||
function parseDescription($item) {
|
||||
return (
|
||||
$item(
|
||||
'td:nth-child(2) > strong:nth-child(3) > span,td:nth-child(2) > p:nth-child(3) > strong > span'
|
||||
).text() || null
|
||||
)
|
||||
}
|
||||
|
||||
function parseImage($item) {
|
||||
return $item('td:nth-child(1) > img.size-full').attr('src') || null
|
||||
}
|
||||
|
||||
function parseStart($item, date) {
|
||||
const time = $item('td:nth-child(1)').text()
|
||||
|
||||
return dayjs.tz(
|
||||
`${date.format('YYYY-MM-DD')} ${time}`,
|
||||
'YYYY-MM-DD HH:mm [hrs.]',
|
||||
'America/Guyana'
|
||||
)
|
||||
}
|
||||
|
||||
function parseItems(content) {
|
||||
const $ = cheerio.load(content)
|
||||
|
||||
return $('table tr')
|
||||
.filter((i, el) => {
|
||||
const firstColumn = $(el).find('td').text()
|
||||
|
||||
return Boolean(firstColumn) && !firstColumn.includes('Time')
|
||||
})
|
||||
.toArray()
|
||||
}
|
||||
|
||||
@@ -1,154 +1,155 @@
|
||||
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')
|
||||
require('dayjs/locale/ar')
|
||||
|
||||
dayjs.extend(customParseFormat)
|
||||
dayjs.extend(timezone)
|
||||
dayjs.extend(utc)
|
||||
|
||||
const headers = {
|
||||
'User-Agent':
|
||||
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36 OPR/115.0.0.0' }
|
||||
|
||||
module.exports = {
|
||||
site: 'elcinema.com',
|
||||
days: 2,
|
||||
request: { headers },
|
||||
url({ channel }) {
|
||||
const lang = channel.lang === 'en' ? 'en/' : '/'
|
||||
|
||||
return `https://elcinema.com/${lang}tvguide/${channel.site_id}/`
|
||||
},
|
||||
parser({ content, channel, date }) {
|
||||
const programs = []
|
||||
const items = parseItems(content, channel, date)
|
||||
items.forEach(item => {
|
||||
const start = parseStart(item, date)
|
||||
const duration = parseDuration(item)
|
||||
const stop = start.add(duration, 'm')
|
||||
programs.push({
|
||||
title: parseTitle(item),
|
||||
description: parseDescription(item),
|
||||
category: parseCategory(item),
|
||||
image: parseImage(item),
|
||||
start,
|
||||
stop
|
||||
})
|
||||
})
|
||||
|
||||
return programs
|
||||
},
|
||||
async channels({ lang }) {
|
||||
const axios = require('axios')
|
||||
let data = ''
|
||||
try {
|
||||
const res = await axios.get(`https://elcinema.com/${lang}/tvguide/`, {
|
||||
headers: headers
|
||||
})
|
||||
data = res && res.data ? res.data : ''
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
return []
|
||||
}
|
||||
|
||||
const $ = cheerio.load(data)
|
||||
|
||||
return $('.tv-line')
|
||||
.map((_, el) => {
|
||||
const link = $(el).find('.channel > div > div.hide-for-small-only > a')
|
||||
const name = $(link).text()
|
||||
const href = $(link).attr('href') || ''
|
||||
const match = href.match(/\/(\d+)\/$/)
|
||||
const site_id = match ? match[1] : null
|
||||
|
||||
return {
|
||||
lang,
|
||||
site_id,
|
||||
name
|
||||
}
|
||||
})
|
||||
.get()
|
||||
}
|
||||
}
|
||||
|
||||
function parseImage(item) {
|
||||
const $ = cheerio.load(item)
|
||||
const imgSrc =
|
||||
$('.row > div.columns.small-3.large-1 > a > img').data('src') ||
|
||||
$('.row > div.columns.small-5.large-1 > img').data('src')
|
||||
|
||||
return imgSrc || null
|
||||
}
|
||||
|
||||
function parseCategory(item) {
|
||||
const $ = cheerio.load(item)
|
||||
const category = $('.row > div.columns.small-6.large-3 > ul > li:nth-child(2)').text()
|
||||
|
||||
return category.replace(/\(\d+\)/, '').trim() || null
|
||||
}
|
||||
|
||||
function parseDuration(item) {
|
||||
const $ = cheerio.load(item)
|
||||
const duration =
|
||||
$('.row > div.columns.small-3.large-2 > ul > li:nth-child(2) > span').text() ||
|
||||
$('.row > div.columns.small-7.large-11 > ul > li:nth-child(2) > span').text()
|
||||
|
||||
return duration.replace(/\D/g, '') || ''
|
||||
}
|
||||
|
||||
function parseStart(item, initDate) {
|
||||
const $ = cheerio.load(item)
|
||||
let time =
|
||||
$('.row > div.columns.small-3.large-2 > ul > li:nth-child(1)').text() ||
|
||||
$('.row > div.columns.small-7.large-11 > ul > li:nth-child(2)').text() ||
|
||||
''
|
||||
|
||||
time = time
|
||||
.replace(/\[.*\]/, '')
|
||||
.replace('مساءً', 'PM')
|
||||
.replace('صباحًا', 'AM')
|
||||
.trim()
|
||||
|
||||
time = `${initDate.format('YYYY-MM-DD')} ${time}`
|
||||
|
||||
return dayjs.tz(time, 'YYYY-MM-DD hh:mm A', dayjs.tz.guess())
|
||||
}
|
||||
|
||||
function parseTitle(item) {
|
||||
const $ = cheerio.load(item)
|
||||
|
||||
return (
|
||||
$('.row > div.columns.small-6.large-3 > ul > li:nth-child(1) > a').text() ||
|
||||
$('.row > div.columns.small-7.large-11 > ul > li:nth-child(1)').text() ||
|
||||
null
|
||||
)
|
||||
}
|
||||
|
||||
function parseDescription(item) {
|
||||
const $ = cheerio.load(item)
|
||||
const excerpt = $('.row > div.columns.small-12.large-6 > ul > li:nth-child(3)').text() || ''
|
||||
|
||||
return excerpt.replace('...اقرأ المزيد', '').replace('...Read more', '')
|
||||
}
|
||||
|
||||
function parseItems(content, channel, date) {
|
||||
const $ = cheerio.load(content)
|
||||
|
||||
const dateString = date.locale(channel.lang).format('dddd D')
|
||||
|
||||
const list = $('.dates')
|
||||
.filter((i, el) => {
|
||||
let parsedDateString = $(el).text().trim()
|
||||
parsedDateString = parsedDateString.replace(/\s\s+/g, ' ')
|
||||
|
||||
return parsedDateString.includes(dateString)
|
||||
})
|
||||
.first()
|
||||
.parent()
|
||||
.next()
|
||||
|
||||
return $('.padded-half', list).toArray()
|
||||
}
|
||||
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')
|
||||
require('dayjs/locale/ar')
|
||||
|
||||
dayjs.extend(customParseFormat)
|
||||
dayjs.extend(timezone)
|
||||
dayjs.extend(utc)
|
||||
|
||||
const headers = {
|
||||
'User-Agent':
|
||||
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36 OPR/115.0.0.0'
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
site: 'elcinema.com',
|
||||
days: 2,
|
||||
request: { headers },
|
||||
url({ channel }) {
|
||||
const lang = channel.lang === 'en' ? 'en/' : '/'
|
||||
|
||||
return `https://elcinema.com/${lang}tvguide/${channel.site_id}/`
|
||||
},
|
||||
parser({ content, channel, date }) {
|
||||
const programs = []
|
||||
const items = parseItems(content, channel, date)
|
||||
items.forEach(item => {
|
||||
const start = parseStart(item, date)
|
||||
const duration = parseDuration(item)
|
||||
const stop = start.add(duration, 'm')
|
||||
programs.push({
|
||||
title: parseTitle(item),
|
||||
description: parseDescription(item),
|
||||
category: parseCategory(item),
|
||||
image: parseImage(item),
|
||||
start,
|
||||
stop
|
||||
})
|
||||
})
|
||||
|
||||
return programs
|
||||
},
|
||||
async channels({ lang }) {
|
||||
const axios = require('axios')
|
||||
let data = ''
|
||||
try {
|
||||
const res = await axios.get(`https://elcinema.com/${lang}/tvguide/`, {
|
||||
headers: headers
|
||||
})
|
||||
data = res && res.data ? res.data : ''
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
return []
|
||||
}
|
||||
|
||||
const $ = cheerio.load(data)
|
||||
|
||||
return $('.tv-line')
|
||||
.map((_, el) => {
|
||||
const link = $(el).find('.channel > div > div.hide-for-small-only > a')
|
||||
const name = $(link).text()
|
||||
const href = $(link).attr('href') || ''
|
||||
const match = href.match(/\/(\d+)\/$/)
|
||||
const site_id = match ? match[1] : null
|
||||
|
||||
return {
|
||||
lang,
|
||||
site_id,
|
||||
name
|
||||
}
|
||||
})
|
||||
.get()
|
||||
}
|
||||
}
|
||||
|
||||
function parseImage(item) {
|
||||
const $ = cheerio.load(item)
|
||||
const imgSrc =
|
||||
$('.row > div.columns.small-3.large-1 > a > img').data('src') ||
|
||||
$('.row > div.columns.small-5.large-1 > img').data('src')
|
||||
|
||||
return imgSrc || null
|
||||
}
|
||||
|
||||
function parseCategory(item) {
|
||||
const $ = cheerio.load(item)
|
||||
const category = $('.row > div.columns.small-6.large-3 > ul > li:nth-child(2)').text()
|
||||
|
||||
return category.replace(/\(\d+\)/, '').trim() || null
|
||||
}
|
||||
|
||||
function parseDuration(item) {
|
||||
const $ = cheerio.load(item)
|
||||
const duration =
|
||||
$('.row > div.columns.small-3.large-2 > ul > li:nth-child(2) > span').text() ||
|
||||
$('.row > div.columns.small-7.large-11 > ul > li:nth-child(2) > span').text()
|
||||
|
||||
return duration.replace(/\D/g, '') || ''
|
||||
}
|
||||
|
||||
function parseStart(item, initDate) {
|
||||
const $ = cheerio.load(item)
|
||||
let time =
|
||||
$('.row > div.columns.small-3.large-2 > ul > li:nth-child(1)').text() ||
|
||||
$('.row > div.columns.small-7.large-11 > ul > li:nth-child(2)').text() ||
|
||||
''
|
||||
|
||||
time = time
|
||||
.replace(/\[.*\]/, '')
|
||||
.replace('مساءً', 'PM')
|
||||
.replace('صباحًا', 'AM')
|
||||
.trim()
|
||||
|
||||
time = `${initDate.format('YYYY-MM-DD')} ${time}`
|
||||
|
||||
return dayjs.tz(time, 'YYYY-MM-DD hh:mm A', dayjs.tz.guess())
|
||||
}
|
||||
|
||||
function parseTitle(item) {
|
||||
const $ = cheerio.load(item)
|
||||
|
||||
return (
|
||||
$('.row > div.columns.small-6.large-3 > ul > li:nth-child(1) > a').text() ||
|
||||
$('.row > div.columns.small-7.large-11 > ul > li:nth-child(1)').text() ||
|
||||
null
|
||||
)
|
||||
}
|
||||
|
||||
function parseDescription(item) {
|
||||
const $ = cheerio.load(item)
|
||||
const excerpt = $('.row > div.columns.small-12.large-6 > ul > li:nth-child(3)').text() || ''
|
||||
|
||||
return excerpt.replace('...اقرأ المزيد', '').replace('...Read more', '')
|
||||
}
|
||||
|
||||
function parseItems(content, channel, date) {
|
||||
const $ = cheerio.load(content)
|
||||
|
||||
const dateString = date.locale(channel.lang).format('dddd D')
|
||||
|
||||
const list = $('.dates')
|
||||
.filter((i, el) => {
|
||||
let parsedDateString = $(el).text().trim()
|
||||
parsedDateString = parsedDateString.replace(/\s\s+/g, ' ')
|
||||
|
||||
return parsedDateString.includes(dateString)
|
||||
})
|
||||
.first()
|
||||
.parent()
|
||||
.next()
|
||||
|
||||
return $('.padded-half', list).toArray()
|
||||
}
|
||||
|
||||
@@ -1,54 +1,57 @@
|
||||
const axios = require('axios')
|
||||
const parser = require('epg-parser')
|
||||
|
||||
module.exports = {
|
||||
site: 'epg.112114.xyz',
|
||||
days: 1,
|
||||
url: 'https://epg.112114.xyz/pp.xml',
|
||||
request: {
|
||||
cache: {
|
||||
ttl: 24 * 60 * 60 * 1000 // 1 day
|
||||
}
|
||||
},
|
||||
parser: function ({ content, channel, date }) {
|
||||
let programs = []
|
||||
const items = parseItems(content, channel, date)
|
||||
items.forEach(item => {
|
||||
programs.push({
|
||||
title: item.title?.[0]?.value,
|
||||
start: item.start,
|
||||
stop: item.stop
|
||||
})
|
||||
})
|
||||
|
||||
return programs
|
||||
},
|
||||
async channels() {
|
||||
const data = await axios
|
||||
.get('https://epg.112114.xyz/pp.xml')
|
||||
.then(r => r.data)
|
||||
.catch(e => { console.log(e); return null })
|
||||
if (!data) return []
|
||||
|
||||
const { channels = [] } = parser.parse(data)
|
||||
|
||||
const seen = new Set()
|
||||
return channels
|
||||
.filter(ch => {
|
||||
if (seen.has(ch.id)) return false
|
||||
seen.add(ch.id)
|
||||
return true
|
||||
})
|
||||
.map(channel => ({
|
||||
lang: 'zh',
|
||||
site_id: channel.id,
|
||||
name: channel.displayName?.[0]?.value || ''
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
function parseItems(content, channel, date) {
|
||||
const { programs } = parser.parse(content)
|
||||
|
||||
return programs.filter(p => p.channel === channel.site_id && date.isSame(p.start, 'day'))
|
||||
}
|
||||
const axios = require('axios')
|
||||
const parser = require('epg-parser')
|
||||
|
||||
module.exports = {
|
||||
site: 'epg.112114.xyz',
|
||||
days: 1,
|
||||
url: 'https://epg.112114.xyz/pp.xml',
|
||||
request: {
|
||||
cache: {
|
||||
ttl: 24 * 60 * 60 * 1000 // 1 day
|
||||
}
|
||||
},
|
||||
parser: function ({ content, channel, date }) {
|
||||
let programs = []
|
||||
const items = parseItems(content, channel, date)
|
||||
items.forEach(item => {
|
||||
programs.push({
|
||||
title: item.title?.[0]?.value,
|
||||
start: item.start,
|
||||
stop: item.stop
|
||||
})
|
||||
})
|
||||
|
||||
return programs
|
||||
},
|
||||
async channels() {
|
||||
const data = await axios
|
||||
.get('https://epg.112114.xyz/pp.xml')
|
||||
.then(r => r.data)
|
||||
.catch(e => {
|
||||
console.log(e)
|
||||
return null
|
||||
})
|
||||
if (!data) return []
|
||||
|
||||
const { channels = [] } = parser.parse(data)
|
||||
|
||||
const seen = new Set()
|
||||
return channels
|
||||
.filter(ch => {
|
||||
if (seen.has(ch.id)) return false
|
||||
seen.add(ch.id)
|
||||
return true
|
||||
})
|
||||
.map(channel => ({
|
||||
lang: 'zh',
|
||||
site_id: channel.id,
|
||||
name: channel.displayName?.[0]?.value || ''
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
function parseItems(content, channel, date) {
|
||||
const { programs } = parser.parse(content)
|
||||
|
||||
return programs.filter(p => p.channel === channel.site_id && date.isSame(p.start, 'day'))
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,64 +1,64 @@
|
||||
const axios = require('axios')
|
||||
const iconv = require('iconv-lite')
|
||||
const parser = require('epg-parser')
|
||||
const pako = require('pako')
|
||||
|
||||
let cachedContent
|
||||
|
||||
module.exports = {
|
||||
site: 'epg.iptvx.one',
|
||||
days: 2,
|
||||
url: 'https://iptvx.one/epg/epg_noarch.xml.gz',
|
||||
request: {
|
||||
maxContentLength: 500000000, // 500 MB
|
||||
cache: {
|
||||
ttl: 24 * 60 * 60 * 1000 // 1 day
|
||||
}
|
||||
},
|
||||
parser: function ({ buffer, channel, date, cached }) {
|
||||
if (!cached) cachedContent = undefined
|
||||
|
||||
let programs = []
|
||||
const items = parseItems(buffer, channel, date)
|
||||
items.forEach(item => {
|
||||
programs.push({
|
||||
title: item.title?.[0]?.value,
|
||||
description: item.desc?.[0]?.value,
|
||||
start: item.start,
|
||||
stop: item.stop
|
||||
})
|
||||
})
|
||||
|
||||
return programs
|
||||
},
|
||||
async channels() {
|
||||
const data = await axios
|
||||
.get('https://epg.iptvx.one/api/channels.json')
|
||||
.then(r => r.data)
|
||||
.catch(console.log)
|
||||
|
||||
return data.channels.map(channel => {
|
||||
const [name] = channel.chan_names.split(' • ')
|
||||
|
||||
return {
|
||||
lang: 'ru',
|
||||
site_id: channel.chan_id,
|
||||
name
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function parseItems(buffer, channel, date) {
|
||||
if (!buffer) return []
|
||||
|
||||
if (!cachedContent) {
|
||||
const content = pako.ungzip(buffer)
|
||||
const encoded = iconv.decode(content, 'utf8')
|
||||
cachedContent = parser.parse(encoded)
|
||||
}
|
||||
|
||||
const { programs } = cachedContent
|
||||
|
||||
return programs.filter(p => p.channel === channel.site_id && date.isSame(p.start, 'day'))
|
||||
}
|
||||
const axios = require('axios')
|
||||
const iconv = require('iconv-lite')
|
||||
const parser = require('epg-parser')
|
||||
const pako = require('pako')
|
||||
|
||||
let cachedContent
|
||||
|
||||
module.exports = {
|
||||
site: 'epg.iptvx.one',
|
||||
days: 2,
|
||||
url: 'https://iptvx.one/epg/epg_noarch.xml.gz',
|
||||
request: {
|
||||
maxContentLength: 500000000, // 500 MB
|
||||
cache: {
|
||||
ttl: 24 * 60 * 60 * 1000 // 1 day
|
||||
}
|
||||
},
|
||||
parser: function ({ buffer, channel, date, cached }) {
|
||||
if (!cached) cachedContent = undefined
|
||||
|
||||
let programs = []
|
||||
const items = parseItems(buffer, channel, date)
|
||||
items.forEach(item => {
|
||||
programs.push({
|
||||
title: item.title?.[0]?.value,
|
||||
description: item.desc?.[0]?.value,
|
||||
start: item.start,
|
||||
stop: item.stop
|
||||
})
|
||||
})
|
||||
|
||||
return programs
|
||||
},
|
||||
async channels() {
|
||||
const data = await axios
|
||||
.get('https://epg.iptvx.one/api/channels.json')
|
||||
.then(r => r.data)
|
||||
.catch(console.log)
|
||||
|
||||
return data.channels.map(channel => {
|
||||
const [name] = channel.chan_names.split(' • ')
|
||||
|
||||
return {
|
||||
lang: 'ru',
|
||||
site_id: channel.chan_id,
|
||||
name
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function parseItems(buffer, channel, date) {
|
||||
if (!buffer) return []
|
||||
|
||||
if (!cachedContent) {
|
||||
const content = pako.ungzip(buffer)
|
||||
const encoded = iconv.decode(content, 'utf8')
|
||||
cachedContent = parser.parse(encoded)
|
||||
}
|
||||
|
||||
const { programs } = cachedContent
|
||||
|
||||
return programs.filter(p => p.channel === channel.site_id && date.isSame(p.start, 'day'))
|
||||
}
|
||||
|
||||
@@ -1,46 +1,46 @@
|
||||
const { parser, url } = require('./epg.iptvx.one.config.js')
|
||||
const dayjs = require('dayjs')
|
||||
const utc = require('dayjs/plugin/utc')
|
||||
const timezone = require('dayjs/plugin/timezone')
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
|
||||
dayjs.extend(utc)
|
||||
dayjs.extend(timezone)
|
||||
|
||||
const date = dayjs.utc('2025-09-24', 'YYYY-MM-DD').startOf('d')
|
||||
const channel = { site_id: '12-omsk', xmltv_id: 'Channel12.ru' }
|
||||
|
||||
it('can generate valid url', () => {
|
||||
expect(url).toBe('https://iptvx.one/epg/epg_noarch.xml.gz')
|
||||
})
|
||||
|
||||
it('can parse response', () => {
|
||||
const buffer = fs.readFileSync(path.resolve(__dirname, '__data__/content.xml.gz'))
|
||||
const results = parser({ date, buffer, channel })
|
||||
|
||||
expect(results.length).toBe(33)
|
||||
expect(results[0]).toMatchObject({
|
||||
start: '2025-09-24T00:00:00.000Z',
|
||||
stop: '2025-09-24T00:25:00.000Z',
|
||||
title: 'Час новостей',
|
||||
description:
|
||||
'Каждый день наша программа рассказывает вам о самых горячих событиях. Наше преимущество – оперативность: мы всегда там, где происходит что-то важное. Наш девиз – объективность: у нас нет запретных тем и героев вне критики. Наша цель – быть интересными каждому из вас. Мы живем рядом с вами, нас волнуют общие проблемы, каждую – мы обсуждаем, как свою'
|
||||
})
|
||||
expect(results[32]).toMatchObject({
|
||||
start: '2025-09-24T22:35:00.000Z',
|
||||
stop: '2025-09-25T00:00:00.000Z',
|
||||
title: 'д/с Необыкновенные люди',
|
||||
description:
|
||||
'В этом документальном цикле герои – врачи, спортсмены, волонтеры, творческие личности и многие другие – делятся своими историями. Их работа и деятельность имеют важное значение для жизни особенных людей, которые сталкиваются с непростыми жизненными условиями. Россия'
|
||||
})
|
||||
})
|
||||
|
||||
it('can handle empty guide', () => {
|
||||
const result = parser({
|
||||
date,
|
||||
channel,
|
||||
buffer: ''
|
||||
})
|
||||
expect(result).toMatchObject([])
|
||||
})
|
||||
const { parser, url } = require('./epg.iptvx.one.config.js')
|
||||
const dayjs = require('dayjs')
|
||||
const utc = require('dayjs/plugin/utc')
|
||||
const timezone = require('dayjs/plugin/timezone')
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
|
||||
dayjs.extend(utc)
|
||||
dayjs.extend(timezone)
|
||||
|
||||
const date = dayjs.utc('2025-09-24', 'YYYY-MM-DD').startOf('d')
|
||||
const channel = { site_id: '12-omsk', xmltv_id: 'Channel12.ru' }
|
||||
|
||||
it('can generate valid url', () => {
|
||||
expect(url).toBe('https://iptvx.one/epg/epg_noarch.xml.gz')
|
||||
})
|
||||
|
||||
it('can parse response', () => {
|
||||
const buffer = fs.readFileSync(path.resolve(__dirname, '__data__/content.xml.gz'))
|
||||
const results = parser({ date, buffer, channel })
|
||||
|
||||
expect(results.length).toBe(33)
|
||||
expect(results[0]).toMatchObject({
|
||||
start: '2025-09-24T00:00:00.000Z',
|
||||
stop: '2025-09-24T00:25:00.000Z',
|
||||
title: 'Час новостей',
|
||||
description:
|
||||
'Каждый день наша программа рассказывает вам о самых горячих событиях. Наше преимущество – оперативность: мы всегда там, где происходит что-то важное. Наш девиз – объективность: у нас нет запретных тем и героев вне критики. Наша цель – быть интересными каждому из вас. Мы живем рядом с вами, нас волнуют общие проблемы, каждую – мы обсуждаем, как свою'
|
||||
})
|
||||
expect(results[32]).toMatchObject({
|
||||
start: '2025-09-24T22:35:00.000Z',
|
||||
stop: '2025-09-25T00:00:00.000Z',
|
||||
title: 'д/с Необыкновенные люди',
|
||||
description:
|
||||
'В этом документальном цикле герои – врачи, спортсмены, волонтеры, творческие личности и многие другие – делятся своими историями. Их работа и деятельность имеют важное значение для жизни особенных людей, которые сталкиваются с непростыми жизненными условиями. Россия'
|
||||
})
|
||||
})
|
||||
|
||||
it('can handle empty guide', () => {
|
||||
const result = parser({
|
||||
date,
|
||||
channel,
|
||||
buffer: ''
|
||||
})
|
||||
expect(result).toMatchObject([])
|
||||
})
|
||||
|
||||
@@ -1,125 +1,127 @@
|
||||
const dayjs = require('dayjs')
|
||||
const axios = require('axios')
|
||||
|
||||
const BASIC_TOKEN =
|
||||
'MjdlMTFmNWUtODhlMi00OGU0LWJkNDItOGUxNWFiYmM2NmY1OjEyejJzMXJ3bXdhZmsxMGNkdzl0cjloOWFjYjZwdjJoZDhscXZ0aGc='
|
||||
|
||||
let session
|
||||
|
||||
module.exports = {
|
||||
site: 'epg.telemach.ba',
|
||||
days: 3,
|
||||
url({ channel, date, country }) {
|
||||
const communityId = country === 'ba' ? 12 : country === 'me' ? 5 : 12
|
||||
const languageId = country === 'ba' ? 59 : country === 'me' ? 10001 : 59
|
||||
|
||||
return `https://api-web.ug-be.cdn.united.cloud/v1/public/events/epg?fromTime=${date.format(
|
||||
'YYYY-MM-DDTHH:mm:ss-00:00'
|
||||
)}&toTime=${date
|
||||
.add(1, 'days')
|
||||
.subtract(1, 's')
|
||||
.format('YYYY-MM-DDTHH:mm:ss-00:00')}&communityId=${communityId}&languageId=${languageId}&cid=${channel.site_id}`
|
||||
},
|
||||
request: {
|
||||
async headers({ country } = {}) {
|
||||
if (!session) {
|
||||
session = await loadSessionDetails()
|
||||
if (!session || !session.access_token) return null
|
||||
}
|
||||
|
||||
const referer = country === 'me' ? 'https://epg.telemach.me/' : 'https://epg.telemach.ba/'
|
||||
|
||||
return {
|
||||
Authorization: `Bearer ${session.access_token}`,
|
||||
Referer: referer
|
||||
}
|
||||
}
|
||||
},
|
||||
parser({ content }) {
|
||||
try {
|
||||
const programs = []
|
||||
const data = JSON.parse(content)
|
||||
for (const channelId in data) {
|
||||
if (Array.isArray(data[channelId])) {
|
||||
data[channelId].forEach(item => {
|
||||
programs.push({
|
||||
title: item.title,
|
||||
description: item.shortDescription,
|
||||
image: parseImage(item),
|
||||
season: item.seasonNumber,
|
||||
episode: item.episodeNumber,
|
||||
start: dayjs(item.startTime),
|
||||
stop: dayjs(item.endTime)
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
return programs
|
||||
} catch {
|
||||
return []
|
||||
}
|
||||
},
|
||||
async channels({ country }) {
|
||||
const communityID = country === 'ba' ? 12 : country === 'me' ? 5 : 12
|
||||
const languageID = country === 'ba' ? 59 : country === 'me' ? 10001 : 59
|
||||
const lang = country === 'ba' ? 'hr' : country === 'me' ? 'bs' : ''
|
||||
|
||||
const tokenSession = await loadSessionDetails()
|
||||
if (!tokenSession || !tokenSession.access_token) return null
|
||||
|
||||
const data = await axios
|
||||
.get(
|
||||
`https://api-web.ug-be.cdn.united.cloud/v1/public/channels?channelType=TV&communityId=${communityID}&languageId=${languageID}&imageSize=L`,
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokenSession.access_token}`
|
||||
}
|
||||
}
|
||||
)
|
||||
.then(r => r.data)
|
||||
.catch(err => {
|
||||
console.error(err)
|
||||
return null
|
||||
})
|
||||
|
||||
if (!Array.isArray(data)) return []
|
||||
|
||||
return data
|
||||
.map(item => ({
|
||||
lang,
|
||||
site_id: item.id,
|
||||
name: item.name
|
||||
}))
|
||||
.sort((a, b) => {
|
||||
const ai = Number(a.site_id)
|
||||
const bi = Number(b.site_id)
|
||||
if (!Number.isFinite(ai) || !Number.isFinite(bi)) return String(a.site_id).localeCompare(String(b.site_id))
|
||||
return ai - bi
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function parseImage(item) {
|
||||
const baseURL = 'https://images-web.ug-be.cdn.united.cloud'
|
||||
|
||||
return Array.isArray(item?.images) && item.images[0] ? `${baseURL}${item.images[0].path}` : null
|
||||
}
|
||||
|
||||
async function loadSessionDetails() {
|
||||
try {
|
||||
const r = await axios
|
||||
.post(
|
||||
'https://api-web.ug-be.cdn.united.cloud/oauth/token?grant_type=client_credentials',
|
||||
{},
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Basic ${BASIC_TOKEN}`
|
||||
}
|
||||
}
|
||||
)
|
||||
return r.data
|
||||
} catch (message) {
|
||||
return console.log(message)
|
||||
}
|
||||
}
|
||||
const dayjs = require('dayjs')
|
||||
const axios = require('axios')
|
||||
|
||||
const BASIC_TOKEN =
|
||||
'MjdlMTFmNWUtODhlMi00OGU0LWJkNDItOGUxNWFiYmM2NmY1OjEyejJzMXJ3bXdhZmsxMGNkdzl0cjloOWFjYjZwdjJoZDhscXZ0aGc='
|
||||
|
||||
let session
|
||||
|
||||
module.exports = {
|
||||
site: 'epg.telemach.ba',
|
||||
days: 3,
|
||||
url({ channel, date, country }) {
|
||||
const communityId = country === 'ba' ? 12 : country === 'me' ? 5 : 12
|
||||
const languageId = country === 'ba' ? 59 : country === 'me' ? 10001 : 59
|
||||
|
||||
return `https://api-web.ug-be.cdn.united.cloud/v1/public/events/epg?fromTime=${date.format(
|
||||
'YYYY-MM-DDTHH:mm:ss-00:00'
|
||||
)}&toTime=${date
|
||||
.add(1, 'days')
|
||||
.subtract(1, 's')
|
||||
.format(
|
||||
'YYYY-MM-DDTHH:mm:ss-00:00'
|
||||
)}&communityId=${communityId}&languageId=${languageId}&cid=${channel.site_id}`
|
||||
},
|
||||
request: {
|
||||
async headers({ country } = {}) {
|
||||
if (!session) {
|
||||
session = await loadSessionDetails()
|
||||
if (!session || !session.access_token) return null
|
||||
}
|
||||
|
||||
const referer = country === 'me' ? 'https://epg.telemach.me/' : 'https://epg.telemach.ba/'
|
||||
|
||||
return {
|
||||
Authorization: `Bearer ${session.access_token}`,
|
||||
Referer: referer
|
||||
}
|
||||
}
|
||||
},
|
||||
parser({ content }) {
|
||||
try {
|
||||
const programs = []
|
||||
const data = JSON.parse(content)
|
||||
for (const channelId in data) {
|
||||
if (Array.isArray(data[channelId])) {
|
||||
data[channelId].forEach(item => {
|
||||
programs.push({
|
||||
title: item.title,
|
||||
description: item.shortDescription,
|
||||
image: parseImage(item),
|
||||
season: item.seasonNumber,
|
||||
episode: item.episodeNumber,
|
||||
start: dayjs(item.startTime),
|
||||
stop: dayjs(item.endTime)
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
return programs
|
||||
} catch {
|
||||
return []
|
||||
}
|
||||
},
|
||||
async channels({ country }) {
|
||||
const communityID = country === 'ba' ? 12 : country === 'me' ? 5 : 12
|
||||
const languageID = country === 'ba' ? 59 : country === 'me' ? 10001 : 59
|
||||
const lang = country === 'ba' ? 'hr' : country === 'me' ? 'bs' : ''
|
||||
|
||||
const tokenSession = await loadSessionDetails()
|
||||
if (!tokenSession || !tokenSession.access_token) return null
|
||||
|
||||
const data = await axios
|
||||
.get(
|
||||
`https://api-web.ug-be.cdn.united.cloud/v1/public/channels?channelType=TV&communityId=${communityID}&languageId=${languageID}&imageSize=L`,
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokenSession.access_token}`
|
||||
}
|
||||
}
|
||||
)
|
||||
.then(r => r.data)
|
||||
.catch(err => {
|
||||
console.error(err)
|
||||
return null
|
||||
})
|
||||
|
||||
if (!Array.isArray(data)) return []
|
||||
|
||||
return data
|
||||
.map(item => ({
|
||||
lang,
|
||||
site_id: item.id,
|
||||
name: item.name
|
||||
}))
|
||||
.sort((a, b) => {
|
||||
const ai = Number(a.site_id)
|
||||
const bi = Number(b.site_id)
|
||||
if (!Number.isFinite(ai) || !Number.isFinite(bi))
|
||||
return String(a.site_id).localeCompare(String(b.site_id))
|
||||
return ai - bi
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function parseImage(item) {
|
||||
const baseURL = 'https://images-web.ug-be.cdn.united.cloud'
|
||||
|
||||
return Array.isArray(item?.images) && item.images[0] ? `${baseURL}${item.images[0].path}` : null
|
||||
}
|
||||
|
||||
async function loadSessionDetails() {
|
||||
try {
|
||||
const r = await axios.post(
|
||||
'https://api-web.ug-be.cdn.united.cloud/oauth/token?grant_type=client_credentials',
|
||||
{},
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Basic ${BASIC_TOKEN}`
|
||||
}
|
||||
}
|
||||
)
|
||||
return r.data
|
||||
} catch (message) {
|
||||
return console.log(message)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,94 +1,94 @@
|
||||
const { parser, url, request } = require('./epg.telemach.ba.config.js')
|
||||
const fs = require('fs')
|
||||
const axios = require('axios')
|
||||
const path = require('path')
|
||||
const dayjs = require('dayjs')
|
||||
const utc = require('dayjs/plugin/utc')
|
||||
const customParseFormat = require('dayjs/plugin/customParseFormat')
|
||||
dayjs.extend(customParseFormat)
|
||||
dayjs.extend(utc)
|
||||
|
||||
jest.mock('axios')
|
||||
|
||||
axios.post.mockImplementation((url, data, opts) => {
|
||||
if (
|
||||
url === 'https://api-web.ug-be.cdn.united.cloud/oauth/token?grant_type=client_credentials' &&
|
||||
JSON.stringify(opts.headers) ===
|
||||
JSON.stringify({
|
||||
Authorization:
|
||||
'Basic MjdlMTFmNWUtODhlMi00OGU0LWJkNDItOGUxNWFiYmM2NmY1OjEyejJzMXJ3bXdhZmsxMGNkdzl0cjloOWFjYjZwdjJoZDhscXZ0aGc='
|
||||
})
|
||||
) {
|
||||
return Promise.resolve({
|
||||
data: JSON.parse(fs.readFileSync(path.resolve(__dirname, '__data__/session.json')))
|
||||
})
|
||||
} else {
|
||||
return Promise.resolve({
|
||||
data: JSON.parse(fs.readFileSync(path.resolve(__dirname, '__data__/no_session.json')))
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
const date = dayjs.utc('2025-01-20', 'YYYY-MM-DD').startOf('d')
|
||||
const channel = {
|
||||
site_id: '1607',
|
||||
xmltv_id: 'N1HD.hr'
|
||||
}
|
||||
|
||||
it('can generate valid url', async () => {
|
||||
const result = url({ date, channel, country : 'ba' })
|
||||
|
||||
expect(result).toBe(
|
||||
'https://api-web.ug-be.cdn.united.cloud/v1/public/events/epg?fromTime=2025-01-20T00:00:00-00:00&toTime=2025-01-20T23:59:59-00:00&communityId=12&languageId=59&cid=1607'
|
||||
)
|
||||
})
|
||||
|
||||
it('can generate valid request headers', async () => {
|
||||
const result = await request.headers()
|
||||
|
||||
expect(result).toMatchObject({
|
||||
Authorization:
|
||||
'Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOlsidWMtaW5mby1zZXJ2aWNlIl0sInNjb3BlIjpbInJlYWQiXSwiZXhwIjoxNzM3Mzc3NDUxLCJhdXRob3JpdGllcyI6WyJST0xFX1BVQkxJQ19FUEciXSwianRpIjoiUVBubHdRSDczS1EwSnU0WDZwRTc2Zm5mUmRnIiwiY2xpZW50X2lkIjoiMjdlMTFmNWUtODhlMi00OGU0LWJkNDItOGUxNWFiYmM2NmY1In0.LqJAZUWEqIOcLrRSMpxZxnF-f1arKbHgfweLMXt-MBjCDbVJD39OQEsh_b68mtePAoa3n8LRbf3IFT40Ys5Vbe-k_Btm4a9gdEGr6cNi_4HGk4Bto6RUDvCp59VRfoRZhWe145Q2b5TS6szmC4Ws2YWIcZU5vrJcYs2GZiCk6U11MOcd1i52WmZj8cLPq0ZPDB_bzmTgYkvkVa7zOzUOPSl4M8T6fPUa__vVKUt0jOgtFoHeue2mQVgISC2puEGsBN0jJwvJ8PzM6IVxXrQno3MBv0VJy_qILiFPcxRePGRAmKLuEqagvikO7P_XQgFjZgg-j8u8wX2WwO0Yxft0Pg'
|
||||
})
|
||||
})
|
||||
|
||||
it('can parse response', () => {
|
||||
const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.json'), 'utf8')
|
||||
let results = parser({ content })
|
||||
results = results.map(p => {
|
||||
p.start = p.start.toJSON()
|
||||
p.stop = p.stop.toJSON()
|
||||
return p
|
||||
})
|
||||
|
||||
expect(results.length).toBe(35)
|
||||
expect(results[0]).toMatchObject({
|
||||
start: '2025-01-20T00:00:00.000Z',
|
||||
stop: '2025-01-20T00:30:00.000Z',
|
||||
title: 'DW Euromaxx',
|
||||
description:
|
||||
'Euromaxx je lifestyle Europe magazine, koji nam donosi zanimljivosti iz evropskih gradova, priče o načinu života ljudi i upoznaje nas sa njihovim kulturama.',
|
||||
image:
|
||||
'https://images-web.ug-be.cdn.united.cloud/2021/02/18/06/05/21/stb_xl_cd4f72e01d308ecce782e29b69af7de6707b9e85.jpg',
|
||||
season: null,
|
||||
episode: null
|
||||
})
|
||||
expect(results[34]).toMatchObject({
|
||||
start: '2025-01-20T23:50:00.000Z',
|
||||
stop: '2025-01-21T00:00:00.000Z',
|
||||
title: 'DW Shift',
|
||||
description: 'Tjedni magazin koji nam donosi najnovije vijesti vezane za Internet.',
|
||||
image:
|
||||
'https://images-web.ug-be.cdn.united.cloud/2023/06/09/13/07/53/stb_xl_0849d5d70c1337651b85b6335e340e15bd5d6a73_340fc454bc73019d052cf936ebee5da3.jpg',
|
||||
season: null,
|
||||
episode: null
|
||||
})
|
||||
})
|
||||
|
||||
it('can handle empty guide', () => {
|
||||
const results = parser({
|
||||
content: fs.readFileSync(path.resolve(__dirname, '__data__/no_content.json'), 'utf8')
|
||||
})
|
||||
|
||||
expect(results).toMatchObject([])
|
||||
})
|
||||
const { parser, url, request } = require('./epg.telemach.ba.config.js')
|
||||
const fs = require('fs')
|
||||
const axios = require('axios')
|
||||
const path = require('path')
|
||||
const dayjs = require('dayjs')
|
||||
const utc = require('dayjs/plugin/utc')
|
||||
const customParseFormat = require('dayjs/plugin/customParseFormat')
|
||||
dayjs.extend(customParseFormat)
|
||||
dayjs.extend(utc)
|
||||
|
||||
jest.mock('axios')
|
||||
|
||||
axios.post.mockImplementation((url, data, opts) => {
|
||||
if (
|
||||
url === 'https://api-web.ug-be.cdn.united.cloud/oauth/token?grant_type=client_credentials' &&
|
||||
JSON.stringify(opts.headers) ===
|
||||
JSON.stringify({
|
||||
Authorization:
|
||||
'Basic MjdlMTFmNWUtODhlMi00OGU0LWJkNDItOGUxNWFiYmM2NmY1OjEyejJzMXJ3bXdhZmsxMGNkdzl0cjloOWFjYjZwdjJoZDhscXZ0aGc='
|
||||
})
|
||||
) {
|
||||
return Promise.resolve({
|
||||
data: JSON.parse(fs.readFileSync(path.resolve(__dirname, '__data__/session.json')))
|
||||
})
|
||||
} else {
|
||||
return Promise.resolve({
|
||||
data: JSON.parse(fs.readFileSync(path.resolve(__dirname, '__data__/no_session.json')))
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
const date = dayjs.utc('2025-01-20', 'YYYY-MM-DD').startOf('d')
|
||||
const channel = {
|
||||
site_id: '1607',
|
||||
xmltv_id: 'N1HD.hr'
|
||||
}
|
||||
|
||||
it('can generate valid url', async () => {
|
||||
const result = url({ date, channel, country: 'ba' })
|
||||
|
||||
expect(result).toBe(
|
||||
'https://api-web.ug-be.cdn.united.cloud/v1/public/events/epg?fromTime=2025-01-20T00:00:00-00:00&toTime=2025-01-20T23:59:59-00:00&communityId=12&languageId=59&cid=1607'
|
||||
)
|
||||
})
|
||||
|
||||
it('can generate valid request headers', async () => {
|
||||
const result = await request.headers()
|
||||
|
||||
expect(result).toMatchObject({
|
||||
Authorization:
|
||||
'Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOlsidWMtaW5mby1zZXJ2aWNlIl0sInNjb3BlIjpbInJlYWQiXSwiZXhwIjoxNzM3Mzc3NDUxLCJhdXRob3JpdGllcyI6WyJST0xFX1BVQkxJQ19FUEciXSwianRpIjoiUVBubHdRSDczS1EwSnU0WDZwRTc2Zm5mUmRnIiwiY2xpZW50X2lkIjoiMjdlMTFmNWUtODhlMi00OGU0LWJkNDItOGUxNWFiYmM2NmY1In0.LqJAZUWEqIOcLrRSMpxZxnF-f1arKbHgfweLMXt-MBjCDbVJD39OQEsh_b68mtePAoa3n8LRbf3IFT40Ys5Vbe-k_Btm4a9gdEGr6cNi_4HGk4Bto6RUDvCp59VRfoRZhWe145Q2b5TS6szmC4Ws2YWIcZU5vrJcYs2GZiCk6U11MOcd1i52WmZj8cLPq0ZPDB_bzmTgYkvkVa7zOzUOPSl4M8T6fPUa__vVKUt0jOgtFoHeue2mQVgISC2puEGsBN0jJwvJ8PzM6IVxXrQno3MBv0VJy_qILiFPcxRePGRAmKLuEqagvikO7P_XQgFjZgg-j8u8wX2WwO0Yxft0Pg'
|
||||
})
|
||||
})
|
||||
|
||||
it('can parse response', () => {
|
||||
const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.json'), 'utf8')
|
||||
let results = parser({ content })
|
||||
results = results.map(p => {
|
||||
p.start = p.start.toJSON()
|
||||
p.stop = p.stop.toJSON()
|
||||
return p
|
||||
})
|
||||
|
||||
expect(results.length).toBe(35)
|
||||
expect(results[0]).toMatchObject({
|
||||
start: '2025-01-20T00:00:00.000Z',
|
||||
stop: '2025-01-20T00:30:00.000Z',
|
||||
title: 'DW Euromaxx',
|
||||
description:
|
||||
'Euromaxx je lifestyle Europe magazine, koji nam donosi zanimljivosti iz evropskih gradova, priče o načinu života ljudi i upoznaje nas sa njihovim kulturama.',
|
||||
image:
|
||||
'https://images-web.ug-be.cdn.united.cloud/2021/02/18/06/05/21/stb_xl_cd4f72e01d308ecce782e29b69af7de6707b9e85.jpg',
|
||||
season: null,
|
||||
episode: null
|
||||
})
|
||||
expect(results[34]).toMatchObject({
|
||||
start: '2025-01-20T23:50:00.000Z',
|
||||
stop: '2025-01-21T00:00:00.000Z',
|
||||
title: 'DW Shift',
|
||||
description: 'Tjedni magazin koji nam donosi najnovije vijesti vezane za Internet.',
|
||||
image:
|
||||
'https://images-web.ug-be.cdn.united.cloud/2023/06/09/13/07/53/stb_xl_0849d5d70c1337651b85b6335e340e15bd5d6a73_340fc454bc73019d052cf936ebee5da3.jpg',
|
||||
season: null,
|
||||
episode: null
|
||||
})
|
||||
})
|
||||
|
||||
it('can handle empty guide', () => {
|
||||
const results = parser({
|
||||
content: fs.readFileSync(path.resolve(__dirname, '__data__/no_content.json'), 'utf8')
|
||||
})
|
||||
|
||||
expect(results).toMatchObject([])
|
||||
})
|
||||
|
||||
@@ -1,123 +1,123 @@
|
||||
const axios = require('axios')
|
||||
const iconv = require('iconv-lite')
|
||||
const parser = require('epg-parser')
|
||||
const { ungzip } = require('pako')
|
||||
const zlib = require('zlib')
|
||||
const sax = require('sax')
|
||||
|
||||
let cachedContent
|
||||
|
||||
module.exports = {
|
||||
site: 'epgshare01.online',
|
||||
days: 2,
|
||||
url({ channel }) {
|
||||
const [tag] = channel.site_id.split('#')
|
||||
|
||||
return `https://epgshare01.online/epgshare01/epg_ripper_${tag}.xml.gz`
|
||||
},
|
||||
request: {
|
||||
cache: {
|
||||
ttl: 24 * 60 * 60 * 1000 // 1 day
|
||||
},
|
||||
maxContentLength: 100000000 // 100 MB
|
||||
},
|
||||
parser({ buffer, channel, date, cached }) {
|
||||
if (!cached) cachedContent = undefined
|
||||
|
||||
let programs = []
|
||||
const items = parseItems(buffer, channel, date)
|
||||
items.forEach(item => {
|
||||
programs.push({
|
||||
title: item.title?.[0]?.value,
|
||||
description: item.desc?.[0]?.value,
|
||||
start: item.start,
|
||||
stop: item.stop
|
||||
})
|
||||
})
|
||||
|
||||
return programs
|
||||
},
|
||||
async channels({ tag }) {
|
||||
const url = `https://epgshare01.online/epgshare01/epg_ripper_${tag}.xml.gz`
|
||||
try {
|
||||
const res = await axios.get(url, { responseType: 'stream' })
|
||||
|
||||
const parserStream = sax.createStream(true, { trim: true })
|
||||
const channels = []
|
||||
let current = null
|
||||
let curText = ''
|
||||
let curTag = null
|
||||
|
||||
parserStream.on('opentag', node => {
|
||||
const name = node.name.toLowerCase()
|
||||
if (name === 'channel') {
|
||||
current = { id: node.attributes.id || node.attributes.ID, displayName: [] }
|
||||
} else if (current && (name === 'display-name' || name === 'displayname')) {
|
||||
curTag = 'displayName'
|
||||
curText = ''
|
||||
// capture possible lang attribute (xml:lang or lang)
|
||||
current._lang = node.attributes['xml:lang'] || node.attributes['xml:Lang'] || node.attributes.lang
|
||||
}
|
||||
})
|
||||
|
||||
parserStream.on('text', text => {
|
||||
if (curTag === 'displayName') curText += text
|
||||
})
|
||||
|
||||
parserStream.on('cdata', text => {
|
||||
if (curTag === 'displayName') curText += text
|
||||
})
|
||||
|
||||
parserStream.on('closetag', nameRaw => {
|
||||
const name = nameRaw.toLowerCase()
|
||||
if (current && (name === 'display-name' || name === 'displayname')) {
|
||||
current.displayName.push({
|
||||
lang: current._lang || 'en',
|
||||
value: curText.trim()
|
||||
})
|
||||
curTag = null
|
||||
curText = ''
|
||||
current._lang = undefined
|
||||
} else if (name === 'channel' && current) {
|
||||
channels.push({ id: current.id, displayName: current.displayName })
|
||||
current = null
|
||||
}
|
||||
})
|
||||
|
||||
await new Promise((resolve, reject) => {
|
||||
res.data
|
||||
.pipe(zlib.createGunzip())
|
||||
.pipe(parserStream)
|
||||
.on('end', resolve)
|
||||
.on('error', reject)
|
||||
})
|
||||
|
||||
return channels.map(channel => {
|
||||
const displayName = (channel.displayName && channel.displayName[0]) || { lang: 'en', value: channel.id }
|
||||
return {
|
||||
lang: displayName.lang || 'en',
|
||||
site_id: `${tag}#${channel.id}`,
|
||||
name: displayName.value
|
||||
}
|
||||
})
|
||||
} catch (err) {
|
||||
console.error(err)
|
||||
return []
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function parseItems(buffer, channel, date) {
|
||||
if (!buffer) return []
|
||||
|
||||
if (!cachedContent) {
|
||||
const content = ungzip(buffer)
|
||||
const encoded = iconv.decode(content, 'utf8')
|
||||
cachedContent = parser.parse(encoded)
|
||||
}
|
||||
|
||||
const { programs } = cachedContent
|
||||
const [, channelId] = channel.site_id.split('#')
|
||||
|
||||
return programs.filter(p => p.channel === channelId && date.isSame(p.start, 'day'))
|
||||
}
|
||||
const axios = require('axios')
|
||||
const iconv = require('iconv-lite')
|
||||
const parser = require('epg-parser')
|
||||
const { ungzip } = require('pako')
|
||||
const zlib = require('zlib')
|
||||
const sax = require('sax')
|
||||
|
||||
let cachedContent
|
||||
|
||||
module.exports = {
|
||||
site: 'epgshare01.online',
|
||||
days: 2,
|
||||
url({ channel }) {
|
||||
const [tag] = channel.site_id.split('#')
|
||||
|
||||
return `https://epgshare01.online/epgshare01/epg_ripper_${tag}.xml.gz`
|
||||
},
|
||||
request: {
|
||||
cache: {
|
||||
ttl: 24 * 60 * 60 * 1000 // 1 day
|
||||
},
|
||||
maxContentLength: 100000000 // 100 MB
|
||||
},
|
||||
parser({ buffer, channel, date, cached }) {
|
||||
if (!cached) cachedContent = undefined
|
||||
|
||||
let programs = []
|
||||
const items = parseItems(buffer, channel, date)
|
||||
items.forEach(item => {
|
||||
programs.push({
|
||||
title: item.title?.[0]?.value,
|
||||
description: item.desc?.[0]?.value,
|
||||
start: item.start,
|
||||
stop: item.stop
|
||||
})
|
||||
})
|
||||
|
||||
return programs
|
||||
},
|
||||
async channels({ tag }) {
|
||||
const url = `https://epgshare01.online/epgshare01/epg_ripper_${tag}.xml.gz`
|
||||
try {
|
||||
const res = await axios.get(url, { responseType: 'stream' })
|
||||
|
||||
const parserStream = sax.createStream(true, { trim: true })
|
||||
const channels = []
|
||||
let current = null
|
||||
let curText = ''
|
||||
let curTag = null
|
||||
|
||||
parserStream.on('opentag', node => {
|
||||
const name = node.name.toLowerCase()
|
||||
if (name === 'channel') {
|
||||
current = { id: node.attributes.id || node.attributes.ID, displayName: [] }
|
||||
} else if (current && (name === 'display-name' || name === 'displayname')) {
|
||||
curTag = 'displayName'
|
||||
curText = ''
|
||||
// capture possible lang attribute (xml:lang or lang)
|
||||
current._lang =
|
||||
node.attributes['xml:lang'] || node.attributes['xml:Lang'] || node.attributes.lang
|
||||
}
|
||||
})
|
||||
|
||||
parserStream.on('text', text => {
|
||||
if (curTag === 'displayName') curText += text
|
||||
})
|
||||
|
||||
parserStream.on('cdata', text => {
|
||||
if (curTag === 'displayName') curText += text
|
||||
})
|
||||
|
||||
parserStream.on('closetag', nameRaw => {
|
||||
const name = nameRaw.toLowerCase()
|
||||
if (current && (name === 'display-name' || name === 'displayname')) {
|
||||
current.displayName.push({
|
||||
lang: current._lang || 'en',
|
||||
value: curText.trim()
|
||||
})
|
||||
curTag = null
|
||||
curText = ''
|
||||
current._lang = undefined
|
||||
} else if (name === 'channel' && current) {
|
||||
channels.push({ id: current.id, displayName: current.displayName })
|
||||
current = null
|
||||
}
|
||||
})
|
||||
|
||||
await new Promise((resolve, reject) => {
|
||||
res.data.pipe(zlib.createGunzip()).pipe(parserStream).on('end', resolve).on('error', reject)
|
||||
})
|
||||
|
||||
return channels.map(channel => {
|
||||
const displayName = (channel.displayName && channel.displayName[0]) || {
|
||||
lang: 'en',
|
||||
value: channel.id
|
||||
}
|
||||
return {
|
||||
lang: displayName.lang || 'en',
|
||||
site_id: `${tag}#${channel.id}`,
|
||||
name: displayName.value
|
||||
}
|
||||
})
|
||||
} catch (err) {
|
||||
console.error(err)
|
||||
return []
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function parseItems(buffer, channel, date) {
|
||||
if (!buffer) return []
|
||||
|
||||
if (!cachedContent) {
|
||||
const content = ungzip(buffer)
|
||||
const encoded = iconv.decode(content, 'utf8')
|
||||
cachedContent = parser.parse(encoded)
|
||||
}
|
||||
|
||||
const { programs } = cachedContent
|
||||
const [, channelId] = channel.site_id.split('#')
|
||||
|
||||
return programs.filter(p => p.channel === channelId && date.isSame(p.start, 'day'))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user