mirror of
https://github.com/iptv-org/epg
synced 2026-04-28 21:46:58 -04:00
Replace LF endings with CRLF
This commit is contained in:
@@ -1,16 +1,16 @@
|
||||
module.exports = {
|
||||
site: 'example.com',
|
||||
url({ channel, date }) {
|
||||
return `https://example.com/api/${channel.site_id}/${date.format('YYYY-MM-DD')}`
|
||||
},
|
||||
parser({ content }) {
|
||||
try {
|
||||
return JSON.parse(content)
|
||||
} catch {
|
||||
return []
|
||||
}
|
||||
},
|
||||
channels() {
|
||||
return []
|
||||
}
|
||||
}
|
||||
module.exports = {
|
||||
site: 'example.com',
|
||||
url({ channel, date }) {
|
||||
return `https://example.com/api/${channel.site_id}/${date.format('YYYY-MM-DD')}`
|
||||
},
|
||||
parser({ content }) {
|
||||
try {
|
||||
return JSON.parse(content)
|
||||
} catch {
|
||||
return []
|
||||
}
|
||||
},
|
||||
channels() {
|
||||
return []
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,38 +1,38 @@
|
||||
const { parser, url } = require('./example.com.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('2025-01-12', 'YYYY-MM-DD').startOf('d')
|
||||
const channel = { site_id: 'bbc1' }
|
||||
|
||||
it('can generate valid url', () => {
|
||||
expect(url({ channel, date })).toBe('https://example.com/api/bbc1/2025-01-12')
|
||||
})
|
||||
|
||||
it('can parse response', () => {
|
||||
const content =
|
||||
'[{"title":"Program 1","start":"2025-01-12T00:00:00.000Z","stop":"2025-01-12T00:30:00.000Z"},{"title":"Program 2","start":"2025-01-12T00:30:00.000Z","stop":"2025-01-12T01:00:00.000Z"}]'
|
||||
|
||||
const results = parser({ content })
|
||||
|
||||
expect(results.length).toBe(2)
|
||||
expect(results[0]).toMatchObject({
|
||||
title: 'Program 1',
|
||||
start: '2025-01-12T00:00:00.000Z',
|
||||
stop: '2025-01-12T00:30:00.000Z'
|
||||
})
|
||||
expect(results[1]).toMatchObject({
|
||||
title: 'Program 2',
|
||||
start: '2025-01-12T00:30:00.000Z',
|
||||
stop: '2025-01-12T01:00:00.000Z'
|
||||
})
|
||||
})
|
||||
|
||||
it('can handle empty guide', () => {
|
||||
const results = parser({ content: '' })
|
||||
|
||||
expect(results).toMatchObject([])
|
||||
})
|
||||
const { parser, url } = require('./example.com.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('2025-01-12', 'YYYY-MM-DD').startOf('d')
|
||||
const channel = { site_id: 'bbc1' }
|
||||
|
||||
it('can generate valid url', () => {
|
||||
expect(url({ channel, date })).toBe('https://example.com/api/bbc1/2025-01-12')
|
||||
})
|
||||
|
||||
it('can parse response', () => {
|
||||
const content =
|
||||
'[{"title":"Program 1","start":"2025-01-12T00:00:00.000Z","stop":"2025-01-12T00:30:00.000Z"},{"title":"Program 2","start":"2025-01-12T00:30:00.000Z","stop":"2025-01-12T01:00:00.000Z"}]'
|
||||
|
||||
const results = parser({ content })
|
||||
|
||||
expect(results.length).toBe(2)
|
||||
expect(results[0]).toMatchObject({
|
||||
title: 'Program 1',
|
||||
start: '2025-01-12T00:00:00.000Z',
|
||||
stop: '2025-01-12T00:30:00.000Z'
|
||||
})
|
||||
expect(results[1]).toMatchObject({
|
||||
title: 'Program 2',
|
||||
start: '2025-01-12T00:30:00.000Z',
|
||||
stop: '2025-01-12T01:00:00.000Z'
|
||||
})
|
||||
})
|
||||
|
||||
it('can handle empty guide', () => {
|
||||
const results = parser({ content: '' })
|
||||
|
||||
expect(results).toMatchObject([])
|
||||
})
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
module.exports = {
|
||||
site: 'example.com',
|
||||
url: 'https://example.com',
|
||||
parser() {
|
||||
return []
|
||||
},
|
||||
channels() {
|
||||
return [
|
||||
{
|
||||
lang: 'en',
|
||||
site_id: 140,
|
||||
name: 'CNN International'
|
||||
},
|
||||
{
|
||||
lang: 'en',
|
||||
site_id: 240,
|
||||
name: 'BBC World News'
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
module.exports = {
|
||||
site: 'example.com',
|
||||
url: 'https://example.com',
|
||||
parser() {
|
||||
return []
|
||||
},
|
||||
channels() {
|
||||
return [
|
||||
{
|
||||
lang: 'en',
|
||||
site_id: 140,
|
||||
name: 'CNN International'
|
||||
},
|
||||
{
|
||||
lang: 'en',
|
||||
site_id: 240,
|
||||
name: 'BBC World News'
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,30 +1,30 @@
|
||||
import { execSync } from 'child_process'
|
||||
import fs from 'fs-extra'
|
||||
import { pathToFileURL } from 'node:url'
|
||||
|
||||
beforeEach(() => {
|
||||
fs.emptyDirSync('tests/__data__/output')
|
||||
fs.copySync(
|
||||
'tests/__data__/input/channels_parse/example.com.channels.xml',
|
||||
'tests/__data__/output/example.com.channels.xml'
|
||||
)
|
||||
})
|
||||
|
||||
describe('channels:parse', () => {
|
||||
it('can parse channels', () => {
|
||||
const cmd =
|
||||
'npm run channels:parse --- --config=tests/__data__/input/channels_parse/example.com.config.js --output=tests/__data__/output/example.com.channels.xml'
|
||||
const stdout = execSync(cmd, { encoding: 'utf8' })
|
||||
if (process.env.DEBUG === 'true') console.log(cmd, stdout)
|
||||
|
||||
expect(content('tests/__data__/output/example.com.channels.xml')).toEqual(
|
||||
content('tests/__data__/expected/channels_parse/example.com.channels.xml')
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
function content(filepath: string) {
|
||||
return fs.readFileSync(pathToFileURL(filepath), {
|
||||
encoding: 'utf8'
|
||||
})
|
||||
}
|
||||
import { execSync } from 'child_process'
|
||||
import fs from 'fs-extra'
|
||||
import { pathToFileURL } from 'node:url'
|
||||
|
||||
beforeEach(() => {
|
||||
fs.emptyDirSync('tests/__data__/output')
|
||||
fs.copySync(
|
||||
'tests/__data__/input/channels_parse/example.com.channels.xml',
|
||||
'tests/__data__/output/example.com.channels.xml'
|
||||
)
|
||||
})
|
||||
|
||||
describe('channels:parse', () => {
|
||||
it('can parse channels', () => {
|
||||
const cmd =
|
||||
'npm run channels:parse --- --config=tests/__data__/input/channels_parse/example.com.config.js --output=tests/__data__/output/example.com.channels.xml'
|
||||
const stdout = execSync(cmd, { encoding: 'utf8' })
|
||||
if (process.env.DEBUG === 'true') console.log(cmd, stdout)
|
||||
|
||||
expect(content('tests/__data__/output/example.com.channels.xml')).toEqual(
|
||||
content('tests/__data__/expected/channels_parse/example.com.channels.xml')
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
function content(filepath: string) {
|
||||
return fs.readFileSync(pathToFileURL(filepath), {
|
||||
encoding: 'utf8'
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user