mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-09 16:40:07 -04:00
Fixes linter errors
This commit is contained in:
parent
57e508fc3b
commit
63c86a2b30
393 changed files with 28447 additions and 28443 deletions
|
@ -1,57 +1,57 @@
|
|||
const dayjs = require('dayjs')
|
||||
const axios = require('axios')
|
||||
|
||||
module.exports = {
|
||||
site: 'tv.movistar.com.pe',
|
||||
days: 2,
|
||||
url({ channel, date }) {
|
||||
return `https://contentapi-pe.cdn.telefonica.com/28/default/es-PE/schedules?fields=Pid,Title,Description,ChannelName,LiveChannelPid,Start,End,images.videoFrame,AgeRatingPid&orderBy=START_TIME%3Aa&filteravailability=false&starttime=${date.unix()}&endtime=${date
|
||||
.add(1, 'd')
|
||||
.unix()}&livechannelpids=${channel.site_id}`
|
||||
},
|
||||
parser({ content, channel }) {
|
||||
let programs = []
|
||||
const items = parseItems(content, channel)
|
||||
items.forEach(item => {
|
||||
programs.push({
|
||||
title: item.Title,
|
||||
description: item.Description,
|
||||
icon: parseIcon(item),
|
||||
start: parseTime(item.Start),
|
||||
stop: parseTime(item.End)
|
||||
})
|
||||
})
|
||||
|
||||
return programs
|
||||
},
|
||||
async channels() {
|
||||
const items = await axios
|
||||
.get(
|
||||
'https://contentapi-pe.cdn.telefonica.com/28/default/es-PE/contents/all?contentTypes=LCH&fields=Pid,Name&orderBy=contentOrder&limit=1000'
|
||||
)
|
||||
.then(r => r.data.Content.List)
|
||||
.catch(console.error)
|
||||
|
||||
return items.map(i => {
|
||||
return {
|
||||
lang: 'es',
|
||||
name: i.Name,
|
||||
site_id: i.Pid.toLowerCase()
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function parseIcon(item) {
|
||||
return item.Images?.VideoFrame?.[0]?.Url
|
||||
}
|
||||
|
||||
function parseTime(timestamp) {
|
||||
return dayjs.unix(timestamp)
|
||||
}
|
||||
|
||||
function parseItems(content) {
|
||||
const data = JSON.parse(content)
|
||||
|
||||
return data.Content || []
|
||||
}
|
||||
const dayjs = require('dayjs')
|
||||
const axios = require('axios')
|
||||
|
||||
module.exports = {
|
||||
site: 'tv.movistar.com.pe',
|
||||
days: 2,
|
||||
url({ channel, date }) {
|
||||
return `https://contentapi-pe.cdn.telefonica.com/28/default/es-PE/schedules?fields=Pid,Title,Description,ChannelName,LiveChannelPid,Start,End,images.videoFrame,AgeRatingPid&orderBy=START_TIME%3Aa&filteravailability=false&starttime=${date.unix()}&endtime=${date
|
||||
.add(1, 'd')
|
||||
.unix()}&livechannelpids=${channel.site_id}`
|
||||
},
|
||||
parser({ content, channel }) {
|
||||
let programs = []
|
||||
const items = parseItems(content, channel)
|
||||
items.forEach(item => {
|
||||
programs.push({
|
||||
title: item.Title,
|
||||
description: item.Description,
|
||||
icon: parseIcon(item),
|
||||
start: parseTime(item.Start),
|
||||
stop: parseTime(item.End)
|
||||
})
|
||||
})
|
||||
|
||||
return programs
|
||||
},
|
||||
async channels() {
|
||||
const items = await axios
|
||||
.get(
|
||||
'https://contentapi-pe.cdn.telefonica.com/28/default/es-PE/contents/all?contentTypes=LCH&fields=Pid,Name&orderBy=contentOrder&limit=1000'
|
||||
)
|
||||
.then(r => r.data.Content.List)
|
||||
.catch(console.error)
|
||||
|
||||
return items.map(i => {
|
||||
return {
|
||||
lang: 'es',
|
||||
name: i.Name,
|
||||
site_id: i.Pid.toLowerCase()
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function parseIcon(item) {
|
||||
return item.Images?.VideoFrame?.[0]?.Url
|
||||
}
|
||||
|
||||
function parseTime(timestamp) {
|
||||
return dayjs.unix(timestamp)
|
||||
}
|
||||
|
||||
function parseItems(content) {
|
||||
const data = JSON.parse(content)
|
||||
|
||||
return data.Content || []
|
||||
}
|
||||
|
|
|
@ -1,47 +1,47 @@
|
|||
// npm run channels:parse -- --config=./sites/tv.movistar.com.pe/tv.movistar.com.pe.config.js --output=./sites/tv.movistar.com.pe/tv.movistar.com.pe.channels.xml
|
||||
// npm run grab -- --site=tv.movistar.com.pe
|
||||
|
||||
const { parser, url } = require('./tv.movistar.com.pe.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-11-29', 'YYYY-MM-DD').startOf('d')
|
||||
const channel = {
|
||||
site_id: 'lch2219',
|
||||
xmltv_id: 'WillaxTV.pe'
|
||||
}
|
||||
|
||||
it('can generate valid url', () => {
|
||||
expect(url({ channel, date })).toBe(
|
||||
'https://contentapi-pe.cdn.telefonica.com/28/default/es-PE/schedules?fields=Pid,Title,Description,ChannelName,LiveChannelPid,Start,End,images.videoFrame,AgeRatingPid&orderBy=START_TIME%3Aa&filteravailability=false&starttime=1669680000&endtime=1669766400&livechannelpids=lch2219'
|
||||
)
|
||||
})
|
||||
|
||||
it('can parse response', () => {
|
||||
const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.json'))
|
||||
let results = parser({ content, channel, date }).map(p => {
|
||||
p.start = p.start.toJSON()
|
||||
p.stop = p.stop.toJSON()
|
||||
return p
|
||||
})
|
||||
|
||||
expect(results[0]).toMatchObject({
|
||||
start: '2022-11-28T23:50:00.000Z',
|
||||
stop: '2022-11-29T00:50:00.000Z',
|
||||
title: 'Willax noticias edición central',
|
||||
description:
|
||||
'Edición central con el desarrollo y cobertura noticiosa de todos los acontecimientos nacionales e internacionales.',
|
||||
icon: 'http://media.gvp.telefonica.com/storagearea0/IMAGES/00/13/00/13003906_281B2DAB18B01955.jpg'
|
||||
})
|
||||
})
|
||||
|
||||
it('can handle empty guide', () => {
|
||||
const content = fs.readFileSync(path.resolve(__dirname, '__data__/no_content.json'))
|
||||
const result = parser({ content, channel, date })
|
||||
expect(result).toMatchObject([])
|
||||
})
|
||||
// npm run channels:parse -- --config=./sites/tv.movistar.com.pe/tv.movistar.com.pe.config.js --output=./sites/tv.movistar.com.pe/tv.movistar.com.pe.channels.xml
|
||||
// npm run grab -- --site=tv.movistar.com.pe
|
||||
|
||||
const { parser, url } = require('./tv.movistar.com.pe.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-11-29', 'YYYY-MM-DD').startOf('d')
|
||||
const channel = {
|
||||
site_id: 'lch2219',
|
||||
xmltv_id: 'WillaxTV.pe'
|
||||
}
|
||||
|
||||
it('can generate valid url', () => {
|
||||
expect(url({ channel, date })).toBe(
|
||||
'https://contentapi-pe.cdn.telefonica.com/28/default/es-PE/schedules?fields=Pid,Title,Description,ChannelName,LiveChannelPid,Start,End,images.videoFrame,AgeRatingPid&orderBy=START_TIME%3Aa&filteravailability=false&starttime=1669680000&endtime=1669766400&livechannelpids=lch2219'
|
||||
)
|
||||
})
|
||||
|
||||
it('can parse response', () => {
|
||||
const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.json'))
|
||||
let results = parser({ content, channel, date }).map(p => {
|
||||
p.start = p.start.toJSON()
|
||||
p.stop = p.stop.toJSON()
|
||||
return p
|
||||
})
|
||||
|
||||
expect(results[0]).toMatchObject({
|
||||
start: '2022-11-28T23:50:00.000Z',
|
||||
stop: '2022-11-29T00:50:00.000Z',
|
||||
title: 'Willax noticias edición central',
|
||||
description:
|
||||
'Edición central con el desarrollo y cobertura noticiosa de todos los acontecimientos nacionales e internacionales.',
|
||||
icon: 'http://media.gvp.telefonica.com/storagearea0/IMAGES/00/13/00/13003906_281B2DAB18B01955.jpg'
|
||||
})
|
||||
})
|
||||
|
||||
it('can handle empty guide', () => {
|
||||
const content = fs.readFileSync(path.resolve(__dirname, '__data__/no_content.json'))
|
||||
const result = parser({ content, channel, date })
|
||||
expect(result).toMatchObject([])
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue