mirror of
https://github.com/iptv-org/epg
synced 2025-12-16 18:37:01 -05:00
Replaced LF endings with CRLF
This commit is contained in:
@@ -1,95 +1,95 @@
|
||||
const dayjs = require('dayjs')
|
||||
const utc = require('dayjs/plugin/utc')
|
||||
|
||||
dayjs.extend(utc)
|
||||
|
||||
module.exports = {
|
||||
site: 'programetv.ro',
|
||||
days: 2,
|
||||
url: function ({ date, channel }) {
|
||||
const daysOfWeek = {
|
||||
0: 'duminica',
|
||||
1: 'luni',
|
||||
2: 'marti',
|
||||
3: 'miercuri',
|
||||
4: 'joi',
|
||||
5: 'vineri',
|
||||
6: 'sambata'
|
||||
}
|
||||
const day = date.day()
|
||||
|
||||
return `https://www.programetv.ro/program-tv/${channel.site_id}/${daysOfWeek[day]}/`
|
||||
},
|
||||
parser: function ({ content }) {
|
||||
let programs = []
|
||||
const data = parseContent(content)
|
||||
if (!data || !data.shows) return programs
|
||||
const items = data.shows
|
||||
items.forEach(item => {
|
||||
programs.push({
|
||||
title: item.title,
|
||||
sub_title: item.titleOriginal,
|
||||
description: item.desc || item.obs,
|
||||
category: item.categories,
|
||||
season: item.season || null,
|
||||
episode: item.episode || null,
|
||||
start: parseStart(item),
|
||||
stop: parseStop(item),
|
||||
url: item.url || null,
|
||||
date: item.date,
|
||||
rating: parseRating(item),
|
||||
directors: parseDirector(item),
|
||||
actors: parseActor(item),
|
||||
icon: item.icon
|
||||
})
|
||||
})
|
||||
|
||||
return programs
|
||||
},
|
||||
async channels() {
|
||||
const axios = require('axios')
|
||||
const data = await axios
|
||||
.get('https://www.programetv.ro/api/station/index/')
|
||||
.then(r => r.data)
|
||||
.catch(console.log)
|
||||
|
||||
return data.map(item => {
|
||||
return {
|
||||
lang: 'ro',
|
||||
site_id: item.slug,
|
||||
name: item.displayName
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function parseStart(item) {
|
||||
return dayjs(item.start).toJSON()
|
||||
}
|
||||
|
||||
function parseStop(item) {
|
||||
return dayjs(item.stop).toJSON()
|
||||
}
|
||||
|
||||
function parseContent(content) {
|
||||
const [, data] = content.match(/var pageData = ({.+?});/) || [null, null]
|
||||
|
||||
return data ? JSON.parse(data) : {}
|
||||
}
|
||||
|
||||
function parseDirector(item) {
|
||||
return item.credits && item.credits.director ? item.credits.director : null
|
||||
}
|
||||
|
||||
function parseActor(item) {
|
||||
return item.credits && item.credits.actor ? item.credits.actor : null
|
||||
}
|
||||
|
||||
function parseRating(item) {
|
||||
return item.rating
|
||||
? {
|
||||
system: 'CNC',
|
||||
value: item.rating.toUpperCase()
|
||||
}
|
||||
: null
|
||||
}
|
||||
const dayjs = require('dayjs')
|
||||
const utc = require('dayjs/plugin/utc')
|
||||
|
||||
dayjs.extend(utc)
|
||||
|
||||
module.exports = {
|
||||
site: 'programetv.ro',
|
||||
days: 2,
|
||||
url: function ({ date, channel }) {
|
||||
const daysOfWeek = {
|
||||
0: 'duminica',
|
||||
1: 'luni',
|
||||
2: 'marti',
|
||||
3: 'miercuri',
|
||||
4: 'joi',
|
||||
5: 'vineri',
|
||||
6: 'sambata'
|
||||
}
|
||||
const day = date.day()
|
||||
|
||||
return `https://www.programetv.ro/program-tv/${channel.site_id}/${daysOfWeek[day]}/`
|
||||
},
|
||||
parser: function ({ content }) {
|
||||
let programs = []
|
||||
const data = parseContent(content)
|
||||
if (!data || !data.shows) return programs
|
||||
const items = data.shows
|
||||
items.forEach(item => {
|
||||
programs.push({
|
||||
title: item.title,
|
||||
sub_title: item.titleOriginal,
|
||||
description: item.desc || item.obs,
|
||||
category: item.categories,
|
||||
season: item.season || null,
|
||||
episode: item.episode || null,
|
||||
start: parseStart(item),
|
||||
stop: parseStop(item),
|
||||
url: item.url || null,
|
||||
date: item.date,
|
||||
rating: parseRating(item),
|
||||
directors: parseDirector(item),
|
||||
actors: parseActor(item),
|
||||
icon: item.icon
|
||||
})
|
||||
})
|
||||
|
||||
return programs
|
||||
},
|
||||
async channels() {
|
||||
const axios = require('axios')
|
||||
const data = await axios
|
||||
.get('https://www.programetv.ro/api/station/index/')
|
||||
.then(r => r.data)
|
||||
.catch(console.log)
|
||||
|
||||
return data.map(item => {
|
||||
return {
|
||||
lang: 'ro',
|
||||
site_id: item.slug,
|
||||
name: item.displayName
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function parseStart(item) {
|
||||
return dayjs(item.start).toJSON()
|
||||
}
|
||||
|
||||
function parseStop(item) {
|
||||
return dayjs(item.stop).toJSON()
|
||||
}
|
||||
|
||||
function parseContent(content) {
|
||||
const [, data] = content.match(/var pageData = ({.+?});/) || [null, null]
|
||||
|
||||
return data ? JSON.parse(data) : {}
|
||||
}
|
||||
|
||||
function parseDirector(item) {
|
||||
return item.credits && item.credits.director ? item.credits.director : null
|
||||
}
|
||||
|
||||
function parseActor(item) {
|
||||
return item.credits && item.credits.actor ? item.credits.actor : null
|
||||
}
|
||||
|
||||
function parseRating(item) {
|
||||
return item.rating
|
||||
? {
|
||||
system: 'CNC',
|
||||
value: item.rating.toUpperCase()
|
||||
}
|
||||
: null
|
||||
}
|
||||
|
||||
@@ -1,42 +1,42 @@
|
||||
const { parser, url } = require('./programetv.ro.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-10-24', 'YYYY-MM-DD').startOf('d')
|
||||
const channel = { site_id: 'pro-tv', xmltv_id: 'ProTV.ro' }
|
||||
|
||||
it('can generate valid url', () => {
|
||||
const result = url({ date, channel })
|
||||
expect(result).toBe('https://www.programetv.ro/program-tv/pro-tv/duminica/')
|
||||
})
|
||||
|
||||
it('can parse response', () => {
|
||||
const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.html'), 'utf8')
|
||||
const result = parser({ date, channel, content })
|
||||
expect(result).toMatchObject([
|
||||
{
|
||||
start: '2021-11-07T05:00:00.000Z',
|
||||
stop: '2021-11-07T07:59:59.000Z',
|
||||
title: 'Ştirile Pro Tv',
|
||||
description:
|
||||
'În fiecare zi, cele mai importante evenimente, transmisiuni LIVE, analize, anchete şi reportaje sunt la Ştirile ProTV.',
|
||||
category: ['Ştiri'],
|
||||
icon: 'https://www.programetv.ro/img/shows/84/54/stirile-pro-tv.png?key=Z2lfZnVial90cmFyZXZwLzAwLzAwLzA1LzE4MzgxMnktMTIwazE3MC1hLW40NTk4MW9zLmNhdA=='
|
||||
}
|
||||
])
|
||||
})
|
||||
|
||||
it('can handle empty guide', () => {
|
||||
const result = parser({
|
||||
date,
|
||||
channel,
|
||||
content: fs.readFileSync(path.resolve(__dirname, '__data__/no_content.html'), 'utf8')
|
||||
|
||||
})
|
||||
expect(result).toMatchObject([])
|
||||
})
|
||||
const { parser, url } = require('./programetv.ro.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-10-24', 'YYYY-MM-DD').startOf('d')
|
||||
const channel = { site_id: 'pro-tv', xmltv_id: 'ProTV.ro' }
|
||||
|
||||
it('can generate valid url', () => {
|
||||
const result = url({ date, channel })
|
||||
expect(result).toBe('https://www.programetv.ro/program-tv/pro-tv/duminica/')
|
||||
})
|
||||
|
||||
it('can parse response', () => {
|
||||
const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.html'), 'utf8')
|
||||
const result = parser({ date, channel, content })
|
||||
expect(result).toMatchObject([
|
||||
{
|
||||
start: '2021-11-07T05:00:00.000Z',
|
||||
stop: '2021-11-07T07:59:59.000Z',
|
||||
title: 'Ştirile Pro Tv',
|
||||
description:
|
||||
'În fiecare zi, cele mai importante evenimente, transmisiuni LIVE, analize, anchete şi reportaje sunt la Ştirile ProTV.',
|
||||
category: ['Ştiri'],
|
||||
icon: 'https://www.programetv.ro/img/shows/84/54/stirile-pro-tv.png?key=Z2lfZnVial90cmFyZXZwLzAwLzAwLzA1LzE4MzgxMnktMTIwazE3MC1hLW40NTk4MW9zLmNhdA=='
|
||||
}
|
||||
])
|
||||
})
|
||||
|
||||
it('can handle empty guide', () => {
|
||||
const result = parser({
|
||||
date,
|
||||
channel,
|
||||
content: fs.readFileSync(path.resolve(__dirname, '__data__/no_content.html'), 'utf8')
|
||||
|
||||
})
|
||||
expect(result).toMatchObject([])
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user