mirror of
https://github.com/iptv-org/epg
synced 2026-05-09 19:07:03 -04:00
Fix linter issues in sites/
This commit is contained in:
@@ -1,68 +1,68 @@
|
||||
const axios = require('axios')
|
||||
const dayjs = require('dayjs')
|
||||
const utc = require('dayjs/plugin/utc')
|
||||
|
||||
dayjs.extend(utc)
|
||||
|
||||
const headers = {
|
||||
'X-Apikey': 'xe1dgrShwdR1DVOKGmsj8Ut4QLlGyOFI',
|
||||
'X-Core-Appversion': '2.14.0.1',
|
||||
'X-Core-Contentratinglimit': '0',
|
||||
'X-Core-Deviceid': '',
|
||||
'X-Core-Devicetype': 'web',
|
||||
Origin: 'https://nostv.pt',
|
||||
'User-Agent':
|
||||
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36'
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
site: 'nostv.pt',
|
||||
days: 2,
|
||||
url({ channel, date }) {
|
||||
return `https://tyr-prod.apigee.net/nostv/ott/schedule/range/contents/guest?channels=${
|
||||
channel.site_id
|
||||
}&minDate=${date.format('YYYY-MM-DD')}T00:00:00Z&maxDate=${date.format(
|
||||
'YYYY-MM-DD'
|
||||
)}T23:59:59Z&isDateInclusive=true&client_id=${headers['X-Apikey']}`
|
||||
},
|
||||
request: { headers },
|
||||
parser({ content }) {
|
||||
const programs = []
|
||||
if (content) {
|
||||
const items = Array.isArray(content) ? content : JSON.parse(content)
|
||||
items.forEach(item => {
|
||||
programs.push({
|
||||
title: item.Metadata?.Title,
|
||||
sub_title: item.Metadata?.SubTitle ? item.Metadata?.SubTitle : null,
|
||||
description: item.Metadata?.Description,
|
||||
season: item.Metadata?.Season,
|
||||
episode: item.Metadata?.Episode,
|
||||
image: item.Images
|
||||
? `https://mage.stream.nos.pt/v1/nostv_mage/Images?sourceUri=${item.Images[0].Url}&profile=ott_1_452x340&client_id=${headers['X-Apikey']}`
|
||||
: null,
|
||||
start: dayjs.utc(item.UtcDateTimeStart),
|
||||
stop: dayjs.utc(item.UtcDateTimeEnd)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
return programs
|
||||
},
|
||||
async channels() {
|
||||
const result = await axios
|
||||
.get(
|
||||
`https://tyr-prod.apigee.net/nostv/ott/channels/guest?client_id=${headers['X-Apikey']}`,
|
||||
{ headers }
|
||||
)
|
||||
.then(r => r.data)
|
||||
.catch(console.error)
|
||||
|
||||
return result.map(item => {
|
||||
return {
|
||||
lang: 'pt',
|
||||
site_id: item.ServiceId,
|
||||
name: item.Name
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
const axios = require('axios')
|
||||
const dayjs = require('dayjs')
|
||||
const utc = require('dayjs/plugin/utc')
|
||||
|
||||
dayjs.extend(utc)
|
||||
|
||||
const headers = {
|
||||
'X-Apikey': 'xe1dgrShwdR1DVOKGmsj8Ut4QLlGyOFI',
|
||||
'X-Core-Appversion': '2.14.0.1',
|
||||
'X-Core-Contentratinglimit': '0',
|
||||
'X-Core-Deviceid': '',
|
||||
'X-Core-Devicetype': 'web',
|
||||
Origin: 'https://nostv.pt',
|
||||
'User-Agent':
|
||||
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36'
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
site: 'nostv.pt',
|
||||
days: 2,
|
||||
url({ channel, date }) {
|
||||
return `https://tyr-prod.apigee.net/nostv/ott/schedule/range/contents/guest?channels=${
|
||||
channel.site_id
|
||||
}&minDate=${date.format('YYYY-MM-DD')}T00:00:00Z&maxDate=${date.format(
|
||||
'YYYY-MM-DD'
|
||||
)}T23:59:59Z&isDateInclusive=true&client_id=${headers['X-Apikey']}`
|
||||
},
|
||||
request: { headers },
|
||||
parser({ content }) {
|
||||
const programs = []
|
||||
if (content) {
|
||||
const items = Array.isArray(content) ? content : JSON.parse(content)
|
||||
items.forEach(item => {
|
||||
programs.push({
|
||||
title: item.Metadata?.Title,
|
||||
sub_title: item.Metadata?.SubTitle ? item.Metadata?.SubTitle : null,
|
||||
description: item.Metadata?.Description,
|
||||
season: item.Metadata?.Season,
|
||||
episode: item.Metadata?.Episode,
|
||||
image: item.Images
|
||||
? `https://mage.stream.nos.pt/v1/nostv_mage/Images?sourceUri=${item.Images[0].Url}&profile=ott_1_452x340&client_id=${headers['X-Apikey']}`
|
||||
: null,
|
||||
start: dayjs.utc(item.UtcDateTimeStart),
|
||||
stop: dayjs.utc(item.UtcDateTimeEnd)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
return programs
|
||||
},
|
||||
async channels() {
|
||||
const result = await axios
|
||||
.get(
|
||||
`https://tyr-prod.apigee.net/nostv/ott/channels/guest?client_id=${headers['X-Apikey']}`,
|
||||
{ headers }
|
||||
)
|
||||
.then(r => r.data)
|
||||
.catch(console.error)
|
||||
|
||||
return result.map(item => {
|
||||
return {
|
||||
lang: 'pt',
|
||||
site_id: item.ServiceId,
|
||||
name: item.Name
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,51 +1,51 @@
|
||||
const { parser, url } = require('./nostv.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('2023-12-11').startOf('d')
|
||||
const channel = {
|
||||
site_id: '510',
|
||||
xmltv_id: 'SPlus.pt'
|
||||
}
|
||||
|
||||
it('can generate valid url', () => {
|
||||
expect(url({ channel, date })).toBe(
|
||||
'https://tyr-prod.apigee.net/nostv/ott/schedule/range/contents/guest?channels=510&minDate=2023-12-11T00:00:00Z&maxDate=2023-12-11T23:59:59Z&isDateInclusive=true&client_id=xe1dgrShwdR1DVOKGmsj8Ut4QLlGyOFI'
|
||||
)
|
||||
})
|
||||
|
||||
it('can parse response', () => {
|
||||
const content = fs.readFileSync(path.resolve(__dirname, '__data__/data.json'))
|
||||
const results = parser({ content }).map(p => {
|
||||
p.start = p.start.toJSON()
|
||||
p.stop = p.stop.toJSON()
|
||||
return p
|
||||
})
|
||||
|
||||
expect(results[0]).toMatchObject({
|
||||
start: '2023-12-11T16:30:00.000Z',
|
||||
stop: '2023-12-11T17:00:00.000Z',
|
||||
title: 'Village Vets',
|
||||
description:
|
||||
'A história de dois melhores amigos veterinários e o seu extraordinário trabalho na Austrália.',
|
||||
season: 1,
|
||||
episode: 12,
|
||||
image:
|
||||
'https://mage.stream.nos.pt/v1/nostv_mage/Images?sourceUri=http://vip.pam.local.internal/PAM.Images/Store/8329ed1aec5d4c0faa2056972256ff9f&profile=ott_1_452x340&client_id=xe1dgrShwdR1DVOKGmsj8Ut4QLlGyOFI'
|
||||
})
|
||||
})
|
||||
|
||||
it('can handle empty guide', async () => {
|
||||
const results = await parser({
|
||||
date,
|
||||
content: '[]'
|
||||
})
|
||||
|
||||
expect(results).toMatchObject([])
|
||||
})
|
||||
const { parser, url } = require('./nostv.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('2023-12-11').startOf('d')
|
||||
const channel = {
|
||||
site_id: '510',
|
||||
xmltv_id: 'SPlus.pt'
|
||||
}
|
||||
|
||||
it('can generate valid url', () => {
|
||||
expect(url({ channel, date })).toBe(
|
||||
'https://tyr-prod.apigee.net/nostv/ott/schedule/range/contents/guest?channels=510&minDate=2023-12-11T00:00:00Z&maxDate=2023-12-11T23:59:59Z&isDateInclusive=true&client_id=xe1dgrShwdR1DVOKGmsj8Ut4QLlGyOFI'
|
||||
)
|
||||
})
|
||||
|
||||
it('can parse response', () => {
|
||||
const content = fs.readFileSync(path.resolve(__dirname, '__data__/data.json'))
|
||||
const results = parser({ content }).map(p => {
|
||||
p.start = p.start.toJSON()
|
||||
p.stop = p.stop.toJSON()
|
||||
return p
|
||||
})
|
||||
|
||||
expect(results[0]).toMatchObject({
|
||||
start: '2023-12-11T16:30:00.000Z',
|
||||
stop: '2023-12-11T17:00:00.000Z',
|
||||
title: 'Village Vets',
|
||||
description:
|
||||
'A história de dois melhores amigos veterinários e o seu extraordinário trabalho na Austrália.',
|
||||
season: 1,
|
||||
episode: 12,
|
||||
image:
|
||||
'https://mage.stream.nos.pt/v1/nostv_mage/Images?sourceUri=http://vip.pam.local.internal/PAM.Images/Store/8329ed1aec5d4c0faa2056972256ff9f&profile=ott_1_452x340&client_id=xe1dgrShwdR1DVOKGmsj8Ut4QLlGyOFI'
|
||||
})
|
||||
})
|
||||
|
||||
it('can handle empty guide', async () => {
|
||||
const results = await parser({
|
||||
date,
|
||||
content: '[]'
|
||||
})
|
||||
|
||||
expect(results).toMatchObject([])
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user