mirror of
https://github.com/iptv-org/epg
synced 2026-05-07 09:57:06 -04:00
Replace LF line endings with CRLF
This commit is contained in:
@@ -1,21 +1,21 @@
|
||||
# tv.blue.ch
|
||||
|
||||
https://tv.blue.ch/tv-guide
|
||||
|
||||
### Download the guide
|
||||
|
||||
```sh
|
||||
npm run grab --- --site=tv.blue.ch
|
||||
```
|
||||
|
||||
### Update channel list
|
||||
|
||||
```sh
|
||||
npm run channels:parse --- --config=./sites/tv.blue.ch/tv.blue.ch.config.js --output=./sites/tv.blue.ch/tv.blue.ch.channels.xml
|
||||
```
|
||||
|
||||
### Test
|
||||
|
||||
```sh
|
||||
npm test --- tv.blue.ch
|
||||
```
|
||||
# tv.blue.ch
|
||||
|
||||
https://tv.blue.ch/tv-guide
|
||||
|
||||
### Download the guide
|
||||
|
||||
```sh
|
||||
npm run grab --- --site=tv.blue.ch
|
||||
```
|
||||
|
||||
### Update channel list
|
||||
|
||||
```sh
|
||||
npm run channels:parse --- --config=./sites/tv.blue.ch/tv.blue.ch.config.js --output=./sites/tv.blue.ch/tv.blue.ch.channels.xml
|
||||
```
|
||||
|
||||
### Test
|
||||
|
||||
```sh
|
||||
npm test --- tv.blue.ch
|
||||
```
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,85 +1,85 @@
|
||||
const axios = require('axios')
|
||||
const dayjs = require('dayjs')
|
||||
const utc = require('dayjs/plugin/utc')
|
||||
|
||||
dayjs.extend(utc)
|
||||
|
||||
module.exports = {
|
||||
site: 'tv.blue.ch',
|
||||
days: 2,
|
||||
url: function ({ channel, date }) {
|
||||
return `https://services.sg101.prd.sctv.ch/catalog/tv/channels/list/(ids=${
|
||||
channel.site_id
|
||||
};start=${date.format('YYYYMMDDHHss')};end=${date
|
||||
.add(1, 'd')
|
||||
.format('YYYYMMDDHHss')};level=normal)`
|
||||
},
|
||||
parser: function ({ content }) {
|
||||
let programs = []
|
||||
const items = parseItems(content)
|
||||
items.forEach(item => {
|
||||
const title = parseTitle(item)
|
||||
if (title === 'Sendepause') return
|
||||
programs.push({
|
||||
title,
|
||||
description: parseDescription(item),
|
||||
image: parseImage(item),
|
||||
start: parseStart(item),
|
||||
stop: parseStop(item)
|
||||
})
|
||||
})
|
||||
|
||||
return programs
|
||||
},
|
||||
async channels() {
|
||||
const items = await axios
|
||||
.get('https://services.sg101.prd.sctv.ch/portfolio/tv/channels')
|
||||
.then(r => r.data)
|
||||
.catch(console.log)
|
||||
|
||||
return items.map(item => {
|
||||
return {
|
||||
lang: item.Languages[0] || 'de',
|
||||
site_id: item.Identifier,
|
||||
name: item.Title
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function parseTitle(item) {
|
||||
return item.Content.Description.Title
|
||||
}
|
||||
|
||||
function parseDescription(item) {
|
||||
return item.Content.Description.Summary
|
||||
}
|
||||
|
||||
function parseImage(item) {
|
||||
const image = item.Content.Nodes ? item.Content.Nodes.Items.find(i => i.Kind === 'Image') : null
|
||||
const path = image ? image.ContentPath : null
|
||||
|
||||
return path ? `https://services.sg101.prd.sctv.ch/content/images${path}_w1920.webp` : null
|
||||
}
|
||||
|
||||
function parseStart(item) {
|
||||
const available = item.Availabilities.length ? item.Availabilities[0] : null
|
||||
|
||||
return dayjs(available.AvailabilityStart)
|
||||
}
|
||||
|
||||
function parseStop(item) {
|
||||
const available = item.Availabilities.length ? item.Availabilities[0] : null
|
||||
|
||||
return dayjs(available.AvailabilityEnd)
|
||||
}
|
||||
|
||||
function parseItems(content) {
|
||||
const data = JSON.parse(content)
|
||||
const nodes = data.Nodes.Items.filter(i => i.Kind === 'Channel')
|
||||
if (!nodes.length) return []
|
||||
|
||||
return nodes[0].Content.Nodes && Array.isArray(nodes[0].Content.Nodes.Items)
|
||||
? nodes[0].Content.Nodes.Items.filter(i => i.Kind === 'Broadcast')
|
||||
: []
|
||||
}
|
||||
const axios = require('axios')
|
||||
const dayjs = require('dayjs')
|
||||
const utc = require('dayjs/plugin/utc')
|
||||
|
||||
dayjs.extend(utc)
|
||||
|
||||
module.exports = {
|
||||
site: 'tv.blue.ch',
|
||||
days: 2,
|
||||
url: function ({ channel, date }) {
|
||||
return `https://services.sg101.prd.sctv.ch/catalog/tv/channels/list/(ids=${
|
||||
channel.site_id
|
||||
};start=${date.format('YYYYMMDDHHss')};end=${date
|
||||
.add(1, 'd')
|
||||
.format('YYYYMMDDHHss')};level=normal)`
|
||||
},
|
||||
parser: function ({ content }) {
|
||||
let programs = []
|
||||
const items = parseItems(content)
|
||||
items.forEach(item => {
|
||||
const title = parseTitle(item)
|
||||
if (title === 'Sendepause') return
|
||||
programs.push({
|
||||
title,
|
||||
description: parseDescription(item),
|
||||
image: parseImage(item),
|
||||
start: parseStart(item),
|
||||
stop: parseStop(item)
|
||||
})
|
||||
})
|
||||
|
||||
return programs
|
||||
},
|
||||
async channels() {
|
||||
const items = await axios
|
||||
.get('https://services.sg101.prd.sctv.ch/portfolio/tv/channels')
|
||||
.then(r => r.data)
|
||||
.catch(console.log)
|
||||
|
||||
return items.map(item => {
|
||||
return {
|
||||
lang: item.Languages[0] || 'de',
|
||||
site_id: item.Identifier,
|
||||
name: item.Title
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function parseTitle(item) {
|
||||
return item.Content.Description.Title
|
||||
}
|
||||
|
||||
function parseDescription(item) {
|
||||
return item.Content.Description.Summary
|
||||
}
|
||||
|
||||
function parseImage(item) {
|
||||
const image = item.Content.Nodes ? item.Content.Nodes.Items.find(i => i.Kind === 'Image') : null
|
||||
const path = image ? image.ContentPath : null
|
||||
|
||||
return path ? `https://services.sg101.prd.sctv.ch/content/images${path}_w1920.webp` : null
|
||||
}
|
||||
|
||||
function parseStart(item) {
|
||||
const available = item.Availabilities.length ? item.Availabilities[0] : null
|
||||
|
||||
return dayjs(available.AvailabilityStart)
|
||||
}
|
||||
|
||||
function parseStop(item) {
|
||||
const available = item.Availabilities.length ? item.Availabilities[0] : null
|
||||
|
||||
return dayjs(available.AvailabilityEnd)
|
||||
}
|
||||
|
||||
function parseItems(content) {
|
||||
const data = JSON.parse(content)
|
||||
const nodes = data.Nodes.Items.filter(i => i.Kind === 'Channel')
|
||||
if (!nodes.length) return []
|
||||
|
||||
return nodes[0].Content.Nodes && Array.isArray(nodes[0].Content.Nodes.Items)
|
||||
? nodes[0].Content.Nodes.Items.filter(i => i.Kind === 'Broadcast')
|
||||
: []
|
||||
}
|
||||
|
||||
@@ -1,72 +1,72 @@
|
||||
const { parser, url } = require('./tv.blue.ch.config.js')
|
||||
const dayjs = require('dayjs')
|
||||
const utc = require('dayjs/plugin/utc')
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const customParseFormat = require('dayjs/plugin/customParseFormat')
|
||||
dayjs.extend(customParseFormat)
|
||||
dayjs.extend(utc)
|
||||
|
||||
const date = dayjs.utc('2022-01-17', 'YYYY-MM-DD').startOf('d')
|
||||
const channel = {
|
||||
site_id: '1221',
|
||||
xmltv_id: 'BlueZoomD.ch'
|
||||
}
|
||||
|
||||
it('can generate valid url', () => {
|
||||
expect(url({ channel, date })).toBe(
|
||||
'https://services.sg101.prd.sctv.ch/catalog/tv/channels/list/(ids=1221;start=202201170000;end=202201180000;level=normal)'
|
||||
)
|
||||
})
|
||||
|
||||
it('can parse response', () => {
|
||||
const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.json'))
|
||||
const result = parser({ content }).map(p => {
|
||||
p.start = p.start.toJSON()
|
||||
p.stop = p.stop.toJSON()
|
||||
return p
|
||||
})
|
||||
|
||||
expect(result).toMatchObject([
|
||||
{
|
||||
start: '2022-01-16T23:30:00.000Z',
|
||||
stop: '2022-01-17T00:00:00.000Z',
|
||||
title: 'Weekend on the Rocks',
|
||||
description:
|
||||
' - «R.E.S.P.E.C.T», lieber Charles Nguela. Der Comedian tourt fleissig durch die Schweiz, macht für uns aber einen Halt, um in der neuen Ausgabe von «Weekend on the Rocks» mit Moderatorin Vania Spescha über die Entertainment-News der Woche zu plaudern.',
|
||||
image:
|
||||
'https://services.sg101.prd.sctv.ch/content/images/tv/broadcast/1221/t1221ddc59247d45_landscape_w1920.webp'
|
||||
}
|
||||
])
|
||||
})
|
||||
|
||||
it('can parse response without image', () => {
|
||||
const content = fs.readFileSync(path.resolve(__dirname, '__data__/content_without_image.json'))
|
||||
const result = parser({ content }).map(p => {
|
||||
p.start = p.start.toJSON()
|
||||
p.stop = p.stop.toJSON()
|
||||
return p
|
||||
})
|
||||
|
||||
expect(result).toMatchObject([
|
||||
{
|
||||
start: '2022-01-17T04:59:00.000Z',
|
||||
stop: '2022-01-17T05:00:00.000Z',
|
||||
title: 'Lorem ipsum'
|
||||
}
|
||||
])
|
||||
})
|
||||
|
||||
it('can handle wrong site id', () => {
|
||||
const result = parser({
|
||||
content: fs.readFileSync(path.resolve(__dirname, '__data__/content_invalid_siteid.json'))
|
||||
})
|
||||
expect(result).toMatchObject([])
|
||||
})
|
||||
|
||||
it('can handle empty guide', () => {
|
||||
const result = parser({
|
||||
content: fs.readFileSync(path.resolve(__dirname, '__data__/no_content.json'))
|
||||
})
|
||||
expect(result).toMatchObject([])
|
||||
})
|
||||
const { parser, url } = require('./tv.blue.ch.config.js')
|
||||
const dayjs = require('dayjs')
|
||||
const utc = require('dayjs/plugin/utc')
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const customParseFormat = require('dayjs/plugin/customParseFormat')
|
||||
dayjs.extend(customParseFormat)
|
||||
dayjs.extend(utc)
|
||||
|
||||
const date = dayjs.utc('2022-01-17', 'YYYY-MM-DD').startOf('d')
|
||||
const channel = {
|
||||
site_id: '1221',
|
||||
xmltv_id: 'BlueZoomD.ch'
|
||||
}
|
||||
|
||||
it('can generate valid url', () => {
|
||||
expect(url({ channel, date })).toBe(
|
||||
'https://services.sg101.prd.sctv.ch/catalog/tv/channels/list/(ids=1221;start=202201170000;end=202201180000;level=normal)'
|
||||
)
|
||||
})
|
||||
|
||||
it('can parse response', () => {
|
||||
const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.json'))
|
||||
const result = parser({ content }).map(p => {
|
||||
p.start = p.start.toJSON()
|
||||
p.stop = p.stop.toJSON()
|
||||
return p
|
||||
})
|
||||
|
||||
expect(result).toMatchObject([
|
||||
{
|
||||
start: '2022-01-16T23:30:00.000Z',
|
||||
stop: '2022-01-17T00:00:00.000Z',
|
||||
title: 'Weekend on the Rocks',
|
||||
description:
|
||||
' - «R.E.S.P.E.C.T», lieber Charles Nguela. Der Comedian tourt fleissig durch die Schweiz, macht für uns aber einen Halt, um in der neuen Ausgabe von «Weekend on the Rocks» mit Moderatorin Vania Spescha über die Entertainment-News der Woche zu plaudern.',
|
||||
image:
|
||||
'https://services.sg101.prd.sctv.ch/content/images/tv/broadcast/1221/t1221ddc59247d45_landscape_w1920.webp'
|
||||
}
|
||||
])
|
||||
})
|
||||
|
||||
it('can parse response without image', () => {
|
||||
const content = fs.readFileSync(path.resolve(__dirname, '__data__/content_without_image.json'))
|
||||
const result = parser({ content }).map(p => {
|
||||
p.start = p.start.toJSON()
|
||||
p.stop = p.stop.toJSON()
|
||||
return p
|
||||
})
|
||||
|
||||
expect(result).toMatchObject([
|
||||
{
|
||||
start: '2022-01-17T04:59:00.000Z',
|
||||
stop: '2022-01-17T05:00:00.000Z',
|
||||
title: 'Lorem ipsum'
|
||||
}
|
||||
])
|
||||
})
|
||||
|
||||
it('can handle wrong site id', () => {
|
||||
const result = parser({
|
||||
content: fs.readFileSync(path.resolve(__dirname, '__data__/content_invalid_siteid.json'))
|
||||
})
|
||||
expect(result).toMatchObject([])
|
||||
})
|
||||
|
||||
it('can handle empty guide', () => {
|
||||
const result = parser({
|
||||
content: fs.readFileSync(path.resolve(__dirname, '__data__/no_content.json'))
|
||||
})
|
||||
expect(result).toMatchObject([])
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user