mirror of
https://github.com/iptv-org/epg
synced 2026-04-30 22:46:58 -04:00
Replace LF endings with CRLF
This commit is contained in:
@@ -1,85 +1,85 @@
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
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 : []
|
||||
}
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
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,76 +1,76 @@
|
||||
const { parser, url, request } = require('./directv.com.uy.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('2022-08-29', 'YYYY-MM-DD').startOf('d')
|
||||
const channel = {
|
||||
site_id: '184#VTV',
|
||||
xmltv_id: 'VTV.uy'
|
||||
}
|
||||
|
||||
it('can generate valid url', () => {
|
||||
expect(url).toBe('https://www.directv.com.uy/guia/ChannelDetail.aspx/GetProgramming')
|
||||
})
|
||||
|
||||
it('can generate valid request method', () => {
|
||||
expect(request.method).toBe('POST')
|
||||
})
|
||||
|
||||
it('can generate valid request headers', () => {
|
||||
expect(request.headers).toMatchObject({
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
Cookie: 'PGCSS=16384; PGLang=S; PGCulture=es-UY;'
|
||||
})
|
||||
})
|
||||
|
||||
it('can generate valid request data', () => {
|
||||
expect(request.data({ channel, date })).toMatchObject({
|
||||
filterParameters: {
|
||||
day: 29,
|
||||
time: 0,
|
||||
minute: 0,
|
||||
month: 8,
|
||||
year: 2022,
|
||||
offSetValue: 0,
|
||||
filtersScreenFilters: [''],
|
||||
isHd: '',
|
||||
isChannelDetails: 'Y',
|
||||
channelNum: '184',
|
||||
channelName: 'VTV'
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
it('can parse response', () => {
|
||||
const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.json'))
|
||||
const results = parser({ content, channel }).map(p => {
|
||||
p.start = p.start.toJSON()
|
||||
p.stop = p.stop.toJSON()
|
||||
return p
|
||||
})
|
||||
|
||||
expect(results[0]).toMatchObject({
|
||||
start: '2022-08-29T03:00:00.000Z',
|
||||
stop: '2022-08-29T05:00:00.000Z',
|
||||
title: 'Peñarol vs. Danubio : Fútbol Uruguayo Primera División - Peñarol vs. Danubio',
|
||||
description:
|
||||
'Jornada 5 del Torneo Clausura 2022. Peñarol recibe a Danubio en el estadio Campeón del Siglo. Los carboneros llevan 3 partidos sin caer (2PG 1PE), mientras que los franjeados acumulan 6 juegos sin derrotas (4PG 2PE).',
|
||||
rating: {
|
||||
system: 'MPA',
|
||||
value: 'NR'
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
it('can handle empty guide', () => {
|
||||
const result = parser({
|
||||
content: '',
|
||||
channel
|
||||
})
|
||||
expect(result).toMatchObject([])
|
||||
})
|
||||
const { parser, url, request } = require('./directv.com.uy.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('2022-08-29', 'YYYY-MM-DD').startOf('d')
|
||||
const channel = {
|
||||
site_id: '184#VTV',
|
||||
xmltv_id: 'VTV.uy'
|
||||
}
|
||||
|
||||
it('can generate valid url', () => {
|
||||
expect(url).toBe('https://www.directv.com.uy/guia/ChannelDetail.aspx/GetProgramming')
|
||||
})
|
||||
|
||||
it('can generate valid request method', () => {
|
||||
expect(request.method).toBe('POST')
|
||||
})
|
||||
|
||||
it('can generate valid request headers', () => {
|
||||
expect(request.headers).toMatchObject({
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
Cookie: 'PGCSS=16384; PGLang=S; PGCulture=es-UY;'
|
||||
})
|
||||
})
|
||||
|
||||
it('can generate valid request data', () => {
|
||||
expect(request.data({ channel, date })).toMatchObject({
|
||||
filterParameters: {
|
||||
day: 29,
|
||||
time: 0,
|
||||
minute: 0,
|
||||
month: 8,
|
||||
year: 2022,
|
||||
offSetValue: 0,
|
||||
filtersScreenFilters: [''],
|
||||
isHd: '',
|
||||
isChannelDetails: 'Y',
|
||||
channelNum: '184',
|
||||
channelName: 'VTV'
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
it('can parse response', () => {
|
||||
const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.json'))
|
||||
const results = parser({ content, channel }).map(p => {
|
||||
p.start = p.start.toJSON()
|
||||
p.stop = p.stop.toJSON()
|
||||
return p
|
||||
})
|
||||
|
||||
expect(results[0]).toMatchObject({
|
||||
start: '2022-08-29T03:00:00.000Z',
|
||||
stop: '2022-08-29T05:00:00.000Z',
|
||||
title: 'Peñarol vs. Danubio : Fútbol Uruguayo Primera División - Peñarol vs. Danubio',
|
||||
description:
|
||||
'Jornada 5 del Torneo Clausura 2022. Peñarol recibe a Danubio en el estadio Campeón del Siglo. Los carboneros llevan 3 partidos sin caer (2PG 1PE), mientras que los franjeados acumulan 6 juegos sin derrotas (4PG 2PE).',
|
||||
rating: {
|
||||
system: 'MPA',
|
||||
value: 'NR'
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
it('can handle empty guide', () => {
|
||||
const result = parser({
|
||||
content: '',
|
||||
channel
|
||||
})
|
||||
expect(result).toMatchObject([])
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user