mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-09 16:40:07 -04:00
Merge pull request #1603 from RevGear/RTP
Add RTP International Asia / America
This commit is contained in:
commit
8937b07ac7
3 changed files with 28 additions and 20 deletions
|
@ -9,19 +9,24 @@ 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',
|
||||
url({ channel, date }) {
|
||||
return `https://www.rtp.pt/EPG/json/rtp-channels-page/list-grid/tv/${
|
||||
channel.site_id
|
||||
}/${date.format('D-M-YYYY')}`
|
||||
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 }) {
|
||||
parser({ content, channel }) {
|
||||
let programs = []
|
||||
const items = parseItems(content)
|
||||
items.forEach(item => {
|
||||
const prev = programs[programs.length - 1]
|
||||
let start = parseStart(item)
|
||||
let start = parseStart(item, channel)
|
||||
if (!start) return
|
||||
if (prev) {
|
||||
prev.stop = start
|
||||
|
@ -56,12 +61,13 @@ module.exports = {
|
|||
|
||||
function parseIcon(item) {
|
||||
const last = item.image.pop()
|
||||
|
||||
return last?.src
|
||||
if(!last) return null
|
||||
return last.src
|
||||
}
|
||||
|
||||
function parseStart(item) {
|
||||
return dayjs.tz(item.date, 'YYYY-MM-DD HH:mm:ss', 'Europe/Lisbon')
|
||||
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) {
|
||||
|
|
|
@ -12,19 +12,19 @@ dayjs.extend(utc)
|
|||
|
||||
const date = dayjs.utc('2022-12-02', 'YYYY-MM-DD').startOf('d')
|
||||
const channel = {
|
||||
site_id: '4',
|
||||
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'
|
||||
'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 }).map(p => {
|
||||
let results = parser({ content, channel }).map(p => {
|
||||
p.start = p.start.toJSON()
|
||||
p.stop = p.stop.toJSON()
|
||||
return p
|
||||
|
|
|
@ -1,13 +1,15 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<site site="rtp.pt">
|
||||
<channels>
|
||||
<channel lang="pt" xmltv_id="RTP1.pt" site_id="1">RTP1</channel>
|
||||
<channel lang="pt" xmltv_id="RTP2.pt" site_id="8">RTP2</channel>
|
||||
<channel lang="pt" xmltv_id="RTP3.pt" site_id="7">RTP3</channel>
|
||||
<channel lang="pt" xmltv_id="RTPMemoria.pt" site_id="9">RTP Memória</channel>
|
||||
<channel lang="pt" xmltv_id="RTPAfrica.pt" site_id="6">RTP África</channel>
|
||||
<channel lang="pt" xmltv_id="RTPInternacional.pt" site_id="5">RTP Internacional</channel>
|
||||
<channel lang="pt" xmltv_id="RTPAcores.pt" site_id="3">RTP Açores</channel>
|
||||
<channel lang="pt" xmltv_id="RTPMadeira.pt" site_id="4">RTP Madeira</channel>
|
||||
<channel lang="pt" xmltv_id="RTP1.pt" site_id="lis#1">RTP1</channel>
|
||||
<channel lang="pt" xmltv_id="RTP2.pt" site_id="lis#8">RTP2</channel>
|
||||
<channel lang="pt" xmltv_id="RTP3.pt" site_id="lis#7">RTP3</channel>
|
||||
<channel lang="pt" xmltv_id="RTPMemoria.pt" site_id="lis#9">RTP Memória</channel>
|
||||
<channel lang="pt" xmltv_id="RTPAfrica.pt" site_id="lis#6">RTP África</channel>
|
||||
<channel lang="pt" xmltv_id="RTPInternacional.pt" site_id="lis#5">RTP Internacional</channel>
|
||||
<channel lang="pt" xmltv_id="RTPiAmerica.pt" site_id="rja#5">RTP Internacional América</channel>
|
||||
<channel lang="pt" xmltv_id="RTPiAsia.pt" site_id="per#5">RTP Internacional Ásia</channel>
|
||||
<channel lang="pt" xmltv_id="RTPAcores.pt" site_id="lis#3">RTP Açores</channel>
|
||||
<channel lang="pt" xmltv_id="RTPMadeira.pt" site_id="lis#4">RTP Madeira</channel>
|
||||
</channels>
|
||||
</site>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue