mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-09 16:40:07 -04:00
commit
58987b81a5
5 changed files with 35 additions and 57 deletions
File diff suppressed because one or more lines are too long
|
@ -1,10 +0,0 @@
|
||||||
<!DOCTYPE html PUBLIC "-//IETF//DTD HTML 2.0//EN">
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<title>301 Moved Permanently</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>Moved Permanently</h1>
|
|
||||||
<p>The document has moved <a href="https://mediasetinfinity.mediaset.it/">here</a>.</p>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
|
@ -12,4 +12,5 @@
|
||||||
<channel site="mediasetinfinity.mediaset.it" lang="it" xmltv_id="MediasetExtra.it" site_id="KQ">Mediaset Extra</channel>
|
<channel site="mediasetinfinity.mediaset.it" lang="it" xmltv_id="MediasetExtra.it" site_id="KQ">Mediaset Extra</channel>
|
||||||
<channel site="mediasetinfinity.mediaset.it" lang="it" xmltv_id="Rete4.it" site_id="R4">Rete 4</channel>
|
<channel site="mediasetinfinity.mediaset.it" lang="it" xmltv_id="Rete4.it" site_id="R4">Rete 4</channel>
|
||||||
<channel site="mediasetinfinity.mediaset.it" lang="it" xmltv_id="TopCrime.it" site_id="LT">Top Crime</channel>
|
<channel site="mediasetinfinity.mediaset.it" lang="it" xmltv_id="TopCrime.it" site_id="LT">Top Crime</channel>
|
||||||
</channels>
|
<channel site="mediasetinfinity.mediaset.it" lang="it" xmltv_id="TGCom24.it" site_id="KF">TGCom 24</channel>
|
||||||
|
</channels>
|
||||||
|
|
|
@ -11,49 +11,40 @@ module.exports = {
|
||||||
site: 'mediasetinfinity.mediaset.it',
|
site: 'mediasetinfinity.mediaset.it',
|
||||||
days: 2,
|
days: 2,
|
||||||
url: function ({ date, channel }) {
|
url: function ({ date, channel }) {
|
||||||
return `http://www.mediaset.it/guidatv/inc/canali/${date.format('YYYYMM')}/${date.format(
|
// Get the epoch timestamp
|
||||||
'YYYYMMDD'
|
const todayEpoch = date.startOf('day').utc().valueOf();
|
||||||
)}_${channel.site_id}.sjson`
|
// Get the epoch timestamp for the next day
|
||||||
|
const nextDayEpoch = date.add(1, 'day').startOf('day').utc().valueOf();
|
||||||
|
return `https://api-ott-prod-fe.mediaset.net/PROD/play/feed/allListingFeedEpg/v2.0?byListingTime=${todayEpoch}~${nextDayEpoch}&byCallSign=${channel.site_id}`
|
||||||
},
|
},
|
||||||
parser: function ({ content, date }) {
|
parser: function ({ content, date }) {
|
||||||
const programs = []
|
const programs = [];
|
||||||
const items = getItems(content)
|
const data = JSON.parse(content);
|
||||||
|
|
||||||
items.forEach(item => {
|
if (!data.response || !data.response.entries || !data.response.entries[0] || !data.response.entries[0].listings) {
|
||||||
if (item.title && item.startTime && item.duration) {
|
// If the structure is not as expected, return an empty array
|
||||||
const start = parseStart(item, date)
|
return programs;
|
||||||
const duration = parseInt(item.duration)
|
}
|
||||||
const stop = start.add(duration, 'm')
|
|
||||||
|
const listings = data.response.entries[0].listings;
|
||||||
|
|
||||||
|
listings.forEach((listing) => {
|
||||||
|
if (listing.program.title && listing.startTime && listing.endTime) {
|
||||||
|
const start = parseTime(listing.startTime);
|
||||||
|
const stop = parseTime(listing.endTime);
|
||||||
|
|
||||||
programs.push({
|
programs.push({
|
||||||
title: item.displayTitle || item.title,
|
title: listing.program.title,
|
||||||
description: item.description,
|
description: listing.program.description,
|
||||||
category: item.genere,
|
|
||||||
start,
|
start,
|
||||||
stop
|
stop
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
|
return programs;
|
||||||
return programs
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseStart(item, date) {
|
function parseTime(timestamp) {
|
||||||
return dayjs.tz(
|
return dayjs(timestamp).utc().format('YYYY-MM-DD HH:mm');
|
||||||
`${date.format('YYYY-MM-DD')} ${item.startTime}`,
|
|
||||||
'YYYY-MM-DD HH:mm',
|
|
||||||
'Europe/Rome'
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
function getItems(content) {
|
|
||||||
let data
|
|
||||||
try {
|
|
||||||
data = JSON.parse(content)
|
|
||||||
} catch (err) {
|
|
||||||
return []
|
|
||||||
}
|
|
||||||
|
|
||||||
return data && Array.isArray(data.events) ? data.events : []
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ const customParseFormat = require('dayjs/plugin/customParseFormat')
|
||||||
dayjs.extend(customParseFormat)
|
dayjs.extend(customParseFormat)
|
||||||
dayjs.extend(utc)
|
dayjs.extend(utc)
|
||||||
|
|
||||||
const date = dayjs.utc('2023-10-20', 'YYYY-MM-DD').startOf('d')
|
const date = dayjs.utc('2024-01-20', 'YYYY-MM-DD').startOf('d')
|
||||||
const channel = {
|
const channel = {
|
||||||
site_id: 'LB',
|
site_id: 'LB',
|
||||||
xmltv_id: '20.it'
|
xmltv_id: '20.it'
|
||||||
|
@ -15,30 +15,27 @@ const channel = {
|
||||||
|
|
||||||
it('can generate valid url', () => {
|
it('can generate valid url', () => {
|
||||||
expect(url({ channel, date })).toBe(
|
expect(url({ channel, date })).toBe(
|
||||||
'http://www.mediaset.it/guidatv/inc/canali/202310/20231020_LB.sjson'
|
'https://api-ott-prod-fe.mediaset.net/PROD/play/feed/allListingFeedEpg/v2.0?byListingTime=1705708800000~1705795200000&byCallSign=LB'
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('can parse response', () => {
|
it('can parse response', () => {
|
||||||
const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.json'), 'utf8')
|
const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.json'), 'utf8')
|
||||||
const results = parser({ content, date }).map(p => {
|
const results = parser({ content, date }).map(p => {
|
||||||
p.start = p.start.toJSON()
|
|
||||||
p.stop = p.stop.toJSON()
|
|
||||||
return p
|
return p
|
||||||
})
|
})
|
||||||
|
|
||||||
expect(results[0]).toMatchObject({
|
expect(results[0]).toMatchObject({
|
||||||
start: '2023-10-20T04:10:00.000Z',
|
start: '2024-01-19 22:37',
|
||||||
stop: '2023-10-20T05:07:00.000Z',
|
stop: '2024-01-20 00:54',
|
||||||
title: 'Showreel',
|
title: 'Independence day: Rigenerazione',
|
||||||
description: 'INTRATTENIMENTO 15 - Italia, 2023',
|
description: 'Sequel del film di fantascienza Independence Day, con L. Hemsworth e B. Pullman. Dopo 20 anni la Terra si prepara a subire un secondo, terrificante attacco alieno.',
|
||||||
category: 'INTRATTENIMENTO'
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it('can handle empty guide', () => {
|
it('can handle empty guide', () => {
|
||||||
const result = parser({
|
const result = parser({
|
||||||
content: fs.readFileSync(path.resolve(__dirname, '__data__/no_content.html'), 'utf8')
|
content: '[]'
|
||||||
})
|
})
|
||||||
expect(result).toMatchObject([])
|
expect(result).toMatchObject([])
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue