mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 00:50:09 -04:00
commit
ce9b79c7c9
2 changed files with 21 additions and 15 deletions
|
@ -1,18 +1,14 @@
|
||||||
const dayjs = require('dayjs')
|
const { DateTime } = require('luxon')
|
||||||
const utc = require('dayjs/plugin/utc')
|
|
||||||
const customParseFormat = require('dayjs/plugin/customParseFormat')
|
|
||||||
const timezone = require('dayjs/plugin/timezone')
|
|
||||||
|
|
||||||
dayjs.extend(utc)
|
|
||||||
dayjs.extend(customParseFormat)
|
|
||||||
dayjs.extend(timezone)
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
site: 'meo.pt',
|
site: 'meo.pt',
|
||||||
days: 2,
|
days: 2,
|
||||||
url: `https://www.meo.pt/_layouts/15/Ptsi.Isites.GridTv/GridTvMng.asmx/getProgramsFromChannels`,
|
url: `https://authservice.apps.meo.pt/Services/GridTv/GridTvMng.svc/getProgramsFromChannels`,
|
||||||
request: {
|
request: {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
Origin: 'https://www.meo.pt'
|
||||||
|
},
|
||||||
data: function ({ channel, date }) {
|
data: function ({ channel, date }) {
|
||||||
return {
|
return {
|
||||||
service: 'channelsguide',
|
service: 'channelsguide',
|
||||||
|
@ -29,8 +25,8 @@ module.exports = {
|
||||||
items.forEach(item => {
|
items.forEach(item => {
|
||||||
const start = parseStart(item)
|
const start = parseStart(item)
|
||||||
let stop = parseStop(item)
|
let stop = parseStop(item)
|
||||||
if (stop.isBefore(start)) {
|
if (stop < start) {
|
||||||
stop = stop.add(1, 'd')
|
stop = stop.plus({ days: 1 })
|
||||||
}
|
}
|
||||||
programs.push({
|
programs.push({
|
||||||
title: item.name,
|
title: item.name,
|
||||||
|
@ -44,11 +40,15 @@ module.exports = {
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseStart(item) {
|
function parseStart(item) {
|
||||||
return dayjs.tz(`${item.date} ${item.timeIni}`, 'D-M-YYYY HH:mm', 'Europe/Lisbon')
|
return DateTime.fromFormat(`${item.date} ${item.timeIni}`, 'd-M-yyyy HH:mm', {
|
||||||
|
zone: 'Europe/Lisbon'
|
||||||
|
}).toUTC()
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseStop(item) {
|
function parseStop(item) {
|
||||||
return dayjs.tz(`${item.date} ${item.timeEnd}`, 'D-M-YYYY HH:mm', 'Europe/Lisbon')
|
return DateTime.fromFormat(`${item.date} ${item.timeEnd}`, 'd-M-yyyy HH:mm', {
|
||||||
|
zone: 'Europe/Lisbon'
|
||||||
|
}).toUTC()
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseItems(content) {
|
function parseItems(content) {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// npx epg-grabber --config=sites/meo.pt/meo.pt.config.js --channels=sites/meo.pt/meo.pt.channels.xml --output=guide.xml --days=2
|
// npx epg-grabber --config=sites/meo.pt/meo.pt.config.js --channels=sites/meo.pt/meo.pt.channels.xml --output=guide.xml
|
||||||
|
|
||||||
const { parser, url, request } = require('./meo.pt.config.js')
|
const { parser, url, request } = require('./meo.pt.config.js')
|
||||||
const fs = require('fs')
|
const fs = require('fs')
|
||||||
|
@ -17,7 +17,7 @@ const channel = {
|
||||||
|
|
||||||
it('can generate valid url', () => {
|
it('can generate valid url', () => {
|
||||||
expect(url).toBe(
|
expect(url).toBe(
|
||||||
'https://www.meo.pt/_layouts/15/Ptsi.Isites.GridTv/GridTvMng.asmx/getProgramsFromChannels'
|
'https://authservice.apps.meo.pt/Services/GridTv/GridTvMng.svc/getProgramsFromChannels'
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -25,6 +25,12 @@ it('can generate valid request method', () => {
|
||||||
expect(request.method).toBe('POST')
|
expect(request.method).toBe('POST')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('can generate valid request headers', () => {
|
||||||
|
expect(request.headers).toMatchObject({
|
||||||
|
Origin: 'https://www.meo.pt'
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
it('can generate valid request method', () => {
|
it('can generate valid request method', () => {
|
||||||
expect(request.data({ channel, date })).toMatchObject({
|
expect(request.data({ channel, date })).toMatchObject({
|
||||||
service: 'channelsguide',
|
service: 'channelsguide',
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue