mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-12 01:50:07 -04:00
Merge pull request #1234 from iptv-org/fix-magentatv.at
Fix magentatv.at
This commit is contained in:
commit
6e6ace6e21
7 changed files with 138 additions and 89 deletions
1
sites/magentatv.at/__data__/content_0000.json
Normal file
1
sites/magentatv.at/__data__/content_0000.json
Normal file
File diff suppressed because one or more lines are too long
1
sites/magentatv.at/__data__/content_0600.json
Normal file
1
sites/magentatv.at/__data__/content_0600.json
Normal file
File diff suppressed because one or more lines are too long
1
sites/magentatv.at/__data__/content_1200.json
Normal file
1
sites/magentatv.at/__data__/content_1200.json
Normal file
File diff suppressed because one or more lines are too long
1
sites/magentatv.at/__data__/content_1800.json
Normal file
1
sites/magentatv.at/__data__/content_1800.json
Normal file
File diff suppressed because one or more lines are too long
1
sites/magentatv.at/__data__/program.json
Normal file
1
sites/magentatv.at/__data__/program.json
Normal file
|
@ -0,0 +1 @@
|
||||||
|
{"imageVersion":"1cjcfg","eventId":"crid:~~2F~~2Fgn.tv~~2F2236391~~2FEP019388320252,imi:af4af994f29354e64878101c0612b17999d0c1a3","channelId":"13TH_STREET_HD","title":"Law & Order: Special Victims Unit","startTime":1667087700,"endTime":1667094000,"mergedId":"184536|de","minimumAge":"16","replayTvMinAge":16,"seriesId":"crid:~~2F~~2Fgn.tv~~2F7896816~~2FSH019388320000","parentSeriesId":"crid:~~2F~~2Fbds.tv~~2F14625541","episodeName":"Mutterinstinkt","seasonNumber":6,"episodeNumber":1,"shortDescription":"Patty Branson wird von einem Jungen in einem Park angegriffen und von diesem verfolgt. Der Junge wurde von Michelle Osborne engagiert, die vorgibt, die leibliche Mutter des Mädchens zu sein. Doch ist dies tatsächlich die Wahrheit?","longDescription":"Patty Branson wird von einem Jungen in einem Park angegriffen und von diesem verfolgt. Der Junge wurde von Michelle Osborne engagiert, die vorgibt, die leibliche Mutter des Mädchens zu sein. Doch ist dies tatsächlich die Wahrheit?","actors":["Christopher Meloni","Mariska Hargitay","Richard Belzer","Dann Florek","Ice-T","BD Wong","Diane Neal","Tamara Tunie","Abigail Breslin","Lea Thompson"],"directors":["Arthur W. Forney"],"producers":["Dick Wolf","Ted Kotcheff","Neal Baer"],"audioLanguages":[{"lang":"de"}],"productionDate":"2004","countryOfOrigin":"US","genres":["Drama-Serie","Krimi Drama","Action","Thriller"],"seriesPremiereAirings":true}
|
|
@ -1,71 +1,122 @@
|
||||||
const axios = require('axios')
|
const axios = require('axios')
|
||||||
const dayjs = require('dayjs')
|
const dayjs = require('dayjs')
|
||||||
|
|
||||||
const API_ENDPOINT = `https://prod.oesp.magentatv.at/oesp/v4/AT/deu/web/programschedules`
|
const API_STATIC_ENDPOINT = 'https://static.spark.magentatv.at/deu/web/epg-service-lite/at'
|
||||||
|
const API_PROD_ENDPOINT = 'https://prod.spark.magentatv.at/deu/web/linear-service/v2'
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
site: 'magentatv.at',
|
site: 'magentatv.at',
|
||||||
ignore: true, // INFO: Request failed with status code 404 (Not Found)
|
request: {
|
||||||
url: function ({ date }) {
|
cache: {
|
||||||
return `${API_ENDPOINT}/${date.format('YYYYMMDD')}/1`
|
ttl: 60 * 60 * 1000 // 1 hour
|
||||||
|
}
|
||||||
|
},
|
||||||
|
url: function ({ date, channel }) {
|
||||||
|
return `${API_STATIC_ENDPOINT}/${channel.lang}/events/segments/${date.format('YYYYMMDDHHmmss')}`
|
||||||
},
|
},
|
||||||
async parser({ content, channel, date }) {
|
async parser({ content, channel, date }) {
|
||||||
let programs = []
|
let programs = []
|
||||||
let items = parseItems(content, channel)
|
let items = parseItems(content, channel)
|
||||||
if (!items.length) return programs
|
if (!items.length) return programs
|
||||||
const d = date.format('YYYYMMDD')
|
|
||||||
const promises = [
|
const promises = [
|
||||||
axios.get(`${API_ENDPOINT}/${d}/2`),
|
axios.get(
|
||||||
axios.get(`${API_ENDPOINT}/${d}/3`),
|
`${API_STATIC_ENDPOINT}/${channel.lang}/events/segments/${date
|
||||||
axios.get(`${API_ENDPOINT}/${d}/4`)
|
.add(6, 'h')
|
||||||
|
.format('YYYYMMDDHHmmss')}`,
|
||||||
|
{
|
||||||
|
responseType: 'arraybuffer'
|
||||||
|
}
|
||||||
|
),
|
||||||
|
axios.get(
|
||||||
|
`${API_STATIC_ENDPOINT}/${channel.lang}/events/segments/${date
|
||||||
|
.add(12, 'h')
|
||||||
|
.format('YYYYMMDDHHmmss')}`,
|
||||||
|
{
|
||||||
|
responseType: 'arraybuffer'
|
||||||
|
}
|
||||||
|
),
|
||||||
|
axios.get(
|
||||||
|
`${API_STATIC_ENDPOINT}/${channel.lang}/events/segments/${date
|
||||||
|
.add(18, 'h')
|
||||||
|
.format('YYYYMMDDHHmmss')}`,
|
||||||
|
{
|
||||||
|
responseType: 'arraybuffer'
|
||||||
|
}
|
||||||
|
)
|
||||||
]
|
]
|
||||||
|
|
||||||
await Promise.allSettled(promises)
|
await Promise.allSettled(promises)
|
||||||
.then(results => {
|
.then(results => {
|
||||||
results.forEach(r => {
|
results.forEach(r => {
|
||||||
if (r.status === 'fulfilled') {
|
if (r.status === 'fulfilled') {
|
||||||
items = items.concat(parseItems(r.value.data, channel))
|
const parsed = parseItems(r.value.data, channel)
|
||||||
|
|
||||||
|
items = items.concat(parsed)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.catch(console.error)
|
.catch(console.error)
|
||||||
items.forEach(item => {
|
|
||||||
|
for (let item of items) {
|
||||||
|
const detail = await loadProgramDetails(item, channel)
|
||||||
programs.push({
|
programs.push({
|
||||||
title: item.t,
|
title: item.title,
|
||||||
|
sub_title: detail.episodeName,
|
||||||
|
description: detail.longDescription,
|
||||||
|
category: detail.genres,
|
||||||
|
actors: detail.actors,
|
||||||
|
directors: detail.directors,
|
||||||
|
producers: detail.producers,
|
||||||
|
season: detail.seasonNumber,
|
||||||
|
episode: detail.episodeNumber,
|
||||||
start: parseStart(item),
|
start: parseStart(item),
|
||||||
stop: parseStop(item)
|
stop: parseStop(item)
|
||||||
})
|
})
|
||||||
})
|
}
|
||||||
|
|
||||||
return programs
|
return programs
|
||||||
},
|
},
|
||||||
async channels() {
|
async channels() {
|
||||||
const data = await axios
|
const data = await axios
|
||||||
.get(`https://prod.oesp.magentatv.at/oesp/v4/AT/deu/web/channels`)
|
.get(`${API_PROD_ENDPOINT}/channels?cityId=65535&language=de&productClass=Orion-DASH`)
|
||||||
.then(r => r.data)
|
.then(r => r.data)
|
||||||
.catch(console.log)
|
.catch(console.log)
|
||||||
|
|
||||||
return data.channels.map(item => {
|
return data.channels.map(item => {
|
||||||
return {
|
return {
|
||||||
lang: 'de',
|
lang: 'de',
|
||||||
site_id: item.id.replace('lgi-at-prodobo-master:101-', ''),
|
site_id: item.id,
|
||||||
name: item.title
|
name: item.name
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function loadProgramDetails(item, channel) {
|
||||||
|
if (!item.id) return {}
|
||||||
|
const url = `${API_PROD_ENDPOINT}/replayEvent/${item.id}?returnLinearContent=true&language=${channel.lang}`
|
||||||
|
const data = await axios
|
||||||
|
.get(url)
|
||||||
|
.then(r => r.data)
|
||||||
|
.catch(console.log)
|
||||||
|
|
||||||
|
return data || {}
|
||||||
|
}
|
||||||
|
|
||||||
function parseStart(item) {
|
function parseStart(item) {
|
||||||
return dayjs(item.s)
|
return dayjs.unix(item.startTime)
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseStop(item) {
|
function parseStop(item) {
|
||||||
return dayjs(item.e)
|
return dayjs.unix(item.endTime)
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseItems(content, channel) {
|
function parseItems(content, channel) {
|
||||||
const data = typeof content === 'string' ? JSON.parse(content) : content
|
if (!content) return []
|
||||||
|
const data = JSON.parse(content)
|
||||||
if (!data || !Array.isArray(data.entries)) return []
|
if (!data || !Array.isArray(data.entries)) return []
|
||||||
const entity = data.entries.find(e => e.o === `lgi-at-prodobo-master:${channel.site_id}`)
|
const channelData = data.entries.find(e => e.channelId === channel.site_id)
|
||||||
|
if (!channelData) return []
|
||||||
|
|
||||||
return entity ? entity.l : []
|
return Array.isArray(channelData.events) ? channelData.events : []
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
// npx epg-grabber --config=sites/magentatv.at/magentatv.at.config.js --channels=sites/magentatv.at/magentatv.at_at.channels.xml --output=guide.xml --days=2
|
// npx epg-grabber --config=sites/magentatv.at/magentatv.at.config.js --channels=sites/magentatv.at/magentatv.at_at.channels.xml --output=guide.xml --days=2
|
||||||
|
|
||||||
const { parser, url } = require('./magentatv.at.config.js')
|
const { parser, url } = require('./magentatv.at.config.js')
|
||||||
|
const fs = require('fs')
|
||||||
|
const path = require('path')
|
||||||
const axios = require('axios')
|
const axios = require('axios')
|
||||||
const dayjs = require('dayjs')
|
const dayjs = require('dayjs')
|
||||||
const utc = require('dayjs/plugin/utc')
|
const utc = require('dayjs/plugin/utc')
|
||||||
|
@ -9,95 +11,86 @@ const customParseFormat = require('dayjs/plugin/customParseFormat')
|
||||||
dayjs.extend(customParseFormat)
|
dayjs.extend(customParseFormat)
|
||||||
dayjs.extend(utc)
|
dayjs.extend(utc)
|
||||||
|
|
||||||
|
const API_STATIC_ENDPOINT = 'https://static.spark.magentatv.at/deu/web/epg-service-lite/at'
|
||||||
|
const API_PROD_ENDPOINT = 'https://prod.spark.magentatv.at/deu/web/linear-service/v2'
|
||||||
|
|
||||||
jest.mock('axios')
|
jest.mock('axios')
|
||||||
|
|
||||||
const date = dayjs.utc('2022-03-09', 'YYYY-MM-DD').startOf('d')
|
const date = dayjs.utc('2022-10-30', 'YYYY-MM-DD').startOf('d')
|
||||||
const channel = {
|
const channel = {
|
||||||
site_id: '13TH_Street_HD',
|
site_id: '13TH_STREET_HD',
|
||||||
xmltv_id: '13thStreet.de'
|
xmltv_id: '13thStreet.de',
|
||||||
|
lang: 'de'
|
||||||
}
|
}
|
||||||
|
|
||||||
it('can generate valid url', () => {
|
it('can generate valid url', () => {
|
||||||
expect(url({ date })).toBe(
|
expect(url({ date, channel })).toBe(`${API_STATIC_ENDPOINT}/de/events/segments/20221030000000`)
|
||||||
'https://prod.oesp.magentatv.at/oesp/v4/AT/deu/web/programschedules/20220309/1'
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('can parse response', done => {
|
it('can parse response', async () => {
|
||||||
const content = `{"entries":[{"o":"lgi-at-prodobo-master:13TH_Street_HD","l":[{"i":"crid:~~2F~~2Fbds.tv~~2F1870513,imi:c83a0bf1b04d6610d0517e63647772c1c8725693","t":"Law & Order: Special Victims Unit","s":1646778600000,"e":1646781300000,"c":"lgi-at-prodobo-master:genre-9","a":false,"r":false,"rm":false,"ad":[],"sl":[]}]}]}`
|
const content = fs.readFileSync(path.resolve(__dirname, '__data__/content_0000.json'))
|
||||||
|
|
||||||
axios.get.mockImplementation(url => {
|
axios.get.mockImplementation(url => {
|
||||||
if (url === 'https://prod.oesp.magentatv.at/oesp/v4/AT/deu/web/programschedules/20220309/2') {
|
if (url === `${API_STATIC_ENDPOINT}/de/events/segments/20221030060000`) {
|
||||||
return Promise.resolve({
|
return Promise.resolve({
|
||||||
data: JSON.parse(
|
data: fs.readFileSync(path.resolve(__dirname, '__data__/content_0600.json'))
|
||||||
`{"entries":[{"o":"lgi-at-prodobo-master:13TH_Street_HD","l":[{"i":"crid:~~2F~~2Fmedia-press.tv~~2F217048123,imi:ee14cfe306cb50502b03c96d58851c32345a9391","t":"FBI: Special Crime Unit","s":1646781300000,"e":1646784000000,"c":"lgi-at-prodobo-master:genre-9","a":false,"r":false,"rm":false,"ad":[],"sl":[]}]}]}`
|
})
|
||||||
)
|
} else if (url === `${API_STATIC_ENDPOINT}/de/events/segments/20221030120000`) {
|
||||||
|
return Promise.resolve({
|
||||||
|
data: fs.readFileSync(path.resolve(__dirname, '__data__/content_1200.json'))
|
||||||
|
})
|
||||||
|
} else if (url === `${API_STATIC_ENDPOINT}/de/events/segments/20221030180000`) {
|
||||||
|
return Promise.resolve({
|
||||||
|
data: fs.readFileSync(path.resolve(__dirname, '__data__/content_1800.json'))
|
||||||
})
|
})
|
||||||
} else if (
|
} else if (
|
||||||
url === 'https://prod.oesp.magentatv.at/oesp/v4/AT/deu/web/programschedules/20220309/3'
|
url ===
|
||||||
|
`${API_PROD_ENDPOINT}/replayEvent/crid:~~2F~~2Fgn.tv~~2F2236391~~2FEP019388320252,imi:af4af994f29354e64878101c0612b17999d0c1a3?returnLinearContent=true&language=de`
|
||||||
) {
|
) {
|
||||||
return Promise.resolve({
|
return Promise.resolve({
|
||||||
data: JSON.parse(
|
data: JSON.parse(fs.readFileSync(path.resolve(__dirname, '__data__/program.json')))
|
||||||
`{"entries":[{"o":"lgi-at-prodobo-master:13TH_Street_HD","l":[{"i":"crid:~~2F~~2Fmedia-press.tv~~2F224431085,imi:805c5a9b6610edb65cdff319a9b080ab5f65a6c8","t":"FBI: Special Crime Unit","s":1646784000000,"e":1646786700000,"c":"lgi-at-prodobo-master:genre-9","a":false,"r":false,"rm":false,"ad":[],"sl":[]}]}]}`
|
|
||||||
)
|
|
||||||
})
|
|
||||||
} else if (
|
|
||||||
url === 'https://prod.oesp.magentatv.at/oesp/v4/AT/deu/web/programschedules/20220309/4'
|
|
||||||
) {
|
|
||||||
return Promise.resolve({
|
|
||||||
data: JSON.parse(
|
|
||||||
`{"entries":[{"o":"lgi-at-prodobo-master:13TH_Street_HD","l":[{"i":"crid:~~2F~~2Fbds.tv~~2F918961,imi:f27353bf910e8849d60e0381fdb2d1f7518ef7a2","t":"Law & Order","s":1646786700000,"e":1646789400000,"c":"lgi-at-prodobo-master:genre-9","a":false,"r":false,"rm":false,"ad":[],"sl":[]}]}]}`
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
return Promise.resolve({ data: '' })
|
return Promise.resolve({ data: '' })
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
parser({ content, channel, date })
|
let results = await parser({ content, channel, date })
|
||||||
.then(result => {
|
results = results.map(p => {
|
||||||
result = result.map(p => {
|
|
||||||
p.start = p.start.toJSON()
|
p.start = p.start.toJSON()
|
||||||
p.stop = p.stop.toJSON()
|
p.stop = p.stop.toJSON()
|
||||||
return p
|
return p
|
||||||
})
|
})
|
||||||
|
|
||||||
expect(result).toMatchObject([
|
expect(results[0]).toMatchObject({
|
||||||
{
|
start: '2022-10-29T23:55:00.000Z',
|
||||||
start: '2022-03-08T22:30:00.000Z',
|
stop: '2022-10-30T01:40:00.000Z',
|
||||||
stop: '2022-03-08T23:15:00.000Z',
|
title: 'Law & Order: Special Victims Unit',
|
||||||
title: 'Law & Order: Special Victims Unit'
|
sub_title: 'Mutterinstinkt',
|
||||||
},
|
description:
|
||||||
{
|
'Patty Branson wird von einem Jungen in einem Park angegriffen und von diesem verfolgt. Der Junge wurde von Michelle Osborne engagiert, die vorgibt, die leibliche Mutter des Mädchens zu sein. Doch ist dies tatsächlich die Wahrheit?',
|
||||||
start: '2022-03-08T23:15:00.000Z',
|
category: ['Drama-Serie', 'Krimi Drama', 'Action', 'Thriller'],
|
||||||
stop: '2022-03-09T00:00:00.000Z',
|
actors: [
|
||||||
title: 'FBI: Special Crime Unit'
|
'Christopher Meloni',
|
||||||
},
|
'Mariska Hargitay',
|
||||||
{
|
'Richard Belzer',
|
||||||
start: '2022-03-09T00:00:00.000Z',
|
'Dann Florek',
|
||||||
stop: '2022-03-09T00:45:00.000Z',
|
'Ice-T',
|
||||||
title: 'FBI: Special Crime Unit'
|
'BD Wong',
|
||||||
},
|
'Diane Neal',
|
||||||
{
|
'Tamara Tunie',
|
||||||
start: '2022-03-09T00:45:00.000Z',
|
'Abigail Breslin',
|
||||||
stop: '2022-03-09T01:30:00.000Z',
|
'Lea Thompson'
|
||||||
title: 'Law & Order'
|
],
|
||||||
}
|
directors: ['Arthur W. Forney'],
|
||||||
])
|
producers: ['Dick Wolf', 'Ted Kotcheff', 'Neal Baer'],
|
||||||
done()
|
season: 6,
|
||||||
|
episode: 1
|
||||||
})
|
})
|
||||||
.catch(done)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('can handle empty guide', done => {
|
it('can handle empty guide', async () => {
|
||||||
parser({
|
let results = await parser({ content: ``, channel, date })
|
||||||
content: `[{"type":"PATH_PARAM","code":"period","reason":"INVALID"}]`,
|
|
||||||
channel,
|
expect(results).toMatchObject([])
|
||||||
date
|
|
||||||
})
|
|
||||||
.then(result => {
|
|
||||||
expect(result).toMatchObject([])
|
|
||||||
done()
|
|
||||||
})
|
|
||||||
.catch(done)
|
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue