mirror of
https://github.com/iptv-org/epg
synced 2025-12-16 10:26:41 -05:00
Merge branch 'master' of https://github.com/iptv-org/epg into be-updates
This commit is contained in:
@@ -1,89 +1,89 @@
|
||||
const cheerio = require('cheerio')
|
||||
const { DateTime } = require('luxon')
|
||||
|
||||
module.exports = {
|
||||
delay: 5000,
|
||||
site: 'programtv.onet.pl',
|
||||
days: 2,
|
||||
url: function ({ date, channel }) {
|
||||
const currDate = DateTime.now().toUTC().startOf('day')
|
||||
const day = date.diff(currDate, 'd')
|
||||
|
||||
return `https://programtv.onet.pl/program-tv/${channel.site_id}?dzien=${day}`
|
||||
},
|
||||
parser: function ({ content, date }) {
|
||||
const programs = []
|
||||
const items = parseItems(content)
|
||||
items.forEach(item => {
|
||||
const prev = programs[programs.length - 1]
|
||||
const $item = cheerio.load(item)
|
||||
let start = parseStart($item, date)
|
||||
if (prev) {
|
||||
if (start < prev.start) {
|
||||
start = start.plus({ days: 1 })
|
||||
date = date.add(1, 'd')
|
||||
}
|
||||
prev.stop = start
|
||||
}
|
||||
const stop = start.plus({ hours: 1 })
|
||||
programs.push({
|
||||
title: parseTitle($item),
|
||||
description: parseDescription($item),
|
||||
category: parseCategory($item),
|
||||
start,
|
||||
stop
|
||||
})
|
||||
})
|
||||
|
||||
return programs
|
||||
},
|
||||
async channels() {
|
||||
const axios = require('axios')
|
||||
const data = await axios
|
||||
.get('https://programtv.onet.pl/stacje')
|
||||
.then(r => r.data)
|
||||
.catch(console.log)
|
||||
|
||||
let channels = []
|
||||
|
||||
const $ = cheerio.load(data)
|
||||
$('ul.channelList a').each((i, el) => {
|
||||
const name = $(el).text()
|
||||
const url = $(el).attr('href')
|
||||
const [, site_id] = url.match(/^\/program-tv\/(.*)$/i)
|
||||
|
||||
channels.push({
|
||||
lang: 'pl',
|
||||
site_id,
|
||||
name
|
||||
})
|
||||
})
|
||||
|
||||
return channels
|
||||
}
|
||||
}
|
||||
|
||||
function parseStart($item, date) {
|
||||
const timeString = $item('.hours > .hour').text()
|
||||
const dateString = `${date.format('MM/DD/YYYY')} ${timeString}`
|
||||
|
||||
return DateTime.fromFormat(dateString, 'MM/dd/yyyy HH:mm', { zone: 'Europe/Warsaw' }).toUTC()
|
||||
}
|
||||
|
||||
function parseCategory($item) {
|
||||
return $item('.titles > .type').text()
|
||||
}
|
||||
|
||||
function parseDescription($item) {
|
||||
return $item('.titles > p').text().trim()
|
||||
}
|
||||
|
||||
function parseTitle($item) {
|
||||
return $item('.titles > a').text().trim()
|
||||
}
|
||||
|
||||
function parseItems(content) {
|
||||
const $ = cheerio.load(content)
|
||||
|
||||
return $('#channelTV > section > div.emissions > ul > li').toArray()
|
||||
}
|
||||
const cheerio = require('cheerio')
|
||||
const { DateTime } = require('luxon')
|
||||
|
||||
module.exports = {
|
||||
delay: 5000,
|
||||
site: 'programtv.onet.pl',
|
||||
days: 2,
|
||||
url: function ({ date, channel }) {
|
||||
const currDate = DateTime.now().toUTC().startOf('day')
|
||||
const day = date.diff(currDate, 'd')
|
||||
|
||||
return `https://programtv.onet.pl/program-tv/${channel.site_id}?dzien=${day}`
|
||||
},
|
||||
parser: function ({ content, date }) {
|
||||
const programs = []
|
||||
const items = parseItems(content)
|
||||
items.forEach(item => {
|
||||
const prev = programs[programs.length - 1]
|
||||
const $item = cheerio.load(item)
|
||||
let start = parseStart($item, date)
|
||||
if (prev) {
|
||||
if (start < prev.start) {
|
||||
start = start.plus({ days: 1 })
|
||||
date = date.add(1, 'd')
|
||||
}
|
||||
prev.stop = start
|
||||
}
|
||||
const stop = start.plus({ hours: 1 })
|
||||
programs.push({
|
||||
title: parseTitle($item),
|
||||
description: parseDescription($item),
|
||||
category: parseCategory($item),
|
||||
start,
|
||||
stop
|
||||
})
|
||||
})
|
||||
|
||||
return programs
|
||||
},
|
||||
async channels() {
|
||||
const axios = require('axios')
|
||||
const data = await axios
|
||||
.get('https://programtv.onet.pl/stacje')
|
||||
.then(r => r.data)
|
||||
.catch(console.log)
|
||||
|
||||
let channels = []
|
||||
|
||||
const $ = cheerio.load(data)
|
||||
$('ul.channelList a').each((i, el) => {
|
||||
const name = $(el).text()
|
||||
const url = $(el).attr('href')
|
||||
const [, site_id] = url.match(/^\/program-tv\/(.*)$/i)
|
||||
|
||||
channels.push({
|
||||
lang: 'pl',
|
||||
site_id,
|
||||
name
|
||||
})
|
||||
})
|
||||
|
||||
return channels
|
||||
}
|
||||
}
|
||||
|
||||
function parseStart($item, date) {
|
||||
const timeString = $item('.hours > .hour').text()
|
||||
const dateString = `${date.format('MM/DD/YYYY')} ${timeString}`
|
||||
|
||||
return DateTime.fromFormat(dateString, 'MM/dd/yyyy HH:mm', { zone: 'Europe/Warsaw' }).toUTC()
|
||||
}
|
||||
|
||||
function parseCategory($item) {
|
||||
return $item('.titles > .type').text()
|
||||
}
|
||||
|
||||
function parseDescription($item) {
|
||||
return $item('.titles > p').text().trim()
|
||||
}
|
||||
|
||||
function parseTitle($item) {
|
||||
return $item('.titles > a').text().trim()
|
||||
}
|
||||
|
||||
function parseItems(content) {
|
||||
const $ = cheerio.load(content)
|
||||
|
||||
return $('#channelTV > section > div.emissions > ul > li').toArray()
|
||||
}
|
||||
|
||||
@@ -1,76 +1,76 @@
|
||||
const MockDate = require('mockdate')
|
||||
const { parser, url } = require('./programtv.onet.pl.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('2021-11-24', 'YYYY-MM-DD').startOf('d')
|
||||
const channel = {
|
||||
site_id: '13th-street-250',
|
||||
xmltv_id: '13thStreet.de'
|
||||
}
|
||||
|
||||
it('can generate valid url', () => {
|
||||
MockDate.set(dayjs.utc('2021-11-24', 'YYYY-MM-DD').startOf('d'))
|
||||
expect(url({ channel, date })).toBe(
|
||||
'https://programtv.onet.pl/program-tv/13th-street-250?dzien=0'
|
||||
)
|
||||
MockDate.reset()
|
||||
})
|
||||
|
||||
it('can generate valid url for next day', () => {
|
||||
MockDate.set(dayjs.utc('2021-11-23', 'YYYY-MM-DD').startOf('d'))
|
||||
expect(url({ channel, date })).toBe(
|
||||
'https://programtv.onet.pl/program-tv/13th-street-250?dzien=1'
|
||||
)
|
||||
MockDate.reset()
|
||||
})
|
||||
|
||||
it('can parse response', () => {
|
||||
const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.html'))
|
||||
const result = parser({ content, date }).map(p => {
|
||||
p.start = p.start.toJSON()
|
||||
p.stop = p.stop.toJSON()
|
||||
return p
|
||||
})
|
||||
|
||||
expect(result).toMatchObject([
|
||||
{
|
||||
start: '2021-11-24T02:20:00.000Z',
|
||||
stop: '2021-11-24T22:30:00.000Z',
|
||||
title: 'Law & Order, odc. 15: Letzte Worte',
|
||||
category: 'Krimiserie',
|
||||
description:
|
||||
'Bei einer Reality-TV-Show stirbt einer der Teilnehmer. Zunächst tappen Briscoe (Jerry Orbach) und Green (Jesse L....'
|
||||
},
|
||||
{
|
||||
start: '2021-11-24T22:30:00.000Z',
|
||||
stop: '2021-11-25T00:00:00.000Z',
|
||||
title: 'Navy CIS, odc. 1: New Orleans',
|
||||
category: 'Krimiserie',
|
||||
description:
|
||||
'Der Abgeordnete Dan McLane, ein ehemaliger Vorgesetzter von Gibbs, wird in New Orleans ermordet. In den 90er Jahren...'
|
||||
},
|
||||
{
|
||||
start: '2021-11-25T00:00:00.000Z',
|
||||
stop: '2021-11-25T01:00:00.000Z',
|
||||
title: 'Navy CIS: L.A, odc. 13: High Society',
|
||||
category: 'Krimiserie',
|
||||
description:
|
||||
'Die Zahl der Drogentoten ist gestiegen. Das Team des NCIS glaubt, dass sich Terroristen durch den zunehmenden...'
|
||||
}
|
||||
])
|
||||
})
|
||||
|
||||
it('can handle empty guide', () => {
|
||||
const result = parser({
|
||||
date,
|
||||
channel,
|
||||
content: fs.readFileSync(path.resolve(__dirname, '__data__/no_content.html'))
|
||||
})
|
||||
expect(result).toMatchObject([])
|
||||
})
|
||||
const MockDate = require('mockdate')
|
||||
const { parser, url } = require('./programtv.onet.pl.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('2021-11-24', 'YYYY-MM-DD').startOf('d')
|
||||
const channel = {
|
||||
site_id: '13th-street-250',
|
||||
xmltv_id: '13thStreet.de'
|
||||
}
|
||||
|
||||
it('can generate valid url', () => {
|
||||
MockDate.set(dayjs.utc('2021-11-24', 'YYYY-MM-DD').startOf('d'))
|
||||
expect(url({ channel, date })).toBe(
|
||||
'https://programtv.onet.pl/program-tv/13th-street-250?dzien=0'
|
||||
)
|
||||
MockDate.reset()
|
||||
})
|
||||
|
||||
it('can generate valid url for next day', () => {
|
||||
MockDate.set(dayjs.utc('2021-11-23', 'YYYY-MM-DD').startOf('d'))
|
||||
expect(url({ channel, date })).toBe(
|
||||
'https://programtv.onet.pl/program-tv/13th-street-250?dzien=1'
|
||||
)
|
||||
MockDate.reset()
|
||||
})
|
||||
|
||||
it('can parse response', () => {
|
||||
const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.html'))
|
||||
const result = parser({ content, date }).map(p => {
|
||||
p.start = p.start.toJSON()
|
||||
p.stop = p.stop.toJSON()
|
||||
return p
|
||||
})
|
||||
|
||||
expect(result).toMatchObject([
|
||||
{
|
||||
start: '2021-11-24T02:20:00.000Z',
|
||||
stop: '2021-11-24T22:30:00.000Z',
|
||||
title: 'Law & Order, odc. 15: Letzte Worte',
|
||||
category: 'Krimiserie',
|
||||
description:
|
||||
'Bei einer Reality-TV-Show stirbt einer der Teilnehmer. Zunächst tappen Briscoe (Jerry Orbach) und Green (Jesse L....'
|
||||
},
|
||||
{
|
||||
start: '2021-11-24T22:30:00.000Z',
|
||||
stop: '2021-11-25T00:00:00.000Z',
|
||||
title: 'Navy CIS, odc. 1: New Orleans',
|
||||
category: 'Krimiserie',
|
||||
description:
|
||||
'Der Abgeordnete Dan McLane, ein ehemaliger Vorgesetzter von Gibbs, wird in New Orleans ermordet. In den 90er Jahren...'
|
||||
},
|
||||
{
|
||||
start: '2021-11-25T00:00:00.000Z',
|
||||
stop: '2021-11-25T01:00:00.000Z',
|
||||
title: 'Navy CIS: L.A, odc. 13: High Society',
|
||||
category: 'Krimiserie',
|
||||
description:
|
||||
'Die Zahl der Drogentoten ist gestiegen. Das Team des NCIS glaubt, dass sich Terroristen durch den zunehmenden...'
|
||||
}
|
||||
])
|
||||
})
|
||||
|
||||
it('can handle empty guide', () => {
|
||||
const result = parser({
|
||||
date,
|
||||
channel,
|
||||
content: fs.readFileSync(path.resolve(__dirname, '__data__/no_content.html'))
|
||||
})
|
||||
expect(result).toMatchObject([])
|
||||
})
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
# programtv.onet.pl
|
||||
|
||||
https://programtv.onet.pl/ _[Geo-blocked]_
|
||||
|
||||
### Download the guide
|
||||
|
||||
```sh
|
||||
npm run grab --- --site=programtv.onet.pl
|
||||
```
|
||||
|
||||
### Update channel list
|
||||
|
||||
```sh
|
||||
npm run channels:parse --- --config=./sites/programtv.onet.pl/programtv.onet.pl.config.js --output=./sites/programtv.onet.pl/programtv.onet.pl.channels.xml
|
||||
```
|
||||
|
||||
### Test
|
||||
|
||||
```sh
|
||||
npm test --- programtv.onet.pl
|
||||
```
|
||||
# programtv.onet.pl
|
||||
|
||||
https://programtv.onet.pl/ _[Geo-blocked]_
|
||||
|
||||
### Download the guide
|
||||
|
||||
```sh
|
||||
npm run grab --- --site=programtv.onet.pl
|
||||
```
|
||||
|
||||
### Update channel list
|
||||
|
||||
```sh
|
||||
npm run channels:parse --- --config=./sites/programtv.onet.pl/programtv.onet.pl.config.js --output=./sites/programtv.onet.pl/programtv.onet.pl.channels.xml
|
||||
```
|
||||
|
||||
### Test
|
||||
|
||||
```sh
|
||||
npm test --- programtv.onet.pl
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user