mirror of
https://github.com/iptv-org/epg
synced 2026-04-29 05:56:58 -04:00
Fixes linter errors
This commit is contained in:
@@ -1,100 +1,100 @@
|
||||
process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = 0
|
||||
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.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"'
|
||||
},
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
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 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"'
|
||||
},
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
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,79 +1,79 @@
|
||||
// npm run grab -- --site=directv.com.ar
|
||||
|
||||
const { parser, url, request } = require('./directv.com.ar.config.js')
|
||||
const dayjs = require('dayjs')
|
||||
const utc = require('dayjs/plugin/utc')
|
||||
const customParseFormat = require('dayjs/plugin/customParseFormat')
|
||||
dayjs.extend(customParseFormat)
|
||||
dayjs.extend(utc)
|
||||
|
||||
const date = dayjs.utc('2022-06-19', 'YYYY-MM-DD').startOf('d')
|
||||
const channel = {
|
||||
site_id: '207#A&EHD',
|
||||
xmltv_id: 'AEHDSouth.us'
|
||||
}
|
||||
|
||||
it('can generate valid url', () => {
|
||||
expect(url).toBe('https://www.directv.com.ar/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=16; PGLang=S; PGCulture=es-AR;'
|
||||
})
|
||||
})
|
||||
|
||||
it('can generate valid request data', () => {
|
||||
expect(request.data({ channel, date })).toMatchObject({
|
||||
filterParameters: {
|
||||
day: 19,
|
||||
time: 0,
|
||||
minute: 0,
|
||||
month: 6,
|
||||
year: 2022,
|
||||
offSetValue: 0,
|
||||
filtersScreenFilters: [''],
|
||||
isHd: '',
|
||||
isChannelDetails: 'Y',
|
||||
channelNum: '207',
|
||||
channelName: 'A&EHD'
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
it('can parse response', () => {
|
||||
const content =
|
||||
'{"d":[{"ChannelSection":"","ChannelFullName":"A&E HD","IsFavorite":false,"ChannelName":"A&EHD","ChannelNumber":207,"ProgramList":[{"_channelSection":"","eventId":"120289890767","titleId":"SH0110397700000001","title":"Chicas guapas","programId":null,"description":"Un espacio destinado a la belleza y los distintos estilos de vida, que muestra el trabajo inspiracional de la moda latinoamericana.","episodeTitle":null,"channelNumber":120,"channelName":"AME2","channelFullName":"América TV (ARG)","channelSection":"","contentChannelID":120,"startTime":"/Date(-62135578800000)/","endTime":"/Date(-62135578800000)/","GMTstartTime":"/Date(-62135578800000)/","GMTendTime":"/Date(-62135578800000)/","css":16,"language":null,"tmsId":"SH0110397700000001","rating":"NR","categoryId":"Tipos de Programas","categoryName":0,"subCategoryId":0,"subCategoryName":"Series","serviceExpiration":"/Date(-62135578800000)/","crId":null,"promoUrl1":null,"promoUrl2":null,"price":0,"isPurchasable":"N","videoUrl":"","imageUrl":"https://dnqt2wx2urq99.cloudfront.net/ondirectv/LOGOS/Canales/AR/120.png","titleSecond":"Chicas guapas","isHD":"N","DetailsURL":null,"BuyURL":null,"ProgramServiceId":null,"SearchDateTime":null,"startTimeString":"6/19/2022 12:00:00 AM","endTimeString":"6/19/2022 12:15:00 AM","DurationInMinutes":null,"castDetails":null,"scheduleDetails":null,"seriesDetails":null,"processedSeasonDetails":null}]}]}'
|
||||
const result = parser({ content, channel }).map(p => {
|
||||
p.start = p.start.toJSON()
|
||||
p.stop = p.stop.toJSON()
|
||||
return p
|
||||
})
|
||||
|
||||
expect(result).toMatchObject([
|
||||
{
|
||||
start: '2022-06-19T03:00:00.000Z',
|
||||
stop: '2022-06-19T03:15:00.000Z',
|
||||
title: 'Chicas guapas',
|
||||
description:
|
||||
'Un espacio destinado a la belleza y los distintos estilos de vida, que muestra el trabajo inspiracional de la moda latinoamericana.',
|
||||
rating: {
|
||||
system: 'MPA',
|
||||
value: 'NR'
|
||||
}
|
||||
}
|
||||
])
|
||||
})
|
||||
|
||||
it('can handle empty guide', () => {
|
||||
const result = parser({
|
||||
content: '',
|
||||
channel
|
||||
})
|
||||
expect(result).toMatchObject([])
|
||||
})
|
||||
// npm run grab -- --site=directv.com.ar
|
||||
|
||||
const { parser, url, request } = require('./directv.com.ar.config.js')
|
||||
const dayjs = require('dayjs')
|
||||
const utc = require('dayjs/plugin/utc')
|
||||
const customParseFormat = require('dayjs/plugin/customParseFormat')
|
||||
dayjs.extend(customParseFormat)
|
||||
dayjs.extend(utc)
|
||||
|
||||
const date = dayjs.utc('2022-06-19', 'YYYY-MM-DD').startOf('d')
|
||||
const channel = {
|
||||
site_id: '207#A&EHD',
|
||||
xmltv_id: 'AEHDSouth.us'
|
||||
}
|
||||
|
||||
it('can generate valid url', () => {
|
||||
expect(url).toBe('https://www.directv.com.ar/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=16; PGLang=S; PGCulture=es-AR;'
|
||||
})
|
||||
})
|
||||
|
||||
it('can generate valid request data', () => {
|
||||
expect(request.data({ channel, date })).toMatchObject({
|
||||
filterParameters: {
|
||||
day: 19,
|
||||
time: 0,
|
||||
minute: 0,
|
||||
month: 6,
|
||||
year: 2022,
|
||||
offSetValue: 0,
|
||||
filtersScreenFilters: [''],
|
||||
isHd: '',
|
||||
isChannelDetails: 'Y',
|
||||
channelNum: '207',
|
||||
channelName: 'A&EHD'
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
it('can parse response', () => {
|
||||
const content =
|
||||
'{"d":[{"ChannelSection":"","ChannelFullName":"A&E HD","IsFavorite":false,"ChannelName":"A&EHD","ChannelNumber":207,"ProgramList":[{"_channelSection":"","eventId":"120289890767","titleId":"SH0110397700000001","title":"Chicas guapas","programId":null,"description":"Un espacio destinado a la belleza y los distintos estilos de vida, que muestra el trabajo inspiracional de la moda latinoamericana.","episodeTitle":null,"channelNumber":120,"channelName":"AME2","channelFullName":"América TV (ARG)","channelSection":"","contentChannelID":120,"startTime":"/Date(-62135578800000)/","endTime":"/Date(-62135578800000)/","GMTstartTime":"/Date(-62135578800000)/","GMTendTime":"/Date(-62135578800000)/","css":16,"language":null,"tmsId":"SH0110397700000001","rating":"NR","categoryId":"Tipos de Programas","categoryName":0,"subCategoryId":0,"subCategoryName":"Series","serviceExpiration":"/Date(-62135578800000)/","crId":null,"promoUrl1":null,"promoUrl2":null,"price":0,"isPurchasable":"N","videoUrl":"","imageUrl":"https://dnqt2wx2urq99.cloudfront.net/ondirectv/LOGOS/Canales/AR/120.png","titleSecond":"Chicas guapas","isHD":"N","DetailsURL":null,"BuyURL":null,"ProgramServiceId":null,"SearchDateTime":null,"startTimeString":"6/19/2022 12:00:00 AM","endTimeString":"6/19/2022 12:15:00 AM","DurationInMinutes":null,"castDetails":null,"scheduleDetails":null,"seriesDetails":null,"processedSeasonDetails":null}]}]}'
|
||||
const result = parser({ content, channel }).map(p => {
|
||||
p.start = p.start.toJSON()
|
||||
p.stop = p.stop.toJSON()
|
||||
return p
|
||||
})
|
||||
|
||||
expect(result).toMatchObject([
|
||||
{
|
||||
start: '2022-06-19T03:00:00.000Z',
|
||||
stop: '2022-06-19T03:15:00.000Z',
|
||||
title: 'Chicas guapas',
|
||||
description:
|
||||
'Un espacio destinado a la belleza y los distintos estilos de vida, que muestra el trabajo inspiracional de la moda latinoamericana.',
|
||||
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