mirror of
https://github.com/iptv-org/epg
synced 2026-04-30 06:26:59 -04:00
Fixes linter errors
This commit is contained in:
@@ -1,56 +1,56 @@
|
||||
const axios = require('axios')
|
||||
const dayjs = require('dayjs')
|
||||
|
||||
module.exports = {
|
||||
site: 'tv.post.lu',
|
||||
days: 2,
|
||||
url({ channel, date }) {
|
||||
return `https://tv.post.lu/api/channels?id=${channel.site_id}&date=${date.format('YYYY-MM-DD')}`
|
||||
},
|
||||
parser({ content }) {
|
||||
let programs = []
|
||||
const items = parseItems(content)
|
||||
items.forEach(item => {
|
||||
programs.push({
|
||||
title: item.title,
|
||||
description: item.description,
|
||||
category: item.program_type,
|
||||
icon: item.image_url,
|
||||
start: dayjs.unix(item.tsStart),
|
||||
stop: dayjs.unix(item.tsEnd)
|
||||
})
|
||||
})
|
||||
|
||||
return programs
|
||||
},
|
||||
async channels() {
|
||||
const promises = [...Array(17).keys()].map(i =>
|
||||
axios.get(`https://tv.post.lu/api/channels/?page=${i + 1}`)
|
||||
)
|
||||
|
||||
const channels = []
|
||||
await Promise.all(promises).then(values => {
|
||||
values.forEach(r => {
|
||||
let items = r.data.result.data
|
||||
items.forEach(item => {
|
||||
channels.push({
|
||||
lang: item.language.code,
|
||||
name: item.name,
|
||||
site_id: item.id
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
return channels
|
||||
}
|
||||
}
|
||||
|
||||
function parseItems(content) {
|
||||
if (!content) return []
|
||||
const data = JSON.parse(content)
|
||||
if (!data || !data.result || !data.result.epg || !Array.isArray(data.result.epg.programme))
|
||||
return []
|
||||
|
||||
return data.result.epg.programme
|
||||
}
|
||||
const axios = require('axios')
|
||||
const dayjs = require('dayjs')
|
||||
|
||||
module.exports = {
|
||||
site: 'tv.post.lu',
|
||||
days: 2,
|
||||
url({ channel, date }) {
|
||||
return `https://tv.post.lu/api/channels?id=${channel.site_id}&date=${date.format('YYYY-MM-DD')}`
|
||||
},
|
||||
parser({ content }) {
|
||||
let programs = []
|
||||
const items = parseItems(content)
|
||||
items.forEach(item => {
|
||||
programs.push({
|
||||
title: item.title,
|
||||
description: item.description,
|
||||
category: item.program_type,
|
||||
icon: item.image_url,
|
||||
start: dayjs.unix(item.tsStart),
|
||||
stop: dayjs.unix(item.tsEnd)
|
||||
})
|
||||
})
|
||||
|
||||
return programs
|
||||
},
|
||||
async channels() {
|
||||
const promises = [...Array(17).keys()].map(i =>
|
||||
axios.get(`https://tv.post.lu/api/channels/?page=${i + 1}`)
|
||||
)
|
||||
|
||||
const channels = []
|
||||
await Promise.all(promises).then(values => {
|
||||
values.forEach(r => {
|
||||
let items = r.data.result.data
|
||||
items.forEach(item => {
|
||||
channels.push({
|
||||
lang: item.language.code,
|
||||
name: item.name,
|
||||
site_id: item.id
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
return channels
|
||||
}
|
||||
}
|
||||
|
||||
function parseItems(content) {
|
||||
if (!content) return []
|
||||
const data = JSON.parse(content)
|
||||
if (!data || !data.result || !data.result.epg || !Array.isArray(data.result.epg.programme))
|
||||
return []
|
||||
|
||||
return data.result.epg.programme
|
||||
}
|
||||
|
||||
@@ -1,49 +1,49 @@
|
||||
// npm run channels:parse -- --config=./sites/tv.post.lu/tv.post.lu.config.js --output=./sites/tv.post.lu/tv.post.lu.channels.xml
|
||||
// npm run grab -- --site=tv.post.lu
|
||||
|
||||
const { parser, url } = require('./tv.post.lu.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-01-16', 'YYYY-MM-DD').startOf('d')
|
||||
const channel = {
|
||||
site_id: '269695d0-8076-11e9-b5ca-f345a2ed0fbe',
|
||||
xmltv_id: 'DasErste.de'
|
||||
}
|
||||
|
||||
it('can generate valid url', () => {
|
||||
expect(url({ channel, date })).toBe(
|
||||
'https://tv.post.lu/api/channels?id=269695d0-8076-11e9-b5ca-f345a2ed0fbe&date=2023-01-16'
|
||||
)
|
||||
})
|
||||
|
||||
it('can parse response', () => {
|
||||
const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.json'))
|
||||
const results = parser({ content }).map(p => {
|
||||
p.start = p.start.toJSON()
|
||||
p.stop = p.stop.toJSON()
|
||||
return p
|
||||
})
|
||||
|
||||
expect(results[0]).toMatchObject({
|
||||
title: 'Tagesschau',
|
||||
description:
|
||||
'Das Flaggschiff unter den deutschen Nachrichtensendungen ist gleichzeitig die "dienstälteste" noch bestehende Sendung im deutschen Fernsehen. In bis zu 20 am Tag produzierten Sendungen wird die Komplexität des Weltgeschehens verständlich erklärt und in komprimierter Form über aktuelle politische, wirtschaftliche, soziale, kulturelle, sportliche und sonstige Ereignisse berichtet.',
|
||||
category: 'Nachrichten',
|
||||
icon: 'https://mp-photos-cdn.azureedge.net/container3cc71e4948ac40ab803c26e0abc2e3e5/original/e6eb49013a822f5c6eb2e7701e69a1f80aa0b947.jpg',
|
||||
start: '2023-01-16T00:05:00.000Z',
|
||||
stop: '2023-01-16T00:10:00.000Z'
|
||||
})
|
||||
})
|
||||
|
||||
it('can handle empty guide', () => {
|
||||
const results = parser({ content: '' })
|
||||
|
||||
expect(results).toMatchObject([])
|
||||
})
|
||||
// npm run channels:parse -- --config=./sites/tv.post.lu/tv.post.lu.config.js --output=./sites/tv.post.lu/tv.post.lu.channels.xml
|
||||
// npm run grab -- --site=tv.post.lu
|
||||
|
||||
const { parser, url } = require('./tv.post.lu.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-01-16', 'YYYY-MM-DD').startOf('d')
|
||||
const channel = {
|
||||
site_id: '269695d0-8076-11e9-b5ca-f345a2ed0fbe',
|
||||
xmltv_id: 'DasErste.de'
|
||||
}
|
||||
|
||||
it('can generate valid url', () => {
|
||||
expect(url({ channel, date })).toBe(
|
||||
'https://tv.post.lu/api/channels?id=269695d0-8076-11e9-b5ca-f345a2ed0fbe&date=2023-01-16'
|
||||
)
|
||||
})
|
||||
|
||||
it('can parse response', () => {
|
||||
const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.json'))
|
||||
const results = parser({ content }).map(p => {
|
||||
p.start = p.start.toJSON()
|
||||
p.stop = p.stop.toJSON()
|
||||
return p
|
||||
})
|
||||
|
||||
expect(results[0]).toMatchObject({
|
||||
title: 'Tagesschau',
|
||||
description:
|
||||
'Das Flaggschiff unter den deutschen Nachrichtensendungen ist gleichzeitig die "dienstälteste" noch bestehende Sendung im deutschen Fernsehen. In bis zu 20 am Tag produzierten Sendungen wird die Komplexität des Weltgeschehens verständlich erklärt und in komprimierter Form über aktuelle politische, wirtschaftliche, soziale, kulturelle, sportliche und sonstige Ereignisse berichtet.',
|
||||
category: 'Nachrichten',
|
||||
icon: 'https://mp-photos-cdn.azureedge.net/container3cc71e4948ac40ab803c26e0abc2e3e5/original/e6eb49013a822f5c6eb2e7701e69a1f80aa0b947.jpg',
|
||||
start: '2023-01-16T00:05:00.000Z',
|
||||
stop: '2023-01-16T00:10:00.000Z'
|
||||
})
|
||||
})
|
||||
|
||||
it('can handle empty guide', () => {
|
||||
const results = parser({ content: '' })
|
||||
|
||||
expect(results).toMatchObject([])
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user