mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 09:00:07 -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
|
maxContentLength: 100 * 1024 * 1024 // 100Mb
|
||||||
},
|
},
|
||||||
url: function ({ channel }) {
|
url({ channel }) {
|
||||||
const [path] = channel.site_id.split('#')
|
const [path] = channel.site_id.split('#')
|
||||||
|
|
||||||
return `${API_ENDPOINT}/${path}.xml`
|
return `${API_ENDPOINT}/${path}.xml`
|
||||||
},
|
},
|
||||||
parser: function ({ content, channel, date }) {
|
parser({ content, channel, date }) {
|
||||||
const items = parseItems(content, channel, date)
|
const items = parseItems(content, channel, date)
|
||||||
|
|
||||||
let programs = items.map(item => {
|
const programs = items.map(item => {
|
||||||
return {
|
return {
|
||||||
...item,
|
...item,
|
||||||
title: getTitle(item),
|
title: getTitle(item),
|
||||||
description: getDescription(item),
|
description: getDescription(item),
|
||||||
categories: getCategories(item)
|
categories: getCategories(item),
|
||||||
|
icon: getIcon(item)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
programs = mergeMovieParts(programs)
|
return mergeMovieParts(programs)
|
||||||
|
|
||||||
return programs
|
|
||||||
},
|
},
|
||||||
async channels({ provider }) {
|
async channels({ provider }) {
|
||||||
const providers = {
|
const providers = {
|
||||||
|
@ -104,14 +103,14 @@ module.exports = {
|
||||||
nz: [{ path: 'nz/epg', lang: 'en' }]
|
nz: [{ path: 'nz/epg', lang: 'en' }]
|
||||||
}
|
}
|
||||||
|
|
||||||
let channels = []
|
const channels = []
|
||||||
|
|
||||||
const providerOptions = providers[provider]
|
const providerOptions = providers[provider]
|
||||||
for (const option of providerOptions) {
|
for (const option of providerOptions) {
|
||||||
const xml = await axios
|
const xml = await axios
|
||||||
.get(`${API_ENDPOINT}/${option.path}.xml`)
|
.get(`${API_ENDPOINT}/${option.path}.xml`)
|
||||||
.then(r => r.data)
|
.then(r => r.data)
|
||||||
.catch(console.log)
|
.catch(console.error)
|
||||||
const data = parser.parse(xml)
|
const data = parser.parse(xml)
|
||||||
|
|
||||||
data.channels.forEach(item => {
|
data.channels.forEach(item => {
|
||||||
|
@ -128,7 +127,7 @@ module.exports = {
|
||||||
}
|
}
|
||||||
|
|
||||||
function mergeMovieParts(programs) {
|
function mergeMovieParts(programs) {
|
||||||
let output = []
|
const output = []
|
||||||
|
|
||||||
programs.forEach(prog => {
|
programs.forEach(prog => {
|
||||||
let prev = output[output.length - 1]
|
let prev = output[output.length - 1]
|
||||||
|
@ -160,6 +159,10 @@ function getCategories(item) {
|
||||||
return item.category.map(c => c.value)
|
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) {
|
function parseItems(content, channel, date) {
|
||||||
try {
|
try {
|
||||||
const curr_day = date
|
const curr_day = date
|
||||||
|
@ -168,10 +171,14 @@ function parseItems(content, channel, date) {
|
||||||
const data = parser.parse(content)
|
const data = parser.parse(content)
|
||||||
if (!data || !Array.isArray(data.programs)) return []
|
if (!data || !Array.isArray(data.programs)) return []
|
||||||
|
|
||||||
return data.programs.filter(
|
return data.programs
|
||||||
p =>
|
.filter(p => p.channel === site_id && dayjs(p.start, 'YYYYMMDDHHmmss ZZ').isBetween(curr_day, next_day))
|
||||||
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) {
|
} catch (error) {
|
||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,10 +29,10 @@ it('can parse response', () => {
|
||||||
start: '2023-06-23T07:14:32.000Z',
|
start: '2023-06-23T07:14:32.000Z',
|
||||||
stop: '2023-06-23T09:09:36.000Z',
|
stop: '2023-06-23T09:09:36.000Z',
|
||||||
title: 'Killers Within',
|
title: 'Killers Within',
|
||||||
date: ['20180101'],
|
date: '20180101',
|
||||||
description:
|
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.',
|
'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']
|
categories: ['Movie']
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue