mirror of
https://github.com/iptv-org/epg
synced 2026-05-08 02:16:59 -04:00
Replace LF line endings with CRLF
This commit is contained in:
@@ -1,15 +1,15 @@
|
||||
# rtp.pt
|
||||
|
||||
https://www.rtp.pt/tv/
|
||||
|
||||
### Download the guide
|
||||
|
||||
```sh
|
||||
npm run grab --- --site=rtp.pt
|
||||
```
|
||||
|
||||
### Test
|
||||
|
||||
```sh
|
||||
npm test --- rtp.pt
|
||||
```
|
||||
# rtp.pt
|
||||
|
||||
https://www.rtp.pt/tv/
|
||||
|
||||
### Download the guide
|
||||
|
||||
```sh
|
||||
npm run grab --- --site=rtp.pt
|
||||
```
|
||||
|
||||
### Test
|
||||
|
||||
```sh
|
||||
npm test --- rtp.pt
|
||||
```
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<channels>
|
||||
<channel site="rtp.pt" lang="pt" xmltv_id="RTP1.pt" site_id="lis#1">RTP1</channel>
|
||||
<channel site="rtp.pt" lang="pt" xmltv_id="RTP2.pt" site_id="lis#8">RTP2</channel>
|
||||
<channel site="rtp.pt" lang="pt" xmltv_id="RTP3.pt" site_id="lis#7">RTP3</channel>
|
||||
<channel site="rtp.pt" lang="pt" xmltv_id="RTPAcores.pt" site_id="lis#3">RTP Açores</channel>
|
||||
<channel site="rtp.pt" lang="pt" xmltv_id="RTPAfrica.pt" site_id="lis#6">RTP África</channel>
|
||||
<channel site="rtp.pt" lang="pt" xmltv_id="RTPiAmerica.pt" site_id="rja#5">RTP Internacional América</channel>
|
||||
<channel site="rtp.pt" lang="pt" xmltv_id="RTPiAsia.pt" site_id="per#5">RTP Internacional Ásia</channel>
|
||||
<channel site="rtp.pt" lang="pt" xmltv_id="RTPInternacional.pt" site_id="lis#5">RTP Internacional</channel>
|
||||
<channel site="rtp.pt" lang="pt" xmltv_id="RTPMadeira.pt" site_id="lis#4">RTP Madeira</channel>
|
||||
<channel site="rtp.pt" lang="pt" xmltv_id="RTPMemoria.pt" site_id="lis#9">RTP Memória</channel>
|
||||
</channels>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<channels>
|
||||
<channel site="rtp.pt" lang="pt" xmltv_id="RTP1.pt" site_id="lis#1">RTP1</channel>
|
||||
<channel site="rtp.pt" lang="pt" xmltv_id="RTP2.pt" site_id="lis#8">RTP2</channel>
|
||||
<channel site="rtp.pt" lang="pt" xmltv_id="RTP3.pt" site_id="lis#7">RTP3</channel>
|
||||
<channel site="rtp.pt" lang="pt" xmltv_id="RTPAcores.pt" site_id="lis#3">RTP Açores</channel>
|
||||
<channel site="rtp.pt" lang="pt" xmltv_id="RTPAfrica.pt" site_id="lis#6">RTP África</channel>
|
||||
<channel site="rtp.pt" lang="pt" xmltv_id="RTPiAmerica.pt" site_id="rja#5">RTP Internacional América</channel>
|
||||
<channel site="rtp.pt" lang="pt" xmltv_id="RTPiAsia.pt" site_id="per#5">RTP Internacional Ásia</channel>
|
||||
<channel site="rtp.pt" lang="pt" xmltv_id="RTPInternacional.pt" site_id="lis#5">RTP Internacional</channel>
|
||||
<channel site="rtp.pt" lang="pt" xmltv_id="RTPMadeira.pt" site_id="lis#4">RTP Madeira</channel>
|
||||
<channel site="rtp.pt" lang="pt" xmltv_id="RTPMemoria.pt" site_id="lis#9">RTP Memória</channel>
|
||||
</channels>
|
||||
|
||||
@@ -1,65 +1,65 @@
|
||||
const dayjs = require('dayjs')
|
||||
const utc = require('dayjs/plugin/utc')
|
||||
const timezone = require('dayjs/plugin/timezone')
|
||||
const customParseFormat = require('dayjs/plugin/customParseFormat')
|
||||
|
||||
dayjs.extend(utc)
|
||||
dayjs.extend(timezone)
|
||||
dayjs.extend(customParseFormat)
|
||||
|
||||
const tz = {
|
||||
lis: 'Europe/Lisbon',
|
||||
per: 'Asia/Macau',
|
||||
rja: 'America/Sao_Paulo'
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
site: 'rtp.pt',
|
||||
days: 2,
|
||||
url({ channel, date }) {
|
||||
let [region, channelCode] = channel.site_id.split('#')
|
||||
return `https://www.rtp.pt/EPG/json/rtp-channels-page/list-grid/tv/${channelCode}/${date.format(
|
||||
'D-M-YYYY'
|
||||
)}/${region}`
|
||||
},
|
||||
parser({ content, channel }) {
|
||||
let programs = []
|
||||
const items = parseItems(content)
|
||||
items.forEach(item => {
|
||||
const prev = programs[programs.length - 1]
|
||||
let start = parseStart(item, channel)
|
||||
if (!start) return
|
||||
if (prev) {
|
||||
prev.stop = start
|
||||
}
|
||||
const stop = start.add(30, 'm')
|
||||
programs.push({
|
||||
title: item.name,
|
||||
description: item.description,
|
||||
image: parseImage(item),
|
||||
start,
|
||||
stop
|
||||
})
|
||||
})
|
||||
|
||||
return programs
|
||||
}
|
||||
}
|
||||
|
||||
function parseImage(item) {
|
||||
const last = item.image.pop()
|
||||
if (!last) return null
|
||||
return last.src
|
||||
}
|
||||
|
||||
function parseStart(item, channel) {
|
||||
let [region] = channel.site_id.split('#')
|
||||
return dayjs.tz(item.date, 'YYYY-MM-DD HH:mm:ss', tz[region])
|
||||
}
|
||||
|
||||
function parseItems(content) {
|
||||
if (!content) return []
|
||||
const data = JSON.parse(content)
|
||||
|
||||
return Object.values(data.result).flat()
|
||||
}
|
||||
const dayjs = require('dayjs')
|
||||
const utc = require('dayjs/plugin/utc')
|
||||
const timezone = require('dayjs/plugin/timezone')
|
||||
const customParseFormat = require('dayjs/plugin/customParseFormat')
|
||||
|
||||
dayjs.extend(utc)
|
||||
dayjs.extend(timezone)
|
||||
dayjs.extend(customParseFormat)
|
||||
|
||||
const tz = {
|
||||
lis: 'Europe/Lisbon',
|
||||
per: 'Asia/Macau',
|
||||
rja: 'America/Sao_Paulo'
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
site: 'rtp.pt',
|
||||
days: 2,
|
||||
url({ channel, date }) {
|
||||
let [region, channelCode] = channel.site_id.split('#')
|
||||
return `https://www.rtp.pt/EPG/json/rtp-channels-page/list-grid/tv/${channelCode}/${date.format(
|
||||
'D-M-YYYY'
|
||||
)}/${region}`
|
||||
},
|
||||
parser({ content, channel }) {
|
||||
let programs = []
|
||||
const items = parseItems(content)
|
||||
items.forEach(item => {
|
||||
const prev = programs[programs.length - 1]
|
||||
let start = parseStart(item, channel)
|
||||
if (!start) return
|
||||
if (prev) {
|
||||
prev.stop = start
|
||||
}
|
||||
const stop = start.add(30, 'm')
|
||||
programs.push({
|
||||
title: item.name,
|
||||
description: item.description,
|
||||
image: parseImage(item),
|
||||
start,
|
||||
stop
|
||||
})
|
||||
})
|
||||
|
||||
return programs
|
||||
}
|
||||
}
|
||||
|
||||
function parseImage(item) {
|
||||
const last = item.image.pop()
|
||||
if (!last) return null
|
||||
return last.src
|
||||
}
|
||||
|
||||
function parseStart(item, channel) {
|
||||
let [region] = channel.site_id.split('#')
|
||||
return dayjs.tz(item.date, 'YYYY-MM-DD HH:mm:ss', tz[region])
|
||||
}
|
||||
|
||||
function parseItems(content) {
|
||||
if (!content) return []
|
||||
const data = JSON.parse(content)
|
||||
|
||||
return Object.values(data.result).flat()
|
||||
}
|
||||
|
||||
@@ -1,42 +1,42 @@
|
||||
const { parser, url } = require('./rtp.pt.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('2022-12-02', 'YYYY-MM-DD').startOf('d')
|
||||
const channel = {
|
||||
site_id: 'lis#4',
|
||||
xmltv_id: 'RTPMadeira.pt'
|
||||
}
|
||||
|
||||
it('can generate valid url', () => {
|
||||
expect(url({ channel, date })).toBe(
|
||||
'https://www.rtp.pt/EPG/json/rtp-channels-page/list-grid/tv/4/2-12-2022/lis'
|
||||
)
|
||||
})
|
||||
|
||||
it('can parse response', () => {
|
||||
const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.json'))
|
||||
let results = parser({ content, channel }).map(p => {
|
||||
p.start = p.start.toJSON()
|
||||
p.stop = p.stop.toJSON()
|
||||
return p
|
||||
})
|
||||
|
||||
expect(results[9]).toMatchObject({
|
||||
start: '2022-12-02T23:30:00.000Z',
|
||||
stop: '2022-12-03T00:00:00.000Z',
|
||||
title: 'Telejornal Madeira',
|
||||
description: 'Informação de proximidade. De confiança!',
|
||||
image: 'https://cdn-images.rtp.pt/EPG/imagens/15790_43438_8820.png?w=384&h=216'
|
||||
})
|
||||
})
|
||||
|
||||
it('can handle empty guide', () => {
|
||||
const result = parser({ content: '', channel, date })
|
||||
expect(result).toMatchObject([])
|
||||
})
|
||||
const { parser, url } = require('./rtp.pt.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('2022-12-02', 'YYYY-MM-DD').startOf('d')
|
||||
const channel = {
|
||||
site_id: 'lis#4',
|
||||
xmltv_id: 'RTPMadeira.pt'
|
||||
}
|
||||
|
||||
it('can generate valid url', () => {
|
||||
expect(url({ channel, date })).toBe(
|
||||
'https://www.rtp.pt/EPG/json/rtp-channels-page/list-grid/tv/4/2-12-2022/lis'
|
||||
)
|
||||
})
|
||||
|
||||
it('can parse response', () => {
|
||||
const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.json'))
|
||||
let results = parser({ content, channel }).map(p => {
|
||||
p.start = p.start.toJSON()
|
||||
p.stop = p.stop.toJSON()
|
||||
return p
|
||||
})
|
||||
|
||||
expect(results[9]).toMatchObject({
|
||||
start: '2022-12-02T23:30:00.000Z',
|
||||
stop: '2022-12-03T00:00:00.000Z',
|
||||
title: 'Telejornal Madeira',
|
||||
description: 'Informação de proximidade. De confiança!',
|
||||
image: 'https://cdn-images.rtp.pt/EPG/imagens/15790_43438_8820.png?w=384&h=216'
|
||||
})
|
||||
})
|
||||
|
||||
it('can handle empty guide', () => {
|
||||
const result = parser({ content: '', channel, date })
|
||||
expect(result).toMatchObject([])
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user