mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 00:50:09 -04:00
Merge pull request #2526 from iptv-org/bellezaemporium/fixes/i.mjh
[Fix] i.mjh.nz
This commit is contained in:
commit
2ef74b7743
2 changed files with 23 additions and 16 deletions
|
@ -18,26 +18,25 @@ module.exports = {
|
|||
},
|
||||
maxContentLength: 100 * 1024 * 1024 // 100Mb
|
||||
},
|
||||
url: function ({ channel }) {
|
||||
url({ channel }) {
|
||||
const [path] = channel.site_id.split('#')
|
||||
|
||||
return `${API_ENDPOINT}/${path}.xml`
|
||||
},
|
||||
parser: function ({ content, channel, date }) {
|
||||
parser({ content, channel, date }) {
|
||||
const items = parseItems(content, channel, date)
|
||||
|
||||
let programs = items.map(item => {
|
||||
const programs = items.map(item => {
|
||||
return {
|
||||
...item,
|
||||
title: getTitle(item),
|
||||
description: getDescription(item),
|
||||
categories: getCategories(item)
|
||||
categories: getCategories(item),
|
||||
icon: getIcon(item)
|
||||
}
|
||||
})
|
||||
|
||||
programs = mergeMovieParts(programs)
|
||||
|
||||
return programs
|
||||
return mergeMovieParts(programs)
|
||||
},
|
||||
async channels({ provider }) {
|
||||
const providers = {
|
||||
|
@ -104,14 +103,14 @@ module.exports = {
|
|||
nz: [{ path: 'nz/epg', lang: 'en' }]
|
||||
}
|
||||
|
||||
let channels = []
|
||||
const channels = []
|
||||
|
||||
const providerOptions = providers[provider]
|
||||
for (const option of providerOptions) {
|
||||
const xml = await axios
|
||||
.get(`${API_ENDPOINT}/${option.path}.xml`)
|
||||
.then(r => r.data)
|
||||
.catch(console.log)
|
||||
.catch(console.error)
|
||||
const data = parser.parse(xml)
|
||||
|
||||
data.channels.forEach(item => {
|
||||
|
@ -128,7 +127,7 @@ module.exports = {
|
|||
}
|
||||
|
||||
function mergeMovieParts(programs) {
|
||||
let output = []
|
||||
const output = []
|
||||
|
||||
programs.forEach(prog => {
|
||||
let prev = output[output.length - 1]
|
||||
|
@ -160,6 +159,10 @@ function getCategories(item) {
|
|||
return item.category.map(c => c.value)
|
||||
}
|
||||
|
||||
function getIcon(item) {
|
||||
return item.icon && item.icon.length ? item.icon[0] : null
|
||||
}
|
||||
|
||||
function parseItems(content, channel, date) {
|
||||
try {
|
||||
const curr_day = date
|
||||
|
@ -168,10 +171,14 @@ function parseItems(content, channel, date) {
|
|||
const data = parser.parse(content)
|
||||
if (!data || !Array.isArray(data.programs)) return []
|
||||
|
||||
return data.programs.filter(
|
||||
p =>
|
||||
p.channel === site_id && dayjs(p.start, 'YYYYMMDDHHmmss ZZ').isBetween(curr_day, next_day)
|
||||
)
|
||||
return data.programs
|
||||
.filter(p => p.channel === site_id && dayjs(p.start, 'YYYYMMDDHHmmss ZZ').isBetween(curr_day, next_day))
|
||||
.map(p => {
|
||||
if (Array.isArray(p.date) && p.date.length) {
|
||||
p.date = p.date[0]
|
||||
}
|
||||
return p
|
||||
})
|
||||
} catch (error) {
|
||||
return []
|
||||
}
|
||||
|
|
|
@ -29,10 +29,10 @@ it('can parse response', () => {
|
|||
start: '2023-06-23T07:14:32.000Z',
|
||||
stop: '2023-06-23T09:09:36.000Z',
|
||||
title: 'Killers Within',
|
||||
date: ['20180101'],
|
||||
date: '20180101',
|
||||
description:
|
||||
'With her son being held captive by a criminal gang, police officer Amanda Doyle, together with her ex-husband and three unlikely allies, takes part in a desperate plot to hold a wealthy banker and his family to ransom. But this is no ordinary family.',
|
||||
icon: ['https://provider-static.plex.tv/epg/images/thumbnails/darkmatter-tv-fallback.jpg'],
|
||||
icon: 'https://provider-static.plex.tv/epg/images/thumbnails/darkmatter-tv-fallback.jpg',
|
||||
categories: ['Movie']
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue