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,40 +1,40 @@
|
|||
const dayjs = require('dayjs')
|
||||
const utc = require('dayjs/plugin/utc')
|
||||
|
||||
dayjs.extend(utc)
|
||||
|
||||
module.exports = {
|
||||
site: 'tvtv.us',
|
||||
request: {
|
||||
delay: 500 // 500 ms
|
||||
},
|
||||
days: 2,
|
||||
url: function ({ date, channel }) {
|
||||
return `https://www.tvtv.us/api/v1/lineup/USA-NY71652-DEFAULT/grid/${date.toJSON()}/${date
|
||||
.add(1, 'd')
|
||||
.toJSON()}/${channel.site_id}`
|
||||
},
|
||||
parser: function ({ content }) {
|
||||
let programs = []
|
||||
|
||||
const items = parseItems(content)
|
||||
items.forEach(item => {
|
||||
const start = dayjs.utc(item.startTime)
|
||||
const stop = start.add(item.runTime, 'm')
|
||||
programs.push({
|
||||
title: item.title,
|
||||
description: item.subtitle,
|
||||
start,
|
||||
stop
|
||||
})
|
||||
})
|
||||
|
||||
return programs
|
||||
}
|
||||
}
|
||||
|
||||
function parseItems(content) {
|
||||
const json = JSON.parse(content)
|
||||
if (!json.length) return []
|
||||
return json[0]
|
||||
}
|
||||
const dayjs = require('dayjs')
|
||||
const utc = require('dayjs/plugin/utc')
|
||||
|
||||
dayjs.extend(utc)
|
||||
|
||||
module.exports = {
|
||||
site: 'tvtv.us',
|
||||
request: {
|
||||
delay: 500 // 500 ms
|
||||
},
|
||||
days: 2,
|
||||
url: function ({ date, channel }) {
|
||||
return `https://www.tvtv.us/api/v1/lineup/USA-NY71652-DEFAULT/grid/${date.toJSON()}/${date
|
||||
.add(1, 'd')
|
||||
.toJSON()}/${channel.site_id}`
|
||||
},
|
||||
parser: function ({ content }) {
|
||||
let programs = []
|
||||
|
||||
const items = parseItems(content)
|
||||
items.forEach(item => {
|
||||
const start = dayjs.utc(item.startTime)
|
||||
const stop = start.add(item.runTime, 'm')
|
||||
programs.push({
|
||||
title: item.title,
|
||||
description: item.subtitle,
|
||||
start,
|
||||
stop
|
||||
})
|
||||
})
|
||||
|
||||
return programs
|
||||
}
|
||||
}
|
||||
|
||||
function parseItems(content) {
|
||||
const json = JSON.parse(content)
|
||||
if (!json.length) return []
|
||||
return json[0]
|
||||
}
|
||||
|
|
|
@ -1,54 +1,54 @@
|
|||
// npm run grab -- --site=tvtv.us
|
||||
|
||||
const { parser, url } = require('./tvtv.us.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-09-20', 'YYYY-MM-DD').startOf('d')
|
||||
const channel = {
|
||||
site_id: '62670',
|
||||
xmltv_id: 'AMITV.ca',
|
||||
logo: 'https://tvtv.us/gn/i/assets/s62670_ll_h15_ab.png?w=360&h=270'
|
||||
}
|
||||
|
||||
it('can generate valid url', () => {
|
||||
expect(url({ channel, date })).toBe(
|
||||
'https://www.tvtv.us/api/v1/lineup/USA-NY71652-DEFAULT/grid/2022-09-20T00:00:00.000Z/2022-09-21T00:00:00.000Z/62670'
|
||||
)
|
||||
})
|
||||
|
||||
it('can parse response', () => {
|
||||
const content =
|
||||
'[[{"programId":"EP039131940001","title":"Beyond the Field","subtitle":"Diversity in Sport","flags":["CC","DVS"],"type":"O","startTime":"2022-09-20T00:00Z","start":0,"duration":30,"runTime":30},{"programId":"EP032368970002","title":"IGotThis","subtitle":"Listen to Dis","flags":["CC","DVS"],"type":"O","startTime":"2022-09-20T00:30Z","start":120,"duration":30,"runTime":30}]]'
|
||||
|
||||
const result = parser({ content }).map(p => {
|
||||
p.start = p.start.toJSON()
|
||||
p.stop = p.stop.toJSON()
|
||||
return p
|
||||
})
|
||||
|
||||
expect(result).toMatchObject([
|
||||
{
|
||||
start: '2022-09-20T00:00:00.000Z',
|
||||
stop: '2022-09-20T00:30:00.000Z',
|
||||
title: 'Beyond the Field',
|
||||
description: 'Diversity in Sport'
|
||||
},
|
||||
{
|
||||
start: '2022-09-20T00:30:00.000Z',
|
||||
stop: '2022-09-20T01:00:00.000Z',
|
||||
title: 'IGotThis',
|
||||
description: 'Listen to Dis'
|
||||
}
|
||||
])
|
||||
})
|
||||
|
||||
it('can handle empty guide', () => {
|
||||
const result = parser({
|
||||
content: '[]'
|
||||
})
|
||||
expect(result).toMatchObject([])
|
||||
})
|
||||
// npm run grab -- --site=tvtv.us
|
||||
|
||||
const { parser, url } = require('./tvtv.us.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-09-20', 'YYYY-MM-DD').startOf('d')
|
||||
const channel = {
|
||||
site_id: '62670',
|
||||
xmltv_id: 'AMITV.ca',
|
||||
logo: 'https://tvtv.us/gn/i/assets/s62670_ll_h15_ab.png?w=360&h=270'
|
||||
}
|
||||
|
||||
it('can generate valid url', () => {
|
||||
expect(url({ channel, date })).toBe(
|
||||
'https://www.tvtv.us/api/v1/lineup/USA-NY71652-DEFAULT/grid/2022-09-20T00:00:00.000Z/2022-09-21T00:00:00.000Z/62670'
|
||||
)
|
||||
})
|
||||
|
||||
it('can parse response', () => {
|
||||
const content =
|
||||
'[[{"programId":"EP039131940001","title":"Beyond the Field","subtitle":"Diversity in Sport","flags":["CC","DVS"],"type":"O","startTime":"2022-09-20T00:00Z","start":0,"duration":30,"runTime":30},{"programId":"EP032368970002","title":"IGotThis","subtitle":"Listen to Dis","flags":["CC","DVS"],"type":"O","startTime":"2022-09-20T00:30Z","start":120,"duration":30,"runTime":30}]]'
|
||||
|
||||
const result = parser({ content }).map(p => {
|
||||
p.start = p.start.toJSON()
|
||||
p.stop = p.stop.toJSON()
|
||||
return p
|
||||
})
|
||||
|
||||
expect(result).toMatchObject([
|
||||
{
|
||||
start: '2022-09-20T00:00:00.000Z',
|
||||
stop: '2022-09-20T00:30:00.000Z',
|
||||
title: 'Beyond the Field',
|
||||
description: 'Diversity in Sport'
|
||||
},
|
||||
{
|
||||
start: '2022-09-20T00:30:00.000Z',
|
||||
stop: '2022-09-20T01:00:00.000Z',
|
||||
title: 'IGotThis',
|
||||
description: 'Listen to Dis'
|
||||
}
|
||||
])
|
||||
})
|
||||
|
||||
it('can handle empty guide', () => {
|
||||
const result = parser({
|
||||
content: '[]'
|
||||
})
|
||||
expect(result).toMatchObject([])
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue