mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-11 17:40:07 -04:00
Create tv.blue.ch.config.js
This commit is contained in:
parent
2ab77a9500
commit
1928604244
1 changed files with 85 additions and 0 deletions
85
sites/tv.blue.ch/tv.blue.ch.config.js
Normal file
85
sites/tv.blue.ch/tv.blue.ch.config.js
Normal file
|
@ -0,0 +1,85 @@
|
||||||
|
const axios = require('axios')
|
||||||
|
const cheerio = require('cheerio')
|
||||||
|
const dayjs = require('dayjs')
|
||||||
|
const utc = require('dayjs/plugin/utc')
|
||||||
|
|
||||||
|
dayjs.extend(utc)
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
site: 'tv.blue.ch',
|
||||||
|
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)`
|
||||||
|
},
|
||||||
|
logo({ channel }) {
|
||||||
|
return `https://services.sg101.prd.sctv.ch/content/images/tv/channel/${channel.site_id}_image_7_w116.webp`
|
||||||
|
},
|
||||||
|
parser: function ({ content }) {
|
||||||
|
let programs = []
|
||||||
|
const items = parseItems(content)
|
||||||
|
items.forEach(item => {
|
||||||
|
if (item.title === 'Fin des programmes') return
|
||||||
|
programs.push({
|
||||||
|
title: parseTitle(item),
|
||||||
|
description: parseDescription(item),
|
||||||
|
icon: parseIcon(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 parseIcon(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.Items.filter(i => i.Kind === 'Broadcast')
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue