forked from iptv-org/epg
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tvheute.at.config.js
96 lines (76 loc) · 2.17 KB
/
tvheute.at.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
const cheerio = require('cheerio')
const dayjs = require('dayjs')
module.exports = {
site: 'tvheute.at',
days: 2,
url({ channel, date }) {
return `https://tvheute.at/part/channel-shows/partial/${channel.site_id}/${date.format(
'DD-MM-YYYY'
)}`
},
parser: function ({ content }) {
let programs = []
const items = parseItems(content)
items.forEach(item => {
programs.push({
title: parseTitle(item),
description: parseDescription(item),
icon: parseIcon(item),
category: parseCategory(item),
start: parseStart(item).toJSON(),
stop: parseStop(item).toJSON()
})
})
return programs
},
async channels() {
const axios = require('axios')
const html = await axios
.get(`https://tvheute.at/part/channel-selection`)
.then(r => r.data)
.catch(console.log)
let channels = []
const $ = cheerio.load(html)
$('.sortable-list > li').each((i, el) => {
const name = $(el).find('label').text()
const site_id = $(el).find('input').attr('value')
channels.push({
lang: 'de',
site_id,
name
})
})
return channels
}
}
function parseTitle(item) {
const $ = cheerio.load(item)
return $('.title-col strong').text()
}
function parseDescription(item) {
const $ = cheerio.load(item)
return $('.title-col .description').text()
}
function parseCategory(item) {
const $ = cheerio.load(item)
return $('.station-col > .type').text()
}
function parseIcon(item) {
const $ = cheerio.load(item)
const imgSrc = $('.title-col .image img').data('src-desktop')
return imgSrc ? `https://tvheute.at${imgSrc}` : null
}
function parseStart(item) {
const $ = cheerio.load(item)
const time = $('.end-col > .duration-wrapper').data('start')
return dayjs(time)
}
function parseStop(item) {
const $ = cheerio.load(item)
const time = $('.end-col > .duration-wrapper').data('stop')
return dayjs(time)
}
function parseItems(content) {
const $ = cheerio.load(content)
return $('#showListContainer > table > tbody > tr').toArray()
}