mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 17:10:07 -04:00
Merge pull request #2410 from ToRvaLDz/master
Adding subtitle, catgory, season, episode, thumb to mediasetinfinity.mediaset.it
This commit is contained in:
commit
270e85cfae
2 changed files with 79 additions and 31 deletions
|
@ -10,41 +10,84 @@ dayjs.extend(timezone)
|
||||||
module.exports = {
|
module.exports = {
|
||||||
site: 'mediasetinfinity.mediaset.it',
|
site: 'mediasetinfinity.mediaset.it',
|
||||||
days: 2,
|
days: 2,
|
||||||
url: function ({ date, channel }) {
|
url: function ({date, channel}) {
|
||||||
// Get the epoch timestamp
|
// Get the epoch timestamp
|
||||||
const todayEpoch = date.startOf('day').utc().valueOf();
|
const todayEpoch = date.startOf('day').utc().valueOf()
|
||||||
// Get the epoch timestamp for the next day
|
// Get the epoch timestamp for the next day
|
||||||
const nextDayEpoch = date.add(1, 'day').startOf('day').utc().valueOf();
|
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}`
|
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}) {
|
||||||
const programs = [];
|
const programs = []
|
||||||
const data = JSON.parse(content);
|
const data = JSON.parse(content)
|
||||||
|
|
||||||
if (!data.response || !data.response.entries || !data.response.entries[0] || !data.response.entries[0].listings) {
|
if (!data.response || !data.response.entries || !data.response.entries[0] || !data.response.entries[0].listings) {
|
||||||
// If the structure is not as expected, return an empty array
|
// If the structure is not as expected, return an empty array
|
||||||
return programs;
|
return programs
|
||||||
}
|
}
|
||||||
|
|
||||||
const listings = data.response.entries[0].listings;
|
const listings = data.response.entries[0].listings
|
||||||
|
|
||||||
listings.forEach((listing) => {
|
listings.forEach((listing) => {
|
||||||
if (listing.program.title && listing.startTime && listing.endTime) {
|
const title = listing.mediasetlisting$epgTitle
|
||||||
const start = parseTime(listing.startTime);
|
const subTitle = listing.program.title
|
||||||
const stop = parseTime(listing.endTime);
|
const season = parseSeason(listing)
|
||||||
|
const episode = parseEpisode(listing)
|
||||||
|
|
||||||
|
|
||||||
|
if (listing.program.title && listing.startTime && listing.endTime) {
|
||||||
programs.push({
|
programs.push({
|
||||||
title: listing.program.title,
|
title: title || subTitle,
|
||||||
description: listing.program.description,
|
sub_title: title && title != subTitle ? subTitle : null,
|
||||||
start,
|
description: listing.program.description || null,
|
||||||
stop
|
category: listing.program.mediasetprogram$skyGenre || null,
|
||||||
});
|
season: episode && !season ? '0' : season,
|
||||||
|
episode: episode,
|
||||||
|
start: parseTime(listing.startTime),
|
||||||
|
stop: parseTime(listing.endTime),
|
||||||
|
image: getMaxResolutionThumbnails(listing)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
return programs;
|
|
||||||
|
return programs
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function parseTime(timestamp) {
|
function parseTime(timestamp) {
|
||||||
return dayjs(timestamp).utc().format('YYYY-MM-DD HH:mm');
|
return dayjs(timestamp).utc().format('YYYY-MM-DD HH:mm')
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseSeason(item) {
|
||||||
|
if (!item.mediasetlisting$shortDescription) return null
|
||||||
|
const season = item.mediasetlisting$shortDescription.match(/S(\d+)\s/)
|
||||||
|
return season ? season[1] : null
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseEpisode(item) {
|
||||||
|
if (!item.mediasetlisting$shortDescription) return null
|
||||||
|
const episode = item.mediasetlisting$shortDescription.match(/Ep(\d+)\s/)
|
||||||
|
return episode ? episode[1] : null
|
||||||
|
}
|
||||||
|
|
||||||
|
function getMaxResolutionThumbnails(item) {
|
||||||
|
const thumbnails = item.program.thumbnails || null
|
||||||
|
const maxResolutionThumbnails = {}
|
||||||
|
|
||||||
|
for (const key in thumbnails) {
|
||||||
|
const type = key.split('-')[0] // Estrarre il tipo di thumbnail
|
||||||
|
const {width, height, url, title} = thumbnails[key]
|
||||||
|
|
||||||
|
if (!maxResolutionThumbnails[type] ||
|
||||||
|
(width * height > maxResolutionThumbnails[type].width * maxResolutionThumbnails[type].height)) {
|
||||||
|
maxResolutionThumbnails[type] = {width, height, url, title}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (maxResolutionThumbnails.image_keyframe_poster)
|
||||||
|
return maxResolutionThumbnails.image_keyframe_poster.url
|
||||||
|
else if (maxResolutionThumbnails.image_header_poster)
|
||||||
|
return maxResolutionThumbnails.image_header_poster.url
|
||||||
|
else
|
||||||
|
return null
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
const { parser, url } = require('./mediasetinfinity.mediaset.it.config.js')
|
const {parser, url} = require('./mediasetinfinity.mediaset.it.config.js')
|
||||||
const fs = require('fs')
|
const fs = require('fs')
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
const dayjs = require('dayjs')
|
const dayjs = require('dayjs')
|
||||||
|
@ -9,27 +9,32 @@ dayjs.extend(utc)
|
||||||
|
|
||||||
const date = dayjs.utc('2024-01-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'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
it('can generate valid url', () => {
|
it('can generate valid url', () => {
|
||||||
expect(url({ channel, date })).toBe(
|
expect(url({
|
||||||
'https://api-ott-prod-fe.mediaset.net/PROD/play/feed/allListingFeedEpg/v2.0?byListingTime=1705708800000~1705795200000&byCallSign=LB'
|
channel,
|
||||||
)
|
date
|
||||||
|
})).toBe('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 => {
|
||||||
return p
|
return p
|
||||||
})
|
})
|
||||||
|
|
||||||
expect(results[0]).toMatchObject({
|
expect(results[3]).toMatchObject({
|
||||||
start: '2024-01-19 22:37',
|
start: '2024-01-20 02:14',
|
||||||
stop: '2024-01-20 00:54',
|
stop: '2024-01-20 02:54',
|
||||||
title: 'Independence day: Rigenerazione',
|
title: 'Chicago Fire',
|
||||||
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.',
|
sub_title: 'Ep. 22 - Io non ti lascio',
|
||||||
|
description: 'Severide e Kidd continuano a indagare su un vecchio caso doloso di Benny. Notizie inaspettate portano Brett a meditare su una grande decisione.',
|
||||||
|
category: 'Intrattenimento',
|
||||||
|
season: '7',
|
||||||
|
episode: '22',
|
||||||
|
image: 'https://static2.mediasetplay.mediaset.it/Mediaset_Italia_Production_-_Main/F309370301002204/media/0/0/1ef76b73-3173-43bd-9c16-73986a0ec131/46896726-11e7-4438-b947-d2ae53f58c0b.jpg'
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue